|
From: <axl...@us...> - 2009-07-21 01:52:42
|
Revision: 432
http://hgengine.svn.sourceforge.net/hgengine/?rev=432&view=rev
Author: axlecrusher
Date: 2009-07-21 01:52:34 +0000 (Tue, 21 Jul 2009)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/src/Frustum.cpp
Mercury2/src/Frustum.h
Mercury2/src/MercuryVBO.cpp
Mercury2/src/Viewport.h
Added Paths:
-----------
Mercury2/src/Orthographic.cpp
Mercury2/src/Orthographic.h
Modified: Mercury2/src/Frustum.cpp
===================================================================
--- Mercury2/src/Frustum.cpp 2009-07-21 00:48:39 UTC (rev 431)
+++ Mercury2/src/Frustum.cpp 2009-07-21 01:52:34 UTC (rev 432)
@@ -91,6 +91,32 @@
m_planes[PRIGHT].Setup(m_nc+X*m_nw,normal);
}
+void Frustum::Ortho(float left, float right, float bottom, float top, float near, float far)
+{
+ float rml = right - left;
+ float tmb = top - bottom;
+ float fmn = far - near;
+
+ m_frustum = MercuryMatrix::Identity();
+ m_frustum[0][0] = 2.0f/rml;
+ m_frustum[1][1] = 2.0f/tmb;
+ m_frustum[2][2] = 2.0f/fmn;
+
+ m_frustum[0][3] = -(right+left)/rml;
+ m_frustum[1][3] = -(top+bottom)/tmb;
+ m_frustum[2][3] = -(far+near)/fmn;
+
+ m_planes[PTOP].Setup(MercuryVertex(rml/2.0f, top, fmn/2.0f), MercuryVector(0,-1,0));
+ m_planes[PBOTTOM].Setup(MercuryVertex(rml/2.0f, bottom, fmn/2.0f), MercuryVector(0,1,0));
+
+ m_planes[PLEFT].Setup(MercuryVertex(left, tmb/2.0f, fmn/2.0f), MercuryVector(1,0,0));
+ m_planes[PRIGHT].Setup(MercuryVertex(right, tmb/2.0f, fmn/2.0f), MercuryVector(-1,0,0));
+
+ m_planes[PNEAR].Setup(MercuryVertex(rml/2.0f, tmb/2.0f, near), MercuryVector(0,0,-1));
+ m_planes[PFAR].Setup(MercuryVertex(rml/2.0f, tmb/2.0f, far), MercuryVector(0,0,1));
+}
+
+
/*
void Frustum::LookAt()
{
Modified: Mercury2/src/Frustum.h
===================================================================
--- Mercury2/src/Frustum.h 2009-07-21 00:48:39 UTC (rev 431)
+++ Mercury2/src/Frustum.h 2009-07-21 01:52:34 UTC (rev 432)
@@ -22,6 +22,7 @@
const MercuryMatrix& GetMatrix() const { return m_frustum; }
void ComputeFrustum(float left, float right, float bottom, float top, float zNear, float zFar);
void LookAt(const MercuryVertex& eye, const MercuryVector& look, const MercuryVector& up);
+ void Ortho(float left, float right, float bottom, float top, float near, float far);
inline const MercuryPlane& GetPlane(int i) const { return m_planes[i]; }
private:
@@ -35,6 +36,11 @@
MercuryVector m_nc, m_fc;
};
+extern const Frustum* FRUSTUM;
+extern MercuryMatrix VIEWMATRIX;
+extern MercuryVertex EYE;
+extern MercuryVector LOOKAT;
+
#endif
/****************************************************************************
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-07-21 00:48:39 UTC (rev 431)
+++ Mercury2/src/MercuryVBO.cpp 2009-07-21 01:52:34 UTC (rev 432)
@@ -28,8 +28,8 @@
uint8_t numTextures = Texture::NumberActiveTextures();
uint16_t stride = sizeof(float)*8;
- if ( !m_initiated )
- InitVBO();
+ if ( !m_initiated ) InitVBO();
+glDisable(GL_CULL_FACE);
if ( this != m_lastVBOrendered )
{
Added: Mercury2/src/Orthographic.cpp
===================================================================
--- Mercury2/src/Orthographic.cpp (rev 0)
+++ Mercury2/src/Orthographic.cpp 2009-07-21 01:52:34 UTC (rev 432)
@@ -0,0 +1,90 @@
+#include <Orthographic.h>
+#include <GLHeaders.h>
+#include <MercuryWindow.h>
+
+REGISTER_NODE_TYPE(Orthographic);
+
+Orthographic::Orthographic()
+{
+}
+
+void Orthographic::PreRender(const MercuryMatrix& matrix)
+{
+ FRUSTUM = &m_frustum;
+
+ MercuryWindow* w = MercuryWindow::GetCurrentWindow();
+
+ //Load the frustum into the projection
+ //"eye" position does not go into projection
+ glMatrixMode(GL_PROJECTION);
+ glLoadMatrix( m_frustum.GetMatrix() );
+ m_frustum.GetMatrix().Print();
+ 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 Orthographic::LoadFromXML(const XMLNode& node)
+{
+ MercuryWindow* w = MercuryWindow::GetCurrentWindow();
+
+ m_frustum.Ortho( StrToFloat(node.Attribute("left")),
+ StrToFloat(node.Attribute("right")),
+ StrToFloat(node.Attribute("bottom")),
+ StrToFloat(node.Attribute("top")),
+ StrToFloat(node.Attribute("near")),
+ StrToFloat(node.Attribute("far")) );
+
+ MercuryNode::LoadFromXML(node);
+}
+
+/****************************************************************************
+ * Copyright (C) 2009 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/Orthographic.h
===================================================================
--- Mercury2/src/Orthographic.h (rev 0)
+++ Mercury2/src/Orthographic.h 2009-07-21 01:52:34 UTC (rev 432)
@@ -0,0 +1,56 @@
+#ifndef ORTHOGRAPHIC_H
+#define ORTHOGRAPHIC_H
+
+#include <MercuryNode.h>
+#include <MercuryMatrix.h>
+#include <MercuryVertex.h>
+#include <MercuryPlane.h>
+#include <Frustum.h>
+
+class Orthographic : public MercuryNode
+{
+ public:
+ Orthographic();
+ virtual void PreRender(const MercuryMatrix& matrix);
+
+ virtual void LoadFromXML(const XMLNode& node);
+
+ GENRTTI(Orthographic);
+ private:
+ Frustum m_frustum;
+// float m_xFactor, m_yFactor;
+// int m_minx, m_miny;
+};
+
+#endif
+/****************************************************************************
+ * Copyright (C) 2009 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Modified: Mercury2/src/Viewport.h
===================================================================
--- Mercury2/src/Viewport.h 2009-07-21 00:48:39 UTC (rev 431)
+++ Mercury2/src/Viewport.h 2009-07-21 01:52:34 UTC (rev 432)
@@ -7,11 +7,6 @@
#include <MercuryPlane.h>
#include <Frustum.h>
-extern const Frustum* FRUSTUM;
-extern MercuryMatrix VIEWMATRIX;
-extern MercuryVertex EYE;
-extern MercuryVector LOOKAT;
-
class Viewport : public MercuryNode
{
public:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|