To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cadOpen lugnet.cad in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / 14636
14635  |  14637
Subject: 
Re: 3D Transformations Architecture Question
Newsgroups: 
lugnet.cad
Date: 
Fri, 13 Jul 2007 00:38:25 GMT
Viewed: 
2122 times
  
In lugnet.cad, Jeff Boen wrote:
   Feedback from the guys who built the viewers (LDGlite, LDView, etc) would be really great on this.

I have a project, not Lego, but similar and I’m writing some software for 3D viewing and manipulation of items. The LDraw architecture is a good match so I’m adapting some of the concepts we use.

I have a question about how you guys attack all the necessary transformations needed for viewing. This isn’t a “How do you do 3D?” question, I’ve got all the data structures, transformation matrices and drawing routines implemented. This

Actually, based on what you write after the above, this is a “How do you draw in 3D?” question, which is fairly close to “How do you do 3D?”. The implementation details of how 3D gets drawn to the screen tend to answer all your questions. When you go to draw a 3D point to the screen, you take the point and multiply it by the current transformation and projection matrix. (The projection matrix generally contains things like scaling to window coordinates, perspective projection, and that kind of stuff, and I’m going to pretend it doesn’t exist for the rest of this post.) The transformation matrix deals with how the points are transformed in the scene.

The above realization mostly answers your questions. Store the transformation matrix for each object (just like LDraw), and do the multiplication at display time. To draw an object, you do the following:
  • Push the current transformation matrix onto a stack somewhere.
  • Multiply the current transformation matrix by the object’s transformation matrix, and store the result as the current transformation matrix.
  • Draw all the geometry in the object (multiplying each point by the current transformation matrix).
  • Pop the pre-object transformation matrix back off the stack to make it the current transformation matrix.
In OpenGl, the above steps break down into:
  • glPushMatrix()
  • glMultMatrixf(objectMatrix) (or glMultMatrixd if you don’t care about performance)
  • draw the geometry normally, using object local coordinates
  • glPopMatrix()
I’m guessing that it’s roughly the same in Direct3D. To be honest, you’re much better off just using OpenGL or Direct3D to do the drawing. You’re still going to want to go through the same steps as above even if you do the drawing yourself, and I don’t see how you gain much by doing that. The thing to remember here is that in order to draw a point, it has to be multiplied by a transformation matrix. So the only extra overhead is the push/multiply/pop of the object’s matrix for each object. As long as your objects aren’t tiny, this overhead turns out to be fairly minimal.

--Travis



Message has 1 Reply:
  Re: 3D Transformations Architecture Question
 
(...) Travis, Thanks, but that answer is exactly what I was trying to avoid in this discussion. I understand about creating a transformation matrix, a camera matrix and a projection/perspective matrix. I understand about compositing them all for a (...) (17 years ago, 13-Jul-07, to lugnet.cad, FTX)

Message is in Reply To:
  3D Transformations Architecture Question
 
Feedback from the guys who built the viewers (LDGlite, LDView, etc) would be really great on this. I have a project, not Lego, but similar and I'm writing some software for 3D viewing and manipulation of items. The LDraw architecture is a good match (...) (17 years ago, 12-Jul-07, to lugnet.cad)

8 Messages in This Thread:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR