You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(46) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(185) |
Feb
(242) |
Mar
(237) |
Apr
(180) |
May
(102) |
Jun
(278) |
Jul
(114) |
Aug
(92) |
Sep
(246) |
Oct
(212) |
Nov
(279) |
Dec
(99) |
| 2007 |
Jan
(130) |
Feb
(194) |
Mar
(22) |
Apr
(72) |
May
(40) |
Jun
(111) |
Jul
(114) |
Aug
(154) |
Sep
(114) |
Oct
(2) |
Nov
(1) |
Dec
(5) |
| 2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(6) |
Oct
(51) |
Nov
(34) |
Dec
(130) |
| 2009 |
Jan
(22) |
Feb
(20) |
Mar
(41) |
Apr
(45) |
May
(82) |
Jun
(96) |
Jul
(48) |
Aug
(90) |
Sep
(13) |
Oct
(49) |
Nov
(31) |
Dec
(21) |
| 2010 |
Jan
(25) |
Feb
(9) |
Mar
(7) |
Apr
(28) |
May
(27) |
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(1) |
Nov
(13) |
Dec
(2) |
| 2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <axl...@us...> - 2009-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-24 20:34:34
|
Revision: 642
http://hgengine.svn.sourceforge.net/hgengine/?rev=642&view=rev
Author: axlecrusher
Date: 2009-12-24 20:34:24 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
set default pass
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 19:32:26 UTC (rev 641)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 20:34:24 UTC (rev 642)
@@ -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"/>
+ <node type="particleemitter" setPasses="7"/>
</node>
</node>
<node type="transformnode" movx="1" fallback="lamprow.lamp" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 19:32:34
|
Revision: 641
http://hgengine.svn.sourceforge.net/hgengine/?rev=641&view=rev
Author: axlecrusher
Date: 2009-12-24 19:32:26 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
more accurate vbo stats
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-24 19:31:48 UTC (rev 640)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-24 19:32:26 UTC (rev 641)
@@ -267,7 +267,7 @@
GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID) );
// GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0) );
- MercuryVBO::m_lastVBOrendered = this;
+ MercuryVBO::SetLastRendered(this);
if (m_dirtyVBO)
{
@@ -293,6 +293,7 @@
GLCALL( glPopAttrib() );
m_particlesDrawn+=m_maxParticles;
+ MercuryVBO::IncrementBatches();
base::Render(matrix);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 19:31:58
|
Revision: 640
http://hgengine.svn.sourceforge.net/hgengine/?rev=640&view=rev
Author: axlecrusher
Date: 2009-12-24 19:31:48 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
more accurate vbo stats
Modified Paths:
--------------
Mercury2/src/BoundingBox.cpp
Mercury2/src/MercuryVBO.cpp
Mercury2/src/MercuryVBO.h
Modified: Mercury2/src/BoundingBox.cpp
===================================================================
--- Mercury2/src/BoundingBox.cpp 2009-12-24 18:11:56 UTC (rev 639)
+++ Mercury2/src/BoundingBox.cpp 2009-12-24 19:31:48 UTC (rev 640)
@@ -155,9 +155,9 @@
if (m_vboID == 0) InitVBO();
- if ( MercuryVBO::m_lastVBOrendered != &m_vboID )
+ if ( MercuryVBO::GetLastRendered() != &m_vboID )
{
- MercuryVBO::m_lastVBOrendered = &m_vboID;
+ MercuryVBO::SetLastRendered( &m_vboID );
GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboID) ); // once
GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0) ); // once
GLCALL( glVertexPointer(3, GL_FLOAT, 0, 0) ); // once
@@ -170,7 +170,7 @@
GLCALL( glDepthMask(GL_FALSE) );
GLCALL( glDrawArrays(GL_QUADS, 0, 24) );
-
+ MercuryVBO::IncrementBatches();
GLCALL( glEndQueryARB(GL_SAMPLES_PASSED_ARB) );
// GLCALL( glGetQueryObjectuivARB(q, GL_QUERY_RESULT_ARB, &samples) );
@@ -189,15 +189,16 @@
if (m_vboID == 0) InitVBO();
-// if ( MercuryVBO::m_lastVBOrendered != &m_vboID )
+// if ( MercuryVBO::GetLastRendered() != &m_vboID )
{
- MercuryVBO::m_lastVBOrendered = &m_vboID;
+ MercuryVBO::SetLastRendered( &m_vboID );
GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboID) ); // once
GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0) ); // once
GLCALL( glVertexPointer(3, GL_FLOAT, 0, 0) ); // once
}
GLCALL( glDrawArrays(GL_QUADS, 0, 24) );
+ MercuryVBO::IncrementBatches();
GLCALL( glPopMatrix() );
}
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-12-24 18:11:56 UTC (rev 639)
+++ Mercury2/src/MercuryVBO.cpp 2009-12-24 19:31:48 UTC (rev 640)
@@ -28,9 +28,9 @@
if ( !m_initiated ) InitVBO();
- if ( this != m_lastVBOrendered )
+ if ( this != GetLastRendered() )
{
- m_lastVBOrendered = this;
+ SetLastRendered(this);
if ( m_bDirtyVertices ) UpdateVertices();
if( m_bDirtyIndices ) UpdateIndices();
@@ -60,7 +60,7 @@
GLCALL( glNormalPointer(GL_FLOAT, STRIDE*sizeof(float), BUFFER_OFFSET(sizeof(float)*2)) );
GLCALL( glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL) );
- ++m_vboBatches;
+ IncrementBatches();
if (m_boundingVolume && SHOWBOUNDINGVOLUME) m_boundingVolume->Render();
@@ -119,6 +119,12 @@
m_indexData.Allocate(count);
}
+void MercuryVBO::SetLastRendered(void* p)
+{
+ m_lastVBOrendered = p;
+ ++m_vboBinds;
+}
+
void* MercuryVBO::m_lastVBOrendered = NULL;
uint32_t MercuryVBO::m_vboBatches = 0;
uint32_t MercuryVBO::m_vboBinds = 0;
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2009-12-24 18:11:56 UTC (rev 639)
+++ Mercury2/src/MercuryVBO.h 2009-12-24 19:31:48 UTC (rev 640)
@@ -36,15 +36,19 @@
inline uint16_t IndiceCount() const { return m_indexData.Length(); }
- static void* m_lastVBOrendered;
inline void DirtyVertices() { m_bDirtyVertices = true; }
inline void DirtyVerexColor() { m_bDirtyVertexColor = true; }
inline void DirtyIndices() { m_bDirtyIndices = true; }
+
+ static void SetLastRendered(void* p);
+ inline static const void* GetLastRendered() { return m_lastVBOrendered; }
+ inline static void IncrementBatches() { ++m_vboBatches; }
GENRTTI( MercuryVBO );
private:
virtual void InitVBO();
+ static void* m_lastVBOrendered;
unsigned int m_bufferIDs[3];
bool m_initiated;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 18:12:07
|
Revision: 639
http://hgengine.svn.sourceforge.net/hgengine/?rev=639&view=rev
Author: axlecrusher
Date: 2009-12-24 18:11:56 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
update for faster particle rendering, use gl_Color instead of uniforms to set values
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/ParticleEmitter.h
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-24 18:11:04 UTC (rev 638)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-24 18:11:56 UTC (rev 639)
@@ -255,8 +255,7 @@
void ParticleEmitter::Render(const MercuryMatrix& matrix)
{
-// printf("render particles\n");
- GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT) );
+ GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT|GL_CURRENT_BIT) );
GLCALL( glDepthMask( false ) );
GLCALL( glDisable(GL_CULL_FACE) );
@@ -266,38 +265,47 @@
}
GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID) );
+// GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0) );
+
MercuryVBO::m_lastVBOrendered = this;
if (m_dirtyVBO)
{
m_dirtyVBO = false;
- GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STATIC_DRAW_ARB) );
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STREAM_DRAW_ARB) );
}
GLCALL( glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) );
//do render stuff here
-// GLCALL( glDisableClientState(GL_TEXTURE_COORD_ARRAY) );
- Texture::ApplyActiveTextures(ParticleBase::STRIDE*sizeof(float));
+ Texture::ApplyActiveTextures(ParticleBase::STRIDE*sizeof(float), 7*sizeof(float));
GLCALL( glEnableClientState(GL_VERTEX_ARRAY) );
GLCALL( glEnableClientState( GL_COLOR_ARRAY ) ); //used for attributes
+// GLCALL( glDisableClientState( GL_NORMAL_ARRAY ) );
+
GLCALL( glVertexPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 0*sizeof(float) ) ) );
GLCALL( glColorPointer(4, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 3*sizeof(float) ) ) );
- GLCALL( glTexCoordPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 7*sizeof(float) ) ) );
-// GLCALL( glDrawRangeElements(GL_QUADS, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL) );
-// GLCALL( glDrawElements(GL_QUADS, m_maxParticles*4, GL_UNSIGNED_BYTE, 0) );
GLCALL( glDrawArrays(GL_QUADS, 0, m_maxParticles*4) );
-//printf("darw\n");
+
GLCALL( glPopClientAttrib() );
GLCALL( glPopAttrib() );
+ m_particlesDrawn+=m_maxParticles;
+
base::Render(matrix);
+}
-
+uint32_t ParticleEmitter::ResetDrawnCount()
+{
+ uint32_t t = m_particlesDrawn;
+ m_particlesDrawn = 0;
+ return t;
}
+uint32_t ParticleEmitter::m_particlesDrawn = 0;
+
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/modules/ParticleEmitter.h
===================================================================
--- Mercury2/modules/ParticleEmitter.h 2009-12-24 18:11:04 UTC (rev 638)
+++ Mercury2/modules/ParticleEmitter.h 2009-12-24 18:11:56 UTC (rev 639)
@@ -64,6 +64,8 @@
void SetMaxParticleCount(uint16_t count);
inline void SetDirtyVBO() { m_dirtyVBO=true; }
+ static uint32_t ResetDrawnCount();
+
GENRTTI( ParticleEmitter );
private:
// void DestroyParticles();
@@ -91,6 +93,7 @@
std::list< ParticleBase* > m_active, m_inactive;
// MercuryNode* m_masterParticle;
+ static uint32_t m_particlesDrawn;
};
#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 18:11:11
|
Revision: 638
http://hgengine.svn.sourceforge.net/hgengine/?rev=638&view=rev
Author: axlecrusher
Date: 2009-12-24 18:11:04 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
update fire particles scene
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 18:07:19 UTC (rev 637)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-24 18:11:04 UTC (rev 638)
@@ -35,14 +35,10 @@
<!-- <asset type="StateChanger" file="DepthWrite:0" />
state changer needs some work for proper on and off.
until then had code it for all particles -->
- <node type="particleemitter" texture="GRAPHIC:flame.png">
- <asset type="texture" file="GRAPHIC:flame.png"/>
+ <node type="transformnode" scalex="0.1" scaley="0.1" scalez="0.1">
<asset type="shader" file="GRAPHIC:FireParticles"/>
- <particle>
- <node type="transformnode" scalex="0.075" scaley="0.075" scalez="0.075" alphaPath="false">
- <asset type="quad"/>
- </node>
- </particle>
+ <asset type="texture" file="GRAPHIC:flame.png"/>
+ <node type="particleemitter"/>
</node>
</node>
<node type="transformnode" movx="1" fallback="lamprow.lamp" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 18:07:27
|
Revision: 637
http://hgengine.svn.sourceforge.net/hgengine/?rev=637&view=rev
Author: axlecrusher
Date: 2009-12-24 18:07:19 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
update for faster particle rendering, use gl_Color instead of uniforms to set values
Modified Paths:
--------------
Mercury2/Themes/default/Graphic/FireParticles.frag
Mercury2/Themes/default/Graphic/FireParticles.vert
Modified: Mercury2/Themes/default/Graphic/FireParticles.frag
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-24 18:01:17 UTC (rev 636)
+++ Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-24 18:07:19 UTC (rev 637)
@@ -1,9 +1,9 @@
-uniform vec4 HG_ParticleTime;
uniform sampler2D HG_Texture0;
+varying vec4 particleData;
void main()
{
- float pComplete = (HG_ParticleTime.x/HG_ParticleTime.y);
+ float pComplete = (particleData.x/particleData.y);
vec4 blue = vec4(0,0,1,0.125);
vec4 orange = vec4(1,0.917647059,0.11372549,1);
@@ -18,5 +18,5 @@
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;
- gl_FragData[0].a *= 1.0-(HG_ParticleTime.x/HG_ParticleTime.y);
-}
+ gl_FragData[0].a *= 1.0-(particleData.x/particleData.y);
+}
\ No newline at end of file
Modified: Mercury2/Themes/default/Graphic/FireParticles.vert
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-24 18:01:17 UTC (rev 636)
+++ Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-24 18:07:19 UTC (rev 637)
@@ -1,10 +1,11 @@
-uniform vec4 HG_ParticleTime;
+//uniform vec4 HG_ParticleTime;
uniform vec4 HG_EyePos;
uniform vec4 HG_LookVector;
uniform mat4 HG_ModelMatrix;
uniform mat4 HG_WorldMatrix;
uniform mat4 HG_ViewMatrix;
varying vec3 angleC;
+varying vec4 particleData;
mat4 glRotate(float angle, vec3 axis)
{
@@ -47,15 +48,21 @@
void main()
{
+ particleData = gl_Color;
+
vec4 pos = vec4(1.0);
- pos.y = 0.30*(HG_ParticleTime.x*HG_ParticleTime.x);
- pos.x = 0.40*((HG_ParticleTime.z-50000.0)/50000.0)*HG_ParticleTime.x; //rand num
- pos.z = 0.40*((HG_ParticleTime.w-50000.0)/50000.0)*HG_ParticleTime.x; //rand num
+ pos.y = 0.6*(particleData.x*particleData.x);
+ 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
mat4 m = Billboard(pos.xyz);
m[3].xyz = pos.xyz;
- gl_Position = gl_ProjectionMatrix *HG_ViewMatrix *HG_ModelMatrix *m* gl_Vertex;
-
+ 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[3][3] = 1.0;
+ gl_Position = gl_ProjectionMatrix *HG_ViewMatrix *HG_ModelMatrix *m*s* gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 18:01:29
|
Revision: 636
http://hgengine.svn.sourceforge.net/hgengine/?rev=636&view=rev
Author: axlecrusher
Date: 2009-12-24 18:01:17 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
set uv offset
Modified Paths:
--------------
Mercury2/src/RenderDeferredLights.cpp
Modified: Mercury2/src/RenderDeferredLights.cpp
===================================================================
--- Mercury2/src/RenderDeferredLights.cpp 2009-12-24 17:58:11 UTC (rev 635)
+++ Mercury2/src/RenderDeferredLights.cpp 2009-12-24 18:01:17 UTC (rev 636)
@@ -20,7 +20,7 @@
// uint8_t numTextures = Texture::NumberActiveTextures();
uint16_t stride = sizeof(float)*8;
- Texture::ApplyActiveTextures(stride);
+ Texture::ApplyActiveTextures(stride, 0);
GLCALL( glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT) );
GLCALL( glCullFace(GL_FRONT) );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-24 17:58:18
|
Revision: 635
http://hgengine.svn.sourceforge.net/hgengine/?rev=635&view=rev
Author: axlecrusher
Date: 2009-12-24 17:58:11 +0000 (Thu, 24 Dec 2009)
Log Message:
-----------
ability to specify different UV offset
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-12-23 21:24:26 UTC (rev 634)
+++ Mercury2/src/MercuryVBO.cpp 2009-12-24 17:58:11 UTC (rev 635)
@@ -49,11 +49,12 @@
++m_vboBinds;
}
+ GLCALL( glPushAttrib(GL_CURRENT_BIT) );
GLCALL( glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) );
if (m_useVertexColor) { GLCALL( glEnableClientState( GL_COLOR_ARRAY ) ); }
- Texture::ApplyActiveTextures(STRIDE*sizeof(float));
+ Texture::ApplyActiveTextures(STRIDE*sizeof(float), 0);
GLCALL( glEnableClientState( GL_NORMAL_ARRAY ) );
GLCALL( glNormalPointer(GL_FLOAT, STRIDE*sizeof(float), BUFFER_OFFSET(sizeof(float)*2)) );
@@ -64,6 +65,7 @@
if (m_boundingVolume && SHOWBOUNDINGVOLUME) m_boundingVolume->Render();
GLCALL( glPopClientAttrib() );
+ GLCALL( glPopAttrib() );
if ( SHOWAXISES ) DrawAxes();
}
@@ -118,8 +120,8 @@
}
void* MercuryVBO::m_lastVBOrendered = NULL;
-uint32_t MercuryVBO::m_vboBatches;
-uint32_t MercuryVBO::m_vboBinds;
+uint32_t MercuryVBO::m_vboBatches = 0;
+uint32_t MercuryVBO::m_vboBinds = 0;
/****************************************************************************
* Copyright (C) 2008 by Joshua Allen *
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-12-23 21:24:26 UTC (rev 634)
+++ Mercury2/src/Texture.cpp 2009-12-24 17:58:11 UTC (rev 635)
@@ -217,13 +217,13 @@
GLERRORCHECK;
}
-void Texture::ApplyActiveTextures(uint16_t stride)
+void Texture::ApplyActiveTextures(uint16_t stride, uint8_t uvByteOffset)
{
for (uint8_t i = 0; i < m_numActiveTextures; ++i)
{
GLCALL( glActiveTexture( GL_TEXTURE0+i ) );
GLCALL( glClientActiveTextureARB(GL_TEXTURE0+i) );
- GLCALL( glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(sizeof(float)*0)) );
+ GLCALL( glTexCoordPointer(2, GL_FLOAT, stride, BUFFER_OFFSET(uvByteOffset)) );
}
Texture::DisableUnusedTextures();
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-12-23 21:24:26 UTC (rev 634)
+++ Mercury2/src/Texture.h 2009-12-24 17:58:11 UTC (rev 635)
@@ -43,7 +43,7 @@
void SetRawData(RawImageData* raw);
- static void ApplyActiveTextures(uint16_t stride);
+ static void ApplyActiveTextures(uint16_t stride, uint8_t uvByteOffset);
static void DisableUnusedTextures();
void SetFilter( TextureFilterMode t ) { m_tFilterMode = t; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-23 21:24:36
|
Revision: 634
http://hgengine.svn.sourceforge.net/hgengine/?rev=634&view=rev
Author: axlecrusher
Date: 2009-12-23 21:24:26 +0000 (Wed, 23 Dec 2009)
Log Message:
-----------
faster particles
still not 100% working
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/ParticleEmitter.h
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-23 01:29:35 UTC (rev 633)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-23 21:24:26 UTC (rev 634)
@@ -5,63 +5,36 @@
#include <MercuryVBO.h>
#include <Texture.h>
+#include <list>
+using namespace std;
//REGISTER_NODE_TYPE(ParticleBase);
REGISTER_NODE_TYPE(ParticleEmitter);
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
ParticleBase::ParticleBase()
- :m_nextParticle(NULL), m_age(0), m_lifespan(0), m_particleVobData(NULL)
+ :m_age(0), m_lifespan(0), m_particleVobData(NULL)
{
}
ParticleBase::~ParticleBase()
{
m_particleVobData = NULL;
-// m_children.clear();
}
void ParticleBase::Init()
{
-// base::Init();
m_age = 0;
-// m_lifespan = (rand()%5000)/1000.f;
-// LOG.Write("init particle");
}
void ParticleBase::Update(float dTime)
{
-// base::Update(dTime);
-
m_age += dTime;
WriteAgeToVBO();
- if (m_age >= m_lifespan)
- {
- m_emitter->DeactivateParticle(this);
- Deactivate();
- }
+ if (m_age >= m_lifespan) Deactivate();
}
-/*
-void ParticleBase::RecursiveRender()
-{
- ShaderAttribute sa;
- sa.type = ShaderAttribute::TYPE_FLOATV4;
- sa.value.fFloatV4[0] = m_age;
- sa.value.fFloatV4[1] = m_lifespan;
- sa.value.fFloatV4[2] = m_rand1;
- sa.value.fFloatV4[3] = m_rand2;
- Shader::SetAttribute("HG_ParticleTime", sa);
-
- GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT) );
- GLCALL( glDepthMask( false ) );
- GLCALL( glDisable(GL_CULL_FACE) );
-
- base::RecursiveRender();
-
- GLCALL( glPopAttrib() );
-}
-*/
+
void ParticleBase::WriteAgeToVBO()
{
m_emitter->SetDirtyVBO();
@@ -92,6 +65,7 @@
void ParticleBase::Activate()
{
+// printf("Activate\n");
uint8_t i = 0;
//upper left
@@ -122,13 +96,13 @@
void ParticleBase::Deactivate()
{
- m_emitter->SetDirtyVBO();
for (uint8_t i = 0; i < 4; ++i)
{
WriteFloatToVertices(0,i,0);
WriteFloatToVertices(0,i,1);
WriteFloatToVertices(0,i,2);
}
+ m_emitter->SetDirtyVBO();
}
void ParticleBase::WriteFloatToVertices(float v, uint8_t vertexIndex, uint8_t offset)
@@ -144,24 +118,10 @@
WriteRand2ToVBO();
}
-/*
-void ParticleBase::Activate()
-{
- LOG.Write("Activate");
- m_emitter->AddChild(this);
-}
-
-void ParticleBase::Deactivate()
-{
- LOG.Write("Deactivate");
- m_emitter->RemoveChild(this);
- m_emitter->DeactivateParticle(this);
-}
-*/
ParticleEmitter::ParticleEmitter()
- :m_maxParticles(50), m_age(0), m_emitDelay(0.01), m_lifespan(0),
- m_particlesEmitted(0), m_particleMinLife(0.01), m_particleMaxLife(5),
- m_inactiveParticles(NULL), m_particles(NULL), GenerateParticlesClbk(NULL),
+ :base(), m_maxParticles(50), m_age(0), m_emitDelay(0.1), m_lifespan(0),
+ m_particlesEmitted(0), m_particleMinLife(0.1), m_particleMaxLife(5),
+ m_particles(NULL), GenerateParticlesClbk(NULL),
m_bufferID(0), m_dirtyVBO(false)
{
Init();
@@ -170,31 +130,21 @@
ParticleEmitter::~ParticleEmitter()
{
- DestroyParticles();
-
if (m_bufferID > 0) { GLCALL( glDeleteBuffersARB(1, &m_bufferID) ); }
+ SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
SAFE_DELETE(GenerateParticlesClbk);
-// SAFE_DELETE(m_masterParticle);
}
void ParticleEmitter::Init()
{
MercuryNode::Init();
- DestroyParticles();
+ SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
SetMaxParticleCount(m_maxParticles);
}
-
-void ParticleEmitter::DestroyParticles()
-{
-/// for (uint32_t i = 0; (i < m_maxParticles) && m_particles; ++i)
-// RemoveChild(m_particles+i);
- SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
-}
-
void ParticleEmitter::Update(float dTime)
{
m_age += dTime;
@@ -207,58 +157,55 @@
++m_particlesEmitted; //always increment even if the maximum number of particles exist
ActivateParticle();
}
+
+ list< ParticleBase* >::iterator i = m_active.begin();
+ while ( i!=m_active.end() )
+ {
+ ParticleBase *p = *i;
+ p->Update(dTime);
+ if ( !p->IsActive() )
+ {
+ m_active.erase(i++); //don't invalidate iterator before incrementing it
+ m_inactive.push_back(p);
+ }
+ else
+ {
+ ++i;
+ }
+ }
}
void ParticleEmitter::ActivateParticle()
{
- if (m_inactiveParticles)
+ if (!m_inactive.empty())
{
- ParticleBase* p = m_inactiveParticles;
- m_inactiveParticles = p->m_nextParticle;
- p->m_nextParticle = NULL;
+ ParticleBase* p = m_inactive.front();
+ m_inactive.pop_front();
+
p->Init();
p->Activate();
-
p->m_lifespan = m_particleMinLife;
p->m_lifespan += (rand()%(int(m_particleMaxLife*1000) - int(m_particleMinLife*1000)))/1000.0f;
p->m_rand1 = rand()%100000;
p->m_rand2 = rand()%100000;
// +((rand()%((m_particleMaxLife*1000)-(m_particleMinLife*1000)))/1000.0f);
-
-// AddChild(p);
- }
-}
-void ParticleEmitter::DeactivateParticle(ParticleBase* p)
-{
-// LOG.Write("Deactivate");
-// RemoveChild(p);
- if (!m_inactiveParticles)
- {
- m_inactiveParticles = p;
- }
- else
- {
- ParticleBase* ip = m_inactiveParticles;
- while (ip->m_nextParticle) ip = ip->m_nextParticle;
- ip->m_nextParticle = p;
- }
-}
-void ParticleEmitter::FillUnusedParticleList(ParticleBase* p, uint32_t i)
-{
- if (p)
- {
- p->m_emitter = this;
- ++i;
- if (i<m_maxParticles) p->m_nextParticle = m_particles+i;
- FillUnusedParticleList(p->m_nextParticle, i);
+ p->WriteAgeToVBO();
+ p->WriteLifespanToVBO();
+ p->WriteRand1ToVBO();
+ p->WriteRand2ToVBO();
+
+ //add to the active list
+// printf("push %p\n", p);
+ m_active.push_back(p);
}
}
void ParticleEmitter::LoadFromXML(const XMLNode& node)
{
+ printf("LOADED!!!!!\n");
base::LoadFromXML(node);
/*
XMLNode particleXML;
@@ -283,25 +230,32 @@
SAFE_DELETE_ARRAY(m_particles);
// if (GenerateParticlesClbk) m_particles = (*GenerateParticlesClbk)(m_maxParticles);
m_particles = new ParticleBase[m_maxParticles];
- m_inactiveParticles = m_particles;
- InitNewParticles(m_particles, 0, ParticleBase::STRIDE*4, m_vertexData.Buffer());
-}
+// m_inactiveParticles = m_particles;
+// InitNewParticles(m_particles, 0, ParticleBase::STRIDE*4, m_vertexData.Buffer());
-void ParticleEmitter::InitNewParticles(ParticleBase* p, uint32_t i, uint16_t vobStep, float* vob)
-{
- if (p)
+ m_inactive.clear();
+ m_active.clear();
+
+ for (uint32_t i = 0; i < m_maxParticles; ++i)
{
+ ParticleBase* p = m_particles+i;
p->m_emitter = this;
- p->m_particleVobData = vob;
+ p->m_particleVobData = m_vertexData.Buffer()+(ParticleBase::STRIDE*4*i);
p->Deactivate();
- ++i;
- if (i<m_maxParticles) p->m_nextParticle = m_particles+i;
- InitNewParticles(p->m_nextParticle, i, vobStep, vob+vobStep);
+// printf("addr1 %p\n", p);
+ m_inactive.push_back( p );
}
}
+void ParticleEmitter::PreRender(const MercuryMatrix& matrix)
+{
+ MercuryNode::PreRender(matrix);
+ SetCulled(false);
+}
+
void ParticleEmitter::Render(const MercuryMatrix& matrix)
{
+// printf("render particles\n");
GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT) );
GLCALL( glDepthMask( false ) );
GLCALL( glDisable(GL_CULL_FACE) );
@@ -335,12 +289,12 @@
// GLCALL( glDrawRangeElements(GL_QUADS, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL) );
// GLCALL( glDrawElements(GL_QUADS, m_maxParticles*4, GL_UNSIGNED_BYTE, 0) );
GLCALL( glDrawArrays(GL_QUADS, 0, m_maxParticles*4) );
-
+//printf("darw\n");
GLCALL( glPopClientAttrib() );
+ GLCALL( glPopAttrib() );
base::Render(matrix);
- GLCALL( glPopAttrib() );
}
Modified: Mercury2/modules/ParticleEmitter.h
===================================================================
--- Mercury2/modules/ParticleEmitter.h 2009-12-23 01:29:35 UTC (rev 633)
+++ Mercury2/modules/ParticleEmitter.h 2009-12-23 21:24:26 UTC (rev 634)
@@ -21,6 +21,8 @@
void Deactivate();
void WriteToVBO();
+ inline bool IsActive() const { return m_age < m_lifespan; }
+
// GENRTTI( ParticleBase );
private:
// CLASS_HELPERS( MercuryNode );
@@ -34,7 +36,7 @@
void WriteFloatToVertices(float v, uint8_t vertexIndex, uint8_t offset);
friend class ParticleEmitter;
- ParticleBase* m_nextParticle;
+// ParticleBase *m_prev, *m_next;
float m_age;
float m_lifespan;
float m_rand1, m_rand2;
@@ -54,6 +56,9 @@
void DeactivateParticle(ParticleBase* p);
virtual void LoadFromXML(const XMLNode& node);
+
+
+ virtual void PreRender(const MercuryMatrix& matrix);
virtual void Render(const MercuryMatrix& matrix);
void SetMaxParticleCount(uint16_t count);
@@ -61,11 +66,11 @@
GENRTTI( ParticleEmitter );
private:
- void DestroyParticles();
+// void DestroyParticles();
void ActivateParticle();
- void FillUnusedParticleList(ParticleBase* p, uint32_t i);
- void InitNewParticles(ParticleBase* p, uint32_t i, uint16_t vobStep, float* vob);
+// void FillUnusedParticleList(ParticleBase* p, uint32_t i);
+// void InitNewParticles(ParticleBase* p, uint32_t i, uint16_t vobStep, float* vob);
CLASS_HELPERS( MercuryNode );
@@ -76,8 +81,7 @@
uint32_t m_particlesEmitted;
float m_particleMinLife, m_particleMaxLife;
- ParticleBase* m_inactiveParticles;
- ParticleBase* m_particles;
+ ParticleBase *m_particles;
Callback1R<uint32_t,ParticleBase*>* GenerateParticlesClbk;
AlignedBuffer<float> m_vertexData;
@@ -85,6 +89,7 @@
unsigned int m_bufferID;
bool m_dirtyVBO;
+ std::list< ParticleBase* > m_active, m_inactive;
// MercuryNode* m_masterParticle;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-23 01:29:43
|
Revision: 633
http://hgengine.svn.sourceforge.net/hgengine/?rev=633&view=rev
Author: axlecrusher
Date: 2009-12-23 01:29:35 +0000 (Wed, 23 Dec 2009)
Log Message:
-----------
working on faster particles
Modified Paths:
--------------
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/ParticleEmitter.h
Modified: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp 2009-12-22 16:08:48 UTC (rev 632)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-23 01:29:35 UTC (rev 633)
@@ -2,23 +2,28 @@
#include <Shader.h>
#include <GLHeaders.h>
+#include <MercuryVBO.h>
+#include <Texture.h>
+
//REGISTER_NODE_TYPE(ParticleBase);
REGISTER_NODE_TYPE(ParticleEmitter);
+#define BUFFER_OFFSET(i) ((char*)NULL + (i))
ParticleBase::ParticleBase()
- :m_nextParticle(NULL), m_age(0), m_lifespan(0)
+ :m_nextParticle(NULL), m_age(0), m_lifespan(0), m_particleVobData(NULL)
{
}
ParticleBase::~ParticleBase()
{
+ m_particleVobData = NULL;
// m_children.clear();
}
void ParticleBase::Init()
{
- base::Init();
+// base::Init();
m_age = 0;
// m_lifespan = (rand()%5000)/1000.f;
// LOG.Write("init particle");
@@ -26,20 +31,26 @@
void ParticleBase::Update(float dTime)
{
- base::Update(dTime);
+// base::Update(dTime);
m_age += dTime;
- if (m_age >= m_lifespan) m_emitter->DeactivateParticle(this);
+ WriteAgeToVBO();
+
+ if (m_age >= m_lifespan)
+ {
+ m_emitter->DeactivateParticle(this);
+ Deactivate();
+ }
}
-
+/*
void ParticleBase::RecursiveRender()
{
ShaderAttribute sa;
sa.type = ShaderAttribute::TYPE_FLOATV4;
sa.value.fFloatV4[0] = m_age;
sa.value.fFloatV4[1] = m_lifespan;
- sa.value.fFloatV4[2] = m_seed1;
- sa.value.fFloatV4[3] = m_seed2;
+ sa.value.fFloatV4[2] = m_rand1;
+ sa.value.fFloatV4[3] = m_rand2;
Shader::SetAttribute("HG_ParticleTime", sa);
GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT) );
@@ -50,6 +61,89 @@
GLCALL( glPopAttrib() );
}
+*/
+void ParticleBase::WriteAgeToVBO()
+{
+ m_emitter->SetDirtyVBO();
+ for (uint8_t i = 0; i < 4; ++i)
+ WriteFloatToVertices(m_age,i,3);
+}
+
+void ParticleBase::WriteLifespanToVBO()
+{
+ m_emitter->SetDirtyVBO();
+ for (uint8_t i = 0; i < 4; ++i)
+ WriteFloatToVertices(m_lifespan,i,4);
+}
+
+void ParticleBase::WriteRand1ToVBO()
+{
+ m_emitter->SetDirtyVBO();
+ for (uint8_t i = 0; i < 4; ++i)
+ WriteFloatToVertices(m_rand1,i,5);
+}
+
+void ParticleBase::WriteRand2ToVBO()
+{
+ m_emitter->SetDirtyVBO();
+ for (uint8_t i = 0; i < 4; ++i)
+ WriteFloatToVertices(m_rand2,i,6);
+}
+
+void ParticleBase::Activate()
+{
+ uint8_t i = 0;
+
+ //upper left
+ m_particleVobData[i++] = -0.5; m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0;
+ i+=4; m_particleVobData[i++] = 1; m_particleVobData[i++] = 0; //skip color data and set U,V
+
+ //lower left
+ m_particleVobData[i++] = -0.5; m_particleVobData[i++] = -0.5; m_particleVobData[i++] = 0;
+ i+=4; m_particleVobData[i++] = 0; m_particleVobData[i++] = 0; //skip color data and set U,V
+
+ //lower right
+ m_particleVobData[i++] = 0.5; m_particleVobData[i++] = -0.5; m_particleVobData[i++] = 0;
+ i+=4; m_particleVobData[i++] = 0; m_particleVobData[i++] = 1; //skip color data and set U,V
+
+ //upper right
+ m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0.5; m_particleVobData[i++] = 0;
+ i+=4; m_particleVobData[i++] = 1; m_particleVobData[i++] = 1; //skip color data and set U,V
+
+/* for (uint8_t i = 0; i < 4; ++i)
+ {
+ WriteFloatToVertices(0,i,0);
+ WriteFloatToVertices(0,i,1);
+ WriteFloatToVertices(0,i,2);
+ }
+*/
+ m_emitter->SetDirtyVBO();
+}
+
+void ParticleBase::Deactivate()
+{
+ m_emitter->SetDirtyVBO();
+ for (uint8_t i = 0; i < 4; ++i)
+ {
+ WriteFloatToVertices(0,i,0);
+ WriteFloatToVertices(0,i,1);
+ WriteFloatToVertices(0,i,2);
+ }
+}
+
+void ParticleBase::WriteFloatToVertices(float v, uint8_t vertexIndex, uint8_t offset)
+{
+ *(m_particleVobData+((STRIDE*vertexIndex)+offset)) = v;
+}
+
+void ParticleBase::WriteToVBO()
+{
+ WriteAgeToVBO();
+ WriteLifespanToVBO();
+ WriteRand1ToVBO();
+ WriteRand2ToVBO();
+}
+
/*
void ParticleBase::Activate()
{
@@ -67,7 +161,8 @@
ParticleEmitter::ParticleEmitter()
:m_maxParticles(50), m_age(0), m_emitDelay(0.01), m_lifespan(0),
m_particlesEmitted(0), m_particleMinLife(0.01), m_particleMaxLife(5),
- m_inactiveParticles(NULL), m_particles(NULL), GenerateParticlesClbk(NULL)
+ m_inactiveParticles(NULL), m_particles(NULL), GenerateParticlesClbk(NULL),
+ m_bufferID(0), m_dirtyVBO(false)
{
Init();
}
@@ -77,6 +172,8 @@
{
DestroyParticles();
+ if (m_bufferID > 0) { GLCALL( glDeleteBuffersARB(1, &m_bufferID) ); }
+
SAFE_DELETE(GenerateParticlesClbk);
// SAFE_DELETE(m_masterParticle);
}
@@ -86,18 +183,15 @@
{
MercuryNode::Init();
DestroyParticles();
-
- if (GenerateParticlesClbk) m_particles = (*GenerateParticlesClbk)(m_maxParticles);
- m_particles = new ParticleBase[m_maxParticles];
- m_inactiveParticles = m_particles;
- FillUnusedParticleList(m_particles, 0);
+
+ SetMaxParticleCount(m_maxParticles);
}
void ParticleEmitter::DestroyParticles()
{
- for (uint32_t i = 0; (i < m_maxParticles) && m_particles; ++i)
- RemoveChild(m_particles+i);
+/// for (uint32_t i = 0; (i < m_maxParticles) && m_particles; ++i)
+// RemoveChild(m_particles+i);
SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
}
@@ -123,22 +217,23 @@
m_inactiveParticles = p->m_nextParticle;
p->m_nextParticle = NULL;
p->Init();
+ p->Activate();
p->m_lifespan = m_particleMinLife;
p->m_lifespan += (rand()%(int(m_particleMaxLife*1000) - int(m_particleMinLife*1000)))/1000.0f;
- p->m_seed1 = rand()%100000;
- p->m_seed2 = rand()%100000;
+ p->m_rand1 = rand()%100000;
+ p->m_rand2 = rand()%100000;
// +((rand()%((m_particleMaxLife*1000)-(m_particleMinLife*1000)))/1000.0f);
- AddChild(p);
+// AddChild(p);
}
}
void ParticleEmitter::DeactivateParticle(ParticleBase* p)
{
// LOG.Write("Deactivate");
- RemoveChild(p);
+// RemoveChild(p);
if (!m_inactiveParticles)
{
m_inactiveParticles = p;
@@ -165,7 +260,7 @@
void ParticleEmitter::LoadFromXML(const XMLNode& node)
{
base::LoadFromXML(node);
-
+/*
XMLNode particleXML;
for (XMLNode n = node.Child(); n.IsValid(); n=n.NextNode())
if (n.Name() == "particle")
@@ -173,9 +268,82 @@
for (uint32_t i = 0; (i < m_maxParticles) && m_particles; ++i)
m_particles[i].LoadFromXML(particleXML);
+ */
}
+void ParticleEmitter::SetMaxParticleCount(uint16_t count)
+{
+ //3 floats for position
+ //1 age, 1 lifespan, 2 random
+ //7 floats total per particle
+ m_maxParticles = count;
+ m_vertexData.Allocate(m_maxParticles*ParticleBase::STRIDE*4);
+
+ SAFE_DELETE_ARRAY(m_particles);
+// if (GenerateParticlesClbk) m_particles = (*GenerateParticlesClbk)(m_maxParticles);
+ m_particles = new ParticleBase[m_maxParticles];
+ m_inactiveParticles = m_particles;
+ InitNewParticles(m_particles, 0, ParticleBase::STRIDE*4, m_vertexData.Buffer());
+}
+
+void ParticleEmitter::InitNewParticles(ParticleBase* p, uint32_t i, uint16_t vobStep, float* vob)
+{
+ if (p)
+ {
+ p->m_emitter = this;
+ p->m_particleVobData = vob;
+ p->Deactivate();
+ ++i;
+ if (i<m_maxParticles) p->m_nextParticle = m_particles+i;
+ InitNewParticles(p->m_nextParticle, i, vobStep, vob+vobStep);
+ }
+}
+
+void ParticleEmitter::Render(const MercuryMatrix& matrix)
+{
+ GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT) );
+ GLCALL( glDepthMask( false ) );
+ GLCALL( glDisable(GL_CULL_FACE) );
+
+ if (m_bufferID==0)
+ {
+ GLCALL( glGenBuffersARB(1, &m_bufferID) );
+ }
+
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferID) );
+ MercuryVBO::m_lastVBOrendered = this;
+
+ if (m_dirtyVBO)
+ {
+ m_dirtyVBO = false;
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STATIC_DRAW_ARB) );
+ }
+
+ GLCALL( glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) );
+
+ //do render stuff here
+// GLCALL( glDisableClientState(GL_TEXTURE_COORD_ARRAY) );
+ Texture::ApplyActiveTextures(ParticleBase::STRIDE*sizeof(float));
+
+ GLCALL( glEnableClientState(GL_VERTEX_ARRAY) );
+ GLCALL( glEnableClientState( GL_COLOR_ARRAY ) ); //used for attributes
+ GLCALL( glVertexPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 0*sizeof(float) ) ) );
+ GLCALL( glColorPointer(4, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 3*sizeof(float) ) ) );
+ GLCALL( glTexCoordPointer(3, GL_FLOAT, ParticleBase::STRIDE*sizeof(float), BUFFER_OFFSET( 7*sizeof(float) ) ) );
+
+// GLCALL( glDrawRangeElements(GL_QUADS, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL) );
+// GLCALL( glDrawElements(GL_QUADS, m_maxParticles*4, GL_UNSIGNED_BYTE, 0) );
+ GLCALL( glDrawArrays(GL_QUADS, 0, m_maxParticles*4) );
+
+ GLCALL( glPopClientAttrib() );
+
+ base::Render(matrix);
+
+ GLCALL( glPopAttrib() );
+
+}
+
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/modules/ParticleEmitter.h
===================================================================
--- Mercury2/modules/ParticleEmitter.h 2009-12-22 16:08:48 UTC (rev 632)
+++ Mercury2/modules/ParticleEmitter.h 2009-12-23 01:29:35 UTC (rev 633)
@@ -6,7 +6,7 @@
class ParticleEmitter;
-class ParticleBase : public MercuryNode
+class ParticleBase
{
public:
ParticleBase();
@@ -15,22 +15,32 @@
virtual void Init();
virtual void Update(float dTime);
- virtual void RecursiveRender();
+// virtual void RecursiveRender();
-// void Activate();
-// void Deactivate();
+ void Activate();
+ void Deactivate();
+ void WriteToVBO();
- GENRTTI( ParticleBase );
+// GENRTTI( ParticleBase );
private:
- CLASS_HELPERS( MercuryNode );
+// CLASS_HELPERS( MercuryNode );
+ static const uint8_t STRIDE = 9;
+
+ void WriteAgeToVBO();
+ void WriteLifespanToVBO();
+ void WriteRand1ToVBO();
+ void WriteRand2ToVBO();
+ void WriteFloatToVertices(float v, uint8_t vertexIndex, uint8_t offset);
+
friend class ParticleEmitter;
ParticleBase* m_nextParticle;
float m_age;
float m_lifespan;
- float m_seed1, m_seed2;
+ float m_rand1, m_rand2;
ParticleEmitter* m_emitter;
// MercuryNode* m_particleGraph;
+ float* m_particleVobData; //pointer to position in VBO
};
class ParticleEmitter : public MercuryNode
@@ -44,12 +54,19 @@
void DeactivateParticle(ParticleBase* p);
virtual void LoadFromXML(const XMLNode& node);
+ virtual void Render(const MercuryMatrix& matrix);
+ void SetMaxParticleCount(uint16_t count);
+ inline void SetDirtyVBO() { m_dirtyVBO=true; }
+
GENRTTI( ParticleEmitter );
private:
void DestroyParticles();
void ActivateParticle();
- void FillUnusedParticleList(ParticleBase* p, uint32_t);
+
+ void FillUnusedParticleList(ParticleBase* p, uint32_t i);
+ void InitNewParticles(ParticleBase* p, uint32_t i, uint16_t vobStep, float* vob);
+
CLASS_HELPERS( MercuryNode );
uint32_t m_maxParticles;
@@ -63,7 +80,11 @@
ParticleBase* m_particles;
Callback1R<uint32_t,ParticleBase*>* GenerateParticlesClbk;
+ AlignedBuffer<float> m_vertexData;
+ unsigned int m_bufferID;
+ bool m_dirtyVBO;
+
// MercuryNode* m_masterParticle;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-22 16:08:59
|
Revision: 632
http://hgengine.svn.sourceforge.net/hgengine/?rev=632&view=rev
Author: axlecrusher
Date: 2009-12-22 16:08:48 +0000 (Tue, 22 Dec 2009)
Log Message:
-----------
add windows mouse handling
Modified Paths:
--------------
Mercury2/src/MercuryWindow.cpp
Mercury2/src/MercuryWindow.h
Mercury2/src/Win32Window.cpp
Mercury2/src/Win32Window.h
Mercury2/src/X11Window.cpp
Mercury2/src/X11Window.h
Modified: Mercury2/src/MercuryWindow.cpp
===================================================================
--- Mercury2/src/MercuryWindow.cpp 2009-12-21 20:08:27 UTC (rev 631)
+++ Mercury2/src/MercuryWindow.cpp 2009-12-22 16:08:48 UTC (rev 632)
@@ -2,7 +2,7 @@
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_bGrabbed(true),m_iLastMouseX(0),m_iLastMouseY(0),m_inFocus(false)
{
}
Modified: Mercury2/src/MercuryWindow.h
===================================================================
--- Mercury2/src/MercuryWindow.h 2009-12-21 20:08:27 UTC (rev 631)
+++ Mercury2/src/MercuryWindow.h 2009-12-22 16:08:48 UTC (rev 632)
@@ -34,6 +34,9 @@
void SetGrabbedMouseMode( bool bGrabbed ) { m_bGrabbed = bGrabbed; }
bool GetGrabbedMouseMode( ) { return m_bGrabbed; }
+
+ inline bool InFocus() const { return m_inFocus; }
+
protected:
static Callback0R< MercuryWindow* > genWindowClbk;
static MercuryWindow* m_windowInstance;
@@ -43,6 +46,11 @@
uint8_t m_bits, m_depthBits;
bool m_fullscreen;
bool m_bGrabbed;
+
+ int m_iLastMouseX;
+ int m_iLastMouseY;
+
+ bool m_inFocus;
};
#endif
Modified: Mercury2/src/Win32Window.cpp
===================================================================
--- Mercury2/src/Win32Window.cpp 2009-12-21 20:08:27 UTC (rev 631)
+++ Mercury2/src/Win32Window.cpp 2009-12-22 16:08:48 UTC (rev 632)
@@ -1,9 +1,11 @@
#include <Win32Window.h>
+//#include <Windowsx.h>
#include <GLHeaders.h>
-#include <MercuryInput.h>
+#include <MercuryInput.h>
LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); //Window callback
Callback0R< MercuryWindow* > MercuryWindow::genWindowClbk(Win32Window::GenWin32Window); //Register window generation callback
+bool ACTIVE = false;
MercuryWindow* Win32Window::GenWin32Window()
{
@@ -20,8 +22,8 @@
}
Win32Window::Win32Window(const MString& title, int width, int height, int bits, int depthBits, bool fullscreen)
- :m_hwnd(NULL), m_hdc(NULL), m_hglrc(NULL), m_hInstance(NULL), m_className(NULL), m_windowAtom(NULL), m_winTitle(NULL),
- MercuryWindow(title, width, height, bits, depthBits, fullscreen)
+ :m_hwnd(NULL), m_hdc(NULL), m_hglrc(NULL), m_hInstance(NULL), m_className(NULL), m_windowAtom(NULL), m_winTitle(NULL),m_cX(0),
+ m_cY(0),MercuryWindow(title, width, height, bits, depthBits, fullscreen)
{
m_className = (WCHAR*)StringToLPCTSTR("Mercury Render Window");
m_winTitle = (WCHAR*)StringToLPCTSTR(title);
@@ -191,44 +193,62 @@
{
MSG message;
+ if ( InFocus() != ACTIVE )
+ {
+ m_inFocus = ACTIVE;
+ ShowCursor(!m_inFocus);
+ PointerToCenter();
+ }
+
while (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
- switch( message.message )
+ if ( InFocus() )
{
- case WM_QUIT:
- return false;
- case WM_KEYDOWN:
+ switch( message.message )
{
- if ( IsKeyRepeat(message.lParam) ) break;
-// printf( "%d\n", message.lParam>>16 );
- KeyboardInput::ProcessKeyInput( ConvertScancode( message.lParam ), true, false);
- }
- break;
- case WM_KEYUP:
- {
- if ( IsKeyRepeat(message.lParam) ) break;
-// printf( "%d\n", message.lParam>>16 );
- KeyboardInput::ProcessKeyInput( ConvertScancode( message.lParam ), false, false);
- }
- break;
- case WM_MOUSEMOVE:
- break;
- case WM_LBUTTONDOWN:
- break;
- case WM_LBUTTONUP:
- break;
- case WM_RBUTTONDOWN:
- break;
- case WM_RBUTTONUP:
- break;
- case WM_MBUTTONDOWN:
- break;
- case WM_MBUTTONUP:
- break;
- case 0x020A: //Do nothing (at least now) It's a mouse wheel!
- break;
+ case WM_KEYDOWN:
+ {
+ if ( IsKeyRepeat(message.lParam) ) break;
+ KeyboardInput::ProcessKeyInput( ConvertScancode( message.lParam ), true, false);
+ }
+ break;
+ case WM_KEYUP:
+ {
+ if ( IsKeyRepeat(message.lParam) ) break;
+ KeyboardInput::ProcessKeyInput( ConvertScancode( message.lParam ), false, false);
+ }
+ break;
+ case WM_MOUSEMOVE:
+ {
+ POINT pos;
+ GetCursorPos(&pos);
+ if (pos.x!=m_cX || pos.y!=m_cY) //ignore the resets to center
+ {
+ int dx = m_cX - pos.x;
+ int dy = m_cY - pos.y;
+ m_iLastMouseX += dx;
+ m_iLastMouseY += dy;
+ MouseInput::ProcessMouseInput(dx, dy, message.wParam&MK_LBUTTON, message.wParam&MK_RBUTTON, message.wParam&MK_MBUTTON, 0, 0);
+ PointerToCenter();
+ }
+ }
+ break;
+ case WM_LBUTTONDOWN:
+ break;
+ case WM_LBUTTONUP:
+ break;
+ case WM_RBUTTONDOWN:
+ break;
+ case WM_RBUTTONUP:
+ break;
+ case WM_MBUTTONDOWN:
+ break;
+ case WM_MBUTTONUP:
+ break;
+ case 0x020A: //Do nothing (at least now) It's a mouse wheel!
+ break;
+ }
}
-
TranslateMessage(&message); // Translate The Message
DispatchMessage(&message); // Dispatch The Message
}
@@ -246,127 +266,139 @@
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
-bool Win32Window::IsKeyRepeat(uint32_t c)
-{
-// printf("count %d\n", (c&65535));
- return (c&65535) > 1;
-}
+bool Win32Window::IsKeyRepeat(uint32_t c)
+{
+// printf("count %d\n", (c&65535));
+ return (c&65535) > 1;
+}
-short Win32Window::ConvertScancode( uint32_t scanin )
-{
-// Specifies the scan code. The value depends on the OEM.
- scanin = (scanin>>16)&511;
- switch( scanin )
- {
- case 1: return 27; //esc
- case 0: return '0';
- case 41: return 97; //`
- case 14: return 8; //backspace
- case 87: return 292; //F11
- case 88: return 293; //F12
- case 12: return 45; //-
- case 13: return 61; //=
- case 43: return 92; //backslash
- case 15: return 9; //tab
- case 58: return 15; //Caps lock
- case 42: return 160; //[lshift]
- case 54: return 161; //[rshift]
-
- case 30: return 'a';
- case 48: return 'b';
- case 46: return 'c';
- case 32: return 'd';
- case 18: return 'e';
- case 33: return 'f';
- case 34: return 'g';
- case 35: return 'h';
- case 23: return 'i';
- case 36: return 'j';
- case 37: return 'k';
- case 38: return 'l';
- case 50: return 'm';
- case 49: return 'n';
- case 24: return 'o';
- case 25: return 'p';
- case 16: return 'q';
- case 19: return 'r';
- case 31: return 's';
- case 20: return 't';
- case 22: return 'u';
- case 47: return 'v';
- case 17: return 'w';
- case 45: return 'x';
- case 21: return 'y';
- case 44: return 'z';
-
- case 39: return 59; //;
- case 40: return 39; //'
- case 51: return 44; //,
- case 52: return 46; //.
- case 53: return 47; // /
-
- case 328: return 273; //arrow keys: up
- case 331: return 276; //arrow keys: left
- case 333: return 275; //arrow keys: right
- case 336: return 274; //arrow keys: down
-//STOPPED HERE
- case 29: return 162; //left ctrl
- case 347: return 91; //left super (aka win)
- case 64: return 164; //left alt
- case 57: return 32; //space bar
- case 108: return 165; //right alt
- case 134: return 91; //right super (aka win)
- case 349: return 93; //menu
- case 285: return 268; //right control
-
- case 107: return 316; //Print Screen
- //case 78: scroll lock
- case 127: return 19; //Pause
- case 118: return 277; //Insert
- case 110: return 278; //Home
- case 112: return 280; //Page Up
- case 119: return 127; //Delete
- case 115: return 279; //End
- case 117: return 181; //Page Down
-
- //case 77: Num Lock (not mapped)
- case 106: return 267; //Keypad /
- case 63: return 268; //Keypad *
- case 82: return 269; //Keypad -
- case 79: return 263; //Keypad 7
- case 80: return 264; //Keypad 8
- case 81: return 265; //Keypad 9
- case 86: return 270; //Keypad +
- case 83: return 260; //Keypad 4
- case 84: return 261; //Keypad 5
- case 85: return 262; //Keypad 6
-// case 87: return 257; //Keypad 1
-// case 88: return 258; //Keypad 2
- case 89: return 259; //Keypad 3
-// case 36: //Enter
- case 104: return 13; //Keypad enter
- case 90: return 260; //Keypad 0
- case 91: return 266; //Keypad .
-
- default:
- // numbers
- if( scanin >= 10 && scanin <= 18 )
- return scanin + ( (short)'1' - 10 );
- // f1 -- f10
- if( scanin >= 67 && scanin <= 76 )
- return scanin + ( 282 - 67 );
- return scanin;
- }
+void Win32Window::PointerToCenter()
+{
+ RECT rect;
+ GetWindowRect(m_hwnd, &rect);
+ m_cX = rect.left+m_width/2;
+ m_cY = rect.top+m_height/2;
+ SetCursorPos(m_cX, m_cY);
}
+short Win32Window::ConvertScancode( uint32_t scanin )
+{
+// Specifies the scan code. The value depends on the OEM.
+ scanin = (scanin>>16)&511;
+ switch( scanin )
+ {
+ case 1: return 27; //esc
+ case 0: return '0';
+ case 41: return 97; //`
+ case 14: return 8; //backspace
+ case 87: return 292; //F11
+ case 88: return 293; //F12
+ case 12: return 45; //-
+ case 13: return 61; //=
+ case 43: return 92; //backslash
+ case 15: return 9; //tab
+ case 58: return 15; //Caps lock
+ case 42: return 160; //[lshift]
+ case 54: return 161; //[rshift]
+
+ case 30: return 'a';
+ case 48: return 'b';
+ case 46: return 'c';
+ case 32: return 'd';
+ case 18: return 'e';
+ case 33: return 'f';
+ case 34: return 'g';
+ case 35: return 'h';
+ case 23: return 'i';
+ case 36: return 'j';
+ case 37: return 'k';
+ case 38: return 'l';
+ case 50: return 'm';
+ case 49: return 'n';
+ case 24: return 'o';
+ case 25: return 'p';
+ case 16: return 'q';
+ case 19: return 'r';
+ case 31: return 's';
+ case 20: return 't';
+ case 22: return 'u';
+ case 47: return 'v';
+ case 17: return 'w';
+ case 45: return 'x';
+ case 21: return 'y';
+ case 44: return 'z';
+
+ case 39: return 59; //;
+ case 40: return 39; //'
+ case 51: return 44; //,
+ case 52: return 46; //.
+ case 53: return 47; // /
+
+ case 328: return 273; //arrow keys: up
+ case 331: return 276; //arrow keys: left
+ case 333: return 275; //arrow keys: right
+ case 336: return 274; //arrow keys: down
+//STOPPED HERE
+ case 29: return 162; //left ctrl
+ case 347: return 91; //left super (aka win)
+ case 64: return 164; //left alt
+ case 57: return 32; //space bar
+ case 108: return 165; //right alt
+ case 134: return 91; //right super (aka win)
+ case 349: return 93; //menu
+ case 285: return 268; //right control
+
+ case 107: return 316; //Print Screen
+ //case 78: scroll lock
+ case 127: return 19; //Pause
+ case 118: return 277; //Insert
+ case 110: return 278; //Home
+ case 112: return 280; //Page Up
+ case 119: return 127; //Delete
+ case 115: return 279; //End
+ case 117: return 181; //Page Down
+
+ //case 77: Num Lock (not mapped)
+ case 106: return 267; //Keypad /
+ case 63: return 268; //Keypad *
+ case 82: return 269; //Keypad -
+ case 79: return 263; //Keypad 7
+ case 80: return 264; //Keypad 8
+ case 81: return 265; //Keypad 9
+ case 86: return 270; //Keypad +
+ case 83: return 260; //Keypad 4
+ case 84: return 261; //Keypad 5
+ case 85: return 262; //Keypad 6
+// case 87: return 257; //Keypad 1
+// case 88: return 258; //Keypad 2
+ case 89: return 259; //Keypad 3
+// case 36: //Enter
+ case 104: return 13; //Keypad enter
+ case 90: return 260; //Keypad 0
+ case 91: return 266; //Keypad .
+
+ default:
+ // numbers
+ if( scanin >= 10 && scanin <= 18 )
+ return scanin + ( (short)'1' - 10 );
+ // f1 -- f10
+ if( scanin >= 67 && scanin <= 76 )
+ return scanin + ( 282 - 67 );
+ return scanin;
+ }
+}
+
LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CLOSE:
- {
- exit(1);
- }
+ exit(1);
+ break;
+ case WM_ACTIVATE:
+ ACTIVE = LOWORD(wParam)!=WA_INACTIVE;
+// return 0;
+ break;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
Modified: Mercury2/src/Win32Window.h
===================================================================
--- Mercury2/src/Win32Window.h 2009-12-21 20:08:27 UTC (rev 631)
+++ Mercury2/src/Win32Window.h 2009-12-22 16:08:48 UTC (rev 632)
@@ -17,17 +17,19 @@
static MercuryWindow* GenWin32Window();
virtual void* GetProcAddress(const MString& x);
virtual void Clear();
- static short ConvertScancode( uint32_t scanin );
+ static short ConvertScancode( uint32_t scanin );
private:
- bool IsKeyRepeat(uint32_t c);
-
+ bool IsKeyRepeat(uint32_t c);
+
void GenWindow();
void GenWinClass();
void SetPixelType();
void CreateRenderingContext();
void GenPixelType();
+ void PointerToCenter();
+
HWND m_hwnd; //window handle
HDC m_hdc; //device handle
PIXELFORMATDESCRIPTOR m_pfd; //pixel format descriptor
@@ -40,6 +42,8 @@
MScopedArray< WCHAR > m_className;
MScopedArray< WCHAR > m_winTitle;
+
+ uint16_t m_cX, m_cY;
};
#endif
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2009-12-21 20:08:27 UTC (rev 631)
+++ Mercury2/src/X11Window.cpp 2009-12-22 16:08:48 UTC (rev 632)
@@ -231,7 +231,7 @@
bool X11Window::PumpMessages()
{
- static bool inFocus = false;
+// static bool inFocus = false;
XEvent event;
while ( XPending(m_display) > 0)
{
@@ -265,14 +265,14 @@
case FocusOut:
{
//XFocusChangeEvent*e = (XFocusChangeEvent*)&event;
- inFocus = (event.type == FocusIn);
- if (inFocus && m_bGrabbed ) XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2);
+ 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);
break;
}
}
//The events below only get processed if window is in focus
- if ( !inFocus ) continue;
+ if ( !m_inFocus ) continue;
switch (event.type)
{
case ButtonPress:
Modified: Mercury2/src/X11Window.h
===================================================================
--- Mercury2/src/X11Window.h 2009-12-21 20:08:27 UTC (rev 631)
+++ Mercury2/src/X11Window.h 2009-12-22 16:08:48 UTC (rev 632)
@@ -28,9 +28,6 @@
GLXContext m_renderCtx;
Window m_window;
Atom m_wmDeleteMessage;
-
- int m_iLastMouseX;
- int m_iLastMouseY;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-21 20:08:34
|
Revision: 631
http://hgengine.svn.sourceforge.net/hgengine/?rev=631&view=rev
Author: axlecrusher
Date: 2009-12-21 20:08:27 +0000 (Mon, 21 Dec 2009)
Log Message:
-----------
windows keyboard input
Modified Paths:
--------------
Mercury2/src/Win32Window.cpp
Mercury2/src/Win32Window.h
Modified: Mercury2/src/Win32Window.cpp
===================================================================
--- Mercury2/src/Win32Window.cpp 2009-12-21 19:10:26 UTC (rev 630)
+++ Mercury2/src/Win32Window.cpp 2009-12-21 20:08:27 UTC (rev 631)
@@ -1,5 +1,6 @@
#include <Win32Window.h>
#include <GLHeaders.h>
+#include <MercuryInput.h>
LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); //Window callback
Callback0R< MercuryWindow* > MercuryWindow::genWindowClbk(Win32Window::GenWin32Window); //Register window generation callback
@@ -197,9 +198,18 @@
case WM_QUIT:
return false;
case WM_KEYDOWN:
- printf( "%d\n", message.lParam>>16 );
+ {
+ if ( IsKeyRepeat(message.lParam) ) break;
+// printf( "%d\n", message.lParam>>16 );
+ KeyboardInput::ProcessKeyInput( ConvertScancode( message.lParam ), true, false);
+ }
break;
case WM_KEYUP:
+ {
+ if ( IsKeyRepeat(message.lParam) ) break;
+// printf( "%d\n", message.lParam>>16 );
+ KeyboardInput::ProcessKeyInput( ConvertScancode( message.lParam ), false, false);
+ }
break;
case WM_MOUSEMOVE:
break;
@@ -236,7 +246,119 @@
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
}
+bool Win32Window::IsKeyRepeat(uint32_t c)
+{
+// printf("count %d\n", (c&65535));
+ return (c&65535) > 1;
+}
+short Win32Window::ConvertScancode( uint32_t scanin )
+{
+// Specifies the scan code. The value depends on the OEM.
+ scanin = (scanin>>16)&511;
+ switch( scanin )
+ {
+ case 1: return 27; //esc
+ case 0: return '0';
+ case 41: return 97; //`
+ case 14: return 8; //backspace
+ case 87: return 292; //F11
+ case 88: return 293; //F12
+ case 12: return 45; //-
+ case 13: return 61; //=
+ case 43: return 92; //backslash
+ case 15: return 9; //tab
+ case 58: return 15; //Caps lock
+ case 42: return 160; //[lshift]
+ case 54: return 161; //[rshift]
+
+ case 30: return 'a';
+ case 48: return 'b';
+ case 46: return 'c';
+ case 32: return 'd';
+ case 18: return 'e';
+ case 33: return 'f';
+ case 34: return 'g';
+ case 35: return 'h';
+ case 23: return 'i';
+ case 36: return 'j';
+ case 37: return 'k';
+ case 38: return 'l';
+ case 50: return 'm';
+ case 49: return 'n';
+ case 24: return 'o';
+ case 25: return 'p';
+ case 16: return 'q';
+ case 19: return 'r';
+ case 31: return 's';
+ case 20: return 't';
+ case 22: return 'u';
+ case 47: return 'v';
+ case 17: return 'w';
+ case 45: return 'x';
+ case 21: return 'y';
+ case 44: return 'z';
+
+ case 39: return 59; //;
+ case 40: return 39; //'
+ case 51: return 44; //,
+ case 52: return 46; //.
+ case 53: return 47; // /
+
+ case 328: return 273; //arrow keys: up
+ case 331: return 276; //arrow keys: left
+ case 333: return 275; //arrow keys: right
+ case 336: return 274; //arrow keys: down
+//STOPPED HERE
+ case 29: return 162; //left ctrl
+ case 347: return 91; //left super (aka win)
+ case 64: return 164; //left alt
+ case 57: return 32; //space bar
+ case 108: return 165; //right alt
+ case 134: return 91; //right super (aka win)
+ case 349: return 93; //menu
+ case 285: return 268; //right control
+
+ case 107: return 316; //Print Screen
+ //case 78: scroll lock
+ case 127: return 19; //Pause
+ case 118: return 277; //Insert
+ case 110: return 278; //Home
+ case 112: return 280; //Page Up
+ case 119: return 127; //Delete
+ case 115: return 279; //End
+ case 117: return 181; //Page Down
+
+ //case 77: Num Lock (not mapped)
+ case 106: return 267; //Keypad /
+ case 63: return 268; //Keypad *
+ case 82: return 269; //Keypad -
+ case 79: return 263; //Keypad 7
+ case 80: return 264; //Keypad 8
+ case 81: return 265; //Keypad 9
+ case 86: return 270; //Keypad +
+ case 83: return 260; //Keypad 4
+ case 84: return 261; //Keypad 5
+ case 85: return 262; //Keypad 6
+// case 87: return 257; //Keypad 1
+// case 88: return 258; //Keypad 2
+ case 89: return 259; //Keypad 3
+// case 36: //Enter
+ case 104: return 13; //Keypad enter
+ case 90: return 260; //Keypad 0
+ case 91: return 266; //Keypad .
+
+ default:
+ // numbers
+ if( scanin >= 10 && scanin <= 18 )
+ return scanin + ( (short)'1' - 10 );
+ // f1 -- f10
+ if( scanin >= 67 && scanin <= 76 )
+ return scanin + ( 282 - 67 );
+ return scanin;
+ }
+}
+
LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
Modified: Mercury2/src/Win32Window.h
===================================================================
--- Mercury2/src/Win32Window.h 2009-12-21 19:10:26 UTC (rev 630)
+++ Mercury2/src/Win32Window.h 2009-12-21 20:08:27 UTC (rev 631)
@@ -17,8 +17,11 @@
static MercuryWindow* GenWin32Window();
virtual void* GetProcAddress(const MString& x);
virtual void Clear();
+ static short ConvertScancode( uint32_t scanin );
private:
+ bool IsKeyRepeat(uint32_t c);
+
void GenWindow();
void GenWinClass();
void SetPixelType();
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-14 22:00:29
|
Revision: 629
http://hgengine.svn.sourceforge.net/hgengine/?rev=629&view=rev
Author: axlecrusher
Date: 2009-12-14 22:00:23 +0000 (Mon, 14 Dec 2009)
Log Message:
-----------
fire shader
Added Paths:
-----------
Mercury2/Themes/default/Graphic/FireParticles.frag
Mercury2/Themes/default/Graphic/FireParticles.vert
Added: Mercury2/Themes/default/Graphic/FireParticles.frag
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.frag (rev 0)
+++ Mercury2/Themes/default/Graphic/FireParticles.frag 2009-12-14 22:00:23 UTC (rev 629)
@@ -0,0 +1,22 @@
+uniform vec4 HG_ParticleTime;
+uniform sampler2D HG_Texture0;
+
+void main()
+{
+ float pComplete = (HG_ParticleTime.x/HG_ParticleTime.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);
+
+ //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
+
+ //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
+
+ gl_FragData[0] = texture2D(HG_Texture0, gl_TexCoord[0].st)*color;
+ gl_FragData[0].a *= 1.0-(HG_ParticleTime.x/HG_ParticleTime.y);
+}
Added: Mercury2/Themes/default/Graphic/FireParticles.vert
===================================================================
--- Mercury2/Themes/default/Graphic/FireParticles.vert (rev 0)
+++ Mercury2/Themes/default/Graphic/FireParticles.vert 2009-12-14 22:00:23 UTC (rev 629)
@@ -0,0 +1,61 @@
+uniform vec4 HG_ParticleTime;
+uniform vec4 HG_EyePos;
+uniform vec4 HG_LookVector;
+uniform mat4 HG_ModelMatrix;
+uniform mat4 HG_WorldMatrix;
+uniform mat4 HG_ViewMatrix;
+varying vec3 angleC;
+
+mat4 glRotate(float angle, vec3 axis)
+{
+ axis=normalize(axis);
+ mat4 m = mat4(0);
+ float c = cos(angle);
+ float s = sin(angle);
+ float nc = 1.0-c;
+
+ m[0][0] = (axis.x*axis.x*nc)+c;
+ m[0][1] = (axis.x*axis.y*nc)-(axis.z*s);
+ m[0][2] = (axis.x*axis.z*nc)+(axis.y*s);
+
+ m[1][0] = (axis.y*axis.x*nc)+(axis.z*s);
+ m[1][1] = (axis.y*axis.y*nc)+c;
+ m[1][2] = (axis.y*axis.z*nc)-(axis.x*s);
+
+ m[2][0] = (axis.x*axis.z*nc)-(axis.y*s);
+ m[2][1] = (axis.y*axis.z*nc)+(axis.x*s);
+ m[2][2] = (axis.z*axis.z*nc)+c;
+
+ m[3][3] = 1.0;
+
+ return m;
+}
+
+mat4 Billboard(vec3 pos)
+{
+ vec3 objToEye = (HG_EyePos - HG_ModelMatrix*vec4(pos,1)).xyz;
+// objToEye.y = 0.0;
+
+ vec3 objLookAt = normalize((HG_ModelMatrix * vec4(0,0,-1,0)).xyz);
+ objToEye = normalize(objToEye);
+
+ vec3 up = cross(objLookAt, objToEye);
+ float angleCos = dot(objLookAt, objToEye);
+
+ return glRotate(-acos(angleCos), up);
+}
+
+void main()
+{
+ vec4 pos = vec4(1.0);
+ pos.y = 0.30*(HG_ParticleTime.x*HG_ParticleTime.x);
+ pos.x = 0.40*((HG_ParticleTime.z-50000.0)/50000.0)*HG_ParticleTime.x; //rand num
+ pos.z = 0.40*((HG_ParticleTime.w-50000.0)/50000.0)*HG_ParticleTime.x; //rand num
+
+ mat4 m = Billboard(pos.xyz);
+ m[3].xyz = pos.xyz;
+
+ gl_Position = gl_ProjectionMatrix *HG_ViewMatrix *HG_ModelMatrix *m* gl_Vertex;
+
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-14 20:27:13
|
Revision: 628
http://hgengine.svn.sourceforge.net/hgengine/?rev=628&view=rev
Author: axlecrusher
Date: 2009-12-14 20:27:01 +0000 (Mon, 14 Dec 2009)
Log Message:
-----------
updates for particles
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/Themes/default/Graphic/test.frag
Mercury2/Themes/default/Graphic/test.vert
Mercury2/modules.xml
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-12-14 20:17:42 UTC (rev 627)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-14 20:27:01 UTC (rev 628)
@@ -17,6 +17,7 @@
<asset type="texture" file="MODEL:map.png"/>
<asset type="terrain" file="MODEL:map.hgmdl" />
</node>
+
<node type="mercurynode" name="lampForest" >
<node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" >
<node type="mercurynode" name="lamp">
@@ -24,12 +25,24 @@
<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="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>
+ </node> -->
+<!-- <asset type="StateChanger" file="DepthWrite:0" />
+ state changer needs some work for proper on and off.
+ until then had code it for all particles -->
+ <node type="particleemitter" texture="GRAPHIC:flame.png">
+ <asset type="texture" file="GRAPHIC:flame.png"/>
+ <asset type="shader" file="GRAPHIC:FireParticles"/>
+ <particle>
+ <node type="transformnode" scalex="0.075" scaley="0.075" scalez="0.075" alphaPath="false">
+ <asset type="quad"/>
+ </node>
+ </particle>
</node>
</node>
<node type="transformnode" movx="1" fallback="lamprow.lamp" />
Modified: Mercury2/Themes/default/Graphic/test.frag
===================================================================
--- Mercury2/Themes/default/Graphic/test.frag 2009-12-14 20:17:42 UTC (rev 627)
+++ Mercury2/Themes/default/Graphic/test.frag 2009-12-14 20:27:01 UTC (rev 628)
@@ -1,4 +1,6 @@
+varying vec3 color;
+
void main()
{
- gl_FragColor = vec4( 1., 0., 1., 1. );
-}
\ No newline at end of file
+ gl_FragColor = vec4( color, 1. );
+}
Modified: Mercury2/Themes/default/Graphic/test.vert
===================================================================
--- Mercury2/Themes/default/Graphic/test.vert 2009-12-14 20:17:42 UTC (rev 627)
+++ Mercury2/Themes/default/Graphic/test.vert 2009-12-14 20:27:01 UTC (rev 628)
@@ -1,4 +1,14 @@
+varying vec3 color;
+
+uniform vec4 HG_EyePos;
+uniform mat4 HG_ModelMatrix;
+
void main()
{
gl_Position = ftransform();
-}
\ No newline at end of file
+ color = vec3(0,0,1);
+
+ vec3 v = normalize(HG_EyePos - (HG_ModelMatrix*vec4(0,0,0,1))).xyz;
+
+ color = (v+1.0)*0.5;
+}
Modified: Mercury2/modules.xml
===================================================================
--- Mercury2/modules.xml 2009-12-14 20:17:42 UTC (rev 627)
+++ Mercury2/modules.xml 2009-12-14 20:27:01 UTC (rev 628)
@@ -3,5 +3,6 @@
<Module src="modules/BillboardNode.cpp" obj="modules/BillboardNode" func="InstallBillboardNode" class="BillboardNode" />
<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/ParticleEmitter.cpp" obj="modules/ParticleEmitter" func="InstallParticleEmitter" class="ParticleEmitter"/>
<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: <axl...@us...> - 2009-12-14 20:17:48
|
Revision: 627
http://hgengine.svn.sourceforge.net/hgengine/?rev=627&view=rev
Author: axlecrusher
Date: 2009-12-14 20:17:42 +0000 (Mon, 14 Dec 2009)
Log Message:
-----------
add particle emitter
Modified Paths:
--------------
Mercury2/modules/Makefile
Added Paths:
-----------
Mercury2/modules/ParticleEmitter.cpp
Mercury2/modules/ParticleEmitter.h
Modified: Mercury2/modules/Makefile
===================================================================
--- Mercury2/modules/Makefile 2009-12-14 20:16:40 UTC (rev 626)
+++ Mercury2/modules/Makefile 2009-12-14 20:17:42 UTC (rev 627)
@@ -2,7 +2,7 @@
CXXFLAGS=${CFLAGS}
LDFLAGS=-shared
-all : BillboardNode.so TextNode.so Terrain.so TextPlate.so Cu2.so
+all : BillboardNode.so TextNode.so Terrain.so TextPlate.so ParticleEmitter.so Cu2.so
clean :
rm -rf *~ *.o *.so
Added: Mercury2/modules/ParticleEmitter.cpp
===================================================================
--- Mercury2/modules/ParticleEmitter.cpp (rev 0)
+++ Mercury2/modules/ParticleEmitter.cpp 2009-12-14 20:17:42 UTC (rev 627)
@@ -0,0 +1,209 @@
+#include <ParticleEmitter.h>
+#include <Shader.h>
+#include <GLHeaders.h>
+
+//REGISTER_NODE_TYPE(ParticleBase);
+REGISTER_NODE_TYPE(ParticleEmitter);
+
+
+ParticleBase::ParticleBase()
+ :m_nextParticle(NULL), m_age(0), m_lifespan(0)
+{
+}
+
+ParticleBase::~ParticleBase()
+{
+// m_children.clear();
+}
+
+void ParticleBase::Init()
+{
+ base::Init();
+ m_age = 0;
+// m_lifespan = (rand()%5000)/1000.f;
+// LOG.Write("init particle");
+}
+
+void ParticleBase::Update(float dTime)
+{
+ base::Update(dTime);
+
+ m_age += dTime;
+ if (m_age >= m_lifespan) m_emitter->DeactivateParticle(this);
+}
+
+void ParticleBase::RecursiveRender()
+{
+ ShaderAttribute sa;
+ sa.type = ShaderAttribute::TYPE_FLOATV4;
+ sa.value.fFloatV4[0] = m_age;
+ sa.value.fFloatV4[1] = m_lifespan;
+ sa.value.fFloatV4[2] = m_seed1;
+ sa.value.fFloatV4[3] = m_seed2;
+ Shader::SetAttribute("HG_ParticleTime", sa);
+
+ GLCALL( glPushAttrib(GL_ENABLE_BIT|GL_DEPTH_BUFFER_BIT) );
+ GLCALL( glDepthMask( false ) );
+ GLCALL( glDisable(GL_CULL_FACE) );
+
+ base::RecursiveRender();
+
+ GLCALL( glPopAttrib() );
+}
+/*
+void ParticleBase::Activate()
+{
+ LOG.Write("Activate");
+ m_emitter->AddChild(this);
+}
+
+void ParticleBase::Deactivate()
+{
+ LOG.Write("Deactivate");
+ m_emitter->RemoveChild(this);
+ m_emitter->DeactivateParticle(this);
+}
+*/
+ParticleEmitter::ParticleEmitter()
+ :m_maxParticles(50), m_age(0), m_emitDelay(0.01), m_lifespan(0),
+ m_particlesEmitted(0), m_particleMinLife(0.01), m_particleMaxLife(5),
+ m_inactiveParticles(NULL), m_particles(NULL), GenerateParticlesClbk(NULL)
+{
+ Init();
+}
+
+
+ParticleEmitter::~ParticleEmitter()
+{
+ DestroyParticles();
+
+ SAFE_DELETE(GenerateParticlesClbk);
+// SAFE_DELETE(m_masterParticle);
+}
+
+
+void ParticleEmitter::Init()
+{
+ MercuryNode::Init();
+ DestroyParticles();
+
+ if (GenerateParticlesClbk) m_particles = (*GenerateParticlesClbk)(m_maxParticles);
+ m_particles = new ParticleBase[m_maxParticles];
+ m_inactiveParticles = m_particles;
+ FillUnusedParticleList(m_particles, 0);
+}
+
+
+void ParticleEmitter::DestroyParticles()
+{
+ for (uint32_t i = 0; (i < m_maxParticles) && m_particles; ++i)
+ RemoveChild(m_particles+i);
+ SAFE_DELETE_ARRAY(m_particles); //do we need to destroy each element????
+}
+
+void ParticleEmitter::Update(float dTime)
+{
+ m_age += dTime;
+
+ /* create particles until we meet the total number of
+ particles possible in terms of the age of the emitter */
+ while (((m_age-(m_particlesEmitted*m_emitDelay)) > m_emitDelay) && (m_emitDelay>0))
+ {
+// LOG.Write("Emit");
+ ++m_particlesEmitted; //always increment even if the maximum number of particles exist
+ ActivateParticle();
+ }
+}
+
+void ParticleEmitter::ActivateParticle()
+{
+ if (m_inactiveParticles)
+ {
+ ParticleBase* p = m_inactiveParticles;
+ m_inactiveParticles = p->m_nextParticle;
+ p->m_nextParticle = NULL;
+ p->Init();
+
+
+ p->m_lifespan = m_particleMinLife;
+ 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);
+
+ AddChild(p);
+ }
+}
+
+void ParticleEmitter::DeactivateParticle(ParticleBase* p)
+{
+// LOG.Write("Deactivate");
+ RemoveChild(p);
+ if (!m_inactiveParticles)
+ {
+ m_inactiveParticles = p;
+ }
+ else
+ {
+ ParticleBase* ip = m_inactiveParticles;
+ while (ip->m_nextParticle) ip = ip->m_nextParticle;
+ ip->m_nextParticle = p;
+ }
+}
+
+void ParticleEmitter::FillUnusedParticleList(ParticleBase* p, uint32_t i)
+{
+ if (p)
+ {
+ p->m_emitter = this;
+ ++i;
+ if (i<m_maxParticles) p->m_nextParticle = m_particles+i;
+ FillUnusedParticleList(p->m_nextParticle, i);
+ }
+}
+
+void ParticleEmitter::LoadFromXML(const XMLNode& node)
+{
+ base::LoadFromXML(node);
+
+ XMLNode particleXML;
+ for (XMLNode n = node.Child(); n.IsValid(); n=n.NextNode())
+ if (n.Name() == "particle")
+ particleXML = n;
+
+ for (uint32_t i = 0; (i < m_maxParticles) && m_particles; ++i)
+ m_particles[i].LoadFromXML(particleXML);
+}
+
+
+/****************************************************************************
+ * 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/modules/ParticleEmitter.h
===================================================================
--- Mercury2/modules/ParticleEmitter.h (rev 0)
+++ Mercury2/modules/ParticleEmitter.h 2009-12-14 20:17:42 UTC (rev 627)
@@ -0,0 +1,102 @@
+#ifndef PARTICLEEMITTER_H
+#define PARTICLEEMITTER_H
+
+#include <MercuryNode.h>
+#include <Callback.h>
+
+class ParticleEmitter;
+
+class ParticleBase : public MercuryNode
+{
+ public:
+ ParticleBase();
+ ~ParticleBase();
+
+ virtual void Init();
+ virtual void Update(float dTime);
+
+ virtual void RecursiveRender();
+
+// void Activate();
+// void Deactivate();
+
+ GENRTTI( ParticleBase );
+ private:
+ CLASS_HELPERS( MercuryNode );
+
+ friend class ParticleEmitter;
+ ParticleBase* m_nextParticle;
+ float m_age;
+ float m_lifespan;
+ float m_seed1, m_seed2;
+ ParticleEmitter* m_emitter;
+// MercuryNode* m_particleGraph;
+};
+
+class ParticleEmitter : public MercuryNode
+{
+ public:
+ ParticleEmitter();
+ ~ParticleEmitter();
+
+ virtual void Init();
+ virtual void Update(float dTime);
+
+ void DeactivateParticle(ParticleBase* p);
+ virtual void LoadFromXML(const XMLNode& node);
+
+ GENRTTI( ParticleEmitter );
+ private:
+ void DestroyParticles();
+ void ActivateParticle();
+ void FillUnusedParticleList(ParticleBase* p, uint32_t);
+ CLASS_HELPERS( MercuryNode );
+
+ uint32_t m_maxParticles;
+ float m_age;
+ float m_emitDelay; //seconds
+ float m_lifespan; //emitter lifespan
+ uint32_t m_particlesEmitted;
+ float m_particleMinLife, m_particleMaxLife;
+
+ ParticleBase* m_inactiveParticles;
+ ParticleBase* m_particles;
+
+ Callback1R<uint32_t,ParticleBase*>* GenerateParticlesClbk;
+
+// MercuryNode* m_masterParticle;
+};
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2009 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-12-14 20:16:47
|
Revision: 626
http://hgengine.svn.sourceforge.net/hgengine/?rev=626&view=rev
Author: axlecrusher
Date: 2009-12-14 20:16:40 +0000 (Mon, 14 Dec 2009)
Log Message:
-----------
updates
Modified Paths:
--------------
Mercury2/src/GLHeaders.h
Mercury2/src/MercuryNode.h
Mercury2/src/Shader.cpp
Mercury2/src/StateChanger.cpp
Modified: Mercury2/src/GLHeaders.h
===================================================================
--- Mercury2/src/GLHeaders.h 2009-11-18 23:03:51 UTC (rev 625)
+++ Mercury2/src/GLHeaders.h 2009-12-14 20:16:40 UTC (rev 626)
@@ -1,8 +1,8 @@
#ifndef GLHEADERS_H
#define GLHEADERS_H
-
-#include <configuration.h>
+#include <configuration.h>
+
#ifdef WIN32
#include <windows.h>
#else
@@ -29,6 +29,7 @@
uint32_t e = GLCALL( glGetError() ); \
if ( e != GL_NO_ERROR ) { \
LOG.Write(ssprintf("GL Error:%s", GlError2String(e).c_str())); \
+printf("GL Error:%s", GlError2String(e).c_str()); \
assert(0); } }
#define CHECKFBO { \
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-11-18 23:03:51 UTC (rev 625)
+++ Mercury2/src/MercuryNode.h 2009-12-14 20:16:40 UTC (rev 626)
@@ -34,6 +34,8 @@
MercuryNode();
virtual ~MercuryNode();
+ virtual void Init() {};
+
virtual void AddChild(MercuryNode* n);
virtual void RemoveChild(MercuryNode* n);
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-11-18 23:03:51 UTC (rev 625)
+++ Mercury2/src/Shader.cpp 2009-12-14 20:16:40 UTC (rev 626)
@@ -160,7 +160,7 @@
f2->Read( Buffer, i );
f2->Close();
Buffer[i] = '\0';
- LOG.Write("Compiling: %s"+s2);
+ LOG.Write("Compiling: "+s2);
if( !LoadShaderVert( Buffer ) )
{
if( f3 )
@@ -178,7 +178,7 @@
f3->Read( Buffer, i );
f3->Close();
Buffer[i] = '\0';
- LOG.Write("Compiling: %s"+s3);
+ LOG.Write("Compiling: "+s3);
if( !LoadShaderGeom( Buffer ) )
{
free( Buffer );
@@ -485,11 +485,13 @@
GLCALL( glUniform1iARB( location, x.value.iInt ) );
break;
case ShaderAttribute::TYPE_FLOAT:
+ GLCALL( glUniform1fARB( location, x.value.fFloat ) );
+ break;
case ShaderAttribute::TYPE_FLOATV4:
GLCALL( glUniform4fvARB( location, 1, &x.value.fFloatV4[0] ) );
break;
case ShaderAttribute::TYPE_MATRIX:
- GLCALL( glUniformMatrix4fvARB(location, 1, 1, x.value.matrix) ); //transpase too
+ GLCALL( glUniformMatrix4fvARB(location, 1, 1, x.value.matrix) ); //transpose too
break;
case ShaderAttribute::TYPE_INT4:
GLCALL( glUniform4ivARB( location, 1, x.value.iInts ) );
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-11-18 23:03:51 UTC (rev 625)
+++ Mercury2/src/StateChanger.cpp 2009-12-14 20:16:40 UTC (rev 626)
@@ -112,7 +112,36 @@
REGISTER_STATECHANGE( DepthTest );
+class DepthWrite : public StateChange
+{
+public:
+ DepthWrite( const MVector< MString > & sParameters ) : StateChange( sParameters )
+ {
+ if( sParameters.size() < 1 )
+ {
+ LOG.Write( ssprintf( "Error: DepthWrite state has invalid number of parameters(%d).", sParameters.size() ) );
+ return;
+ }
+ bEnable = StrToBool( sParameters[0] );
+ }
+
+ void Stringify( MString & sOut )
+ {
+ sOut = ssprintf( "%f", bEnable );
+ }
+
+ void Activate()
+ {
+ glDepthMask( bEnable );
+ }
+
+ STATECHANGE_RTTI( DepthWrite );
+ bool bEnable;
+};
+
+REGISTER_STATECHANGE( DepthWrite );
+
//////////////////////////////////////STATE CHANGE CHUNK//////////////////////////////////////
StateChangeRegister * StateChangeRegister::m_Instance;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-18 23:04:02
|
Revision: 625
http://hgengine.svn.sourceforge.net/hgengine/?rev=625&view=rev
Author: cnlohr
Date: 2009-11-18 23:03:51 +0000 (Wed, 18 Nov 2009)
Log Message:
-----------
tweak UI (And make MessageManager more const'ed)
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-11-18 22:11:44 UTC (rev 624)
+++ Mercury2/modules/Cu2.cpp 2009-11-18 23:03:51 UTC (rev 625)
@@ -45,7 +45,7 @@
SetSize( m_fOrigW, m_fOrigH );
}
-bool Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask )
+int Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask )
{
if( IsHidden() )
return false;
@@ -87,11 +87,11 @@
{
//Break on the first one that is a hit, that way we don't pass mouse info to buttons below.
if( sa->MouseMotion( x - int(sa->m_fX), y - int(sa->m_fY), iCurrentButtonMask, iLastButtonMask ) )
- return bIsInside;
+ return 2;
}
}
- return bIsInside;
+ return bIsInside?1:0;
}
void Cu2Element::PropogateReleaseOut( int x, int y, int iWhichButton )
@@ -278,7 +278,10 @@
}
else
{
- MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data, m_iLastButtonMask );
+ if( MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data, m_iLastButtonMask ) != 2 )
+ {
+ MESSAGEMAN.BroadcastMessage( "UIMissMouse", &data );
+ }
}
m_iLastButtonMask = m.buttons.data;
@@ -318,6 +321,7 @@
LOAD_FROM_XML( "clickMessage", m_sMessageToSend, );
LOAD_FROM_XML( "text", m_sText, );
LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool );
+ LOAD_FROM_XML( "clickPayload", m_sValueToSend, );
if( m_pText )
{
@@ -338,6 +342,7 @@
void Cu2Button::SaveToXMLTag( MString & sXMLStream )
{
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_pText )
@@ -498,8 +503,8 @@
glColor3f( .3, .3, .3 );
glBegin( GL_QUADS );
- glVertex2f( 2., GetH()-18 );
- glVertex2f( GetW()-2, GetH()-18 );
+ glVertex2f( 2., GetH()-19 );
+ glVertex2f( GetW()-2, GetH()-19 );
glVertex2f( GetW()-2, GetH()-3 );
glVertex2f( 2., GetH()-3 );
glEnd();
@@ -527,14 +532,18 @@
Cu2Element::MouseAction( x, y, c, iWhichButton );
}
-bool Cu2Dialog::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask )
+int Cu2Dialog::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask )
{
if( m_bDragging )
{
float ix = GetX() - ( m_iClickX - x );
float iy = GetY() - ( m_iClickY - y );
+ int dx = x - m_iClickX;
+ int dy = y - m_iClickY;
+
SetXY( ix, iy );
+ return Cu2Element::MouseMotion( x - dx, y - dy, iCurrentButtonMask, iLastButtonMask );
}
return Cu2Element::MouseMotion( x, y, iCurrentButtonMask, iLastButtonMask );
}
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2009-11-18 22:11:44 UTC (rev 624)
+++ Mercury2/modules/Cu2.h 2009-11-18 23:03:51 UTC (rev 625)
@@ -37,7 +37,10 @@
///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, unsigned char iLastButtonMask );
+ ///Return value 2: Has hit a child.
+ ///Return value 1: Has hit self.
+ ///Return value 0: Has missed self.
+ virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
///Called when a key is pressed - down the focus line.
virtual void GetKeypress( int key, bool bDown, bool bRepeat );
@@ -155,11 +158,14 @@
void SetAutoSize( bool bAutoSize ) { m_bAutoSize = bAutoSize; Refresh(); }
void Refresh();
+ MString & Payload() { return m_sValueToSend; }
+
TextNode * GetTextNodeHandle() { return m_pText; }
GENRTTI( Cu2Button );
private:
MString m_sMessageToSend;
+ MString m_sValueToSend;
MString m_sText;
bool m_bAutoSize;
bool m_bDown;
@@ -177,7 +183,7 @@
virtual void LoadFromXML(const XMLNode& node);
virtual void SaveToXMLTag( MString & sXMLStream );
virtual void Render( const MercuryMatrix& m );
- virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
+ virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton );
void SetText( const MString & sText );
Modified: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp 2009-11-18 22:11:44 UTC (rev 624)
+++ Mercury2/src/MercuryMessageManager.cpp 2009-11-18 23:03:51 UTC (rev 625)
@@ -46,7 +46,7 @@
}
}
-void MercuryMessageManager::BroadcastMessage( const MString & message, MessageData * data )
+void MercuryMessageManager::BroadcastMessage( const MString & message, const MessageData * data )
{
std::list< MessagePair > recipients;
{
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2009-11-18 22:11:44 UTC (rev 624)
+++ Mercury2/src/MercuryMessageManager.h 2009-11-18 23:03:51 UTC (rev 625)
@@ -40,7 +40,7 @@
void PostMessage(const MString& message, MessageData* data, float delay);
///Immediately dispatch message
- void BroadcastMessage( const MString & message, MessageData * data );
+ void BroadcastMessage( const MString & message, const MessageData * data );
void PumpMessages(const uint64_t& currTime);
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: <cn...@us...> - 2009-11-18 22:10:46
|
Revision: 623
http://hgengine.svn.sourceforge.net/hgengine/?rev=623&view=rev
Author: cnlohr
Date: 2009-11-18 22:10:37 +0000 (Wed, 18 Nov 2009)
Log Message:
-----------
add dialogs
Modified Paths:
--------------
Mercury2/modules/Cu2.cpp
Mercury2/modules/Cu2.h
Modified: Mercury2/modules/Cu2.cpp
===================================================================
--- Mercury2/modules/Cu2.cpp 2009-11-18 22:09:24 UTC (rev 622)
+++ Mercury2/modules/Cu2.cpp 2009-11-18 22:10:37 UTC (rev 623)
@@ -10,7 +10,7 @@
///////////////////////////////////////COPPER 2 ELEMENT///////////////////////////////////////
Cu2Element::Cu2Element() : TransformNode(),
- m_pFocusNode(0), m_bCanTabStop( false ), m_iButtonMask(0), m_bWasMouseInThisFrame(0),
+ m_pFocusNode(0), m_bCanTabStop( true ), 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)
{
@@ -45,7 +45,7 @@
SetSize( m_fOrigW, m_fOrigH );
}
-bool Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask )
+bool Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask )
{
if( IsHidden() )
return false;
@@ -62,13 +62,12 @@
for( unsigned button = 0; button < 8; button++ )
{
unsigned char Mask = 1<<button;
- bool bWasDown = m_iButtonMask & Mask;
+ bool bWasDown = iLastButtonMask & 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
@@ -76,18 +75,19 @@
}
else if( !bWasDown && bIsDown && bIsInside )
{
- m_iButtonMask |= Mask;
MouseAction( x, y, PRESS_IN, button );
}
}
if( bIsInside )
- for( MercuryNode* send = FirstChild(); send; send = NextChild( send ) )
+ for( MercuryNode* send = LastChild(); send; send = PrevChild( send ) )
{
Cu2Element * sa = dynamic_cast<Cu2Element*>(send);
if( sa )
{
- sa->MouseMotion( x - int(sa->m_fX), y - int(sa->m_fY), iCurrentButtonMask );
+ //Break on the first one that is a hit, that way we don't pass mouse info to buttons below.
+ if( sa->MouseMotion( x - int(sa->m_fX), y - int(sa->m_fY), iCurrentButtonMask, iLastButtonMask ) )
+ return bIsInside;
}
}
@@ -108,7 +108,8 @@
void Cu2Element::MouseAction( int x, int y, Cu2Action c, int iWhichButton )
{
- //nothing
+ if( c == PRESS_IN )
+ RaiseFocus();
}
void Cu2Element::AddChild(MercuryNode* n)
@@ -154,6 +155,39 @@
return 0;
}
+bool Cu2Element::HasFocus()
+{
+ Cu2Element * sa = dynamic_cast<Cu2Element*>(Parent());
+
+ if( sa && sa->m_pFocusNode == this )
+ return true;
+ else
+ return false;
+}
+
+void Cu2Element::RaiseFocus()
+{
+ Cu2Element * ca = dynamic_cast<Cu2Element*>(Parent());
+
+ if( ca )
+ {
+ bool bCouldTabStop = IsEnableTabStop( );
+
+ //Remove this node from wherever it is
+ ca->RemoveChild( this );
+
+ //This is reset by RemoveChild - so we have to update.
+ SetEnableTabStop( bCouldTabStop );
+
+ //Make it so it draws last.
+ ca->AddChild( this );
+
+ ca->m_pFocusNode = this;
+
+ ca->RaiseFocus();
+ }
+}
+
void Cu2Element::SetHidden( bool bHide )
{
MercuryNode::SetHidden( bHide );
@@ -184,12 +218,14 @@
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;
}
@@ -242,8 +278,10 @@
}
else
{
- MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data );
+ MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data, m_iLastButtonMask );
}
+
+ m_iLastButtonMask = m.buttons.data;
}
void Cu2Root::HandleKeyboardInput(const MessageData& data)
@@ -312,7 +350,7 @@
if( c == RELEASE_IN )
{
if( m_bDown )
- Click();
+ Click( x, y );
m_bDown = false;
}
@@ -320,6 +358,8 @@
{
m_bDown = false;
}
+
+ Cu2Element::MouseAction( x, y, c, iWhichButton );
}
void Cu2Button::Refresh()
@@ -336,11 +376,10 @@
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()
+void Cu2Button::Click( int x, int y )
{
if( m_sMessageToSend.length() )
MESSAGEMAN.BroadcastMessage( m_sMessageToSend, new PointerDataMessage( this ) );
@@ -389,7 +428,128 @@
REGISTER_NODE_TYPE(Cu2Button);
+///////////////////////////////////////COPPER 2 DIALOG///////////////////////////////////////
+
+Cu2Dialog::Cu2Dialog() : Cu2Element(), m_bDragging( false ), m_iClickX( 0 ), m_iClickY( 0 )
+{
+ m_sTitle = "(not set)";
+ m_pTitle = (TextNode*)NODEFACTORY.Generate( "TextNode" );
+ AddChild( m_pTitle );
+}
+
+void Cu2Dialog::LoadFromXML(const XMLNode& node)
+{
+ LOAD_FROM_XML( "text", m_sTitle, );
+
+ if( m_pTitle )
+ {
+ m_pTitle->SetAlignment( TextNode::LEFT );
+ m_pTitle->LoadFont( node.Attribute("font") );
+ m_pTitle->SetSize( StrToFloat( node.Attribute("size") ) );
+ m_pTitle->SetShiftAbsolute( true );
+ m_pTitle->SetShiftX( 3 );
+ m_pTitle->SetShiftY( GetH() - 18 );
+ SetText( m_sTitle );
+ }
+ Cu2Element::LoadFromXML( node );
+}
+
+void Cu2Dialog::SaveToXMLTag( MString & sXMLStream )
+{
+ if( !m_pTitle )
+ m_pTitle->SaveToXMLTag( sXMLStream );
+
+ Cu2Element::SaveToXMLTag( sXMLStream );
+}
+
+void Cu2Dialog::Render( const MercuryMatrix& m )
+{
+ glDisable( GL_TEXTURE_2D );
+ 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 );
+ glColor3f( 0.7, 0.7, 0.7 );
+ glVertex2f( 1, 1 );
+ glVertex2f( 1, GetH()-1 );
+ glVertex2f( 1, GetH()-1 );
+ glVertex2f( GetW()-2, GetH()-1 );
+ glColor3f( 0.1, 0.1, 0.1 );
+ glVertex2f( GetW()-1, GetH()-2 );
+ glVertex2f( GetW()-1, 1 );
+ glVertex2f( GetW()-1, 1 );
+ glVertex2f( 1, 1 );
+ glEnd();
+
+ if( HasFocus() )
+ glColor3f( 0., 0., 1. );
+ else
+ glColor3f( .3, .3, .3 );
+
+ glBegin( GL_QUADS );
+ glVertex2f( 2., GetH()-18 );
+ glVertex2f( GetW()-2, GetH()-18 );
+ glVertex2f( GetW()-2, GetH()-3 );
+ glVertex2f( 2., GetH()-3 );
+ glEnd();
+
+ glEnable( GL_TEXTURE_2D );
+
+ glColor3f( 1., 1., 1. );
+
+ TransformNode::Render( m );
+}
+
+void Cu2Dialog::MouseAction( int x, int y, Cu2Action c, int iWhichButton )
+{
+ if( y > GetH() - 14 && c == PRESS_IN )
+ {
+ m_bDragging = true;
+ m_iClickX = x;
+ m_iClickY = y;
+ }
+
+ if( c == RELEASE_IN || c == RELEASE_OUT )
+ m_bDragging = false;
+
+
+ Cu2Element::MouseAction( x, y, c, iWhichButton );
+}
+
+bool Cu2Dialog::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask )
+{
+ if( m_bDragging )
+ {
+ float ix = GetX() - ( m_iClickX - x );
+ float iy = GetY() - ( m_iClickY - y );
+
+ SetXY( ix, iy );
+ }
+ return Cu2Element::MouseMotion( x, y, iCurrentButtonMask, iLastButtonMask );
+}
+
+void Cu2Dialog::SetText( const MString & sText )
+{
+ m_sTitle = sText;
+ if( m_pTitle )
+ {
+ m_pTitle->SetText( m_sTitle );
+ m_pTitle->RenderText();
+ }
+}
+
+
+REGISTER_NODE_TYPE(Cu2Dialog);
+
+
/****************************************************************************
* Copyright (C) 2008-2009 by Joshua Allen *
* Charles Lohr *
Modified: Mercury2/modules/Cu2.h
===================================================================
--- Mercury2/modules/Cu2.h 2009-11-18 22:09:24 UTC (rev 622)
+++ Mercury2/modules/Cu2.h 2009-11-18 22:10:37 UTC (rev 623)
@@ -37,7 +37,7 @@
///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 );
+ virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
///Called when a key is pressed - down the focus line.
virtual void GetKeypress( int key, bool bDown, bool bRepeat );
@@ -53,6 +53,12 @@
///Also handle tab stopping correctly.
virtual void SetHidden( bool bHide );
+ ///Does this node have focus?
+ bool HasFocus();
+
+ ///Make this object get focus.
+ void RaiseFocus();
+
///Progress to the next tab.
Cu2Element * NextTab();
@@ -68,12 +74,6 @@
///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 ) ); }
@@ -102,9 +102,6 @@
bool m_bCanTabStop;
- ///Mask of currently depressed buttons.
- unsigned char m_iButtonMask;
-
bool m_bWasMouseInThisFrame;
float m_fX, m_fY, m_fW, m_fH;
@@ -133,6 +130,7 @@
GENRTTI( Cu2Root );
private:
static Cu2Root * g_pCurrentInstance;
+ unsigned char m_iLastButtonMask;
};
class TextNode;
@@ -145,7 +143,7 @@
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 Click( int x, int y );
virtual void LoadFromXML(const XMLNode& node);
virtual void SaveToXMLTag( MString & sXMLStream );
@@ -168,6 +166,29 @@
TextNode * m_pText;
};
+class Cu2Dialog : public Cu2Element
+{
+public:
+ Cu2Dialog();
+ GENRTTI( Cu2Dialog );
+
+ TextNode * GetTextNodeHandle() { return m_pTitle; }
+
+ virtual void LoadFromXML(const XMLNode& node);
+ virtual void SaveToXMLTag( MString & sXMLStream );
+ virtual void Render( const MercuryMatrix& m );
+ virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask );
+ virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton );
+
+ void SetText( const MString & sText );
+
+private:
+ bool m_bDragging;
+ int m_iClickX, m_iClickY;
+ TextNode * m_pTitle;
+ MString m_sTitle;
+};
+
#endif
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:09:31
|
Revision: 622
http://hgengine.svn.sourceforge.net/hgengine/?rev=622&view=rev
Author: cnlohr
Date: 2009-11-18 22:09:24 +0000 (Wed, 18 Nov 2009)
Log Message:
-----------
add lastchild
Modified Paths:
--------------
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-11-18 22:09:16 UTC (rev 621)
+++ Mercury2/src/MercuryNode.cpp 2009-11-18 22:09:24 UTC (rev 622)
@@ -114,6 +114,15 @@
return NULL;
}
+MercuryNode* MercuryNode::LastChild() const
+{
+ if( !m_children.empty() )
+ return m_children.back();
+ else
+ return NULL;
+}
+
+
MercuryNode* MercuryNode::NextChild(const MercuryNode* child) const
{
if (child==NULL) return NULL;
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-11-18 22:09:16 UTC (rev 621)
+++ Mercury2/src/MercuryNode.h 2009-11-18 22:09:24 UTC (rev 622)
@@ -41,6 +41,7 @@
inline MercuryNode* NextSibling() const { return m_nextSibling; }
inline MercuryNode* PrevSibling() const { return m_prevSibling; }
MercuryNode* FirstChild() const;
+ MercuryNode* LastChild() const;
MercuryNode* NextChild(const MercuryNode* n) const; ///Finds the next child in regards to n
MercuryNode* PrevChild(const MercuryNode* n) const; ///Finds the previous child in regards to n
const std::list< MercuryNode* >& Children() const { return m_children; }
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:09:24
|
Revision: 621
http://hgengine.svn.sourceforge.net/hgengine/?rev=621&view=rev
Author: cnlohr
Date: 2009-11-18 22:09:16 +0000 (Wed, 18 Nov 2009)
Log Message:
-----------
Reduce uninitialized variables issue
Modified Paths:
--------------
Mercury2/src/DataTypes/MTriangle.cpp
Modified: Mercury2/src/DataTypes/MTriangle.cpp
===================================================================
--- Mercury2/src/DataTypes/MTriangle.cpp 2009-11-13 07:46:14 UTC (rev 620)
+++ Mercury2/src/DataTypes/MTriangle.cpp 2009-11-18 22:09:16 UTC (rev 621)
@@ -4,6 +4,9 @@
MTriangle::MTriangle()
{
+ m_verts[0] = 0;
+ m_verts[1] = 0;
+ m_verts[2] = 0;
}
MTriangle::MTriangle(const MercuryVertex a, const MercuryVertex& b, const MercuryVertex& c)
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-13 07:46:10
|
Revision: 619
http://hgengine.svn.sourceforge.net/hgengine/?rev=619&view=rev
Author: cnlohr
Date: 2009-11-13 07:45:59 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
Allow for post-shifting of text.
Modified Paths:
--------------
Mercury2/modules/TextNode.cpp
Mercury2/modules/TextNode.h
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2009-11-13 07:44:56 UTC (rev 618)
+++ Mercury2/modules/TextNode.cpp 2009-11-13 07:45:59 UTC (rev 619)
@@ -17,7 +17,9 @@
m_fTextWidth( INFINITY ),
m_kVBO(0), m_kTEX(0),
m_fRMinX(0),m_fRMinY(0),
- m_fRMaxX(0),m_fRMaxY(0)
+ m_fRMaxX(0),m_fRMaxY(0),
+ m_fShiftX(0),m_fShiftY(0),
+ m_bShiftAbsolute(false)
{
//Disabling saving of children... As, we create many temporary children.
m_bEnableSaveChildren = false;
@@ -45,6 +47,13 @@
if( m_fTextWidth < 1e9 )
sXMLStream += ssprintf( "width=\"%f\" ", m_fTextWidth );
+ if( ABS(m_fShiftX) > 1e-9 )
+ sXMLStream += ssprintf( "shiftx=\"%f\" ", m_fShiftX );
+ if( ABS(m_fShiftY) > 1e-9 )
+ sXMLStream += ssprintf( "shifty=\"%f\" ", m_fShiftY );
+ if( m_bShiftAbsolute )
+ sXMLStream += ssprintf( "shiftAbsolute=\"%d\" ", m_bShiftAbsolute );
+
sXMLStream += "alignment=\"";
switch( m_alignment )
{
@@ -70,6 +79,10 @@
{
MercuryNode::LoadFromXML(node);
+ LOAD_FROM_XML( "shiftx", m_fShiftX, StrToFloat );
+ LOAD_FROM_XML( "shifty", m_fShiftY, StrToFloat );
+ LOAD_FROM_XML( "shiftAbsolute", m_bShiftAbsolute, StrToBool );
+
if ( !node.Attribute("font").empty() )
LoadFont( node.Attribute("font") );
if ( !node.Attribute("size").empty() )
@@ -100,12 +113,14 @@
if( !m_kTEX )
{
- m_kTEX = MAutoPtr< MercuryAsset >( Texture::LoadFromFile( m_pThisFont->m_sImage ) );
+
+ m_kTEX = ASSETFACTORY.Generate( "Texture", m_pThisFont->m_sImage );
if( !m_kTEX )
{
fprintf( stderr, "Could not create Texture for text.\n" );
return;
}
+ m_kTEX->ChangeKey( m_pThisFont->m_sImage );
AddAsset( m_kTEX );
}
@@ -294,12 +309,13 @@
((MercuryVBO*)m_kVBO.Ptr())->AllocateIndexSpace((unsigned)chars.size()*6);
((MercuryVBO*)m_kVBO.Ptr())->AllocateVertexSpace((unsigned)chars.size()*4);
+ float * vd = ((MercuryVBO*)m_kVBO.Ptr())->GetVertexHandle();
+ short unsigned int * id = ((MercuryVBO*)m_kVBO.Ptr())->GetIndexHandle();
+
for( unsigned i = 0; i < chars.size(); i++ )
{
DChar & dc = chars[i];
Glyph * g = dc.glyph;
- float * vd = ((MercuryVBO*)m_kVBO.Ptr())->GetVertexHandle();
- short unsigned int * id = ((MercuryVBO*)m_kVBO.Ptr())->GetIndexHandle();
float sx = (-g->iox + dc.xps)*m_fSize;
float sy = -(-g->ioy + dc.yps)*m_fSize;
@@ -359,6 +375,23 @@
if( sx < m_fRMinX ) m_fRMinX = sx;
}
+ if( ABS(m_fShiftX) > 1e-9 || ABS(m_fShiftY) > 1e-9 || m_bShiftAbsolute )
+ {
+ for( unsigned i = 0; i < chars.size(); i++ )
+ {
+ for( unsigned j = 0; j < 4; j++ )
+ {
+ vd[(i*4+j)*8+5] += ((m_bShiftAbsolute)?-m_fRMinX:0) + m_fShiftX;
+ vd[(i*4+j)*8+6] += ((m_bShiftAbsolute)?-m_fRMinY:0) + m_fShiftY;
+ }
+ }
+
+ m_fRMaxX += ((m_bShiftAbsolute)?-m_fRMinX:0) + m_fShiftX;
+ m_fRMaxY += ((m_bShiftAbsolute)?-m_fRMinY:0) + m_fShiftY;
+ m_fRMinX += ((m_bShiftAbsolute)?-m_fRMinX:0) + m_fShiftX;
+ m_fRMinY += ((m_bShiftAbsolute)?-m_fRMinY:0) + m_fShiftY;
+ }
+
((MercuryVBO*)m_kVBO.Ptr())->DirtyVertices();
((MercuryVBO*)m_kVBO.Ptr())->DirtyIndices();
Modified: Mercury2/modules/TextNode.h
===================================================================
--- Mercury2/modules/TextNode.h 2009-11-13 07:44:56 UTC (rev 618)
+++ Mercury2/modules/TextNode.h 2009-11-13 07:45:59 UTC (rev 619)
@@ -45,6 +45,12 @@
inline float GetRMaxX() { return m_fRMaxX; }
inline float GetRMaxY() { return m_fRMaxY; }
+ inline float GetShiftX() { return m_fShiftX; }
+ inline float GetShiftY() { return m_fShiftY; }
+ inline void SetShiftX( float fX ) { m_fShiftX = fX; }
+ inline void SetShiftY( float fY ) { m_fShiftY = fY; }
+ inline void SetShiftAbsolute( bool bAbs ) { m_bShiftAbsolute = bAbs; }
+
virtual void SaveToXMLTag( MString & sXMLStream );
GENRTTI(TextNode);
@@ -70,6 +76,11 @@
float m_fRMaxX;
float m_fRMaxY;
+ float m_fShiftX;
+ float m_fShiftY;
+
+ bool m_bShiftAbsolute;
+
//Font-class specific stuff
class Glyph
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|