Wireframe 3D engine problem
i coded a small wireframe engine, but i am having some problems with more complex forms, like toroids.
with simple forms, like cubes and piramids, there are no problem.
but with the toroid, it get distorted at certain angles. i calculate the toroid as follow:
the problem, seens to me, is in the xx and yy calculation. but also can be in my vector_to_2d() function.
#define DegToRad 0.017453293f
//create toroidal object
//walk in 45 degrees steps
//calculate circle position relative to toroid body
//walk in 20 degrees steps
//build toroidal face
//link the vectors generated in step above, forming a a circular poligon
//generate next toroid face
//link each face to others faces
//vector 1 is linked to vector 1+(number of vectors in face * face), till form a ring
my MAX_X and MAX_Y are 640 and 480, respectively. as MAX_Z, i tried several values, ending with 500. all values for MAX_Z show the distortion problem, but with 500 the problem is smaller.
void vector_to_2d(float x,float y,float z,DWORD *x0,DWORD *y0)
i dunno, but maybe the MAX_Z distortion is not related to my main distortion problem, but only a effect of perspective.
below i attach 2 pictures: 1 angle where it look right, and other wrong.
any suggestion in how correct the problem?
ps: sorry for my bad english: i fell it is a barrier to describe my problem and my algo :-(