Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kingy

Move vertex forward

This topic is 6236 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Has anyone got some kind of wrapper function that will move an vertex forward, or can someone explain how it is done? What Im trying to get to grips with is working out where "forward" actually is in 3d space after applying a matrixes to rotate a vertex / object.

Share this post


Link to post
Share on other sites
Advertisement
Hi,

well it depends on what you want to do... your problem isn''t completely clear to me, but I will try to explain.

Suppose you have a vertex in a polygon and you want to move that forward.... then just use the crossproduct on 2 edges of the polygon and it will give you the normal vector.


Another option is: Just keep the transform matrix... When the transform matrix is rotated, translated, scaled... the axis will point in the correct direction. So if before any transformation you said that the x-axis was forward... just apply the transformation and use the x-axis agian... since this will still be forward.

I hope I was of any help, Dark

Share this post


Link to post
Share on other sites
Ok bad examples, forget about vertices.

Think about loading a .x file in instead and moving that "forward"

Share this post


Link to post
Share on other sites
First figure out where it is you want "forward" to be.

Next make a vector from the center of the object to a point that is in front of it(depends on what you defined as front of course).

Now make the size of the vector be whatever speed you want the object to move at.

To move it forward now, just add the x value of the vector to all x values of points of the object, and the same with y and z values (a vector is just basically the difference between 2 3D points, making it be exactly like a 3d point, which is the reason I use the same structure for both vectors and points)

On a final note, remember to rotate the vector together with any rotation you make to the object(if for example you multiply all the points in the object by a rotation matrix, do that to the vector also) otherwise the front will not stay constant.

Hope this helps.

Share this post


Link to post
Share on other sites
The usual way of moving a model forward is by setting a world matrix for it. Exported models are resist in its local coordinate, therefore we will need a world matrix to define the model position within the world coordinate. The world matrix may consist of translation, rotation, etc.

So basically you set the world matrix in the pipeline (which will do the matrix multiplication in hardware if hardware acceleration exist) then all vertices in your model will be multiplied by the matrix, giving them new positions in the world coordinate.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!