From: <axl...@us...> - 2009-07-25 20:25:23
|
Revision: 438 http://hgengine.svn.sourceforge.net/hgengine/?rev=438&view=rev Author: axlecrusher Date: 2009-07-25 20:25:16 +0000 (Sat, 25 Jul 2009) Log Message: ----------- orthographic is still broken, but we are getting closer Modified Paths: -------------- Mercury2/Themes/default/File/scenegraph.xml Mercury2/adv_set.c Mercury2/src/Camera.cpp Mercury2/src/Camera.h Mercury2/src/MercuryVBO.cpp Mercury2/src/Orthographic.cpp Mercury2/src/Orthographic.h Mercury2/src/Viewport.cpp Mercury2/src/Viewport.h Modified: Mercury2/Themes/default/File/scenegraph.xml =================================================================== --- Mercury2/Themes/default/File/scenegraph.xml 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/Themes/default/File/scenegraph.xml 2009-07-25 20:25:16 UTC (rev 438) @@ -1,50 +1,44 @@ <SceneGraph name="root"> -<!-- <node type="cameranode" movx="6" movz="-5.5" movy="3" rotx="-45" roty="90"> - <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> - </node> ---> - <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera"> - <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"/> - </node> - - <node type="transformnode" movz="-5" > - <node type="TextNode" text="test font 123 HELLO WORLD!!! WOOT!" font="FONT:testfont.hgfont" size=".01" width="300" alphaPath="true" alignment="FIT_FULL" /> - </node> -<!-- <asset type="texture" file="screenFBO_0" dynamic="true"/> - <asset type="fullscreenquad"/> - <node type="mercuryfbo" width="640" height="480" depth="true" tnum="2" name="screenFBO" usescreensize="true"> - <asset type="shader" file="testShader"/> ---> <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> - <asset type="texture" file="MODEL:map.png"/> - <asset type="hgmdlmodel" file="MODEL:map.hgmdl" /> - </node> - <node type="mercurynode" name="lampForest" > - <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > - <node type="mercurynode" name="lamp"> - <node type="transformnode" rotx="-90" > - <asset type="texture" file="MODEL:lamp.png"/> - <asset type="hgmdlmodel" file="MODEL:lampN.hgmdl" /> - </node> - <node type="billboardnode" billboardaxis="0,1,0" spheremode="true" > - <node type="transformnode" roty="180" scalex="0.1" scaley="0.1" alphaPath="true"> - <asset type="texture" file="GRAPHIC:flame.png"/> - <asset type="quad"/> + <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp"> + <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera"> + <node type="transformnode" movz="-5" > + <node type="TextNode" text="test font 123 HELLO WORLD!!! WOOT!" font="FONT:testfont.hgfont" size=".01" width="300" alphaPath="true" alignment="FIT_FULL" /> + </node> + <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> + <asset type="texture" file="MODEL:map.png"/> + <asset type="hgmdlmodel" file="MODEL:map.hgmdl" /> + </node> + <node type="mercurynode" name="lampForest" > + <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > + <node type="mercurynode" name="lamp"> + <node type="transformnode" rotx="-90" > + <asset type="texture" file="MODEL:lamp.png"/> + <asset type="hgmdlmodel" file="MODEL:lampN.hgmdl" /> </node> + <node type="billboardnode" billboardaxis="0,1,0" spheremode="true" > + <node type="transformnode" roty="180" scalex="0.1" scaley="0.1" alphaPath="true"> + <asset type="texture" file="GRAPHIC:flame.png"/> + <asset type="quad"/> + </node> + </node> </node> + <node type="transformnode" movx="1" fallback="lamprow.lamp" /> + <node type="transformnode" movx="2" fallback="lamprow.lamp" /> + <node type="transformnode" movx="3" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-1" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-2" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-3" fallback="lamprow.lamp" /> </node> - <node type="transformnode" movx="1" fallback="lamprow.lamp" /> - <node type="transformnode" movx="2" fallback="lamprow.lamp" /> - <node type="transformnode" movx="3" fallback="lamprow.lamp" /> - <node type="transformnode" movx="-1" fallback="lamprow.lamp" /> - <node type="transformnode" movx="-2" fallback="lamprow.lamp" /> - <node type="transformnode" movx="-3" fallback="lamprow.lamp" /> + <node type="transformnode" movz="-6" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-7" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-8" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-9" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/> </node> - <node type="transformnode" movz="-6" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-7" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-8" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-9" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/> - <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/> </node> -<!-- </node> --> + </node> +<!-- <node type="orthographic" left="0" right="1" top="0" bottom="1" near="-1" far="1"> + <asset type="quad"/> + </node> --> </SceneGraph> Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/adv_set.c 2009-07-25 20:25:16 UTC (rev 438) @@ -13,7 +13,7 @@ src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \ src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \ src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \ - src/MercuryTheme.cpp" + src/MercuryTheme.cpp src/Orthographic.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/src/Camera.cpp =================================================================== --- Mercury2/src/Camera.cpp 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/src/Camera.cpp 2009-07-25 20:25:16 UTC (rev 438) @@ -12,6 +12,18 @@ REGISTER_FOR_MESSAGE( INPUTEVENT_MOUSE ); } +void CameraNode::PreRender(const MercuryMatrix& matrix) +{ + VIEWMATRIX = m_viewMatrix; + TransformNode::PreRender(matrix); +} + +void CameraNode::Render(const MercuryMatrix& matrix) +{ + VIEWMATRIX = m_viewMatrix; + TransformNode::Render(matrix); +} + void CameraNode::ComputeMatrix() { m_tainted = false; @@ -33,7 +45,7 @@ local.Translate( GetPosition()*-1 ); // m_globalMatrix = local * parent; //fold in any parent transform in reverse (correct rotation) - VIEWMATRIX = local * parent; + m_viewMatrix = local * parent; //compute camera position in world space (broken if camera is in transform node) local = MercuryMatrix::Identity(); Modified: Mercury2/src/Camera.h =================================================================== --- Mercury2/src/Camera.h 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/src/Camera.h 2009-07-25 20:25:16 UTC (rev 438) @@ -11,11 +11,14 @@ virtual void ComputeMatrix(); virtual void HandleMessage(const MString& message, const MessageData* data); virtual void Update(float dTime); + virtual void PreRender(const MercuryMatrix& matrix); + virtual void Render(const MercuryMatrix& matrix); GENRTTI(CameraNode); private: MercuryVector m_lookAt; float m_x, m_y; + MercuryMatrix m_viewMatrix; }; #endif Modified: Mercury2/src/MercuryVBO.cpp =================================================================== --- Mercury2/src/MercuryVBO.cpp 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/src/MercuryVBO.cpp 2009-07-25 20:25:16 UTC (rev 438) @@ -29,7 +29,6 @@ uint16_t stride = sizeof(float)*8; if ( !m_initiated ) InitVBO(); -glDisable(GL_CULL_FACE); if ( this != m_lastVBOrendered ) { Modified: Mercury2/src/Orthographic.cpp =================================================================== --- Mercury2/src/Orthographic.cpp 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/src/Orthographic.cpp 2009-07-25 20:25:16 UTC (rev 438) @@ -18,8 +18,22 @@ glMatrixMode(GL_MODELVIEW); VIEWMATRIX = matrix; + MercuryNode::PreRender(matrix); } +void Orthographic::Render(const MercuryMatrix& matrix) +{ + FRUSTUM = &m_frustum; + + //Load the frustum into the projection + glMatrixMode(GL_PROJECTION); + glLoadMatrix( m_frustum.GetMatrix() ); + glMatrixMode(GL_MODELVIEW); + + VIEWMATRIX = matrix; + MercuryNode::Render(matrix); +} + void Orthographic::LoadFromXML(const XMLNode& node) { MercuryWindow* w = MercuryWindow::GetCurrentWindow(); Modified: Mercury2/src/Orthographic.h =================================================================== --- Mercury2/src/Orthographic.h 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/src/Orthographic.h 2009-07-25 20:25:16 UTC (rev 438) @@ -12,6 +12,7 @@ public: Orthographic(); virtual void PreRender(const MercuryMatrix& matrix); + virtual void Render(const MercuryMatrix& matrix); virtual void LoadFromXML(const XMLNode& node); Modified: Mercury2/src/Viewport.cpp =================================================================== --- Mercury2/src/Viewport.cpp 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/src/Viewport.cpp 2009-07-25 20:25:16 UTC (rev 438) @@ -49,6 +49,42 @@ m_frustum.LookAt(EYE, LOOKAT, MercuryVertex(0,1,0)); } +void Viewport::Render(const MercuryMatrix& matrix) +{ + FRUSTUM = &m_frustum; + + MercuryWindow* w = MercuryWindow::GetCurrentWindow(); + glViewport(m_minx, m_miny, (GLsizei)(w->Width()*m_xFactor), (GLsizei)(w->Height()*m_yFactor)); + + //Load the frustum into the projection + //"eye" position does not go into projection + glMatrixMode(GL_PROJECTION); + glLoadMatrix( m_frustum.GetMatrix() ); + + glMatrixMode(GL_MODELVIEW); + + //compute the position of the eye +// EYE = MercuryVertex(0,0,0,1); //wrong +// EYE = matrix * EYE; + +// VIEWMATRIX = matrix; + + //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"); +// LOOKAT.Print("Lookat"); +// printf("******\n"); +// LOOKAT = (matrix * l).Normalize(); +// LOOKAT. +// LOOKAT.Print(); + + //Sets up the clipping frustum +// m_frustum.LookAt(EYE, LOOKAT, MercuryVertex(0,1,0)); +} + void Viewport::LoadFromXML(const XMLNode& node) { m_xFactor = StrToFloat(node.Attribute("xfactor"), 1.0f); Modified: Mercury2/src/Viewport.h =================================================================== --- Mercury2/src/Viewport.h 2009-07-25 20:09:25 UTC (rev 437) +++ Mercury2/src/Viewport.h 2009-07-25 20:25:16 UTC (rev 438) @@ -12,6 +12,7 @@ public: Viewport(); virtual void PreRender(const MercuryMatrix& matrix); + virtual void Render(const MercuryMatrix& matrix); virtual void LoadFromXML(const XMLNode& node); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |