Jump to content
  • Advertisement


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


basic transformation / Rotation concept

This topic is 5225 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''ve just been happily coding away my little 3D deisgn program but I''ve suddenly hit a real problem, something that I SHOULD have accomodated for on a very basic level, but completely forgot about when starting to write (too anxious to get coding). Ok my problem is that I have a world editor, that creates objects in 3D space, translates them etc. Now my problem is that I haven''t done glTranslatef(...) or glRotatef(...), I''ve meerly specified all of the vertices at given world coordinates. Basically, I am drawing a mesh in world space, defining it''s orinetation and position by vertex values, rather than building a mesh around 0,0 and then rotating and translating it to a given position in world space. So my questions are: 1. Is what I have done TOTALLY wrong? 2. Will trying to rotate the object cause me massive problems now? (as I won''t be rotating then translating, I will have to calculate the new vertex positions given it''s mid point in world space). I''ve given this some serious thought already and tried to work out exactly what the issues are with what I am done, but I''d just like to hear some more experienced advice. Thanks.

Share this post

Link to post
Share on other sites
Yeah, that''s not the best way to do it at all. Ideally, you want to construct your meshes so that they are centered around the origin, then translate/rotate them. This simplifies the transformations if you need to move the object, and also allows you to re-use a single mesh for multiple objects of the same type, rather than maintaining a copy of the mesh data for every object of that type in the world. This sort of thing can quickly get out of hand memory-wise if you are not careful.

Trust me, you will save yourself some headaches by re-vamping the system to use local coordinate systems for objects.

Best of luck

Blender--The Gimp--Python--Lua--SDL

Share this post

Link to post
Share on other sites
My application works like yours (it''s a 3D level editor in the vein of q3radiant). I have brushes, and each brush has a vertex list in world coordinates (the faces reference the vertices in the list). When I need to move an object, I create a transformation matrix, then apply it to the vertex list. It''s not ideal, and is probably only a stop gap until I implement a new system. However, for large meshes, this can be horribly inefficent (luckily, my brushes never have more than about 50 vertices), so you''ll need to use the method VertexNormal proposed. Bear in mind that commercial programs probably use that method for all their objects, because they can''t know how large a mesh the user will create. So in short: with your current method, there''s no real performance hit to use matrices, IF your meshes don''t have many vertices. The more vertices a mesh has, the less and less efficent matrices become.

If you decide to stick with your current method, you''ll need to look up matrix identities for translation, rotation and scaling, and bear this in mind: if you want to rotate or scale an object about it''s own axis, you need to translate it to the origin, rotate it or scale it there, then translate it back...

Windows 95 - 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can''t stand 1 bit of competition.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!