3d math in a 2d language
I have a program I''m working on and I can''t access outside files for DLL''s and such, so I have to do the 3d math my self. This isn''t a problem, I can find tutorials on rotation and such fine, but I can''t find anything on how to plot the points onthe screen so you get the whole 3d look based on perspective. I imagine it would look something like:
int x,y,z;
x=50;
y=50;
z=-10;
drawDot(x*(some value), y*(some value), colour)
...
I just havent a clue on how to figure out a value based on the perspective and z value or whatever. Any help would be awesome.
Thanks
As usual, I''ll point you towards Zed3D, a nice PDF full of lecture notes on software rasterizers. Or perhaps you''d prefer Michael Abrash''s Black Book Of Graphics Programming, conveniently located on the web. Or any of the other references on 3d graphics, including the DX reference materials?
Or for a simplistic formula:
pset ( x / z, y / z )
Or for a simplistic formula:
pset ( x / z, y / z )
Thanks for the tip, I''m seach for those books tirght now. The problem with your quick code is that if I have a point at (1000,1000,-5) and I go 1000/-5 the result is negative and it shouldn''t. Anyway around this?
an if then structure
laziness is the foundation of efficiency | www.AdrianWalker.info | Adventures in Game Production | @zer0wolf - Twitter
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement