ok, i was a math minor, so they’re in column major format (i’m still working on my working, but unoptimized, implementation)
(i also replaced all of the  used in array idexing to | | cuz the forum is getting mad at me and interpreting brackets around i…)
inline Matrix MultiplyMatrix( const Matrix& m1,const Matrix& m2 )
for( int i = 0; i < 4; i++ )
for( int j = 0; j < 4; j++ )
Product|i| |j| = m1|i| |0|*m2|0| |j|
+ m1|i| |1|*m2|1| |j|
+ m1|i| |2|*m2|2| |j|
+ m1|i| |3|*m2|3| |j|;
inline Vector4d MultiplyMatrix( const Vector4d& v,const Matrix& m )
float( v.xm|0| |0| + v.ym|0| |1| + v.zm|0| |2| + v.wm|0| |3| ),
float( v.xm|1| |0| + v.ym|1| |1| + v.zm|1| |2| + v.wm|1| |3| ),
float( v.xm|2| |0| + v.ym|2| |1| + v.zm|2| |2| + v.wm|2| |3| ),
float( v.xm|3| |0| + v.ym|3| |1| + v.zm|3| |2| + v.wm|3| |3| )
Vector3d Camera::TransformPoint( const Vector3d& v )
// return mProjectionMatrixmViewMatrixv;
// return mViewMatrixmProjectionMatrixv;
Vector3d p = mViewMatrixmProjectionMatrixv;
return Vector3d( p.x/p.w,p.y/p.w,p.z/p.w );
oh, i’m using screen coords to reduce geometrey, not for culling.
i don’t usually like just posting code and saying “hey, debug this for me, cuz i cant”, but this time you asked i just like to compare algorithms, in plain english, maybe pseudocode.
thx, though, softland… but i’m not sure its the code, and not cuz i’m suffering from the “i’m right” syndrome that plagues so many programmers, it’s just cuz the code works for me in other places.
i use the multiply matrix in composing my view matrix. first i generate a translation matrix for the -position of the camera, rotate to the camera’s orientation, then translate to the near plane. that stuff all works out
the only thing i can see is maybe my MultiplyMatrix( m1,m2 ) is actually performing m2*m1, but that’s easily fixed, and i can write around that if it wasn’t, but now thinking about it, the vector matrix function isn’t even being used in this program, but i just cut and pasted it from my old ray-tracing program, where it worked.
basically, what my question really is: what ogl does after it gets these coordinates, called clip coordinates, i believe. ogl says that all the axis coords should be in the range [-1,1], but i’m not sure what w should be. shouldn’t z be 0 here? well, -(1,1,1) <= (x,y,z) <= (1,1,1), z != 0, w is large and positive
i know that next is the transformation to Normalized device coords, and that’s performed by dividing by w, but right now w is around 500… it’s making x and y very close to 0, cuz [-1,1]/500 = [-1/500,1/500]
man, i hope it’s the code, cuz that’s easier to fix!
thx again, softland
[This message has been edited by Succinct (edited 12-28-2000).]