Rotating Object Points
#1 Members - Reputation: 103
Posted 18 April 2011 - 03:45 AM
I created my ship using dynamic Vertices. To move my ship i simply translate all the vertex points as desired. Walking, and strafing with my ship works fine.
My ship's directional movement is also just fine, by creating a unit vector from the angle of my rotation, i am able to move the ship in any 3D direction.
My problem is when i rotate my ship, my ship stays the exact same, the vertex points do not change. I would like to have the vertex points inside my ship
change as I rotate the ship, so the heading of my ship points to the direction that it is headed. I know that once i shift one point inside my ship I will be able
to shift the rest of the vertexes inside the ship, but I do not know how i am going to shift a point in my desired direction. I think i have to use the angle with
sin or cos and apply it to my point but so far that has yielded bad results, my math is pretty rusty.
I think i may be approaching this problem wrong and I do not have a lot of time to focus on this due to exams, but i really want to figure it out. Is there
anyone who can point me in the right direction? Possibly give me a hint if they know the answer?
Thank you
#2 Members - Reputation: 1900
Posted 18 April 2011 - 04:53 AM
Am I understanding that correctly? Are you transforming the vertices 'by hand'? Or are you using a transform matrix?
#3 Members - Reputation: 103
Posted 18 April 2011 - 01:58 PM
So from what i gather i would store one of points in a transform matrix, and apply the transformations in local space, and then render.
Am i right in assuming i just need to store one point in a transform matrix, and then apply the transformation to all points or would i need
a transformation matrix for each point?
#4 Members - Reputation: 103
Posted 18 April 2011 - 05:41 PM
the problem now is I need my object to rotate around its local axis instead of the origin, so i'll try to figure that out, thanks for the help!
Oh by the way how would i go about storing my object vertices within a local space? Do i have to "manually" figure out the center of my object and use that as the origin?
Or is there a simpler more efficient way?
#5 Members - Reputation: 560
Posted 18 April 2011 - 06:57 PM
Ok i used a transform matrix with a translation matrix and was able to get the object to rotate around the origin.
the problem now is I need my object to rotate around its local axis instead of the origin, so i'll try to figure that out, thanks for the help!
Oh by the way how would i go about storing my object vertices within a local space? Do i have to "manually" figure out the center of my object and use that as the origin?
Or is there a simpler more efficient way?
The model is in local space if you say it is
#6 Members - Reputation: 103
Posted 19 April 2011 - 01:04 AM
the world space.
I was wondering for Rotations this is what my logic is right now...
1.) Go into local space, save the current coordinates of the ship inside the world space
2.) return the ship back to object space (0,0,0) origin
3.) Rotate the ship (which i now i have working
4.) translate the ship back into world space
Also if this is right, do i require a View matrix for my ship to do translations from object to world space?
#7 Members - Reputation: 1900
Posted 19 April 2011 - 01:37 AM
Just to be clear, you shouldn't be modifying the vertices of the ship model at all. Just leave them in local space, and apply a transform via the D3D API to position and orient the ship the way you want it.I was wondering for Rotations this is what my logic is right now...
1.) Go into local space, save the current coordinates of the ship inside the world space
2.) return the ship back to object space (0,0,0) origin
3.) Rotate the ship (which i now i have working)
4.) translate the ship back into world space
Also if this is right, do i require a View matrix for my ship to do translations from object to world space?
#8 Members - Reputation: 103
Posted 19 April 2011 - 02:09 AM
1.) To orient the ship, just apply a transform do not touch vertices
1.1.) This makes sense, but how am I to change the ship's orientation without changing its vertices? Do I move the world instead of the ship?
2.) To move the ship do i just apply another transform, and not touch the vertices in local space as well?
This is because for all of my ships movement, i had been changing the vertices to simulate movement.
Thank you, you may have steered me away from a bad road.
#9 Members - Reputation: 1900
Posted 19 April 2011 - 02:21 AM
Right.1.) To orient the ship, just apply a transform do not touch vertices
Right, assuming a typical setup, you don't want to touch or modify the model vertices at all. In fact, in many cases you'll just stick them in a static vertex buffer and never touch them again.2.) To move the ship do i just apply another transform, and not touch the vertices in local space as well?
This is because for all of my ships movement, i had been changing the vertices to simulate movement.
To tell the rendering API where to render the ship (essentially), you provide a transform that specifies the object's position and rotation (and any other transforms you might want, such as scale). You can build this transform from separate rotation and translation matrices, or from a quaternion and a position vector, or from a set of Euler angles and a position vector - that's all up to you. But what you actually end up sending to the API will generally be one or more transforms that specifies how the geometry will make its way from local space to clip space. (If you're using the fixed-function pipeline, for example, these will be the world, view, and projection transforms.)
#10 Members - Reputation: 103
Posted 19 April 2011 - 02:43 AM
Thank you JYK, i feel like an idiot haha, thanks for getting me off that road of thought.
This is my last question because i feel bad about asking so many questions when i should be experimenting through example but...
Just making sure i'm supposed to assign this ship a position on the world map, which will also be the origin of the ship correct?
So to move the ship i am technically "Moving the world to adjust to the ships movement" Is that a good way to think of it?
Thanks again!
#11 Members - Reputation: 1900
Posted 19 April 2011 - 03:07 AM
I'm not completely sure what you mean, but in general, yes, the position of the object in the world will correspond to the local-space origin of the model. (That is, the world-space position of the model x, y, z will correspond to the local-space origin 0, 0, 0.)Just making sure i'm supposed to assign this ship a position on the world map, which will also be the origin of the ship correct?
We were just discussing this in another thread :)So to move the ship i am technically "Moving the world to adjust to the ships movement" Is that a good way to think of it?
Generally speaking, as far as the simulation is concerned, you move the ship and not the world. There are some conceptual issues involved, and there's more than one way to look at things, but when it comes to actually updating the entities in your simulation, you should think of the ship as moving, rather than the world. (In the general case, at least.)






