You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(185) |
Feb
(242) |
Mar
(237) |
Apr
(180) |
May
(102) |
Jun
(278) |
Jul
(114) |
Aug
(92) |
Sep
(246) |
Oct
(212) |
Nov
(279) |
Dec
(99) |
| 2007 |
Jan
(130) |
Feb
(194) |
Mar
(22) |
Apr
(72) |
May
(40) |
Jun
(111) |
Jul
(114) |
Aug
(154) |
Sep
(114) |
Oct
(2) |
Nov
(1) |
Dec
(5) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(51) |
Nov
(34) |
Dec
(130) |
| 2009 |
Jan
(22) |
Feb
(20) |
Mar
(41) |
Apr
(45) |
May
(82) |
Jun
(96) |
Jul
(48) |
Aug
(90) |
Sep
(13) |
Oct
(49) |
Nov
(31) |
Dec
(21) |
| 2010 |
Jan
(25) |
Feb
(9) |
Mar
(7) |
Apr
(28) |
May
(27) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(13) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <axl...@us...> - 2009-06-14 02:12:55
|
Revision: 318
http://hgengine.svn.sourceforge.net/hgengine/?rev=318&view=rev
Author: axlecrusher
Date: 2009-06-14 01:54:48 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
Rendering scene to FBO then to a fullscreen quad
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/scenegraph.xml
Added Paths:
-----------
Mercury2/src/FullscreenQuad.cpp
Mercury2/src/FullscreenQuad.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-06-13 21:56:35 UTC (rev 317)
+++ Mercury2/adv_set.c 2009-06-14 01:54:48 UTC (rev 318)
@@ -12,7 +12,7 @@
src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \
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/GLHelpers.cpp src/FullscreenQuad.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-13 21:56:35 UTC (rev 317)
+++ Mercury2/scenegraph.xml 2009-06-14 01:54:48 UTC (rev 318)
@@ -6,18 +6,17 @@
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0">
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/>
</node>
- <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
- <node type="renderablenode">
- <asset type="texture" file="map.png"/>
- <asset type="hgmdlmodel" file="map.hgmdl" />
- </node>
- <node type="renderablenode">
- <asset type="texture" file="screenFBO" dynamic="true"/>
- <asset type="quad"/>
- </node>
+ <node type="renderablenode">
+ <asset type="texture" file="screenFBO" dynamic="true"/>
+ <asset type="fullscreenquad"/>
</node>
- <node type="mercuryfbo" width="512" height="512" depth="false" tnum="1" name="screenFBO">
-<!-- <asset type="renderbuffer" buffertype="texture" /> -->
+ <node type="mercuryfbo" width="640" height="480" depth="false" tnum="1" name="screenFBO">
+ <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
+ <node type="renderablenode">
+ <asset type="texture" file="map.png"/>
+ <asset type="hgmdlmodel" file="map.hgmdl" />
+ </node>
+ </node>
<node type="renderablenode" name="lampForest">
<asset type="texture" file="lamp.png"/>
<node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
Added: Mercury2/src/FullscreenQuad.cpp
===================================================================
--- Mercury2/src/FullscreenQuad.cpp (rev 0)
+++ Mercury2/src/FullscreenQuad.cpp 2009-06-14 01:54:48 UTC (rev 318)
@@ -0,0 +1,71 @@
+#include <GLHeaders.h>
+#include <FullscreenQuad.h>
+
+REGISTER_ASSET_TYPE(FullscreenQuad);
+
+FullscreenQuad::FullscreenQuad()
+{
+ m_matrix = MercuryMatrix::Identity();
+ m_matrix.Scale(2,2,1);
+ m_matrix.Transpose();
+}
+
+void FullscreenQuad::Render(const MercuryNode* node)
+{
+ //reverse texture mapping for
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glLoadIdentity();
+ glRotatef(180,1,0,0);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadMatrixf( m_matrix.Ptr() );
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+ Quad::Render( node );
+
+ glPopMatrix();
+ glMatrixMode(GL_TEXTURE); glPopMatrix();
+ glMatrixMode(GL_MODELVIEW); glPopMatrix();
+}
+
+FullscreenQuad* FullscreenQuad::Generate()
+{
+ return new FullscreenQuad();
+}
+
+/****************************************************************************
+ * 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/FullscreenQuad.h
===================================================================
--- Mercury2/src/FullscreenQuad.h (rev 0)
+++ Mercury2/src/FullscreenQuad.h 2009-06-14 01:54:48 UTC (rev 318)
@@ -0,0 +1,46 @@
+#include <Quad.h>
+
+class FullscreenQuad : public Quad
+{
+ public:
+ FullscreenQuad();
+// virtual ~FullscreenQuad();
+
+ virtual void Render(const MercuryNode* node);
+
+ static FullscreenQuad* Generate();
+ private:
+ MercuryMatrix m_matrix;
+};
+
+/****************************************************************************
+ * 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. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-14 02:05:15
|
Revision: 319
http://hgengine.svn.sourceforge.net/hgengine/?rev=319&view=rev
Author: axlecrusher
Date: 2009-06-14 02:03:25 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
bug fixes
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/MercuryFBO.cpp
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-14 01:54:48 UTC (rev 318)
+++ Mercury2/scenegraph.xml 2009-06-14 02:03:25 UTC (rev 319)
@@ -10,7 +10,7 @@
<asset type="texture" file="screenFBO" dynamic="true"/>
<asset type="fullscreenquad"/>
</node>
- <node type="mercuryfbo" width="640" height="480" depth="false" tnum="1" name="screenFBO">
+ <node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="screenFBO">
<node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
<node type="renderablenode">
<asset type="texture" file="map.png"/>
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2009-06-14 01:54:48 UTC (rev 318)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-14 02:03:25 UTC (rev 319)
@@ -83,7 +83,7 @@
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushAttrib(GL_VIEWPORT_BIT);
- glViewport(0,0,m_width, m_width);
+// glViewport(0,0,m_width, m_width);
RenderableNode::Render(matrix);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-13 21:56:36
|
Revision: 317
http://hgengine.svn.sourceforge.net/hgengine/?rev=317&view=rev
Author: axlecrusher
Date: 2009-06-13 21:56:35 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/src/MercuryFBO.cpp
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-06-13 21:30:11 UTC (rev 316)
+++ Mercury2/adv_set.c 2009-06-13 21:56:35 UTC (rev 317)
@@ -12,7 +12,7 @@
src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \
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/RenderBuffer.cpp src/GLHelpers.cpp"
+ src/GLHelpers.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2009-06-13 21:30:11 UTC (rev 316)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-13 21:56:35 UTC (rev 317)
@@ -80,7 +80,7 @@
// m_lastInStask = m_lastRendered;
}
- glClear(GL_COLOR_BUFFER_BIT );
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0,0,m_width, m_width);
@@ -107,7 +107,6 @@
void MercuryFBO::LoadFromXML(const XMLNode& node)
{
- printf("load\n");
if ( !node.Attribute("width").empty() )
SetWidth( StrToInt(node.Attribute("width")) );
@@ -120,8 +119,6 @@
if ( !node.Attribute("tnum").empty() )
SetNumTextures( StrToInt(node.Attribute("tnum")) );
- printf("%d %d %d %d\n", m_width, m_height, m_useDepth, m_numTextures);
-
RenderableNode::LoadFromXML(node);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-13 21:30:15
|
Revision: 316
http://hgengine.svn.sourceforge.net/hgengine/?rev=316&view=rev
Author: axlecrusher
Date: 2009-06-13 21:30:11 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
FBO works
Modified Paths:
--------------
Mercury2/scenegraph.xml
Mercury2/src/MercuryFBO.cpp
Mercury2/src/MercuryFBO.h
Mercury2/src/RenderBuffer.cpp
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-13 02:35:10 UTC (rev 315)
+++ Mercury2/scenegraph.xml 2009-06-13 21:30:11 UTC (rev 316)
@@ -11,9 +11,13 @@
<asset type="texture" file="map.png"/>
<asset type="hgmdlmodel" file="map.hgmdl" />
</node>
+ <node type="renderablenode">
+ <asset type="texture" file="screenFBO" dynamic="true"/>
+ <asset type="quad"/>
+ </node>
</node>
- <node type="mercuryfbo" >
- <asset type="renderbuffer" buffertype="texture" />
+ <node type="mercuryfbo" width="512" height="512" depth="false" tnum="1" name="screenFBO">
+<!-- <asset type="renderbuffer" buffertype="texture" /> -->
<node type="renderablenode" name="lampForest">
<asset type="texture" file="lamp.png"/>
<node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
Modified: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2009-06-13 02:35:10 UTC (rev 315)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-13 21:30:11 UTC (rev 316)
@@ -4,15 +4,57 @@
REGISTER_NODE_TYPE(MercuryFBO);
MercuryFBO::MercuryFBO()
- :m_fboID(0), m_initiated(false)
+ :m_fboID(0), m_depthBufferID(0), m_initiated(false), m_useDepth(false), m_numTextures(0)
{
+ for (uint8_t i = 0; i < 4; ++i) m_textures[i] = NULL;
}
MercuryFBO::~MercuryFBO()
{
+ Clean();
+}
+
+void MercuryFBO::Clean()
+{
if (m_fboID != 0) glDeleteFramebuffersEXT(1, &m_fboID);
+ if (m_depthBufferID != 0) glDeleteRenderbuffersEXT( 1, &m_depthBufferID );
+ m_fboID = m_depthBufferID = 0;
+ m_initiated = false;
+ for (uint8_t i = 0; i < 4; ++i) m_textures[i] = NULL;
}
+void MercuryFBO::Setup()
+{
+ Clean();
+
+ m_initiated = true;
+
+ if( m_useDepth ) glGenRenderbuffersEXT( 1, &m_depthBufferID );
+ glGenFramebuffersEXT( 1, &m_fboID );
+
+ for (uint8_t i = 0; i < m_numTextures; ++i)
+ {
+ m_textures[i] = Texture::LoadDynamicTexture(m_name);
+ m_textures[i]->MakeDynamic(m_width, m_height,m_name);
+ }
+
+ if( m_useDepth )
+ {
+ glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_fboID );
+ glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, m_width, m_height );
+ }
+ glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_fboID );
+
+ for (uint8_t i = 0; i < m_numTextures; ++i)
+ glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, m_textures[i]->TextureID(), 0 );
+
+
+ if( m_useDepth )
+ glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthBufferID );
+
+ CHECKFBO; //Incomplete FBO
+}
+/*
void MercuryFBO::InitFBOBeforeRender()
{
m_initiated = true;
@@ -20,10 +62,10 @@
CHECKFBO;
GLERRORCHECK;
}
-
+*/
void MercuryFBO::PreRender(const MercuryMatrix& matrix)
{
- if ( !m_initiated ) InitFBOBeforeRender();
+ if ( !m_initiated ) Setup();
RenderableNode::PreRender(matrix);
}
@@ -38,15 +80,17 @@
// m_lastInStask = m_lastRendered;
}
-// glPushAttrib(GL_VIEWPORT_BIT);
- // glViewport(0,0,width, height);
+ glClear(GL_COLOR_BUFFER_BIT );
+
+ glPushAttrib(GL_VIEWPORT_BIT);
+ glViewport(0,0,m_width, m_width);
RenderableNode::Render(matrix);
}
void MercuryFBO::PostRender(const MercuryMatrix& matrix)
{
-// glPopAttrib();
+ glPopAttrib();
// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_lastInStask);
// m_lastRendered = m_lastInStask;
@@ -61,6 +105,26 @@
m_lastRendered = 0;
}
+void MercuryFBO::LoadFromXML(const XMLNode& node)
+{
+ printf("load\n");
+ if ( !node.Attribute("width").empty() )
+ SetWidth( StrToInt(node.Attribute("width")) );
+
+ if ( !node.Attribute("height").empty() )
+ SetHeight( StrToInt(node.Attribute("height")) );
+
+ if ( !node.Attribute("depth").empty() )
+ SetUseDepth( node.Attribute("depth") == "true"?true:false );
+
+ if ( !node.Attribute("tnum").empty() )
+ SetNumTextures( StrToInt(node.Attribute("tnum")) );
+
+ printf("%d %d %d %d\n", m_width, m_height, m_useDepth, m_numTextures);
+
+ RenderableNode::LoadFromXML(node);
+}
+
uint32_t MercuryFBO::m_lastRendered = NULL;
/****************************************************************************
Modified: Mercury2/src/MercuryFBO.h
===================================================================
--- Mercury2/src/MercuryFBO.h 2009-06-13 02:35:10 UTC (rev 315)
+++ Mercury2/src/MercuryFBO.h 2009-06-13 21:30:11 UTC (rev 316)
@@ -2,6 +2,7 @@
#define MERCURYFBO_H
#include <RenderableNode.h>
+#include <Texture.h>
class MercuryFBO : public RenderableNode
{
@@ -13,16 +14,31 @@
virtual void Render(const MercuryMatrix& matrix);
virtual void PostRender(const MercuryMatrix& matrix);
+ virtual void LoadFromXML(const XMLNode& node);
+
+ inline void SetWidth(uint16_t width) { m_width = width; }
+ inline void SetHeight(uint16_t height) { m_height = height; }
+ inline void SetUseDepth(bool toggle) { m_useDepth = toggle; }
+ inline void SetNumTextures(uint8_t x) { m_numTextures = x; }
+
+
GENRTTI(MercuryFBO);
private:
- void InitFBOBeforeRender();
+ void Setup();
+ void Clean();
+// void InitFBOBeforeRender();
- uint32_t m_fboID;
- bool m_initiated;
+ uint32_t m_fboID, m_depthBufferID;
+ bool m_initiated, m_useDepth;
+ uint16_t m_width, m_height;
+// uint32_t m_textureID[4];
+ Texture *m_textures[4];
+ uint8_t m_numTextures;
+
static uint32_t m_lastRendered;
- uint32_t m_lastInStask;
+// uint32_t m_lastInStask;
protected:
// AlignedBuffer<float> m_vertexData;
Modified: Mercury2/src/RenderBuffer.cpp
===================================================================
--- Mercury2/src/RenderBuffer.cpp 2009-06-13 02:35:10 UTC (rev 315)
+++ Mercury2/src/RenderBuffer.cpp 2009-06-13 21:30:11 UTC (rev 316)
@@ -37,24 +37,20 @@
void RenderBuffer::Render(const MercuryNode* node)
{
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_bufferID);
-// CHECKFBO; //missing attachment
- GLERRORCHECK;
if ( NeedResize() ) AllocateSpace();
-
- //attach to FBO
-// if ( !m_bound )
+
+ if ( m_type == TEXTURE )
{
- m_bound = true;
- if ( m_type == TEXTURE )
- glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_TEXTURE_2D, m_textureID, 0);
- else
- glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_RENDERBUFFER_EXT, m_bufferID);
- CHECKFBO;
- GLERRORCHECK;
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_TEXTURE_2D, m_textureID, 0);
}
-
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ else
+ {
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_RENDERBUFFER_EXT, m_bufferID);
+ }
+ CHECKFBO;
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ glClear(GL_COLOR_BUFFER_BIT );
GLERRORCHECK;
}
@@ -134,6 +130,8 @@
{
m_width = MercuryWindow::GetCurrentWindow()->Width();
m_height = MercuryWindow::GetCurrentWindow()->Height();
+ m_width = 512;
+ m_height = 512;
if (m_type == TEXTURE)
{
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-06-13 02:35:10 UTC (rev 315)
+++ Mercury2/src/Texture.cpp 2009-06-13 21:30:11 UTC (rev 316)
@@ -21,12 +21,17 @@
{
REMOVE_ASSET_INSTANCE(TEXTURE, m_path);
- if (m_textureID) glDeleteTextures(1, &m_textureID);
- m_textureID = 0;
+ Clean();
SAFE_DELETE(m_raw);
}
+void Texture::Clean()
+{
+ if (m_textureID) glDeleteTextures(1, &m_textureID);
+ m_textureID = 0;
+}
+
void Texture::Init(MercuryNode* node)
{
MercuryAsset::Init( node );
@@ -101,7 +106,16 @@
void Texture::LoadFromXML(const XMLNode& node)
{
- LoadImagePath( node.Attribute("file") );
+ bool dynamic = false;
+ if ( !node.Attribute("dynamic").empty() )
+ dynamic = node.Attribute("dynamic")=="true"?true:false;
+
+ MString file = node.Attribute("file");
+
+ if ( dynamic )
+ MakeDynamic( 0, 0, file );
+ else
+ LoadImagePath( file );
}
void Texture::BindTexture()
@@ -151,6 +165,27 @@
m_raw = raw;
}
+void Texture::MakeDynamic(uint16_t width, uint16_t height, const MString& name)
+{
+ Clean();
+
+ SetLoadState(LOADED);
+
+ REMOVE_ASSET_INSTANCE(TEXTURE, m_path);
+ m_path = "DYNATEXT"+name;
+ ADD_ASSET_INSTANCE(Texture, m_path, this);
+
+ glGenTextures( 1, &m_textureID );
+ printf("booo %d\n", m_textureID);
+ glBindTexture( GL_TEXTURE_2D, m_textureID );
+ glCopyTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, width, height, 0 );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glBindTexture( GL_TEXTURE_2D, 0 );
+
+ GLERRORCHECK;
+}
+
Texture* Texture::Generate()
{
return new Texture();
@@ -164,6 +199,14 @@
return a;
}
+MAutoPtr< Texture > Texture::LoadDynamicTexture(const MString& name)
+{
+ MAutoPtr< MercuryAsset > t( AssetFactory::GetInstance().Generate("Texture", "DYNATEXT"+name) );
+ Texture *a = (Texture*)t.Ptr();
+// a->LoadImagePath( path );
+ return a;
+}
+
bool Texture::m_initTextureSuccess = false;
uint8_t Texture::m_activeTextures = 0;
uint32_t Texture::m_textureBinds = 0;
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-06-13 02:35:10 UTC (rev 315)
+++ Mercury2/src/Texture.h 2009-06-13 21:30:11 UTC (rev 316)
@@ -10,6 +10,8 @@
Texture();
virtual ~Texture();
+ void Clean();
+
virtual void Init(MercuryNode* node);
virtual void Render(const MercuryNode* node);
@@ -21,9 +23,14 @@
inline static uint8_t NumberActiveTextures() { return m_activeTextures; }
inline static uint32_t ReadAndResetBindCount() { uint32_t t = m_textureBinds; m_textureBinds = 0; return t; }
+ inline uint32_t TextureID() const { return m_textureID; }
+ void MakeDynamic(uint16_t width, uint16_t height, const MString& name);
+
+
static Texture* Generate();
static MAutoPtr< Texture > LoadFromFile(const MString& path);
+ static MAutoPtr< Texture > LoadDynamicTexture(const MString& name);
void SetRawData(RawImageData* raw);
private:
@@ -33,8 +40,8 @@
void UnbindTexture();
const RawImageData* m_raw;
- unsigned int m_textureID;
- unsigned int m_textureResource;
+ uint32_t m_textureID;
+ uint32_t m_textureResource;
static bool m_initTextureSuccess;
static uint8_t m_activeTextures;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-13 02:35:27
|
Revision: 315
http://hgengine.svn.sourceforge.net/hgengine/?rev=315&view=rev
Author: axlecrusher
Date: 2009-06-13 02:35:10 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
error checking
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/src/GLHeaders.h
Mercury2/src/MercuryFBO.cpp
Mercury2/src/RenderBuffer.cpp
Added Paths:
-----------
Mercury2/src/GLHelpers.cpp
Mercury2/src/GLHelpers.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-06-13 01:13:21 UTC (rev 314)
+++ Mercury2/adv_set.c 2009-06-13 02:35:10 UTC (rev 315)
@@ -12,7 +12,7 @@
src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \
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/RenderBuffer.cpp"
+ src/RenderBuffer.cpp src/GLHelpers.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/src/GLHeaders.h
===================================================================
--- Mercury2/src/GLHeaders.h 2009-06-13 01:13:21 UTC (rev 314)
+++ Mercury2/src/GLHeaders.h 2009-06-13 02:35:10 UTC (rev 315)
@@ -18,4 +18,19 @@
#include <GL/freeglut.h>
#endif
+#include <GLHelpers.h>
+
+#define GLERRORCHECK { \
+uint32_t e = glGetError(); \
+if ( e != GL_NO_ERROR ) { \
+printf("GL Error:%s\n", GlError2String(e).c_str()); \
+assert(0); } }
+
+#define CHECKFBO { \
+uint32_t e = glCheckFramebufferStatus(GL_FRAMEBUFFER); \
+if ( e != GL_FRAMEBUFFER_COMPLETE ) { \
+printf("GL FBO Error:%s\n", GlError2String(e).c_str()); \
+assert(0); } }
+
+
#endif
\ No newline at end of file
Added: Mercury2/src/GLHelpers.cpp
===================================================================
--- Mercury2/src/GLHelpers.cpp (rev 0)
+++ Mercury2/src/GLHelpers.cpp 2009-06-13 02:35:10 UTC (rev 315)
@@ -0,0 +1,72 @@
+#include <GLHeaders.h>
+#include <GLHelpers.h>
+
+MString GlError2String(uint32_t e)
+{
+ switch (e)
+ {
+ case GL_INVALID_ENUM:
+ return "Invalid Enum";
+ case GL_INVALID_VALUE:
+ return "Invalid Value";
+ case GL_INVALID_OPERATION:
+ return "Invalid Operation";
+ case GL_STACK_OVERFLOW:
+ return "Stack Overflow";
+ case GL_STACK_UNDERFLOW:
+ return "Stack Underflow";
+ case GL_OUT_OF_MEMORY:
+ return "Out of Memory";
+ case GL_INVALID_FRAMEBUFFER_OPERATION:
+ return "Invalid FBO Operation";
+ case GL_FRAMEBUFFER_UNSUPPORTED:
+ return "FBO Unsupported";
+ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
+ return "FBO Incomplete Attachment";
+ case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
+ return "FBO Incomplete Missing Attachment";
+// case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
+// return "FBO Incomplete Dimensions";
+// case GL_FRAMEBUFFER_INCOMPLETE_FORMATS:
+// return "FBO Incomplete Formats";
+ case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
+ return "FBO Incomplete Draw Buffer";
+ case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
+ return "FBO Incomplete Read Buffer";
+ case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
+ return "FBO Incomplete Multisample";
+ }
+ return "Unknown Error";
+}
+
+/****************************************************************************
+ * 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/GLHelpers.h
===================================================================
--- Mercury2/src/GLHelpers.h (rev 0)
+++ Mercury2/src/GLHelpers.h 2009-06-13 02:35:10 UTC (rev 315)
@@ -0,0 +1,36 @@
+#include <global.h>
+#include <MercuryUtil.h>
+
+MString GlError2String(uint32_t e);
+
+/****************************************************************************
+ * 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/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp 2009-06-13 01:13:21 UTC (rev 314)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-13 02:35:10 UTC (rev 315)
@@ -17,6 +17,8 @@
{
m_initiated = true;
glGenFramebuffersEXT(1, &m_fboID);
+ CHECKFBO;
+ GLERRORCHECK;
}
void MercuryFBO::PreRender(const MercuryMatrix& matrix)
@@ -30,6 +32,8 @@
if (m_lastRendered != m_fboID)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboID);
+// CHECKFBO; //Incomplete FBO
+ GLERRORCHECK;
m_lastRendered = m_fboID;
// m_lastInStask = m_lastRendered;
}
@@ -46,10 +50,15 @@
// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_lastInStask);
// m_lastRendered = m_lastInStask;
+
+ RenderableNode::PostRender(matrix);
+ GLERRORCHECK;
+
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind
- m_lastRendered = 0;
+ CHECKFBO;
+ GLERRORCHECK;
- RenderableNode::PostRender(matrix);
+ m_lastRendered = 0;
}
uint32_t MercuryFBO::m_lastRendered = NULL;
Modified: Mercury2/src/RenderBuffer.cpp
===================================================================
--- Mercury2/src/RenderBuffer.cpp 2009-06-13 01:13:21 UTC (rev 314)
+++ Mercury2/src/RenderBuffer.cpp 2009-06-13 02:35:10 UTC (rev 315)
@@ -37,6 +37,9 @@
void RenderBuffer::Render(const MercuryNode* node)
{
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_bufferID);
+// CHECKFBO; //missing attachment
+ GLERRORCHECK;
+
if ( NeedResize() ) AllocateSpace();
//attach to FBO
@@ -47,25 +50,31 @@
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_TEXTURE_2D, m_textureID, 0);
else
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_RENDERBUFFER_EXT, m_bufferID);
+ CHECKFBO;
+ GLERRORCHECK;
}
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ GLERRORCHECK;
}
void RenderBuffer::PostRender(const MercuryNode* node)
{
- static uint32_t t = time(NULL);
- if ( (m_type == TEXTURE) && (time(NULL) > (t+3)))
-// if (false)
+ GLERRORCHECK;
+ if ( m_type == TEXTURE )
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
+ GLERRORCHECK;
+
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
+ GLERRORCHECK;
+
// printf("active %d\n", Texture::NumberActiveTextures() );
//this works with a "normal" texture, FBO texture is still white
@@ -75,6 +84,7 @@
glBindTexture(GL_TEXTURE_2D, m_textureID);
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+ GLERRORCHECK;
glBegin(GL_QUADS);
glTexCoord2d(0,1);
@@ -88,8 +98,10 @@
glTexCoord2d(0,0);
glVertex3i(-1, 1, -1);
+
glEnd();
+ GLERRORCHECK;
glBindTexture(GL_TEXTURE_2D, 0);
// glActiveTexture( GL_TEXTURE0 );
@@ -97,9 +109,13 @@
// glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable( GL_TEXTURE_2D );
+ GLERRORCHECK;
+
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
+
+ GLERRORCHECK;
}
}
@@ -107,12 +123,11 @@
{
m_initiated = true;
glGenRenderbuffersEXT(1, &m_bufferID);
-
- if (m_type == TEXTURE)
- {
- glGenTextures(1, &m_textureID);
- printf("texture rb %d\n", m_textureID);
- }
+ CHECKFBO;
+ GLERRORCHECK;
+ if (m_type == TEXTURE) glGenTextures(1, &m_textureID);
+ CHECKFBO;
+ GLERRORCHECK;
}
void RenderBuffer::AllocateSpace()
@@ -127,6 +142,7 @@
}
else
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GLType(), m_width, m_height);
+ GLERRORCHECK;
}
bool RenderBuffer::NeedResize()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-13 01:13:22
|
Revision: 314
http://hgengine.svn.sourceforge.net/hgengine/?rev=314&view=rev
Author: axlecrusher
Date: 2009-06-13 01:13:21 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
FBO
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/scenegraph.xml
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-06-13 01:11:52 UTC (rev 313)
+++ Mercury2/adv_set.c 2009-06-13 01:13:21 UTC (rev 314)
@@ -11,7 +11,8 @@
src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \
src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \
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/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
+ src/RenderBuffer.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-13 01:11:52 UTC (rev 313)
+++ Mercury2/scenegraph.xml 2009-06-13 01:13:21 UTC (rev 314)
@@ -12,28 +12,31 @@
<asset type="hgmdlmodel" file="map.hgmdl" />
</node>
</node>
- <node type="renderablenode" name="lampForest">
- <asset type="texture" file="lamp.png"/>
- <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
- <node type="transformnode" rotx="-90" name="lamp">
- <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
- <node type="renderablenode">
- <asset type="hgmdlmodel" file="lamp.hgmdl" />
+ <node type="mercuryfbo" >
+ <asset type="renderbuffer" buffertype="texture" />
+ <node type="renderablenode" name="lampForest">
+ <asset type="texture" file="lamp.png"/>
+ <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
+ <node type="transformnode" rotx="-90" name="lamp">
+ <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
+ <node type="renderablenode">
+ <asset type="hgmdlmodel" file="lamp.hgmdl" />
+ </node>
</node>
</node>
+ <node type="transformnode" movx="1" fallback="lampForest.lamprow.lamp" />
+ <node type="transformnode" movx="2" fallback="lampForest.lamprow.lamp" />
+ <node type="transformnode" movx="3" fallback="lampForest.lamprow.lamp" />
+ <node type="transformnode" movx="-1" fallback="lampForest.lamprow.lamp" />
+ <node type="transformnode" movx="-2" fallback="lampForest.lamprow.lamp" />
+ <node type="transformnode" movx="-3" fallback="lampForest.lamprow.lamp" />
</node>
- <node type="transformnode" movx="1" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="2" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="3" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="-1" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="-2" fallback="lampForest.lamprow.lamp" />
- <node type="transformnode" movx="-3" fallback="lampForest.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>
</SceneGraph>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-13 01:11:53
|
Revision: 313
http://hgengine.svn.sourceforge.net/hgengine/?rev=313&view=rev
Author: axlecrusher
Date: 2009-06-13 01:11:52 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
comment
Modified Paths:
--------------
Mercury2/src/RenderGraph.cpp
Modified: Mercury2/src/RenderGraph.cpp
===================================================================
--- Mercury2/src/RenderGraph.cpp 2009-06-13 01:10:48 UTC (rev 312)
+++ Mercury2/src/RenderGraph.cpp 2009-06-13 01:11:52 UTC (rev 313)
@@ -9,14 +9,15 @@
if (m_node)
{
- m_node->PreRender( *m_matrix );
+ m_node->PreRender( *m_matrix ); //calls on children assets
m = m_node->ManipulateMatrix( *m_matrix );
if ( m_node->IsHidden() || m_node->IsCulled(m) ) return;
m.Transpose();
glLoadMatrixf( m.Ptr() );
- m_node->Render( m );
+ m_node->Render( m ); //calls on children assets
}
+ //call render on other render graph entries under me
std::list< RenderGraphEntry >::iterator i;
for (i = m_children.begin(); i != m_children.end(); ++i )
i->Render();
@@ -24,8 +25,8 @@
if (m_node)
{
glLoadMatrixf( m.Ptr() );
- m_node->PostRender( m );
- }
+ m_node->PostRender( m ); //calls on children assets
+ }
}
void RenderGraph::Build( MercuryNode* node )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-13 01:10:49
|
Revision: 312
http://hgengine.svn.sourceforge.net/hgengine/?rev=312&view=rev
Author: axlecrusher
Date: 2009-06-13 01:10:48 +0000 (Sat, 13 Jun 2009)
Log Message:
-----------
broken FBO
Added Paths:
-----------
Mercury2/src/MercuryFBO.cpp
Mercury2/src/MercuryFBO.h
Mercury2/src/RenderBuffer.cpp
Mercury2/src/RenderBuffer.h
Added: Mercury2/src/MercuryFBO.cpp
===================================================================
--- Mercury2/src/MercuryFBO.cpp (rev 0)
+++ Mercury2/src/MercuryFBO.cpp 2009-06-13 01:10:48 UTC (rev 312)
@@ -0,0 +1,87 @@
+#include <MercuryFBO.h>
+#include <GLHeaders.h>
+
+REGISTER_NODE_TYPE(MercuryFBO);
+
+MercuryFBO::MercuryFBO()
+ :m_fboID(0), m_initiated(false)
+{
+}
+
+MercuryFBO::~MercuryFBO()
+{
+ if (m_fboID != 0) glDeleteFramebuffersEXT(1, &m_fboID);
+}
+
+void MercuryFBO::InitFBOBeforeRender()
+{
+ m_initiated = true;
+ glGenFramebuffersEXT(1, &m_fboID);
+}
+
+void MercuryFBO::PreRender(const MercuryMatrix& matrix)
+{
+ if ( !m_initiated ) InitFBOBeforeRender();
+ RenderableNode::PreRender(matrix);
+}
+
+void MercuryFBO::Render(const MercuryMatrix& matrix)
+{
+ if (m_lastRendered != m_fboID)
+ {
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboID);
+ m_lastRendered = m_fboID;
+// m_lastInStask = m_lastRendered;
+ }
+
+// glPushAttrib(GL_VIEWPORT_BIT);
+ // glViewport(0,0,width, height);
+
+ RenderableNode::Render(matrix);
+}
+
+void MercuryFBO::PostRender(const MercuryMatrix& matrix)
+{
+// glPopAttrib();
+
+// glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_lastInStask);
+// m_lastRendered = m_lastInStask;
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind
+ m_lastRendered = 0;
+
+ RenderableNode::PostRender(matrix);
+}
+
+uint32_t MercuryFBO::m_lastRendered = NULL;
+
+/****************************************************************************
+ * 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/MercuryFBO.h
===================================================================
--- Mercury2/src/MercuryFBO.h (rev 0)
+++ Mercury2/src/MercuryFBO.h 2009-06-13 01:10:48 UTC (rev 312)
@@ -0,0 +1,64 @@
+#ifndef MERCURYFBO_H
+#define MERCURYFBO_H
+
+#include <RenderableNode.h>
+
+class MercuryFBO : public RenderableNode
+{
+ public:
+ MercuryFBO();
+ virtual ~MercuryFBO();
+
+ virtual void PreRender(const MercuryMatrix& matrix);
+ virtual void Render(const MercuryMatrix& matrix);
+ virtual void PostRender(const MercuryMatrix& matrix);
+
+ GENRTTI(MercuryFBO);
+
+ private:
+ void InitFBOBeforeRender();
+
+ uint32_t m_fboID;
+ bool m_initiated;
+ static uint32_t m_lastRendered;
+
+ uint32_t m_lastInStask;
+
+ protected:
+// AlignedBuffer<float> m_vertexData;
+// AlignedBuffer<uint16_t> m_indexData;
+};
+
+#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. *
+ ***************************************************************************/
Added: Mercury2/src/RenderBuffer.cpp
===================================================================
--- Mercury2/src/RenderBuffer.cpp (rev 0)
+++ Mercury2/src/RenderBuffer.cpp 2009-06-13 01:10:48 UTC (rev 312)
@@ -0,0 +1,228 @@
+#include <RenderBuffer.h>
+#include <GLHeaders.h>
+#include <MercuryWindow.h>
+#include <RenderableNode.h>
+
+#include <Texture.h>
+
+REGISTER_ASSET_TYPE(RenderBuffer);
+
+RenderBuffer::RenderBuffer()
+ :MercuryAsset(), m_bufferID(0), m_textureID(0), m_initiated(false), m_width(0), m_height(0), m_type(NONE), m_bound(false)
+{
+}
+
+RenderBuffer::~RenderBuffer()
+{
+ if (m_bufferID != 0) glDeleteRenderbuffersEXT(1, &m_bufferID);
+}
+
+void RenderBuffer::Init(MercuryNode* node)
+{
+ MercuryAsset::Init( node );
+
+ RenderableNode* rn = RenderableNode::Cast( node );
+ if ( rn )
+ {
+ rn->AddPreRender( this );
+ rn->AddPostRender( this );
+ }
+}
+
+void RenderBuffer::PreRender(const MercuryNode* node)
+{
+ if ( !m_initiated ) InitRenderBuffer();
+}
+
+void RenderBuffer::Render(const MercuryNode* node)
+{
+ glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_bufferID);
+ if ( NeedResize() ) AllocateSpace();
+
+ //attach to FBO
+// if ( !m_bound )
+ {
+ m_bound = true;
+ if ( m_type == TEXTURE )
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_TEXTURE_2D, m_textureID, 0);
+ else
+ glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GLAttachPoint(), GL_RENDERBUFFER_EXT, m_bufferID);
+ }
+
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+}
+
+void RenderBuffer::PostRender(const MercuryNode* node)
+{
+ static uint32_t t = time(NULL);
+ if ( (m_type == TEXTURE) && (time(NULL) > (t+3)))
+// if (false)
+ {
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity();
+
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity();
+
+// printf("active %d\n", Texture::NumberActiveTextures() );
+
+ //this works with a "normal" texture, FBO texture is still white
+ glActiveTexture( GL_TEXTURE0 );
+ glClientActiveTextureARB(GL_TEXTURE0);
+ glEnable( GL_TEXTURE_2D );
+ glBindTexture(GL_TEXTURE_2D, m_textureID);
+ glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+
+
+ glBegin(GL_QUADS);
+ glTexCoord2d(0,1);
+ glVertex3i(-1, -1, -1);
+
+ glTexCoord2d(1,1);
+ glVertex3i(1, -1, -1);
+
+ glTexCoord2d(1,0);
+ glVertex3i(1, 1, -1);
+
+ glTexCoord2d(0,0);
+ glVertex3i(-1, 1, -1);
+ glEnd();
+
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+// glActiveTexture( GL_TEXTURE0 );
+// glClientActiveTextureARB(GL_TEXTURE0);
+// glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisable( GL_TEXTURE_2D );
+
+ glPopMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ }
+}
+
+void RenderBuffer::InitRenderBuffer()
+{
+ m_initiated = true;
+ glGenRenderbuffersEXT(1, &m_bufferID);
+
+ if (m_type == TEXTURE)
+ {
+ glGenTextures(1, &m_textureID);
+ printf("texture rb %d\n", m_textureID);
+ }
+}
+
+void RenderBuffer::AllocateSpace()
+{
+ m_width = MercuryWindow::GetCurrentWindow()->Width();
+ m_height = MercuryWindow::GetCurrentWindow()->Height();
+
+ if (m_type == TEXTURE)
+ {
+ glBindTexture(GL_TEXTURE_2D, m_textureID);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ }
+ else
+ glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GLType(), m_width, m_height);
+}
+
+bool RenderBuffer::NeedResize()
+{
+ int width = MercuryWindow::GetCurrentWindow()->Width();
+ int height = MercuryWindow::GetCurrentWindow()->Height();
+ return (width != m_width)||(height != m_height);
+}
+
+int RenderBuffer::GLType()
+{
+ switch( m_type )
+ {
+ case TEXTURE:
+ case COLOR:
+ return GL_RGBA;
+ case DEPTH:
+ return GL_DEPTH_COMPONENT;
+ case STENCIL:
+ return GL_STENCIL_INDEX;
+ default:
+ return 0;
+ }
+}
+
+int RenderBuffer::GLAttachPoint()
+{
+ switch( m_type )
+ {
+ case TEXTURE:
+ case COLOR:
+ return GL_COLOR_ATTACHMENT0_EXT;
+ case DEPTH:
+ return GL_DEPTH_ATTACHMENT_EXT;
+ case STENCIL:
+ return GL_STENCIL_ATTACHMENT_EXT;
+ default:
+ return 0;
+ }
+}
+
+void RenderBuffer::LoadFromXML(const XMLNode& node)
+{
+ MString t = node.Attribute("buffertype");
+
+ if ( t == "color" )
+ {
+ m_type = COLOR;
+ }
+ else if ( t == "depth" )
+ {
+ m_type = DEPTH;
+ }
+ else if ( t == "stencil" )
+ {
+ m_type = STENCIL;
+ }
+ else if ( t == "texture" )
+ {
+ m_type = TEXTURE;
+ }
+}
+
+RenderBuffer* RenderBuffer::Generate()
+{
+ return new RenderBuffer();
+}
+
+/****************************************************************************
+ * 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/RenderBuffer.h
===================================================================
--- Mercury2/src/RenderBuffer.h (rev 0)
+++ Mercury2/src/RenderBuffer.h 2009-06-13 01:10:48 UTC (rev 312)
@@ -0,0 +1,85 @@
+#ifndef RENDERBUFFER_H
+#define RENDERBUFFER_H
+
+#include <MercuryAsset.h>
+
+class RenderBuffer : public MercuryAsset
+{
+ public:
+ enum RBType
+ {
+ NONE,
+ COLOR,
+ DEPTH,
+ STENCIL,
+ TEXTURE
+ };
+
+ RenderBuffer();
+ virtual ~RenderBuffer();
+
+ virtual void Init(MercuryNode* node);
+
+ virtual void PreRender(const MercuryNode* node);
+ virtual void Render(const MercuryNode* node);
+ virtual void PostRender(const MercuryNode* node);
+ virtual void LoadFromXML(const XMLNode& node);
+
+ static RenderBuffer* Generate();
+
+ private:
+ virtual void InitRenderBuffer();
+ void AllocateSpace();
+ bool NeedResize();
+
+ int GLType();
+ int GLAttachPoint();
+
+ uint32_t m_bufferID;
+ uint32_t m_textureID;
+ bool m_initiated;
+ int m_width, m_height;
+ RBType m_type;
+
+ bool m_bound;
+
+// static void* m_lastRendered;
+
+ protected:
+// AlignedBuffer<float> m_vertexData;
+// AlignedBuffer<uint16_t> m_indexData;
+};
+
+#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. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-07 23:58:41
|
Revision: 311
http://hgengine.svn.sourceforge.net/hgengine/?rev=311&view=rev
Author: axlecrusher
Date: 2009-06-07 23:58:40 +0000 (Sun, 07 Jun 2009)
Log Message:
-----------
make billboard a type of transform node
Modified Paths:
--------------
Mercury2/modules/BillboardNode.cpp
Mercury2/modules/BillboardNode.h
Mercury2/scenegraph.xml
Mercury2/src/TransformNode.cpp
Mercury2/src/TransformNode.h
Modified: Mercury2/modules/BillboardNode.cpp
===================================================================
--- Mercury2/modules/BillboardNode.cpp 2009-06-05 01:00:49 UTC (rev 310)
+++ Mercury2/modules/BillboardNode.cpp 2009-06-07 23:58:40 UTC (rev 311)
@@ -5,15 +5,17 @@
REGISTER_NODE_TYPE(BillboardNode);
BillboardNode::BillboardNode()
- :m_sphere(false)
+ :TransformNode(), m_sphere(false)
{
}
-MercuryMatrix BillboardNode::ManipulateMatrix(const MercuryMatrix& matrix)
+void BillboardNode::Update(float dTime)
{
+ TransformNode::Update( dTime );
+
//Compute the object's center point (position?) in world space
MercuryVertex center(0,0,0,1);
- center = matrix * center;
+ center = TransformNode::GetGlobalMatrix() * center;
MercuryVector objToEye = (EYE - center);
MercuryVector objToEyeProj( objToEye );
@@ -30,7 +32,7 @@
if (up[1] < 0) f *= -1;
//needs to be the local axis to rotate around
- MercuryMatrix global(matrix);
+ MercuryMatrix global( TransformNode::GetGlobalMatrix() );
MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(m_billboardAxis, f);
//spherical below
@@ -45,12 +47,20 @@
global.Rotate( mtmp );
- return RenderableNode::ManipulateMatrix( global );
+ m_billboardMatrix = global;
+
+ //notify children that our global matrix has changed
+ SetTaint(true);
}
+const MercuryMatrix& BillboardNode::GetGlobalMatrix() const
+{
+ return m_billboardMatrix;
+}
+
void BillboardNode::LoadFromXML(const XMLNode& node)
{
- RenderableNode::LoadFromXML(node);
+ TransformNode::LoadFromXML(node);
if ( !node.Attribute("billboardaxis").empty() )
m_billboardAxis = MercuryVector::CreateFromString( node.Attribute("billboardaxis") );
Modified: Mercury2/modules/BillboardNode.h
===================================================================
--- Mercury2/modules/BillboardNode.h 2009-06-05 01:00:49 UTC (rev 310)
+++ Mercury2/modules/BillboardNode.h 2009-06-07 23:58:40 UTC (rev 311)
@@ -1,20 +1,27 @@
#ifndef BILLBOARDNODE_H
#define BILLBOARDNODE_H
-#include <RenderableNode.h>
+#include <TransformNode.h>
#include <MercuryVertex.h>
-class BillboardNode : public RenderableNode
+class BillboardNode : public TransformNode
{
public:
BillboardNode();
- virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
+ virtual void Update(float dTime);
+
+// virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
+ virtual const MercuryMatrix& GetGlobalMatrix() const;
+
virtual void LoadFromXML(const XMLNode& node);
+ GENRTTI(BillboardNode);
+
private:
MercuryVector m_billboardAxis;
bool m_sphere;
+ MercuryMatrix m_billboardMatrix;
};
#endif
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-05 01:00:49 UTC (rev 310)
+++ Mercury2/scenegraph.xml 2009-06-07 23:58:40 UTC (rev 311)
@@ -17,7 +17,9 @@
<node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
<node type="transformnode" rotx="-90" name="lamp">
<node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
- <asset type="hgmdlmodel" file="lamp.hgmdl" />
+ <node type="renderablenode">
+ <asset type="hgmdlmodel" file="lamp.hgmdl" />
+ </node>
</node>
</node>
<node type="transformnode" movx="1" fallback="lampForest.lamprow.lamp" />
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2009-06-05 01:00:49 UTC (rev 310)
+++ Mercury2/src/TransformNode.cpp 2009-06-07 23:58:40 UTC (rev 311)
@@ -154,6 +154,11 @@
}
}
+const MercuryMatrix& TransformNode::GetGlobalMatrix() const
+{
+ return m_globalMatrix;
+}
+
void RotatorNode::Update(float dTime)
{
MQuaternion r = GetRotation();
Modified: Mercury2/src/TransformNode.h
===================================================================
--- Mercury2/src/TransformNode.h 2009-06-05 01:00:49 UTC (rev 310)
+++ Mercury2/src/TransformNode.h 2009-06-07 23:58:40 UTC (rev 311)
@@ -23,7 +23,8 @@
inline const MercuryVertex& GetPosition() const { return m_position; }
inline const MQuaternion& GetRotation() const { return m_rotation; }
- inline const MercuryMatrix& GetGlobalMatrix() const { return m_globalMatrix; }
+// inline const MercuryMatrix& GetGlobalMatrix() const { return m_globalMatrix; }
+ virtual const MercuryMatrix& GetGlobalMatrix() const;
const MercuryMatrix& GetParentMatrix() const;
void SetTaint(bool taint);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-05 01:00:58
|
Revision: 310
http://hgengine.svn.sourceforge.net/hgengine/?rev=310&view=rev
Author: axlecrusher
Date: 2009-06-05 01:00:49 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
remove printf
Modified Paths:
--------------
Mercury2/modules/BillboardNode.cpp
Modified: Mercury2/modules/BillboardNode.cpp
===================================================================
--- Mercury2/modules/BillboardNode.cpp 2009-06-05 00:45:50 UTC (rev 309)
+++ Mercury2/modules/BillboardNode.cpp 2009-06-05 01:00:49 UTC (rev 310)
@@ -39,7 +39,6 @@
objToEye.NormalizeSelf();
angleCos = objToEyeProj.DotProduct( objToEye );
f = ACOS(angleCos);
- printf("%f %f\n", angleCos, f);
if (objToEye[1] < 0) f *= -1;
if (angleCos < 0.99999) mtmp *= MQuaternion::CreateFromAxisAngle(MercuryVector(1,0,0), f);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-05 00:45:56
|
Revision: 309
http://hgengine.svn.sourceforge.net/hgengine/?rev=309&view=rev
Author: axlecrusher
Date: 2009-06-05 00:45:50 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
sherical billboarding works now
Modified Paths:
--------------
Mercury2/modules/BillboardNode.cpp
Mercury2/modules/BillboardNode.h
Mercury2/scenegraph.xml
Modified: Mercury2/modules/BillboardNode.cpp
===================================================================
--- Mercury2/modules/BillboardNode.cpp 2009-06-04 10:46:55 UTC (rev 308)
+++ Mercury2/modules/BillboardNode.cpp 2009-06-05 00:45:50 UTC (rev 309)
@@ -4,6 +4,11 @@
REGISTER_NODE_TYPE(BillboardNode);
+BillboardNode::BillboardNode()
+ :m_sphere(false)
+{
+}
+
MercuryMatrix BillboardNode::ManipulateMatrix(const MercuryMatrix& matrix)
{
//Compute the object's center point (position?) in world space
@@ -27,30 +32,21 @@
//needs to be the local axis to rotate around
MercuryMatrix global(matrix);
MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(m_billboardAxis, f);
- global.Rotate( mtmp );
-
- MercuryMatrix m = RenderableNode::ManipulateMatrix( global );
-
-/* //spherical below
- objToEye.NormalizeSelf();
- angleCos = objToEyeProj.DotProduct( objToEye );
- if ((angleCos < 0.99990) && (angleCos > -0.9999))
+
+ //spherical below
+ if ( m_sphere )
{
- printf("%f\n", angleCos);
- float f = ACOS(angleCos)*RADDEG;
- MercuryMatrix mtmp;
- if (objToEye[1] < 0)
- mtmp.RotateAngAxis(f, 1, 0, 0);
- else
- mtmp.RotateAngAxis(f, -1, 0, 0);
-// m.Print();
-// m = m * mtmp;
-// m.Print();
- printf("********************\n");
-// mtmp.Print();
+ objToEye.NormalizeSelf();
+ angleCos = objToEyeProj.DotProduct( objToEye );
+ f = ACOS(angleCos);
+ printf("%f %f\n", angleCos, f);
+ if (objToEye[1] < 0) f *= -1;
+ if (angleCos < 0.99999) mtmp *= MQuaternion::CreateFromAxisAngle(MercuryVector(1,0,0), f);
}
-*/
- return m;
+
+ global.Rotate( mtmp );
+
+ return RenderableNode::ManipulateMatrix( global );
}
void BillboardNode::LoadFromXML(const XMLNode& node)
@@ -59,6 +55,9 @@
if ( !node.Attribute("billboardaxis").empty() )
m_billboardAxis = MercuryVector::CreateFromString( node.Attribute("billboardaxis") );
+
+ if ( !node.Attribute("spheremode").empty() )
+ m_sphere = node.Attribute("spheremode") == "true"?true:false;
}
/****************************************************************************
Modified: Mercury2/modules/BillboardNode.h
===================================================================
--- Mercury2/modules/BillboardNode.h 2009-06-04 10:46:55 UTC (rev 308)
+++ Mercury2/modules/BillboardNode.h 2009-06-05 00:45:50 UTC (rev 309)
@@ -7,11 +7,14 @@
class BillboardNode : public RenderableNode
{
public:
+ BillboardNode();
+
virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
virtual void LoadFromXML(const XMLNode& node);
private:
MercuryVector m_billboardAxis;
+ bool m_sphere;
};
#endif
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-04 10:46:55 UTC (rev 308)
+++ Mercury2/scenegraph.xml 2009-06-05 00:45:50 UTC (rev 309)
@@ -16,7 +16,7 @@
<asset type="texture" file="lamp.png"/>
<node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
<node type="transformnode" rotx="-90" name="lamp">
- <node type="billboardnode" billboardaxis="0,0,1" >
+ <node type="billboardnode" billboardaxis="0,0,1" spheremode="true" >
<asset type="hgmdlmodel" file="lamp.hgmdl" />
</node>
</node>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 10:48:03
|
Revision: 308
http://hgengine.svn.sourceforge.net/hgengine/?rev=308&view=rev
Author: axlecrusher
Date: 2009-06-04 10:46:55 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
use axis from XML
Modified Paths:
--------------
Mercury2/modules/BillboardNode.cpp
Modified: Mercury2/modules/BillboardNode.cpp
===================================================================
--- Mercury2/modules/BillboardNode.cpp 2009-06-04 01:43:22 UTC (rev 307)
+++ Mercury2/modules/BillboardNode.cpp 2009-06-04 10:46:55 UTC (rev 308)
@@ -26,7 +26,7 @@
//needs to be the local axis to rotate around
MercuryMatrix global(matrix);
- MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(MercuryVector(0,0,1), f);
+ MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(m_billboardAxis, f);
global.Rotate( mtmp );
MercuryMatrix m = RenderableNode::ManipulateMatrix( global );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 02:14:34
|
Revision: 307
http://hgengine.svn.sourceforge.net/hgengine/?rev=307&view=rev
Author: axlecrusher
Date: 2009-06-04 01:43:22 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
fix camera doing funky things at exactly PI/2
it would flip a translation axis and possibly disappear into a void
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-06-04 01:02:38 UTC (rev 306)
+++ Mercury2/src/Camera.cpp 2009-06-04 01:43:22 UTC (rev 307)
@@ -18,7 +18,7 @@
MercuryMatrix local, parent(GetParentMatrix());
- MQuaternion r( GetRotation().normalize() );
+ MQuaternion r( GetRotation() );
//compute the world space look vector (broken if camera is in transform node)
m_lookAt = MercuryVector(0,0,-1); //by default camera looks down world Z
@@ -50,14 +50,18 @@
m_y += m->dy/1200.0f;
m_x += m->dx/1200.0f;
- m_y = Clamp(-Q_PI/2, Q_PI/2, m_y);
+ m_y = Clamp((-Q_PI/2.0f)+0.00001f, (Q_PI/2.0f)-0.00001f, m_y);
MQuaternion qLeftRight = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x);
MercuryVector LocalX = MercuryVector( 1, 0, 0 );
LocalX = LocalX.Rotate( qLeftRight );
MQuaternion qUpDown = MQuaternion::CreateFromAxisAngle(LocalX, m_y);
+
+// qLeftRight.Print();
+
SetRotation(qUpDown*qLeftRight);
+// GetRotation().Print();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 01:22:34
|
Revision: 305
http://hgengine.svn.sourceforge.net/hgengine/?rev=305&view=rev
Author: axlecrusher
Date: 2009-06-04 00:34:24 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
billboarding works
Modified Paths:
--------------
Mercury2/modules/BillboardNode.cpp
Mercury2/modules/BillboardNode.h
Mercury2/scenegraph.xml
Modified: Mercury2/modules/BillboardNode.cpp
===================================================================
--- Mercury2/modules/BillboardNode.cpp 2009-06-04 00:29:27 UTC (rev 304)
+++ Mercury2/modules/BillboardNode.cpp 2009-06-04 00:34:24 UTC (rev 305)
@@ -6,8 +6,6 @@
MercuryMatrix BillboardNode::ManipulateMatrix(const MercuryMatrix& matrix)
{
- MercuryMatrix m = RenderableNode::ManipulateMatrix( matrix );
-
//Compute the object's center point (position?) in world space
MercuryVertex center(0,0,0,1);
center = matrix * center;
@@ -18,29 +16,22 @@
//vector from object to eye projected on XZ
objToEyeProj[1] = 0; objToEyeProj.NormalizeSelf();
-// MercuryVector objLookAt(0,0,1); //origional look vector of object
-// objLookAt = matrix * objLookAt; //convert to world space
-// objLookAt.NormalizeSelf();
+ MercuryVector objLookAt(0,0,-1); //origional look vector of object
-// objLookAt.Print();
-
-// MercuryVector up = (objLookAt.CrossProduct( objToEyeProj )).Normalize();
-// up = objLookAt;
-// up.Print();
-
- MercuryVector up(0,0,1); //we wan't the camera's up
-
- float angleCos = LOOKAT.DotProduct(objToEyeProj);
+ MercuryVector up = objLookAt.CrossProduct(objToEyeProj);
+ float angleCos = objLookAt.DotProduct(objToEyeProj);
- if ((angleCos < 0.99990) && (angleCos > -0.9999))
- {
- float f = ACOS(angleCos)*RADDEG;
- MercuryMatrix mtmp;
- mtmp.RotateAngAxis(f, up[0], up[1], up[2]);
- m = m * mtmp;
- }
+ float f = ACOS(angleCos);//*RADDEG;
+ if (up[1] < 0) f *= -1;
- //spherical below
+ //needs to be the local axis to rotate around
+ MercuryMatrix global(matrix);
+ MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(MercuryVector(0,0,1), f);
+ global.Rotate( mtmp );
+
+ MercuryMatrix m = RenderableNode::ManipulateMatrix( global );
+
+/* //spherical below
objToEye.NormalizeSelf();
angleCos = objToEyeProj.DotProduct( objToEye );
if ((angleCos < 0.99990) && (angleCos > -0.9999))
@@ -53,15 +44,23 @@
else
mtmp.RotateAngAxis(f, -1, 0, 0);
// m.Print();
- m = m * mtmp;
+// m = m * mtmp;
// m.Print();
printf("********************\n");
// mtmp.Print();
}
-
+*/
return m;
}
+void BillboardNode::LoadFromXML(const XMLNode& node)
+{
+ RenderableNode::LoadFromXML(node);
+
+ if ( !node.Attribute("billboardaxis").empty() )
+ m_billboardAxis = MercuryVector::CreateFromString( node.Attribute("billboardaxis") );
+}
+
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/modules/BillboardNode.h
===================================================================
--- Mercury2/modules/BillboardNode.h 2009-06-04 00:29:27 UTC (rev 304)
+++ Mercury2/modules/BillboardNode.h 2009-06-04 00:34:24 UTC (rev 305)
@@ -2,13 +2,16 @@
#define BILLBOARDNODE_H
#include <RenderableNode.h>
+#include <MercuryVertex.h>
class BillboardNode : public RenderableNode
{
public:
virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix);
+ virtual void LoadFromXML(const XMLNode& node);
private:
+ MercuryVector m_billboardAxis;
};
#endif
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-06-04 00:29:27 UTC (rev 304)
+++ Mercury2/scenegraph.xml 2009-06-04 00:34:24 UTC (rev 305)
@@ -16,7 +16,7 @@
<asset type="texture" file="lamp.png"/>
<node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
<node type="transformnode" rotx="-90" name="lamp">
- <node type="renderablenode" >
+ <node type="billboardnode" billboardaxis="0,0,1" >
<asset type="hgmdlmodel" file="lamp.hgmdl" />
</node>
</node>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 01:22:27
|
Revision: 304
http://hgengine.svn.sourceforge.net/hgengine/?rev=304&view=rev
Author: axlecrusher
Date: 2009-06-04 00:29:27 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
we MUST normalize before multiplying
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2009-06-04 00:11:52 UTC (rev 303)
+++ Mercury2/src/MQuaternion.cpp 2009-06-04 00:29:27 UTC (rev 304)
@@ -180,11 +180,14 @@
MQuaternion MQuaternion::operator * (const MQuaternion &rhs) const
{
+ MQuaternion q1( this->normalize() );
+ MQuaternion q2( rhs.normalize() );
+
MQuaternion result;
- result.m_wxyz[0] = (m_wxyz[0]*rhs.m_wxyz[0])-(m_wxyz[1]*rhs.m_wxyz[1])-(m_wxyz[2]*rhs.m_wxyz[2])-(m_wxyz[3]*rhs.m_wxyz[3]);
- result.m_wxyz[1] = (m_wxyz[0]*rhs.m_wxyz[1])+(m_wxyz[1]*rhs.m_wxyz[0])+(m_wxyz[2]*rhs.m_wxyz[3])-(m_wxyz[3]*rhs.m_wxyz[2]);
- result.m_wxyz[2] = (m_wxyz[0]*rhs.m_wxyz[2])-(m_wxyz[1]*rhs.m_wxyz[3])+(m_wxyz[2]*rhs.m_wxyz[0])+(m_wxyz[3]*rhs.m_wxyz[1]);
- result.m_wxyz[3] = (m_wxyz[0]*rhs.m_wxyz[3])+(m_wxyz[1]*rhs.m_wxyz[2])-(m_wxyz[2]*rhs.m_wxyz[1])+(m_wxyz[3]*rhs.m_wxyz[0]);
+ result.W() = (q1.W()*q2.W())-(q1.X()*q2.X())-(q1.Y()*q2.Y())-(q1.Z()*q2.Z());
+ result.X() = (q1.W()*q2.X())+(q1.X()*q2.W())+(q1.Y()*q2.Z())-(q1.Z()*q2.Y());
+ result.Y() = (q1.W()*q2.Y())-(q1.X()*q2.Z())+(q1.Y()*q2.W())+(q1.Z()*q2.X());
+ result.Z() = (q1.W()*q2.Z())+(q1.X()*q2.Y())-(q1.Y()*q2.X())+(q1.Z()*q2.W());
return result;
}
@@ -208,10 +211,7 @@
}
MQuaternion& MQuaternion::operator *= (const MQuaternion &rhs) {
- m_wxyz[0] = (m_wxyz[0]*rhs.m_wxyz[0])-(m_wxyz[1]*rhs.m_wxyz[1])-(m_wxyz[2]*rhs.m_wxyz[2])-(m_wxyz[3]*rhs.m_wxyz[3]);
- m_wxyz[1] = (m_wxyz[0]*rhs.m_wxyz[1])+(m_wxyz[1]*rhs.m_wxyz[0])+(m_wxyz[2]*rhs.m_wxyz[3])-(m_wxyz[3]*rhs.m_wxyz[2]);
- m_wxyz[2] = (m_wxyz[0]*rhs.m_wxyz[2])-(m_wxyz[1]*rhs.m_wxyz[3])+(m_wxyz[2]*rhs.m_wxyz[0])+(m_wxyz[3]*rhs.m_wxyz[1]);
- m_wxyz[3] = (m_wxyz[0]*rhs.m_wxyz[3])+(m_wxyz[1]*rhs.m_wxyz[2])-(m_wxyz[2]*rhs.m_wxyz[1])+(m_wxyz[3]*rhs.m_wxyz[0]);
+ *this = *this * rhs;
return (*this);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 01:02:54
|
Revision: 306
http://hgengine.svn.sourceforge.net/hgengine/?rev=306&view=rev
Author: axlecrusher
Date: 2009-06-04 01:02:38 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
updates
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Mercury2/src/MQuaternion.h
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2009-06-04 00:34:24 UTC (rev 305)
+++ Mercury2/src/MQuaternion.cpp 2009-06-04 01:02:38 UTC (rev 306)
@@ -16,6 +16,7 @@
m_wxyz[1] = X;
m_wxyz[2] = Y;
m_wxyz[3] = Z;
+ *this = this->normalize();
}
MQuaternion::MQuaternion(float W, const MercuryVertex& p)
@@ -24,13 +25,9 @@
m_wxyz[1] = p[0];
m_wxyz[2] = p[1];
m_wxyz[3] = p[2];
+ *this = this->normalize();
}
-float & MQuaternion::operator [] (WXYZ i)
-{
- return m_wxyz[i]; //haha we won't even get here.
-}
-
void MQuaternion::SetEuler(const MercuryVertex& angles)
{
float X = angles[0]/2.0f; //roll
@@ -50,6 +47,8 @@
m_wxyz[1] = sx*cy*cz-cx*sy*sz;//q2
m_wxyz[2] = cx*sy*cz+sx*cy*sz;//q3
m_wxyz[3] = cx*cy*sz-sx*sy*cz;//q4
+
+ *this = this->normalize();
}
MQuaternion MQuaternion::CreateFromAxisAngle(const MercuryVertex& p, const float radians)
@@ -65,9 +64,9 @@
float sn = SIN(radians/2.0f);
m_wxyz[0] = COS(radians/2.0f);
- m_wxyz[1] = sn * p[0];
- m_wxyz[2] = sn * p[1];
- m_wxyz[3] = sn * p[2];
+ m_wxyz[1] = sn * v[0];
+ m_wxyz[2] = sn * v[1];
+ m_wxyz[3] = sn * v[2];
*this = this->normalize();
}
Modified: Mercury2/src/MQuaternion.h
===================================================================
--- Mercury2/src/MQuaternion.h 2009-06-04 00:34:24 UTC (rev 305)
+++ Mercury2/src/MQuaternion.h 2009-06-04 01:02:38 UTC (rev 306)
@@ -25,8 +25,8 @@
void ToAxisAngle(float& angle, float& x, float& y, float& z) const;
///Access a component of the quaternion with the [] operator
- float & operator[] ( const WXYZ rhs );
- const float & operator[] ( const WXYZ rhs ) const;
+ inline float & operator[] ( const WXYZ i ) { return m_wxyz[i]; }
+ inline const float & operator[] ( const WXYZ i ) const { return m_wxyz[i]; }
///Returns the magnitude
float magnitude() const;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 00:12:01
|
Revision: 303
http://hgengine.svn.sourceforge.net/hgengine/?rev=303&view=rev
Author: axlecrusher
Date: 2009-06-04 00:11:52 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
show axes
Modified Paths:
--------------
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryVBO.cpp
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2009-06-04 00:11:19 UTC (rev 302)
+++ Mercury2/src/MercuryAsset.cpp 2009-06-04 00:11:52 UTC (rev 303)
@@ -1,6 +1,8 @@
#include <MercuryAsset.h>
#include <RenderableNode.h>
+#include <GLHeaders.h>
+
MercuryAsset::MercuryAsset()
:m_isInstanced(false), m_boundingVolume(NULL), m_loadState(NONE)
{
@@ -35,6 +37,22 @@
SetLoadState( LOADED );
}
+void MercuryAsset::DrawAxes()
+{
+ glBegin(GL_LINES);
+ glColor3f(1,0,0);
+ glVertex3f(0,0,0);
+ glVertex3f(0.5,0,0);
+ glColor3f(0,1,0);
+ glVertex3f(0,0,0);
+ glVertex3f(0,0.5,0);
+ glColor3f(0,0,1);
+ glVertex3f(0,0,0);
+ glVertex3f(0,0,0.5);
+ glColor3f(1,1,1);
+ glEnd();
+}
+
AssetFactory& AssetFactory::GetInstance()
{
static AssetFactory* instance = NULL;
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2009-06-04 00:11:19 UTC (rev 302)
+++ Mercury2/src/MercuryAsset.h 2009-06-04 00:11:52 UTC (rev 303)
@@ -40,6 +40,8 @@
inline const BoundingVolume* GetBoundingVolume() const { return m_boundingVolume; }
inline const MString& Path() const { return m_path; }
+
+ void DrawAxes();
protected:
void SetLoadState(LoadState ls); //thread safe
LoadState GetLoadState(); //thread safe
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-06-04 00:11:19 UTC (rev 302)
+++ Mercury2/src/MercuryVBO.cpp 2009-06-04 00:11:52 UTC (rev 303)
@@ -57,6 +57,7 @@
m_lastVBOrendered = this;
if (m_boundingVolume && SHOWBOUNDINGVOLUME) m_boundingVolume->Render();
+ DrawAxes();
}
void MercuryVBO::InitVBO()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-04 00:11:32
|
Revision: 302
http://hgengine.svn.sourceforge.net/hgengine/?rev=302&view=rev
Author: axlecrusher
Date: 2009-06-04 00:11:19 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
updates, trying to fix broken rotations
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Mercury2/src/MQuaternion.cpp
Mercury2/src/MQuaternion.h
Mercury2/src/MercuryMatrix.cpp
Mercury2/src/TransformNode.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-06-03 01:22:25 UTC (rev 301)
+++ Mercury2/src/Camera.cpp 2009-06-04 00:11:19 UTC (rev 302)
@@ -26,7 +26,7 @@
m_lookAt.NormalizeSelf();
LOOKAT = m_lookAt;
- r[MQuaternion::W] *= -1; //reverse angle for camera
+ r.W() *= -1; //reverse angle for camera
//rotate then translate since we are a camera
r.toMatrix4( local );
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2009-06-03 01:22:25 UTC (rev 301)
+++ Mercury2/src/MQuaternion.cpp 2009-06-04 00:11:19 UTC (rev 302)
@@ -61,11 +61,15 @@
void MQuaternion::FromAxisAngle(const MercuryVertex& p, const float radians)
{
+ MercuryVertex v( p.Normalize() );
+
float sn = SIN(radians/2.0f);
m_wxyz[0] = COS(radians/2.0f);
m_wxyz[1] = sn * p[0];
m_wxyz[2] = sn * p[1];
m_wxyz[3] = sn * p[2];
+
+ *this = this->normalize();
}
void MQuaternion::ToAxisAngle(float& angle, float& x, float& y, float& z) const
@@ -115,28 +119,33 @@
//Converts MQuaternion to 4x4 Matrix(3x3 Spatial)
void MQuaternion::toMatrix( MercuryMatrix &matrix ) const {
- float X = 2*m_wxyz[1]*m_wxyz[1]; //Reduced calulation for speed
- float Y = 2*m_wxyz[2]*m_wxyz[2];
- float Z = 2*m_wxyz[3]*m_wxyz[3];
- float a = 2*m_wxyz[0]*m_wxyz[1];
- float b = 2*m_wxyz[0]*m_wxyz[2];
- float c = 2*m_wxyz[0]*m_wxyz[3];
- float d = 2*m_wxyz[1]*m_wxyz[2];
- float e = 2*m_wxyz[1]*m_wxyz[3];
- float f = 2*m_wxyz[2]*m_wxyz[3];
+ MQuaternion q( this->normalize() );
+
+ //Reduced calulation for speed
+ float xx = 2*q.X()*q.X();
+ float xy = 2*q.X()*q.Y();
+ float xz = 2*q.X()*q.Z();
+ float xw = 2*q.X()*q.W();
+
+ float yy = 2*q.Y()*q.Y();
+ float yz = 2*q.Y()*q.Z();
+ float yw = 2*q.Y()*q.W();
+
+ float zz = 2*q.Z()*q.Z();
+ float zw = 2*q.Z()*q.W();
//row major
- matrix[0][0] = 1-Y-Z;
- matrix[0][1] = d-c;
- matrix[0][2] = e+b;
+ matrix[0][0] = 1-yy-zz;
+ matrix[0][1] = xy-zw;
+ matrix[0][2] = xz+yw;
- matrix[1][0] = d+c;
- matrix[1][1] = 1-X-Z;
- matrix[1][2] = f-a;
+ matrix[1][0] = xy+zw;
+ matrix[1][1] = 1-xx-zz;
+ matrix[1][2] = yz-xw;
- matrix[2][0] = e-b;
- matrix[2][1] = f+a;
- matrix[2][2] = 1-X-Y;
+ matrix[2][0] = xz-yw;
+ matrix[2][1] = yz+xw;
+ matrix[2][2] = 1-xx-yy;
}
void MQuaternion::toMatrix4( MercuryMatrix &matrix ) const {
Modified: Mercury2/src/MQuaternion.h
===================================================================
--- Mercury2/src/MQuaternion.h 2009-06-03 01:22:25 UTC (rev 301)
+++ Mercury2/src/MQuaternion.h 2009-06-04 00:11:19 UTC (rev 302)
@@ -9,7 +9,7 @@
///Mathematical Quaternion (Used for Rotation)
class MQuaternion {
public:
- enum WXYZ { W = 0, X, Y, Z };
+ enum WXYZ { QW = 0, QX, QY, QZ };
//Defines a Quaternion such that q = w + xi + yj + zk
MQuaternion();
@@ -67,6 +67,11 @@
void Print(const MString& s = "MQuaternion") const;
+ inline float& W() { return m_wxyz[0]; }
+ inline float& X() { return m_wxyz[1]; }
+ inline float& Y() { return m_wxyz[2]; }
+ inline float& Z() { return m_wxyz[3]; }
+
// private:
FloatRow m_wxyz;
} M_ALIGN(32);
Modified: Mercury2/src/MercuryMatrix.cpp
===================================================================
--- Mercury2/src/MercuryMatrix.cpp 2009-06-03 01:22:25 UTC (rev 301)
+++ Mercury2/src/MercuryMatrix.cpp 2009-06-04 00:11:19 UTC (rev 302)
@@ -123,7 +123,7 @@
void MercuryMatrix::Rotate(const MQuaternion& q)
{
MercuryMatrix m;
- q.normalize().toMatrix4( m );
+ q.toMatrix4( m );
*this *= m;
}
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2009-06-03 01:22:25 UTC (rev 301)
+++ Mercury2/src/TransformNode.cpp 2009-06-04 00:11:19 UTC (rev 302)
@@ -104,13 +104,13 @@
//only change the values that exist in the XML
if ( !node.Attribute("rotx").empty() )
- rot *= MQuaternion::CreateFromAxisAngle(MercuryVector(1,0,0), StrToFloat( node.Attribute("rotx") ));
+ rot *= MQuaternion::CreateFromAxisAngle(MercuryVector(1,0,0), StrToFloat( node.Attribute("rotx") )*DEGRAD );
if ( !node.Attribute("roty").empty() )
- rot *= MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), StrToFloat( node.Attribute("roty") ));
+ rot *= MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), StrToFloat( node.Attribute("roty") )*DEGRAD );
if ( !node.Attribute("rotz").empty() )
- rot *= MQuaternion::CreateFromAxisAngle(MercuryVector(0,0,1), StrToFloat( node.Attribute("rotz") ));
+ rot *= MQuaternion::CreateFromAxisAngle(MercuryVector(0,0,1), StrToFloat( node.Attribute("rotz") )*DEGRAD );
if ( !node.Attribute("scalex").empty() )
scale.SetX( StrToFloat( node.Attribute("scalex") ) );
@@ -157,8 +157,8 @@
void RotatorNode::Update(float dTime)
{
MQuaternion r = GetRotation();
- r[MQuaternion::X] += (dTime)*25;
- r[MQuaternion::Y] += (dTime)*75;
+ r.X() += (dTime)*25;
+ r.Y() += (dTime)*75;
SetRotation( r );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-03 01:22:27
|
Revision: 301
http://hgengine.svn.sourceforge.net/hgengine/?rev=301&view=rev
Author: axlecrusher
Date: 2009-06-03 01:22:25 +0000 (Wed, 03 Jun 2009)
Log Message:
-----------
construct from string
Modified Paths:
--------------
Mercury2/src/MercuryVertex.cpp
Mercury2/src/MercuryVertex.h
Modified: Mercury2/src/MercuryVertex.cpp
===================================================================
--- Mercury2/src/MercuryVertex.cpp 2009-06-01 00:17:40 UTC (rev 300)
+++ Mercury2/src/MercuryVertex.cpp 2009-06-03 01:22:25 UTC (rev 301)
@@ -121,6 +121,14 @@
return (q * MQuaternion(0, *this) * q.reciprocal()).ToVector();
}
+MercuryVertex MercuryVertex::CreateFromString(const MString& s)
+{
+ float x,y,z;
+ sscanf(s.c_str(), "%f,%f,%f", &x, &y, &z);
+ return MercuryVertex(x,y,z);
+}
+
+
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/src/MercuryVertex.h
===================================================================
--- Mercury2/src/MercuryVertex.h 2009-06-01 00:17:40 UTC (rev 300)
+++ Mercury2/src/MercuryVertex.h 2009-06-03 01:22:25 UTC (rev 301)
@@ -83,6 +83,8 @@
void Print(const MString& s = "Vertex") const;
MercuryVertex Rotate(const MQuaternion& q) const;
+
+ static MercuryVertex CreateFromString(const MString& s);
// float (*this)[3];
FloatRow m_xyzw;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-06-01 01:02:25
|
Revision: 300
http://hgengine.svn.sourceforge.net/hgengine/?rev=300&view=rev
Author: axlecrusher
Date: 2009-06-01 00:17:40 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
side step
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-05-31 22:46:35 UTC (rev 299)
+++ Mercury2/src/Camera.cpp 2009-06-01 00:17:40 UTC (rev 300)
@@ -8,6 +8,7 @@
CameraNode::CameraNode()
:TransformNode(), m_x(0), m_y(0)
{
+ m_lookAt = MercuryVector(0,0,-1);
REGISTER_FOR_MESSAGE( INPUTEVENT_MOUSE );
}
@@ -64,11 +65,19 @@
{
MercuryVector p = GetPosition();
float a = 0;
+ float b = 0;
- if ( KeyboardInput::IsKeyDown(25) ) a += dTime*2;
- if ( KeyboardInput::IsKeyDown(39) ) a -= dTime*2;
+ if ( KeyboardInput::IsKeyDown(25) ) a += dTime*2; //W
+ if ( KeyboardInput::IsKeyDown(39) ) a -= dTime*2; //S
+ if ( KeyboardInput::IsKeyDown(38) ) b -= dTime*2; //A
+ if ( KeyboardInput::IsKeyDown(40) ) b += dTime*2; //D
+
+ MercuryVector Xaxis = m_lookAt.CrossProduct( MercuryVector(0,1,0) );
+ Xaxis.NormalizeSelf();
+
p += m_lookAt * a;
+ p += Xaxis * b;
// p.SetY(0); //lock to ground
SetPosition( p );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-05-31 22:46:43
|
Revision: 299
http://hgengine.svn.sourceforge.net/hgengine/?rev=299&view=rev
Author: axlecrusher
Date: 2009-05-31 22:46:35 +0000 (Sun, 31 May 2009)
Log Message:
-----------
just clamp values
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Mercury2/src/MercuryUtil.h
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-05-31 22:29:07 UTC (rev 298)
+++ Mercury2/src/Camera.cpp 2009-05-31 22:46:35 UTC (rev 299)
@@ -46,17 +46,10 @@
{
MouseInput* m = (MouseInput*)data;
- //keep m_y within [-PI -> PI]
- if( m_y < -Q_PI ) m_y += Q_PI*2.;
- if( m_y > Q_PI ) m_y -= Q_PI*2.;
- //if m_y is < -PI/2 or m_y > PI/2 one must invert the axes
-
m_y += m->dy/1200.0f;
+ m_x += m->dx/1200.0f;
- if (ABS(m_y) > Q_PI/2)
- m_x -= m->dx/1200.0f;
- else
- m_x += m->dx/1200.0f;
+ m_y = Clamp(-Q_PI/2, Q_PI/2, m_y);
MQuaternion qLeftRight = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x);
MercuryVector LocalX = MercuryVector( 1, 0, 0 );
Modified: Mercury2/src/MercuryUtil.h
===================================================================
--- Mercury2/src/MercuryUtil.h 2009-05-31 22:29:07 UTC (rev 298)
+++ Mercury2/src/MercuryUtil.h 2009-05-31 22:46:35 UTC (rev 299)
@@ -45,6 +45,14 @@
return t1<t2?t1:t2;
}
+template<typename T>
+const T& Clamp(const T& min, const T& max, const T& value)
+{
+ if (value > max) return max;
+ if (value < min) return min;
+ return value;
+}
+
//This counter is used with singletons to
//ensure proper destruction order of the
//singleton
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-05-31 22:29:15
|
Revision: 298
http://hgengine.svn.sourceforge.net/hgengine/?rev=298&view=rev
Author: axlecrusher
Date: 2009-05-31 22:29:07 +0000 (Sun, 31 May 2009)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-05-31 21:38:26 UTC (rev 297)
+++ Mercury2/src/Camera.cpp 2009-05-31 22:29:07 UTC (rev 298)
@@ -46,19 +46,23 @@
{
MouseInput* m = (MouseInput*)data;
- m_y += m->dy/1200.0f;
- m_x += m->dx/1200.0f;
-
//keep m_y within [-PI -> PI]
if( m_y < -Q_PI ) m_y += Q_PI*2.;
if( m_y > Q_PI ) m_y -= Q_PI*2.;
-
//if m_y is < -PI/2 or m_y > PI/2 one must invert the axes
+
+ m_y += m->dy/1200.0f;
+
+ if (ABS(m_y) > Q_PI/2)
+ m_x -= m->dx/1200.0f;
+ else
+ m_x += m->dx/1200.0f;
MQuaternion qLeftRight = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x);
- MercuryVector LocalLookAt = MercuryVector( 1, 0, 0 );
- LocalLookAt = LocalLookAt.Rotate( qLeftRight );
- MQuaternion qUpDown = MQuaternion::CreateFromAxisAngle(LocalLookAt, m_y);
+ MercuryVector LocalX = MercuryVector( 1, 0, 0 );
+ LocalX = LocalX.Rotate( qLeftRight );
+
+ MQuaternion qUpDown = MQuaternion::CreateFromAxisAngle(LocalX, m_y);
SetRotation(qUpDown*qLeftRight);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-05-31 21:38:45
|
Revision: 297
http://hgengine.svn.sourceforge.net/hgengine/?rev=297&view=rev
Author: cnlohr
Date: 2009-05-31 21:38:26 +0000 (Sun, 31 May 2009)
Log Message:
-----------
add info for user
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-05-31 21:07:59 UTC (rev 296)
+++ Mercury2/src/Camera.cpp 2009-05-31 21:38:26 UTC (rev 297)
@@ -49,6 +49,12 @@
m_y += m->dy/1200.0f;
m_x += m->dx/1200.0f;
+ //keep m_y within [-PI -> PI]
+ if( m_y < -Q_PI ) m_y += Q_PI*2.;
+ if( m_y > Q_PI ) m_y -= Q_PI*2.;
+
+ //if m_y is < -PI/2 or m_y > PI/2 one must invert the axes
+
MQuaternion qLeftRight = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x);
MercuryVector LocalLookAt = MercuryVector( 1, 0, 0 );
LocalLookAt = LocalLookAt.Rotate( qLeftRight );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-05-31 21:08:07
|
Revision: 296
http://hgengine.svn.sourceforge.net/hgengine/?rev=296&view=rev
Author: cnlohr
Date: 2009-05-31 21:07:59 +0000 (Sun, 31 May 2009)
Log Message:
-----------
fix camera
Modified Paths:
--------------
Mercury2/src/Camera.cpp
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-05-31 19:47:00 UTC (rev 295)
+++ Mercury2/src/Camera.cpp 2009-05-31 21:07:59 UTC (rev 296)
@@ -48,13 +48,12 @@
m_y += m->dy/1200.0f;
m_x += m->dx/1200.0f;
-
- MercuryVector Xaxis = m_lookAt.CrossProduct( MercuryVector(0,1,0) );
- Xaxis.NormalizeSelf();
-
- MQuaternion qx = MQuaternion::CreateFromAxisAngle(Xaxis, m_y);
- MQuaternion qy = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x);
- SetRotation(qx * qy);
+
+ MQuaternion qLeftRight = MQuaternion::CreateFromAxisAngle(MercuryVector(0,1,0), m_x);
+ MercuryVector LocalLookAt = MercuryVector( 1, 0, 0 );
+ LocalLookAt = LocalLookAt.Rotate( qLeftRight );
+ MQuaternion qUpDown = MQuaternion::CreateFromAxisAngle(LocalLookAt, m_y);
+ SetRotation(qUpDown*qLeftRight);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-05-31 19:47:08
|
Revision: 295
http://hgengine.svn.sourceforge.net/hgengine/?rev=295&view=rev
Author: axlecrusher
Date: 2009-05-31 19:47:00 +0000 (Sun, 31 May 2009)
Log Message:
-----------
update
Modified Paths:
--------------
Mercury2/scenegraph.xml
Modified: Mercury2/scenegraph.xml
===================================================================
--- Mercury2/scenegraph.xml 2009-05-31 15:53:44 UTC (rev 294)
+++ Mercury2/scenegraph.xml 2009-05-31 19:47:00 UTC (rev 295)
@@ -2,7 +2,8 @@
<!-- <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">
+-->
+ <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0">
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/>
</node>
<node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|