Page 1 of 1

setLinearVelocity - object not moving

Posted: Thu Aug 20, 2015 10:16 pm
by _hiya_
Hi,
I am having trouble moving an object by using the "setLinearVelocity" method
the object just spins (very fastly) in air but doesnt move.
What I am trying to do is to shoot the object like in the bullet "DemoApplication" example
My code is almost identical to the example code.

what's wrong, any ideas?

Re: setLinearVelocity - object not moving

Posted: Fri Aug 21, 2015 5:43 am
by _hiya_
if my question wasn't clear, I am trying to do the same thing like shootBox example

DemoApplication::shootBox(const btVector3& destination)

but when I use it in my code the box just spins and doesnt move forward.

I tried to change gravity, mass etc. but it just doesn't move.
I am creating the rigidbody, btDynamicsWorld etc like in the sample code.

Re: setLinearVelocity - object not moving

Posted: Fri Aug 21, 2015 6:14 pm
by anthrax11
Seems odd. You should post the physics side of the code.

Re: setLinearVelocity - object not moving

Posted: Sat Aug 22, 2015 12:33 pm
by _hiya_
btRigidBody* body = btRigidBody::upcast(pObject);
body->getWorldTransform().setRotation(btQuaternion(0, 0, 0, 1));
body->setLinearVelocity(linVel);
body->setAngularVelocity(btVector3(0, 0, 0));

body->setCcdMotionThreshold(extends[0]);
body->setCcdSweptSphereRadius(extends[0] * 0.9f);

extends is from bounding box of the mesh model
linVel is just forward vector of camera multiplied by speed value

Re: setLinearVelocity - object not moving

Posted: Mon Aug 24, 2015 6:37 am
by Basroil
_hiya_ wrote: extends is from bounding box of the mesh model
linVel is just forward vector of camera multiplied by speed value
The forward vector is non-zero?

The GL demo app version of the shootbox does not use the camera orientation directly, rather it uses the camera position and target position as the forward vector, then normalizes it and multiplies it by a given speed. You should check DemoApplication.cpp line 562 for more information.

Re: setLinearVelocity - object not moving

Posted: Wed Aug 26, 2015 10:44 am
by _hiya_
forward vector is correct and the object spawns at the right position. ( I make it spawn 128 units in front of camera) but it just spins and doesnt move forward

maybe I am doing something wrong with gravity or other setup stuff setCcdSweptSphereRadius or setCcdMotionThreshold etc...

Any suggestions?