physics object movement
4 posters
physics object movement
I have cube object. I have added physics property(rigid body) to it. I want to throw this cube at a target.
I'm able to throw the cube by setting linear velocity property of the rigid body but i'm not able to throw it in the direction that i wanted.
I modified the direction transformation(_SIO2transform->dir) of the cube but it did not help me. Please do let me know what properties needs to be set to move the cube in the required direction.Thanks in advance.
I'm able to throw the cube by setting linear velocity property of the rigid body but i'm not able to throw it in the direction that i wanted.
I modified the direction transformation(_SIO2transform->dir) of the cube but it did not help me. Please do let me know what properties needs to be set to move the cube in the required direction.Thanks in advance.
praveencastelino- Posts : 7
Join date : 2009-05-20
Re: physics object movement
the dir of the object doesn't matter, the velocity does.
_SIO2object->_btRigidBody->setLinearVelocity(btVector3( ((10,
0,
0) );
This will increase the objects x position. Just try put different values in this function to see how it works
_SIO2object->_btRigidBody->setLinearVelocity(btVector3( ((10,
0,
0) );
This will increase the objects x position. Just try put different values in this function to see how it works
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: physics object movement
Thanks for the reply.
By giving different values to linear velocity moves the cube in the different direction(eg: +/- values moved the cube in the opposite direction ,laterally).
It seems like the the direction of movement also depends on where the centre of mass(/gravity) is located.
>>I wanted little more than this:D . Eg: consider an arrow(rigid body) object. I always wanted to move the arrow in the direction where the tip of the arrow is pointing to.As of now it moves laterally/vertically.It does not move in the direction where the arrow tip is pointing to? .
>>There is one more problem. If the arrow moves out of the terrain then using the function sio2PhysicResetObject() does not reset the arrow to its initial position but calling sio2PhysicResetObject() function when the arrow is flying, resets the arrow to its initial position.
>>Is it possible to hold the object(rigid body) in air and rotate the object in the air? As of it simply falls down.
Thanks in advance.
By giving different values to linear velocity moves the cube in the different direction(eg: +/- values moved the cube in the opposite direction ,laterally).
It seems like the the direction of movement also depends on where the centre of mass(/gravity) is located.
>>I wanted little more than this:D . Eg: consider an arrow(rigid body) object. I always wanted to move the arrow in the direction where the tip of the arrow is pointing to.As of now it moves laterally/vertically.It does not move in the direction where the arrow tip is pointing to? .
>>There is one more problem. If the arrow moves out of the terrain then using the function sio2PhysicResetObject() does not reset the arrow to its initial position but calling sio2PhysicResetObject() function when the arrow is flying, resets the arrow to its initial position.
>>Is it possible to hold the object(rigid body) in air and rotate the object in the air? As of it simply falls down.
Thanks in advance.
praveencastelino- Posts : 7
Join date : 2009-05-20
Re: physics object movement
math, math and more math :ppraveencastelino wrote:
>>I wanted little more than this:D . Eg: consider an arrow(rigid body) object. I always wanted to move the arrow in the direction where the tip of the arrow is pointing to.As of now it moves laterally/vertically.It does not move in the direction where the arrow tip is pointing to? .
_SIO2object->_SIO2transform->rot? remember to call sio2TransformBindMatrix( player.playerObj->_SIO2transform ); after rotating your object. For holding it in air do you mean that it must move with the same z pos at all time and don't drop too much(don't fall down on the ground)?praveencastelino wrote:
>>Is it possible to hold the object(rigid body) in air and rotate the object in the air? As of it simply falls down.
oioioi- Posts : 136
Join date : 2008-12-02
Location : Norway
Re: physics object movement
Are you wanting the arrow to follow a parabolic arc?praveencastelino wrote:>>I wanted little more than this:D . Eg: consider an arrow(rigid body) object. I always wanted to move the arrow in the direction where the tip of the arrow is pointing to.As of now it moves laterally/vertically.It does not move in the direction where the arrow tip is pointing to? .
Re: physics object movement
Thanks for the reply.
I'm looking into the bullet physics engine.Any suggestions on this will be a great help to me. Thanks in advance.
Yes. I had done it in 2D without using any physics engine. I knew the initial velocity and the angle. Hence I calculated all the points.Jawdy wrote:
Are you wanting the arrow to follow a parabolic arc?
I'm looking into the bullet physics engine.Any suggestions on this will be a great help to me. Thanks in advance.
praveencastelino- Posts : 7
Join date : 2009-05-20
Re: physics object movement
You mean something like this:
vec3 *target, *arrow, *vel;
sio2Diff( target, arrow, vel );
sio2Normalize( vel, vel );
Multiply this vel by whatever velocity you want (try 40.0) and then use this new vector in a call to setLinearVelocity().
Good luck,
--yarri
vec3 *target, *arrow, *vel;
sio2Diff( target, arrow, vel );
sio2Normalize( vel, vel );
Multiply this vel by whatever velocity you want (try 40.0) and then use this new vector in a call to setLinearVelocity().
Good luck,
--yarri
yarri- Posts : 81
Join date : 2009-04-10
Re: physics object movement
Thanks for the inputs. I have tried the options listed. However, I ran into some problems.
No doubt the arrow moves in the direction of the target. But since the center of gravity is the middle of the arrow, the arrow moves laterally and hits the target. How do we then align the tip of the arrow to the target before the velocity kicks in?
However our problem is a wee bit different. The user aligns the arrow and fires it. So
1. The linear velocity vector is determined by the direction which the user chooses.
2. When the user fires , the arrow tip ( and hence the arrow) should move in this direction determined by the vector.
So I guess all I want is a vector that aligns with the arrow. I can multiply it by a factor and set this vector as a linear velocity of the arrow.
Now the arrow moves in the direction it is pointed with the speed I want.
Now to the question :-). How do we get this vector which aligns with the arrow?
Thanks a lot for being patient and keeping up with the replies.
Regards,
Praveen.
yarri wrote:You mean something like this:
vec3 *target, *arrow, *vel;
sio2Diff( target, arrow, vel );
sio2Normalize( vel, vel );
Multiply this vel by whatever velocity you want (try 40.0) and then use this new vector in a call to setLinearVelocity().
No doubt the arrow moves in the direction of the target. But since the center of gravity is the middle of the arrow, the arrow moves laterally and hits the target. How do we then align the tip of the arrow to the target before the velocity kicks in?
However our problem is a wee bit different. The user aligns the arrow and fires it. So
1. The linear velocity vector is determined by the direction which the user chooses.
2. When the user fires , the arrow tip ( and hence the arrow) should move in this direction determined by the vector.
So I guess all I want is a vector that aligns with the arrow. I can multiply it by a factor and set this vector as a linear velocity of the arrow.
Now the arrow moves in the direction it is pointed with the speed I want.
Now to the question :-). How do we get this vector which aligns with the arrow?
Thanks a lot for being patient and keeping up with the replies.
Regards,
Praveen.
praveencastelino- Posts : 7
Join date : 2009-05-20
Re: physics object movement
One more help needed....... If I want to get the tip of the arrow, how do i get it? I got the vertices from the arrow object.
but it looks like these points are stored in non linear manner. So, is there any way to find the Head and Tail vertices of the arrow.
Thanks in advance.
- Code:
_SIO2object->buf = ( unsigned char * ) sio2MapBuffer( _SIO2object->vbo, GL_ARRAY_BUFFER );
but it looks like these points are stored in non linear manner. So, is there any way to find the Head and Tail vertices of the arrow.
Thanks in advance.
praveencastelino- Posts : 7
Join date : 2009-05-20
Similar topics
» physics object inside another physics object
» Camera / object movement
» Track movement
» character movement advice
» rotate a physics object?
» Camera / object movement
» Track movement
» character movement advice
» rotate a physics object?
Permissions in this forum:
You cannot reply to topics in this forum