|
From: <axl...@us...> - 2009-08-14 03:22:25
|
Revision: 477
http://hgengine.svn.sourceforge.net/hgengine/?rev=477&view=rev
Author: axlecrusher
Date: 2009-08-14 01:56:19 +0000 (Fri, 14 Aug 2009)
Log Message:
-----------
try a different attenuation
Modified Paths:
--------------
Mercury2/Themes/default/Graphic/pointLight.frag
Mercury2/src/Light.cpp
Mercury2/src/Light.h
Modified: Mercury2/Themes/default/Graphic/pointLight.frag
===================================================================
--- Mercury2/Themes/default/Graphic/pointLight.frag 2009-08-12 03:42:02 UTC (rev 476)
+++ Mercury2/Themes/default/Graphic/pointLight.frag 2009-08-14 01:56:19 UTC (rev 477)
@@ -41,9 +41,11 @@
if( dist > HG_LightAtten.w ) discard;
- float att = HG_LightColor.a / (HG_LightAtten.x + HG_LightAtten.y * dist +
- HG_LightAtten.z * dist * dist);
+// float att = HG_LightColor.a / (HG_LightAtten.x + HG_LightAtten.y * dist+
+// HG_LightAtten.z * dist * dist);
+ float att = ((HG_LightAtten.w - (HG_LightAtten.y * dist) - (HG_LightAtten.z * dist * dist))/HG_LightAtten.w) * HG_LightColor.a;
+
vec3 diffuse = texture2D(HG_Texture1, coord).rgb;
vec3 R = reflect(-lightDir, norm);
Modified: Mercury2/src/Light.cpp
===================================================================
--- Mercury2/src/Light.cpp 2009-08-12 03:42:02 UTC (rev 476)
+++ Mercury2/src/Light.cpp 2009-08-14 01:56:19 UTC (rev 477)
@@ -33,6 +33,7 @@
m_worldPosition = FindModelViewMatrix();
m_worldPosition2 = FindGlobalMatrix();
CURRENTRENDERGRAPH->AddDifferedLight( this );
+// m_boundingVolume->Render();
// m_parent = node;
}
@@ -40,6 +41,8 @@
{
if ( !node.Attribute("atten").empty() )
StrTo3Float(node.Attribute("atten"), m_atten);
+
+ ComputeRadius();
if ( !node.Attribute("power").empty() )
m_power = StrToFloat(node.Attribute("power"), 1.0);
@@ -47,6 +50,9 @@
if ( !node.Attribute("fullscreen").empty() )
m_fullscreen = node.Attribute("fullscreen")=="true"?true:false;
+ if ( !node.Attribute("radius").empty() )
+ m_radius = StrToFloat(node.Attribute("radius"), 1.0);
+
if ( !node.Attribute("shader").empty() )
{
MString key = node.Attribute("shader");
@@ -63,8 +69,8 @@
m_fullscreen = node.Attribute("fullscreen")=="true"?true:false;
}
- ComputeRadius();
-
+ BuildBoundingBox();
+
MercuryNode::LoadFromXML( node );
}
@@ -116,7 +122,10 @@
m_radius = Clamp<float>(0.0f, 1000.0f, d);
printf("light radius %f\n", m_radius);
+}
+void Light::BuildBoundingBox()
+{
SAFE_DELETE( m_boundingVolume );
m_boundingVolume = new BoundingBox(MercuryVertex(0,0,0), MercuryVertex(m_radius,m_radius,m_radius) );
}
Modified: Mercury2/src/Light.h
===================================================================
--- Mercury2/src/Light.h 2009-08-12 03:42:02 UTC (rev 476)
+++ Mercury2/src/Light.h 2009-08-14 01:56:19 UTC (rev 477)
@@ -30,6 +30,7 @@
private:
void StrTo3Float(const MString& s, float* a);
void ComputeRadius();
+ void BuildBoundingBox();
float m_atten[3];
float m_color[3];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-08-18 05:24:57
|
Revision: 487
http://hgengine.svn.sourceforge.net/hgengine/?rev=487&view=rev
Author: cnlohr
Date: 2009-08-18 05:24:42 +0000 (Tue, 18 Aug 2009)
Log Message:
-----------
add attic
Added Paths:
-----------
Mercury2/attic/
Mercury2/attic/SelfTraversal.txt
Added: Mercury2/attic/SelfTraversal.txt
===================================================================
--- Mercury2/attic/SelfTraversal.txt (rev 0)
+++ Mercury2/attic/SelfTraversal.txt 2009-08-18 05:24:42 UTC (rev 487)
@@ -0,0 +1,135 @@
+(From Charles Lohr)
+
+At one point I was considering stackless traversal of the scene graph for limited sections.
+I chose not to do this in the end due to the limitation of being unable to adaptively change
+it based on which objects are hidden/visible.
+
+This code is below:
+
+void Viewport::GoAll( const float fDtime )
+{
+ MercuryNode * n;
+ int depth = 0;
+
+ if( NeedsRebuild() )
+ {
+ printf( "Xxxx\n" );
+ }
+
+ //Update pass
+ n = this;
+ while( n )
+ {
+ n->Update( fDtime );
+ n = n->TraversalNextNode( this, depth );
+ }
+
+ //Prerender pass
+ n = this;
+ while( n )
+ {
+ //If we're hidden, skip to the next traversable element
+ if( n->IsHidden() )
+ {
+ //Make sure we have a next sibling...
+ while( n && n != this && !n->NextSibling() )
+ {
+ depth--;
+ n = n->Parent();
+ }
+
+ if( !n || n == this )
+ break;
+
+ n = n->NextSibling();
+ }
+
+
+ const MercuryMatrix& matrix = n->FindGlobalMatrix();
+
+ TransformNode * tn = dynamic_cast< TransformNode * >( n );
+ if( tn )
+ tn->HandleMatrixOperations();
+
+ n->PreRender( matrix );
+
+ if( n->Parent() )
+ n->Parent()->SetCulled( n->Parent()->IsCulled() && n->IsCulled() );
+
+ //Traverse next
+/*
+ MercuryNode * ret;
+ if( ret = n->FirstChild() )
+ {
+ depth++;
+ n = ret;
+ }
+ else if( ret = n->NextSibling() )
+ n = ret;
+ else if( ret = n->Parent() )
+ {
+ depth--;
+
+ while( ret && ret != this && !ret->NextSibling() )
+ {
+ depth--;
+ ret = ret->Parent();
+ }
+
+ if( !ret || ret == this )
+ return 0;
+
+ n = ret->m_nextSibling;
+ }
+ else
+ return 0;
+*/
+
+ n = n->TraversalNextNode( this, depth );
+ }
+
+ n = this;
+ while( n )
+ {
+ if( n->IsHidden() || IsCulled() )
+ {
+ //Make sure we have a next sibling...
+ while( n && n != this && !n->NextSibling() )
+ {
+ depth--;
+ n = n->Parent();
+ }
+
+ if( !n || n == this )
+ break;
+
+ n = n->NextSibling();
+ }
+
+ const MercuryMatrix& matrix = n->FindGlobalMatrix();
+ const MercuryMatrix& modelView = n->FindModelViewMatrix(); //get the one computed in the last transform
+
+ glLoadMatrix( modelView );
+
+ ShaderAttribute sa;
+ sa.type = ShaderAttribute::TYPE_MATRIX;
+ sa.value.matrix = matrix.Ptr();
+ Shader::SetAttribute("HG_ModelMatrix", sa);
+
+ if ( n->m_useAlphaPath )
+ CURRENTRENDERGRAPH->AddAlphaNode(n);
+ else
+ n->Render( modelView );
+
+ glLoadMatrix( modelView );
+ Shader::SetAttribute("HG_ModelMatrix", sa);
+
+ if ( !n->m_useAlphaPath )
+ n->PostRender( modelView );
+
+ n = n->TraversalNextNode( this, depth );
+ }
+
+ this->PostRender( FindModelViewMatrix() );
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-09-26 18:07:35
|
Revision: 539
http://hgengine.svn.sourceforge.net/hgengine/?rev=539&view=rev
Author: cnlohr
Date: 2009-09-26 18:07:23 +0000 (Sat, 26 Sep 2009)
Log Message:
-----------
add constant time allocator for specialty tasks
Modified Paths:
--------------
Mercury2/adv_set.c
Added Paths:
-----------
Mercury2/src/MercuryCTA.cpp
Mercury2/src/MercuryCTA.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-09-04 06:11:23 UTC (rev 538)
+++ Mercury2/adv_set.c 2009-09-26 18:07:23 UTC (rev 539)
@@ -14,7 +14,7 @@
src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDifferedLights.cpp \
- src/MercuryLog.cpp"
+ src/MercuryLog.cpp src/MercuryCTA.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Added: Mercury2/src/MercuryCTA.cpp
===================================================================
--- Mercury2/src/MercuryCTA.cpp (rev 0)
+++ Mercury2/src/MercuryCTA.cpp 2009-09-26 18:07:23 UTC (rev 539)
@@ -0,0 +1,95 @@
+#include "MercuryCTA.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+MercuryCTA::MercuryCTA( int inElementSize, int iDefaultSize )
+{
+ iElementSize = inElementSize;
+ iCurSize = iDefaultSize;
+
+ ibmFree = (void**)::malloc( iCurSize * sizeof( void * ) );
+ ibmHead = &ibmFree[iCurSize-1];
+
+ void * vData = ::malloc( iDefaultSize * iElementSize );
+
+ pHeadToFree = new PtrPair( vData, 0 );
+
+ //TODO: Test performance of reverse numbering, so the first blocks are allocated before the later ones.
+ for( void ** i = ibmFree; i != (ibmHead + 1); ++i, vData = ((char*)vData) + iElementSize )
+ *i = vData;
+}
+
+MercuryCTA::~MercuryCTA()
+{
+ for( ; pHeadToFree != 0; )
+ {
+ ::free( pHeadToFree->data );
+ PtrPair * next = pHeadToFree->next;
+ delete pHeadToFree;
+ pHeadToFree = next;
+ }
+ ::free( ibmFree );
+}
+
+void * MercuryCTA::Malloc()
+{
+ //Out of space
+ if( ibmHead < ibmFree )
+ {
+ int iNumOfAddedElements = iCurSize; //iCurSize * 2 - iCurSize
+ iCurSize *= 2;
+
+ ::free( ibmFree );
+ ibmFree = (void**)::malloc( iCurSize * sizeof( void * ) );
+
+ ibmHead = &ibmFree[iNumOfAddedElements-1];
+
+ void * vData = ::malloc( iNumOfAddedElements * iElementSize );
+
+ pHeadToFree = new PtrPair( vData, pHeadToFree );
+
+ //TODO: Test performance of reverse numbering, so the first blocks are allocated before the later ones.
+ for( void** i = ibmFree; i != (ibmHead + 1); i++, vData = ((char*)vData) + iElementSize )
+ *i = vData;
+ }
+ return *(ibmHead--);
+}
+
+void MercuryCTA::Free( void * data )
+{
+ ibmHead++;
+ *ibmHead = data;
+}
+
+
+/****************************************************************************
+ * Copyright (C) 2009 by Charles Lohr *
+ * *
+ * *
+ * 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/MercuryCTA.h
===================================================================
--- Mercury2/src/MercuryCTA.h (rev 0)
+++ Mercury2/src/MercuryCTA.h 2009-09-26 18:07:23 UTC (rev 539)
@@ -0,0 +1,61 @@
+#ifndef _CTA_H
+#define _CTA_H
+
+class MercuryCTA
+{
+public:
+ MercuryCTA( int inElementSize, int iDefaultSize );
+ ~MercuryCTA();
+
+ void * Malloc();
+ void Free( void * data );
+private:
+ void ** ibmFree;
+ void ** ibmHead;
+ int iElementSize;
+ int iCurSize;
+
+ class PtrPair
+ {
+ public:
+ PtrPair( void * id, PtrPair * parent ) : data( id ), next( parent ) { }
+ void * data;
+ PtrPair * next;
+ };
+
+ PtrPair * pHeadToFree;
+};
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2009 by Charles Lohr *
+ * *
+ * *
+ * 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-10-16 22:56:40
|
Revision: 572
http://hgengine.svn.sourceforge.net/hgengine/?rev=572&view=rev
Author: axlecrusher
Date: 2009-10-16 22:56:32 +0000 (Fri, 16 Oct 2009)
Log Message:
-----------
updates
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/modules/Terrain.cpp
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-10-13 01:44:38 UTC (rev 571)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-10-16 22:56:32 UTC (rev 572)
@@ -7,7 +7,7 @@
<node type="transformnode" movz="-5" movx="-4" movy="2">
<node type="TextNode" text="Another test!" font="FONT:FreeMonoBold.hgfont" size=".01" width="300" alphaPath="true" alignment="LEFT" />
</node>
- <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5">
+ <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-0.99">
<asset type="texture" file="MODEL:map.png"/>
<asset type="terrain" file="MODEL:map.hgmdl" />
</node>
Modified: Mercury2/modules/Terrain.cpp
===================================================================
--- Mercury2/modules/Terrain.cpp 2009-10-13 01:44:38 UTC (rev 571)
+++ Mercury2/modules/Terrain.cpp 2009-10-16 22:56:32 UTC (rev 572)
@@ -182,7 +182,7 @@
Terrain* t = (Terrain*)m_asset.Ptr();
local = t->ComputePositionLinear( local );
- local[2] += 0.5; //height of player
+ local[2] += 0.75; //height of player
local = m_parentNode->GetGlobalMatrix() * local;
POST_MESSAGE("SetCameraPosition", new VertexDataMessage(local), 0);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-10-25 21:22:43
|
Revision: 582
http://hgengine.svn.sourceforge.net/hgengine/?rev=582&view=rev
Author: cnlohr
Date: 2009-10-25 21:22:33 +0000 (Sun, 25 Oct 2009)
Log Message:
-----------
add beginnings of a textplate -also fix billboarding so you can indicate negative axes.
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/modules/BillboardNode.cpp
Mercury2/modules/BillboardNode.h
Mercury2/modules/Makefile
Mercury2/modules.xml
Added Paths:
-----------
Mercury2/modules/TextPlate.cpp
Mercury2/modules/TextPlate.h
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-10-25 20:37:45 UTC (rev 581)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-10-25 21:22:33 UTC (rev 582)
@@ -2,7 +2,7 @@
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp">
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
<node type="transformnode" movz="-5" movy="2">
- <node type="TextNode" text="test font 123 HELLO WORLD!!! WOOT!" font="FONT:FreeSans.hgfont" size=".01" width="300" alphaPath="true" alignment="FIT_FULL" />
+ <node type="TextPlate" text="test font 123 HELLO WORLD!!! WOOT!" font="FONT:FreeSans.hgfont" size=".01" width="400" alphaPath="true" billboardaxis="0,-1,0" offset="-2,0,0" spheremode="false" />
</node>
<node type="transformnode" movz="-5" movx="-4" movy="2">
<node type="TextNode" text="Another test!" font="FONT:FreeMonoBold.hgfont" size=".01" width="300" alphaPath="true" alignment="LEFT" />
@@ -18,8 +18,8 @@
<asset type="texture" file="MODEL:lamp.png"/>
<asset type="hgmdlmodel" file="MODEL:lampN.hgmdl" />
</node>
- <node type="billboardnode" billboardaxis="0,1,0" spheremode="true" >
- <node type="transformnode" roty="180" scalex="0.1" scaley="0.1" alphaPath="true">
+ <node type="billboardnode" billboardaxis="0,-1,0" spheremode="true" >
+ <node type="transformnode" scalex="0.1" scaley="0.1" alphaPath="true">
<asset type="texture" file="GRAPHIC:flame.png"/>
<asset type="quad"/>
</node>
Modified: Mercury2/modules/BillboardNode.cpp
===================================================================
--- Mercury2/modules/BillboardNode.cpp 2009-10-25 20:37:45 UTC (rev 581)
+++ Mercury2/modules/BillboardNode.cpp 2009-10-25 21:22:33 UTC (rev 582)
@@ -30,10 +30,12 @@
float f = ACOS(angleCos);//*RADDEG;
if (up[1] < 0) f *= -1;
-
+
+ bool bFlip = m_billboardAxis.DotProduct( MercuryVector(1,1,1) ) < 0 ;
+
//needs to be the local axis to rotate around
MercuryMatrix global( TransformNode::GetGlobalMatrix() );
- MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(m_billboardAxis, f);
+ MQuaternion mtmp = MQuaternion::CreateFromAxisAngle(m_billboardAxis, ((bFlip)?(Q_PI-f):f) );
//spherical below
if ( m_sphere )
@@ -42,7 +44,7 @@
angleCos = objToEyeProj.DotProduct( objToEye );
f = ACOS(angleCos);
if (objToEye[1] < 0) f *= -1;
- if (angleCos < 0.99999) mtmp *= MQuaternion::CreateFromAxisAngle(MercuryVector(1,0,0), f);
+ if (angleCos < 0.99999) mtmp *= MQuaternion::CreateFromAxisAngle(MercuryVector(1,0,0), (bFlip)?-f:f );
}
global.Rotate( mtmp );
Modified: Mercury2/modules/BillboardNode.h
===================================================================
--- Mercury2/modules/BillboardNode.h 2009-10-25 20:37:45 UTC (rev 581)
+++ Mercury2/modules/BillboardNode.h 2009-10-25 21:22:33 UTC (rev 582)
@@ -18,7 +18,7 @@
GENRTTI(BillboardNode);
- private:
+ protected:
MercuryVector m_billboardAxis;
bool m_sphere;
MercuryMatrix m_billboardMatrix;
Modified: Mercury2/modules/Makefile
===================================================================
--- Mercury2/modules/Makefile 2009-10-25 20:37:45 UTC (rev 581)
+++ Mercury2/modules/Makefile 2009-10-25 21:22:33 UTC (rev 582)
@@ -1,17 +1,12 @@
-CFLAGS=-O2 -g0 -Wall -I/usr/include/libxml2 -I.. -msse2 -DHAVE_CONFIG -DHGENGINE -fexceptions -fPIC -I../src -I../src/DataTypes -I../src/DataStructures -g
+CFLAGS=-O2 -g0 -Wall -I/usr/include/libxml2 -I.. -msse2 -DHAVE_CONFIG -DHGENGINE -fexceptions -fPIC -I../src -I../src/DataTypes -I../src/DataStructures -g -I.
CXXFLAGS=${CFLAGS}
LDFLAGS=-shared
-all : BillboardNode.so TextNode.so Terrain.so
+all : BillboardNode.so TextNode.so Terrain.so TextPlate.so
clean :
rm -rf *~ *.o *.so
-BillboardNode.so : BillboardNode.o
+%.so : %.o
g++ -o$@ $^ ${LDFLAGS}
-TextNode.so : TextNode.o
- g++ -o$@ $^ ${LDFLAGS}
-
-Terrain.so : Terrain.o
- g++ -o$@ $^ ${LDFLAGS}
Added: Mercury2/modules/TextPlate.cpp
===================================================================
--- Mercury2/modules/TextPlate.cpp (rev 0)
+++ Mercury2/modules/TextPlate.cpp 2009-10-25 21:22:33 UTC (rev 582)
@@ -0,0 +1,60 @@
+#include "TextPlate.h"
+#include <TextNode.h>
+#include <MercuryVertex.h>
+#include <Viewport.h>
+
+REGISTER_NODE_TYPE(TextPlate);
+
+TextPlate::TextPlate()
+ :BillboardNode()
+{
+ m_TextNode = (TextNode*)NODEFACTORY.Generate( "TextNode" );
+ AddChild( m_TextNode );
+}
+
+void TextPlate::Update(float dTime)
+{
+ BillboardNode::Update( dTime );
+ m_billboardMatrix.Translate( m_fvOffset );
+}
+
+
+void TextPlate::LoadFromXML(const XMLNode& node)
+{
+ BillboardNode::LoadFromXML(node);
+ if ( !node.Attribute("offset").empty() )
+ m_fvOffset = MercuryVector::CreateFromString( node.Attribute("offset") );
+ m_TextNode->LoadFromXML(node);
+}
+
+/****************************************************************************
+ * Copyright (C) 2009 by Charles Lohr *
+ * *
+ * *
+ * 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/modules/TextPlate.h
===================================================================
--- Mercury2/modules/TextPlate.h (rev 0)
+++ Mercury2/modules/TextPlate.h 2009-10-25 21:22:33 UTC (rev 582)
@@ -0,0 +1,55 @@
+#ifndef TextPlate_H
+#define TextPlate_H
+
+#include <TransformNode.h>
+#include <BillboardNode.h>
+#include <MercuryVertex.h>
+
+class TextNode;
+
+class TextPlate : public BillboardNode
+{
+public:
+ TextPlate();
+ virtual void Update(float dTime);
+ virtual void LoadFromXML(const XMLNode& node);
+ GENRTTI(TextPlate);
+private:
+ MercuryVector m_fvOffset;
+ TextNode * m_TextNode;
+};
+
+#endif
+
+
+/****************************************************************************
+ * Copyright (C) 2009 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Modified: Mercury2/modules.xml
===================================================================
--- Mercury2/modules.xml 2009-10-25 20:37:45 UTC (rev 581)
+++ Mercury2/modules.xml 2009-10-25 21:22:33 UTC (rev 582)
@@ -2,4 +2,5 @@
<Module src="modules/TextNode.cpp" obj="modules/TextNode" func="InstallTextNode" class="TextNode" />
<Module src="modules/BillboardNode.cpp" obj="modules/BillboardNode" func="InstallBillboardNode" class="BillboardNode" />
<Module src="modules/Terrain.cpp" obj="modules/Terrain" func="InstallTerrainNode" class="TerrainNode"/>
+ <Module src="modules/TextPlate.cpp" obj="modules/TextPlate" func="InstallTextPlate" class="TextPlate"/>
</Modules>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-10-26 01:49:12
|
Revision: 583
http://hgengine.svn.sourceforge.net/hgengine/?rev=583&view=rev
Author: axlecrusher
Date: 2009-10-26 01:49:06 +0000 (Mon, 26 Oct 2009)
Log Message:
-----------
use spatial hash to find triangles
Modified Paths:
--------------
Mercury2/modules/Terrain.cpp
Mercury2/src/DataStructures/SpatialHash.h
Modified: Mercury2/modules/Terrain.cpp
===================================================================
--- Mercury2/modules/Terrain.cpp 2009-10-25 21:22:33 UTC (rev 582)
+++ Mercury2/modules/Terrain.cpp 2009-10-26 01:49:06 UTC (rev 583)
@@ -59,7 +59,7 @@
}
printf("%f %f %f\n", xMax, yMax, zMax);
- m_hash.Allocate(xMax, yMax, zMax, 1);
+ m_hash.Allocate(10, 1);
for(uint16_t i = 0; i < length; i+=3)
{
@@ -114,14 +114,14 @@
if (foundCount > 1) LOG.Write( ssprintf("!!!!!! Found %d triangles !!!!!!", foundCount) );
return result;
}
-/*
+
MercuryVertex Terrain::ComputePosition(const MercuryVertex& p)
{
+ //discard camera height
MercuryVertex l( p );
l[2] = 0;
std::list<MTriangle> triangles = m_hash.FindByXY(p[0], p[1]);
- LOG.Write( ssprintf("%d", triangles.size()) );
MercuryVector result = l;
@@ -130,35 +130,24 @@
std::list<MTriangle>::iterator i = triangles.begin();
for(;i != triangles.end(); ++i)
{
- MTriangle t = *i;
- t.m_verts[0][2] = 0;
- t.m_verts[1][2] = 0;
- t.m_verts[2][2] = 0;
- if ( t.IsInTriangle(l) )
+ //comput against a flat triangle since we don't care if we are at the correct height.
+ MTriangle flatTriangle = *i;
+ flatTriangle.m_verts[0][2] = 0;
+ flatTriangle.m_verts[1][2] = 0;
+ flatTriangle.m_verts[2][2] = 0;
+ if ( flatTriangle.IsInTriangle(l) )
{
- MercuryVector b = t.Barycentric(l);
- t = *i;
-
- MercuryVector pos;//(t.m_verts[0]);
-
- pos = t.m_verts[0]*b[0] + t.m_verts[1]*b[1] + t.m_verts[2]*b[2];
-// pos.Print();
-// pos += (t.m_verts[0] - t.m_verts[1]) * b;
-// pos += (t.m_verts[0] - t.m_verts[2]) * b;
-
-
-// pos.Print();
- LOG.Write("Found");
- result[2] = result[2]<pos[2]?pos[2]:result[2];
-// return pos;
+ MercuryVector b = flatTriangle.Barycentric(l);
+ MercuryVector pos( i->InterpolatePosition(b) );
+ return pos;
}
}
}
return result;
}
-*/
+
TerrainAssetInstance::TerrainAssetInstance(MercuryAsset* asset, MercuryNode* parentNode)
:base(asset, parentNode)
{
@@ -181,7 +170,8 @@
local[3] = 1; //no W
Terrain* t = (Terrain*)m_asset.Ptr();
- local = t->ComputePositionLinear( local );
+// local = t->ComputePositionLinear( local );
+ local = t->ComputePosition( local );
local[2] += 0.75; //height of player
local = m_parentNode->GetGlobalMatrix() * local;
Modified: Mercury2/src/DataStructures/SpatialHash.h
===================================================================
--- Mercury2/src/DataStructures/SpatialHash.h 2009-10-25 21:22:33 UTC (rev 582)
+++ Mercury2/src/DataStructures/SpatialHash.h 2009-10-26 01:49:06 UTC (rev 583)
@@ -12,7 +12,7 @@
SpatialHash()
:m_hashTable(NULL), m_spacing(1.0f)
{
- m_xSize = m_ySize = m_zSize = 0;
+ m_cellCount = 0;
}
~SpatialHash()
@@ -20,31 +20,29 @@
DeleteHash();
}
- void Allocate(uint32_t xmax, uint32_t ymax, uint32_t zmax, uint32_t spacing)
+ void Allocate(uint32_t cellCount, float spacing)
{
DeleteHash();
m_spacing = spacing;
- m_xSize = (abs(xmax)/m_spacing) + 1;
- m_ySize = (abs(ymax)/m_spacing) + 1;
- m_zSize = (abs(zmax)/m_spacing) + 1;
+ cellCount = cellCount==0?1:cellCount;
+ m_cellCount = cellCount;
- uint32_t size = m_xSize*m_ySize*m_zSize;
+ uint32_t size = cellCount*cellCount*cellCount;
m_hashTable = new std::list<T>[size];
}
void Insert(float x, float y, float z, const T& d)
{
- unsigned int ix = abs(x) / m_spacing;
- unsigned int iy = abs(y) / m_spacing;
- unsigned int iz = abs(z) / m_spacing;
+ float s = 1.0f/m_spacing;
+ uint32_t ix = (uint32_t)(abs(x)*s);
+ uint32_t iy = (uint32_t)(abs(y)*s);
+ uint32_t iz = (uint32_t)(abs(z)*s);
- if (ix >= m_xSize || iy >= m_ySize || iz >= m_zSize)
- {
- printf("%d >= %d || %d >= %d || %d >= %d\n", ix, m_xSize, iy, m_ySize, iz, m_zSize);
- return;
- }
+ ix = ix % m_cellCount;
+ iy = iy % m_cellCount;
+ iz = iz % m_cellCount;
//check for and skip duplicate
std::list<T>& cell = m_hashTable[ Index( ix, iy, iz ) ];
@@ -57,46 +55,48 @@
std::list<T> FindByXY(float x, float y)
{
- unsigned int ix = abs(x) / m_spacing;
- unsigned int iy = abs(y) / m_spacing;
+ float s = 1.0f/m_spacing;
+ uint32_t ix = (uint32_t)(abs(x)*s);
+ uint32_t iy = (uint32_t)(abs(y)*s);
+ ix = ix % m_cellCount;
+ iy = iy % m_cellCount;
+
std::list<T> r;
- if (ix < m_xSize || iy < m_ySize )
- {
- for (uint32_t iz = 0; iz < m_zSize; ++iz)
- CopyIntoList(m_hashTable[Index(ix, iy, iz)], r);
- }
+ for (uint32_t iz = 0; iz < m_cellCount; ++iz)
+ CopyIntoList(m_hashTable[Index(ix, iy, iz)], r);
return r;
}
std::list<T> FindByXZ(float x, float z)
{
- unsigned int ix = abs(x) / m_spacing;
- unsigned int iz = abs(z) / m_spacing;
+ float s = 1.0f/m_spacing;
+ uint32_t ix = (uint32_t)(abs(x)*s);
+ uint32_t iz = (uint32_t)(abs(z)*s);
+ ix = ix % m_cellCount;
+ iz = iz % m_cellCount;
+
std::list<T> r;
- if (ix < m_xSize || iz < m_zSize )
- {
- for (uint32_t iy = 0; iy < m_ySize; ++iy)
- CopyIntoList(m_hashTable[Index(ix, iy, iz)], r);
- }
+ for (uint32_t iy = 0; iy < m_cellCount; ++iy)
+ CopyIntoList(m_hashTable[Index(ix, iy, iz)], r);
return r;
}
private:
inline uint32_t Index(uint32_t x, uint32_t y, uint32_t z)
{
- return x + (m_xSize * y) + (m_xSize * m_ySize * z);
+ return x + (m_cellCount * y) + (m_cellCount * m_cellCount * z);
}
void DeleteHash()
{
if (m_hashTable) delete[] m_hashTable;
m_spacing = 1;
- m_xSize = m_ySize = m_zSize = 0;
+ m_cellCount = 0;
}
void CopyIntoList(std::list<T>& in, std::list<T>& r)
@@ -108,7 +108,7 @@
std::list<T>* m_hashTable;
uint32_t m_spacing;
- uint32_t m_xSize, m_ySize, m_zSize;
+ uint32_t m_cellCount;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-10-27 04:50:15
|
Revision: 592
http://hgengine.svn.sourceforge.net/hgengine/?rev=592&view=rev
Author: cnlohr
Date: 2009-10-27 04:50:09 +0000 (Tue, 27 Oct 2009)
Log Message:
-----------
add XML Saving to everything
Modified Paths:
--------------
Mercury2/modules/BillboardNode.cpp
Mercury2/modules/BillboardNode.h
Mercury2/modules/Terrain.h
Mercury2/modules/TextNode.cpp
Mercury2/modules/TextNode.h
Mercury2/modules/TextPlate.cpp
Mercury2/modules/TextPlate.h
Mercury2/src/Camera.cpp
Mercury2/src/Camera.h
Mercury2/src/FullscreenQuad.h
Mercury2/src/HGMDLModel.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/MercuryVBO.h
Mercury2/src/Quad.h
Mercury2/src/Texture.h
Mercury2/src/TransformNode.cpp
Mercury2/src/TransformNode.h
Mercury2/src/Viewport.cpp
Mercury2/src/Viewport.h
Modified: Mercury2/modules/BillboardNode.cpp
===================================================================
--- Mercury2/modules/BillboardNode.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/modules/BillboardNode.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -60,6 +60,13 @@
return m_billboardMatrix;
}
+void BillboardNode::SaveToXMLTag( MString & sXMLStream )
+{
+ TransformNode::SaveToXMLTag( sXMLStream );
+ sXMLStream += ssprintf( "billboardaxis=\"%f,%f,%f\" spheremode=\"%d\" ",
+ m_billboardAxis[0], m_billboardAxis[1], m_billboardAxis[2], m_sphere );
+}
+
void BillboardNode::LoadFromXML(const XMLNode& node)
{
TransformNode::LoadFromXML(node);
@@ -68,7 +75,7 @@
m_billboardAxis = MercuryVector::CreateFromString( node.Attribute("billboardaxis") );
if ( !node.Attribute("spheremode").empty() )
- m_sphere = node.Attribute("spheremode") == "true"?true:false;
+ m_sphere = StrToBool( node.Attribute("spheremode") );
}
/****************************************************************************
Modified: Mercury2/modules/BillboardNode.h
===================================================================
--- Mercury2/modules/BillboardNode.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/modules/BillboardNode.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -15,6 +15,7 @@
virtual const MercuryMatrix& GetGlobalMatrix() const;
virtual void LoadFromXML(const XMLNode& node);
+ virtual void SaveToXMLTag( MString & sXMLStream );
GENRTTI(BillboardNode);
Modified: Mercury2/modules/Terrain.h
===================================================================
--- Mercury2/modules/Terrain.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/modules/Terrain.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -20,7 +20,7 @@
virtual MercuryAssetInstance* GenerateInstanceData(MercuryNode* parentNode);
MercuryVertex ComputePosition(const MercuryVertex& p);
MercuryVertex ComputePositionLinear(const MercuryVertex& p);
-
+ GENRTTI( Terrain );
private:
CLASS_HELPERS( HGMDLModel );
void BuildHash();
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/modules/TextNode.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -31,6 +31,49 @@
MercuryNode::Update( dTime );
}
+void TextNode::SaveToXML( MString & sXMLStream, int depth )
+{
+ sXMLStream += ssprintf( "%*c<node ", depth*3, 32 );
+
+ SaveBaseXMLTag( sXMLStream );
+ SaveToXMLTag( sXMLStream );
+
+ sXMLStream += "/>\n";
+}
+
+void TextNode::SaveToXMLTag( MString & sXMLStream )
+{
+ MercuryNode::SaveToXMLTag( sXMLStream );
+ if( m_sFont.length() )
+ sXMLStream += ssprintf( "font=\"%s\" ", m_sFont.c_str() );
+ sXMLStream += ssprintf( "size=\"%f\" ", m_fSize );
+ if( m_sText.length() )
+ sXMLStream += ssprintf( "text=\"%s\" ", m_sText.c_str() );
+
+ if( m_fTextWidth < 1e9 )
+ sXMLStream += ssprintf( "width=\"%f\" ", m_fTextWidth );
+
+ sXMLStream += "alignment=\"";
+ switch( m_alignment )
+ {
+ case LEFT:
+ sXMLStream += "LEFT\" ";
+ break;
+ case RIGHT:
+ sXMLStream += "RIGHT\" ";
+ break;
+ case CENTER:
+ sXMLStream += "CENTER\" ";
+ break;
+ case FIT:
+ sXMLStream += "FIT\" ";
+ break;
+ case FIT_FULL:
+ sXMLStream += "FIT_FULL\" ";
+ break;
+ }
+}
+
void TextNode::LoadFromXML(const XMLNode& node)
{
MercuryNode::LoadFromXML(node);
@@ -348,7 +391,7 @@
} else
m_pThisFont = &g_AllFonts[sFont];
SetDirtyText();
-
+ m_sFont = sFont;
return true;
}
Modified: Mercury2/modules/TextNode.h
===================================================================
--- Mercury2/modules/TextNode.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/modules/TextNode.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -45,6 +45,10 @@
inline float GetRMaxX() { return m_fRMaxX; }
inline float GetRMaxY() { return m_fRMaxY; }
+ ///Careful, Text node is a virtual node - it doesn't actually recurse into children.
+ virtual void SaveToXML( MString & sXMLStream, int depth = 0 );
+ virtual void SaveToXMLTag( MString & sXMLStream );
+
GENRTTI(TextNode);
private:
Modified: Mercury2/modules/TextPlate.cpp
===================================================================
--- Mercury2/modules/TextPlate.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/modules/TextPlate.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -19,6 +19,24 @@
}
+void TextPlate::SaveToXML( MString & sXMLStream, int depth )
+{
+ sXMLStream += ssprintf( "%*c<node ", depth*3, 32 );
+
+ SaveBaseXMLTag( sXMLStream );
+ SaveToXMLTag( sXMLStream );
+ m_TextNode->SaveToXMLTag( sXMLStream );
+
+ sXMLStream += "/>\n";
+}
+
+void TextPlate::SaveToXMLTag( MString & sXMLStream )
+{
+ BillboardNode::SaveToXMLTag( sXMLStream );
+ if( m_fvOffset.Length() > 1e-9 )
+ sXMLStream += ssprintf( "offset=\"%f,%f,%f\" ", m_fvOffset[0], m_fvOffset[1], m_fvOffset[2] );
+}
+
void TextPlate::LoadFromXML(const XMLNode& node)
{
BillboardNode::LoadFromXML(node);
Modified: Mercury2/modules/TextPlate.h
===================================================================
--- Mercury2/modules/TextPlate.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/modules/TextPlate.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -13,6 +13,11 @@
TextPlate();
virtual void Update(float dTime);
virtual void LoadFromXML(const XMLNode& node);
+
+ //Because this is a virtual node, we have to abstract from SaveToXML as well.
+ virtual void SaveToXML( MString & sXMLStream, int depth = 0 );
+ virtual void SaveToXMLTag( MString & sXMLStream );
+
GENRTTI(TextPlate);
private:
MercuryVector m_fvOffset;
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/Camera.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -13,7 +13,6 @@
m_lookAt = MercuryVector(0,0,-1);
REGISTER_MESSAGE_WITH_DELEGATE( INPUTEVENT_MOUSE, &CameraNode::HandleMouseInput );
REGISTER_MESSAGE_WITH_DELEGATE( "SetCameraPosition", &CameraNode::SetCameraPosition );
- POST_MESSAGE("QueryTerrainPoint", new VertexDataMessage(m_origionalPosition), 0.00001);
}
void CameraNode::PreRender(const MercuryMatrix& matrix)
@@ -101,6 +100,7 @@
void CameraNode::SetCameraPosition(const MessageData& data)
{
const VertexDataMessage& m( dynamic_cast<const VertexDataMessage&>( data ) );
+
SetPosition(m.Vertex);
}
@@ -126,7 +126,8 @@
// SetPosition( p );
m_origionalPosition = p;
TransformNode::Update( dTime );
-
+
+
if (a != 0 || b != 0)
{
POST_MESSAGE("QueryTerrainPoint", new VertexDataMessage(p), 0);
@@ -134,6 +135,24 @@
}
+void CameraNode::SaveToXMLTag( MString & sXMLStream )
+{
+ //Tricky - we want to save where we think we are, not where the camera is.
+ //That way when we get re-opened, we are where we should be.
+ MercuryVertex OrigPos = GetPosition();
+ SetPosition( m_origionalPosition );
+ TransformNode::SaveToXMLTag( sXMLStream );
+ SetPosition( OrigPos );
+}
+
+void CameraNode::LoadFromXML(const XMLNode& node)
+{
+ TransformNode::LoadFromXML( node );
+ m_origionalPosition = GetPosition();
+ POST_MESSAGE("QueryTerrainPoint", new VertexDataMessage(GetPosition()), 0.00001);
+}
+
+
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/src/Camera.h
===================================================================
--- Mercury2/src/Camera.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/Camera.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -14,6 +14,8 @@
virtual void PreRender(const MercuryMatrix& matrix);
virtual void Render(const MercuryMatrix& matrix);
virtual void SetCameraPosition(const MessageData& data);
+ virtual void LoadFromXML(const XMLNode& node);
+ virtual void SaveToXMLTag( MString & sXMLStream );
GENRTTI(CameraNode);
private:
Modified: Mercury2/src/FullscreenQuad.h
===================================================================
--- Mercury2/src/FullscreenQuad.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/FullscreenQuad.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -13,6 +13,7 @@
virtual void Render(const MercuryNode* node);
static FullscreenQuad* Generate();
+ GENRTTI( FullscreenQuad );
private:
MercuryMatrix m_matrix;
};
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/HGMDLModel.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -22,7 +22,7 @@
virtual bool DoCullingTests(OcclusionResult& occlusion, const MercuryMatrix& matrix);
virtual void PreRender(const MercuryNode* node);
virtual void Render(const MercuryNode* node);
-
+ GENRTTI( HGMDLModel );
protected:
std::vector< MAutoPtr< HGMDLMesh > > m_meshes;
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/Mercury2.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -177,6 +177,7 @@
fpsTimer = timer;
}
+//Uncomment to enable scenegraph saving.
MString st;
root->SaveToXML( st );
StringToFile( "test.xml", st );
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/MercuryAsset.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -79,7 +79,7 @@
void MercuryAsset::SaveToXML( MString & sXMLStream, int depth )
{
- sXMLStream += ssprintf( "%*c<node type=\"%s\" ", depth*3, 32, GetType() );
+ sXMLStream += ssprintf( "%*c<asset type=\"%s\" ", depth*3, 32, GetType() );
if( m_path.length() )
sXMLStream += ssprintf( "file=\"%s\" ", m_path.c_str() );
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/MercuryNode.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -310,10 +310,9 @@
void MercuryNode::SaveToXML( MString & sXMLStream, int depth )
{
- sXMLStream += ssprintf( "%*c<node type=\"%s\" ", depth*3, 32, GetType() );
- if( GetName().length() )
- sXMLStream += ssprintf( "name=\"%s\" ", GetName().c_str() );
+ sXMLStream += ssprintf( "%*c<node ", depth * 3, 32 );
+ SaveBaseXMLTag( sXMLStream );
SaveToXMLTag( sXMLStream );
bool bNoChildren = true;
@@ -346,9 +345,18 @@
void MercuryNode::SaveToXMLTag( MString & sXMLStream )
{
- //MercuryNodes do not have anything else to save.
+ //Don't actually do anything here
}
+void MercuryNode::SaveBaseXMLTag( MString & sXMLStream )
+{
+ sXMLStream+= ssprintf( "type=\"%s\" ", GetType() );
+ if( GetName().length() )
+ sXMLStream += ssprintf( "name=\"%s\" ", GetName().c_str() );
+ if( m_useAlphaPath )
+ sXMLStream += "alphaPath=\"true\" ";
+}
+
void MercuryNode::PreRender(const MercuryMatrix& matrix)
{
SetCulled( false );
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/MercuryNode.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -97,6 +97,8 @@
The various abstracted classes must append on arguments they require. */
virtual void SaveToXMLTag( MString & sXMLStream );
+ void SaveBaseXMLTag( MString & sXMLStream );
+
///Run on a child when added to a parent
virtual void OnAdded() {};
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/MercuryVBO.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -37,6 +37,7 @@
void DirtyVertices() { m_bDirtyVertices = 1; }
void DirtyIndices() { m_bDirtyIndices = 1; }
+ GENRTTI( MercuryVBO );
private:
virtual void InitVBO();
Modified: Mercury2/src/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/Quad.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -11,7 +11,7 @@
~Quad();
static Quad* Generate();
-
+ GENRTTI( Quad );
private:
};
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/Texture.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -34,6 +34,7 @@
static void ApplyActiveTextures(uint16_t stride);
static void DisableUnusedTextures();
+ GENRTTI( Texture );
private:
void LoadImagePath(const MString& path);
Modified: Mercury2/src/TransformNode.cpp
===================================================================
--- Mercury2/src/TransformNode.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/TransformNode.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -121,6 +121,28 @@
}
}
+void TransformNode::SaveToXMLTag( MString & sXMLStream )
+{
+ MercuryNode::SaveToXMLTag( sXMLStream );
+
+ const MercuryVertex & scale = GetScale();
+ if( scale[0] != 1 ) sXMLStream += ssprintf( "scalex=\"%f\" ", scale[0] );
+ if( scale[1] != 1 ) sXMLStream += ssprintf( "scaley=\"%f\" ", scale[1] );
+ if( scale[2] != 1 ) sXMLStream += ssprintf( "scalez=\"%f\" ", scale[2] );
+
+ const MercuryVertex & pos = GetPosition();
+ if( pos[0] != 0 ) sXMLStream += ssprintf( "movx=\"%f\" ", pos[0] );
+ if( pos[1] != 0 ) sXMLStream += ssprintf( "movy=\"%f\" ", pos[1] );
+ if( pos[2] != 0 ) sXMLStream += ssprintf( "movz=\"%f\" ", pos[2] );
+
+ MercuryVertex r;
+ GetRotation().ToEuler( r );
+ if( r[0] != 0 ) sXMLStream += ssprintf( "rotx=\"%f\" ", r[0] * RADDEG );
+ if( r[1] != 0 ) sXMLStream += ssprintf( "roty=\"%f\" ", r[1] * RADDEG );
+ if( r[2] != 0 ) sXMLStream += ssprintf( "rotz=\"%f\" ", r[2] * RADDEG );
+
+}
+
void TransformNode::LoadFromXML(const XMLNode& node)
{
MercuryVertex pos(m_position), scale(m_scale);
Modified: Mercury2/src/TransformNode.h
===================================================================
--- Mercury2/src/TransformNode.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/TransformNode.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -33,7 +33,8 @@
virtual void ComputeMatrix();
virtual void LoadFromXML(const XMLNode& node);
-
+ virtual void SaveToXMLTag( MString & sXMLStream );
+
virtual void OnAdded();
virtual void RecursivePreRender();
Modified: Mercury2/src/Viewport.cpp
===================================================================
--- Mercury2/src/Viewport.cpp 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/Viewport.cpp 2009-10-27 04:50:09 UTC (rev 592)
@@ -95,6 +95,13 @@
MercuryNode::PostRender(matrix);
}
+void Viewport::SaveToXMLTag( MString & sXMLStream )
+{
+ MercuryNode::SaveToXMLTag( sXMLStream );
+ sXMLStream += ssprintf( "xfactor=\"%f\" yfactor=\"%f\" minx=\"%d\" miny=\"%d\" fov=\"%f\" near=\"%f\" far=\"%f\" ",
+ m_xFactor, m_yFactor, m_minx, m_miny, m_fov, m_frustum.ZNear(), m_frustum.ZFar() );
+}
+
void Viewport::LoadFromXML(const XMLNode& node)
{
m_xFactor = StrToFloat(node.Attribute("xfactor"), 1.0f);
@@ -104,7 +111,8 @@
MercuryWindow* w = MercuryWindow::GetCurrentWindow();
- m_frustum.SetPerspective( StrToFloat(node.Attribute("fov")),
+ m_fov = StrToFloat(node.Attribute("fov"), 60.f);
+ m_frustum.SetPerspective( m_fov,
(w->Width()*m_xFactor)/(w->Height()*m_yFactor),
// StrToFloat(node.Attribute("aspect")),
StrToFloat(node.Attribute("near")),
Modified: Mercury2/src/Viewport.h
===================================================================
--- Mercury2/src/Viewport.h 2009-10-27 04:49:25 UTC (rev 591)
+++ Mercury2/src/Viewport.h 2009-10-27 04:50:09 UTC (rev 592)
@@ -17,12 +17,13 @@
virtual void PostRender(const MercuryMatrix& matrix);
virtual void LoadFromXML(const XMLNode& node);
-
+ virtual void SaveToXMLTag( MString & sXMLStream );
GENRTTI(Viewport);
private:
Frustum m_frustum;
float m_xFactor, m_yFactor;
int m_minx, m_miny;
+ float m_fov;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-03 08:24:51
|
Revision: 596
http://hgengine.svn.sourceforge.net/hgengine/?rev=596&view=rev
Author: cnlohr
Date: 2009-11-03 08:24:44 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
take advantage of new asset statechanger. Greatly increase quality of TextPlate.
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/adv_set.c
Mercury2/modules/TextPlate.cpp
Mercury2/modules/TextPlate.h
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/Quad.cpp
Mercury2/src/Quad.h
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-11-03 08:24:44 UTC (rev 596)
@@ -1,8 +1,12 @@
<SceneGraph name="root">
+ <!--We have to put all states that are the generic state up here. This way, the states will fall back to these -->
+ <asset type="StateChanger" file="ColorChange:1,1,1,1" />
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp">
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
- <node type="transformnode" movz="-5" movy="2">
- <node type="TextPlate" text="test font 123 HELLO WORLD!!! WOOT!" font="FONT:FreeSans.hgfont" size=".01" width="400" alphaPath="true" billboardaxis="0,-1,0" offset="-2,0,0" spheremode="false" />
+ <node type="transformnode" movz="-5" movy=".2">
+ <node type="TextPlate" text="x=3.14159" font="FONT:FreeSans.hgfont" size=".002" alphaPath="true" billboardaxis="0,-1,0" spheremode="false" alignment="CENTER" >
+ <asset type="StateChanger" file="ColorChange:0,0,0,1" />
+ </node>
</node>
<node type="transformnode" movz="-5" movx="-4" movy="2">
<node type="TextNode" text="Another test!" font="FONT:FreeMonoBold.hgfont" size=".01" width="300" alphaPath="true" alignment="LEFT" />
@@ -20,6 +24,7 @@
</node>
<node type="billboardnode" billboardaxis="0,-1,0" spheremode="true" >
<node type="transformnode" scalex="0.1" scaley="0.1" alphaPath="true">
+ <asset type="StateChanger" file="ColorChange:1,0,1,1" />
<asset type="texture" file="GRAPHIC:flame.png"/>
<asset type="quad"/>
</node>
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/adv_set.c 2009-11-03 08:24:44 UTC (rev 596)
@@ -14,7 +14,7 @@
src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDifferedLights.cpp \
- src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp"
+ src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/modules/TextPlate.cpp
===================================================================
--- Mercury2/modules/TextPlate.cpp 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/modules/TextPlate.cpp 2009-11-03 08:24:44 UTC (rev 596)
@@ -2,6 +2,9 @@
#include <TextNode.h>
#include <MercuryVertex.h>
#include <Viewport.h>
+#include <Quad.h>
+#include <GLHeaders.h>
+#include <StateChanger.h>
REGISTER_NODE_TYPE(TextPlate);
@@ -10,6 +13,13 @@
{
m_TextNode = (TextNode*)NODEFACTORY.Generate( "TextNode" );
AddChild( m_TextNode );
+
+ m_BackgroundColor = ASSETFACTORY.Generate( "StateChanger", "ColorChange:1,1,0,1" );
+ ((StateChanger*)m_BackgroundColor.Ptr())->LoadFromString( "ColorChange:1,1,0,1" );
+ AddAsset( m_BackgroundColor );
+
+ m_BackPlane = ASSETFACTORY.Generate( "Quad", "TBQ" );
+ AddAsset( m_BackPlane );
}
void TextPlate::Update(float dTime)
@@ -18,7 +28,6 @@
m_billboardMatrix.Translate( m_fvOffset );
}
-
void TextPlate::SaveToXML( MString & sXMLStream, int depth )
{
sXMLStream += ssprintf( "%*c<node ", depth*3, 32 );
@@ -43,8 +52,23 @@
if ( !node.Attribute("offset").empty() )
m_fvOffset = MercuryVector::CreateFromString( node.Attribute("offset") );
m_TextNode->LoadFromXML(node);
+ if ( !node.Attribute("text").empty() )
+ SetText( node.Attribute("text") );
}
+void TextPlate::SetText( const MString & sText )
+{
+ m_TextNode->SetText(sText);
+ m_TextNode->RenderText();
+
+ ((Quad*)m_BackPlane.Ptr())->LoadFromString( ssprintf( "%f,%f,%f,%f,-.01",
+ m_TextNode->GetRMinX() * 1.1 ,
+ m_TextNode->GetRMinY() * 1.1 ,
+ m_TextNode->GetRMaxX() * 1.1 ,
+ m_TextNode->GetRMaxY() * 1.1 ) );
+}
+
+
/****************************************************************************
* Copyright (C) 2009 by Charles Lohr *
* *
Modified: Mercury2/modules/TextPlate.h
===================================================================
--- Mercury2/modules/TextPlate.h 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/modules/TextPlate.h 2009-11-03 08:24:44 UTC (rev 596)
@@ -6,6 +6,8 @@
#include <MercuryVertex.h>
class TextNode;
+class Quad;
+class StateChanger;
class TextPlate : public BillboardNode
{
@@ -18,10 +20,14 @@
virtual void SaveToXML( MString & sXMLStream, int depth = 0 );
virtual void SaveToXMLTag( MString & sXMLStream );
+ void SetText( const MString & sText );
+
GENRTTI(TextPlate);
private:
MercuryVector m_fvOffset;
TextNode * m_TextNode;
+ MAutoPtr< MercuryAsset > m_BackgroundColor;
+ MAutoPtr< MercuryAsset > m_BackPlane;
};
#endif
@@ -58,3 +64,4 @@
* (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/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/MercuryAsset.cpp 2009-11-03 08:24:44 UTC (rev 596)
@@ -138,10 +138,10 @@
MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type, const MString& key)
{
MString t = ToUpper( type );
-
+
MercuryAsset *asset = LocateAsset(t+key);
if ( asset ) return asset;
-
+
std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
if (i->first == t) return i->second();
@@ -163,26 +163,36 @@
MHash< MercuryAsset*> AssetFactory::m_assetInstances;
-/***************************************************************************
- * Copyright (C) 2008 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 <ORGANIZATION> 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. *
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * 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/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/MercuryAsset.h 2009-11-03 08:24:44 UTC (rev 596)
@@ -152,6 +152,8 @@
};
+#define ASSETFACTORY (AssetFactory::GetInstance())
+
static InstanceCounter<AssetFactory> AFcounter("AssetFactory");
#define REGISTER_ASSET_TYPE(class)\
@@ -170,26 +172,36 @@
#endif
-/***************************************************************************
- * Copyright (C) 2008 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 <ORGANIZATION> 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. *
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * 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/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/Quad.cpp 2009-11-03 08:24:44 UTC (rev 596)
@@ -8,8 +8,74 @@
Quad::Quad()
:MercuryVBO()
{
+}
+
+Quad::~Quad()
+{
+ REMOVE_ASSET_INSTANCE(Quad,m_path);
+}
+
+Quad* Quad::Generate()
+{
+ Quad *asset = new Quad();
+ ADD_ASSET_INSTANCE(Quad,"",asset);
+ return asset;
+}
+
+void Quad::LoadFromXML(const XMLNode& node)
+{
+ LoadFromString( node.Attribute("file") );
+
+ MercuryAsset::LoadFromXML( node );
+}
+
+
+
+bool Quad::LoadFromString( const MString & sDescription )
+{
+ float lX = -0.5;
+ float lY = -0.5;
+ float hX = 0.5;
+ float hY = 0.5;
+ float zp = 0;
+ bool bResetRegistration = sDescription != m_path;
+
AllocateIndexSpace(6);
AllocateVertexSpace(4);
+
+ if( bResetRegistration )
+ REMOVE_ASSET_INSTANCE(Quad,m_path);
+ m_path = sDescription;
+ if( bResetRegistration )
+ ADD_ASSET_INSTANCE(Quad,m_path,this);
+
+ MVector< MString > vsDescription;
+ SplitStrings( sDescription, vsDescription, ",", " ", 1, 1 );
+
+ if( vsDescription.size() == 0 )
+ {
+ //Do nothing
+ }
+ else if( vsDescription.size() == 2 )
+ {
+ lX = 0;
+ lY = 0;
+ hX = StrToFloat( vsDescription[0] );
+ hY = StrToFloat( vsDescription[1] );
+ }
+ else if( vsDescription.size() == 4 || vsDescription.size() == 5 )
+ {
+ lX = StrToFloat( vsDescription[0] );
+ lY = StrToFloat( vsDescription[1] );
+ hX = StrToFloat( vsDescription[2] );
+ hY = StrToFloat( vsDescription[3] );
+ if( vsDescription.size() == 5 )
+ zp = StrToFloat( vsDescription[4] );
+ }
+ else
+ {
+ LOG.Write( ssprintf( "Invalid number of parameters passed into new Quad: \"%s\"", sDescription.c_str() ) );
+ }
// float* buffer = m_vertexData.m_vertexData();
int i = 0;
@@ -18,59 +84,62 @@
//this makes it so FBO images render correctly right out of the buffer, no flip needed
m_vertexData[i++] = 0; m_vertexData[i++] = 0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = -0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = lX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
m_vertexData[i++] = 1; m_vertexData[i++] = 0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = 0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = hX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
m_vertexData[i++] = 1; m_vertexData[i++] = 1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = hX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
m_vertexData[i++] = 0; m_vertexData[i++] = 1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = lX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
m_indexData[5] = m_indexData[0] = 0;
m_indexData[1] = 1;
m_indexData[3] = m_indexData[2] = 2;
m_indexData[4] = 3;
-}
-Quad::~Quad()
-{
- REMOVE_ASSET_INSTANCE(Quad,"");
-}
+ m_path = sDescription;
-Quad* Quad::Generate()
-{
- Quad *asset = new Quad();
- ADD_ASSET_INSTANCE(Quad,"",asset);
- LOG.Write( "new quad" );
- return asset;
+ return true;
}
-/***************************************************************************
- * Copyright (C) 2008 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 <ORGANIZATION> 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. *
+
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * 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/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/Quad.h 2009-11-03 08:24:44 UTC (rev 596)
@@ -10,6 +10,9 @@
Quad();
~Quad();
+ void LoadFromXML(const XMLNode& node );
+ bool LoadFromString( const MString & sDescription );
+
static Quad* Generate();
GENRTTI( Quad );
private:
@@ -17,26 +20,36 @@
#endif
-/***************************************************************************
- * Copyright (C) 2008 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 <ORGANIZATION> 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. *
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * 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: <cn...@us...> - 2009-11-03 18:50:40
|
Revision: 597
http://hgengine.svn.sourceforge.net/hgengine/?rev=597&view=rev
Author: cnlohr
Date: 2009-11-03 18:50:32 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
add options for liberty
Modified Paths:
--------------
Mercury2/base_set.sh
Mercury2/cnconfigure
Modified: Mercury2/base_set.sh
===================================================================
--- Mercury2/base_set.sh 2009-11-03 08:24:44 UTC (rev 596)
+++ Mercury2/base_set.sh 2009-11-03 18:50:32 UTC (rev 597)
@@ -46,6 +46,7 @@
NEED_H="stdio.h stdlib.h"
WANT_H="time.h"
+WANT_L="iberty"
CC_BASE="$CC_BASE -I."
NEED_L="m c z pthread png pthread";
Modified: Mercury2/cnconfigure
===================================================================
--- Mercury2/cnconfigure 2009-11-03 08:24:44 UTC (rev 596)
+++ Mercury2/cnconfigure 2009-11-03 18:50:32 UTC (rev 597)
@@ -100,7 +100,7 @@
done
for i in $WANT_L; do
- if CheckForLib "$i"; then echo "#define _HAVE_LIB_$i" >> configuration.h; fi
+ if CheckForLib "$i"; then echo "#define _HAVE_LIB_$i" >> configuration.h; LDFLAGS="$LDFLAGS -l$i"; fi
done
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-05 02:44:14
|
Revision: 598
http://hgengine.svn.sourceforge.net/hgengine/?rev=598&view=rev
Author: cnlohr
Date: 2009-11-05 02:44:00 +0000 (Thu, 05 Nov 2009)
Log Message:
-----------
update spelling on rendering deferred lights
Modified Paths:
--------------
Mercury2/adv_set.c
Added Paths:
-----------
Mercury2/src/RenderDeferredLights.cpp
Mercury2/src/RenderDeferredLights.h
Removed Paths:
-------------
Mercury2/src/RenderDifferedLights.cpp
Mercury2/src/RenderDifferedLights.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-11-03 18:50:32 UTC (rev 597)
+++ Mercury2/adv_set.c 2009-11-05 02:44:00 UTC (rev 598)
@@ -13,7 +13,7 @@
src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \
src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
- src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDifferedLights.cpp \
+ src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDeferredLights.cpp \
src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
Added: Mercury2/src/RenderDeferredLights.cpp
===================================================================
--- Mercury2/src/RenderDeferredLights.cpp (rev 0)
+++ Mercury2/src/RenderDeferredLights.cpp 2009-11-05 02:44:00 UTC (rev 598)
@@ -0,0 +1,68 @@
+#include <RenderDeferredLights.h>
+#include <RenderGraph.h>
+
+#include <Texture.h>
+#include <GLHeaders.h>
+
+REGISTER_ASSET_TYPE(RenderDeferredLights);
+
+RenderDeferredLights::RenderDeferredLights( const MString & key, bool bInstanced ) :
+ MercuryAsset( key, bInstanced )
+{
+}
+
+RenderDeferredLights::~RenderDeferredLights()
+{
+}
+
+void RenderDeferredLights::Render(const MercuryNode* node)
+{
+// uint8_t numTextures = Texture::NumberActiveTextures();
+ uint16_t stride = sizeof(float)*8;
+
+ Texture::ApplyActiveTextures(stride);
+
+ GLCALL( glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT) );
+ GLCALL( glCullFace(GL_FRONT) );
+
+ GLCALL( glDisable(GL_DEPTH_TEST) );
+ GLCALL( glDepthMask(false) );
+ GLCALL( glBlendFunc(GL_ONE, GL_ONE) );
+
+ CURRENTRENDERGRAPH->DoDifferedLightPass();
+
+ GLCALL( glPopAttrib( ) );
+}
+
+
+/****************************************************************************
+ * 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/RenderDeferredLights.h
===================================================================
--- Mercury2/src/RenderDeferredLights.h (rev 0)
+++ Mercury2/src/RenderDeferredLights.h 2009-11-05 02:44:00 UTC (rev 598)
@@ -0,0 +1,48 @@
+#ifndef RENDERDEFERREDLIGHTS_H
+#define RENDERDEFERREDLIGHTS_H
+
+#include <MercuryAsset.h>
+
+class RenderDeferredLights : public MercuryAsset
+{
+ public:
+ RenderDeferredLights( const MString & key, bool bInstanced );
+ virtual ~RenderDeferredLights();
+
+ virtual void Render(const MercuryNode* node);
+ GENRTTI( RenderDeferredLights );
+};
+
+#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. *
+ ***************************************************************************/
Deleted: Mercury2/src/RenderDifferedLights.cpp
===================================================================
--- Mercury2/src/RenderDifferedLights.cpp 2009-11-03 18:50:32 UTC (rev 597)
+++ Mercury2/src/RenderDifferedLights.cpp 2009-11-05 02:44:00 UTC (rev 598)
@@ -1,72 +0,0 @@
-#include <RenderDifferedLights.h>
-#include <RenderGraph.h>
-
-#include <Texture.h>
-#include <GLHeaders.h>
-
-REGISTER_ASSET_TYPE(RenderDifferedLights);
-
-RenderDifferedLights::RenderDifferedLights()
-{
-}
-
-RenderDifferedLights::~RenderDifferedLights()
-{
-}
-
-void RenderDifferedLights::Render(const MercuryNode* node)
-{
- uint8_t numTextures = Texture::NumberActiveTextures();
- uint16_t stride = sizeof(float)*8;
-
- Texture::ApplyActiveTextures(stride);
-
- GLCALL( glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT) );
- GLCALL( glCullFace(GL_FRONT) );
-
- GLCALL( glDisable(GL_DEPTH_TEST) );
- GLCALL( glDepthMask(false) );
- GLCALL( glBlendFunc(GL_ONE, GL_ONE) );
-
- CURRENTRENDERGRAPH->DoDifferedLightPass();
-
- GLCALL( glPopAttrib( ) );
-}
-
-RenderDifferedLights* RenderDifferedLights::Generate()
-{
- return new RenderDifferedLights();
-}
-
-
-/****************************************************************************
- * 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. *
- ***************************************************************************/
Deleted: Mercury2/src/RenderDifferedLights.h
===================================================================
--- Mercury2/src/RenderDifferedLights.h 2009-11-03 18:50:32 UTC (rev 597)
+++ Mercury2/src/RenderDifferedLights.h 2009-11-05 02:44:00 UTC (rev 598)
@@ -1,49 +0,0 @@
-#ifndef RENDERDIFFEREDLIGHTS_H
-#define RENDERDIFFEREDLIGHTS_H
-
-#include <MercuryAsset.h>
-
-class RenderDifferedLights : public MercuryAsset
-{
- public:
- RenderDifferedLights();
- virtual ~RenderDifferedLights();
-
- virtual void Render(const MercuryNode* node);
- static RenderDifferedLights* Generate();
-
-};
-
-#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: <cn...@us...> - 2009-11-06 06:45:18
|
Revision: 602
http://hgengine.svn.sourceforge.net/hgengine/?rev=602&view=rev
Author: cnlohr
Date: 2009-11-06 06:45:08 +0000 (Fri, 06 Nov 2009)
Log Message:
-----------
ok - sound is in there
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/base_set.sh
Mercury2/src/Mercury2.cpp
Mercury2/src/MercurySound.cpp
Mercury2/src/MercurySoundDriverALSA.cpp
Mercury2/src/MercurySoundSourceVorbis.cpp
Mercury2/src/MercurySoundSourceVorbis.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/adv_set.c 2009-11-06 06:45:08 UTC (rev 602)
@@ -14,7 +14,8 @@
src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDeferredLights.cpp \
- src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp"
+ src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp \
+ src/MercurySound.cpp src/MercurySoundSourceRAM.cpp "
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
@@ -30,6 +31,14 @@
SOURCES="$SOURCES src/X11Window.cpp"
#endif
+#ifdef USE_ALSA
+SOURCES="$SOURCES src/MercurySoundDriverALSA.cpp"
+#endif
+
+#ifdef _HAVE_LIB_ogg
+SOURCES="$SOURCES src/MercurySoundSourceVorbis.cpp"
+#endif
+
PROJ="mercury"
CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -Isrc/DataStructures -Isrc/DataTypes -g -rdynamic"
LDFLAGS="$LDFLAGS -rdynamic -g -fPIC "
Modified: Mercury2/base_set.sh
===================================================================
--- Mercury2/base_set.sh 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/base_set.sh 2009-11-06 06:45:08 UTC (rev 602)
@@ -8,7 +8,7 @@
ISMAC=1; fi
-OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch"
+OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg"
OPT_X11=1
OPT_OGL=1
OPT_libxml=1
@@ -16,7 +16,10 @@
OPT_gprof=0
OPT_glprofile=0
OPT_instancewatch=1
+OPT_alsa=1
+OPT_ogg=1
+
DEFINES="WAS_CONFIGURED USE_MSTRING"
CC_BASE="-O2 -g0 -Wall"
@@ -77,7 +80,7 @@
fi
if test $OPT_OGL = 1; then
- NEED_H="GL/gl.h"
+ NEED_H="$NEED_H GL/gl.h"
NEED_L="$NEED_L GL GLU"
fi
@@ -94,6 +97,17 @@
DEFINES="$DEFINES INSTANCE_WATCH"
fi
+if test $OPT_alsa = 1; then
+ NEED_L="$NEED_L asound"
+ NEED_H="$NEED_H alsa/asoundlib.h"
+ DEFINES="$DEFINES USE_ALSA"
+fi
+
+if test $OPT_ogg = 1; then
+ NEED_H="$NEED_H ogg/ogg.h"
+ NEED_L="$NEED_L vorbisfile ogg"
+fi
+
ARCH=`uname -m`
if test $ARCH = "i686" || test $ARCH = "i586"; then
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/Mercury2.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -11,7 +11,7 @@
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
#include <MercuryMessageManager.h>
-
+#include <MercurySound.h>
#include <MercuryTimer.h>
#include <RenderGraph.h>
#include <Texture.h>
@@ -102,7 +102,9 @@
cnset_execute_on_crash( SignalHandler );
HandleCommandLineParameters( argc, argv );
-
+
+ //Sound first.
+ SOUNDMAN->Init( "" );
MercuryWindow* w = MercuryWindow::MakeWindow();
#ifdef WIN32
Modified: Mercury2/src/MercurySound.cpp
===================================================================
--- Mercury2/src/MercurySound.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySound.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -136,8 +136,6 @@
pc->FillBuffer( cBufferToFill, iCount );
}
-
- printf( "%f %p\n", cBufferToFill[44], & cBufferToFill[44] );
}
void MercurySoundManager::PostFill()
Modified: Mercury2/src/MercurySoundDriverALSA.cpp
===================================================================
--- Mercury2/src/MercurySoundDriverALSA.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySoundDriverALSA.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -4,7 +4,7 @@
#include "MercurySound.h"
#include <alsa/asoundlib.h>
-#define LOW_LATENCY
+//#define LOW_LATENCY
class MercurySoundDriverALSA
{
Modified: Mercury2/src/MercurySoundSourceVorbis.cpp
===================================================================
--- Mercury2/src/MercurySoundSourceVorbis.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySoundSourceVorbis.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -70,12 +70,11 @@
vorbisCallbacks.close_func = vorbis_close_func;
vorbisCallbacks.tell_func = vorbis_tell_func;
- int ret = ov_open_callbacks( f, vorbisFile, NULL, 0, vorbisCallbacks );
+ ov_open_callbacks( f, vorbisFile, NULL, 0, vorbisCallbacks );
vorbis_info* info = ov_info(vorbisFile, -1);
unsigned VorbisChannels = info->channels;
- unsigned VorbisSamplerate = info->rate;
-
+// unsigned VorbisSamplerate = info->rate;
unsigned VorbisSamples = ov_pcm_total( vorbisFile, 0 );
unsigned Vorbisbytes_read;
@@ -116,19 +115,19 @@
//Now, the section on the regular MercurySoundSource
-/*
REGISTER_SOUND_SOURCE( MercurySoundSourceVorbis, "Vorbis" );
MercurySoundSourceVorbis::MercurySoundSourceVorbis( MercurySoundSource * chain ) :
- MercurySoundSource( chain )
+ MercurySoundSource( chain ), iBufferSize( 32768 ), iBufferLoad(1), iBufferPlay(0)
{
+ iBuffer = (short*)malloc( sizeof( short ) * iBufferSize * 2 );
}
-void MercurySoundSourceVorbis::~MercurySoundSourceVorbis()
+MercurySoundSourceVorbis::~MercurySoundSourceVorbis()
{
- SAFE_DELETE(m_File);
- SAFE_DELETE(f);
- SAFE_DELETE(vorbisFile);
+ delete m_File;
+ delete iBuffer;
+ delete vorbisFile;
}
@@ -136,15 +135,10 @@
{
MAutoPtr< HGRawSound > r;
MAutoPtr< HGRawSound > * g;
- if( ( g = g_SoundLibrary.get( sDescriptor ) ) )
- {
- m_Sound = *g;
- return true;
- }
m_File = FILEMAN.Open( sDescriptor );
- OggVorbis_File * vorbisFile = new OggVorbis_File;
+ vorbisFile = new OggVorbis_File;
ov_callbacks vorbisCallbacks;
vorbisCallbacks.read_func = vorbis_read_func;
@@ -152,19 +146,18 @@
vorbisCallbacks.close_func = vorbis_close_func;
vorbisCallbacks.tell_func = vorbis_tell_func;
- int ret = ov_open_callbacks( f, vorbisFile, NULL, 0, vorbisCallbacks );
+ ov_open_callbacks( m_File, vorbisFile, NULL, 0, vorbisCallbacks );
vorbis_info* info = ov_info(vorbisFile, -1);
- unsigned VorbisChannels = info->channels;
- unsigned VorbisSamplerate = info->rate;
-
+// unsigned VorbisChannels = info->channels;
+// unsigned VorbisSamplerate = info->rate;
unsigned VorbisSamples = ov_pcm_total( vorbisFile, 0 );
unsigned Vorbisbytes_read;
if( VorbisSamples <= 0 )
{
- delete f;
+ delete m_File;
delete vorbisFile;
return false;
@@ -175,44 +168,54 @@
void MercurySoundSourceVorbis::FillBuffer( float * cBufferToFill, int iCount )
{
+ //Don't worry our circular queue is threadsafe.
+ for( unsigned i = 0; i < iCount; i++ )
+ {
+ if( PlayLeft() <= 2 ) break;
+ cBufferToFill[i*2+0] = float(iBuffer[iBufferPlay*2+0])/32768.;
+ cBufferToFill[i*2+1] = float(iBuffer[iBufferPlay*2+1])/32768.;
+ iBufferPlay=(iBufferPlay+1)%iBufferSize;
+ }
+ //If we run out... that's okay. It'll just be silent and have time to fill.
}
bool MercurySoundSourceVorbis::PostFill()
{
unsigned Vorbistotal_bytes_read = 0;
+ unsigned Vorbisbytes_read;
int VorbisAbstream;
- short * VorbisData = new short[VorbisSamples*VorbisChannels];
+ unsigned long BF = BufferFree();
+ unsigned long BFL = BF;
+ short tibuf[BF * 2];
- while( (Vorbisbytes_read = ov_read(vorbisFile, ((char*)VorbisData) +
- Vorbistotal_bytes_read, VorbisSamples*VorbisChannels*2 -
- Vorbistotal_bytes_read, 0, 2, 1, &VorbisAbstream)) > 0 )
+ do
{
- if( VorbisAbstream == 0 )
- Vorbistotal_bytes_read+= Vorbisbytes_read;
- }
+ Vorbisbytes_read = ov_read(vorbisFile, ((char*)&(tibuf[0]) + Vorbistotal_bytes_read),
+ BFL * 4, 0, 2, 1, &VorbisAbstream);
+ BFL -= Vorbisbytes_read / 4;
+ Vorbistotal_bytes_read += Vorbisbytes_read;
+ } while( Vorbisbytes_read > 0 && BFL );
+ if( Vorbisbytes_read < 0 )
+ return false;
- r = new HGRawSound(new float[VorbisSamples*VorbisChannels],VorbisSamples);
-
- for( unsigned i = 0; i < VorbisSamples*VorbisChannels; i++ )
+ for( unsigned i = 0; i < BF; i++ )
{
- r->fSound[i] = ((float)VorbisData[i])/32768.0;
+ iBuffer[iBufferLoad*2+0] = tibuf[i*2+0];
+ iBuffer[iBufferLoad*2+1] = tibuf[i*2+1];
+ iBufferLoad=(iBufferLoad+1)%iBufferSize;
}
- delete vorbisFile;
- delete f;
-
- m_Sound = r;
- g_SoundLibrary[sDescriptor] = r;
- return true;
+ if( Vorbisbytes_read == 0 && PlayLeft() == 0 )
+ return false;
+ else
+ return true;
}
-*/
-
/****************************************************************************
* Copyright (C) 2009 by Charles Lohr *
* *
Modified: Mercury2/src/MercurySoundSourceVorbis.h
===================================================================
--- Mercury2/src/MercurySoundSourceVorbis.h 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySoundSourceVorbis.h 2009-11-06 06:45:08 UTC (rev 602)
@@ -15,7 +15,6 @@
static MHash< MAutoPtr< HGRawSound > > g_SoundLibrary;
};
-/*
class OggVorbis_File;
class vorbis_info;
class MercuryFile;
@@ -34,10 +33,17 @@
protected:
MercuryFile * m_File;
OggVorbis_File * vorbisFile;
- vorbis_info * info
+ vorbis_info * info;
+
+ unsigned BufferFree() { return ((iBufferPlay + iBufferSize) - iBufferLoad )%iBufferSize; }
+ unsigned PlayLeft() { return ((iBufferLoad + iBufferSize) - iBufferPlay - 1 )%iBufferSize; }
+ unsigned iBufferSize;
+ unsigned iBufferPlay;
+ unsigned iBufferLoad;
+ short * iBuffer;
};
-*/
+
#endif
/****************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-09 07:54:16
|
Revision: 610
http://hgengine.svn.sourceforge.net/hgengine/?rev=610&view=rev
Author: cnlohr
Date: 2009-11-09 07:54:06 +0000 (Mon, 09 Nov 2009)
Log Message:
-----------
enable disabling and enabling of saving to XML (both for children and self)
Modified Paths:
--------------
Mercury2/modules/TextNode.cpp
Mercury2/modules/TextNode.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/Quad.cpp
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/modules/TextNode.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -19,6 +19,8 @@
m_fRMinX(0),m_fRMinY(0),
m_fRMaxX(0),m_fRMaxY(0)
{
+ //Disabling saving of children... As, we create many temporary children.
+ m_bEnableSaveChildren = false;
}
void TextNode::Update(float dTime)
@@ -31,16 +33,6 @@
MercuryNode::Update( dTime );
}
-void TextNode::SaveToXML( MString & sXMLStream, int depth )
-{
- sXMLStream += ssprintf( "%*c<node ", depth*3, 32 );
-
- SaveBaseXMLTag( sXMLStream );
- SaveToXMLTag( sXMLStream );
-
- sXMLStream += "/>\n";
-}
-
void TextNode::SaveToXMLTag( MString & sXMLStream )
{
MercuryNode::SaveToXMLTag( sXMLStream );
Modified: Mercury2/modules/TextNode.h
===================================================================
--- Mercury2/modules/TextNode.h 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/modules/TextNode.h 2009-11-09 07:54:06 UTC (rev 610)
@@ -45,8 +45,6 @@
inline float GetRMaxX() { return m_fRMaxX; }
inline float GetRMaxY() { return m_fRMaxY; }
- ///Careful, Text node is a virtual node - it doesn't actually recurse into children.
- virtual void SaveToXML( MString & sXMLStream, int depth = 0 );
virtual void SaveToXMLTag( MString & sXMLStream );
GENRTTI(TextNode);
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/Mercury2.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -100,7 +100,6 @@
g_SceneGraphToLoad = "FILE:scenegraph.xml";
cnset_execute_on_crash( SignalHandler );
-
HandleCommandLineParameters( argc, argv );
//Sound first.
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/MercuryNode.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -19,6 +19,7 @@
:m_parent(NULL), m_prevSibling(NULL),
m_nextSibling(NULL), m_hidden(false),
m_useAlphaPath(false), m_culled(false),
+ m_bEnableSave(true), m_bEnableSaveChildren(true),
m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 )
{
m_pGlobalMatrix = &MercuryMatrix::Identity();
@@ -314,31 +315,41 @@
void MercuryNode::SaveToXML( MString & sXMLStream, int depth )
{
+ if( !m_bEnableSave ) return;
sXMLStream += ssprintf( "%*c<node ", depth * 3, 32 );
SaveBaseXMLTag( sXMLStream );
SaveToXMLTag( sXMLStream );
bool bNoChildren = true;
- if( !m_assets.empty() )
+
+ if( m_bEnableSaveChildren )
{
- //No children yet (but we have them, so terminate (>) )
- if( bNoChildren )
- sXMLStream += ">\n";
- bNoChildren = false;
+ if( !m_assets.empty() )
+ {
+ //No children yet (but we have them, so terminate (>) )
+ if( bNoChildren )
+ sXMLStream += ">\n";
+ bNoChildren = false;
- for( std::list< MercuryAssetInstance * >::iterator i = m_assets.begin(); i != m_assets.end(); i++ )
- (*i)->Asset().SaveToXML( sXMLStream, depth + 1 );
- }
+ for( std::list< MercuryAssetInstance * >::iterator i = m_assets.begin(); i != m_assets.end(); i++ )
+ (*i)->Asset().SaveToXML( sXMLStream, depth + 1 );
+ }
- if( ! m_children.empty() )
- {
- //No children yet (but we have them, so terminate (>) )
- if( bNoChildren )
- sXMLStream += ">\n";
- bNoChildren = false;
- for( std::list< MercuryNode * >::iterator i = m_children.begin(); i != m_children.end(); i++ )
- (*i)->SaveToXML( sXMLStream, depth + 1 );
+ if( ! m_children.empty() )
+ {
+ //No children yet (but we have them, so terminate (>) )
+ for( std::list< MercuryNode * >::iterator i = m_children.begin(); i != m_children.end(); i++ )
+ {
+ if( (*i)->m_bEnableSave )
+ {
+ if( bNoChildren )
+ sXMLStream += ">\n";
+ bNoChildren = false;
+ (*i)->SaveToXML( sXMLStream, depth + 1 );
+ }
+ }
+ }
}
if( bNoChildren )
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/MercuryNode.h 2009-11-09 07:54:06 UTC (rev 610)
@@ -140,6 +140,8 @@
bool m_hidden;
bool m_useAlphaPath;
bool m_culled;
+ bool m_bEnableSave;
+ bool m_bEnableSaveChildren;
bool IsInAssetList(MercuryAsset* asset) const;
unsigned short m_iPasses;
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/Quad.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -54,7 +54,8 @@
m_bFlipV = false;
vsDescription.remove( 0 );
}
-
+ else
+ break;
} while(1);
if( vsDescription.size() == 0 )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-13 07:46:25
|
Revision: 620
http://hgengine.svn.sourceforge.net/hgengine/?rev=620&view=rev
Author: cnlohr
Date: 2009-11-13 07:46:14 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
add beginnings of UI
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/modules/Makefile
Mercury2/modules.xml
Added Paths:
-----------
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-11-13 07:45:59 UTC (rev 619)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-11-13 07:46:14 UTC (rev 620)
@@ -1,6 +1,8 @@
<SceneGraph name="root">
<!--We have to put all states that are the generic state up here. This way, the states will fall back to these -->
<asset type="StateChanger" file="ColorChange:1,1,1,1" />
+ <asset type="StateChanger" file="DepthTest:1" />
+ <asset type="StateChanger" file="LightingSwitch:0" />
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp">
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
<node type="transformnode" movz="-5" movy=".2">
@@ -51,4 +53,11 @@
<asset type="quad"/>
</node>
-->
+ <node type="orthographic" left="0" right="640" top="480" bottom="0" near="1" far="-1" name="Ortho" >
+ <asset type="StateChanger" file="LightingSwitch:0" />
+ <asset type="StateChanger" file="DepthTest:0" />
+ <node type="Cu2Root" width="640" height="480" hidden="true" >
+ <node type="Cu2Button" text="hello" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="450" />
+ </node>
+ </node>
</SceneGraph>
Added: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp (rev 0)
+++ Mercury2/modules/Cu2.cpp 2009-11-13 07:46:14 UTC (rev 620)
@@ -0,0 +1,426 @@
+#include "Cu2.h"
+#include <MercuryInput.h>
+#include <MercuryMessageManager.h>
+#include <MercuryWindow.h>
+#include <MercuryLog.h>
+#include <TextNode.h>
+
+#include <GLHeaders.h>
+
+///////////////////////////////////////COPPER 2 ELEMENT///////////////////////////////////////
+
+Cu2Element::Cu2Element() : TransformNode(),
+ m_pFocusNode(0), m_bCanTabStop( false ), m_iButtonMask(0), m_bWasMouseInThisFrame(0),
+ m_fX(0), m_fY(0), m_fW(100), m_fH(100),
+ m_fOrigX(0), m_fOrigY(0), m_fOrigW(100), m_fOrigH(100)
+{
+}
+
+void Cu2Element::LoadFromXML(const XMLNode& node)
+{
+ LOAD_FROM_XML( "x", m_fOrigX, StrToFloat );
+ LOAD_FROM_XML( "y", m_fOrigY, StrToFloat );
+ LOAD_FROM_XML( "width", m_fOrigW, StrToFloat );
+ LOAD_FROM_XML( "height", m_fOrigH, StrToFloat );
+
+ TransformNode::LoadFromXML( node );
+
+ SetXY( m_fOrigX, m_fOrigY );
+ SetSize( m_fOrigW, m_fOrigH );
+}
+
+void Cu2Element::SaveToXMLTag( MString & sXMLStream )
+{
+ if( GetX() != 0 ) sXMLStream += ssprintf( "x=\"%f\" ", GetX() );
+ if( GetY() != 0 ) sXMLStream += ssprintf( "y=\"%f\" ", GetY() );
+ if( GetW() != 0 ) sXMLStream += ssprintf( "width=\"%f\" ", GetW() );
+ if( GetH() != 0 ) sXMLStream += ssprintf( "height=\"%f\" ", GetH() );
+
+ TransformNode::SaveToXMLTag( sXMLStream );
+}
+
+void Cu2Element::ResetAttributes()
+{
+ SetXY( m_fOrigX, m_fOrigY );
+ SetSize( m_fOrigW, m_fOrigH );
+}
+
+bool Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask )
+{
+ if( IsHidden() )
+ return false;
+
+ bool bIsInside = ( x >= 0 && x < m_fW && y >= 0 && y < m_fH );
+
+ if( m_bWasMouseInThisFrame && !bIsInside )
+ MouseAction( x, y, MOVE_OUT, 0 );
+ else if( !m_bWasMouseInThisFrame && bIsInside )
+ MouseAction( x, y, MOVE_IN, 0 );
+
+ m_bWasMouseInThisFrame = bIsInside;
+
+ for( unsigned button = 0; button < 8; button++ )
+ {
+ unsigned char Mask = 1<<button;
+ bool bWasDown = m_iButtonMask & Mask;
+ bool bIsDown = iCurrentButtonMask & Mask;
+ if( bWasDown && !bIsDown )
+ {
+ //XXX: When we release outside - we want to propogate that information, and that can be tricky..
+ //So, instead, we choose to propogate that elsewhere...
+ m_iButtonMask &= ~Mask;
+ if( bIsInside )
+ MouseAction( x, y, RELEASE_IN, button );
+ else
+ PropogateReleaseOut( x, y, button );
+ }
+ else if( !bWasDown && bIsDown && bIsInside )
+ {
+ m_iButtonMask |= Mask;
+ MouseAction( x, y, PRESS_IN, button );
+ }
+ }
+
+ if( bIsInside )
+ for( MercuryNode* send = FirstChild(); send; send = NextChild( send ) )
+ {
+ Cu2Element * sa = dynamic_cast<Cu2Element*>(send);
+ if( sa )
+ {
+ sa->MouseMotion( x - int(sa->m_fX), y - int(sa->m_fY), iCurrentButtonMask );
+ }
+ }
+
+ return bIsInside;
+}
+
+void Cu2Element::PropogateReleaseOut( int x, int y, int iWhichButton )
+{
+ MouseAction( x, y, RELEASE_OUT, iWhichButton );
+
+ for( MercuryNode* send = FirstChild(); send; send = NextChild( send ) )
+ {
+ Cu2Element * sa = dynamic_cast<Cu2Element*>(send);
+ if( sa )
+ sa->PropogateReleaseOut( x - int(sa->m_fX), y - int(sa->m_fY), iWhichButton );
+ }
+}
+
+void Cu2Element::MouseAction( int x, int y, Cu2Action c, int iWhichButton )
+{
+ //nothing
+}
+
+void Cu2Element::AddChild(MercuryNode* n)
+{
+ if( !m_pFocusNode )
+ {
+ Cu2Element * sa = dynamic_cast< Cu2Element * >(n);
+ if( sa && sa->IsEnableTabStop() && !sa->IsHidden() )
+ m_pFocusNode = sa;
+ }
+ MercuryNode::AddChild( n );
+}
+
+void Cu2Element::RemoveChild(MercuryNode* n)
+{
+ if( m_pFocusNode == n )
+ {
+ m_pFocusNode->SetEnableTabStop( false );
+ UpdateTab();
+ }
+
+ MercuryNode::RemoveChild( n );
+}
+
+Cu2Element * Cu2Element::NextTab()
+{
+ if( m_pFocusNode )
+ {
+ for( MercuryNode* send = NextChild( m_pFocusNode ); send; send = NextChild( send ) )
+ {
+ Cu2Element * sa = dynamic_cast<Cu2Element*>(send);
+ if( sa && sa->IsEnableTabStop() && !sa->IsHidden() )
+ return sa;
+ }
+ }
+
+ for( MercuryNode* send = FirstChild(); send; send = NextChild( send ) )
+ {
+ Cu2Element * sa = dynamic_cast<Cu2Element*>(send);
+ if( sa && sa->IsEnableTabStop() && !sa->IsHidden() )
+ return sa;
+ }
+ return 0;
+}
+
+void Cu2Element::SetHidden( bool bHide )
+{
+ MercuryNode::SetHidden( bHide );
+ Cu2Element * parent = dynamic_cast<Cu2Element *>(Parent());
+ if( parent )
+ parent->UpdateTab();
+}
+
+void Cu2Element::SetEnableTabStop( bool bStop )
+{
+ m_bCanTabStop = bStop;
+ Cu2Element * parent = dynamic_cast<Cu2Element *>(Parent());
+ if( parent )
+ parent->UpdateTab();
+}
+
+void Cu2Element::UpdateTab()
+{
+ for( MercuryNode* send = m_pFocusNode; send; send = NextChild( send ) )
+ {
+ Cu2Element * sa = dynamic_cast<Cu2Element*>(send);
+ if( sa && sa->IsEnableTabStop() && !sa->IsHidden() )
+ {
+ m_pFocusNode = sa;
+ return;
+ }
+ }
+ for( MercuryNode* send = FirstChild(); send; send = NextChild( send ) )
+ {
+ Cu2Element * sa = dynamic_cast<Cu2Element*>(send);
+ if( sa && sa->IsEnableTabStop() && !sa->IsHidden() )
+ {
+ m_pFocusNode = sa;
+ return;
+ }
+ }
+ m_pFocusNode = 0;
+}
+
+void Cu2Element::GetKeypress( int key, bool bDown, bool bRepeat )
+{
+ if( m_pFocusNode )
+ m_pFocusNode->GetKeypress( key, bDown, bRepeat );
+}
+
+REGISTER_NODE_TYPE(Cu2Element);
+
+
+
+
+///////////////////////////////////////COPPER 2 ROOT///////////////////////////////////////
+Cu2Root::Cu2Root()
+{
+ g_pCurrentInstance = this;
+ REGISTER_MESSAGE_WITH_DELEGATE( INPUTEVENT_MOUSE, &Cu2Root::HandleMouseInput );
+ REGISTER_MESSAGE_WITH_DELEGATE( INPUTEVENT_KEYBOARD, &Cu2Root::HandleKeyboardInput );
+}
+
+Cu2Root::~Cu2Root()
+{
+ g_pCurrentInstance = 0;
+}
+
+void Cu2Root::SetHidden( bool bHide )
+{
+ MercuryWindow::GetCurrentWindow()->SetGrabbedMouseMode( bHide );
+
+ MercuryNode::SetHidden( bHide );
+}
+
+void Cu2Root::LoadFromXML(const XMLNode& node)
+{
+ Cu2Element::LoadFromXML( node );
+ MercuryWindow::GetCurrentWindow()->SetGrabbedMouseMode( IsHidden() );
+}
+
+
+void Cu2Root::HandleMouseInput(const MessageData& data)
+{
+ const MouseInput& m( dynamic_cast<const MouseInput&>( data ) );
+
+ //Don't pass on things if we're hidden.
+ if( IsHidden() )
+ {
+ //Don't do anything
+ }
+ else
+ {
+ MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data );
+ }
+}
+
+void Cu2Root::HandleKeyboardInput(const MessageData& data)
+{
+ const KeyboardInput& m( dynamic_cast<const KeyboardInput&>( data ) );
+
+ if( m.key == 27 && m.isDown && !m.isRepeat )
+ {
+ SetHidden( !IsHidden() );
+ }
+
+ //Don't pass on things if we're hidden.
+ if( IsHidden() ) return;
+
+ GetKeypress( m.key, m.isDown, m.isRepeat );
+}
+
+Cu2Root * Cu2Root::g_pCurrentInstance;
+
+REGISTER_NODE_TYPE(Cu2Root);
+
+///////////////////////////////////////COPPER 2 BUTTON///////////////////////////////////////
+
+Cu2Button::Cu2Button() : Cu2Element()
+{
+ m_pText = (TextNode*)NODEFACTORY.Generate( "TextNode" );
+ AddChild( m_pText );
+ m_bAutoSize = true;
+ m_bDown = false;
+}
+
+void Cu2Button::LoadFromXML(const XMLNode& node)
+{
+ LOAD_FROM_XML( "clickMessage", m_sMessageToSend, );
+ LOAD_FROM_XML( "text", m_sText, );
+ LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool );
+
+ if( m_pText )
+ {
+ m_pText->LoadFromXML( node );
+ m_pText->SetShiftAbsolute( true );
+ m_pText->SetShiftX( 5 );
+ m_pText->SetShiftY( 5 );
+ }
+
+ Cu2Element::LoadFromXML( node );
+
+ Refresh();
+}
+
+void Cu2Button::SaveToXMLTag( MString & sXMLStream )
+{
+ if( m_sMessageToSend.length() ) sXMLStream += ssprintf( "clickMessage=\"%s\" ", m_sMessageToSend.c_str() );
+ if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize );
+
+ if( !m_pText )
+ m_pText->SaveToXMLTag( sXMLStream );
+
+ Cu2Element::SaveToXMLTag( sXMLStream );
+}
+
+void Cu2Button::MouseAction( int x, int y, Cu2Action c, int iWhichButton )
+{
+ if( c == PRESS_IN )
+ m_bDown = true;
+ if( c == RELEASE_IN )
+ {
+ if( m_bDown )
+ Click();
+ m_bDown = false;
+ }
+
+ if( c == RELEASE_OUT )
+ {
+ m_bDown = false;
+ }
+}
+
+void Cu2Button::Refresh()
+{
+ if( !m_pText )
+ {
+ LOG.Write( "Warning: Cu2Button \"" + GetName() + "\" does not have valid Text box associated." );
+ return;
+ }
+
+ m_pText->SetText( m_sText );
+ m_pText->RenderText();
+
+ if( m_bAutoSize )
+ {
+ SetSize( m_pText->GetRMaxX() + 8, m_pText->GetRMaxY() + 8 );
+ printf( "Size: %f %f\n", m_pText->GetRMaxX() + 8, m_pText->GetRMaxY() + 8 );
+ }
+}
+
+void Cu2Button::Click()
+{
+ if( m_sMessageToSend.length() )
+ MESSAGEMAN.BroadcastMessage( m_sMessageToSend, new PointerDataMessage( this ) );
+}
+
+void Cu2Button::Render( const MercuryMatrix& m )
+{
+ glDisable( GL_TEXTURE_2D );
+ if( m_bDown )
+ glColor3f( 0.3, 0.3, 0.3 );
+ else
+ glColor3f( 0.5, 0.5, 0.5 );
+
+ glBegin( GL_QUADS );
+ glVertex2f( 1., 1. );
+ glVertex2f( GetW()-1, 1 );
+ glVertex2f( GetW()-1, GetH()-1);
+ glVertex2f( 1., GetH()-1 );
+ glEnd();
+
+ glLineWidth( 2 );
+ glBegin( GL_LINES );
+ if( m_bDown )
+ glColor3f( 0.1, 0.1, 0.1 );
+ else
+ glColor3f( 0.7, 0.7, 0.7 );
+ glVertex2f( 1, 1 );
+ glVertex2f( 1, GetH()-1 );
+ glVertex2f( 1, GetH()-1 );
+ glVertex2f( GetW()-2, GetH()-1 );
+ if( !m_bDown )
+ glColor3f( 0.1, 0.1, 0.1 );
+ else
+ glColor3f( 0.7, 0.7, 0.7 );
+ glVertex2f( GetW()-1, GetH()-2 );
+ glVertex2f( GetW()-1, 1 );
+ glVertex2f( GetW()-1, 1 );
+ glVertex2f( 1, 1 );
+ glEnd();
+ glEnable( GL_TEXTURE_2D );
+
+ glColor3f( 1., 1., 1. );
+
+ TransformNode::Render( m );
+}
+
+REGISTER_NODE_TYPE(Cu2Button);
+
+
+/****************************************************************************
+ * Copyright (C) 2008-2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * 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/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h (rev 0)
+++ Mercury2/modules/Cu2.h 2009-11-13 07:46:14 UTC (rev 620)
@@ -0,0 +1,206 @@
+#ifndef _CU2_H
+#define _CU2_H
+
+#include <TransformNode.h>
+
+///All the mouse actions Cu2 can transmit.
+enum Cu2Action
+{
+ RESERVED,
+ MOVE_IN,
+ MOVE_OUT,
+ PRESS_IN,
+ RELEASE_IN,
+ RELEASE_OUT,
+ RELEASE_OUT_PROPOGATE,
+};
+
+///The base Cu2 UI Element.
+class Cu2Element : public TransformNode
+{
+public:
+ Cu2Element();
+
+ ///Load fromXML
+ virtual void LoadFromXML(const XMLNode& node);
+
+ ///Save extra stuff to XML.
+ virtual void SaveToXMLTag( MString & sXMLStream );
+
+ ///Handle a mouse action at a high level, typically this is overridden.
+ ///This will get called by Cu2Element::MouseMotion. Generally, users do not call this.
+ ///For move events, iWhichButton is always 0.
+ virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton );
+
+ ///Reset All attributes (will operate on all children in base class)
+ virtual void ResetAttributes();
+
+ ///Push raw mouse event. Generally, this calls MouseAction, and is only called internally.
+ ///You may override this if you want to take actions that require mouse motion.
+ virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask );
+
+ ///Called when a key is pressed - down the focus line.
+ virtual void GetKeypress( int key, bool bDown, bool bRepeat );
+
+ //Below here - you run into functions that are seldom overloaded.
+
+ ///Handle updating of tab information
+ virtual void AddChild(MercuryNode* n);
+
+ ///Handle updating of tab information
+ virtual void RemoveChild(MercuryNode* n);
+
+ ///Also handle tab stopping correctly.
+ virtual void SetHidden( bool bHide );
+
+ ///Progress to the next tab.
+ Cu2Element * NextTab();
+
+ ///Update this's tab
+ void UpdateTab();
+
+ ///Enable/disable tab stopping on this node.
+ void SetEnableTabStop( bool bStop );
+
+ ///Find out if tab stopping is allowed on this node.
+ bool IsEnableTabStop( ) { return m_bCanTabStop; }
+
+ ///Propogate Release (You should not override this or modify it)
+ void PropogateReleaseOut( int x, int y, int iWhichButton );
+
+ ///Get current button mask
+ inline unsigned char GetCurrentButtonMask() { return m_iButtonMask; }
+
+ ///Get if current button is down
+ inline bool IsButtonDown( char iWhichButton ) { return (m_iButtonMask)&(1<<iWhichButton); }
+
+ ///Set Position
+ void SetXY( float fX, float fY ) { m_fX = fX; m_fY = fY; SetPosition( MercuryVertex( m_fX, m_fY, 0. ) ); }
+ void SetX( float fX ) { m_fX = fX; SetPosition( MercuryVertex( m_fX, m_fY, 0 ) ); }
+ void SetY( float fY ) { m_fY = fY; SetPosition( MercuryVertex( m_fX, m_fY, 0 ) ); }
+
+ ///Get X location
+ float GetX() { return m_fX; }
+ ///Get Y location
+ float GetY() { return m_fY; }
+
+ ///Set Width/Height
+ void SetSize( float fW, float fH ) { m_fW = fW; m_fH = fH; }
+ ///Set Width
+ void SetW( float fW ) { m_fW = fW; }
+ ///Set Height
+ void SetH( float fH ) { m_fH = fH; }
+
+ ///Get Width
+ float GetW() { return m_fW; }
+
+ ///Get Height
+ float GetH() { return m_fH; }
+
+protected:
+ Cu2Element * m_pFocusNode;
+
+ bool m_bCanTabStop;
+
+ ///Mask of currently depressed buttons.
+ unsigned char m_iButtonMask;
+
+ bool m_bWasMouseInThisFrame;
+
+ float m_fX, m_fY, m_fW, m_fH;
+ float m_fOrigX, m_fOrigY, m_fOrigW, m_fOrigH;
+};
+
+///Root Cu2 Window - this is usually full screen - when it is visible, mouse input grabbing is diabled, so you can use the cursor.
+class Cu2Root : public Cu2Element
+{
+public:
+ Cu2Root();
+ virtual ~Cu2Root();
+
+ ///Overload hiddent to find out when the user
+ virtual void SetHidden( bool bHide );
+
+ virtual void LoadFromXML( const XMLNode & node );
+
+ ///Return current Cu2Root.
+ ///Note: This will misbehave if you load more than one. If no instance is loaded, it will return 0.
+ static Cu2Root * GetCurrent() { return g_pCurrentInstance; }
+
+ void HandleMouseInput(const MessageData& data);
+ void HandleKeyboardInput(const MessageData& data);
+
+ GENRTTI( Cu2Root );
+private:
+ static Cu2Root * g_pCurrentInstance;
+};
+
+class TextNode;
+
+///Standard button
+class Cu2Button : public Cu2Element
+{
+public:
+ Cu2Button();
+
+ virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton );
+ ///This function gets called whenever the button is clicked, you should abstract from this.
+ virtual void Click();
+
+ virtual void LoadFromXML(const XMLNode& node);
+ virtual void SaveToXMLTag( MString & sXMLStream );
+
+
+ virtual void Render( const MercuryMatrix& m );
+
+ void SetText( const MString & sText ) { m_sText = sText; Refresh(); }
+ void SetAutoSize( bool bAutoSize ) { m_bAutoSize = bAutoSize; Refresh(); }
+ void Refresh();
+
+ TextNode * GetTextNodeHandle() { return m_pText; }
+
+ GENRTTI( Cu2Button );
+private:
+ MString m_sMessageToSend;
+ MString m_sText;
+ bool m_bAutoSize;
+ bool m_bDown;
+ TextNode * m_pText;
+};
+
+#endif
+
+
+/****************************************************************************
+ * Copyright (C) 2009 by Charles Lohr *
+ * 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/modules/Makefile
===================================================================
--- Mercury2/modules/Makefile 2009-11-13 07:45:59 UTC (rev 619)
+++ Mercury2/modules/Makefile 2009-11-13 07:46:14 UTC (rev 620)
@@ -2,7 +2,7 @@
CXXFLAGS=${CFLAGS}
LDFLAGS=-shared
-all : BillboardNode.so TextNode.so Terrain.so TextPlate.so
+all : BillboardNode.so TextNode.so Terrain.so TextPlate.so Cu2.so
clean :
rm -rf *~ *.o *.so
Modified: Mercury2/modules.xml
===================================================================
--- Mercury2/modules.xml 2009-11-13 07:45:59 UTC (rev 619)
+++ Mercury2/modules.xml 2009-11-13 07:46:14 UTC (rev 620)
@@ -1,6 +1,7 @@
<Modules>
<Module src="modules/TextNode.cpp" obj="modules/TextNode" func="InstallTextNode" class="TextNode" />
<Module src="modules/BillboardNode.cpp" obj="modules/BillboardNode" func="InstallBillboardNode" class="BillboardNode" />
- <Module src="modules/Terrain.cpp" obj="modules/Terrain" func="InstallTerrainNode" class="TerrainNode"/>
+ <Module src="modules/Terrain.cpp" obj="modules/Terrain" func="" class="TerrainNode"/>
<Module src="modules/TextPlate.cpp" obj="modules/TextPlate" func="InstallTextPlate" class="TextPlate"/>
+ <Module src="modules/Cu2.cpp" obj="modules/Cu2" func="InstallCu2Element" class="Cu2Element"/>
</Modules>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-18 22:11:50
|
Revision: 624
http://hgengine.svn.sourceforge.net/hgengine/?rev=624&view=rev
Author: cnlohr
Date: 2009-11-18 22:11:44 +0000 (Wed, 18 Nov 2009)
Log Message:
-----------
tweak - add dialogs
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/modules/Cu2.cpp
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-11-18 22:10:37 UTC (rev 623)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-11-18 22:11:44 UTC (rev 624)
@@ -57,7 +57,10 @@
<asset type="StateChanger" file="LightingSwitch:0" />
<asset type="StateChanger" file="DepthTest:0" />
<node type="Cu2Root" width="640" height="480" hidden="true" >
- <node type="Cu2Button" text="hello" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="450" />
+ <node type="Cu2Button" text="hello" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="450" name="Button" />
+ <node type="Cu2Dialog" text="T00" font="FONT:FreeSans.hgfont" size=".25" x="200" y="40" name="Dialog" >
+ <node type="Cu2Button" text="hel0" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="40" />
+ </node>
</node>
</node>
</SceneGraph>
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2009-11-18 22:10:37 UTC (rev 623)
+++ Mercury2/modules/Cu2.cpp 2009-11-18 22:11:44 UTC (rev 624)
@@ -321,7 +321,10 @@
if( m_pText )
{
- m_pText->LoadFromXML( node );
+ m_pText->SetAlignment( TextNode::LEFT );
+ m_pText->LoadFont( node.Attribute("font") );
+ m_pText->SetSize( StrToFloat( node.Attribute("size") ) );
+ SetText( m_sText );
m_pText->SetShiftAbsolute( true );
m_pText->SetShiftX( 5 );
m_pText->SetShiftY( 5 );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-21 19:10:32
|
Revision: 630
http://hgengine.svn.sourceforge.net/hgengine/?rev=630&view=rev
Author: axlecrusher
Date: 2009-12-21 19:10:26 +0000 (Mon, 21 Dec 2009)
Log Message:
-----------
fix windows compile
renders very slow
Modified Paths:
--------------
Mercury2/Mercury2.vcproj
Mercury2/modules/ParticleEmitter.cpp
Mercury2/src/GLHeaders.h
Mercury2/src/MercuryMath.h
Mercury2/src/OGLExtensions.cpp
Mercury2/src/OGLExtensions.h
Mercury2/src/StateChanger.cpp
Mercury2/src/StateChanger.h
Mercury2/src/global.h
Modified: Mercury2/Mercury2.vcproj
===================================================================
--- Mercury2/Mercury2.vcproj 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/Mercury2.vcproj 2009-12-21 19:10:26 UTC (rev 630)
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories=".;src;src/include;src/include/png;src/include/zlib"
+ AdditionalIncludeDirectories="modules;.;src;src/include;src/include/png;src/include/zlib;src/DataStructures;src/DataTypes"
PreprocessorDefinitions="HGENGINE;WIN32;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@@ -172,6 +172,10 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
+ RelativePath=".\src\AlignedBuffer.h"
+ >
+ </File>
+ <File
RelativePath=".\src\BMPLoader.cpp"
>
</File>
@@ -180,401 +184,395 @@
>
</File>
<File
- RelativePath=".\src\Camera.cpp"
+ RelativePath=".\src\BoundingBox.h"
>
</File>
<File
- RelativePath=".\src\Frustum.cpp"
+ RelativePath=".\src\Callback.h"
>
</File>
<File
- RelativePath=".\src\FullscreenQuad.cpp"
+ RelativePath=".\src\Camera.cpp"
>
</File>
<File
- RelativePath=".\src\GLHelpers.cpp"
+ RelativePath=".\src\Camera.h"
>
</File>
<File
- RelativePath=".\src\HGMDLMesh.cpp"
+ RelativePath=".\src\Frustum.cpp"
>
</File>
<File
- RelativePath=".\src\HGMDLModel.cpp"
+ RelativePath=".\src\Frustum.h"
>
</File>
<File
- RelativePath=".\src\ImageLoader.cpp"
+ RelativePath=".\src\FullscreenQuad.cpp"
>
</File>
<File
- RelativePath=".\src\Mercury2.cpp"
+ RelativePath=".\src\FullscreenQuad.h"
>
</File>
<File
- RelativePath=".\src\MercuryAsset.cpp"
+ RelativePath=".\src\glext.h"
>
</File>
<File
- RelativePath=".\src\MercuryBacktrace.c"
+ RelativePath=".\src\GLHeaders.h"
>
</File>
<File
- RelativePath=".\src\MercuryCrash.c"
+ RelativePath=".\src\GLHelpers.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryFBO.cpp"
+ RelativePath=".\src\GLHelpers.h"
>
</File>
<File
- RelativePath=".\src\MercuryFile.cpp"
+ RelativePath=".\src\global.h"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverDirect.cpp"
+ RelativePath=".\src\HGMDLMesh.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverMem.cpp"
+ RelativePath=".\src\HGMDLMesh.h"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverPacked.cpp"
+ RelativePath=".\src\HGMDLModel.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverZipped.cpp"
+ RelativePath=".\src\HGMDLModel.h"
>
</File>
<File
- RelativePath=".\src\MercuryInput.cpp"
+ RelativePath=".\src\ImageLoader.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryMath.cpp"
+ RelativePath=".\src\ImageLoader.h"
>
</File>
<File
- RelativePath=".\src\MercuryMatrix.cpp"
+ RelativePath=".\src\Light.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryMessageManager.cpp"
+ RelativePath=".\src\Light.h"
>
</File>
<File
- RelativePath=".\src\MercuryNamedResource.cpp"
+ RelativePath=".\src\MAutoPtr.h"
>
</File>
<File
- RelativePath=".\src\MercuryNode.cpp"
+ RelativePath=".\src\Mercury2.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryPlane.cpp"
+ RelativePath=".\src\MercuryAsset.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryPrefs.cpp"
+ RelativePath=".\src\MercuryAsset.h"
>
</File>
<File
- RelativePath=".\src\MercuryString.cpp"
+ RelativePath=".\src\MercuryBacktrace.c"
>
</File>
<File
- RelativePath=".\src\MercuryTheme.cpp"
+ RelativePath=".\src\MercuryBacktrace.h"
>
</File>
<File
- RelativePath=".\src\MercuryThreads.cpp"
+ RelativePath=".\src\MercuryCrash.c"
>
</File>
<File
- RelativePath=".\src\MercuryTimer.cpp"
+ RelativePath=".\src\MercuryCrash.h"
>
</File>
<File
- RelativePath=".\src\MercuryUtil.cpp"
+ RelativePath=".\src\MercuryCTA.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryVBO.cpp"
+ RelativePath=".\src\MercuryCTA.h"
>
</File>
<File
- RelativePath=".\src\MercuryVertex.cpp"
+ RelativePath=".\src\MercuryFBO.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryWindow.cpp"
+ RelativePath=".\src\MercuryFBO.h"
>
</File>
<File
- RelativePath=".\src\ModuleManager.cpp"
+ RelativePath=".\src\MercuryFile.cpp"
>
</File>
<File
- RelativePath=".\src\MQuaternion.cpp"
+ RelativePath=".\src\MercuryFile.h"
>
</File>
<File
- RelativePath=".\src\MSemaphore.cpp"
+ RelativePath=".\src\MercuryFileDriverDirect.cpp"
>
</File>
<File
- RelativePath=".\src\OGLExtensions.cpp"
+ RelativePath=".\src\MercuryFileDriverDirect.h"
>
</File>
<File
- RelativePath=".\src\PNGLoader.cpp"
+ RelativePath=".\src\MercuryFileDriverMem.cpp"
>
</File>
<File
- RelativePath=".\src\Quad.cpp"
+ RelativePath=".\src\MercuryFileDriverMem.h"
>
</File>
<File
- RelativePath=".\src\RawImageData.cpp"
+ RelativePath=".\src\MercuryFileDriverPacked.cpp"
>
</File>
<File
- RelativePath=".\src\RenderGraph.cpp"
+ RelativePath=".\src\MercuryFileDriverPacked.h"
>
</File>
<File
- RelativePath=".\src\Shader.cpp"
+ RelativePath=".\src\MercuryFileDriverZipped.cpp"
>
</File>
<File
- RelativePath=".\src\Texture.cpp"
+ RelativePath=".\src\MercuryFileDriverZipped.h"
>
</File>
<File
- RelativePath=".\src\TransformNode.cpp"
+ RelativePath=".\src\MercuryHash.h"
>
</File>
<File
- RelativePath=".\src\UpdateThreader.cpp"
+ RelativePath=".\src\MercuryInput.cpp"
>
</File>
<File
- RelativePath=".\src\Viewport.cpp"
+ RelativePath=".\src\MercuryInput.h"
>
</File>
<File
- RelativePath=".\src\Win32Window.cpp"
+ RelativePath=".\src\MercuryList.h"
>
</File>
<File
- RelativePath=".\src\XMLParser.cpp"
+ RelativePath=".\src\MercuryLog.cpp"
>
</File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
- >
<File
- RelativePath=".\src\AlignedBuffer.h"
+ RelativePath=".\src\MercuryMath.cpp"
>
</File>
<File
- RelativePath=".\src\BoundingBox.h"
+ RelativePath=".\src\MercuryMath.h"
>
</File>
<File
- RelativePath=".\src\Callback.h"
+ RelativePath=".\src\MercuryMatrix.cpp"
>
</File>
<File
- RelativePath=".\src\Camera.h"
+ RelativePath=".\src\MercuryMatrix.h"
>
</File>
<File
- RelativePath=".\src\Frustum.h"
+ RelativePath=".\src\MercuryMessageManager.cpp"
>
</File>
<File
- RelativePath=".\src\FullscreenQuad.h"
+ RelativePath=".\src\MercuryMessageManager.h"
>
</File>
<File
- RelativePath=".\src\glext.h"
+ RelativePath=".\src\MercuryNamedResource.cpp"
>
</File>
<File
- RelativePath=".\src\GLHeaders.h"
+ RelativePath=".\src\MercuryNamedResource.h"
>
</File>
<File
- RelativePath=".\src\GLHelpers.h"
+ RelativePath=".\src\MercuryNode.cpp"
>
</File>
<File
- RelativePath=".\src\global.h"
+ RelativePath=".\src\MercuryNode.h"
>
</File>
<File
- RelativePath=".\src\HGMDLMesh.h"
+ RelativePath=".\src\MercuryPlane.cpp"
>
</File>
<File
- RelativePath=".\src\HGMDLModel.h"
+ RelativePath=".\src\MercuryPlane.h"
>
</File>
<File
- RelativePath=".\src\ImageLoader.h"
+ RelativePath=".\src\MercuryPrefs.cpp"
>
</File>
<File
- RelativePath=".\src\MAutoPtr.h"
+ RelativePath=".\src\MercuryPrefs.h"
>
</File>
<File
- RelativePath=".\src\MercuryAsset.h"
+ RelativePath=".\src\MercurySound.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryBacktrace.h"
+ RelativePath=".\src\MercurySound.h"
>
</File>
<File
- RelativePath=".\src\MercuryCrash.h"
+ RelativePath=".\src\MercuryString.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryFBO.h"
+ RelativePath=".\src\MercuryString.h"
>
</File>
<File
- RelativePath=".\src\MercuryFile.h"
+ RelativePath=".\src\MercuryTheme.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverDirect.h"
+ RelativePath=".\src\MercuryTheme.h"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverMem.h"
+ RelativePath=".\src\MercuryThreads.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverPacked.h"
+ RelativePath=".\src\MercuryThreads.h"
>
</File>
<File
- RelativePath=".\src\MercuryFileDriverZipped.h"
+ RelativePath=".\src\MercuryTimer.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryHash.h"
+ RelativePath=".\src\MercuryTimer.h"
>
</File>
<File
- RelativePath=".\src\MercuryInput.h"
+ RelativePath=".\src\MercuryUtil.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryList.h"
+ RelativePath=".\src\MercuryUtil.h"
>
</File>
<File
- RelativePath=".\src\MercuryMath.h"
+ RelativePath=".\src\MercuryVBO.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryMatrix.h"
+ RelativePath=".\src\MercuryVBO.h"
>
</File>
<File
- RelativePath=".\src\MercuryMessageManager.h"
+ RelativePath=".\src\MercuryVector.h"
>
</File>
<File
- RelativePath=".\src\MercuryNamedResource.h"
+ RelativePath=".\src\MercuryVertex.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryNode.h"
+ RelativePath=".\src\MercuryVertex.h"
>
</File>
<File
- RelativePath=".\src\MercuryPlane.h"
+ RelativePath=".\src\MercuryWindow.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryPrefs.h"
+ RelativePath=".\src\MercuryWindow.h"
>
</File>
<File
- RelativePath=".\src\MercuryString.h"
+ RelativePath=".\src\MessageHandler.h"
>
</File>
<File
- RelativePath=".\src\MercuryTheme.h"
+ RelativePath=".\src\Mint.h"
>
</File>
<File
- RelativePath=".\src\MercuryThreads.h"
+ RelativePath=".\src\ModuleManager.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryTimer.h"
+ RelativePath=".\src\ModuleManager.h"
>
</File>
<File
- RelativePath=".\src\MercuryUtil.h"
+ RelativePath=".\src\MQuaternion.cpp"
>
</File>
<File
- RelativePath=".\src\MercuryVBO.h"
+ RelativePath=".\src\MQuaternion.h"
>
</File>
<File
- RelativePath=".\src\MercuryVector.h"
+ RelativePath=".\src\MQueue.h"
>
</File>
<File
- RelativePath=".\src\MercuryVertex.h"
+ RelativePath=".\src\MScopedArray.h"
>
</File>
<File
- RelativePath=".\src\MercuryWindow.h"
+ RelativePath=".\src\MSemaphore.cpp"
>
</File>
<File
- RelativePath=".\src\MessageHandler.h"
+ RelativePath=".\src\MSemaphore.h"
>
</File>
<File
- RelativePath=".\src\Mint.h"
+ RelativePath=".\src\DataTypes\MTriangle.cpp"
>
</File>
<File
- RelativePath=".\src\ModuleManager.h"
+ RelativePath=".\src\DataTypes\MTriangle.h"
>
</File>
<File
- RelativePath=".\src\MQuaternion.h"
+ RelativePath=".\src\OGLExtensions.cpp"
>
</File>
<File
- RelativePath=".\src\MQueue.h"
+ RelativePath=".\src\OGLExtensions.h"
>
</File>
<File
- RelativePath=".\src\MScopedArray.h"
+ RelativePath=".\src\Orthographic.cpp"
>
</File>
<File
- RelativePath=".\src\MSemaphore.h"
+ RelativePath=".\src\Orthographic.h"
>
</File>
<File
- RelativePath=".\src\OGLExtensions.h"
+ RelativePath=".\src\PNGLoader.cpp"
>
</File>
<File
@@ -582,10 +580,18 @@
>
</File>
<File
+ RelativePath=".\src\Quad.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\Quad.h"
>
</File>
<File
+ RelativePath=".\src\RawImageData.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\RawImageData.h"
>
</File>
@@ -594,34 +600,86 @@
>
</File>
<File
+ RelativePath=".\src\RenderDeferredLights.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\RenderDeferredLights.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\RenderGraph.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\RenderGraph.h"
>
</File>
<File
+ RelativePath=".\src\Shader.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\Shader.h"
>
</File>
<File
+ RelativePath=".\src\StateChanger.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\StateChanger.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\stdint.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\Texture.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\Texture.h"
>
</File>
<File
+ RelativePath=".\src\TransformNode.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\TransformNode.h"
>
</File>
<File
+ RelativePath=".\src\UpdateThreader.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\UpdateThreader.h"
>
</File>
<File
+ RelativePath=".\src\Viewport.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\Viewport.h"
>
</File>
<File
+ RelativePath=".\src\Win32Window.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\Win32Window.h"
>
</File>
<File
+ RelativePath=".\src\XMLParser.cpp"
+ >
+ </File>
+ <File
RelativePath=".\src\XMLParser.h"
>
</File>
@@ -644,6 +702,34 @@
>
</File>
<File
+ RelativePath=".\modules\Cu2.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\modules\Cu2.h"
+ >
+ </File>
+ <File
+ RelativePath=".\src\MercuryLog.h"
+ >
+ </File>
+ <File
+ RelativePath=".\modules\ParticleEmitter.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\modules\ParticleEmitter.h"
+ >
+ </File>
+ <File
+ RelativePath=".\modules\Terrain.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\modules\Terrain.h"
+ >
+ </File>
+ <File
RelativePath=".\modules\TextNode.cpp"
>
</File>
@@ -651,6 +737,14 @@
RelativePath=".\modules\TextNode.h"
>
</File>
+ <File
+ RelativePath=".\modules\TextPlate.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\modules\TextPlate.h"
+ >
+ </File>
</Filter>
<File
RelativePath=".\scenegraph.xml"
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-21 19:10:26 UTC (rev 630)
@@ -126,7 +126,7 @@
p->m_lifespan = m_particleMinLife;
- p->m_lifespan = (rand()%(int(m_particleMaxLife*1000) - int(m_particleMinLife*1000)))/1000.0f;
+ p->m_lifespan += (rand()%(int(m_particleMaxLife*1000) - int(m_particleMinLife*1000)))/1000.0f;
p->m_seed1 = rand()%100000;
p->m_seed2 = rand()%100000;
// +((rand()%((m_particleMaxLife*1000)-(m_particleMinLife*1000)))/1000.0f);
Modified: Mercury2/src/GLHeaders.h
===================================================================
--- Mercury2/src/GLHeaders.h 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/src/GLHeaders.h 2009-12-21 19:10:26 UTC (rev 630)
@@ -1,12 +1,11 @@
#ifndef GLHEADERS_H
#define GLHEADERS_H
-#include <configuration.h>
-
#ifdef WIN32
#include <windows.h>
#else
#define GL_GLEXT_PROTOTYPES
+#include <configuration.h>
#endif
#include <GL/gl.h>
Modified: Mercury2/src/MercuryMath.h
===================================================================
--- Mercury2/src/MercuryMath.h 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/src/MercuryMath.h 2009-12-21 19:10:26 UTC (rev 630)
@@ -3,8 +3,10 @@
#include <math.h>
#ifdef HGENGINE
+#ifndef WIN32
#include <configuration.h>
#endif
+#endif
#ifdef USE_SSE
#include <xmmintrin.h>
Modified: Mercury2/src/OGLExtensions.cpp
===================================================================
--- Mercury2/src/OGLExtensions.cpp 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/src/OGLExtensions.cpp 2009-12-21 19:10:26 UTC (rev 630)
@@ -32,6 +32,7 @@
PFNGLPROGRAMPARAMETERIEXTPROC glProgramParameteriEXT;
PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB;
PFNGLUNIFORM1IARBPROC glUniform1iARB;
+PFNGLUNIFORM1FARBPROC glUniform1fARB;
PFNGLUNIFORM4FVARBPROC glUniform4fvARB;
PFNGLUNIFORM4IVARBPROC glUniform4ivARB;
@@ -88,6 +89,7 @@
EXTENSION( PFNGLPROGRAMPARAMETERIEXTPROC,glProgramParameteriEXT );
EXTENSION( PFNGLGETACTIVEUNIFORMARBPROC,glGetActiveUniformARB );
EXTENSION( PFNGLUNIFORM1IARBPROC,glUniform1iARB );
+EXTENSION( PFNGLUNIFORM1FARBPROC,glUniform1fARB );
EXTENSION( PFNGLUNIFORM4FVARBPROC,glUniform4fvARB );
EXTENSION( PFNGLUNIFORMMATRIX4FVARBPROC, glUniformMatrix4fvARB );
Modified: Mercury2/src/OGLExtensions.h
===================================================================
--- Mercury2/src/OGLExtensions.h 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/src/OGLExtensions.h 2009-12-21 19:10:26 UTC (rev 630)
@@ -27,6 +27,7 @@
extern PFNGLPROGRAMPARAMETERIEXTPROC glProgramParameteriEXT;
extern PFNGLGETACTIVEUNIFORMARBPROC glGetActiveUniformARB;
extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
+extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
extern PFNGLUNIFORM4FVARBPROC glUniform4fvARB;
extern PFNGLUNIFORM4IVARBPROC glUniform4ivARB;
extern PFNGLUNIFORMMATRIX4FVARBPROC glUniformMatrix4fvARB;
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/src/StateChanger.cpp 2009-12-21 19:10:26 UTC (rev 630)
@@ -143,10 +143,10 @@
REGISTER_STATECHANGE( DepthWrite );
//////////////////////////////////////STATE CHANGE CHUNK//////////////////////////////////////
-StateChangeRegister * StateChangeRegister::m_Instance;
StateChangeRegister & StateChangeRegister::Instance()
{
+ static StateChangeRegister* m_Instance = NULL;
if( !m_Instance )
m_Instance = new StateChangeRegister();
return *m_Instance;
@@ -286,7 +286,6 @@
MVector< MVector< MAutoPtr< StateChange > > > StateChanger::m_StateSet;
-
/****************************************************************************
* Copyright (C) 2008 - 2009 by Joshua Allen *
* Charles Lohr *
Modified: Mercury2/src/StateChanger.h
===================================================================
--- Mercury2/src/StateChanger.h 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/src/StateChanger.h 2009-12-21 19:10:26 UTC (rev 630)
@@ -27,6 +27,9 @@
class StateChangeRegister
{
public:
+ StateChangeRegister()
+ :m_iStateCount(0)
+ {}
static StateChangeRegister & Instance();
int RegisterGenerator( const MString & name, StateChange*(*gn)( const MVector< MString > &sParameters ) );
MAutoPtr< StateChange > Create( const MString & name, const MVector< MString > & sParameters );
@@ -35,7 +38,7 @@
int GetStateCount() { return m_iStateCount; }
private:
MHash< StateChange*(*)(const MVector< MString > &sParameters) > m_Generators;
- static StateChangeRegister * m_Instance;
+// static StateChangeRegister * m_Instance;
MHash< int > m_hStateIDs;
int m_iStateCount;
};
Modified: Mercury2/src/global.h
===================================================================
--- Mercury2/src/global.h 2009-12-14 22:00:23 UTC (rev 629)
+++ Mercury2/src/global.h 2009-12-21 19:10:26 UTC (rev 630)
@@ -3,8 +3,9 @@
#ifdef WIN32
#pragma warning( disable : 4100 )
+#else
+#include <configuration.h>
#endif
-#include <configuration.h>
#include <Mint.h>
-#endif
+#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 20:45:05
|
Revision: 643
http://hgengine.svn.sourceforge.net/hgengine/?rev=643&view=rev
Author: axlecrusher
Date: 2009-12-24 20:44:59 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
fix default pass for particle emitter
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/modules/ParticleEmitter.cpp
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 20:34:24 UTC (rev 642)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 20:44:59 UTC (rev 643)
@@ -38,7 +38,7 @@
<node type="transformnode" scalex="0.1" scaley="0.1" scalez="0.1">
<asset type="shader" file="GRAPHIC:FireParticles"/>
<asset type="texture" file="GRAPHIC:flame.png"/>
- <node type="particleemitter" setPasses="7"/>
+ <node type="particleemitter"/>
</node>
</node>
<node type="transformnode" movx="1" fallback="lamprow.lamp" />
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-24 20:34:24 UTC (rev 642)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-24 20:44:59 UTC (rev 643)
@@ -124,6 +124,8 @@
m_particles(NULL), GenerateParticlesClbk(NULL),
m_bufferID(0), m_dirtyVBO(false)
{
+ m_iForcePasses = m_iForcePasses | (1<<15);
+ m_iForcePasses = m_iForcePasses | (1<<7);
Init();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-28 22:26:35
|
Revision: 645
http://hgengine.svn.sourceforge.net/hgengine/?rev=645&view=rev
Author: axlecrusher
Date: 2009-12-28 22:26:28 +0000 (Mon, 28 Dec 2009)
Log Message:
-----------
use state changers to affect particles for better looking fire
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/Themes/default/Graphic/FireParticles.frag
Mercury2/Themes/default/Graphic/FireParticles.vert
Mercury2/modules/ParticleEmitter.cpp
Mercury2/src/StateChanger.cpp
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-28 22:26:28 UTC (rev 645)
@@ -3,6 +3,8 @@
<asset type="StateChanger" file="ColorChange:1,1,1,1" />
<asset type="StateChanger" file="DepthTest:1" />
<asset type="StateChanger" file="LightingSwitch:0" />
+ <asset type="StateChanger" file="DepthWrite:1" />
+ <asset type="StateChanger" file="BlendFunc:SRC_ALPHA,ONE_MINUS_SRC_ALPHA" />
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp">
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
<node type="transformnode" movz="-5" movy=".2">
@@ -36,6 +38,8 @@
state changer needs some work for proper on and off.
until then had code it for all particles -->
<node type="transformnode" scalex="0.1" scaley="0.1" scalez="0.1">
+ <asset type="StateChanger" file="DepthWrite:0" />
+ <asset type="StateChanger" file="BlendFunc:ONE,ONE" />
<asset type="shader" file="GRAPHIC:FireParticles"/>
<asset type="texture" file="GRAPHIC:flame2.png"/>
<node type="particleemitter"/>
Modified: Mercury2/Themes/default/Graphic/FireParticles.frag
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-28 22:26:28 UTC (rev 645)
@@ -1,22 +1,34 @@
uniform sampler2D HG_Texture0;
varying vec4 particleData;
+vec3 Blend(vec3 c1, vec3 c2, float p)
+{
+ return c1*(1.0-p) + c2*p;
+}
+
void main()
{
float pComplete = (particleData.x/particleData.y);
- vec4 blue = vec4(0,0,1,0.125);
- vec4 orange = vec4(1,0.917647059,0.11372549,1);
- vec4 color = vec4(0,0,0,0);
+ vec3 blue = vec3(0,0,1);
+ vec3 orange = vec3(1,0.917647059,0.1372549);
+ vec3 color = vec3(0,0,0);
//blues
- color += blue*(1.0-(pComplete*5.0))*float(pComplete<0.2); //blue
- color += 1.25*orange*(pComplete*5.0)*float(pComplete<0.2); //orange
+ color += Blend(blue, orange, min(1.0,pComplete*3.33))*float(pComplete<0.5);
+ color += Blend(orange, vec3(-3), (pComplete-0.5)*2.0)*float(pComplete>0.5);
+// color += blue*(1.0-(pComplete*3.33))*float(pComplete<0.3); //blue
+// color += orange*(pComplete*3.33)*float(pComplete<0.3); //orange
+
//orange to black fade
- color += 1.25*orange*(1.0-(pComplete-0.2))*float(pComplete>0.2); //orange
- color += vec4(-1,-1,-1,1)*(pComplete)*float(pComplete>0.2); //smoke -1 offset
+// color += 1.25*orange*(1.0-(pComplete-0.2))*float(pComplete>0.2); //orange
+// color += vec4(-1,-1,-1,1)*(pComplete)*float(pComplete>0.2); //smoke -1 offset
- gl_FragData[0] = texture2D(HG_Texture0, gl_TexCoord[0].st)*color;
+ color.rgb *= texture2D(HG_Texture0, gl_TexCoord[0].st).a;
+ color.rgb *= 1.0-(particleData.x/particleData.y);
+
+ gl_FragData[0].rgb = texture2D(HG_Texture0, gl_TexCoord[0].st).rgb*color.rgb;
+ gl_FragData[0].a = texture2D(HG_Texture0, gl_TexCoord[0].st).a;
gl_FragData[0].a *= 1.0-(particleData.x/particleData.y);
}
Modified: Mercury2/Themes/default/Graphic/FireParticles.vert
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-28 22:26:28 UTC (rev 645)
@@ -53,7 +53,7 @@
particleData = gl_Color;
vec4 pos = vec4(1.0);
- pos.y = 0.3*(particleData.x*particleData.x);
+ pos.y = 0.3*(particleData.x*particleData.x) + 1.5*(particleData.x/particleData.y);
pos.x = 0.40*((particleData.z-50000.0)/50000.0)*particleData.x; //rand num
pos.z = 0.40*((particleData.w-50000.0)/50000.0)*particleData.x; //rand num
@@ -61,9 +61,9 @@
m[3].xyz = pos.xyz;
mat4 s = mat4(0.0);
- s[0][0] = 1.0+3.0*(particleData.x/particleData.y);
- s[1][1] = 1.0+3.0*(particleData.x/particleData.y);
- s[2][2] = 1.0+3.0*(particleData.x/particleData.y);
+ s[0][0] = 0.5+3.0*(particleData.x/particleData.y);
+ s[1][1] = 0.5+3.0*(particleData.x/particleData.y);
+ s[2][2] = 0.5+3.0*(particleData.x/particleData.y);
s[3][3] = 1.0;
gl_Position = gl_ProjectionMatrix *HG_ViewMatrix *HG_ModelMatrix *m*s* gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-28 22:26:28 UTC (rev 645)
@@ -257,8 +257,7 @@
void ParticleEmitter::Render(const MercuryMatrix& matrix)
{
- GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT|GL_CURRENT_BIT) );
- GLCALL( glDepthMask( false ) );
+ GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_CURRENT_BIT) );
GLCALL( glDisable(GL_CULL_FACE) );
if (m_bufferID==0)
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-12-24 21:28:19 UTC (rev 644)
+++ Mercury2/src/StateChanger.cpp 2009-12-28 22:26:28 UTC (rev 645)
@@ -35,7 +35,7 @@
void Activate()
{
- glColor4f( r,g,b,a );
+ GLCALL( glColor4f( r,g,b,a ) );
}
STATECHANGE_RTTI( ColorChange );
@@ -67,9 +67,13 @@
void Activate()
{
if( bEnable )
- glEnable( GL_LIGHTING );
+ {
+ GLCALL( glEnable( GL_LIGHTING ) );
+ }
else
- glDisable( GL_LIGHTING );
+ {
+ GLCALL( glDisable( GL_LIGHTING ) );
+ }
}
STATECHANGE_RTTI( LightingSwitch );
@@ -101,9 +105,13 @@
void Activate()
{
if( bEnable )
- glEnable( GL_DEPTH_TEST );
+ {
+ GLCALL( glEnable( GL_DEPTH_TEST ) );
+ }
else
- glDisable( GL_DEPTH_TEST );
+ {
+ GLCALL( glDisable( GL_DEPTH_TEST ) );
+ }
}
STATECHANGE_RTTI( DepthTest );
@@ -133,7 +141,7 @@
void Activate()
{
- glDepthMask( bEnable );
+ GLCALL( glDepthMask( bEnable ) );
}
STATECHANGE_RTTI( DepthWrite );
@@ -142,6 +150,58 @@
REGISTER_STATECHANGE( DepthWrite );
+class BlendFunc : public StateChange
+{
+public:
+ BlendFunc( const MVector< MString > & sParameters ) : StateChange( sParameters )
+ {
+ if( sParameters.size() < 2 )
+ {
+ LOG.Write( ssprintf( "Error: BlendFunc state has invalid number of parameters(%d).", sParameters.size() ) );
+ return;
+ }
+
+ m_src = StrToBlend(sParameters[0] );
+ m_dest = StrToBlend(sParameters[1] );
+ }
+
+ void Stringify( MString & sOut )
+ {
+ //XXX
+// sOut = ssprintf( "%f", bEnable );
+ }
+
+#define STRTOGL(x,s) if (x==#s) return GL_##s;
+ int StrToBlend(const MString& s)
+ {
+ STRTOGL(s, ZERO);
+ STRTOGL(s, ONE);
+ STRTOGL(s, SRC_COLOR);
+ STRTOGL(s, ONE_MINUS_SRC_COLOR);
+ STRTOGL(s, DST_COLOR);
+ STRTOGL(s, ONE_MINUS_DST_COLOR);
+ STRTOGL(s, SRC_ALPHA);
+ STRTOGL(s, ONE_MINUS_SRC_ALPHA);
+ STRTOGL(s, DST_ALPHA);
+ STRTOGL(s, ONE_MINUS_DST_ALPHA);
+ STRTOGL(s, CONSTANT_COLOR);
+ STRTOGL(s, ONE_MINUS_CONSTANT_COLOR);
+ STRTOGL(s, CONSTANT_ALPHA);
+ STRTOGL(s, ONE_MINUS_CONSTANT_ALPHA);
+ STRTOGL(s, SRC_ALPHA_SATURATE);
+ }
+
+ void Activate()
+ {
+ GLCALL( glBlendFunc(m_src,m_dest) );
+ }
+
+ STATECHANGE_RTTI( BlendFunc );
+ int m_src, m_dest;
+};
+
+REGISTER_STATECHANGE( BlendFunc );
+
//////////////////////////////////////STATE CHANGE CHUNK//////////////////////////////////////
StateChangeRegister & StateChangeRegister::Instance()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-10 22:13:50
|
Revision: 647
http://hgengine.svn.sourceforge.net/hgengine/?rev=647&view=rev
Author: cnlohr
Date: 2010-01-10 22:13:44 +0000 (Sun, 10 Jan 2010)
Log Message:
-----------
rename Delegate to MessageDelegate since we will have multiple types. Also, add a little bit to Cu2
Modified Paths:
--------------
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Mercury2/src/MercuryMessageManager.cpp
Mercury2/src/MercuryMessageManager.h
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/modules/Cu2.cpp 2010-01-10 22:13:44 UTC (rev 647)
@@ -558,7 +558,16 @@
}
}
+void Cu2Dialog::UpdateSize()
+{
+ if( m_pTitle )
+ {
+ m_pTitle->SetShiftY( GetH() - 18 );
+ m_pTitle->RenderText();
+ }
+}
+
REGISTER_NODE_TYPE(Cu2Dialog);
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/modules/Cu2.h 2010-01-10 22:13:44 UTC (rev 647)
@@ -45,6 +45,9 @@
///Called when a key is pressed - down the focus line.
virtual void GetKeypress( int key, bool bDown, bool bRepeat );
+ ///Called whenever the element is resized.
+ virtual void UpdateSize() { }
+
//Below here - you run into functions that are seldom overloaded.
///Handle updating of tab information
@@ -88,7 +91,7 @@
float GetY() { return m_fY; }
///Set Width/Height
- void SetSize( float fW, float fH ) { m_fW = fW; m_fH = fH; }
+ void SetSize( float fW, float fH ) { m_fW = fW; m_fH = fH; UpdateSize(); }
///Set Width
void SetW( float fW ) { m_fW = fW; }
///Set Height
@@ -185,6 +188,7 @@
virtual void Render( const MercuryMatrix& m );
virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton );
+ virtual void UpdateSize();
void SetText( const MString & sText );
Modified: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/src/MercuryMessageManager.cpp 2010-01-10 22:13:44 UTC (rev 647)
@@ -94,7 +94,7 @@
}
-void MercuryMessageManager::RegisterForMessage(const MString& message, MessageHandler* ptr, Delegate d )
+void MercuryMessageManager::RegisterForMessage(const MString& message, MessageHandler* ptr, MessageDelegate d )
{
MSemaphoreLock lock(&m_recipientLock);
m_messageRecipients[message].push_back(MessagePair(ptr, d));
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2009-12-29 15:52:06 UTC (rev 646)
+++ Mercury2/src/MercuryMessageManager.h 2010-01-10 22:13:44 UTC (rev 647)
@@ -24,7 +24,7 @@
static bool Compare( void * left, void * right );
};
-typedef void (MessageHandler::*Delegate)(const MessageData&);
+typedef void (MessageHandler::*MessageDelegate)(const MessageData&);
/* This message system uses absolute integer time values to fire off events.
This ensures accuarate firing times while eliminating floating point error.
@@ -44,7 +44,7 @@
void PumpMessages(const uint64_t& currTime);
- void RegisterForMessage(const MString& message, MessageHandler* ptr, Delegate d = 0 );
+ void RegisterForMessage(const MString& message, MessageHandler* ptr, MessageDelegate d = 0 );
void UnRegisterForMessage(const MString& message, MessageHandler* ptr);
static MercuryMessageManager& GetInstance();
@@ -57,9 +57,9 @@
struct MessagePair
{
- MessagePair( MessageHandler * th, Delegate td ) : h(th), d(td) { }
+ MessagePair( MessageHandler * th, MessageDelegate td ) : h(th), d(td) { }
MessageHandler * h;
- Delegate d;
+ MessageDelegate d;
};
MHash< std::list< MessagePair > > m_messageRecipients;
@@ -72,7 +72,7 @@
static InstanceCounter<MercuryMessageManager> MMcounter("MessageManager");
#define MESSAGEMAN MercuryMessageManager::GetInstance()
-#define REGISTER_MESSAGE_WITH_DELEGATE(x, d) MESSAGEMAN.RegisterForMessage(x, this, (Delegate)d)
+#define REGISTER_MESSAGE_WITH_DELEGATE(x, d) MESSAGEMAN.RegisterForMessage(x, this, (MessageDelegate)d)
#define REGISTER_FOR_MESSAGE(x) MESSAGEMAN.RegisterForMessage(x, this)
#define UNREGISTER_FOR_MESSAGE(x) MESSAGEMAN.UnRegisterForMessage(x, this)
#define POST_MESSAGE(x,data,delay) MESSAGEMAN.PostMessage(x, data, delay)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 08:01:28
|
Revision: 649
http://hgengine.svn.sourceforge.net/hgengine/?rev=649&view=rev
Author: cnlohr
Date: 2010-01-11 08:01:21 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
add the MercuryValue thing - kind of dirty at the moment, in process of cleaning up.
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/src/MercuryMessageManager.h
Added Paths:
-----------
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2010-01-10 22:27:01 UTC (rev 648)
+++ Mercury2/adv_set.c 2010-01-11 08:01:21 UTC (rev 649)
@@ -15,7 +15,7 @@
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDeferredLights.cpp \
src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp \
- src/MercurySound.cpp src/MercurySoundSourceRAM.cpp "
+ src/MercurySound.cpp src/MercurySoundSourceRAM.cpp src/MercuryValue.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2010-01-10 22:27:01 UTC (rev 648)
+++ Mercury2/src/MercuryMessageManager.h 2010-01-11 08:01:21 UTC (rev 649)
@@ -11,8 +11,8 @@
#include <MercuryUtil.h>
#include <Mint.h>
#include <MAutoPtr.h>
-
#include <MSemaphore.h>
+#include <MercuryValue.h>
class MessageHolder : public RefBase
{
Added: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp (rev 0)
+++ Mercury2/src/MercuryValue.cpp 2010-01-11 08:01:21 UTC (rev 649)
@@ -0,0 +1,115 @@
+#include <MercuryMessageManager.h>
+#include <MercuryValue.h>
+#include <MessageHandler.h>
+
+
+DelegateNotifierList::DelegateNotifierList( DeletionNotifier nf, MessageHandler * no ) :
+ NotifyFunction( nf ), NotifyObject( no ), Next( 0 )
+{
+}
+
+DelegateNotifierList::~DelegateNotifierList()
+{
+ SAFE_DELETE( Next );
+}
+
+void DelegateNotifierList::AddNotifier( DeletionNotifier nf, MessageHandler * no )
+{
+ DelegateNotifierList * nn = new DelegateNotifierList( nf, no );
+ nn->Next = Next;
+ Next = nn;
+}
+
+void DelegateNotifierList::DelNotifier( DeletionNotifier nf, MessageHandler * no, DelegateNotifierList * & ths )
+{
+ if( nf == NotifyFunction && no == NotifyObject )
+ {
+ ths = Next;
+ delete this;
+ return;
+ }
+ if( Next )
+ Next->DelNotifier( nf, no, Next );
+}
+
+void DelegateNotifierList::Notify( MValue * v )
+{
+ (NotifyObject->*NotifyFunction)( v );
+ if( Next )
+ Next->Notify( v );
+}
+
+
+
+
+
+
+MValue::MValue( MVType t ) : m_References( 0 ), m_CurType( t ), DLDelete( 0 ), DLModify( 0 )
+{
+ m_Data.v = 0;
+}
+
+MValue::~MValue()
+{
+ Cleanup();
+ SAFE_DELETE( DLModify );
+ SAFE_DELETE( DLDelete );
+}
+
+void MValue::Cleanup()
+{
+ if( DLDelete )
+ DLDelete->Notify( this );
+ SAFE_DELETE( DLDelete );
+
+ if( m_CurType == TYPE_STRING )
+ SAFE_DELETE( m_Data.dataS );
+}
+
+int MValue::ConvInt()
+{
+ switch( m_CurType )
+ {
+ case TYPE_INT: return m_Data.l;
+ case TYPE_FLOAT: return m_Data.f;
+ case TYPE_STRING: return StrToInt(*m_Data.dataS);
+ default: return 0;
+ }
+}
+
+float MValue::ConvFloat()
+{
+ switch( m_CurType )
+ {
+ case TYPE_INT: return m_Data.l;
+ case TYPE_FLOAT: return m_Data.f;
+ case TYPE_STRING: return StrToFloat(*m_Data.dataS);
+ default: return 0;
+ }
+}
+
+
+const MString & MValue::ConvString()
+{
+ static const MString NILVAL = "(NIL)";
+ switch( m_CurType )
+ {
+ case TYPE_STRING: return *m_Data.dataS;
+ case TYPE_INT: ssprintf( "%d", m_Data.l );
+ case TYPE_FLOAT: ssprintf( "%f", m_Data.f );
+ case TYPE_PTR: ssprintf( "%p", m_Data.v );
+ default: return NILVAL;
+ }
+}
+
+bool MValue::ConvBool()
+{
+ switch( m_CurType )
+ {
+ case TYPE_INT: return m_Data.l != 0;
+ case TYPE_FLOAT: return m_Data.f != 0;
+ case TYPE_STRING: return StrToBool(*m_Data.dataS);
+ default: return 0;
+ }
+}
+
Added: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h (rev 0)
+++ Mercury2/src/MercuryValue.h 2010-01-11 08:01:21 UTC (rev 649)
@@ -0,0 +1,210 @@
+#ifndef _MERCURY_VALUE_H
+#define _MERCURY_VALUE_H
+
+#include <MSemaphore.h>
+
+///Types for the values
+enum MVType
+{
+ TYPE_UNDEF = 0,
+ TYPE_STRING,
+ TYPE_INT,
+ TYPE_FLOAT,
+ TYPE_PTR,
+};
+
+class MValue;
+
+///Delegate for changes to MValues
+typedef void (MessageHandler::*ValueDelegate)( MValue * );
+
+///Delegate to notify an object that it should delete itself
+typedef void (MessageHandler::*DeletionNotifier)( MValue * );
+
+///Delegate List Notifier. This contains a list of delegates to get called back when an event happens.
+class DelegateNotifierList
+{
+public:
+ DelegateNotifierList( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
+ ~DelegateNotifierList();
+
+ void AddNotifier( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
+ void DelNotifier( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject, DelegateNotifierList * & ths );
+ void Notify( MValue * v );
+
+ DeletionNotifier NotifyFunction;
+ MessageHandler * NotifyObject;
+ DelegateNotifierList * Next;
+};
+
+///Variable for general purpose use - generally global scope or passed around. Similar to PSElement.
+/** You usually don't want to make and delete a lot of these. It's best to keep them around and use references. */
+class MValue
+{
+public:
+
+ MValue( MVType t );
+ ~MValue();
+
+ int GetInt() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvInt(); }
+ float GetFloat() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_FLOAT)?m_Data.f:ConvFloat(); }
+ const MString & GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
+ bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvBool(); }
+ void * GetPtr() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_PTR)?m_Data.v:0; }
+
+ void SetInt( int iv ) { MSemaphoreLock( &this->m_Sema ); Cleanup(); m_Data.l = iv; m_CurType = TYPE_INT; Notify();}
+ void SetFloat( float iv ) { MSemaphoreLock( &this->m_Sema ); Cleanup(); m_Data.f = iv; m_CurType = TYPE_FLOAT; Notify(); }
+ void SetString( const MString & iv )
+ {
+ MSemaphoreLock( &this->m_Sema );
+ if( m_CurType != TYPE_STRING )
+ {
+ Cleanup();
+ m_Data.dataS = new MString( iv );
+ m_CurType = TYPE_STRING;
+ }
+ else
+ (*m_Data.dataS) = iv;
+ Notify();
+ }
+ void SetBool( bool iv ){ MSemaphoreLock( &this->m_Sema ); m_Data.l = iv; m_CurType = TYPE_INT; Notify(); }
+ void SetPtr( void * ptr, DelegateNotifierList * dl )
+ {
+ MSemaphoreLock( &this->m_Sema );
+ Cleanup();
+ SAFE_DELETE( DLDelete );
+ DLDelete = dl;
+ m_CurType = TYPE_PTR;
+ m_Data.v = ptr;
+ Notify();
+ }
+
+ MVType GetType() { return m_CurType; }
+private:
+ //Conv functions are not thread protected - this is because the caller of these functions should be.
+ int ConvInt();
+ float ConvFloat();
+ const MString & ConvString();
+ bool ConvBool();
+
+ //Cleanup (to be done when object is deleted or switching types)
+ void Cleanup();
+
+ //A change happened.
+ void Notify() { if( DLModify ) DLModify->Notify( this ); }
+
+ unsigned short m_References;
+ MVType m_CurType : 8;
+
+ union ParmData
+ {
+ float f;
+ int l;
+ void * v;
+ MString * dataS;
+ } m_Data;
+
+ //XXX: Performance warning: One could simply operate on these
+ //values atomically. A full extra semaphore isn't necessairly
+ //needed for everything
+ MSemaphore m_Sema;
+
+
+ DelegateNotifierList * DLDelete;
+ DelegateNotifierList * DLModify;
+
+ friend class MVRefBase;
+};
+
+//Sadly for a number of reasons, these cannot be templated or macro'd... Well, macro'd cleanly.
+
+///Reference base - don't use this.
+/** Be sure not to let anything here become virtual otherwise there will be a slow down potentially. */
+class MVRefBase
+{
+public:
+ MVRefBase(MValue * m) : mv(m) { MSemaphoreLock( &mv->m_Sema ); mv->m_References++; }
+ MVRefBase(const MString & sPath); //Special - get values from MESSAGEMAN
+ ~MVRefBase() {
+ //If out of references, bail.
+ mv->m_Sema.Wait();
+ mv->m_References--;
+ if( mv->m_References <= 0 )
+ {
+ delete mv;
+ return;
+ }
+ mv->m_Sema.UnLock();
+ }
+protected:
+ MValue * mv;
+};
+
+///Value Reference for Int objects.
+class MVRefInt : public MVRefBase
+{
+public:
+ int Get() { return mv->GetInt(); }
+ void Set( int iv ) { mv->SetInt( iv ); }
+};
+
+///Value Reference for Float objects.
+class MVRefFloat : public MVRefBase
+{
+public:
+ float Get() { return mv->GetFloat(); }
+ void Set( float fv ) { mv->SetFloat( fv ); }
+};
+
+///Value Reference for Float objects.
+class MVRefString : public MVRefBase
+{
+public:
+ const MString & Get() { return mv->GetString(); }
+ void Set( const MString & sv ) { mv->SetString( sv ); }
+};
+
+template< typename T >
+class MVRefPtr : public MVRefBase
+{
+public:
+ T * Get() {
+ return (T*)mv->GetPtr();
+ }
+ void Set( T* iv, DelegateNotifierList * del = 0 ) { mv->SetPtr( iv, del ); }
+};
+
+#endif
+
+
+/****************************************************************************
+ * Copyright (C) 2010 by Charles Lohr *
+ * *
+ * *
+ * 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: <cn...@us...> - 2010-01-11 19:24:36
|
Revision: 651
http://hgengine.svn.sourceforge.net/hgengine/?rev=651&view=rev
Author: cnlohr
Date: 2010-01-11 19:24:25 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
transition to values for all things that really should be using. I don't think anything else should be transitioned... ever. But, this does finally open the door to making Cu2 pretty serious.
Modified Paths:
--------------
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Mercury2/src/Camera.cpp
Mercury2/src/Camera.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryInput.cpp
Mercury2/src/MercuryValue.h
Mercury2/src/MercuryWindow.cpp
Mercury2/src/MercuryWindow.h
Mercury2/src/X11Window.cpp
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/modules/Cu2.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -241,6 +241,9 @@
///////////////////////////////////////COPPER 2 ROOT///////////////////////////////////////
+
+MVRefBool Cu2Root::CursorGrabbed( "Input.CursorGrabbed" );
+
Cu2Root::Cu2Root()
{
g_pCurrentInstance = this;
@@ -255,15 +258,14 @@
void Cu2Root::SetHidden( bool bHide )
{
- MercuryWindow::GetCurrentWindow()->SetGrabbedMouseMode( bHide );
-
+ CursorGrabbed.Set( bHide );
MercuryNode::SetHidden( bHide );
}
void Cu2Root::LoadFromXML(const XMLNode& node)
{
Cu2Element::LoadFromXML( node );
- MercuryWindow::GetCurrentWindow()->SetGrabbedMouseMode( IsHidden() );
+ CursorGrabbed.Set( IsHidden() );
}
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/modules/Cu2.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -2,6 +2,7 @@
#define _CU2_H
#include <TransformNode.h>
+#include <MercuryValue.h>
///All the mouse actions Cu2 can transmit.
enum Cu2Action
@@ -133,6 +134,8 @@
void HandleMouseInput(const MessageData& data);
void HandleKeyboardInput(const MessageData& data);
+ static MVRefBool CursorGrabbed;
+
GENRTTI( Cu2Root );
private:
static Cu2Root * g_pCurrentInstance;
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/Camera.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -5,6 +5,8 @@
#include <Shader.h>
+MVRefBool CameraNode::CursorGrabbed( "Input.CursorGrabbed" );
+
REGISTER_NODE_TYPE(CameraNode);
CameraNode::CameraNode()
@@ -82,7 +84,11 @@
void CameraNode::HandleMouseInput(const MessageData& data)
{
const MouseInput& m( dynamic_cast<const MouseInput&>( data ) );
-
+
+ //First find out if cursor is grabbed. If it isn't then we shouldn't be responding to the input.
+ if( !CursorGrabbed.Get() )
+ return;
+
m_y += m.dy/1200.0f;
m_x += m.dx/1200.0f;
Modified: Mercury2/src/Camera.h
===================================================================
--- Mercury2/src/Camera.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/Camera.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -2,6 +2,7 @@
#define CAMERA_H
#include <TransformNode.h>
+#include <MercuryValue.h>
#include <MQuaternion.h>
class CameraNode : public TransformNode
@@ -19,6 +20,8 @@
GENRTTI(CameraNode);
private:
+ static MVRefBool CursorGrabbed;
+
MercuryVertex m_origionalPosition;
MercuryVector m_lookAt;
float m_x, m_y;
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/Mercury2.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -211,12 +211,12 @@
public:
TestMouse()
{
- MESSAGEMAN.GetValue( "Input.CursorDeltaX" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
+ MESSAGEMAN.GetValue( "Input.CursorGrabbed" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
}
void ChangeX( MValue * v )
{
- printf( "Changed: %f\n", v->GetFloat() );
+ printf( "Changed: %d\n", v->GetBool() );
}
} TM;
///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
Modified: Mercury2/src/MercuryInput.cpp
===================================================================
--- Mercury2/src/MercuryInput.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryInput.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -1,8 +1,9 @@
#include <MercuryInput.h>
#include <MercuryMessageManager.h>
-MVRefFloat GlobalMouseX_Set( "Input.CursorDeltaX" );
-MVRefFloat GlobalMouseY_Set( "Input.CursorDeltaY" );
+MVRefFloat GlobalMouseX_Set( "Input.CursorX" );
+MVRefFloat GlobalMouseY_Set( "Input.CursorY" );
+MVRefInt GlobalMouseB_Set( "Input.CursorButtons" );
MouseInput::MouseInput()
:MessageData(), dx(0), dy(0)
@@ -26,6 +27,7 @@
GlobalMouseX_Set.Set( dx );
GlobalMouseY_Set.Set( dy );
+ GlobalMouseB_Set.Set( currentButtonMasks.data );
POST_MESSAGE( INPUTEVENT_MOUSE, mi, 0 );
}
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryValue.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -3,6 +3,8 @@
#include <MSemaphore.h>
+class MessageHandler;
+
///Types for the values
enum MVType
{
@@ -160,6 +162,17 @@
void Set( int iv ) { mv->SetInt( iv ); }
};
+///Value Reference for Bool objects.
+class MVRefBool : public MVRefBase
+{
+public:
+ MVRefBool( MValue * m ) : MVRefBase( m ) { }
+ MVRefBool( const MString & p ) : MVRefBase( p ) { }
+
+ int Get() { return mv->GetBool(); }
+ void Set( int iv ) { mv->SetBool( iv ); }
+};
+
///Value Reference for Float objects.
class MVRefFloat : public MVRefBase
{
Modified: Mercury2/src/MercuryWindow.cpp
===================================================================
--- Mercury2/src/MercuryWindow.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryWindow.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -1,9 +1,11 @@
#include "MercuryWindow.h"
+#include "MercuryMessageManager.h"
MercuryWindow::MercuryWindow(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen)
:m_title(title), m_width(width), m_height(height), m_bits(bits), m_depthBits(depthBits), m_fullscreen(fullscreen),
- m_bGrabbed(true),m_iLastMouseX(0),m_iLastMouseY(0),m_inFocus(false)
+ m_iLastMouseX(0),m_iLastMouseY(0),m_inFocus(false)
{
+ MESSAGEMAN.GetValue( "Input.CursorGrabbed" )->SetBool( true );
}
MercuryWindow::~MercuryWindow()
Modified: Mercury2/src/MercuryWindow.h
===================================================================
--- Mercury2/src/MercuryWindow.h 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/MercuryWindow.h 2010-01-11 19:24:25 UTC (rev 651)
@@ -32,9 +32,6 @@
inline int Width() const { return m_width; }
inline int Height() const { return m_height; }
- void SetGrabbedMouseMode( bool bGrabbed ) { m_bGrabbed = bGrabbed; }
- bool GetGrabbedMouseMode( ) { return m_bGrabbed; }
-
inline bool InFocus() const { return m_inFocus; }
protected:
@@ -45,7 +42,6 @@
int m_width, m_height;
uint8_t m_bits, m_depthBits;
bool m_fullscreen;
- bool m_bGrabbed;
int m_iLastMouseX;
int m_iLastMouseY;
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2010-01-11 08:43:17 UTC (rev 650)
+++ Mercury2/src/X11Window.cpp 2010-01-11 19:24:25 UTC (rev 651)
@@ -11,6 +11,8 @@
#define MOUSE_BTN_SCROLL_UP 4
#define MOUSE_BTN_SCROLL_DOWN 5
+MVRefBool GlobalMouseGrabbed_Set( "Input.CursorGrabbed" );
+
// Use X11_MASK(MOUSE_BTN_SCROLL_UP) to generate the token Button4Mask
#define X11_MASK(x) _X11_MASK(x)
// Sigh... second #define needed, because otherwise x doesn't get evaluated.
@@ -266,7 +268,7 @@
{
//XFocusChangeEvent*e = (XFocusChangeEvent*)&event;
m_inFocus = (event.type == FocusIn);
- if (m_inFocus && m_bGrabbed ) XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2);
+ if (m_inFocus && GlobalMouseGrabbed_Set.Get() ) XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2);
break;
}
}
@@ -317,7 +319,7 @@
center = e->state & X11_MASK(MOUSE_BTN_CENTER);
su = e->state & X11_MASK(MOUSE_BTN_SCROLL_UP);
sd = e->state & X11_MASK(MOUSE_BTN_SCROLL_DOWN);
- if( m_bGrabbed )
+ if( GlobalMouseGrabbed_Set.Get() )
{
x = m_width/2 - e->x;
y = m_height/2 - e->y;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-01-11 20:21:56
|
Revision: 652
http://hgengine.svn.sourceforge.net/hgengine/?rev=652&view=rev
Author: cnlohr
Date: 2010-01-11 20:21:50 +0000 (Mon, 11 Jan 2010)
Log Message:
-----------
better support for values
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/Themes/default/File/scenegraph.xml 2010-01-11 20:21:50 UTC (rev 652)
@@ -72,7 +72,9 @@
<node type="Cu2Root" width="640" height="480" hidden="true" >
<node type="Cu2Button" text="hello" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="450" name="Button" />
<node type="Cu2Dialog" text="T00" font="FONT:FreeSans.hgfont" size=".25" x="200" y="40" name="Dialog" >
- <node type="Cu2Button" text="hel0" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="40" />
+ <node type="Cu2Button" text="A" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="32" y="40" associatedValue="TestMode" associatedValueSet="A" />
+ <node type="Cu2Button" text="B" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="40" associatedValue="TestMode" associatedValueSet="B"/>
+ <node type="Cu2Label" text="[nil]" font="FONT:FreeSans.hgfont" size=".25" alignment="CENTER" x="10" y="10" associatedValue="TestMode" />
</node>
</node>
</node>
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/modules/Cu2.cpp 2010-01-11 20:21:50 UTC (rev 652)
@@ -324,6 +324,8 @@
LOAD_FROM_XML( "text", m_sText, );
LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool );
LOAD_FROM_XML( "clickPayload", m_sValueToSend, );
+ LOAD_FROM_XML( "associatedValue", m_sAssociatedValue, );
+ LOAD_FROM_XML( "associatedValueSet", m_sAssociatedValueSet, );
if( m_pText )
{
@@ -346,6 +348,8 @@
if( m_sMessageToSend.length() ) sXMLStream += ssprintf( "clickMessage=\"%s\" ", m_sMessageToSend.c_str() );
if( m_sValueToSend.length() ) sXMLStream += ssprintf( "clickPayload=\"%s\" ", m_sValueToSend.c_str() );
if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize );
+ if( m_sAssociatedValue.length() ) sXMLStream += ssprintf( "associatedValue=\"%s\" ", m_sAssociatedValue.c_str() );
+ if( m_sAssociatedValueSet.length() ) sXMLStream += ssprintf( "associatedValueSet=\"%s\" ", m_sAssociatedValueSet.c_str() );
if( !m_pText )
m_pText->SaveToXMLTag( sXMLStream );
@@ -391,6 +395,9 @@
void Cu2Button::Click( int x, int y )
{
+ if( m_sAssociatedValue.length() )
+ MESSAGEMAN.GetValue( m_sAssociatedValue )->SetString( m_sAssociatedValueSet );
+
if( m_sMessageToSend.length() )
MESSAGEMAN.BroadcastMessage( m_sMessageToSend, new PointerDataMessage( this ) );
}
@@ -438,6 +445,90 @@
REGISTER_NODE_TYPE(Cu2Button);
+///////////////////////////////////////COPPER 2 LABEL///////////////////////////////////////
+
+Cu2Label::Cu2Label() : Cu2Element()
+{
+ m_pText = (TextNode*)NODEFACTORY.Generate( "TextNode" );
+ AddChild( m_pText );
+ m_bAutoSize = true;
+ m_bDown = false;
+}
+
+Cu2Label::~Cu2Label()
+{
+ if( m_sAssociatedValue.length() )
+ MESSAGEMAN.GetValue( m_sAssociatedValue )->DetachModifyDelegate( (ValueDelegate)&Cu2Label::ChangeValue, this );
+}
+
+void Cu2Label::LoadFromXML(const XMLNode& node)
+{
+ LOAD_FROM_XML( "associatedValue", m_sAssociatedValue, );
+ if( m_sAssociatedValue.length() )
+ {
+ MESSAGEMAN.GetValue( m_sAssociatedValue )->AttachModifyDelegate( (ValueDelegate)&Cu2Label::ChangeValue, this );
+ printf( "Associating Value: %s\n", m_sAssociatedValue.c_str() );
+ }
+
+ LOAD_FROM_XML( "text", m_sText, );
+ LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool );
+
+ if( m_pText )
+ {
+ m_pText->SetAlignment( TextNode::LEFT );
+ m_pText->LoadFont( node.Attribute("font") );
+ m_pText->SetSize( StrToFloat( node.Attribute("size") ) );
+ SetText( m_sText );
+ m_pText->SetShiftAbsolute( true );
+ m_pText->SetShiftX( 5 );
+ m_pText->SetShiftY( 5 );
+ }
+
+ Cu2Element::LoadFromXML( node );
+
+ Refresh();
+}
+
+void Cu2Label::SaveToXMLTag( MString & sXMLStream )
+{
+ if( m_sAssociatedValue.length() ) sXMLStream += ssprintf( "m_sAssociatedValue=\"%s\" ", m_sAssociatedValue.c_str() );
+ if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize );
+
+ if( !m_pText )
+ m_pText->SaveToXMLTag( sXMLStream );
+
+ Cu2Element::SaveToXMLTag( sXMLStream );
+}
+void Cu2Label::Refresh()
+{
+ if( !m_pText )
+ {
+ LOG.Write( "Warning: Cu2Button \"" + GetName() + "\" does not have valid Text box associated." );
+ return;
+ }
+
+ m_pText->SetText( m_sText );
+ m_pText->RenderText();
+
+ if( m_bAutoSize )
+ {
+ SetSize( m_pText->GetRMaxX() + 8, m_pText->GetRMaxY() + 8 );
+ }
+}
+
+void Cu2Label::Render( const MercuryMatrix& m )
+{
+ TransformNode::Render( m );
+}
+
+void Cu2Label::ChangeValue( MValue * v )
+{
+ m_sText = v->GetString();
+ Refresh();
+}
+
+REGISTER_NODE_TYPE(Cu2Label);
+
///////////////////////////////////////COPPER 2 DIALOG///////////////////////////////////////
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/modules/Cu2.h 2010-01-11 20:21:50 UTC (rev 652)
@@ -170,6 +170,9 @@
GENRTTI( Cu2Button );
private:
+ MString m_sAssociatedValue;
+ MString m_sAssociatedValueSet;
+
MString m_sMessageToSend;
MString m_sValueToSend;
MString m_sText;
@@ -178,6 +181,39 @@
TextNode * m_pText;
};
+///Standard label (doesn't do anything but display something)
+class Cu2Label : public Cu2Element
+{
+public:
+ Cu2Label();
+ ~Cu2Label();
+
+ virtual void LoadFromXML(const XMLNode& node);
+ virtual void SaveToXMLTag( MString & sXMLStream );
+
+ virtual void Render( const MercuryMatrix& m );
+
+ void SetText( const MString & sText ) { m_sText = sText; Refresh(); }
+ void SetAutoSize( bool bAutoSize ) { m_bAutoSize = bAutoSize; Refresh(); }
+ void Refresh();
+
+ MString & Payload() { return m_sValueToSend; }
+ TextNode * GetTextNodeHandle() { return m_pText; }
+
+ void ChangeValue( MValue * v );
+
+ GENRTTI( Cu2Button );
+private:
+ MString m_sAssociatedValue;
+ MString m_sMessageToSend;
+ MString m_sValueToSend;
+ MString m_sText;
+ bool m_bAutoSize;
+ bool m_bDown;
+ TextNode * m_pText;
+};
+
+///Dialog box (for putting other things into and being able to drag around)
class Cu2Dialog : public Cu2Element
{
public:
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/src/Mercury2.cpp 2010-01-11 20:21:50 UTC (rev 652)
@@ -211,12 +211,12 @@
public:
TestMouse()
{
- MESSAGEMAN.GetValue( "Input.CursorGrabbed" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
+ MESSAGEMAN.GetValue( "TestMode" )->AttachModifyDelegate( (ValueDelegate)&TestMouse::ChangeX, (MessageHandler*)this );
}
void ChangeX( MValue * v )
{
- printf( "Changed: %d\n", v->GetBool() );
+ printf( "Changed: %s\n", v->GetString().c_str() );
}
} TM;
///XXXXXXX REMOVE THIS CODE BEFORE ANY RELEASE XXXXXXXXXXx
Modified: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/src/MercuryValue.cpp 2010-01-11 20:21:50 UTC (rev 652)
@@ -93,19 +93,31 @@
}
-const MString & MValue::ConvString()
+const MString MValue::ConvString()
{
- static const MString NILVAL = "(NIL)";
switch( m_CurType )
{
case TYPE_STRING: return *m_Data.dataS;
- case TYPE_INT: ssprintf( "%d", m_Data.l );
- case TYPE_FLOAT: ssprintf( "%f", m_Data.f );
- case TYPE_PTR: ssprintf( "%p", m_Data.v );
- default: return NILVAL;
+ case TYPE_INT: return ssprintf( "%d", m_Data.l );
+ case TYPE_FLOAT: return ssprintf( "%.2f", m_Data.f );
+ case TYPE_PTR: return ssprintf( "%p", m_Data.v );
+ default: return "(NIL)";
}
}
+void MValue::ConvString( MString & ret )
+{
+ switch( m_CurType )
+ {
+ case TYPE_STRING: ret = *m_Data.dataS;
+ case TYPE_INT: ret = ssprintf( "%d", m_Data.l );
+ case TYPE_FLOAT: ret = ssprintf( "%.2f", m_Data.f );
+ case TYPE_PTR: ret = ssprintf( "%p", m_Data.v );
+ default: ret = "(NIL)";
+ }
+}
+
+
bool MValue::ConvBool()
{
switch( m_CurType )
@@ -117,6 +129,22 @@
}
}
+
+
+void MValue::AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
+{
+ DelegateNotifierList * d = new DelegateNotifierList( NotifyFunction, NotifyObject );
+ d->Next = DLModify;
+ DLModify = d;
+}
+
+void MValue::DetachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
+{
+ DLModify->DelNotifier( NotifyFunction, NotifyObject, DLModify );
+}
+
+
+
MVRefBase::MVRefBase(const MString & sPath)
{
mv = MESSAGEMAN.GetValue( sPath );
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-11 19:24:25 UTC (rev 651)
+++ Mercury2/src/MercuryValue.h 2010-01-11 20:21:50 UTC (rev 652)
@@ -50,7 +50,8 @@
int GetInt() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvInt(); }
float GetFloat() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_FLOAT)?m_Data.f:ConvFloat(); }
- const MString & GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
+ const MString GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
+ void GetString( MString & str ) { MSemaphoreLock( &this->m_Sema ); if (m_CurType == TYPE_STRING) str = *m_Data.dataS; else ConvString( str ); }
bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvBool(); }
void * GetPtr() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_PTR)?m_Data.v:0; }
@@ -83,19 +84,15 @@
MVType GetType() { return m_CurType; }
- void AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject )
- {
- DelegateNotifierList * d = new DelegateNotifierList( NotifyFunction, NotifyObject );
- d->Next = DLModify;
- DLModify = d;
- }
-
+ void AttachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
+ void DetachModifyDelegate( DeletionNotifier NotifyFunction, MessageHandler * NotifyObject );
void SetReferences( short RefCount ) { m_References = RefCount; }
private:
//Conv functions are not thread protected - this is because the caller of these functions should be.
int ConvInt();
float ConvFloat();
- const MString & ConvString();
+ const MString ConvString();
+ void ConvString( MString & ret );
bool ConvBool();
//Cleanup (to be done when object is deleted or switching types)
@@ -191,7 +188,7 @@
MVRefString( MValue * m ) : MVRefBase( m ) { }
MVRefString( const MString & p ) : MVRefBase( p ) { }
- const MString & Get() { return mv->GetString(); }
+ const MString Get() { return mv->GetString(); }
void Set( const MString & sv ) { mv->SetString( sv ); }
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-01-14 21:31:21
|
Revision: 659
http://hgengine.svn.sourceforge.net/hgengine/?rev=659&view=rev
Author: axlecrusher
Date: 2010-01-14 21:30:42 +0000 (Thu, 14 Jan 2010)
Log Message:
-----------
fix warnings
Modified Paths:
--------------
Mercury2/Mercury2.vcproj
Mercury2/src/MercuryValue.cpp
Mercury2/src/MercuryValue.h
Modified: Mercury2/Mercury2.vcproj
===================================================================
--- Mercury2/Mercury2.vcproj 2010-01-14 19:36:39 UTC (rev 658)
+++ Mercury2/Mercury2.vcproj 2010-01-14 21:30:42 UTC (rev 659)
@@ -480,6 +480,14 @@
>
</File>
<File
+ RelativePath=".\src\MercuryValue.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\src\MercuryValue.h"
+ >
+ </File>
+ <File
RelativePath=".\src\MercuryVBO.cpp"
>
</File>
Modified: Mercury2/src/MercuryValue.cpp
===================================================================
--- Mercury2/src/MercuryValue.cpp 2010-01-14 19:36:39 UTC (rev 658)
+++ Mercury2/src/MercuryValue.cpp 2010-01-14 21:30:42 UTC (rev 659)
@@ -74,7 +74,7 @@
{
switch( m_CurType )
{
- case TYPE_INT: return m_Data.l;
+ case TYPE_INT: return (int)m_Data.l;
case TYPE_FLOAT: return m_Data.f;
case TYPE_STRING: return StrToInt(*m_Data.dataS);
default: return 0;
@@ -85,7 +85,7 @@
{
switch( m_CurType )
{
- case TYPE_INT: return m_Data.l;
+ case TYPE_INT: return (float)m_Data.l;
case TYPE_FLOAT: return m_Data.f;
case TYPE_STRING: return StrToFloat(*m_Data.dataS);
default: return 0;
Modified: Mercury2/src/MercuryValue.h
===================================================================
--- Mercury2/src/MercuryValue.h 2010-01-14 19:36:39 UTC (rev 658)
+++ Mercury2/src/MercuryValue.h 2010-01-14 21:30:42 UTC (rev 659)
@@ -52,7 +52,7 @@
float GetFloat() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_FLOAT)?m_Data.f:ConvFloat(); }
const MString GetString() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_STRING)?*m_Data.dataS:ConvString(); }
void GetString( MString & str ) { MSemaphoreLock( &this->m_Sema ); if (m_CurType == TYPE_STRING) str = *m_Data.dataS; else ConvString( str ); }
- bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l:ConvBool(); }
+ bool GetBool() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_INT)?m_Data.l!=0:ConvBool(); }
void * GetPtr() { MSemaphoreLock( &this->m_Sema ); return (m_CurType == TYPE_PTR)?m_Data.v:0; }
void SetInt( int iv ) { MSemaphoreLock( &this->m_Sema ); Cleanup(); m_Data.l = iv; m_CurType = TYPE_INT; Notify();}
@@ -167,7 +167,7 @@
MVRefBool( const MString & p ) : MVRefBase( p ) { }
int Get() { return mv->GetBool(); }
- void Set( int iv ) { mv->SetBool( iv ); }
+ void Set( int iv ) { mv->SetBool( iv!=0 ); }
};
///Value Reference for Float objects.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-02-23 08:44:30
|
Revision: 676
http://hgengine.svn.sourceforge.net/hgengine/?rev=676&view=rev
Author: cnlohr
Date: 2010-02-23 08:44:24 +0000 (Tue, 23 Feb 2010)
Log Message:
-----------
Wooh! Fix up cleaning up after messages, get some of the C-rays working.
Modified Paths:
--------------
Mercury2/Themes/default/File/ssvgr.xml
Mercury2/modules/Makefile
Mercury2/modules.xml
Mercury2/src/Camera.cpp
Mercury2/src/Camera.h
Mercury2/src/MercuryMessageManager.h
Mercury2/src/Texture.cpp
Modified: Mercury2/Themes/default/File/ssvgr.xml
===================================================================
--- Mercury2/Themes/default/File/ssvgr.xml 2010-02-23 07:39:14 UTC (rev 675)
+++ Mercury2/Themes/default/File/ssvgr.xml 2010-02-23 08:44:24 UTC (rev 676)
@@ -1,34 +1,42 @@
-<SceneGraph name="root" setPasses="6+7" >
+<SceneGraph name="root" setPasses="5+6+7" >
<!--We have to put all states that are the generic state up here. This way, the states will fall back to these -->
<asset type="StateChanger" file="ColorChange:1,1,1,1"/>
- <asset type="StateChanger" file="DepthTest:1"/>
+ <asset type="StateChanger" file="DepthTest:1" setPasses="5+6+7" />
<asset type="StateChanger" file="LightingSwitch:0" enduring="1" />
- <asset type="StateChanger" file="DepthWrite:1"/>
+ <asset type="StateChanger" file="DepthWrite:1" setPasses="5+6+7" />
<asset type="StateChanger" file="FaceCulling:none"/>
<asset type="StateChanger" file="BlendFunc:SRC_ALPHA,ONE_MINUS_SRC_ALPHA" />
<asset type="StateChanger" file="AlphaFunc:GREATER,0.5" /> <!-- makes alpha ordering not matter, since it's all or nothing -->
- <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp" >
+ <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp" setPasses="5+6+7" >
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera" >
- <node fallback="root.ground" setPasses="7" />
- <node type="transformnode" movy="2" >
- <node fallback="root.lampForest" setPasses="6" />
+ <node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="FBOA" colorbyte0="RGBA" usescreensize="true" setPasses="5" >
+ <node fallback="root.lampForest" setPasses="5" />
</node>
- <node type="transformnode" movy="0" >
- <node fallback="root.lampForest" setPasses="7" />
- </node>
- <node type="transformnode" movz="-5" >
- <asset type="texture" file="GRAPHIC:2by.png" filter="none" />
- <asset type="quad" />
+ <node type="mercuryfbo" width="640" height="480" depth="true" tnum="1" name="FBOB" colorbyte0="RGBA" usescreensize="true" setPasses="6" >
+ <node fallback="root.skybox" setPasses="6" />
+ <node fallback="root.ground" setPasses="6" />
+ <node fallback="root.lampForest" setPasses="6" />
</node>
+ </node>
+ </node>
+
+
+ <node type="orthographic" left="-.5" right=".5" top=".5" bottom="-.5" near="1" far="-1" name="Ortho" setPasses="7" >
+ <asset type="StateChanger" file="LightingSwitch:0"/>
+ <asset type="StateChanger" file="DepthTest:0"/>
+ <asset type="shader" file="GRAPHIC:Crepuscular"/>
+ <node type="transformnode" >
+ <asset type="texture" file="FBOB_0" dynamic="true"/>
+ <asset type="texture" file="FBOA_0" dynamic="true"/>
+ <asset type="quad" />
</node>
</node>
-
<!-- Below here is just a library for some junk we can throw in -->
<node type="mercurynode" name="lampForest" setPasses="0" >
@@ -58,4 +66,35 @@
<asset type="terrain" file="MODEL:map.hgmdl" />
</node>
+ <node type="Skybox" name="skybox" setPasses="0" >
+ <asset type="StateChanger" file="DepthTest:0"/>
+ <asset type="StateChanger" file="LightingSwitch:0" />
+ <asset type="StateChanger" file="DepthWrite:0"/>
+
+ <node type="transformnode" movx=".5" rotx="-180" roty="-270" >
+ <asset type="texture" file="MODEL:Skybox/neg_x.png" />
+ <asset type="quad" />
+ </node>
+ <node type="transformnode" movy="-.5" rotx="-90" rotz="270" scaley="-1" >
+ <asset type="texture" file="MODEL:Skybox/neg_y.png" />
+ <asset type="quad" />
+ </node>
+ <node type="transformnode" movz="-.5" rotx="-180" >
+ <asset type="texture" file="MODEL:Skybox/neg_z.png" />
+ <asset type="quad" />
+ </node>
+ <node type="transformnode" movx="-.5" rotx="-180" roty="-270" scalex="-1" >
+ <asset type="texture" file="MODEL:Skybox/pos_x.png" />
+ <asset type="quad" />
+ </node>
+ <node type="transformnode" movy=".5" rotx="-90" rotz="270" >
+ <asset type="texture" file="MODEL:Skybox/pos_y.png" />
+ <asset type="quad" />
+ </node>
+ <node type="transformnode" movz=".5" rotx="-180" scalex="-1" >
+ <asset type="texture" file="MODEL:Skybox/pos_z.png" />
+ <asset type="quad" />
+ </node>
+ </node>
+
</SceneGraph>
Modified: Mercury2/modules/Makefile
===================================================================
--- Mercury2/modules/Makefile 2010-02-23 07:39:14 UTC (rev 675)
+++ Mercury2/modules/Makefile 2010-02-23 08:44:24 UTC (rev 676)
@@ -2,7 +2,7 @@
CXXFLAGS=${CFLAGS}
LDFLAGS=-shared
-all : BillboardNode.so TextNode.so Terrain.so TextPlate.so ParticleEmitter.so Cu2.so
+all : BillboardNode.so TextNode.so Terrain.so TextPlate.so ParticleEmitter.so Cu2.so Skybox.so
clean :
rm -rf *~ *.o *.so
Modified: Mercury2/modules.xml
===================================================================
--- Mercury2/modules.xml 2010-02-23 07:39:14 UTC (rev 675)
+++ Mercury2/modules.xml 2010-02-23 08:44:24 UTC (rev 676)
@@ -5,4 +5,5 @@
<Module src="modules/TextPlate.cpp" obj="modules/TextPlate" func="InstallTextPlate" class="TextPlate"/>
<Module src="modules/ParticleEmitter.cpp" obj="modules/ParticleEmitter" func="InstallParticleEmitter" class="ParticleEmitter"/>
<Module src="modules/Cu2.cpp" obj="modules/Cu2" func="InstallCu2Element" class="Cu2Element"/>
+ <Module src="modules/Skybox.cpp" obj="modules/Skybox" func="InstallSkybox" class="Skybox"/>
</Modules>
Modified: Mercury2/src/Camera.cpp
===================================================================
--- Mercury2/src/Camera.cpp 2010-02-23 07:39:14 UTC (rev 675)
+++ Mercury2/src/Camera.cpp 2010-02-23 08:44:24 UTC (rev 676)
@@ -17,6 +17,12 @@
REGISTER_MESSAGE_WITH_DELEGATE( "SetCameraPosition", &CameraNode::SetCameraPosition );
}
+CameraNode::~CameraNode()
+{
+ UNREGISTER_FOR_MESSAGE( INPUTEVENT_MOUSE );
+ UNREGISTER_FOR_MESSAGE( "SetCameraPosition" );
+}
+
void CameraNode::PreRender(const MercuryMatrix& matrix)
{
VIEWMATRIX = m_viewMatrix;
Modified: Mercury2/src/Camera.h
===================================================================
--- Mercury2/src/Camera.h 2010-02-23 07:39:14 UTC (rev 675)
+++ Mercury2/src/Camera.h 2010-02-23 08:44:24 UTC (rev 676)
@@ -9,6 +9,7 @@
{
public:
CameraNode();
+ ~CameraNode();
virtual void ComputeMatrix();
virtual void HandleMouseInput(const MessageData& data);
virtual void Update(float dTime);
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2010-02-23 07:39:14 UTC (rev 675)
+++ Mercury2/src/MercuryMessageManager.h 2010-02-23 08:44:24 UTC (rev 676)
@@ -34,7 +34,7 @@
class MercuryMessageManager
{
public:
- MercuryMessageManager() : m_messageQueue( MessageHolder::Compare ) { }
+ MercuryMessageManager() : m_messageQueue( MessageHolder::Compare ), m_currTime(0) { }
///Dispatch message whenever the message manager gets control again; delay after now.
void PostMessage(const MString& message, MessageData* data, float delay);
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2010-02-23 07:39:14 UTC (rev 675)
+++ Mercury2/src/Texture.cpp 2010-02-23 08:44:24 UTC (rev 676)
@@ -203,7 +203,7 @@
void Texture::Activate(uint32_t textureResource)
{
GLCALL( glActiveTexture( textureResource ) );
- GLCALL( glClientActiveTextureARB(textureResource) );
+ GLCALL( glClientActiveTextureARB(textureResource) ); //XXX: Note to self, this seems to be causing a crash, look into it.
GLCALL( glEnableClientState(GL_TEXTURE_COORD_ARRAY) );
GLCALL( glEnable( GL_TEXTURE_2D ) );
}
@@ -222,7 +222,7 @@
for (uint8_t i = 0; i < m_numActiveTextures; ++i)
{
GLCALL( glActiveTexture( GL_TEXTURE0+i ) );
- GLCALL( glClientActiveTextureARB(GL_TEXTURE0+i) );
+ GLCALL( glClientActiveTextureARB(GL_TEXTURE0+i) ); //XXX: Note to self, this seems to be causing a crash, look into it.
GLCALL( glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(uvByteOffset)) );
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2010-03-02 03:24:15
|
Revision: 682
http://hgengine.svn.sourceforge.net/hgengine/?rev=682&view=rev
Author: cnlohr
Date: 2010-03-02 03:24:08 +0000 (Tue, 02 Mar 2010)
Log Message:
-----------
allow obj2hgmdl to compile
Modified Paths:
--------------
Mercury2/src/MQuaternion.cpp
Mercury2/src/MQuaternion.h
Mercury2/src/MercuryVertex.cpp
Mercury2/src/MercuryVertex.h
Mercury2/tools/obj2hgmdl/Makefile
Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
Modified: Mercury2/src/MQuaternion.cpp
===================================================================
--- Mercury2/src/MQuaternion.cpp 2010-03-02 02:00:15 UTC (rev 681)
+++ Mercury2/src/MQuaternion.cpp 2010-03-02 03:24:08 UTC (rev 682)
@@ -1,7 +1,6 @@
#include <MQuaternion.h>
#include <MercuryMath.h>
#include <MercuryMatrix.h>
-#include <MercuryLog.h>
MQuaternion::MQuaternion()
{
@@ -264,9 +263,9 @@
return v;
}
-void MQuaternion::Print(const MString& s) const
+MString MQuaternion::Stringify(const MString& s) const
{
- LOG.Write( ssprintf("%s: %f %f %f %f", s.c_str(), m_wxyz[0], m_wxyz[1], m_wxyz[2], m_wxyz[3]) );
+ return ssprintf("%s: %f %f %f %f", s.c_str(), m_wxyz[0], m_wxyz[1], m_wxyz[2], m_wxyz[3]);
}
//Returns the Euclidian Inner Product of two MQuaternions (Similar to Vector Dot-Product)
Modified: Mercury2/src/MQuaternion.h
===================================================================
--- Mercury2/src/MQuaternion.h 2010-03-02 02:00:15 UTC (rev 681)
+++ Mercury2/src/MQuaternion.h 2010-03-02 03:24:08 UTC (rev 682)
@@ -69,7 +69,7 @@
bool operator==(const MQuaternion &rhs) const;
inline bool operator!=(const MQuaternion &rhs) const { return !(*this == rhs); }
- void Print(const MString& s = "MQuaternion") const;
+ MString Stringify(const MString& s = "MQuaternion") const;
inline float& W() { return m_wxyz[0]; }
inline float& X() { return m_wxyz[1]; }
Modified: Mercury2/src/MercuryVertex.cpp
===================================================================
--- Mercury2/src/MercuryVertex.cpp 2010-03-02 02:00:15 UTC (rev 681)
+++ Mercury2/src/MercuryVertex.cpp 2010-03-02 03:24:08 UTC (rev 682)
@@ -2,7 +2,6 @@
#include <MercuryUtil.h>
#include <MercuryMath.h>
#include <MQuaternion.h>
-#include <MercuryLog.h>
#include <MercuryMatrix.h>
@@ -149,9 +148,9 @@
return GetX() + GetY() + GetZ() + GetW();
}
-void MercuryVertex::Print(const MString& s) const
+MString MercuryVertex::Stringify(const MString& s) const
{
- LOG.Write(ssprintf("%s: %f %f %f %f", s.c_str(), (*this)[0], (*this)[1], (*this)[2], (*this)[3]));
+ return ssprintf("%s: %f %f %f %f", s.c_str(), (*this)[0], (*this)[1], (*this)[2], (*this)[3]);
}
MercuryVertex MercuryVertex::Rotate(const MQuaternion& q) const
Modified: Mercury2/src/MercuryVertex.h
===================================================================
--- Mercury2/src/MercuryVertex.h 2010-03-02 02:00:15 UTC (rev 681)
+++ Mercury2/src/MercuryVertex.h 2010-03-02 03:24:08 UTC (rev 682)
@@ -88,7 +88,7 @@
float DotProduct(const MercuryVertex& rhs) const;
MercuryVertex DotProduct3(const MercuryVertex& rhs1, const MercuryVertex& rhs2, const MercuryVertex& rhs3) const;
- void Print(const MString& s = "Vertex") const;
+ MString Stringify(const MString& s = "Vertex") const;
MercuryVertex Rotate(const MQuaternion& q) const;
Modified: Mercury2/tools/obj2hgmdl/Makefile
===================================================================
--- Mercury2/tools/obj2hgmdl/Makefile 2010-03-02 02:00:15 UTC (rev 681)
+++ Mercury2/tools/obj2hgmdl/Makefile 2010-03-02 03:24:08 UTC (rev 682)
@@ -1,2 +1,2 @@
all:
- g++ obj2hgmdl.cpp ../../src/MQuaternion.cpp ../../src/MercuryVertex.cpp -I../../src -I../.. -DHGENGINE -g -o obj2hgmdl
+ g++ obj2hgmdl.cpp ../../src/MQuaternion.cpp ../../src/MercuryVertex.cpp ../../src/MercuryString.cpp -I../../src -I../.. -DHGENGINE -g -o obj2hgmdl
Modified: Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp
===================================================================
--- Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2010-03-02 02:00:15 UTC (rev 681)
+++ Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2010-03-02 03:24:08 UTC (rev 682)
@@ -5,6 +5,7 @@
#include <MercuryVertex.h>
#include <map>
#include <math.h>
+#include <stdlib.h>
using namespace std;
@@ -85,7 +86,8 @@
bool found = false;
tv[i].position = v[ iv[i]-1 ];
tv[i].normal = vn[ ivn[i]-1 ];
- tv[i].uv = vt[ ivt[i]-1 ];
+ if( vt.size() > ivt[i]-1 )
+ tv[i].uv = vt[ ivt[i]-1 ];
for (unsigned long j = 0; j < vertice.size(); ++j)
{
@@ -181,6 +183,12 @@
FILE *mbmf;
ifstream obj;
+ if( argc != 3 )
+ {
+ fprintf( stderr, "Usage: %s [OBJ File] [HGMDL File]\n", argv[0] );
+ exit( -1 );
+ }
+
obj.open(argv[1]);
mbmf = fopen(argv[2], "wb");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2010-03-29 18:38:52
|
Revision: 687
http://hgengine.svn.sourceforge.net/hgengine/?rev=687&view=rev
Author: axlecrusher
Date: 2010-03-29 18:38:45 +0000 (Mon, 29 Mar 2010)
Log Message:
-----------
Minor changes i have had sitting round for a while.
Modified Paths:
--------------
Mercury2/modules/Terrain.cpp
Mercury2/src/Shader.cpp
Modified: Mercury2/modules/Terrain.cpp
===================================================================
--- Mercury2/modules/Terrain.cpp 2010-03-14 23:04:33 UTC (rev 686)
+++ Mercury2/modules/Terrain.cpp 2010-03-29 18:38:45 UTC (rev 687)
@@ -167,7 +167,7 @@
{
if( Asset().GetLoadState() == LOADING )
{
- POST_MESSAGE( "QueryTerrainPoint", new VertexDataMessage( dynamic_cast<const VertexDataMessage&>(data) ), 0.0001 );
+ POST_MESSAGE( "QueryTerrainPoint", new VertexDataMessage( dynamic_cast<const VertexDataMessage&>(data) ), 0.0001f );
return;
}
const VertexDataMessage& v( dynamic_cast<const VertexDataMessage&>(data) );
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2010-03-14 23:04:33 UTC (rev 686)
+++ Mercury2/src/Shader.cpp 2010-03-29 18:38:45 UTC (rev 687)
@@ -410,25 +410,25 @@
if( f )
{
iOut[0] = f->GetModTime();
- delete f;
} else
iOut[0] = 0;
+ SAFE_DELETE(f);
f = FILEMAN.Open( sShaderName + ".vert" );
if( f )
{
iOut[1] = f->GetModTime();
- delete f;
} else
iOut[1] = 0;
+ SAFE_DELETE(f);
f = FILEMAN.Open( sShaderName + ".geom" );
if( f )
{
iOut[2] = f->GetModTime();
- delete f;
} else
iOut[2] = 0;
+ SAFE_DELETE(f);
}
void Shader::ActivateShader()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|