Jump to content
  • Advertisement
Sign in to follow this  
johnnyBravo

Any non calculation intensive ways of rotating a vector with a orientation vector?

This topic is 4870 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

Hi, I was thinking of precalculating the normals for my triangles as I use them for collision detection and lighting. And all my objects have an orientation vector, so I was wondering if there are any quick ways of rotating a triangle normal vector with the orientation vector without any calculations more intensive then the actual normal calculation. which is for example: Vector3 n = (vertices[1].point - vertices[0].point).getCrossProduct(vertices[2].point - vertices[0].point).getNormalized(); The main reason I want to do this is because I am storing the vertices in a objectData class which object classes have a pointer to, and right now i have the points and texture coordinates having meaningful data, but the normal vector is just empty. thx

Share this post


Link to post
Share on other sites
Advertisement
You should be able to transform the normals by the same object-to-world matrix as you transform the vertices (sans-translation, of course), as long as there is no non-uniform scale on the object.

Anyway, you can't represent orientation with just a vector. You need normalized vector and a scale, or a quaternion, or a matrix. The calculation you indicate is very expensive, especially if you are doing it per-vertex.

[edit] also, you shouldn't use this for collision detection. That geometry should be much lower-res. I assume this character geometry is around 1k-2k triangles, while collision geometry should certainly not be more than 100.

Share this post


Link to post
Share on other sites
i c, its just that I'm not using matrices to represent each of my objects... I don't really understand them well enough. So I should use matrices for each of my objects?


...I think you can represent a rotation with a vector, the vector being the axis and the length is how much rotated around the axis it is. It seems to work ok...

...and for collision detection i thought i'd use planes made from each object's triangles to see if they intersect with other object's triangles, that is if the objects are close enough to warrent a collision detection check, shouldn't this be ok?

Also I just use that normal calculation for every 3 vertices...


edit: oh with the matrices, I'm using direct3d and I just get every vertex from all the objects and pile them into a vertex buffer and render them with one call so its fast, which kind of prevents me from setting a world matrix for each object as if I were to do that I'd have to call the vertex buffer draw function for each object, which I'd guess would result in bit of a speed loss, maybe countering the speed reasons for using matrices in the first place.

Share this post


Link to post
Share on other sites
No, don't change your representation... It's normalized vector with a rotation amount coded into the length of the vector. It's like a quaternion sans-trig, No problem. The only real question is why doesn't using normal normals work? You should be able to just say "Here's my precalculated normals in model-space!" "Here's my orientation!" and voila...

Also, about your edit... it implies that you think the bottleneck is the GPU transforming all the verticies by the world matrix. Nothing is further from the truth... it'll do that and bake you some pancakes before the vsync. The real issue is bus-bandwidth, it takes a while to transfer all that memory from main-mem to the GPU. The real question is-- if you resubmit the same vertex buffer with a different world-matrix, will the whole vertex bufer be re-submitted... I don't know the answer, but it's important to understand the question!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!