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: <cn...@us...> - 2009-11-13 07:45:04
|
Revision: 618
http://hgengine.svn.sourceforge.net/hgengine/?rev=618&view=rev
Author: cnlohr
Date: 2009-11-13 07:44:56 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
Broadcast button press location along with button presses.
Modified Paths:
--------------
Mercury2/src/X11Window.cpp
Mercury2/src/X11Window.h
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2009-11-13 07:44:34 UTC (rev 617)
+++ Mercury2/src/X11Window.cpp 2009-11-13 07:44:56 UTC (rev 618)
@@ -286,7 +286,7 @@
su = ((e->state & X11_MASK(MOUSE_BTN_SCROLL_UP))!=0) ^ (e->button == MOUSE_BTN_SCROLL_UP);
sd = ((e->state & X11_MASK(MOUSE_BTN_SCROLL_DOWN))!=0) ^ (e->button == MOUSE_BTN_SCROLL_DOWN);
- MouseInput::ProcessMouseInput(0, 0,
+ MouseInput::ProcessMouseInput(m_iLastMouseX, m_iLastMouseY ,
left, right, center, su, sd);
break;
}
@@ -323,12 +323,16 @@
y = m_height/2 - e->y;
if (x!=0 || y!=0) //prevent recursive XWarp
{
+ m_iLastMouseX = x;
+ m_iLastMouseY = y;
MouseInput::ProcessMouseInput(x, y, left, right, center, su, sd);
XWarpPointer(m_display, None, m_window, 0,0,0,0,m_width/2,m_height/2);
}
}
else
{
+ m_iLastMouseX = e->x;
+ m_iLastMouseY = e->y;
MouseInput::ProcessMouseInput(e->x, e->y, left, right, center, su, sd);
}
break;
Modified: Mercury2/src/X11Window.h
===================================================================
--- Mercury2/src/X11Window.h 2009-11-13 07:44:34 UTC (rev 617)
+++ Mercury2/src/X11Window.h 2009-11-13 07:44:56 UTC (rev 618)
@@ -28,6 +28,9 @@
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: <cn...@us...> - 2009-11-13 07:44:43
|
Revision: 617
http://hgengine.svn.sourceforge.net/hgengine/?rev=617&view=rev
Author: cnlohr
Date: 2009-11-13 07:44:34 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
add new types of containers for messages
Modified Paths:
--------------
Mercury2/src/MessageHandler.h
Modified: Mercury2/src/MessageHandler.h
===================================================================
--- Mercury2/src/MessageHandler.h 2009-11-13 07:44:12 UTC (rev 616)
+++ Mercury2/src/MessageHandler.h 2009-11-13 07:44:34 UTC (rev 617)
@@ -9,7 +9,7 @@
{ if (!n) return 0; return dynamic_cast<const x*>(n); } \
static x* Cast(MessageHandler* n) \
{ if (!n) return 0; return dynamic_cast<x*>(n); } \
-virtual const char * GetType() { return #x; }
+virtual const char * GetType() { return #x; } \
class MessageData
{
@@ -26,6 +26,24 @@
MercuryVertex Vertex;
};
+class StringDataMessage : public MessageData
+{
+ public:
+ StringDataMessage(const MString& s)
+ :String(s)
+ {}
+ MString String;
+};
+
+class PointerDataMessage : public MessageData
+{
+ public:
+ PointerDataMessage(void * s)
+ :Pointer(s)
+ {}
+ void * Pointer;
+};
+
class MessageHandler
{
public:
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:44:19
|
Revision: 616
http://hgengine.svn.sourceforge.net/hgengine/?rev=616&view=rev
Author: cnlohr
Date: 2009-11-13 07:44:12 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
add new state changers
Modified Paths:
--------------
Mercury2/src/StateChanger.cpp
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-11-13 07:43:08 UTC (rev 615)
+++ Mercury2/src/StateChanger.cpp 2009-11-13 07:44:12 UTC (rev 616)
@@ -78,7 +78,41 @@
REGISTER_STATECHANGE( LightingSwitch );
+///State changer for enabling/disabling lighting
+class DepthTest : public StateChange
+{
+public:
+ DepthTest( const MVector< MString > & sParameters ) : StateChange( sParameters )
+ {
+ if( sParameters.size() < 1 )
+ {
+ LOG.Write( ssprintf( "Error: DepthTest state has invalid number of parameters(%d).", sParameters.size() ) );
+ return;
+ }
+ bEnable = StrToBool( sParameters[0] );
+ }
+
+ void Stringify( MString & sOut )
+ {
+ sOut = ssprintf( "%f", bEnable );
+ }
+
+ void Activate()
+ {
+ if( bEnable )
+ glEnable( GL_DEPTH_TEST );
+ else
+ glDisable( GL_DEPTH_TEST );
+ }
+
+ STATECHANGE_RTTI( DepthTest );
+ bool bEnable;
+};
+
+REGISTER_STATECHANGE( DepthTest );
+
+
//////////////////////////////////////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-13 07:43:20
|
Revision: 615
http://hgengine.svn.sourceforge.net/hgengine/?rev=615&view=rev
Author: cnlohr
Date: 2009-11-13 07:43:08 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
Add BroadcastMessage for immediate sending AND Modify the MESSAGEMAN macro to include Instance().
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryMessageManager.cpp
Mercury2/src/MercuryMessageManager.h
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-11-13 07:40:16 UTC (rev 614)
+++ Mercury2/src/Mercury2.cpp 2009-11-13 07:43:08 UTC (rev 615)
@@ -130,7 +130,7 @@
do
{
timer.Touch();
- MESSAGEMAN::GetInstance().PumpMessages( timer.MicrosecondsSinceInit() );
+ MESSAGEMAN.PumpMessages( timer.MicrosecondsSinceInit() );
root->RecursiveUpdate( timer.Age() ); //comment to use threads
Modified: Mercury2/src/MercuryMessageManager.cpp
===================================================================
--- Mercury2/src/MercuryMessageManager.cpp 2009-11-13 07:40:16 UTC (rev 614)
+++ Mercury2/src/MercuryMessageManager.cpp 2009-11-13 07:43:08 UTC (rev 615)
@@ -46,6 +46,36 @@
}
}
+void MercuryMessageManager::BroadcastMessage( const MString & message, MessageData * data )
+{
+ std::list< MessagePair > recipients;
+ {
+ //copy list first (quick lock)
+ MSemaphoreLock lock(&m_recipientLock);
+ std::list< MessagePair > * r = m_messageRecipients.get( message );
+ if ( r ) recipients = *r;
+ }
+
+ if ( !recipients.empty() )
+ {
+ std::list< MessagePair >::iterator recipient = recipients.begin();
+ for (; recipient != recipients.end(); ++recipient)
+ {
+ MessagePair & mp = *recipient;
+ //Okay, the following lines look horrible. Reason is we're using
+ //a horrible horrible c++ construct from the anals of pointerdom.
+ //The idea is we're using a delegate. If we have a delegate, use it.
+ //If you are receiving a delegate, you do not need the message name.
+ //Otherwise, send a standard message through the old interface.
+ if( mp.d )
+ (mp.h->*(mp.d))( *(data) );
+ else
+ mp.h->HandleMessage(message, *(data) );
+ }
+ }
+
+}
+
void MercuryMessageManager::UnRegisterForMessage(const MString& message, MessageHandler* ptr)
{
MSemaphoreLock lock(&m_recipientLock);
Modified: Mercury2/src/MercuryMessageManager.h
===================================================================
--- Mercury2/src/MercuryMessageManager.h 2009-11-13 07:40:16 UTC (rev 614)
+++ Mercury2/src/MercuryMessageManager.h 2009-11-13 07:43:08 UTC (rev 615)
@@ -35,7 +35,13 @@
{
public:
MercuryMessageManager() : m_messageQueue( MessageHolder::Compare ) { }
+
+ ///Dispatch message whenever the message manager gets control again; delay after now.
void PostMessage(const MString& message, MessageData* data, float delay);
+
+ ///Immediately dispatch message
+ void BroadcastMessage( const MString & message, MessageData * data );
+
void PumpMessages(const uint64_t& currTime);
void RegisterForMessage(const MString& message, MessageHandler* ptr, Delegate d = 0 );
@@ -65,11 +71,11 @@
static InstanceCounter<MercuryMessageManager> MMcounter("MessageManager");
-#define MESSAGEMAN MercuryMessageManager
-#define REGISTER_MESSAGE_WITH_DELEGATE(x, d) MESSAGEMAN::GetInstance().RegisterForMessage(x, this, (Delegate)d)
-#define REGISTER_FOR_MESSAGE(x) MESSAGEMAN::GetInstance().RegisterForMessage(x, this)
-#define UNREGISTER_FOR_MESSAGE(x) MESSAGEMAN::GetInstance().UnRegisterForMessage(x, this)
-#define POST_MESSAGE(x,data,delay) MESSAGEMAN::GetInstance().PostMessage(x, data, delay)
+#define MESSAGEMAN MercuryMessageManager::GetInstance()
+#define REGISTER_MESSAGE_WITH_DELEGATE(x, d) MESSAGEMAN.RegisterForMessage(x, this, (Delegate)d)
+#define REGISTER_FOR_MESSAGE(x) MESSAGEMAN.RegisterForMessage(x, this)
+#define UNREGISTER_FOR_MESSAGE(x) MESSAGEMAN.UnRegisterForMessage(x, this)
+#define POST_MESSAGE(x,data,delay) MESSAGEMAN.PostMessage(x, data, delay)
#endif
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:40:22
|
Revision: 614
http://hgengine.svn.sourceforge.net/hgengine/?rev=614&view=rev
Author: cnlohr
Date: 2009-11-13 07:40:16 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
virtualize addition/removal of children, and add macro for helping out load from XML.
Modified Paths:
--------------
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-11-13 07:38:19 UTC (rev 613)
+++ Mercury2/src/MercuryNode.cpp 2009-11-13 07:40:16 UTC (rev 614)
@@ -275,11 +275,11 @@
{
SetName( node.Attribute("name") );
- if ( !node.Attribute("hidden").empty() )
- m_hidden = StrToBool( node.Attribute("hidden") );
+ LOAD_FROM_XML( "hidden", m_hidden, StrToBool );
+ LOAD_FROM_XML( "alphaPath", m_useAlphaPath, StrToBool );
+ LOAD_FROM_XML( "enableSave", m_bEnableSave, StrToBool );
+ LOAD_FROM_XML( "enableSaveChildren", m_bEnableSaveChildren, StrToBool );
- if ( !node.Attribute("alphaPath").empty() )
- m_useAlphaPath = StrToBool( node.Attribute("alphaPath") );
//Not much to do here except run through all the children nodes
for (XMLNode child = node.Child(); child.IsValid(); child = child.NextNode())
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-11-13 07:38:19 UTC (rev 613)
+++ Mercury2/src/MercuryNode.h 2009-11-13 07:40:16 UTC (rev 614)
@@ -17,14 +17,7 @@
Each node exists as a single entity in the scene graph.
**/
-/*
-#define GENRTTI(x) static bool IsMyType(const MercuryNode* n) \
-{ const MercuryNode* tn = n; \
-while(tn) { if (typeid(x) == typeid(*tn)) return true; tn = *n; } \
-return false;}
-*/
-
#define STANDARD_PASS 7
///Which passes, by default, should be run on all nodes.
#define DEFAULT_PASSES ( (1<<STANDARD_PASS) )
@@ -41,8 +34,8 @@
MercuryNode();
virtual ~MercuryNode();
- void AddChild(MercuryNode* n);
- void RemoveChild(MercuryNode* n);
+ virtual void AddChild(MercuryNode* n);
+ virtual void RemoveChild(MercuryNode* n);
inline MercuryNode* Parent() const { return m_parent; }
inline MercuryNode* NextSibling() const { return m_nextSibling; }
@@ -128,6 +121,8 @@
const MercuryMatrix & GetModelViewMatrix() const { return m_pModelViewMatrix[g_iViewportID]; }
inline unsigned short GetPasses() const { return m_iPasses; }
+
+ virtual void SetHidden( bool bHide ) { m_hidden = bHide; }
protected:
std::list< MercuryNode* > m_children; //These nodes are unique, not instanced
MercuryNode* m_parent;
@@ -182,6 +177,8 @@
static InstanceCounter<NodeFactory> NFcounter("NodeFactory");
+
+///Register a new instance of the node with the main Mercury Node Registration System.
#define REGISTER_NODE_TYPE(class)\
MercuryNode* FactoryFunct##class() { return new class(); } \
Callback0R<MercuryNode*> factoryclbk##class( FactoryFunct##class ); \
@@ -195,6 +192,17 @@
} }
+///Load a variable from XML (safely) - this loads a variable of type name into variable using the transform function.
+#define LOAD_FROM_XML( name, variable, function ) \
+ if ( !node.Attribute( name ).empty() ) \
+ variable = function ( node.Attribute(name) );
+
+///Call callee if attribute name exists in XML - attribute can be transformed using function
+#define LOAD_FROM_XML_CALL( name, callee, function ) \
+ if ( !node.Attribute( name ).empty() ) \
+ callee( function ( node.Attribute(name) ) );
+
+
#endif
/****************************************************************************
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:38:29
|
Revision: 613
http://hgengine.svn.sourceforge.net/hgengine/?rev=613&view=rev
Author: cnlohr
Date: 2009-11-13 07:38:19 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
permit other texture modes
Modified Paths:
--------------
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-11-13 07:35:37 UTC (rev 612)
+++ Mercury2/src/Texture.cpp 2009-11-13 07:38:19 UTC (rev 613)
@@ -13,7 +13,7 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
Texture::Texture( const MString & key, bool bInstanced )
- :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false), m_bClamp(true)
+ :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false), m_bClamp(true), m_tFilterMode(TF_LINEAR_MIPS)
{
if (!m_initTextureSuccess)
{
@@ -65,10 +65,24 @@
GL_UNSIGNED_BYTE,
m_raw->m_data);
*/
- GLCALL( gluBuild2DMipmaps( GL_TEXTURE_2D, byteType, m_raw->m_width, m_raw->m_height, byteType, GL_UNSIGNED_BYTE, m_raw->m_data ) );
-
- GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST) );
- GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) );
+ if( m_tFilterMode == TF_NONE )
+ {
+ GLCALL( glTexImage2D(GL_TEXTURE_2D, 0, byteType, m_raw->m_width, m_raw->m_height, 0, byteType, GL_UNSIGNED_BYTE, m_raw->m_data) );
+ GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST) );
+ GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST) );
+ }
+ else if( m_tFilterMode == TF_LINEAR )
+ {
+ GLCALL( glTexImage2D(GL_TEXTURE_2D, 0, byteType, m_raw->m_width, m_raw->m_height, 0, byteType, GL_UNSIGNED_BYTE, m_raw->m_data) );
+ GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) );
+ GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) );
+ }
+ else
+ {
+ GLCALL( gluBuild2DMipmaps( GL_TEXTURE_2D, byteType, m_raw->m_width, m_raw->m_height, byteType, GL_UNSIGNED_BYTE, m_raw->m_data ) );
+ GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR) );
+ GLCALL( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) );
+ }
// GLCALL( glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) );
@@ -104,11 +118,23 @@
void Texture::LoadFromXML(const XMLNode& node)
{
- if ( !node.Attribute("dynamic").empty() )
- m_dynamic = StrToBool( node.Attribute("dynamic") );
- if( !node.Attribute( "clamp" ).empty() )
- m_bClamp = StrToBool( node.Attribute("clamp" ) );
+ LOAD_FROM_XML( "dynamic", m_dynamic, StrToBool );
+ LOAD_FROM_XML( "clamp", m_bClamp, StrToBool );
+
+ MString filter = node.Attribute( "filter" );
+ if( !filter.empty() )
+ {
+ if( filter == "none" )
+ {
+ m_tFilterMode = TF_NONE;
+ }
+ else if( filter == "linear" )
+ {
+ m_tFilterMode = TF_LINEAR;
+ }
+ }
+
MString file = node.Attribute("file");
ChangeKey( file );
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-11-13 07:35:37 UTC (rev 612)
+++ Mercury2/src/Texture.h 2009-11-13 07:38:19 UTC (rev 613)
@@ -4,6 +4,13 @@
#include <MercuryAsset.h>
#include <RawImageData.h>
+enum TextureFilterMode
+{
+ TF_NONE,
+ TF_LINEAR,
+ TF_LINEAR_MIPS,
+};
+
class Texture : public MercuryAsset
{
public:
@@ -39,6 +46,8 @@
static void ApplyActiveTextures(uint16_t stride);
static void DisableUnusedTextures();
+ void SetFilter( TextureFilterMode t ) { m_tFilterMode = t; }
+
GENRTTI( Texture );
private:
void LoadImagePath(const MString& path);
@@ -65,7 +74,8 @@
bool m_bDeleteRaw;
bool m_dynamic;
bool m_bClamp;
-// MString m_filename;
+ TextureFilterMode m_tFilterMode;
+
};
#endif
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:35:45
|
Revision: 612
http://hgengine.svn.sourceforge.net/hgengine/?rev=612&view=rev
Author: cnlohr
Date: 2009-11-13 07:35:37 +0000 (Fri, 13 Nov 2009)
Log Message:
-----------
Oops - forgot to commit these - the RAM Vorbis players
Added Paths:
-----------
Mercury2/src/MercurySoundSourceVorbisRAM.cpp
Mercury2/src/MercurySoundSourceVorbisRAM.h
Added: Mercury2/src/MercurySoundSourceVorbisRAM.cpp
===================================================================
--- Mercury2/src/MercurySoundSourceVorbisRAM.cpp (rev 0)
+++ Mercury2/src/MercurySoundSourceVorbisRAM.cpp 2009-11-13 07:35:37 UTC (rev 612)
@@ -0,0 +1,150 @@
+#include <MercurySoundSourceVorbisRAM.h>
+#include <vorbis/vorbisfile.h>
+#include <MercuryFile.h>
+#include <MercuryLog.h>
+#include <ogg/ogg.h>
+
+
+REGISTER_SOUND_SOURCE( MercurySoundSourceVorbisRAM, "VorbisRAM" );
+
+size_t vorbis_read_func(void *ptr, size_t size, size_t nmemb, void *datasource)
+{
+ MercuryFile * f = (MercuryFile*)datasource;
+ return f->Read( ptr, size * nmemb );
+}
+
+int vorbis_seek_func(void *datasource, ogg_int64_t offset, int whence)
+{
+ MercuryFile * f = (MercuryFile*)datasource;
+ switch( whence )
+ {
+ case SEEK_SET:
+ return !f->Seek( offset );
+ case SEEK_END:
+ return !f->Seek( f->Length() - offset - 1 );
+ case SEEK_CUR:
+ return !f->Seek( f->Tell() + offset );
+ default:
+ LOG.Write( ssprintf( "Warning: OGG Decided to seek with invalid whence!" ) );
+ }
+ return -1;
+}
+
+int vorbis_close_func(void *datasource)
+{
+ return 0;
+}
+
+long vorbis_tell_func(void *datasource)
+{
+ MercuryFile * f = (MercuryFile*)datasource;
+ return f->Tell();
+}
+
+
+MercurySoundSourceVorbisRAM::MercurySoundSourceVorbisRAM( MercurySoundSource * chain ) :
+ MercurySoundSourceRAM( chain )
+{
+}
+
+bool MercurySoundSourceVorbisRAM::Load( const MString & sDescriptor )
+{
+ unsigned Vorbistotal_bytes_read = 0;
+ int VorbisAbstream;
+
+ MAutoPtr< HGRawSound > r;
+ MAutoPtr< HGRawSound > * g;
+ if( ( g = g_SoundLibrary.get( sDescriptor ) ) )
+ {
+ m_Sound = *g;
+ return true;
+ }
+
+ MercuryFile * f = FILEMAN.Open( sDescriptor );
+
+ OggVorbis_File * vorbisFile = new OggVorbis_File;
+
+ ov_callbacks vorbisCallbacks;
+ vorbisCallbacks.read_func = vorbis_read_func;
+ vorbisCallbacks.seek_func = vorbis_seek_func;
+ vorbisCallbacks.close_func = vorbis_close_func;
+ vorbisCallbacks.tell_func = vorbis_tell_func;
+
+ int ret = ov_open_callbacks( f, vorbisFile, NULL, 0, vorbisCallbacks );
+
+ vorbis_info* info = ov_info(vorbisFile, -1);
+ unsigned VorbisChannels = info->channels;
+ unsigned VorbisSamplerate = info->rate;
+
+ unsigned VorbisSamples = ov_pcm_total( vorbisFile, 0 );
+
+ unsigned Vorbisbytes_read;
+
+ if( VorbisSamples <= 0 )
+ {
+ delete f;
+ delete vorbisFile;
+ }
+
+ short * VorbisData = new short[VorbisSamples*VorbisChannels];
+
+ while( (Vorbisbytes_read = ov_read(vorbisFile, ((char*)VorbisData) +
+ Vorbistotal_bytes_read, VorbisSamples*VorbisChannels*2 -
+ Vorbistotal_bytes_read, 0, 2, 1, &VorbisAbstream)) > 0 )
+ {
+ if( VorbisAbstream == 0 )
+ Vorbistotal_bytes_read+= Vorbisbytes_read;
+ }
+
+ r = new HGRawSound(new float[VorbisSamples*VorbisChannels],VorbisSamples);
+
+ for( unsigned i = 0; i < VorbisSamples*VorbisChannels; i++ )
+ {
+ r->fSound[i] = ((float)VorbisData[i])/32768.0;
+ }
+
+ delete vorbisFile;
+ delete f;
+
+ m_Sound = r;
+ g_SoundLibrary[sDescriptor] = r;
+ return true;
+}
+
+MHash< MAutoPtr< HGRawSound > > MercurySoundSourceVorbisRAM::g_SoundLibrary;
+
+
+
+/****************************************************************************
+ * Copyright (C) 2009 by Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
+
+
Added: Mercury2/src/MercurySoundSourceVorbisRAM.h
===================================================================
--- Mercury2/src/MercurySoundSourceVorbisRAM.h (rev 0)
+++ Mercury2/src/MercurySoundSourceVorbisRAM.h 2009-11-13 07:35:37 UTC (rev 612)
@@ -0,0 +1,52 @@
+#ifndef _MERCURY_SOUND_SOURCE_VORBISRAM
+#define _MERCURY_SOUND_SOURCE_VORBISRAM
+
+#include <MercurySoundSourceRAM.h>
+
+
+class MercurySoundSourceVorbisRAM : public MercurySoundSourceRAM
+{
+public:
+ MercurySoundSourceVorbisRAM( MercurySoundSource * chain = 0 );
+
+ virtual bool Load( const MString & sDescriptor );
+protected:
+ static MHash< MAutoPtr< HGRawSound > > g_SoundLibrary;
+};
+
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2009 by Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-11-10 12:30:21
|
Revision: 611
http://hgengine.svn.sourceforge.net/hgengine/?rev=611&view=rev
Author: axlecrusher
Date: 2009-11-10 12:30:11 +0000 (Tue, 10 Nov 2009)
Log Message:
-----------
fix spelling
Modified Paths:
--------------
Mercury2/src/GLHelpers.cpp
Modified: Mercury2/src/GLHelpers.cpp
===================================================================
--- Mercury2/src/GLHelpers.cpp 2009-11-09 07:54:06 UTC (rev 610)
+++ Mercury2/src/GLHelpers.cpp 2009-11-10 12:30:11 UTC (rev 611)
@@ -177,7 +177,7 @@
#else
void PrintGLFunctionCalls()
{
- LOG.Write( "No profiling performed on data set because it was configrued off." );
+ LOG.Write( "No profiling performed on data set because it was configured off." );
}
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-09 07:54:16
|
Revision: 610
http://hgengine.svn.sourceforge.net/hgengine/?rev=610&view=rev
Author: cnlohr
Date: 2009-11-09 07:54:06 +0000 (Mon, 09 Nov 2009)
Log Message:
-----------
enable disabling and enabling of saving to XML (both for children and self)
Modified Paths:
--------------
Mercury2/modules/TextNode.cpp
Mercury2/modules/TextNode.h
Mercury2/src/Mercury2.cpp
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryNode.h
Mercury2/src/Quad.cpp
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/modules/TextNode.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -19,6 +19,8 @@
m_fRMinX(0),m_fRMinY(0),
m_fRMaxX(0),m_fRMaxY(0)
{
+ //Disabling saving of children... As, we create many temporary children.
+ m_bEnableSaveChildren = false;
}
void TextNode::Update(float dTime)
@@ -31,16 +33,6 @@
MercuryNode::Update( dTime );
}
-void TextNode::SaveToXML( MString & sXMLStream, int depth )
-{
- sXMLStream += ssprintf( "%*c<node ", depth*3, 32 );
-
- SaveBaseXMLTag( sXMLStream );
- SaveToXMLTag( sXMLStream );
-
- sXMLStream += "/>\n";
-}
-
void TextNode::SaveToXMLTag( MString & sXMLStream )
{
MercuryNode::SaveToXMLTag( sXMLStream );
Modified: Mercury2/modules/TextNode.h
===================================================================
--- Mercury2/modules/TextNode.h 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/modules/TextNode.h 2009-11-09 07:54:06 UTC (rev 610)
@@ -45,8 +45,6 @@
inline float GetRMaxX() { return m_fRMaxX; }
inline float GetRMaxY() { return m_fRMaxY; }
- ///Careful, Text node is a virtual node - it doesn't actually recurse into children.
- virtual void SaveToXML( MString & sXMLStream, int depth = 0 );
virtual void SaveToXMLTag( MString & sXMLStream );
GENRTTI(TextNode);
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/Mercury2.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -100,7 +100,6 @@
g_SceneGraphToLoad = "FILE:scenegraph.xml";
cnset_execute_on_crash( SignalHandler );
-
HandleCommandLineParameters( argc, argv );
//Sound first.
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/MercuryNode.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -19,6 +19,7 @@
:m_parent(NULL), m_prevSibling(NULL),
m_nextSibling(NULL), m_hidden(false),
m_useAlphaPath(false), m_culled(false),
+ m_bEnableSave(true), m_bEnableSaveChildren(true),
m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 )
{
m_pGlobalMatrix = &MercuryMatrix::Identity();
@@ -314,31 +315,41 @@
void MercuryNode::SaveToXML( MString & sXMLStream, int depth )
{
+ if( !m_bEnableSave ) return;
sXMLStream += ssprintf( "%*c<node ", depth * 3, 32 );
SaveBaseXMLTag( sXMLStream );
SaveToXMLTag( sXMLStream );
bool bNoChildren = true;
- if( !m_assets.empty() )
+
+ if( m_bEnableSaveChildren )
{
- //No children yet (but we have them, so terminate (>) )
- if( bNoChildren )
- sXMLStream += ">\n";
- bNoChildren = false;
+ if( !m_assets.empty() )
+ {
+ //No children yet (but we have them, so terminate (>) )
+ if( bNoChildren )
+ sXMLStream += ">\n";
+ bNoChildren = false;
- for( std::list< MercuryAssetInstance * >::iterator i = m_assets.begin(); i != m_assets.end(); i++ )
- (*i)->Asset().SaveToXML( sXMLStream, depth + 1 );
- }
+ for( std::list< MercuryAssetInstance * >::iterator i = m_assets.begin(); i != m_assets.end(); i++ )
+ (*i)->Asset().SaveToXML( sXMLStream, depth + 1 );
+ }
- if( ! m_children.empty() )
- {
- //No children yet (but we have them, so terminate (>) )
- if( bNoChildren )
- sXMLStream += ">\n";
- bNoChildren = false;
- for( std::list< MercuryNode * >::iterator i = m_children.begin(); i != m_children.end(); i++ )
- (*i)->SaveToXML( sXMLStream, depth + 1 );
+ if( ! m_children.empty() )
+ {
+ //No children yet (but we have them, so terminate (>) )
+ for( std::list< MercuryNode * >::iterator i = m_children.begin(); i != m_children.end(); i++ )
+ {
+ if( (*i)->m_bEnableSave )
+ {
+ if( bNoChildren )
+ sXMLStream += ">\n";
+ bNoChildren = false;
+ (*i)->SaveToXML( sXMLStream, depth + 1 );
+ }
+ }
+ }
}
if( bNoChildren )
Modified: Mercury2/src/MercuryNode.h
===================================================================
--- Mercury2/src/MercuryNode.h 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/MercuryNode.h 2009-11-09 07:54:06 UTC (rev 610)
@@ -140,6 +140,8 @@
bool m_hidden;
bool m_useAlphaPath;
bool m_culled;
+ bool m_bEnableSave;
+ bool m_bEnableSaveChildren;
bool IsInAssetList(MercuryAsset* asset) const;
unsigned short m_iPasses;
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2009-11-09 00:48:35 UTC (rev 609)
+++ Mercury2/src/Quad.cpp 2009-11-09 07:54:06 UTC (rev 610)
@@ -54,7 +54,8 @@
m_bFlipV = false;
vsDescription.remove( 0 );
}
-
+ else
+ break;
} while(1);
if( vsDescription.size() == 0 )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-11-09 00:48:45
|
Revision: 609
http://hgengine.svn.sourceforge.net/hgengine/?rev=609&view=rev
Author: axlecrusher
Date: 2009-11-09 00:48:35 +0000 (Mon, 09 Nov 2009)
Log Message:
-----------
fix uninitalized variables
Modified Paths:
--------------
Mercury2/src/MercuryNode.cpp
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-11-08 23:15:45 UTC (rev 608)
+++ Mercury2/src/MercuryNode.cpp 2009-11-09 00:48:35 UTC (rev 609)
@@ -21,6 +21,8 @@
m_useAlphaPath(false), m_culled(false),
m_iPasses( DEFAULT_PASSES ), m_iForcePasses( 0 )
{
+ m_pGlobalMatrix = &MercuryMatrix::Identity();
+ m_pModelViewMatrix = &MercuryMatrix::Identity();
}
MercuryNode::~MercuryNode()
@@ -468,7 +470,7 @@
}
bool MercuryNode::m_rebuildRenderGraph = false;
-__ThreadLocalStore int g_iViewportID;
+__ThreadLocalStore int g_iViewportID = 0;
__ThreadLocalStore int g_iPass;
/****************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-08 23:15:54
|
Revision: 608
http://hgengine.svn.sourceforge.net/hgengine/?rev=608&view=rev
Author: cnlohr
Date: 2009-11-08 23:15:45 +0000 (Sun, 08 Nov 2009)
Log Message:
-----------
add framework for attributes + make quads able to have straight V's for normal texture mapping
Modified Paths:
--------------
Mercury2/src/Quad.cpp
Mercury2/src/Quad.h
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2009-11-08 15:48:23 UTC (rev 607)
+++ Mercury2/src/Quad.cpp 2009-11-08 23:15:45 UTC (rev 608)
@@ -6,7 +6,7 @@
REGISTER_ASSET_TYPE(Quad);
Quad::Quad( const MString & key, bool bInstanced )
- :MercuryVBO( key, bInstanced )
+ :MercuryVBO( key, bInstanced ), m_bFlipV( true )
{
ChangeKey( key );
}
@@ -35,6 +35,7 @@
float hX = 0.5;
float hY = 0.5;
float zp = 0;
+ m_bFlipV = true;
AllocateIndexSpace(6);
AllocateVertexSpace(4);
@@ -42,6 +43,20 @@
MVector< MString > vsDescription;
SplitStrings( sDescription, vsDescription, ",", " ", 1, 1 );
+ //First, check for known attributes...
+ do
+ {
+ if( !vsDescription.size() )
+ break;
+
+ if( vsDescription[0] == "straightv" )
+ {
+ m_bFlipV = false;
+ vsDescription.remove( 0 );
+ }
+
+ } while(1);
+
if( vsDescription.size() == 0 )
{
//Do nothing
@@ -73,19 +88,19 @@
//UV oriented so 0,0 is lower left and 1,0 upper right.
//this makes it so FBO images render correctly right out of the buffer, no flip needed
- m_vertexData[i++] = 0; m_vertexData[i++] = 0;
+ m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?0:1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = lX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
- m_vertexData[i++] = 1; m_vertexData[i++] = 0;
+ m_vertexData[i++] = 1; m_vertexData[i++] = (m_bFlipV)?0:1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = hX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
- m_vertexData[i++] = 1; m_vertexData[i++] = 1;
+ m_vertexData[i++] = 1; m_vertexData[i++] = (m_bFlipV)?1:0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = hX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
- m_vertexData[i++] = 0; m_vertexData[i++] = 1;
+ m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?1:0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
m_vertexData[i++] = lX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
Modified: Mercury2/src/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2009-11-08 15:48:23 UTC (rev 607)
+++ Mercury2/src/Quad.h 2009-11-08 23:15:45 UTC (rev 608)
@@ -14,7 +14,9 @@
virtual bool ChangeKey( const MString & sDescription );
GENRTTI( Quad );
+
private:
+ bool m_bFlipV;
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <axl...@us...> - 2009-11-08 15:48:45
|
Revision: 607
http://hgengine.svn.sourceforge.net/hgengine/?rev=607&view=rev
Author: axlecrusher
Date: 2009-11-08 15:48:23 +0000 (Sun, 08 Nov 2009)
Log Message:
-----------
untested vertex color arrays
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Mercury2/src/MercuryVBO.h
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-11-07 22:40:43 UTC (rev 606)
+++ Mercury2/src/MercuryVBO.cpp 2009-11-08 15:48:23 UTC (rev 607)
@@ -9,17 +9,18 @@
extern bool SHOWBOUNDINGVOLUME;
extern bool SHOWAXISES;
-MercuryVBO::MercuryVBO( const MString & key, bool bInstanced )
- :MercuryAsset( key, bInstanced ), m_initiated(false)
+MercuryVBO::MercuryVBO( const MString & key, bool bInstanced, bool useVertexColor )
+ :MercuryAsset( key, bInstanced ), m_initiated(false), m_useVertexColor(useVertexColor)
{
- m_bufferIDs[0] = m_bufferIDs[1] = 0;
- m_bDirtyIndices = m_bDirtyVertices = 0;
+ m_bufferIDs[0] = m_bufferIDs[1] = m_bufferIDs[2] = 0;
+ m_bDirtyIndices = m_bDirtyVertices = m_bDirtyVertexColor = false;
}
MercuryVBO::~MercuryVBO()
{
- if (m_bufferIDs[0]) { GLCALL( glDeleteBuffersARB(2, m_bufferIDs) ); }
- m_bufferIDs[0] = m_bufferIDs[1] = 0;
+ if (m_bufferIDs[0] > 0) { GLCALL( glDeleteBuffersARB(2, m_bufferIDs) ); }
+ if (m_bufferIDs[2] > 0) { GLCALL( glDeleteBuffersARB(1, &m_bufferIDs[2]) ); }
+ m_bufferIDs[0] = m_bufferIDs[1] = m_bufferIDs[2] = 0;
}
void MercuryVBO::Render(const MercuryNode* node)
@@ -31,38 +32,51 @@
{
m_lastVBOrendered = this;
- if ( m_bDirtyVertices )
- UpdateVertices();
- if( m_bDirtyIndices )
- UpdateIndices();
+ if ( m_bDirtyVertices ) UpdateVertices();
+ if( m_bDirtyIndices ) UpdateIndices();
+ if( m_bDirtyVertexColor ) UpdateVertexColor();
GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferIDs[0]) );
GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferIDs[1]) );
GLCALL( glVertexPointer(3, GL_FLOAT, STRIDE*sizeof(float), BUFFER_OFFSET( VERTEX_OFFSET*sizeof(float) ) ) );
+
+ if (m_useVertexColor)
+ {
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferIDs[2]) );
+ GLCALL( glColorPointer(4, GL_FLOAT, 0, 0 ) );
+ }
+
++m_vboBinds;
}
+ GLCALL( glPushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT) );
+
+ if (m_useVertexColor) { GLCALL( glEnableClientState( GL_COLOR_ARRAY ) ); }
+
Texture::ApplyActiveTextures(STRIDE*sizeof(float));
GLCALL( glEnableClientState( GL_NORMAL_ARRAY ) );
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++;
+ ++m_vboBatches;
if (m_boundingVolume && SHOWBOUNDINGVOLUME) m_boundingVolume->Render();
+
+ GLCALL( glPopClientAttrib() );
+
if ( SHOWAXISES ) DrawAxes();
}
void MercuryVBO::InitVBO()
{
- if (!m_bufferIDs[0])
- {
- GLCALL( glGenBuffersARB(2, m_bufferIDs) );
- }
+ if (!m_bufferIDs[0]) { GLCALL( glGenBuffersARB(2, m_bufferIDs) ); }
+ if (m_useVertexColor) { GLCALL( glGenBuffersARB(1, &m_bufferIDs[2]) ); }
UpdateIndices();
UpdateVertices();
+ UpdateVertexColor();
+
GLCALL( glEnableClientState(GL_VERTEX_ARRAY) );
m_initiated = true;
@@ -72,19 +86,30 @@
{
GLCALL( glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_bufferIDs[1]) );
GLCALL( glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, m_indexData.LengthInBytes(), m_indexData.Buffer(), GL_STATIC_DRAW_ARB) );
- m_bDirtyIndices = 0;
+ m_bDirtyIndices = false;
}
void MercuryVBO::UpdateVertices()
{
GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferIDs[0]) );
GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexData.LengthInBytes(), m_vertexData.Buffer(), GL_STATIC_DRAW_ARB) );
- m_bDirtyVertices = 0;
+ m_bDirtyVertices = false;
}
+void MercuryVBO::UpdateVertexColor()
+{
+ if (m_useVertexColor)
+ {
+ GLCALL( glBindBufferARB(GL_ARRAY_BUFFER_ARB, m_bufferIDs[2]) );
+ GLCALL( glBufferDataARB(GL_ARRAY_BUFFER_ARB, m_vertexColorData.LengthInBytes(), m_vertexColorData.Buffer(), GL_STATIC_DRAW_ARB) );
+ }
+ m_bDirtyVertexColor = false;
+}
+
void MercuryVBO::AllocateVertexSpace(unsigned int count)
{
m_vertexData.Allocate(count*8);
+ if (m_useVertexColor) m_vertexColorData.Allocate(count*4);
}
void MercuryVBO::AllocateIndexSpace(unsigned int count)
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2009-11-07 22:40:43 UTC (rev 606)
+++ Mercury2/src/MercuryVBO.h 2009-11-08 15:48:23 UTC (rev 607)
@@ -13,7 +13,7 @@
static const uint16_t STRIDE = 8;
static const uint16_t VERTEX_OFFSET = 5;
- MercuryVBO( const MString & key, bool bInstanced );
+ MercuryVBO( const MString & key, bool bInstanced, bool useVertexColor = false );
virtual ~MercuryVBO();
virtual void Render(const MercuryNode* node);
@@ -27,7 +27,10 @@
const float* GetVertexHandle() const { return m_vertexData.Buffer(); }
float* GetVertexHandle() { return m_vertexData.Buffer(); }
-
+
+ const float* GetVertexColorHandle() const { return m_vertexColorData.Buffer(); }
+ float* GetVertexColorHandle() { return m_vertexColorData.Buffer(); }
+
const short unsigned int* GetIndexHandle() const { return m_indexData.Buffer(); }
short unsigned int* GetIndexHandle() { return m_indexData.Buffer(); }
@@ -35,22 +38,29 @@
static void* m_lastVBOrendered;
- void DirtyVertices() { m_bDirtyVertices = 1; }
- void DirtyIndices() { m_bDirtyIndices = 1; }
+ inline void DirtyVertices() { m_bDirtyVertices = true; }
+ inline void DirtyVerexColor() { m_bDirtyVertexColor = true; }
+ inline void DirtyIndices() { m_bDirtyIndices = true; }
+
GENRTTI( MercuryVBO );
private:
virtual void InitVBO();
- unsigned int m_bufferIDs[2];
+ unsigned int m_bufferIDs[3];
bool m_initiated;
bool m_bDirtyIndices;
bool m_bDirtyVertices;
+ bool m_bDirtyVertexColor;
+
+ bool m_useVertexColor;
void UpdateVertices();
+ void UpdateVertexColor();
void UpdateIndices();
protected:
AlignedBuffer<float> m_vertexData;
+ AlignedBuffer<float> m_vertexColorData;
AlignedBuffer<uint16_t> m_indexData;
static uint32_t m_vboBatches;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-07 22:40:53
|
Revision: 606
http://hgengine.svn.sourceforge.net/hgengine/?rev=606&view=rev
Author: cnlohr
Date: 2009-11-07 22:40:43 +0000 (Sat, 07 Nov 2009)
Log Message:
-----------
add new utility for getting a point + ray equation for the camera / point and click ... plus enable diabling of clamping of textures.
Modified Paths:
--------------
Mercury2/src/GLHelpers.cpp
Mercury2/src/GLHelpers.h
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/GLHelpers.cpp
===================================================================
--- Mercury2/src/GLHelpers.cpp 2009-11-07 08:37:17 UTC (rev 605)
+++ Mercury2/src/GLHelpers.cpp 2009-11-07 22:40:43 UTC (rev 606)
@@ -91,6 +91,41 @@
return pointFromScreenLoc( screen_x, screen_y, winZ );
}
+void CameraPointAndRay(int screen_x, int screen_y, MercuryVertex & p, MercuryVertex & r)
+{
+ GLfloat winX, winY, winZ;
+ GLdouble dox = 0, doy = 0, doz = 0;
+ GLint viewport[4];
+ GLdouble modelview[16];
+ GLdouble projection[16];
+
+ GLCALL( glGetIntegerv(GL_VIEWPORT, viewport) );
+ GLCALL( glGetDoublev(GL_MODELVIEW_MATRIX, modelview) );
+ GLCALL( glGetDoublev(GL_PROJECTION_MATRIX, projection) );
+
+ winX = (float)screen_x;
+ winY = (float)viewport[3] - (float)screen_y;
+
+ gluUnProject(
+ winX, winY, -1000,
+ modelview, projection, viewport,
+ &dox, &doy, &doz);
+
+ p = MercuryVertex( dox, doy, doz );
+
+ gluUnProject(
+ winX, winY, 1,
+ modelview, projection, viewport,
+ &dox, &doy, &doz );
+ r = MercuryVertex( dox, doy, doz ) - p;
+
+ r.NormalizeSelf();
+
+ return;
+
+}
+
+
unsigned int ToGLColorType(ColorByteType cbt)
{
switch (cbt)
Modified: Mercury2/src/GLHelpers.h
===================================================================
--- Mercury2/src/GLHelpers.h 2009-11-07 08:37:17 UTC (rev 605)
+++ Mercury2/src/GLHelpers.h 2009-11-07 22:40:43 UTC (rev 606)
@@ -19,6 +19,7 @@
MercuryMatrix glGetMatrix(unsigned int m);
MercuryVertex pointFromScreenLoc(int screen_x, int screen_y);
MercuryVertex pointFromScreenLoc(int screen_x, int screen_y, float fForceDepth);
+void CameraPointAndRay(int screen_x, int screen_y, MercuryVertex & p, MercuryVertex & r);
unsigned int ToGLColorType(ColorByteType cbt);
#ifdef GL_PROFILE
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-11-07 08:37:17 UTC (rev 605)
+++ Mercury2/src/Texture.cpp 2009-11-07 22:40:43 UTC (rev 606)
@@ -13,7 +13,7 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
Texture::Texture( const MString & key, bool bInstanced )
- :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false)
+ :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false), m_bClamp(true)
{
if (!m_initTextureSuccess)
{
@@ -72,8 +72,11 @@
// GLCALL( glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ) );
- GLCALL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP) );
- GLCALL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP) );
+ if( m_bClamp )
+ {
+ GLCALL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP) );
+ GLCALL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP) );
+ }
// GLCALL( gluBuild2DMipmaps( GL_TEXTURE_2D, 3, m_raw->m_width, m_raw->m_height, ByteType, GL_UNSIGNED_BYTE, m_raw->m_data ) );
if( m_bDeleteRaw )
@@ -102,8 +105,10 @@
void Texture::LoadFromXML(const XMLNode& node)
{
if ( !node.Attribute("dynamic").empty() )
- m_dynamic = node.Attribute("dynamic")=="true"?true:false;
-
+ m_dynamic = StrToBool( node.Attribute("dynamic") );
+ if( !node.Attribute( "clamp" ).empty() )
+ m_bClamp = StrToBool( node.Attribute("clamp" ) );
+
MString file = node.Attribute("file");
ChangeKey( file );
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-11-07 08:37:17 UTC (rev 605)
+++ Mercury2/src/Texture.h 2009-11-07 22:40:43 UTC (rev 606)
@@ -64,6 +64,7 @@
bool m_bDeleteRaw;
bool m_dynamic;
+ bool m_bClamp;
// MString m_filename;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-07 08:37:24
|
Revision: 605
http://hgengine.svn.sourceforge.net/hgengine/?rev=605&view=rev
Author: cnlohr
Date: 2009-11-07 08:37:17 +0000 (Sat, 07 Nov 2009)
Log Message:
-----------
add extra utility to the screen to point stuff... Allow textures to be fed from code or to feed code... and add a new state changer (lighting disable/enabling)
Modified Paths:
--------------
Mercury2/src/GLHelpers.cpp
Mercury2/src/GLHelpers.h
Mercury2/src/StateChanger.cpp
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/src/GLHelpers.cpp
===================================================================
--- Mercury2/src/GLHelpers.cpp 2009-11-07 05:51:41 UTC (rev 604)
+++ Mercury2/src/GLHelpers.cpp 2009-11-07 08:37:17 UTC (rev 605)
@@ -57,7 +57,7 @@
return mm;
}
-MercuryVertex pointFromScreenLoc(int screen_x, int screen_y)
+MercuryVertex pointFromScreenLoc(int screen_x, int screen_y, float fForceDepth)
{
GLfloat winX, winY, winZ;
GLdouble mouseX = 0, mouseY = 0, mouseZ = 0;
@@ -71,15 +71,26 @@
winX = (float)screen_x;
winY = (float)viewport[3] - (float)screen_y;
- GLCALL( glReadPixels( screen_x, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ) );
gluUnProject(
- winX, winY, winZ,
+ winX, winY, fForceDepth,
modelview, projection, viewport,
&mouseX, &mouseY, &mouseZ);
return MercuryVertex( (float)mouseX, (float)mouseY, (float)mouseZ );
}
+MercuryVertex pointFromScreenLoc(int screen_x, int screen_y )
+{
+ GLint viewport[4];
+ GLCALL( glGetIntegerv(GL_VIEWPORT, viewport) );
+
+ float winY = (float)viewport[3] - (float)screen_y;
+
+ float winZ;
+ GLCALL( glReadPixels( screen_x, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ) );
+ return pointFromScreenLoc( screen_x, screen_y, winZ );
+}
+
unsigned int ToGLColorType(ColorByteType cbt)
{
switch (cbt)
Modified: Mercury2/src/GLHelpers.h
===================================================================
--- Mercury2/src/GLHelpers.h 2009-11-07 05:51:41 UTC (rev 604)
+++ Mercury2/src/GLHelpers.h 2009-11-07 08:37:17 UTC (rev 605)
@@ -18,6 +18,7 @@
void glLoadMatrix(const MercuryMatrix& m);
MercuryMatrix glGetMatrix(unsigned int m);
MercuryVertex pointFromScreenLoc(int screen_x, int screen_y);
+MercuryVertex pointFromScreenLoc(int screen_x, int screen_y, float fForceDepth);
unsigned int ToGLColorType(ColorByteType cbt);
#ifdef GL_PROFILE
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-11-07 05:51:41 UTC (rev 604)
+++ Mercury2/src/StateChanger.cpp 2009-11-07 08:37:17 UTC (rev 605)
@@ -44,7 +44,41 @@
REGISTER_STATECHANGE( ColorChange );
+///State changer for enabling/disabling lighting
+class LightingSwitch : public StateChange
+{
+public:
+ LightingSwitch( const MVector< MString > & sParameters ) : StateChange( sParameters )
+ {
+ if( sParameters.size() < 1 )
+ {
+ LOG.Write( ssprintf( "Error: ColorChange state has invalid number of parameters(%d).", sParameters.size() ) );
+ return;
+ }
+ bEnable = StrToBool( sParameters[0] );
+ }
+
+ void Stringify( MString & sOut )
+ {
+ sOut = ssprintf( "%f", bEnable );
+ }
+
+ void Activate()
+ {
+ if( bEnable )
+ glEnable( GL_LIGHTING );
+ else
+ glDisable( GL_LIGHTING );
+ }
+
+ STATECHANGE_RTTI( LightingSwitch );
+ bool bEnable;
+};
+
+REGISTER_STATECHANGE( LightingSwitch );
+
+
//////////////////////////////////////STATE CHANGE CHUNK//////////////////////////////////////
StateChangeRegister * StateChangeRegister::m_Instance;
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-11-07 05:51:41 UTC (rev 604)
+++ Mercury2/src/Texture.cpp 2009-11-07 08:37:17 UTC (rev 605)
@@ -13,7 +13,7 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
Texture::Texture( const MString & key, bool bInstanced )
- :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_dynamic(false)
+ :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_bDeleteRaw(true),m_dynamic(false)
{
if (!m_initTextureSuccess)
{
@@ -76,7 +76,8 @@
GLCALL( glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP) );
// GLCALL( gluBuild2DMipmaps( GL_TEXTURE_2D, 3, m_raw->m_width, m_raw->m_height, ByteType, GL_UNSIGNED_BYTE, m_raw->m_data ) );
- SAFE_DELETE(m_raw);
+ if( m_bDeleteRaw )
+ SAFE_DELETE(m_raw);
GLCALL( glPopAttrib() );
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-11-07 05:51:41 UTC (rev 604)
+++ Mercury2/src/Texture.h 2009-11-07 08:37:17 UTC (rev 605)
@@ -20,7 +20,10 @@
virtual bool ChangeKey( const MString & sNewKey );
void LoadFromRaw();
-
+
+ void SetDeleteRawData( bool bDelete = true ) { m_bDeleteRaw = bDelete; }
+ RawImageData * GetRawImageDataHandle() { return m_raw; }
+
inline static uint8_t NumberActiveTextures() { return m_numActiveTextures; }
inline static uint32_t ReadAndResetBindCount() { uint32_t t = m_textureBinds; m_textureBinds = 0; return t; }
inline uint32_t TextureID() const { return m_textureID; }
@@ -35,6 +38,7 @@
static void ApplyActiveTextures(uint16_t stride);
static void DisableUnusedTextures();
+
GENRTTI( Texture );
private:
void LoadImagePath(const MString& path);
@@ -47,7 +51,7 @@
void InitiateBindCache();
- const RawImageData* m_raw;
+ RawImageData* m_raw;
uint32_t m_textureID;
static bool m_initTextureSuccess;
@@ -58,6 +62,7 @@
static uint8_t m_maxActiveTextures;
static Texture** m_lastBound;
+ bool m_bDeleteRaw;
bool m_dynamic;
// MString m_filename;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-07 05:51:48
|
Revision: 604
http://hgengine.svn.sourceforge.net/hgengine/?rev=604&view=rev
Author: cnlohr
Date: 2009-11-07 05:51:41 +0000 (Sat, 07 Nov 2009)
Log Message:
-----------
make MercuryVBO's instancable
Modified Paths:
--------------
Mercury2/src/MercuryVBO.cpp
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-11-07 04:54:56 UTC (rev 603)
+++ Mercury2/src/MercuryVBO.cpp 2009-11-07 05:51:41 UTC (rev 604)
@@ -1,10 +1,9 @@
#include <MercuryVBO.h>
-
#include <GLHeaders.h>
-
-
#include <Texture.h>
+REGISTER_ASSET_TYPE(MercuryVBO);
+
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
extern bool SHOWBOUNDINGVOLUME;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-07 04:55:04
|
Revision: 603
http://hgengine.svn.sourceforge.net/hgengine/?rev=603&view=rev
Author: cnlohr
Date: 2009-11-07 04:54:56 +0000 (Sat, 07 Nov 2009)
Log Message:
-----------
don't make mouse move when clicking
Modified Paths:
--------------
Mercury2/src/X11Window.cpp
Modified: Mercury2/src/X11Window.cpp
===================================================================
--- Mercury2/src/X11Window.cpp 2009-11-06 06:45:08 UTC (rev 602)
+++ Mercury2/src/X11Window.cpp 2009-11-07 04:54:56 UTC (rev 603)
@@ -286,7 +286,7 @@
su = ((e->state & X11_MASK(MOUSE_BTN_SCROLL_UP))!=0) ^ (e->button == MOUSE_BTN_SCROLL_UP);
sd = ((e->state & X11_MASK(MOUSE_BTN_SCROLL_DOWN))!=0) ^ (e->button == MOUSE_BTN_SCROLL_DOWN);
- MouseInput::ProcessMouseInput(e->x, e->y,
+ MouseInput::ProcessMouseInput(0, 0,
left, right, center, su, sd);
break;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-06 06:45:18
|
Revision: 602
http://hgengine.svn.sourceforge.net/hgengine/?rev=602&view=rev
Author: cnlohr
Date: 2009-11-06 06:45:08 +0000 (Fri, 06 Nov 2009)
Log Message:
-----------
ok - sound is in there
Modified Paths:
--------------
Mercury2/adv_set.c
Mercury2/base_set.sh
Mercury2/src/Mercury2.cpp
Mercury2/src/MercurySound.cpp
Mercury2/src/MercurySoundDriverALSA.cpp
Mercury2/src/MercurySoundSourceVorbis.cpp
Mercury2/src/MercurySoundSourceVorbis.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/adv_set.c 2009-11-06 06:45:08 UTC (rev 602)
@@ -14,7 +14,8 @@
src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDeferredLights.cpp \
- src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp"
+ src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp \
+ src/MercurySound.cpp src/MercurySoundSourceRAM.cpp "
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
@@ -30,6 +31,14 @@
SOURCES="$SOURCES src/X11Window.cpp"
#endif
+#ifdef USE_ALSA
+SOURCES="$SOURCES src/MercurySoundDriverALSA.cpp"
+#endif
+
+#ifdef _HAVE_LIB_ogg
+SOURCES="$SOURCES src/MercurySoundSourceVorbis.cpp"
+#endif
+
PROJ="mercury"
CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -Isrc/DataStructures -Isrc/DataTypes -g -rdynamic"
LDFLAGS="$LDFLAGS -rdynamic -g -fPIC "
Modified: Mercury2/base_set.sh
===================================================================
--- Mercury2/base_set.sh 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/base_set.sh 2009-11-06 06:45:08 UTC (rev 602)
@@ -8,7 +8,7 @@
ISMAC=1; fi
-OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch"
+OPTIONS="X11 libxml OGL sse gprof glprofile instancewatch alsa ogg"
OPT_X11=1
OPT_OGL=1
OPT_libxml=1
@@ -16,7 +16,10 @@
OPT_gprof=0
OPT_glprofile=0
OPT_instancewatch=1
+OPT_alsa=1
+OPT_ogg=1
+
DEFINES="WAS_CONFIGURED USE_MSTRING"
CC_BASE="-O2 -g0 -Wall"
@@ -77,7 +80,7 @@
fi
if test $OPT_OGL = 1; then
- NEED_H="GL/gl.h"
+ NEED_H="$NEED_H GL/gl.h"
NEED_L="$NEED_L GL GLU"
fi
@@ -94,6 +97,17 @@
DEFINES="$DEFINES INSTANCE_WATCH"
fi
+if test $OPT_alsa = 1; then
+ NEED_L="$NEED_L asound"
+ NEED_H="$NEED_H alsa/asoundlib.h"
+ DEFINES="$DEFINES USE_ALSA"
+fi
+
+if test $OPT_ogg = 1; then
+ NEED_H="$NEED_H ogg/ogg.h"
+ NEED_L="$NEED_L vorbisfile ogg"
+fi
+
ARCH=`uname -m`
if test $ARCH = "i686" || test $ARCH = "i586"; then
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/Mercury2.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -11,7 +11,7 @@
#include <MercuryCrash.h>
#include <MercuryBacktrace.h>
#include <MercuryMessageManager.h>
-
+#include <MercurySound.h>
#include <MercuryTimer.h>
#include <RenderGraph.h>
#include <Texture.h>
@@ -102,7 +102,9 @@
cnset_execute_on_crash( SignalHandler );
HandleCommandLineParameters( argc, argv );
-
+
+ //Sound first.
+ SOUNDMAN->Init( "" );
MercuryWindow* w = MercuryWindow::MakeWindow();
#ifdef WIN32
Modified: Mercury2/src/MercurySound.cpp
===================================================================
--- Mercury2/src/MercurySound.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySound.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -136,8 +136,6 @@
pc->FillBuffer( cBufferToFill, iCount );
}
-
- printf( "%f %p\n", cBufferToFill[44], & cBufferToFill[44] );
}
void MercurySoundManager::PostFill()
Modified: Mercury2/src/MercurySoundDriverALSA.cpp
===================================================================
--- Mercury2/src/MercurySoundDriverALSA.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySoundDriverALSA.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -4,7 +4,7 @@
#include "MercurySound.h"
#include <alsa/asoundlib.h>
-#define LOW_LATENCY
+//#define LOW_LATENCY
class MercurySoundDriverALSA
{
Modified: Mercury2/src/MercurySoundSourceVorbis.cpp
===================================================================
--- Mercury2/src/MercurySoundSourceVorbis.cpp 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySoundSourceVorbis.cpp 2009-11-06 06:45:08 UTC (rev 602)
@@ -70,12 +70,11 @@
vorbisCallbacks.close_func = vorbis_close_func;
vorbisCallbacks.tell_func = vorbis_tell_func;
- int ret = ov_open_callbacks( f, vorbisFile, NULL, 0, vorbisCallbacks );
+ ov_open_callbacks( f, vorbisFile, NULL, 0, vorbisCallbacks );
vorbis_info* info = ov_info(vorbisFile, -1);
unsigned VorbisChannels = info->channels;
- unsigned VorbisSamplerate = info->rate;
-
+// unsigned VorbisSamplerate = info->rate;
unsigned VorbisSamples = ov_pcm_total( vorbisFile, 0 );
unsigned Vorbisbytes_read;
@@ -116,19 +115,19 @@
//Now, the section on the regular MercurySoundSource
-/*
REGISTER_SOUND_SOURCE( MercurySoundSourceVorbis, "Vorbis" );
MercurySoundSourceVorbis::MercurySoundSourceVorbis( MercurySoundSource * chain ) :
- MercurySoundSource( chain )
+ MercurySoundSource( chain ), iBufferSize( 32768 ), iBufferLoad(1), iBufferPlay(0)
{
+ iBuffer = (short*)malloc( sizeof( short ) * iBufferSize * 2 );
}
-void MercurySoundSourceVorbis::~MercurySoundSourceVorbis()
+MercurySoundSourceVorbis::~MercurySoundSourceVorbis()
{
- SAFE_DELETE(m_File);
- SAFE_DELETE(f);
- SAFE_DELETE(vorbisFile);
+ delete m_File;
+ delete iBuffer;
+ delete vorbisFile;
}
@@ -136,15 +135,10 @@
{
MAutoPtr< HGRawSound > r;
MAutoPtr< HGRawSound > * g;
- if( ( g = g_SoundLibrary.get( sDescriptor ) ) )
- {
- m_Sound = *g;
- return true;
- }
m_File = FILEMAN.Open( sDescriptor );
- OggVorbis_File * vorbisFile = new OggVorbis_File;
+ vorbisFile = new OggVorbis_File;
ov_callbacks vorbisCallbacks;
vorbisCallbacks.read_func = vorbis_read_func;
@@ -152,19 +146,18 @@
vorbisCallbacks.close_func = vorbis_close_func;
vorbisCallbacks.tell_func = vorbis_tell_func;
- int ret = ov_open_callbacks( f, vorbisFile, NULL, 0, vorbisCallbacks );
+ ov_open_callbacks( m_File, vorbisFile, NULL, 0, vorbisCallbacks );
vorbis_info* info = ov_info(vorbisFile, -1);
- unsigned VorbisChannels = info->channels;
- unsigned VorbisSamplerate = info->rate;
-
+// unsigned VorbisChannels = info->channels;
+// unsigned VorbisSamplerate = info->rate;
unsigned VorbisSamples = ov_pcm_total( vorbisFile, 0 );
unsigned Vorbisbytes_read;
if( VorbisSamples <= 0 )
{
- delete f;
+ delete m_File;
delete vorbisFile;
return false;
@@ -175,44 +168,54 @@
void MercurySoundSourceVorbis::FillBuffer( float * cBufferToFill, int iCount )
{
+ //Don't worry our circular queue is threadsafe.
+ for( unsigned i = 0; i < iCount; i++ )
+ {
+ if( PlayLeft() <= 2 ) break;
+ cBufferToFill[i*2+0] = float(iBuffer[iBufferPlay*2+0])/32768.;
+ cBufferToFill[i*2+1] = float(iBuffer[iBufferPlay*2+1])/32768.;
+ iBufferPlay=(iBufferPlay+1)%iBufferSize;
+ }
+ //If we run out... that's okay. It'll just be silent and have time to fill.
}
bool MercurySoundSourceVorbis::PostFill()
{
unsigned Vorbistotal_bytes_read = 0;
+ unsigned Vorbisbytes_read;
int VorbisAbstream;
- short * VorbisData = new short[VorbisSamples*VorbisChannels];
+ unsigned long BF = BufferFree();
+ unsigned long BFL = BF;
+ short tibuf[BF * 2];
- while( (Vorbisbytes_read = ov_read(vorbisFile, ((char*)VorbisData) +
- Vorbistotal_bytes_read, VorbisSamples*VorbisChannels*2 -
- Vorbistotal_bytes_read, 0, 2, 1, &VorbisAbstream)) > 0 )
+ do
{
- if( VorbisAbstream == 0 )
- Vorbistotal_bytes_read+= Vorbisbytes_read;
- }
+ Vorbisbytes_read = ov_read(vorbisFile, ((char*)&(tibuf[0]) + Vorbistotal_bytes_read),
+ BFL * 4, 0, 2, 1, &VorbisAbstream);
+ BFL -= Vorbisbytes_read / 4;
+ Vorbistotal_bytes_read += Vorbisbytes_read;
+ } while( Vorbisbytes_read > 0 && BFL );
+ if( Vorbisbytes_read < 0 )
+ return false;
- r = new HGRawSound(new float[VorbisSamples*VorbisChannels],VorbisSamples);
-
- for( unsigned i = 0; i < VorbisSamples*VorbisChannels; i++ )
+ for( unsigned i = 0; i < BF; i++ )
{
- r->fSound[i] = ((float)VorbisData[i])/32768.0;
+ iBuffer[iBufferLoad*2+0] = tibuf[i*2+0];
+ iBuffer[iBufferLoad*2+1] = tibuf[i*2+1];
+ iBufferLoad=(iBufferLoad+1)%iBufferSize;
}
- delete vorbisFile;
- delete f;
-
- m_Sound = r;
- g_SoundLibrary[sDescriptor] = r;
- return true;
+ if( Vorbisbytes_read == 0 && PlayLeft() == 0 )
+ return false;
+ else
+ return true;
}
-*/
-
/****************************************************************************
* Copyright (C) 2009 by Charles Lohr *
* *
Modified: Mercury2/src/MercurySoundSourceVorbis.h
===================================================================
--- Mercury2/src/MercurySoundSourceVorbis.h 2009-11-05 23:48:55 UTC (rev 601)
+++ Mercury2/src/MercurySoundSourceVorbis.h 2009-11-06 06:45:08 UTC (rev 602)
@@ -15,7 +15,6 @@
static MHash< MAutoPtr< HGRawSound > > g_SoundLibrary;
};
-/*
class OggVorbis_File;
class vorbis_info;
class MercuryFile;
@@ -34,10 +33,17 @@
protected:
MercuryFile * m_File;
OggVorbis_File * vorbisFile;
- vorbis_info * info
+ vorbis_info * info;
+
+ unsigned BufferFree() { return ((iBufferPlay + iBufferSize) - iBufferLoad )%iBufferSize; }
+ unsigned PlayLeft() { return ((iBufferLoad + iBufferSize) - iBufferPlay - 1 )%iBufferSize; }
+ unsigned iBufferSize;
+ unsigned iBufferPlay;
+ unsigned iBufferLoad;
+ short * iBuffer;
};
-*/
+
#endif
/****************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-05 03:50:24
|
Revision: 600
http://hgengine.svn.sourceforge.net/hgengine/?rev=600&view=rev
Author: cnlohr
Date: 2009-11-05 03:01:56 +0000 (Thu, 05 Nov 2009)
Log Message:
-----------
whoops forgot to take out debug
Modified Paths:
--------------
Mercury2/src/MercuryNode.cpp
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-11-05 02:59:30 UTC (rev 599)
+++ Mercury2/src/MercuryNode.cpp 2009-11-05 03:01:56 UTC (rev 600)
@@ -376,7 +376,6 @@
mai->Culled( a.DoCullingTests( mai->GetOcclusionResult(), matrix ) );
culled = culled && mai->Culled();
}
- printf( "CULL: %s (%d) %d\n", mai->Asset().GetType(), a.IgnoreCull(), mai->Culled() );
if ( !mai->Culled() ) a.PreRender(this);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-05 02:59:37
|
Revision: 599
http://hgengine.svn.sourceforge.net/hgengine/?rev=599&view=rev
Author: cnlohr
Date: 2009-11-05 02:59:30 +0000 (Thu, 05 Nov 2009)
Log Message:
-----------
Switch over assets to new system - still not 100% sure this is best, but it should be easier to change around the part of interest at a later time.
Modified Paths:
--------------
Mercury2/modules/Terrain.cpp
Mercury2/modules/Terrain.h
Mercury2/modules/TextNode.cpp
Mercury2/modules/TextPlate.cpp
Mercury2/src/FullscreenQuad.cpp
Mercury2/src/FullscreenQuad.h
Mercury2/src/HGMDLMesh.h
Mercury2/src/HGMDLModel.cpp
Mercury2/src/HGMDLModel.h
Mercury2/src/Light.cpp
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/MercuryNode.cpp
Mercury2/src/MercuryVBO.cpp
Mercury2/src/MercuryVBO.h
Mercury2/src/Quad.cpp
Mercury2/src/Quad.h
Mercury2/src/Shader.cpp
Mercury2/src/Shader.h
Mercury2/src/StateChanger.cpp
Mercury2/src/StateChanger.h
Mercury2/src/Texture.cpp
Mercury2/src/Texture.h
Modified: Mercury2/modules/Terrain.cpp
===================================================================
--- Mercury2/modules/Terrain.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/modules/Terrain.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -4,8 +4,8 @@
REGISTER_ASSET_TYPE(Terrain);
-Terrain::Terrain()
- :base()
+Terrain::Terrain( const MString & key, bool bInstanced )
+ : base( key, bInstanced )
{
}
@@ -13,21 +13,10 @@
{
}
-Terrain* Terrain::Generate()
-{
- LOG.Write( "new Terrain" );
- return new Terrain();
-}
-
-MercuryAssetInstance* Terrain::GenerateInstanceData(MercuryNode* parentNode)
-{
- return new TerrainAssetInstance(this, parentNode);
-}
-
void Terrain::LoadedCallback()
{
+ base::LoadedCallback();
BuildHash();
- base::LoadedCallback();
}
void Terrain::BuildHash()
@@ -40,6 +29,16 @@
}
}
+bool Terrain::ChangeKey( const MString & sNewKey )
+{
+ HGMDLModel::ChangeKey( sNewKey );
+ if( GetLoadState() == LOADED )
+ BuildHash();
+
+ return true;
+}
+
+
void Terrain::ImportMeshToHash(const HGMDLMesh& mesh)
{
const float* vertice = mesh.GetVertexHandle() + MercuryVBO::VERTEX_OFFSET;
@@ -145,7 +144,12 @@
return result;
}
+MercuryAssetInstance * Terrain::MakeAssetInstance( MercuryNode * ParentNode )
+{
+ return new TerrainAssetInstance( this, ParentNode );
+}
+
TerrainAssetInstance::TerrainAssetInstance(MercuryAsset* asset, MercuryNode* parentNode)
:base(asset, parentNode)
{
Modified: Mercury2/modules/Terrain.h
===================================================================
--- Mercury2/modules/Terrain.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/modules/Terrain.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -11,15 +11,15 @@
class Terrain : public HGMDLModel
{
public:
- Terrain();
+ Terrain( const MString & key, bool bInstanced );
~Terrain();
- static Terrain* Generate();
virtual void LoadedCallback(); //thread safe
- virtual MercuryAssetInstance* GenerateInstanceData(MercuryNode* parentNode);
MercuryVertex ComputePosition(const MercuryVertex& p);
MercuryVertex ComputePositionLinear(const MercuryVertex& p);
+ virtual bool ChangeKey( const MString & sNewKey );
+ virtual MercuryAssetInstance * MakeAssetInstance( MercuryNode * ParentNode );
GENRTTI( Terrain );
private:
CLASS_HELPERS( HGMDLModel );
Modified: Mercury2/modules/TextNode.cpp
===================================================================
--- Mercury2/modules/TextNode.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/modules/TextNode.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -106,8 +106,6 @@
if( !m_pThisFont )
return;
-// AddAsset( AssetFactory::GetInstance().Generate( "Quad", "MyQuad" ) );
-
if( !m_kTEX )
{
m_kTEX = MAutoPtr< MercuryAsset >( Texture::LoadFromFile( m_pThisFont->m_sImage ) );
@@ -122,7 +120,7 @@
//Setup FBO and Texture
if( !m_kVBO )
{
- m_kVBO = new MercuryVBO;
+ m_kVBO = new MercuryVBO( GetName() + "VBO", true );
if( !m_kVBO )
{
fprintf( stderr, "Could not create VBO for text.\n" );
Modified: Mercury2/modules/TextPlate.cpp
===================================================================
--- Mercury2/modules/TextPlate.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/modules/TextPlate.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -13,13 +13,6 @@
{
m_TextNode = (TextNode*)NODEFACTORY.Generate( "TextNode" );
AddChild( m_TextNode );
-
- m_BackgroundColor = ASSETFACTORY.Generate( "StateChanger", "ColorChange:1,1,0,1" );
- ((StateChanger*)m_BackgroundColor.Ptr())->LoadFromString( "ColorChange:1,1,0,1" );
- AddAsset( m_BackgroundColor );
-
- m_BackPlane = ASSETFACTORY.Generate( "Quad", "TBQ" );
- AddAsset( m_BackPlane );
}
void TextPlate::Update(float dTime)
@@ -61,11 +54,23 @@
m_TextNode->SetText(sText);
m_TextNode->RenderText();
- ((Quad*)m_BackPlane.Ptr())->LoadFromString( ssprintf( "%f,%f,%f,%f,-.01",
+ MString quadstr = ssprintf( "%f,%f,%f,%f,-.01",
m_TextNode->GetRMinX() * 1.1 ,
m_TextNode->GetRMinY() * 1.1 ,
m_TextNode->GetRMaxX() * 1.1 ,
- m_TextNode->GetRMaxY() * 1.1 ) );
+ m_TextNode->GetRMaxY() * 1.1 );
+ if( !m_BackPlane )
+ {
+
+ m_BackgroundColor = ASSETFACTORY.Generate( "StateChanger", "ColorChange:1,1,0,1" );
+ ((StateChanger*)m_BackgroundColor.Ptr())->ChangeKey( "ColorChange:1,1,0,1" );
+ AddAsset( m_BackgroundColor );
+
+ m_BackPlane = ASSETFACTORY.Generate( "Quad", quadstr );
+ AddAsset( m_BackPlane );
+ }
+ else
+ ((Quad*)m_BackPlane.Ptr())->ChangeKey( quadstr );
}
Modified: Mercury2/src/FullscreenQuad.cpp
===================================================================
--- Mercury2/src/FullscreenQuad.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/FullscreenQuad.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -3,7 +3,8 @@
REGISTER_ASSET_TYPE(FullscreenQuad);
-FullscreenQuad::FullscreenQuad()
+FullscreenQuad::FullscreenQuad( const MString & key, bool bInstanced )
+ : Quad( key, bInstanced )
{
m_matrix = MercuryMatrix::Identity();
m_matrix.Transotale(0,0,-1,0,0,0,2,2,0.01);
@@ -29,11 +30,6 @@
GLCALL( glPopMatrix() );
}
-FullscreenQuad* FullscreenQuad::Generate()
-{
- return new FullscreenQuad();
-}
-
/****************************************************************************
* Copyright (C) 2009 by Joshua Allen *
* *
Modified: Mercury2/src/FullscreenQuad.h
===================================================================
--- Mercury2/src/FullscreenQuad.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/FullscreenQuad.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -7,12 +7,11 @@
class FullscreenQuad : public Quad
{
public:
- FullscreenQuad();
+ FullscreenQuad( const MString & key, bool bInstanced );
// virtual ~FullscreenQuad();
virtual void Render(const MercuryNode* node);
-
- static FullscreenQuad* Generate();
+
GENRTTI( FullscreenQuad );
private:
MercuryMatrix m_matrix;
Modified: Mercury2/src/HGMDLMesh.h
===================================================================
--- Mercury2/src/HGMDLMesh.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/HGMDLMesh.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -7,6 +7,8 @@
class HGMDLMesh : public MercuryVBO
{
public:
+ HGMDLMesh( const MString & key, bool bInstanced ) : MercuryVBO( key, bInstanced ), m_cachable( true ) { }
+
void LoadFromFile(MercuryFile* hgmdl);
void ReadExtraData(MercuryFile* hgmdl);
void LoadOBB(MercuryFile* hgmdl);
Modified: Mercury2/src/HGMDLModel.cpp
===================================================================
--- Mercury2/src/HGMDLModel.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/HGMDLModel.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -6,20 +6,19 @@
const uint16_t EXPCTMJRV = 2;
const uint16_t EXPCTMNRV = 3;
-HGMDLModel::HGMDLModel()
- :MercuryAsset()
+HGMDLModel::HGMDLModel( const MString & key, bool bInstanced )
+ :MercuryAsset( key, bInstanced )
{
}
HGMDLModel::~HGMDLModel()
{
- REMOVE_ASSET_INSTANCE(HGMDLModel, m_path);
}
void HGMDLModel::LoadFromXML(const XMLNode& node)
{
MString path = node.Attribute("file");
- LoadHGMDL( path );
+ ChangeKey( path );
MercuryAsset::LoadFromXML( node );
}
@@ -55,7 +54,7 @@
hgmdl->Read( &numMeshes, sizeof( uint16_t ) );
for (uint16_t i = 0; i < numMeshes; ++i)
{
- MAutoPtr< HGMDLMesh > mesh( new HGMDLMesh() );
+ MAutoPtr< HGMDLMesh > mesh = new HGMDLMesh( model->m_path + "MODEL", model->GetIsInstanced() );
mesh->LoadFromFile( hgmdl );
model->m_meshes.push_back(mesh);
}
@@ -92,28 +91,23 @@
}
}
-void HGMDLModel::LoadHGMDL( const MString& path )
+bool HGMDLModel::ChangeKey( const MString & sNewKey )
{
- if ( m_isInstanced ) return;
- if ( !path.empty() )
+ if( GetLoadState() != NONE && sNewKey == m_path )
+ return true;
+
+ if ( !sNewKey.empty() )
{
SetLoadState(LOADING);
- ADD_ASSET_INSTANCE(HGMDLModel, path, this);
- m_path = path;
LoaderThreadData* ltd = new LoaderThreadData( this );
MercuryThread loaderThread;
loaderThread.HaltOnDestroy(false);
loaderThread.Create( LoaderThread, ltd );
}
+ return MercuryAsset::ChangeKey( sNewKey );
}
-HGMDLModel* HGMDLModel::Generate()
-{
- LOG.Write( "new HGMDL" );
- return new HGMDLModel();
-}
-
void* HGMDLModel::LoaderThread(void* d)
{
LoaderThreadData *pd = (LoaderThreadData*)d;
Modified: Mercury2/src/HGMDLModel.h
===================================================================
--- Mercury2/src/HGMDLModel.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/HGMDLModel.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -5,30 +5,26 @@
#include <HGMDLMesh.h>
#include <MercuryFile.h>
-#include <vector>
-
class HGMDLModel : public MercuryAsset
{
public:
- HGMDLModel();
+ HGMDLModel( const MString & key, bool bInstanced );
~HGMDLModel();
virtual void LoadFromXML(const XMLNode& node);
static void LoadModel(MercuryFile* hgmdl, HGMDLModel* model);
-
- static HGMDLModel* Generate();
-
+
virtual bool DoCullingTests(OcclusionResult& occlusion, const MercuryMatrix& matrix);
virtual void PreRender(const MercuryNode* node);
+ virtual bool ChangeKey( const MString & sNewKey );
virtual void Render(const MercuryNode* node);
GENRTTI( HGMDLModel );
protected:
- std::vector< MAutoPtr< HGMDLMesh > > m_meshes;
+ MVector< MAutoPtr< HGMDLMesh > > m_meshes;
private:
CLASS_HELPERS( MercuryAsset );
- void LoadHGMDL( const MString& path );
static void* LoaderThread(void* d);
};
Modified: Mercury2/src/Light.cpp
===================================================================
--- Mercury2/src/Light.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/Light.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -10,7 +10,7 @@
REGISTER_NODE_TYPE(Light);
Light::Light()
- :MercuryNode(), m_boundingVolume( NULL )
+ :MercuryNode(), m_fullScreenQuad( "", true ), m_boundingVolume( NULL )
{
m_atten[0] = m_atten[1] = m_atten[2] = 0.0f;
m_color[0] = m_color[1] = m_color[2] = 1.0f;
@@ -60,8 +60,7 @@
if ( asset.IsValid() )
{
Shader* shader = dynamic_cast<Shader*>( asset.Ptr() );
-// shader->LoadFromXML( node );
- shader->LoadShader(key, 0);
+ shader->ChangeKey(key);
SetShader( shader );
}
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/MercuryAsset.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -5,13 +5,18 @@
extern bool DOOCCLUSIONCULL;
-MercuryAsset::MercuryAsset()
- :m_isInstanced(false), m_boundingVolume(NULL), m_loadState(NONE), m_ignoreCull(false), m_iPasses( DEFAULT_PASSES )
+MercuryAsset::MercuryAsset( const MString & key, bool bInstanced )
+ :m_isInstanced(bInstanced), m_boundingVolume(NULL),
+ m_path( key ), m_loadState(NONE), m_ignoreCull(false), m_iPasses( DEFAULT_PASSES ), slType( 0 )
{
}
MercuryAsset::~MercuryAsset()
{
+ //If this isn't set, we were never a registered instance to begin with, so, don't unregister.
+ if( slType )
+ AssetFactory::GetInstance().RemoveAssetInstance( ToUpper(slType)+m_path );
+
SAFE_DELETE(m_boundingVolume);
}
@@ -109,11 +114,24 @@
GLCALL( glEnd() );
}
-MercuryAssetInstance* MercuryAsset::GenerateInstanceData(MercuryNode* parentNode)
+bool MercuryAsset::ChangeKey( const MString & sNewKey )
{
- return new MercuryAssetInstance(this, parentNode);
+ if( m_path == sNewKey ) return true;
+
+ AssetFactory::GetInstance().AddAssetInstance( ToUpper(GetType())+m_path, this );
+
+ m_path = sNewKey;
+
+ AssetFactory::GetInstance().RemoveAssetInstance( ToUpper(GetType())+m_path );
+
+ return true;
}
+MercuryAssetInstance * MercuryAsset::MakeAssetInstance( MercuryNode * ParentNode )
+{
+ return new MercuryAssetInstance( this, ParentNode );
+}
+
MercuryAssetInstance::MercuryAssetInstance(MercuryAsset* asset, MercuryNode* parentNode)
:m_parentNode(parentNode), m_asset( asset ), m_isCulled( false ), m_iPasses( asset->GetPasses() )
{
@@ -127,44 +145,51 @@
return *instance;
}
-bool AssetFactory::RegisterFactoryCallback(const MString & type, Callback0R< MAutoPtr<MercuryAsset> > functor)
+bool AssetFactory::RegisterFactoryCallback(const MString & type, MAutoPtr< MercuryAsset > (*functor)( const MString &, bool ) )
{
MString t = ToUpper( type );
- std::pair<MString , Callback0R< MAutoPtr<MercuryAsset> > > pp(t, functor);
- m_factoryCallbacks.push_back( pp );
+ m_factoryCallbacks[t] = functor;
return true;
}
-MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type, const MString& key)
+MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type, const MString& key, bool bInstanced )
{
MString t = ToUpper( type );
- MercuryAsset *asset = LocateAsset(t+key);
- if ( asset ) return asset;
+ if( bInstanced )
+ {
+ MercuryAsset *asset = LocateAsset(t+key);
+ if ( asset ) return asset;
+ }
+ printf( "Asset (%s) not found, generating\n", (t+key).c_str() );
- std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > >::iterator i;
- for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
- if (i->first == t) return i->second();
+ MAutoPtr< MercuryAsset > (**generator)( const MString &, bool ) = m_factoryCallbacks.get( t );
+
+ if( generator )
+ {
+ MAutoPtr< MercuryAsset > g = (**generator)(key, bInstanced);
+ AddAssetInstance( t+key, g.Ptr() );
+ g->slType = g->GetType();
+ return g;
+ }
+
LOG.Write( "WARNING: Asset type " + type + " not found." );
return NULL;
}
void AssetFactory::AddAssetInstance(const MString& key, MercuryAsset* asset)
{
- asset->IsInstanced(true);
m_assetInstances[key] = asset;
}
void AssetFactory::RemoveAssetInstance(const MString& key)
{
m_assetInstances.remove( key );
- LOG.Write( "removed asset "+key );
+ puts( "removed asset "+key );
}
-MHash< MercuryAsset*> AssetFactory::m_assetInstances;
-
/****************************************************************************
- * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Copyright (C) 2008 - 2009 by Joshua Allen *
* Charles Lohr *
* *
* *
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/MercuryAsset.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -29,7 +29,7 @@
class MercuryAsset : public RefBase, public MessageHandler
{
public:
- MercuryAsset();
+ MercuryAsset( const MString & key, bool bInstanced );
virtual ~MercuryAsset();
virtual void Init();
@@ -56,7 +56,8 @@
virtual void LoadedCallback(); //thread safe
- inline void IsInstanced(bool b) { m_isInstanced = b; }
+ inline void SetIsInstanced(bool b) { m_isInstanced = b; }
+ inline bool GetIsInstanced() { return m_isInstanced; }
inline BoundingVolume* GetBoundingVolume() const { return m_boundingVolume; }
inline const MString& Path() const { return m_path; }
@@ -70,12 +71,16 @@
inline unsigned short GetPasses() { return m_iPasses; }
inline void SetPasses( unsigned short p ) { m_iPasses = p; }
-
- virtual MercuryAssetInstance* GenerateInstanceData(MercuryNode* parentNode);
+ virtual bool ChangeKey( const MString & sNewKey );
+
LoadState GetLoadState(); //thread safe
+ virtual MercuryAssetInstance * MakeAssetInstance( MercuryNode * ParentNode );
+
+
GENRTTI( MercuryAsset );
+ const char * slType; //Tricky - we need to know our type in the destructor. Don't touch this.
protected:
void SetLoadState(LoadState ls); //thread safe
@@ -123,10 +128,7 @@
class LoaderThreadData
{
public:
- LoaderThreadData(MercuryAsset* a)
- {
- asset = a;
- }
+ LoaderThreadData(MercuryAsset* a) : asset( a ) { }
//use and autoptr here to prevent crashes if asset is removed during load
MAutoPtr< MercuryAsset > asset;
@@ -136,19 +138,20 @@
{
public:
static AssetFactory& GetInstance();
- bool RegisterFactoryCallback(const MString& type, Callback0R< MAutoPtr<MercuryAsset> >);
- MAutoPtr<MercuryAsset> Generate(const MString& type, const MString& key);
-
+ bool RegisterFactoryCallback(const MString& type, MAutoPtr< MercuryAsset > (*)( const MString &, bool ) );
+
+ MAutoPtr<MercuryAsset> Generate(const MString& type, const MString& key, bool bInstanced = true );
+
void AddAssetInstance(const MString& key, MercuryAsset* asset);
void RemoveAssetInstance(const MString& key);
private:
- MercuryAsset* LocateAsset( const MString& key ) { MercuryAsset ** a = m_assetInstances.get( key ); return a?(*a):0; }
+ MAutoPtr< MercuryAsset > LocateAsset( const MString& key ) { MAutoPtr< MercuryAsset > * a = m_assetInstances.get( key ); return a?(*a):0; }
- std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > > m_factoryCallbacks;
+ MHash< MAutoPtr< MercuryAsset > (*)( const MString &, bool ) > m_factoryCallbacks;
//the actual storage point is in MercuryAssetInstance
- static MHash< MercuryAsset*> m_assetInstances;
+ MHash< MAutoPtr< MercuryAsset > > m_assetInstances;
};
@@ -157,23 +160,16 @@
static InstanceCounter<AssetFactory> AFcounter("AssetFactory");
#define REGISTER_ASSET_TYPE(class)\
- MAutoPtr<MercuryAsset> FactoryFunct##class() { return MAutoPtr<MercuryAsset>(class::Generate()); } \
- Callback0R< MAutoPtr<MercuryAsset> > factoryclbk##class( FactoryFunct##class ); \
- bool GlobalRegisterSuccess##class = AssetFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class);
+ MAutoPtr<MercuryAsset> FactoryFunct##class( const MString & key, bool bInstanced ) { return new class( key, bInstanced ); } \
+ bool GlobalRegisterSuccess##class = AssetFactory::GetInstance().RegisterFactoryCallback(#class, FactoryFunct##class);
-#define ADD_ASSET_INSTANCE(class, key, ptr)\
- AssetFactory::GetInstance().AddAssetInstance( ToUpper(#class)+key, ptr );
-
-#define REMOVE_ASSET_INSTANCE(class, key)\
- AssetFactory::GetInstance().RemoveAssetInstance( ToUpper(#class)+key );
-
#define CLASS_HELPERS(baseClass)\
typedef baseClass base;
#endif
/****************************************************************************
- * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Copyright (C) 2008 - 2009 by Joshua Allen *
* Charles Lohr *
* *
* *
Modified: Mercury2/src/MercuryNode.cpp
===================================================================
--- Mercury2/src/MercuryNode.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/MercuryNode.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -43,7 +43,7 @@
void MercuryNode::AddAsset(MercuryAsset* asset)
{
- m_assets.push_back( asset->GenerateInstanceData(this) );
+ m_assets.push_back( asset->MakeAssetInstance( this ) );
}
void MercuryNode::ClearAssets()
@@ -51,6 +51,8 @@
list< MercuryAssetInstance* >::iterator i;
for (i = m_assets.begin(); i != m_assets.end(); ++i )
SAFE_DELETE(*i);
+
+ m_assets.clear( );
}
void MercuryNode::AddChild(MercuryNode* n)
@@ -374,6 +376,7 @@
mai->Culled( a.DoCullingTests( mai->GetOcclusionResult(), matrix ) );
culled = culled && mai->Culled();
}
+ printf( "CULL: %s (%d) %d\n", mai->Asset().GetType(), a.IgnoreCull(), mai->Culled() );
if ( !mai->Culled() ) a.PreRender(this);
}
Modified: Mercury2/src/MercuryVBO.cpp
===================================================================
--- Mercury2/src/MercuryVBO.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/MercuryVBO.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -10,8 +10,8 @@
extern bool SHOWBOUNDINGVOLUME;
extern bool SHOWAXISES;
-MercuryVBO::MercuryVBO()
- :MercuryAsset(), m_initiated(false)
+MercuryVBO::MercuryVBO( const MString & key, bool bInstanced )
+ :MercuryAsset( key, bInstanced ), m_initiated(false)
{
m_bufferIDs[0] = m_bufferIDs[1] = 0;
m_bDirtyIndices = m_bDirtyVertices = 0;
Modified: Mercury2/src/MercuryVBO.h
===================================================================
--- Mercury2/src/MercuryVBO.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/MercuryVBO.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -13,7 +13,7 @@
static const uint16_t STRIDE = 8;
static const uint16_t VERTEX_OFFSET = 5;
- MercuryVBO();
+ MercuryVBO( const MString & key, bool bInstanced );
virtual ~MercuryVBO();
virtual void Render(const MercuryNode* node);
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/Quad.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -5,50 +5,40 @@
REGISTER_ASSET_TYPE(Quad);
-Quad::Quad()
- :MercuryVBO()
+Quad::Quad( const MString & key, bool bInstanced )
+ :MercuryVBO( key, bInstanced )
{
+ ChangeKey( key );
}
Quad::~Quad()
{
- REMOVE_ASSET_INSTANCE(Quad,m_path);
}
-Quad* Quad::Generate()
-{
- Quad *asset = new Quad();
- ADD_ASSET_INSTANCE(Quad,"",asset);
- return asset;
-}
-
void Quad::LoadFromXML(const XMLNode& node)
{
- LoadFromString( node.Attribute("file") );
+ //If we've already started with the same key - this function will just return.
+ ChangeKey( node.Attribute("file") );
MercuryAsset::LoadFromXML( node );
}
-bool Quad::LoadFromString( const MString & sDescription )
+bool Quad::ChangeKey( const MString & sDescription )
{
+ if( sDescription == m_path && GetLoadState() != NONE )
+ return true;
+
float lX = -0.5;
float lY = -0.5;
float hX = 0.5;
float hY = 0.5;
float zp = 0;
- bool bResetRegistration = sDescription != m_path;
AllocateIndexSpace(6);
AllocateVertexSpace(4);
- if( bResetRegistration )
- REMOVE_ASSET_INSTANCE(Quad,m_path);
- m_path = sDescription;
- if( bResetRegistration )
- ADD_ASSET_INSTANCE(Quad,m_path,this);
-
MVector< MString > vsDescription;
SplitStrings( sDescription, vsDescription, ",", " ", 1, 1 );
@@ -75,6 +65,7 @@
else
{
LOG.Write( ssprintf( "Invalid number of parameters passed into new Quad: \"%s\"", sDescription.c_str() ) );
+ return false;
}
// float* buffer = m_vertexData.m_vertexData();
@@ -103,9 +94,9 @@
m_indexData[3] = m_indexData[2] = 2;
m_indexData[4] = 3;
- m_path = sDescription;
+ SetLoadState( LOADED );
- return true;
+ return MercuryVBO::ChangeKey( sDescription );
}
Modified: Mercury2/src/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/Quad.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -7,13 +7,12 @@
class Quad : public MercuryVBO
{
public:
- Quad();
+ Quad( const MString & key, bool bInstanced );
~Quad();
- void LoadFromXML(const XMLNode& node );
- bool LoadFromString( const MString & sDescription );
+ virtual void LoadFromXML(const XMLNode& node );
+ virtual bool ChangeKey( const MString & sDescription );
- static Quad* Generate();
GENRTTI( Quad );
private:
};
Modified: Mercury2/src/Shader.cpp
===================================================================
--- Mercury2/src/Shader.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/Shader.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -32,7 +32,8 @@
return ret;
}
-Shader::Shader()
+Shader::Shader( const MString & key, bool bInstanced ) :
+ MercuryAsset( key, bInstanced ), fPriority( 0 )
{
iProgramID = (GLhandleARB)NULL;
vertexShader = (GLhandleARB)NULL;
@@ -89,17 +90,21 @@
void Shader::LoadFromXML(const XMLNode& node)
{
- LoadShader( node.Attribute("file"), StrToFloat( node.Attribute("priority") ) );
+ //LoadShader( node.Attribute("file"), ) ) );
+
+ fPriority = StrToFloat( node.Attribute("priority" ) );
+ ChangeKey( node.Attribute("file") );
}
-void Shader::LoadShader( const MString& path, float priority )
+bool Shader::ChangeKey( const MString& path )
{
- if (m_isInstanced) return;
+ if( GetLoadState() != NONE && path == m_path )
+ return true;
sShaderName = path;
- fPriority = priority;
- ADD_ASSET_INSTANCE(Shader, sShaderName, this);
LoadShader( );
+
+ return MercuryAsset::ChangeKey( path );
}
bool Shader::LoadShader( )
Modified: Mercury2/src/Shader.h
===================================================================
--- Mercury2/src/Shader.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/Shader.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -74,21 +74,22 @@
class Shader : public MercuryAsset
{
public:
- Shader();
+ Shader( const MString & key, bool bInstanced );
virtual ~Shader();
virtual void Render(const MercuryNode* node);
virtual void PostRender(const MercuryNode* node);
- static Shader* Generate() { return new Shader; }
+
virtual void LoadFromXML(const XMLNode& node);
static void SetAttribute(const MString& name, const ShaderAttribute& x);
static void RemoveAttribute(const MString& name);
+ virtual bool ChangeKey( const MString & sNewKey );
+
///Explicitly get the OpenGL ProgramID in the event you need it for advanced techniques
unsigned int GetProgramID() { return iProgramID; }
inline static Shader* GetCurrentShader() { return CurrentShader; }
- void LoadShader( const MString& path, float priority );
private:
int32_t GetUniformLocation(const MString& n);
Modified: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/StateChanger.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -85,17 +85,18 @@
REGISTER_ASSET_TYPE(StateChanger);
-StateChanger::StateChanger()
- :MercuryAsset()
+StateChanger::StateChanger( const MString & key, bool bInstanced )
+ :MercuryAsset( key, bInstanced )
{
//Make sure our state stack is correctly sized
if( m_StateSet.size() < (unsigned)StateChangeRegister::Instance().GetStateCount() )
m_StateSet.resize( StateChangeRegister::Instance().GetStateCount() );
+
+ LoadInternal( key );
}
StateChanger::~StateChanger()
{
- REMOVE_ASSET_INSTANCE(TEXTURE, m_path);
}
void StateChanger::Render(const MercuryNode* node)
@@ -127,8 +128,18 @@
}
}
-bool StateChanger::LoadFromString( const MString & sFile )
+bool StateChanger::ChangeKey( const MString & sFile )
{
+ if( m_path == sFile )
+ return true;
+
+ LoadInternal( sFile );
+
+ return MercuryAsset::ChangeKey( sFile );
+}
+
+bool StateChanger::LoadInternal( const MString & sFile )
+{
int f = sFile.find( ":", 0 );
if( f <= 0 )
{
@@ -151,7 +162,6 @@
return false;
}
-
return true;
}
@@ -161,7 +171,7 @@
if ( !node.Attribute("file").empty() )
{
MString sFile = node.Attribute("file");
- LoadFromString( sFile );
+ ChangeKey( sFile );
}
}
@@ -177,11 +187,6 @@
MercuryAsset::SaveToXMLTag( sXMLStream );
}
-StateChanger* StateChanger::Generate()
-{
- return new StateChanger();
-}
-
MVector< MVector< MAutoPtr< StateChange > > > StateChanger::m_StateSet;
Modified: Mercury2/src/StateChanger.h
===================================================================
--- Mercury2/src/StateChanger.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/StateChanger.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -49,7 +49,7 @@
class StateChanger : public MercuryAsset
{
public:
- StateChanger();
+ StateChanger( const MString & key, bool bInstanced );
virtual ~StateChanger();
virtual void Render(const MercuryNode* node);
@@ -57,10 +57,9 @@
virtual void LoadFromXML(const XMLNode& node);
virtual void SaveToXMLTag( MString & sXMLStream );
- static StateChanger* Generate();
- bool LoadFromString( const MString & sDescription );
-
+ virtual bool ChangeKey( const MString & sNewKey );
+ virtual bool LoadInternal( const MString & sFile );
GENRTTI( StateChanger );
private:
Modified: Mercury2/src/Texture.cpp
===================================================================
--- Mercury2/src/Texture.cpp 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/Texture.cpp 2009-11-05 02:59:30 UTC (rev 599)
@@ -12,8 +12,8 @@
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
-Texture::Texture()
- :MercuryAsset(), m_raw(NULL),m_textureID(0)
+Texture::Texture( const MString & key, bool bInstanced )
+ :MercuryAsset( key, bInstanced ), m_raw(NULL),m_textureID(0),m_dynamic(false)
{
if (!m_initTextureSuccess)
{
@@ -26,10 +26,7 @@
Texture::~Texture()
{
- REMOVE_ASSET_INSTANCE(TEXTURE, m_path);
-
- Clean();
-
+ Clean();
SAFE_DELETE(m_raw);
}
@@ -89,6 +86,7 @@
{
if (GetLoadState() == LOADED)
{
+ printf( "Rendering Texture (%s), but state is: %d\n", m_path.c_str(), GetLoadState() );
LoadFromRaw();
SetLoadState(NONE);
}
@@ -102,16 +100,27 @@
void Texture::LoadFromXML(const XMLNode& node)
{
- bool dynamic = false;
if ( !node.Attribute("dynamic").empty() )
- dynamic = node.Attribute("dynamic")=="true"?true:false;
+ m_dynamic = node.Attribute("dynamic")=="true"?true:false;
MString file = node.Attribute("file");
-
- if ( dynamic )
- MakeDynamic( 0, 0, RGBA, file );
+
+ ChangeKey( file );
+}
+
+bool Texture::ChangeKey( const MString & sNewKey )
+{
+ if( sNewKey == m_path && GetLoadState() != NONE )
+ return true;
+
+ if ( m_dynamic )
+ MakeDynamic( 0, 0, RGBA, sNewKey );
else
- LoadImagePath( file );
+ LoadImagePath( sNewKey );
+
+ if( sNewKey != m_path )
+ return MercuryAsset::ChangeKey( sNewKey );
+ return true;
}
void Texture::BindTexture()
@@ -213,13 +222,10 @@
void Texture::LoadImagePath(const MString& path)
{
- if (m_isInstanced) return;
if ( !path.empty() )
{
SetLoadState(LOADING);
- ADD_ASSET_INSTANCE(Texture, path, this);
- m_path = path;
-
+ m_path = path;
// MercuryThread loaderThread;
// ImageLoader::LoadImageThreaded(this, m_filename );
ImageLoader::GetInstance().LoadImageThreaded(this);
@@ -241,10 +247,8 @@
// Clean();
SetLoadState(LOADED);
-
- REMOVE_ASSET_INSTANCE(TEXTURE, m_path);
+
m_path = "DYNATEXT"+name;
- ADD_ASSET_INSTANCE(Texture, m_path, this);
if (m_textureID == 0) { GLCALL( glGenTextures( 1, &m_textureID ) ); }
GLCALL( glBindTexture( GL_TEXTURE_2D, m_textureID ) );
@@ -256,11 +260,6 @@
GLERRORCHECK;
}
-Texture* Texture::Generate()
-{
- return new Texture();
-}
-
MAutoPtr< Texture > Texture::LoadFromFile(const MString& path)
{
MAutoPtr< MercuryAsset > t( AssetFactory::GetInstance().Generate("Texture", path) );
Modified: Mercury2/src/Texture.h
===================================================================
--- Mercury2/src/Texture.h 2009-11-05 02:44:00 UTC (rev 598)
+++ Mercury2/src/Texture.h 2009-11-05 02:59:30 UTC (rev 599)
@@ -7,7 +7,7 @@
class Texture : public MercuryAsset
{
public:
- Texture();
+ Texture( const MString & key, bool bInstanced );
virtual ~Texture();
void Clean();
@@ -16,7 +16,9 @@
virtual void PostRender(const MercuryNode* node);
virtual void LoadFromXML(const XMLNode& node);
-
+
+ virtual bool ChangeKey( const MString & sNewKey );
+
void LoadFromRaw();
inline static uint8_t NumberActiveTextures() { return m_numActiveTextures; }
@@ -25,7 +27,6 @@
void MakeDynamic(uint16_t width, uint16_t height, ColorByteType cbt, const MString& name);
- static Texture* Generate();
static MAutoPtr< Texture > LoadFromFile(const MString& path);
static MAutoPtr< Texture > LoadDynamicTexture(const MString& name);
static const std::list< Texture* >& GetActiveTextures() { return m_activeTextures; }
@@ -56,6 +57,8 @@
static uint8_t m_maxActiveTextures;
static Texture** m_lastBound;
+
+ bool m_dynamic;
// MString m_filename;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-05 02:44:14
|
Revision: 598
http://hgengine.svn.sourceforge.net/hgengine/?rev=598&view=rev
Author: cnlohr
Date: 2009-11-05 02:44:00 +0000 (Thu, 05 Nov 2009)
Log Message:
-----------
update spelling on rendering deferred lights
Modified Paths:
--------------
Mercury2/adv_set.c
Added Paths:
-----------
Mercury2/src/RenderDeferredLights.cpp
Mercury2/src/RenderDeferredLights.h
Removed Paths:
-------------
Mercury2/src/RenderDifferedLights.cpp
Mercury2/src/RenderDifferedLights.h
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-11-03 18:50:32 UTC (rev 597)
+++ Mercury2/adv_set.c 2009-11-05 02:44:00 UTC (rev 598)
@@ -13,7 +13,7 @@
src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \
src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
- src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDifferedLights.cpp \
+ src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDeferredLights.cpp \
src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
Added: Mercury2/src/RenderDeferredLights.cpp
===================================================================
--- Mercury2/src/RenderDeferredLights.cpp (rev 0)
+++ Mercury2/src/RenderDeferredLights.cpp 2009-11-05 02:44:00 UTC (rev 598)
@@ -0,0 +1,68 @@
+#include <RenderDeferredLights.h>
+#include <RenderGraph.h>
+
+#include <Texture.h>
+#include <GLHeaders.h>
+
+REGISTER_ASSET_TYPE(RenderDeferredLights);
+
+RenderDeferredLights::RenderDeferredLights( const MString & key, bool bInstanced ) :
+ MercuryAsset( key, bInstanced )
+{
+}
+
+RenderDeferredLights::~RenderDeferredLights()
+{
+}
+
+void RenderDeferredLights::Render(const MercuryNode* node)
+{
+// uint8_t numTextures = Texture::NumberActiveTextures();
+ uint16_t stride = sizeof(float)*8;
+
+ Texture::ApplyActiveTextures(stride);
+
+ GLCALL( glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT) );
+ GLCALL( glCullFace(GL_FRONT) );
+
+ GLCALL( glDisable(GL_DEPTH_TEST) );
+ GLCALL( glDepthMask(false) );
+ GLCALL( glBlendFunc(GL_ONE, GL_ONE) );
+
+ CURRENTRENDERGRAPH->DoDifferedLightPass();
+
+ GLCALL( glPopAttrib( ) );
+}
+
+
+/****************************************************************************
+ * Copyright (C) 2009 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Added: Mercury2/src/RenderDeferredLights.h
===================================================================
--- Mercury2/src/RenderDeferredLights.h (rev 0)
+++ Mercury2/src/RenderDeferredLights.h 2009-11-05 02:44:00 UTC (rev 598)
@@ -0,0 +1,48 @@
+#ifndef RENDERDEFERREDLIGHTS_H
+#define RENDERDEFERREDLIGHTS_H
+
+#include <MercuryAsset.h>
+
+class RenderDeferredLights : public MercuryAsset
+{
+ public:
+ RenderDeferredLights( const MString & key, bool bInstanced );
+ virtual ~RenderDeferredLights();
+
+ virtual void Render(const MercuryNode* node);
+ GENRTTI( RenderDeferredLights );
+};
+
+#endif
+
+/****************************************************************************
+ * Copyright (C) 2009 by Joshua Allen *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+ ***************************************************************************/
Deleted: Mercury2/src/RenderDifferedLights.cpp
===================================================================
--- Mercury2/src/RenderDifferedLights.cpp 2009-11-03 18:50:32 UTC (rev 597)
+++ Mercury2/src/RenderDifferedLights.cpp 2009-11-05 02:44:00 UTC (rev 598)
@@ -1,72 +0,0 @@
-#include <RenderDifferedLights.h>
-#include <RenderGraph.h>
-
-#include <Texture.h>
-#include <GLHeaders.h>
-
-REGISTER_ASSET_TYPE(RenderDifferedLights);
-
-RenderDifferedLights::RenderDifferedLights()
-{
-}
-
-RenderDifferedLights::~RenderDifferedLights()
-{
-}
-
-void RenderDifferedLights::Render(const MercuryNode* node)
-{
- uint8_t numTextures = Texture::NumberActiveTextures();
- uint16_t stride = sizeof(float)*8;
-
- Texture::ApplyActiveTextures(stride);
-
- GLCALL( glPushAttrib( GL_CURRENT_BIT | GL_ENABLE_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_POLYGON_BIT) );
- GLCALL( glCullFace(GL_FRONT) );
-
- GLCALL( glDisable(GL_DEPTH_TEST) );
- GLCALL( glDepthMask(false) );
- GLCALL( glBlendFunc(GL_ONE, GL_ONE) );
-
- CURRENTRENDERGRAPH->DoDifferedLightPass();
-
- GLCALL( glPopAttrib( ) );
-}
-
-RenderDifferedLights* RenderDifferedLights::Generate()
-{
- return new RenderDifferedLights();
-}
-
-
-/****************************************************************************
- * Copyright (C) 2009 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without *
- * modification, are permitted provided that the following conditions *
- * are met: *
- * * Redistributions of source code must retain the above copyright *
- * notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above *
- * copyright notice, this list of conditions and the following *
- * disclaimer in the documentation and/or other materials provided *
- * with the distribution. *
- * * Neither the name of the Mercury Engine nor the names of its *
- * contributors may be used to endorse or promote products derived *
- * from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
- ***************************************************************************/
Deleted: Mercury2/src/RenderDifferedLights.h
===================================================================
--- Mercury2/src/RenderDifferedLights.h 2009-11-03 18:50:32 UTC (rev 597)
+++ Mercury2/src/RenderDifferedLights.h 2009-11-05 02:44:00 UTC (rev 598)
@@ -1,49 +0,0 @@
-#ifndef RENDERDIFFEREDLIGHTS_H
-#define RENDERDIFFEREDLIGHTS_H
-
-#include <MercuryAsset.h>
-
-class RenderDifferedLights : public MercuryAsset
-{
- public:
- RenderDifferedLights();
- virtual ~RenderDifferedLights();
-
- virtual void Render(const MercuryNode* node);
- static RenderDifferedLights* Generate();
-
-};
-
-#endif
-
-/****************************************************************************
- * Copyright (C) 2009 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without *
- * modification, are permitted provided that the following conditions *
- * are met: *
- * * Redistributions of source code must retain the above copyright *
- * notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above *
- * copyright notice, this list of conditions and the following *
- * disclaimer in the documentation and/or other materials provided *
- * with the distribution. *
- * * Neither the name of the Mercury Engine nor the names of its *
- * contributors may be used to endorse or promote products derived *
- * from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
- ***************************************************************************/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-03 18:50:40
|
Revision: 597
http://hgengine.svn.sourceforge.net/hgengine/?rev=597&view=rev
Author: cnlohr
Date: 2009-11-03 18:50:32 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
add options for liberty
Modified Paths:
--------------
Mercury2/base_set.sh
Mercury2/cnconfigure
Modified: Mercury2/base_set.sh
===================================================================
--- Mercury2/base_set.sh 2009-11-03 08:24:44 UTC (rev 596)
+++ Mercury2/base_set.sh 2009-11-03 18:50:32 UTC (rev 597)
@@ -46,6 +46,7 @@
NEED_H="stdio.h stdlib.h"
WANT_H="time.h"
+WANT_L="iberty"
CC_BASE="$CC_BASE -I."
NEED_L="m c z pthread png pthread";
Modified: Mercury2/cnconfigure
===================================================================
--- Mercury2/cnconfigure 2009-11-03 08:24:44 UTC (rev 596)
+++ Mercury2/cnconfigure 2009-11-03 18:50:32 UTC (rev 597)
@@ -100,7 +100,7 @@
done
for i in $WANT_L; do
- if CheckForLib "$i"; then echo "#define _HAVE_LIB_$i" >> configuration.h; fi
+ if CheckForLib "$i"; then echo "#define _HAVE_LIB_$i" >> configuration.h; LDFLAGS="$LDFLAGS -l$i"; fi
done
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-03 08:24:51
|
Revision: 596
http://hgengine.svn.sourceforge.net/hgengine/?rev=596&view=rev
Author: cnlohr
Date: 2009-11-03 08:24:44 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
take advantage of new asset statechanger. Greatly increase quality of TextPlate.
Modified Paths:
--------------
Mercury2/Themes/default/File/scenegraph.xml
Mercury2/adv_set.c
Mercury2/modules/TextPlate.cpp
Mercury2/modules/TextPlate.h
Mercury2/src/MercuryAsset.cpp
Mercury2/src/MercuryAsset.h
Mercury2/src/Quad.cpp
Mercury2/src/Quad.h
Modified: Mercury2/Themes/default/File/scenegraph.xml
===================================================================
--- Mercury2/Themes/default/File/scenegraph.xml 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/Themes/default/File/scenegraph.xml 2009-11-03 08:24:44 UTC (rev 596)
@@ -1,8 +1,12 @@
<SceneGraph name="root">
+ <!--We have to put all states that are the generic state up here. This way, the states will fall back to these -->
+ <asset type="StateChanger" file="ColorChange:1,1,1,1" />
<node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp">
<node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera">
- <node type="transformnode" movz="-5" movy="2">
- <node type="TextPlate" text="test font 123 HELLO WORLD!!! WOOT!" font="FONT:FreeSans.hgfont" size=".01" width="400" alphaPath="true" billboardaxis="0,-1,0" offset="-2,0,0" spheremode="false" />
+ <node type="transformnode" movz="-5" movy=".2">
+ <node type="TextPlate" text="x=3.14159" font="FONT:FreeSans.hgfont" size=".002" alphaPath="true" billboardaxis="0,-1,0" spheremode="false" alignment="CENTER" >
+ <asset type="StateChanger" file="ColorChange:0,0,0,1" />
+ </node>
</node>
<node type="transformnode" movz="-5" movx="-4" movy="2">
<node type="TextNode" text="Another test!" font="FONT:FreeMonoBold.hgfont" size=".01" width="300" alphaPath="true" alignment="LEFT" />
@@ -20,6 +24,7 @@
</node>
<node type="billboardnode" billboardaxis="0,-1,0" spheremode="true" >
<node type="transformnode" scalex="0.1" scaley="0.1" alphaPath="true">
+ <asset type="StateChanger" file="ColorChange:1,0,1,1" />
<asset type="texture" file="GRAPHIC:flame.png"/>
<asset type="quad"/>
</node>
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/adv_set.c 2009-11-03 08:24:44 UTC (rev 596)
@@ -14,7 +14,7 @@
src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp src/MercuryFBO.cpp \
src/GLHelpers.cpp src/FullscreenQuad.cpp src/MercuryNamedResource.cpp src/MercuryPrefs.cpp \
src/MercuryTheme.cpp src/Orthographic.cpp src/Light.cpp src/RenderDifferedLights.cpp \
- src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp"
+ src/MercuryLog.cpp src/MercuryCTA.cpp src/DataTypes/MTriangle.cpp src/StateChanger.cpp"
SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \
src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp"
Modified: Mercury2/modules/TextPlate.cpp
===================================================================
--- Mercury2/modules/TextPlate.cpp 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/modules/TextPlate.cpp 2009-11-03 08:24:44 UTC (rev 596)
@@ -2,6 +2,9 @@
#include <TextNode.h>
#include <MercuryVertex.h>
#include <Viewport.h>
+#include <Quad.h>
+#include <GLHeaders.h>
+#include <StateChanger.h>
REGISTER_NODE_TYPE(TextPlate);
@@ -10,6 +13,13 @@
{
m_TextNode = (TextNode*)NODEFACTORY.Generate( "TextNode" );
AddChild( m_TextNode );
+
+ m_BackgroundColor = ASSETFACTORY.Generate( "StateChanger", "ColorChange:1,1,0,1" );
+ ((StateChanger*)m_BackgroundColor.Ptr())->LoadFromString( "ColorChange:1,1,0,1" );
+ AddAsset( m_BackgroundColor );
+
+ m_BackPlane = ASSETFACTORY.Generate( "Quad", "TBQ" );
+ AddAsset( m_BackPlane );
}
void TextPlate::Update(float dTime)
@@ -18,7 +28,6 @@
m_billboardMatrix.Translate( m_fvOffset );
}
-
void TextPlate::SaveToXML( MString & sXMLStream, int depth )
{
sXMLStream += ssprintf( "%*c<node ", depth*3, 32 );
@@ -43,8 +52,23 @@
if ( !node.Attribute("offset").empty() )
m_fvOffset = MercuryVector::CreateFromString( node.Attribute("offset") );
m_TextNode->LoadFromXML(node);
+ if ( !node.Attribute("text").empty() )
+ SetText( node.Attribute("text") );
}
+void TextPlate::SetText( const MString & sText )
+{
+ m_TextNode->SetText(sText);
+ m_TextNode->RenderText();
+
+ ((Quad*)m_BackPlane.Ptr())->LoadFromString( ssprintf( "%f,%f,%f,%f,-.01",
+ m_TextNode->GetRMinX() * 1.1 ,
+ m_TextNode->GetRMinY() * 1.1 ,
+ m_TextNode->GetRMaxX() * 1.1 ,
+ m_TextNode->GetRMaxY() * 1.1 ) );
+}
+
+
/****************************************************************************
* Copyright (C) 2009 by Charles Lohr *
* *
Modified: Mercury2/modules/TextPlate.h
===================================================================
--- Mercury2/modules/TextPlate.h 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/modules/TextPlate.h 2009-11-03 08:24:44 UTC (rev 596)
@@ -6,6 +6,8 @@
#include <MercuryVertex.h>
class TextNode;
+class Quad;
+class StateChanger;
class TextPlate : public BillboardNode
{
@@ -18,10 +20,14 @@
virtual void SaveToXML( MString & sXMLStream, int depth = 0 );
virtual void SaveToXMLTag( MString & sXMLStream );
+ void SetText( const MString & sText );
+
GENRTTI(TextPlate);
private:
MercuryVector m_fvOffset;
TextNode * m_TextNode;
+ MAutoPtr< MercuryAsset > m_BackgroundColor;
+ MAutoPtr< MercuryAsset > m_BackPlane;
};
#endif
@@ -58,3 +64,4 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
***************************************************************************/
+
Modified: Mercury2/src/MercuryAsset.cpp
===================================================================
--- Mercury2/src/MercuryAsset.cpp 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/MercuryAsset.cpp 2009-11-03 08:24:44 UTC (rev 596)
@@ -138,10 +138,10 @@
MAutoPtr<MercuryAsset> AssetFactory::Generate(const MString& type, const MString& key)
{
MString t = ToUpper( type );
-
+
MercuryAsset *asset = LocateAsset(t+key);
if ( asset ) return asset;
-
+
std::list< std::pair< MString, Callback0R< MAutoPtr<MercuryAsset> > > >::iterator i;
for (i = m_factoryCallbacks.begin(); i != m_factoryCallbacks.end(); ++i)
if (i->first == t) return i->second();
@@ -163,26 +163,36 @@
MHash< MercuryAsset*> AssetFactory::m_assetInstances;
-/***************************************************************************
- * Copyright (C) 2008 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
- * * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
***************************************************************************/
+
Modified: Mercury2/src/MercuryAsset.h
===================================================================
--- Mercury2/src/MercuryAsset.h 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/MercuryAsset.h 2009-11-03 08:24:44 UTC (rev 596)
@@ -152,6 +152,8 @@
};
+#define ASSETFACTORY (AssetFactory::GetInstance())
+
static InstanceCounter<AssetFactory> AFcounter("AssetFactory");
#define REGISTER_ASSET_TYPE(class)\
@@ -170,26 +172,36 @@
#endif
-/***************************************************************************
- * Copyright (C) 2008 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
- * * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
***************************************************************************/
+
Modified: Mercury2/src/Quad.cpp
===================================================================
--- Mercury2/src/Quad.cpp 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/Quad.cpp 2009-11-03 08:24:44 UTC (rev 596)
@@ -8,8 +8,74 @@
Quad::Quad()
:MercuryVBO()
{
+}
+
+Quad::~Quad()
+{
+ REMOVE_ASSET_INSTANCE(Quad,m_path);
+}
+
+Quad* Quad::Generate()
+{
+ Quad *asset = new Quad();
+ ADD_ASSET_INSTANCE(Quad,"",asset);
+ return asset;
+}
+
+void Quad::LoadFromXML(const XMLNode& node)
+{
+ LoadFromString( node.Attribute("file") );
+
+ MercuryAsset::LoadFromXML( node );
+}
+
+
+
+bool Quad::LoadFromString( const MString & sDescription )
+{
+ float lX = -0.5;
+ float lY = -0.5;
+ float hX = 0.5;
+ float hY = 0.5;
+ float zp = 0;
+ bool bResetRegistration = sDescription != m_path;
+
AllocateIndexSpace(6);
AllocateVertexSpace(4);
+
+ if( bResetRegistration )
+ REMOVE_ASSET_INSTANCE(Quad,m_path);
+ m_path = sDescription;
+ if( bResetRegistration )
+ ADD_ASSET_INSTANCE(Quad,m_path,this);
+
+ MVector< MString > vsDescription;
+ SplitStrings( sDescription, vsDescription, ",", " ", 1, 1 );
+
+ if( vsDescription.size() == 0 )
+ {
+ //Do nothing
+ }
+ else if( vsDescription.size() == 2 )
+ {
+ lX = 0;
+ lY = 0;
+ hX = StrToFloat( vsDescription[0] );
+ hY = StrToFloat( vsDescription[1] );
+ }
+ else if( vsDescription.size() == 4 || vsDescription.size() == 5 )
+ {
+ lX = StrToFloat( vsDescription[0] );
+ lY = StrToFloat( vsDescription[1] );
+ hX = StrToFloat( vsDescription[2] );
+ hY = StrToFloat( vsDescription[3] );
+ if( vsDescription.size() == 5 )
+ zp = StrToFloat( vsDescription[4] );
+ }
+ else
+ {
+ LOG.Write( ssprintf( "Invalid number of parameters passed into new Quad: \"%s\"", sDescription.c_str() ) );
+ }
// float* buffer = m_vertexData.m_vertexData();
int i = 0;
@@ -18,59 +84,62 @@
//this makes it so FBO images render correctly right out of the buffer, no flip needed
m_vertexData[i++] = 0; m_vertexData[i++] = 0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = -0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = lX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
m_vertexData[i++] = 1; m_vertexData[i++] = 0;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = 0.5; m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = hX; m_vertexData[i++] = lY; m_vertexData[i++] = zp;
m_vertexData[i++] = 1; m_vertexData[i++] = 1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = hX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
m_vertexData[i++] = 0; m_vertexData[i++] = 1;
m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0;
- m_vertexData[i++] = -0.5; m_vertexData[i++] = 0.5; m_vertexData[i++] = 0.0;
+ m_vertexData[i++] = lX; m_vertexData[i++] = hY; m_vertexData[i++] = zp;
m_indexData[5] = m_indexData[0] = 0;
m_indexData[1] = 1;
m_indexData[3] = m_indexData[2] = 2;
m_indexData[4] = 3;
-}
-Quad::~Quad()
-{
- REMOVE_ASSET_INSTANCE(Quad,"");
-}
+ m_path = sDescription;
-Quad* Quad::Generate()
-{
- Quad *asset = new Quad();
- ADD_ASSET_INSTANCE(Quad,"",asset);
- LOG.Write( "new quad" );
- return asset;
+ return true;
}
-/***************************************************************************
- * Copyright (C) 2008 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
- * * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
***************************************************************************/
+
+
Modified: Mercury2/src/Quad.h
===================================================================
--- Mercury2/src/Quad.h 2009-11-03 08:21:44 UTC (rev 595)
+++ Mercury2/src/Quad.h 2009-11-03 08:24:44 UTC (rev 596)
@@ -10,6 +10,9 @@
Quad();
~Quad();
+ void LoadFromXML(const XMLNode& node );
+ bool LoadFromString( const MString & sDescription );
+
static Quad* Generate();
GENRTTI( Quad );
private:
@@ -17,26 +20,36 @@
#endif
-/***************************************************************************
- * Copyright (C) 2008 by Joshua Allen *
- * *
- * *
- * All rights reserved. *
- * *
- * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
- * * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. *
- * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. *
- * * Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. *
- * *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR *
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
+/****************************************************************************
+ * Copyright (C) 2009 - 2009 by Joshua Allen *
+ * Charles Lohr *
+ * *
+ * *
+ * All rights reserved. *
+ * *
+ * Redistribution and use in source and binary forms, with or without *
+ * modification, are permitted provided that the following conditions *
+ * are met: *
+ * * Redistributions of source code must retain the above copyright *
+ * notice, this list of conditions and the following disclaimer. *
+ * * Redistributions in binary form must reproduce the above *
+ * copyright notice, this list of conditions and the following *
+ * disclaimer in the documentation and/or other materials provided *
+ * with the distribution. *
+ * * Neither the name of the Mercury Engine nor the names of its *
+ * contributors may be used to endorse or promote products derived *
+ * from this software without specific prior written permission. *
+ * *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT *
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR *
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT *
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, *
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY *
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE *
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
***************************************************************************/
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-03 08:21:51
|
Revision: 595
http://hgengine.svn.sourceforge.net/hgengine/?rev=595&view=rev
Author: cnlohr
Date: 2009-11-03 08:21:44 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
remove xml exporting (debugging thing shouldn't have been committed)
Modified Paths:
--------------
Mercury2/src/Mercury2.cpp
Modified: Mercury2/src/Mercury2.cpp
===================================================================
--- Mercury2/src/Mercury2.cpp 2009-11-03 08:20:45 UTC (rev 594)
+++ Mercury2/src/Mercury2.cpp 2009-11-03 08:21:44 UTC (rev 595)
@@ -178,9 +178,9 @@
}
//Uncomment to enable scenegraph saving.
- MString st;
- root->SaveToXML( st );
- StringToFile( "test.xml", st );
+// MString st;
+// root->SaveToXML( st );
+// StringToFile( "test.xml", st );
}
while ( w->PumpMessages() );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-11-03 08:20:53
|
Revision: 594
http://hgengine.svn.sourceforge.net/hgengine/?rev=594&view=rev
Author: cnlohr
Date: 2009-11-03 08:20:45 +0000 (Tue, 03 Nov 2009)
Log Message:
-----------
wooh state changers
Added Paths:
-----------
Mercury2/src/StateChanger.cpp
Mercury2/src/StateChanger.h
Added: Mercury2/src/StateChanger.cpp
===================================================================
--- Mercury2/src/StateChanger.cpp (rev 0)
+++ Mercury2/src/StateChanger.cpp 2009-11-03 08:20:45 UTC (rev 594)
@@ -0,0 +1,220 @@
+#include <StateChanger.h>
+#include <MercuryNode.h>
+#include <GLHeaders.h>
+
+using namespace std;
+
+//////////////////////////////////////STATE CHANGERS//////////////////////////////////////////
+
+///State changer for color changing.
+class ColorChange : public StateChange
+{
+public:
+ ColorChange( const MVector< MString > & sParameters ) : StateChange( sParameters )
+ {
+ if( sParameters.size() < 3 )
+ {
+ LOG.Write( ssprintf( "Error: ColorChange state has invalid number of parameters(%d).", sParameters.size() ) );
+ return;
+ }
+
+ r = StrToFloat( sParameters[0] );
+ g = StrToFloat( sParameters[1] );
+ b = StrToFloat( sParameters[2] );
+
+ if( sParameters.size() > 3 )
+ a = StrToFloat( sParameters[3] );
+ else
+ a = 1.;
+ }
+
+ void Stringify( MString & sOut )
+ {
+ sOut = ssprintf( "%f,%f,%f,%f", r,g,b,a );
+ }
+
+ void Activate()
+ {
+ glColor4f( r,g,b,a );
+ }
+
+ STATECHANGE_RTTI( ColorChange );
+ float r,g,b,a;
+};
+
+REGISTER_STATECHANGE( ColorChange );
+
+
+//////////////////////////////////////STATE CHANGE CHUNK//////////////////////////////////////
+StateChangeRegister * StateChangeRegister::m_Instance;
+
+StateChangeRegister & StateChangeRegister::Instance()
+{
+ if( !m_Instance )
+ m_Instance = new StateChangeRegister();
+ return *m_Instance;
+}
+
+int StateChangeRegister::RegisterGenerator( const MString & name, StateChange*(*gn)( const MVector< MString > &sParameters ) )
+{
+ m_Generators[name] = gn;
+ m_hStateIDs[name] = m_iStateCount++;
+ return m_iStateCount-1;
+}
+
+MAutoPtr< StateChange > StateChangeRegister::Create( const MString & name, const MVector< MString > & sParameters )
+{
+ StateChange*(**tgn)( const MVector< MString > &sParameters );
+ if( !( tgn = m_Generators.get( name ) ) )
+ return 0;
+
+ return (**tgn)(sParameters );
+}
+
+int StateChangeRegister::GetStateID( const MString & spar )
+{
+ int * r = m_hStateIDs.get( spar );
+ if( r )
+ return *r;
+ else
+ return 0;
+}
+
+
+//////////////////////////////////////STATE CHANGER ASSET/////////////////////////////////////
+
+REGISTER_ASSET_TYPE(StateChanger);
+
+StateChanger::StateChanger()
+ :MercuryAsset()
+{
+ //Make sure our state stack is correctly sized
+ if( m_StateSet.size() < (unsigned)StateChangeRegister::Instance().GetStateCount() )
+ m_StateSet.resize( StateChangeRegister::Instance().GetStateCount() );
+}
+
+StateChanger::~StateChanger()
+{
+ REMOVE_ASSET_INSTANCE(TEXTURE, m_path);
+}
+
+void StateChanger::Render(const MercuryNode* node)
+{
+ for( unsigned i = 0; i < m_vStates.size(); i++ )
+ {
+ MAutoPtr< StateChange > & k = m_vStates[i];
+ k->Activate();
+ m_StateSet[k->sID].push_back( k );
+ }
+}
+
+void StateChanger::PostRender(const MercuryNode* node)
+{
+ for( unsigned i = 0; i < m_vStates.size(); i++ )
+ {
+ MAutoPtr< StateChange > & k = m_vStates[i];
+ MVector< MAutoPtr< StateChange > > & l = m_StateSet[k->sID];
+
+ unsigned ilpos = l.size() - 1;
+
+ if( ilpos <= 0 )
+ continue;
+
+ l.resize( ilpos-- );
+
+ if( ilpos >= 0 )
+ l[ilpos]->Activate();
+ }
+}
+
+bool StateChanger::LoadFromString( const MString & sFile )
+{
+ int f = sFile.find( ":", 0 );
+ if( f <= 0 )
+ {
+ LOG.Write( ssprintf( "Error loading new StateChanger node. File: \"%s\" improperly formatted, required \"[type]:[parameters]\".", sFile.c_str() ) );
+ return false;
+ }
+
+ MString sType = sFile.substr( 0, f );
+ MString sParameters = sFile.substr( f+1 );
+ MVector< MString > vsParameters;
+
+ SplitStrings( sParameters, vsParameters, ",", " ", 1, 1 );
+
+ MAutoPtr< StateChange > s = StateChangeRegister::Instance().Create( sType, vsParameters );
+ if( s.Ptr() )
+ m_vStates.push_back( s );
+ else
+ {
+ LOG.Write( ssprintf( "Error: Could not make new StateChanger from: \"%s\"", sFile.c_str() ) );
+ return false;
+ }
+
+
+ return true;
+}
+
+void StateChanger::LoadFromXML(const XMLNode& node)
+{
+ MercuryAsset::LoadFromXML(node);
+ if ( !node.Attribute("file").empty() )
+ {
+ MString sFile = node.Attribute("file");
+ LoadFromString( sFile );
+ }
+}
+
+void StateChanger::SaveToXMLTag( MString & sXMLStream )
+{
+ if( m_vStates.size() )
+ {
+ MString sStr;
+ m_vStates[0]->Stringify( sStr );
+ sXMLStream += "file=\"" + sStr + "\" ";
+ }
+
+ MercuryAsset::SaveToXMLTag( sXMLStream );
+}
+
+StateChanger* StateChanger::Generate()
+{
+ return new StateChanger();
+}
+
+MVector< MVector< MAutoPtr< StateChange > > > StateChanger::m_StateSet;
+
+
+/****************************************************************************
+ * 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/src/StateChanger.h
===================================================================
--- Mercury2/src/StateChanger.h (rev 0)
+++ Mercury2/src/StateChanger.h 2009-11-03 08:20:45 UTC (rev 594)
@@ -0,0 +1,107 @@
+#ifndef STATE_CHANGER_H
+#define STATE_CHANGER_H
+
+#include <MercuryAsset.h>
+#include <RawImageData.h>
+
+
+#define STATECHANGE_RTTI(x) const char * GetType() { return #x; }
+
+class StateChange : public RefBase
+{
+public:
+ StateChange( const MVector< MString > & sParameters ) { }
+ void Stringify( MString & sOut ) { }
+
+ virtual void Activate() = 0;
+
+ STATECHANGE_RTTI( StateChange );
+ int sID;
+};
+
+#define REGISTER_STATECHANGE( x ) \
+ extern int sID##x;\
+ StateChange*CreateNew##x( const MVector< MString > & sParameters ) { x * ret = new x( sParameters ); ret->sID = sID##x; return ret; } \
+ int sID##x = StateChangeRegister::Instance().RegisterGenerator( #x, CreateNew##x );
+
+class StateChangeRegister
+{
+public:
+ static StateChangeRegister & Instance();
+ int RegisterGenerator( const MString & name, StateChange*(*gn)( const MVector< MString > &sParameters ) );
+ MAutoPtr< StateChange > Create( const MString & name, const MVector< MString > & sParameters );
+
+ int GetStateID( const MString & spar );
+ int GetStateCount() { return m_iStateCount; }
+private:
+ MHash< StateChange*(*)(const MVector< MString > &sParameters) > m_Generators;
+ static StateChangeRegister * m_Instance;
+ MHash< int > m_hStateIDs;
+ int m_iStateCount;
+};
+
+///State Changer Node
+/**
+ This node is for things like changing the color of everything, or turning on/off
+ blending modes, etc. in the overall system.
+ Note: While this node can handle multiple states at once - it is currently
+ only set up to be able to load one from the incoming XML. */
+class StateChanger : public MercuryAsset
+{
+public:
+ StateChanger();
+ virtual ~StateChanger();
+
+ virtual void Render(const MercuryNode* node);
+ virtual void PostRender(const MercuryNode* node);
+
+ virtual void LoadFromXML(const XMLNode& node);
+ virtual void SaveToXMLTag( MString & sXMLStream );
+ static StateChanger* Generate();
+
+ bool LoadFromString( const MString & sDescription );
+
+ GENRTTI( StateChanger );
+private:
+
+ MVector< MAutoPtr< StateChange > > m_vStates;
+
+ //Actually... It's faster if we use MercuryVectors here.
+ static MVector< MVector< MAutoPtr< StateChange > > > m_StateSet;
+};
+
+#endif
+
+/****************************************************************************
+ * 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. *
+ ***************************************************************************/
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <cn...@us...> - 2009-10-31 07:00:33
|
Revision: 593
http://hgengine.svn.sourceforge.net/hgengine/?rev=593&view=rev
Author: cnlohr
Date: 2009-10-31 07:00:16 +0000 (Sat, 31 Oct 2009)
Log Message:
-----------
better crash handling capability
Modified Paths:
--------------
Mercury2/adv_set.c
Modified: Mercury2/adv_set.c
===================================================================
--- Mercury2/adv_set.c 2009-10-27 04:50:09 UTC (rev 592)
+++ Mercury2/adv_set.c 2009-10-31 07:00:16 UTC (rev 593)
@@ -31,7 +31,7 @@
#endif
PROJ="mercury"
-CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -Isrc/DataStructures -Isrc/DataTypes -g "
+CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -Isrc/DataStructures -Isrc/DataTypes -g -rdynamic"
LDFLAGS="$LDFLAGS -rdynamic -g -fPIC "
/*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|