Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > plotting vertices and edges

plotting vertices and edges
Thread Tools
gyc
Dedicated MacNNer
Join Date: Dec 1999
Location: Ann Arbor, MI
Status: Offline
Reply With Quote
Apr 17, 2001, 08:43 PM
 
Hi,
I'm not sure where to put this, but can anyone point me to a general algorithm that will enable me to plot a set of vertices connected by edges to the screen. I have a set of vertices w/ x, y, z coordinates and 3 vertices each are connected by 3 edges to form a triangle. Is there a general algorithm to transform the resulting 3-D image into pixels that I can plot on the screen?
     
Mac Enthusiast
Join Date: Jan 2001
Status: Offline
Reply With Quote
Apr 30, 2001, 10:53 PM
 
I've been working on a 3D engine in my spare time, so I might be able to help you. First of all, do you want this projection to be perspective correct, or isometric? Does it depend on the rotation of the camera of polygon? Is it shaded or just the outline?

Lets say that the camera was at (0,0,0) facing straight down the z-axis. To transform the coords of point A from 3D to 2D space, the transformed "screen" x value would be : A.x * k / A.z.

The y value would be A.y * k / A.z

where k is constant depending on your scene.
do this for all the points adn then connect them with lines.

This makes sense if you think about it, you are taking the hor/vert value and dividing it by its distance from the camera. There is some really awesome other stuff you can do in 3D, sorry if this was vague. I have a simple 3D engine that I had written in Java, you can check out some applets (they are kinda old) and see the source here:
http://homepage.mac.com/lorenb/

check out the source that says q3d...

anyway, it is late, and my grammar is failing me...so please either post or email any questions you may have.
     
Admin Emeritus
Join Date: Oct 2000
Location: Boston, MA
Status: Offline
Reply With Quote
May 1, 2001, 06:31 AM
 
If you want _the_ definitive source on 3-D programming, it's Foley's Computer Graphics: Principles and Practices. Although it's old, it's probably the best graphics book out there.
"Against stupidity, the gods themselves contend in vain" (Schiller)
     
Junior Member
Join Date: May 2000
Location: Thessaloniki,Makedonia,Greece
Status: Offline
Reply With Quote
May 1, 2001, 04:39 PM
 
I would suggest not trying to make your own implementation of a 3d graphics engine. Instead try using OpenGL. I am curerntly working on a physics model that will be using OpenGL as the rendering engine. This way things get very simple and I can focus in what I want to do and not fiddle around with maths for 3d->2d projection.

If you want to know the way things work is that you always have the camera look from -z towards 0,0,0. So you always normalize the 3D coordinates to the "world coordinates" so you can have one algorithm for drawing everything.

ktolis

------------------
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:08 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2