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.

Moving third person object on all axes

2 posters

Go down

Moving third person object on all axes Empty Moving third person object on all axes

Post  CadetCrusher Wed Oct 07, 2009 4:33 pm

Ok, this is a pretty noob question, but here it is:

How do I move an object through space, on all axes? Like a space ship that can rotate an move up or down on x, y, and z. Using setLinearVelocity() is fine and good for moving an object the remains on the ground and only needs to move on the y and x axes, but how do I move on the z? I'm using the tutorial09 as a learning tool (because it has an example of 3rd person camera), but I can't seem to figure out what I need to do. Hence my plea to you fine people. Any help would be greatly appreciated.

Thanks.

CadetCrusher

Posts : 21
Join date : 2009-10-07

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

Post  sio2interactive Wed Oct 07, 2009 5:21 pm

setLinearVelocity is exactly what you need... as you are navigating in 0 gravity... the direction vector passed to setLinearVelocity can be concatenated using the different values of your navigation controller, it is not only good for "ground" movement but for all kind of directional movements.
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

Post  CadetCrusher Wed Oct 07, 2009 5:48 pm

Thanks for the reply! I appreciate it.

Forgive my ignorance, but how would I concatenate the direction value to reflect where the player is pointing?

setLinearVelocity(btVector3(x, y, ?))

I'm loving the SDK so far, thanks!

CadetCrusher

Posts : 21
Join date : 2009-10-07

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

Post  sio2interactive Wed Oct 07, 2009 5:56 pm

Well you got a direction vector (where the ship points to), then if the player hold up left, you want to move up and left... so... you take the direction vector and do the necessary rotation on Z then you add the up factor to it... the result is a new direction vector, "concatenated" (maybe I shouldn't use that word actually).
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

Post  CadetCrusher Wed Oct 07, 2009 10:07 pm

I hate to ask for more help, but, my 3d fundamentals are lacking (you have to start somewhere right?). So, here's what I'm doing (mostly based on tutorial09):

Code:

// this code is heavily edited for brevity, I've only listed what I believe to be important

// rotate the player ("ship") to the correct orientation
// here the variable object is the ship
object->_SIOtransform->rot->z = ROTZ;
object->_SIOtransform->rot->x = ROTX;
object->_SIOtransform->rot->y = ROTY;

sio2TransformBindMatrix(object->_SIO2transform);

// do all the collision detection and placement for the camera (same as tutorial09, omitted here for brevity)

object->_SIO2objectphysic->_btRigidBody->setActivationState(ACTIVE_TAG);
object->_SIO2objectphysic->_btRigidBody->setLinearVelocity(btVector3( (MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->x) * SPEED, (MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->Y) * SPEED, (MOV_DIR * sio2->_SIO2camera->_SIO2transform->dir->z) * SPEED));


The above works in the x,y plane but I can't figure out how to make the ship move in the direction it is pointing. The value of object->_SIO2transform->dir is (0,0,0). What am I missing? How do I correctly calculate the direction vector for the ship and the correct velocity vector?

Thanks again for all your help.

CadetCrusher

Posts : 21
Join date : 2009-10-07

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

Post  sio2interactive Thu Oct 08, 2009 9:34 am

dir == normalize( linear velocity )
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

Post  CadetCrusher Fri Oct 09, 2009 11:03 am

Thanks for helping out. But it seems I need to get my 3D fundamentals a lot better because I'm just not seeing how all this comes together. I've been coding for years, just not games, so this is all new to me. Does anyone have any examples (sample code) of how to achieve the movement I'm attempting? Or at the very least a good book/website for learning the fundamentals of 3D game development?

Thanks!

CadetCrusher

Posts : 21
Join date : 2009-10-07

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

Post  sio2interactive Fri Oct 09, 2009 11:17 am

The SIO2_SDK is a good base to start... go through all the tutorials & video tutorials, then when you are ready you might consider the purchase of MeditationGarden to check how to create an advanced game architecture, link everything together etc...
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 45
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Moving third person object on all axes Empty Re: Moving third person object on all axes

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