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
How can I move my object?
-
- Posts: 8
- Joined: Fri Mar 04, 2011 1:19 pm
Re: How can I move my object?
so, what's the coordinate of the ground and the place you want to place the coin again?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
-
- Posts: 25
- Joined: Tue Dec 04, 2007 7:48 pm
Re: How can I move my object?
Fixed it I used setCenterOfMassTransform()
Thanks
Thanks
-
- Posts: 16
- Joined: Wed Feb 23, 2011 4:54 pm
Re: How can I move my object?
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.
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.
-
- Posts: 25
- Joined: Tue Dec 04, 2007 7:48 pm
Re: How can I move my object?
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()....