From: <axl...@us...> - 2009-07-06 02:39:42
|
Revision: 410 http://hgengine.svn.sourceforge.net/hgengine/?rev=410&view=rev Author: axlecrusher Date: 2009-07-06 02:39:41 +0000 (Mon, 06 Jul 2009) Log Message: ----------- fix broken frustum plane calculations Modified Paths: -------------- Mercury2/src/Frustum.cpp Mercury2/src/Viewport.cpp Modified: Mercury2/src/Frustum.cpp =================================================================== --- Mercury2/src/Frustum.cpp 2009-07-05 21:15:50 UTC (rev 409) +++ Mercury2/src/Frustum.cpp 2009-07-06 02:39:41 UTC (rev 410) @@ -55,37 +55,40 @@ //Right now this only builds the frustum planes MercuryVector X,Y,Z; - Z = (eye - look).Normalize(); //direction behind camera + Z = look * -1; //direction opposite of look X = (up.CrossProduct(Z)).Normalize(); //X axis Y = Z.CrossProduct( X ); //real up - m_nc = (eye - Z) * m_zNear; - m_fc = (eye - Z) * m_zFar; + m_nc = eye - (Z * m_zNear); + m_fc = eye - (Z * m_zFar); - m_planes[PNEAR].Setup(m_nc, Z*(-1)); + //All the normals must face inwards + m_planes[PNEAR].Setup(m_nc, Z*-1); m_planes[PFAR].Setup(m_fc, Z); +// m_planes[PFAR].GetNormal().Print(); // m_fc.Print(); // Z.Print(); MercuryVector aux,normal; aux = (m_nc + Y*m_nh) - eye; aux.NormalizeSelf(); - normal = aux * X; + normal = aux.CrossProduct(X); m_planes[PTOP].Setup(m_nc+Y*m_nh,normal); - + aux = (m_nc - Y*m_nh) - eye; aux.NormalizeSelf(); - normal = X * aux; + normal = X.CrossProduct(aux); m_planes[PBOTTOM].Setup(m_nc-Y*m_nh,normal); aux = (m_nc - X*m_nw) - eye; aux.NormalizeSelf(); - normal = aux * Y; + normal = aux.CrossProduct(Y); m_planes[PLEFT].Setup(m_nc-X*m_nw,normal); aux = (m_nc + X*m_nw) - eye; aux.NormalizeSelf(); - normal = Y * aux; + normal = Y.CrossProduct(aux); + normal.Print(); m_planes[PRIGHT].Setup(m_nc+X*m_nw,normal); } Modified: Mercury2/src/Viewport.cpp =================================================================== --- Mercury2/src/Viewport.cpp 2009-07-05 21:15:50 UTC (rev 409) +++ Mercury2/src/Viewport.cpp 2009-07-06 02:39:41 UTC (rev 410) @@ -33,8 +33,9 @@ VIEWMATRIX = matrix; - MercuryVector z(0,0,1); - LOOKAT = (matrix * z).Normalize(); + //the camera sets this (the calculation here is wrong) +// MercuryVector z(0,0,-1); //look down Z by default +// LOOKAT = (matrix * z).Normalize(); // matrix.Print(); // EYE.Print("Eye"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |