FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

physics object movement

4 posters

Go down

physics object movement Empty physics object movement

Post  praveencastelino Tue May 26, 2009 8:22 am

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. Rolling Eyes
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

Back to top Go down

physics object movement Empty Re: physics object movement

Post  oioioi Tue May 26, 2009 9:27 am

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

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

Back to top Go down

physics object movement Empty Re: physics object movement

Post  praveencastelino Wed May 27, 2009 7:42 am

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? Mad.
>>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

Back to top Go down

physics object movement Empty Re: physics object movement

Post  oioioi Wed May 27, 2009 8:34 am

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? Mad.
math, math and more math :p


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.
_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)?

oioioi

Posts : 136
Join date : 2008-12-02
Location : Norway

Back to top Go down

physics object movement Empty Re: physics object movement

Post  Jawdy Wed May 27, 2009 8:41 am

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? Mad.
Are you wanting the arrow to follow a parabolic arc?
Jawdy
Jawdy

Posts : 65
Join date : 2009-03-17
Location : UK

http://www.gaslightgames.co.uk

Back to top Go down

physics object movement Empty Re: physics object movement

Post  praveencastelino Thu May 28, 2009 9:46 pm

Thanks for the reply.

Jawdy wrote:
Are you wanting the arrow to follow a parabolic arc?
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.
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

Back to top Go down

physics object movement Empty Re: physics object movement

Post  yarri Fri May 29, 2009 1:00 am

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

yarri

Posts : 81
Join date : 2009-04-10

Back to top Go down

physics object movement Empty Re: physics object movement

Post  praveencastelino Sat May 30, 2009 5:55 am

Thanks for the inputs. I have tried the options listed. However, I ran into some problems.
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

Back to top Go down

physics object movement Empty Re: physics object movement

Post  praveencastelino Mon Jun 01, 2009 8:38 am

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.

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

Back to top Go down

physics object movement Empty Re: physics object movement

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum