|
From: <cn...@us...> - 2010-03-03 08:51:28
|
Revision: 684
http://hgengine.svn.sourceforge.net/hgengine/?rev=684&view=rev
Author: cnlohr
Date: 2010-03-03 08:51:22 +0000 (Wed, 03 Mar 2010)
Log Message:
-----------
forgot camera .h and add more traditional lights to state changer, for those who which to manually control their lighting
Modified Paths:
--------------
Mercury2/src/Camera.h
Mercury2/src/StateChanger.cpp
Modified: Mercury2/src/Camera.h
===================================================================
--- Mercury2/src/Camera.h 2010-03-03 08:49:47 UTC (rev 683)
+++ Mercury2/src/Camera.h 2010-03-03 08:51:22 UTC (rev 684)
@@ -26,6 +26,7 @@
MercuryVertex m_origionalPosition;
MercuryVector m_lookAt;
float m_x, m_y;
+ bool m_bFreeFly;
MercuryMatrix m_viewMatrix;
};
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2010-03-03 08:49:47 UTC (rev 683)
+++ Mercury2/src/StateChanger.cpp 2010-03-03 08:51:22 UTC (rev 684)
@@ -271,6 +271,7 @@
REGISTER_STATECHANGE( BlendFunc );
+///Change the alpha blending function (can be useful for non-shader farcry-like foliage)
class AlphaFunc : public StateChange
{
public:
@@ -334,6 +335,51 @@
REGISTER_STATECHANGE( AlphaFunc );
+///OpenGL-based fixed light
+class OGLLight : public StateChange
+{
+public:
+ OGLLight( const MVector< MString > & sParameters ) : StateChange( sParameters )
+ {
+ if( sParameters.size() < 5 )
+ {
+ LOG.Write( ssprintf( "Error: Light has invalid number of parameters(%d).", sParameters.size() ) );
+ return;
+ }
+
+ iLight = StrToInt( sParameters[0] );
+
+ for( unsigned i = 0; i < 16; i++ )
+ if( i+1 < sParameters.size() )
+ {
+ fParams[i] = StrToFloat( sParameters[i+1] );
+ }
+ }
+
+ void Stringify( MString & sOut )
+ {
+ sOut = ssprintf( "%d", iLight );
+ for( unsigned i = 0; i < 16; i++ )
+ sOut += ssprintf( ",%f", fParams[i] );
+ }
+
+ void Activate()
+ {
+ GLCALL( glEnable(GL_LIGHT0 + iLight) );
+ GLCALL( glLightfv(GL_LIGHT0, GL_POSITION, &fParams[0]) );
+ GLCALL( glLightfv(GL_LIGHT0, GL_DIFFUSE, &fParams[4]) );
+ GLCALL( glLightfv(GL_LIGHT0, GL_AMBIENT, &fParams[8]) );
+ GLCALL( glLightfv(GL_LIGHT0, GL_SPECULAR, &fParams[12]) );
+
+ }
+
+ STATECHANGE_RTTI( OGLLight );
+
+ int iLight;
+ float fParams[16]; //Position, Diffuse, Ambient, Specular; each [4]
+};
+
+REGISTER_STATECHANGE( OGLLight );
//////////////////////////////////////STATE CHANGE CHUNK//////////////////////////////////////
StateChangeRegister & StateChangeRegister::Instance()
@@ -442,7 +488,7 @@
MString sParameters = sFile.substr( f+1 );
MVector< MString > vsParameters;
- SplitStrings( sParameters, vsParameters, ",", " ", 1, 1 );
+ SplitStrings( sParameters, vsParameters, ",;", " ", 2, 1 );
MAutoPtr< StateChange > s = StateChangeRegister::Instance().Create( sType, vsParameters );
if( s.Ptr() )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|