Page 9 of 31

Posted: Sun Nov 14, 2010 7:37 pm
by Virion
how to move an object without accelerating and decelerating? sorry i'm new to game physics.

Posted: Sun Nov 14, 2010 9:54 pm
by cobra
Virion:

Code: Select all

irr::matrix4 mat = rigidbody->getWorldTransform();
mat.setTranslation(irr::core::vector3df(20,20,20));

rigidbody->setWorldTransform(mat);

Posted: Mon Nov 15, 2010 5:14 am
by Virion
thx for the help cobra. now i'm trying to rotate my object when i pressing a button. it works fine at first but when it reaches 90 degree it won't rotate anymore.

Code: Select all

matrix4 mat = body->getWorldTransform();
vector3df rot = mat.getRotationDegrees();
mat.setRotationDegrees(rot - vector3df(0, 1 * speed, 0));
body->setWorldTransform(mat);
thx in advance :oops:

Posted: Mon Nov 15, 2010 6:31 am
by Brainsaw
Sounds like a gimbal lock to me (an issue that did cost me about a week to workaround in IrrOde).

In IrrOde it works like this: when a Gimbal Lock is detected the Irrlicht scenenode's rotation is not updated (Gimbal locks are a problem of the Euler angles, quaternions don't have such problems).

Posted: Mon Nov 15, 2010 5:44 pm
by Zurzaza
cobra wrote:Virion:

Code: Select all

irr::matrix4 mat = rigidbody->getWorldTransform();
mat.setTranslation(irr::core::vector3df(20,20,20));

rigidbody->setWorldTransform(mat);
it won't work if the body isn't set as kinematic body. In order to move an object "legally" into the bullet world is to set it as kinematic body

Posted: Mon Nov 15, 2010 6:17 pm
by Virion
Zurzaza wrote:
cobra wrote:Virion:

Code: Select all

irr::matrix4 mat = rigidbody->getWorldTransform();
mat.setTranslation(irr::core::vector3df(20,20,20));

rigidbody->setWorldTransform(mat);
it won't work if the body isn't set as kinematic body. In order to move an object "legally" into the bullet world is to set it as kinematic body
weird. i set my body to kinematics and it won't work anymore.

Code: Select all

body->setCollisionFlags(ECF_KINEMATIC_OBJECT);
then i set it back to character object and it works again. but still the rotation is locked at 90 degree.

Posted: Mon Nov 15, 2010 8:48 pm
by Zurzaza
Virion wrote: weird. i set my body to kinematics and it won't work anymore.

Code: Select all

body->setCollisionFlags(ECF_KINEMATIC_OBJECT);
then i set it back to character object and it works again. but still the rotation is locked at 90 degree.
hmm..it looks very strange.
From the bullet official manual (p.22), it only says that kinematic bodies can be animated by te user:

Kinematic rigidbodies: can be animated by the user, but there will be only one-way interaction: dynamic objects will be pushed away but there is no influence from dynamics objects
So, i can't explain why your object can be moved

Posted: Tue Nov 16, 2010 1:52 am
by cobra
Zurzaza:

It most certainly can be positioned without first being set to kinematic.

You misunderstood what the documentation says.

Kinematic objects are useful for things like character controllers, because they will affect dynamic objects but will themselves not be affected.


Virion:

I'll have to look in to your problem when I have more time. Sorry.
If you figure it out before then, please let me know.

Posted: Sat Nov 20, 2010 8:22 am
by griffin2000
Looks very cool. Apologies if I'm being dense, but how do you go about building it on Visual Studio ?

I see some CMake files further down in the source tree (in some of the sub folders of irrBullet-0.1.65\source\bheaders\Bullet\BulletCollision) but nothing in the root Source folder.

Posted: Sat Nov 20, 2010 4:58 pm
by cobra
griffin2000:

I believe I posted some light instructions in previous pages of this thread.

Also, irrBullet 0.1.7 will have Visual Studio project files and pre-built libs.

help needed!

Posted: Sat Nov 20, 2010 5:52 pm
by Leo [Teh one]
---problem solved---
cobra, thanks for so cool wrapper!

Posted: Sat Nov 20, 2010 8:13 pm
by ent1ty
Virion wrote:thx for the help cobra. now i'm trying to rotate my object when i pressing a button. it works fine at first but when it reaches 90 degree it won't rotate anymore.

Code: Select all

matrix4 mat = body->getWorldTransform();
vector3df rot = mat.getRotationDegrees();
mat.setRotationDegrees(rot - vector3df(0, 1 * speed, 0));
body->setWorldTransform(mat);
thx in advance :oops:
The problem with this is, that getWorldTransform() returnd wrong rotation. My workaround was, to store the rotation manually in a variable, instead of getting it from the body

Code: Select all

int RotY= 0;
IRigidBody* Body;

...

void rotate(float degrees)
{
    rotY+= degrees;
    matrix4 mat= body->getWorldTransform(); //we get the transform, just to get correct translation and won't use the rotation from it
    mat.setRotationDegrees(vector3df(0, rotY, 0));
    body->setWorldTransform(mat);
}

Posted: Sun Nov 21, 2010 11:42 pm
by cobra
You could also try changing "vector3df rot" from mat.getRotationDegrees() to

Code: Select all

body->getCollisionShape()->getSceneNode()->getAbsoluteTransformation().getRotation()

I'll fix this for 0.1.7. Apparently copying over OpenGL matrix from Bullet to Irrlicht doesn't have the right rotation, but from Irrlicht to Bullet it does.

Problem compiling

Posted: Thu Dec 16, 2010 7:43 pm
by Birdman
This files gives me trouble in Softbody.h:
#include <map.h>
#include <vector.h>
Both files seems to be missing, maybe i did something wrong?

This happens to me with 1.65 only.

Re: Problem compiling

Posted: Thu Dec 16, 2010 8:15 pm
by cobra
Birdman wrote:This files gives me trouble in Softbody.h:
#include <map.h>
#include <vector.h>
Both files seems to be missing, maybe i did something wrong?

This happens to me with 1.65 only.

Change map.h to just map, and vector.h to just vector.


This is already fixed for 0.1.7, which will be out by January 5th.