DM> A while ago, I answered some questions about 3D graphics. I said
DM>most things right, but I did make one mistake that I notices when I
DM>tried to make my own 3D graphics library.
DM> I said before that the equation to find a 3D point on a 2D plane
DM>was:
DM> rx = D * x/z
DM> ry = D * y/z
Pretty crap equation for a real time 3d graphics library.
try this (no floating or fixed point, all integral)
2dx = (3dx * PERSPECTIVE) / (3dz + focal point) + (maxx / 2)
2dy = (3dy * PERSPECTIVE) / (3dz + focal point) + (maxy / 2);
in code you would optimize it to
x = (point.x << 8) / (point.z + point.focal_point) + 160;
y = (point.x << 8) / (point.z + point.focal_point) + 100;
I am talking about having a players view, in which it is a 3d world.
Every object belongs to a private 3d world and gets projected respectivly to
the viewers world.
DM> Where rx and ry are the real x and y on the 2D plane.
avoid using reals. Fixed point increase overhead in your code and avoid where
avoidable.
... ASCII stupid question, get a stupid ANSI.
--- Ezycom V1.48g0 01fd016b
---------------
* Origin: Fox's Lair BBS Bris Aus +61-7-38033908 V34+ Node 2 (3:640/238)
|