Jump to content
  • Advertisement
Sign in to follow this  
Carthage

Can someone help me understand projections(java if it matters)?

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

I feel lost when it comes to trying to draw out a polygon on a 2D screen built with vertices that have x,y,z coordinates. From what I gather: (using (x,y,z) coordinates) I need a viewing point, something like (0,0,20) I need to know the coordinates of my polygon's vertices, something like: Vertex 1 = ( 0, 0, 0) Vertex 2 = ( 1, 0, 1) Vertex 3 = ( 0, 1, 1) And I need a plane in which I am projecting onto( the screen ) I gather I have to trace a line from the viewer, through a vertex, which lands on the 2D screen and that's where I place my point, and repeat that for each vertex, then connect the lines to have a polygon, but I'm very confused as to how this is actually done. I've tried understanding the theory behind: http://www.ruthless.zathras.de/facts/apps/polygonesia/3d-projection.php But what really throws me is:
Quote:
World Coordinates: Next we want to convert the (possibly transformed) local coordinates to world coordinates. This means nothing else than taking the entities out of their own lonely worlds and putting them all together into the big wide game world, each in the place where it belongs. Concerning calculations, this is the easiest step.
I don't understand the concept of converting from local to world coordinates.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
the concept of converting from local to world coordinates

Often a developer will create geometry (or sets of vertices) in the neighborhood of the origin, because his modeling program does so, or he wants to use the same geometry in several locations in his "world." E.g., trees, boxes, etc.

To display multiple instances of the same geometry, each instance (the vertices being modeled around the origin are in "local space") is rendered using a matrix (transform, etc.) which rotates it and/or translates it to somewhere in the "world." That matrix is what is being referred to as converting it "from local to world coordinates."

The vertices of the geometry (or your polygon, for instance) are converted to world space by multiplying each vertex position by localMatrix*worldMatrix. (Depending on the graphics system you want to use, the order of those multiplications may be reversed v' = world*local*v. That's just a matter of internal math functions.)

If the developer wants the object to be displayed around the origin, that "local to world" conversion need not be done. Or, you can think of the rotation and translation to be an identity matrix.

Share this post


Link to post
Share on other sites
Thank you, that was very helpful.

Could someone explain how to project a 3D point to a 2D plane with a viewer at a specific x,y,z location? I can't seem to find any explanation on how to do this. I always get tripped up because I don't know the screen coordinates or how the viewer affects things.

Like, if I had a viewer at point x1, y1, z1, how would I project a triangle onto a screen with 3 sets of vertex coordinates?

[Edited by - Carthage on February 16, 2010 7:38:11 PM]

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!