Cannot set Transform for RigidBody?

Post Reply
joehot200
Posts: 15
Joined: Wed Apr 23, 2014 9:47 am

Cannot set Transform for RigidBody?

Post by joehot200 »

Hi, I'm trying to directly set an object's yaw, but directly setting the Transform does not seem to be working.

Code: Select all

Transform worldTr = new Transform();
		worldTr = body.getWorldTransform(worldTr);
		Quat4f quatr = new Quat4f();
		quatr = worldTr.getRotation(quatr);
		QuaternionUtil.setEuler(quatr, 0, 0, rotation);
		worldTr.setRotation(quatr);
		body.setWorldTransform(worldTr);
Using

Code: Select all

setRotation()
instead of

Code: Select all

setEuler()
does not make a difference: It still returns 0.

I'm using JBullet, by the way.

The RigidBody simply does not rotate. It always stays at a rotation of 0, and it never changes.

What is wrong and how can I fix it?
aviator
Posts: 13
Joined: Thu Apr 02, 2015 5:15 pm

Re: Cannot set Transform for RigidBody?

Post by aviator »

joehot200 wrote:Hi, I'm trying to directly set an object's yaw, but directly setting the Transform does not seem to be working.

Code: Select all

Transform worldTr = new Transform();
		worldTr = body.getWorldTransform(worldTr);
		Quat4f quatr = new Quat4f();
		quatr = worldTr.getRotation(quatr);
		QuaternionUtil.setEuler(quatr, 0, 0, rotation);
		worldTr.setRotation(quatr);
		body.setWorldTransform(worldTr);
Using

Code: Select all

setRotation()
instead of

Code: Select all

setEuler()
does not make a difference: It still returns 0.

I'm using JBullet, by the way.

The RigidBody simply does not rotate. It always stays at a rotation of 0, and it never changes.

What is wrong and how can I fix it?
Hello !

One way of doing this could be by creating your own object class, and inherit btActionInterface (#include "BulletDynamics/Dynamics/btActionInterface.h").
In this class define your rigid body and when this is done, you could add another extra method like void move() and in that method you could set object transformation.
RigitBody->setWorldTransform(newTransform);
Post Reply