How can I move my object?

Please don't post Bullet support questions here, use the above forums instead.
Mars_999
Posts: 25
Joined: Tue Dec 04, 2007 7:48 pm

How can I move my object?

Post by Mars_999 »

I can move one of my objects by calling setWorldTransform(), but for some reason some of my objects are not updating when I call setWorldTransform()?


What I have is coins falling from the sky and when they hit the ground or hit by the user, I want to randomly place them up in the air again at some other point. I tried doing this but no luck...

xform.setIdentity();
xform.setOrigin(btVector3(0,0,0));
mit->second->SetMatrixWorldTransform(xform);
mit->second->GetRigidBody()->clearForces();
mit->second->GetRigidBody()->setLinearVelocity(btVector3(0,0,0));
mit->second->GetRigidBody()->setAngularVelocity(btVector3(0,0,0));

I have looked at the BtRidgidBody and the value for getWorldTransform() remains unchanged even after I call setWorldTransform()? Would the object that hits the ground become inactive and not allow updates anymore?

Thanks
justin
Posts: 8
Joined: Fri Mar 04, 2011 1:19 pm

Re: How can I move my object?

Post by justin »

Mars_999 wrote:I can move one of my objects by calling setWorldTransform(), but for some reason some of my objects are not updating when I call setWorldTransform()?


What I have is coins falling from the sky and when they hit the ground or hit by the user, I want to randomly place them up in the air again at some other point. I tried doing this but no luck...

xform.setIdentity();
xform.setOrigin(btVector3(0,0,0));
mit->second->SetMatrixWorldTransform(xform);
mit->second->GetRigidBody()->clearForces();
mit->second->GetRigidBody()->setLinearVelocity(btVector3(0,0,0));
mit->second->GetRigidBody()->setAngularVelocity(btVector3(0,0,0));

I have looked at the BtRidgidBody and the value for getWorldTransform() remains unchanged even after I call setWorldTransform()? Would the object that hits the ground become inactive and not allow updates anymore?

Thanks
so, what's the coordinate of the ground and the place you want to place the coin again?
Mars_999
Posts: 25
Joined: Tue Dec 04, 2007 7:48 pm

Re: How can I move my object?

Post by Mars_999 »

Fixed it I used setCenterOfMassTransform()

Thanks
Xuhai.Tang
Posts: 16
Joined: Wed Feb 23, 2011 4:54 pm

Re: How can I move my object?

Post by Xuhai.Tang »

I used the similar code

iter->RigidBody()->setLinearVelocity((btVector3(iter->CentralVelocity().LinearX, iter->CentralVelocity().LinearY, iter->CentralVelocity().LinearZ)));
iter->RigidBody()->setAngularVelocity((btVector3(iter->CentralVelocity().AngularX, iter->CentralVelocity().AngularY, iter->CentralVelocity().AngularZ)));
iter->RigidBody()->applyForce(btVector3(fx, fy, fz), btVector3(px, py, pz));

It works well.

When did you watch the value? Maybe you should watch the motion after one step of simulation.
Last edited by Xuhai.Tang on Fri Apr 01, 2011 1:58 pm, edited 1 time in total.
Mars_999
Posts: 25
Joined: Tue Dec 04, 2007 7:48 pm

Re: How can I move my object?

Post by Mars_999 »

Xuhai.Tang wrote:I used the similar code

iter->RigidBody()->setLinearVelocity((btVector3(iter->CentralVelocity().LinearX, iter->CentralVelocity().LinearY, iter->CentralVelocity().LinearZ)));
iter->RigidBody()->setAngularVelocity((btVector3(iter->CentralVelocity().AngularX, iter->CentralVelocity().AngularY, iter->CentralVelocity().AngularZ)));
iter->RigidBody()->applyForce(btVector3(fx, fy, fz), btVector3(px, py, pz));

It works well.

When did you watch the value? Maybe you should watch the motion after one step of simulation.

I am not sure if I called applyForce()....