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-18 23:04:02
|
Revision: 625 http://hgengine.svn.sourceforge.net/hgengine/?rev=625&view=rev Author: cnlohr Date: 2009-11-18 23:03:51 +0000 (Wed, 18 Nov 2009) Log Message: ----------- tweak UI (And make MessageManager more const'ed) Modified Paths: -------------- Mercury2/modules/Cu2.cpp Mercury2/modules/Cu2.h Mercury2/src/MercuryMessageManager.cpp Mercury2/src/MercuryMessageManager.h Modified: Mercury2/modules/Cu2.cpp =================================================================== --- Mercury2/modules/Cu2.cpp 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/modules/Cu2.cpp 2009-11-18 23:03:51 UTC (rev 625) @@ -45,7 +45,7 @@ SetSize( m_fOrigW, m_fOrigH ); } -bool Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) +int Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) { if( IsHidden() ) return false; @@ -87,11 +87,11 @@ { //Break on the first one that is a hit, that way we don't pass mouse info to buttons below. if( sa->MouseMotion( x - int(sa->m_fX), y - int(sa->m_fY), iCurrentButtonMask, iLastButtonMask ) ) - return bIsInside; + return 2; } } - return bIsInside; + return bIsInside?1:0; } void Cu2Element::PropogateReleaseOut( int x, int y, int iWhichButton ) @@ -278,7 +278,10 @@ } else { - MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data, m_iLastButtonMask ); + if( MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data, m_iLastButtonMask ) != 2 ) + { + MESSAGEMAN.BroadcastMessage( "UIMissMouse", &data ); + } } m_iLastButtonMask = m.buttons.data; @@ -318,6 +321,7 @@ LOAD_FROM_XML( "clickMessage", m_sMessageToSend, ); LOAD_FROM_XML( "text", m_sText, ); LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool ); + LOAD_FROM_XML( "clickPayload", m_sValueToSend, ); if( m_pText ) { @@ -338,6 +342,7 @@ void Cu2Button::SaveToXMLTag( MString & sXMLStream ) { if( m_sMessageToSend.length() ) sXMLStream += ssprintf( "clickMessage=\"%s\" ", m_sMessageToSend.c_str() ); + if( m_sValueToSend.length() ) sXMLStream += ssprintf( "clickPayload=\"%s\" ", m_sValueToSend.c_str() ); if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize ); if( !m_pText ) @@ -498,8 +503,8 @@ glColor3f( .3, .3, .3 ); glBegin( GL_QUADS ); - glVertex2f( 2., GetH()-18 ); - glVertex2f( GetW()-2, GetH()-18 ); + glVertex2f( 2., GetH()-19 ); + glVertex2f( GetW()-2, GetH()-19 ); glVertex2f( GetW()-2, GetH()-3 ); glVertex2f( 2., GetH()-3 ); glEnd(); @@ -527,14 +532,18 @@ Cu2Element::MouseAction( x, y, c, iWhichButton ); } -bool Cu2Dialog::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) +int Cu2Dialog::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) { if( m_bDragging ) { float ix = GetX() - ( m_iClickX - x ); float iy = GetY() - ( m_iClickY - y ); + int dx = x - m_iClickX; + int dy = y - m_iClickY; + SetXY( ix, iy ); + return Cu2Element::MouseMotion( x - dx, y - dy, iCurrentButtonMask, iLastButtonMask ); } return Cu2Element::MouseMotion( x, y, iCurrentButtonMask, iLastButtonMask ); } Modified: Mercury2/modules/Cu2.h =================================================================== --- Mercury2/modules/Cu2.h 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/modules/Cu2.h 2009-11-18 23:03:51 UTC (rev 625) @@ -37,7 +37,10 @@ ///Push raw mouse event. Generally, this calls MouseAction, and is only called internally. ///You may override this if you want to take actions that require mouse motion. - virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); + ///Return value 2: Has hit a child. + ///Return value 1: Has hit self. + ///Return value 0: Has missed self. + virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); ///Called when a key is pressed - down the focus line. virtual void GetKeypress( int key, bool bDown, bool bRepeat ); @@ -155,11 +158,14 @@ void SetAutoSize( bool bAutoSize ) { m_bAutoSize = bAutoSize; Refresh(); } void Refresh(); + MString & Payload() { return m_sValueToSend; } + TextNode * GetTextNodeHandle() { return m_pText; } GENRTTI( Cu2Button ); private: MString m_sMessageToSend; + MString m_sValueToSend; MString m_sText; bool m_bAutoSize; bool m_bDown; @@ -177,7 +183,7 @@ virtual void LoadFromXML(const XMLNode& node); virtual void SaveToXMLTag( MString & sXMLStream ); virtual void Render( const MercuryMatrix& m ); - virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); + virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton ); void SetText( const MString & sText ); Modified: Mercury2/src/MercuryMessageManager.cpp =================================================================== --- Mercury2/src/MercuryMessageManager.cpp 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/src/MercuryMessageManager.cpp 2009-11-18 23:03:51 UTC (rev 625) @@ -46,7 +46,7 @@ } } -void MercuryMessageManager::BroadcastMessage( const MString & message, MessageData * data ) +void MercuryMessageManager::BroadcastMessage( const MString & message, const MessageData * data ) { std::list< MessagePair > recipients; { Modified: Mercury2/src/MercuryMessageManager.h =================================================================== --- Mercury2/src/MercuryMessageManager.h 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/src/MercuryMessageManager.h 2009-11-18 23:03:51 UTC (rev 625) @@ -40,7 +40,7 @@ void PostMessage(const MString& message, MessageData* data, float delay); ///Immediately dispatch message - void BroadcastMessage( const MString & message, MessageData * data ); + void BroadcastMessage( const MString & message, const MessageData * data ); void PumpMessages(const uint64_t& currTime); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-12-14 20:27:13
|
Revision: 628 http://hgengine.svn.sourceforge.net/hgengine/?rev=628&view=rev Author: axlecrusher Date: 2009-12-14 20:27:01 +0000 (Mon, 14 Dec 2009) Log Message: ----------- updates for particles Modified Paths: -------------- Mercury2/Themes/default/File/scenegraph.xml Mercury2/Themes/default/Graphic/test.frag Mercury2/Themes/default/Graphic/test.vert Mercury2/modules.xml Modified: Mercury2/Themes/default/File/scenegraph.xml =================================================================== --- Mercury2/Themes/default/File/scenegraph.xml 2009-12-14 20:17:42 UTC (rev 627) +++ Mercury2/Themes/default/File/scenegraph.xml 2009-12-14 20:27:01 UTC (rev 628) @@ -17,6 +17,7 @@ <asset type="texture" file="MODEL:map.png"/> <asset type="terrain" file="MODEL:map.hgmdl" /> </node> + <node type="mercurynode" name="lampForest" > <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > <node type="mercurynode" name="lamp"> @@ -24,12 +25,24 @@ <asset type="texture" file="MODEL:lamp.png"/> <asset type="hgmdlmodel" file="MODEL:lampN.hgmdl" /> </node> - <node type="billboardnode" billboardaxis="0,-1,0" spheremode="true" > +<!-- <node type="billboardnode" billboardaxis="0,-1,0" spheremode="true" > <node type="transformnode" scalex="0.1" scaley="0.1" alphaPath="true"> <asset type="StateChanger" file="ColorChange:1,0,1,1" /> <asset type="texture" file="GRAPHIC:flame.png"/> <asset type="quad"/> </node> + </node> --> +<!-- <asset type="StateChanger" file="DepthWrite:0" /> + state changer needs some work for proper on and off. + until then had code it for all particles --> + <node type="particleemitter" texture="GRAPHIC:flame.png"> + <asset type="texture" file="GRAPHIC:flame.png"/> + <asset type="shader" file="GRAPHIC:FireParticles"/> + <particle> + <node type="transformnode" scalex="0.075" scaley="0.075" scalez="0.075" alphaPath="false"> + <asset type="quad"/> + </node> + </particle> </node> </node> <node type="transformnode" movx="1" fallback="lamprow.lamp" /> Modified: Mercury2/Themes/default/Graphic/test.frag =================================================================== --- Mercury2/Themes/default/Graphic/test.frag 2009-12-14 20:17:42 UTC (rev 627) +++ Mercury2/Themes/default/Graphic/test.frag 2009-12-14 20:27:01 UTC (rev 628) @@ -1,4 +1,6 @@ +varying vec3 color; + void main() { - gl_FragColor = vec4( 1., 0., 1., 1. ); -} \ No newline at end of file + gl_FragColor = vec4( color, 1. ); +} Modified: Mercury2/Themes/default/Graphic/test.vert =================================================================== --- Mercury2/Themes/default/Graphic/test.vert 2009-12-14 20:17:42 UTC (rev 627) +++ Mercury2/Themes/default/Graphic/test.vert 2009-12-14 20:27:01 UTC (rev 628) @@ -1,4 +1,14 @@ +varying vec3 color; + +uniform vec4 HG_EyePos; +uniform mat4 HG_ModelMatrix; + void main() { gl_Position = ftransform(); -} \ No newline at end of file + color = vec3(0,0,1); + + vec3 v = normalize(HG_EyePos - (HG_ModelMatrix*vec4(0,0,0,1))).xyz; + + color = (v+1.0)*0.5; +} Modified: Mercury2/modules.xml =================================================================== --- Mercury2/modules.xml 2009-12-14 20:17:42 UTC (rev 627) +++ Mercury2/modules.xml 2009-12-14 20:27:01 UTC (rev 628) @@ -3,5 +3,6 @@ <Module src="modules/BillboardNode.cpp" obj="modules/BillboardNode" func="InstallBillboardNode" class="BillboardNode" /> <Module src="modules/Terrain.cpp" obj="modules/Terrain" func="" class="TerrainNode"/> <Module src="modules/TextPlate.cpp" obj="modules/TextPlate" func="InstallTextPlate" class="TextPlate"/> + <Module src="modules/ParticleEmitter.cpp" obj="modules/ParticleEmitter" func="InstallParticleEmitter" class="ParticleEmitter"/> <Module src="modules/Cu2.cpp" obj="modules/Cu2" func="InstallCu2Element" class="Cu2Element"/> </Modules> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2010-02-23 05:53:33
|
Revision: 674 http://hgengine.svn.sourceforge.net/hgengine/?rev=674&view=rev Author: cnlohr Date: 2010-02-23 05:53:27 +0000 (Tue, 23 Feb 2010) Log Message: ----------- add some stuff for ssvgr Modified Paths: -------------- Mercury2/src/StateChanger.cpp Added Paths: ----------- Mercury2/Themes/default/File/ssvgr.xml Mercury2/Themes/default/Graphic/2by.png Added: Mercury2/Themes/default/File/ssvgr.xml =================================================================== --- Mercury2/Themes/default/File/ssvgr.xml (rev 0) +++ Mercury2/Themes/default/File/ssvgr.xml 2010-02-23 05:53:27 UTC (rev 674) @@ -0,0 +1,61 @@ +<SceneGraph name="root" setPasses="6+7" > + <!--We have to put all states that are the generic state up here. This way, the states will fall back to these --> + <asset type="StateChanger" file="ColorChange:1,1,1,1"/> + <asset type="StateChanger" file="DepthTest:1"/> + <asset type="StateChanger" file="LightingSwitch:0" enduring="1" /> + <asset type="StateChanger" file="DepthWrite:1"/> + <asset type="StateChanger" file="FaceCulling:none"/> + <asset type="StateChanger" file="BlendFunc:SRC_ALPHA,ONE_MINUS_SRC_ALPHA" /> + <asset type="StateChanger" file="AlphaFunc:GREATER,0.5" /> <!-- makes alpha ordering not matter, since it's all or nothing --> + + <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100" name="vp" > + <node type="cameranode" movx="0" movz="0" movy="0" rotx="0" roty="0" rotz="0" name="camera" > + + <node fallback="root.ground" setPasses="7" /> + + <node type="transformnode" movy="2" > + <node fallback="root.lampForest" setPasses="6" /> + </node> + <node type="transformnode" movy="0" > + <node fallback="root.lampForest" setPasses="7" /> + </node> + + <node type="transformnode" movz="-5" > + <asset type="texture" file="GRAPHIC:2by.png" filter="none" /> + <asset type="quad" /> + </node> + + </node> + </node> + + + <!-- Below here is just a library for some junk we can throw in --> + + <node type="mercurynode" name="lampForest" setPasses="0" > + <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > + <node type="mercurynode" name="lamp" > + <node type="transformnode" rotx="-90" > + <asset type="texture" file="MODEL:lamp.png"/> + <asset type="hgmdlmodel" file="MODEL:lampN.hgmdl" /> + </node> + </node> + <node type="transformnode" movx="1" fallback="lamprow.lamp" /> + <node type="transformnode" movx="2" fallback="lamprow.lamp" /> + <node type="transformnode" movx="3" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-1" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-2" fallback="lamprow.lamp" /> + <node type="transformnode" movx="-3" fallback="lamprow.lamp" /> + </node> + <node type="transformnode" movz="-6" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-7" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-8" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-9" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-4" fallback="lampForest.lamprow"/> + <node type="transformnode" movz="-3" fallback="lampForest.lamprow"/> + </node> + <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-0.99" setPasses="0" name="ground" > + <asset type="texture" file="MODEL:map.png" /> + <asset type="terrain" file="MODEL:map.hgmdl" /> + </node> + +</SceneGraph> Added: Mercury2/Themes/default/Graphic/2by.png =================================================================== (Binary files differ) Property changes on: Mercury2/Themes/default/Graphic/2by.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: Mercury2/src/StateChanger.cpp =================================================================== --- Mercury2/src/StateChanger.cpp 2010-02-23 02:19:18 UTC (rev 673) +++ Mercury2/src/StateChanger.cpp 2010-02-23 05:53:27 UTC (rev 674) @@ -150,6 +150,52 @@ REGISTER_STATECHANGE( DepthWrite ); +class FaceCulling : public StateChange +{ +public: + FaceCulling( const MVector< MString > & sParameters ) : StateChange( sParameters ) + { + if( sParameters.size() < 1 ) + { + LOG.Write( ssprintf( "Error: DepthWrite state has invalid number of parameters(%d).", sParameters.size() ) ); + return; + } + if( sParameters[0].compare( "front" ) == 0 ) + iWhich = 1; + if( sParameters[0].compare( "back" ) == 0 ) + iWhich = 2; + else + iWhich = 0; + } + + void Stringify( MString & sOut ) + { + sOut = (iWhich)?((iWhich==1)?"front":"back"):""; + } + + void Activate() + { + if( iWhich ) + { + GLCALL( glEnable(GL_CULL_FACE) ); + if( iWhich == 1 ) + {GLCALL( glCullFace(GL_FRONT) );} + else + {GLCALL( glCullFace(GL_BACK) );} + } + else + { + GLCALL( glDisable(GL_CULL_FACE) ); + } + } + + STATECHANGE_RTTI( FaceCulling ); + int iWhich; +}; + +REGISTER_STATECHANGE( FaceCulling ); + + class BlendFunc : public StateChange { public: @@ -225,6 +271,69 @@ REGISTER_STATECHANGE( BlendFunc ); +class AlphaFunc : public StateChange +{ +public: + AlphaFunc( const MVector< MString > & sParameters ) : StateChange( sParameters ) + { + if( sParameters.size() < 2 ) + { + LOG.Write( ssprintf( "Error: AlphaFunc state has invalid number of parameters(%d).", sParameters.size() ) ); + return; + } + + m_func = StrToAlpha(sParameters[0] ); + m_ref = StrToFloat(sParameters[1] ); + } + + void Stringify( MString & sOut ) + { + sOut = AlphaToStr(m_func) + ssprintf( ",%f", m_ref ); + } + + #define STRTOGL(x,s) if (x==#s) return GL_##s; + int StrToAlpha(const MString& s) + { + STRTOGL(s, NEVER); + STRTOGL(s, LESS); + STRTOGL(s, EQUAL); + STRTOGL(s, LEQUAL); + STRTOGL(s, GREATER); + STRTOGL(s, NOTEQUAL); + STRTOGL(s, GEQUAL); + STRTOGL(s, ALWAYS); + return -1; + } + + #define GLTOSTR(x,s) case GL_##s: return #s; + MString AlphaToStr(int blend) + { + switch (blend) + { + GLTOSTR(blend, NEVER); + GLTOSTR(blend, LESS); + GLTOSTR(blend, EQUAL); + GLTOSTR(blend, LEQUAL); + GLTOSTR(blend, GREATER); + GLTOSTR(blend, NOTEQUAL); + GLTOSTR(blend, GEQUAL); + GLTOSTR(blend, ALWAYS); + }; + } + + void Activate() + { + GLCALL( glEnable( GL_ALPHA_TEST ) ); + GLCALL( glAlphaFunc(m_func,m_ref) ); + } + + STATECHANGE_RTTI( AlphaFunc ); + int m_func; + float m_ref; +}; + +REGISTER_STATECHANGE( AlphaFunc ); + //////////////////////////////////////STATE CHANGE CHUNK////////////////////////////////////// StateChangeRegister & StateChangeRegister::Instance() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2010-05-18 20:14:56
|
Revision: 738 http://hgengine.svn.sourceforge.net/hgengine/?rev=738&view=rev Author: axlecrusher Date: 2010-05-18 20:14:49 +0000 (Tue, 18 May 2010) Log Message: ----------- fix warnings Modified Paths: -------------- Mercury2/modules/Cu2.cpp Mercury2/modules/ParticleEmitter.cpp Mercury2/modules/TextNode.cpp Mercury2/src/DataTypes/MTriangle.cpp Mercury2/src/MercuryInput.cpp Mercury2/src/MercurySound.cpp Mercury2/src/MercurySound.h Mercury2/src/MercuryValue.cpp Mercury2/src/Quad.cpp Modified: Mercury2/modules/Cu2.cpp =================================================================== --- Mercury2/modules/Cu2.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/modules/Cu2.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -62,8 +62,8 @@ for( unsigned button = 0; button < 3; button++ ) { unsigned char Mask = 1<<button; - bool bWasDown = iLastButtonMask & Mask; - bool bIsDown = iCurrentButtonMask & Mask; + bool bWasDown = GetBit(iLastButtonMask,Mask); + bool bIsDown = GetBit(iCurrentButtonMask,Mask); if( bWasDown && !bIsDown ) { //XXX: When we release outside - we want to propogate that information, and that can be tricky.. @@ -396,8 +396,8 @@ { if( m_sAssociatedValueX.length() && m_bDown && x >= 0 && y >= 0 && x < GetW() && y < GetH() ) { - float fxRangeMin = atof( m_sxRangeMin.c_str() ); - float fxRangeMax = m_sxRangeMax.length()?atof( m_sxRangeMax.c_str() ):GetW(); + float fxRangeMin = (float)atof( m_sxRangeMin.c_str() ); + float fxRangeMax = m_sxRangeMax.length()?(float)atof( m_sxRangeMax.c_str() ):GetW(); float fX = ( float(x) / float(GetW()-1) ) * (fxRangeMax - fxRangeMin) + fxRangeMin; MESSAGEMAN.GetValue( m_sAssociatedValueX )->SetFloat( fX ); @@ -405,8 +405,8 @@ if( m_sAssociatedValueY.length() && m_bDown && x >= 0 && y >= 0 && x < GetW() && y < GetH() ) { - float fyRangeMin = atof( m_syRangeMin.c_str() ); - float fyRangeMax = m_syRangeMax.length()?atof( m_syRangeMax.c_str() ):GetW(); + float fyRangeMin = (float)atof( m_syRangeMin.c_str() ); + float fyRangeMax = m_syRangeMax.length()?(float)atof( m_syRangeMax.c_str() ):GetW(); float fY = ( float(y) / float(GetH()-1) ) * (fyRangeMax - fyRangeMin) + fyRangeMin; MESSAGEMAN.GetValue( m_sAssociatedValueY )->SetFloat( fY ); @@ -446,9 +446,9 @@ { glDisable( GL_TEXTURE_2D ); if( m_bDown ) - glColor3f( 0.3, 0.3, 0.3 ); + glColor3f( 0.3f, 0.3f, 0.3f ); else - glColor3f( 0.5, 0.5, 0.5 ); + glColor3f( 0.5f, 0.5f, 0.5f ); glBegin( GL_QUADS ); glVertex2f( 1., 1. ); @@ -460,17 +460,17 @@ glLineWidth( 2 ); glBegin( GL_LINES ); if( m_bDown ) - glColor3f( 0.1, 0.1, 0.1 ); + glColor3f( 0.1f, 0.1f, 0.1f ); else - glColor3f( 0.7, 0.7, 0.7 ); + glColor3f( 0.7f, 0.7f, 0.7f ); glVertex2f( 1, 1 ); glVertex2f( 1, GetH()-1 ); glVertex2f( 1, GetH()-1 ); glVertex2f( GetW()-2, GetH()-1 ); if( !m_bDown ) - glColor3f( 0.1, 0.1, 0.1 ); + glColor3f( 0.1f, 0.1f, 0.1f ); else - glColor3f( 0.7, 0.7, 0.7 ); + glColor3f( 0.7f, 0.7f, 0.7f ); glVertex2f( GetW()-1, GetH()-2 ); glVertex2f( GetW()-1, 1 ); glVertex2f( GetW()-1, 1 ); @@ -618,12 +618,12 @@ glLineWidth( 2 ); glBegin( GL_LINES ); - glColor3f( 0.7, 0.7, 0.7 ); + glColor3f( 0.7f, 0.7f, 0.7f ); glVertex2f( 1, 1 ); glVertex2f( 1, GetH()-1 ); glVertex2f( 1, GetH()-1 ); glVertex2f( GetW()-2, GetH()-1 ); - glColor3f( 0.1, 0.1, 0.1 ); + glColor3f( 0.1f, 0.1f, 0.1f ); glVertex2f( GetW()-1, GetH()-2 ); glVertex2f( GetW()-1, 1 ); glVertex2f( GetW()-1, 1 ); @@ -633,7 +633,7 @@ if( HasFocus() ) glColor3f( 0., 0., 1. ); else - glColor3f( .3, .3, .3 ); + glColor3f( .3f, .3f, .3f ); glBegin( GL_QUADS ); glVertex2f( 2., GetH()-19 ); Modified: Mercury2/modules/ParticleEmitter.cpp =================================================================== --- Mercury2/modules/ParticleEmitter.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/modules/ParticleEmitter.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -113,8 +113,8 @@ } ParticleEmitter::ParticleEmitter() - :base(), m_maxParticles(50), m_age(0), m_emitDelay(0.1), m_lifespan(0), - m_particlesEmitted(0), m_particleMinLife(0.1), m_particleMaxLife(5), + :base(), m_maxParticles(50), m_age(0), m_emitDelay(0.1f), m_lifespan(0), + m_particlesEmitted(0), m_particleMinLife(0.1f), m_particleMaxLife(5.0f), m_particles(NULL), GenerateParticlesClbk(NULL), m_dirtyVBO(0) { @@ -184,8 +184,8 @@ p->m_lifespan = m_particleMinLife; p->m_lifespan += (rand()%(int(m_particleMaxLife*1000) - int(m_particleMinLife*1000)))/1000.0f; - p->m_rand1 = rand()%100000; - p->m_rand2 = rand()%100000; + p->m_rand1 = float(rand()%100000); + p->m_rand2 = float(rand()%100000); // +((rand()%((m_particleMaxLife*1000)-(m_particleMinLife*1000)))/1000.0f); Modified: Mercury2/modules/TextNode.cpp =================================================================== --- Mercury2/modules/TextNode.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/modules/TextNode.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -249,7 +249,7 @@ float offset = m_fTextWidth - fEndOfLine; offset/=2; if( m_fTextWidth > BIG_NUMBER ) - offset = -fEndOfLine/2.; + offset = -fEndOfLine/2.0f; for( unsigned j = iLineStart; j < i; j++ ) chars[j].xps += offset; } else if( m_alignment == FIT_FULL ) Modified: Mercury2/src/DataTypes/MTriangle.cpp =================================================================== --- Mercury2/src/DataTypes/MTriangle.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/src/DataTypes/MTriangle.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -77,7 +77,7 @@ v[0] = m_verts[1] - m_verts[0]; v[1] = m_verts[2] - m_verts[0]; MercuryVector r( v[0].CrossProduct( v[1] ) ); - return r.Length() * 0.5; + return r.Length() * 0.5f; } bool MTriangle::operator == (const MTriangle& rhs) const @@ -92,8 +92,8 @@ { float minX, minY, minZ; float maxX, maxY, maxZ; - minX=minY=minZ = 9999999999999; - maxX=maxY=maxZ = -9999999999999; + minX=minY=minZ = 9999999999999.0f; + maxX=maxY=maxZ = -9999999999999.0f; for (uint8_t i = 0; i<3; ++i) { @@ -109,7 +109,7 @@ MercuryVertex center( (maxX+minX)/2.0f, (maxY+minY)/2.0f, (maxZ+minZ)/2.0f ); //extends - MercuryVertex extend( (maxX-minX)/2.0, (maxY-minY)/2.0, (maxZ-minZ)/2.0 ); + MercuryVertex extend( (maxX-minX)/2.0f, (maxY-minY)/2.0f, (maxZ-minZ)/2.0f ); return BoundingBox(center, extend); } Modified: Mercury2/src/MercuryInput.cpp =================================================================== --- Mercury2/src/MercuryInput.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/src/MercuryInput.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -26,8 +26,8 @@ mi->buttons.motion = bMotionEvent; currentButtonMasks = buttons; - GlobalMouseX_Set.Set( dx ); - GlobalMouseY_Set.Set( dy ); + GlobalMouseX_Set.Set( (float)dx ); + GlobalMouseY_Set.Set( (float)dy ); GlobalMouseB_Set.Set( currentButtonMasks.data ); POST_MESSAGE( INPUTEVENT_MOUSE, mi, 0 ); Modified: Mercury2/src/MercurySound.cpp =================================================================== --- Mercury2/src/MercurySound.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/src/MercurySound.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -134,7 +134,7 @@ //XXX: CONSIDER MUTEXING THIS AREA, AND USING THE SAME MUTEX IN SampleHoldCalcand Attac/Detach sound. float ftd = m_tLastTrip.Touch(); - iLastCountDifference = ftd * fSPS; + iLastCountDifference = int(ftd * fSPS); for( int j = 0; j < iCount * iChannels; ++j ) cBufferToFill[j] = 0; Modified: Mercury2/src/MercurySound.h =================================================================== --- Mercury2/src/MercurySound.h 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/src/MercurySound.h 2010-05-18 20:14:49 UTC (rev 738) @@ -71,7 +71,7 @@ //Useful tools inline float GetSecondsSinceLastFrame() { float tr = m_tLastTrip.Age(); return (tr>1.f)?1.f:tr; } - inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (unsigned int)(tr>1.)?fSPS:(tr*fSPS); } + inline unsigned int SamplesSinceLastFrame() { float tr = m_tLastTrip.Age(); return (unsigned int)((tr>1.)?fSPS:(tr*fSPS)); } //For registering and creation of new sound sources... MAutoPtr< MercurySoundSource > LoadSoundSource( const MString & sSourceType, MAutoPtr< MercurySoundSource > Chain = 0 ); Modified: Mercury2/src/MercuryValue.cpp =================================================================== --- Mercury2/src/MercuryValue.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/src/MercuryValue.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -74,8 +74,8 @@ { switch( m_CurType ) { - case TYPE_INT: return (int)m_Data.l; - case TYPE_FLOAT: return m_Data.f; + case TYPE_INT: return m_Data.l; + case TYPE_FLOAT: return (int)m_Data.f; case TYPE_STRING: return StrToInt(*m_Data.dataS); default: return 0; } Modified: Mercury2/src/Quad.cpp =================================================================== --- Mercury2/src/Quad.cpp 2010-05-18 20:01:48 UTC (rev 737) +++ Mercury2/src/Quad.cpp 2010-05-18 20:14:49 UTC (rev 738) @@ -89,19 +89,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++] = (m_bFlipV)?0:1; - m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0; + m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?0:1.0f; + m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0f; m_vertexData[i++] = lX; m_vertexData[i++] = lY; m_vertexData[i++] = zp; - 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++] = 1; m_vertexData[i++] = (m_bFlipV)?0:1.0f; + m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0f; m_vertexData[i++] = hX; m_vertexData[i++] = lY; m_vertexData[i++] = zp; - 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++] = 1; m_vertexData[i++] = (m_bFlipV)?1.0f:0; + m_vertexData[i++] = 0; m_vertexData[i++] = 0; m_vertexData[i++] = -1.0f; m_vertexData[i++] = hX; m_vertexData[i++] = hY; m_vertexData[i++] = zp; - m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?1:0; + m_vertexData[i++] = 0; m_vertexData[i++] = (m_bFlipV)?1.0f: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; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2008-12-30 19:22:00
|
Revision: 98 http://hgengine.svn.sourceforge.net/hgengine/?rev=98&view=rev Author: axlecrusher Date: 2008-12-30 19:21:53 +0000 (Tue, 30 Dec 2008) Log Message: ----------- updates Modified Paths: -------------- Mercury2/docs/MercuryBinaryModelFormat.odt Mercury2/mercury2.kdevelop Mercury2/scenegraph.xml Mercury2/src/HGMDLModel.cpp Mercury2/src/HGMDLModel.h Mercury2/src/TransformNode.cpp Mercury2/src/TransformNode.h Mercury2/src/X11Window.cpp Added Paths: ----------- Mercury2/beerhall.hgmdl Added: Mercury2/beerhall.hgmdl =================================================================== (Binary files differ) Property changes on: Mercury2/beerhall.hgmdl ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: Mercury2/docs/MercuryBinaryModelFormat.odt =================================================================== (Binary files differ) Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2008-12-30 15:25:26 UTC (rev 97) +++ Mercury2/mercury2.kdevelop 2008-12-30 19:21:53 UTC (rev 98) @@ -41,7 +41,18 @@ <ccompiler>kdevgccoptions</ccompiler> <cxxcompiler>kdevgppoptions</cxxcompiler> <f77compiler>kdevg77options</f77compiler> - <cxxflags>-O2 -g0</cxxflags> + <cxxflags>-O2 -g0 -Wall</cxxflags> + <envvars/> + <configargs/> + <topsourcedir/> + <cppflags>-Isrc/ -I/usr/include/libxml2/ +</cppflags> + <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> + <ccompilerbinary/> + <cxxcompilerbinary/> + <f77compilerbinary/> + <cflags/> + <f77flags/> </optimized> <debug> <configargs>--enable-debug=full</configargs> Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2008-12-30 15:25:26 UTC (rev 97) +++ Mercury2/scenegraph.xml 2008-12-30 19:21:53 UTC (rev 98) @@ -20,4 +20,10 @@ <asset type="quad"/> </node> </node> + <node type="rotatornode" movz="-3" scalex="0.05" scaley="0.05" scalez="0.05" > + <node type="renderablenode"> + <asset type="texture" imagefile="test.bmp"/> + <asset type="hgmdlmodel" file="beerhall.hgmdl"/> + </node> + </node> </SceneGraph> Modified: Mercury2/src/HGMDLModel.cpp =================================================================== --- Mercury2/src/HGMDLModel.cpp 2008-12-30 15:25:26 UTC (rev 97) +++ Mercury2/src/HGMDLModel.cpp 2008-12-30 19:21:53 UTC (rev 98) @@ -46,9 +46,8 @@ void HGMDLModel::Render(MercuryNode* node) { - list< MAutoPtr< HGMDLMesh > >::iterator i = m_meshes.begin(); - for(;i != m_meshes.end(); ++i) - (*i)->Render(node); + for(uint16_t i = 0; i < m_meshes.size(); ++i) + m_meshes[i]->Render(node); } HGMDLModel* HGMDLModel::Generate() Modified: Mercury2/src/HGMDLModel.h =================================================================== --- Mercury2/src/HGMDLModel.h 2008-12-30 15:25:26 UTC (rev 97) +++ Mercury2/src/HGMDLModel.h 2008-12-30 19:21:53 UTC (rev 98) @@ -4,6 +4,8 @@ #include <MercuryAsset.h> #include <HGMDLMesh.h> +#include <vector> + class HGMDLModel : public MercuryAsset { public: @@ -16,7 +18,7 @@ virtual void Render(MercuryNode* node); private: - std::list< MAutoPtr< HGMDLMesh > > m_meshes; + std::vector< MAutoPtr< HGMDLMesh > > m_meshes; }; #endif Modified: Mercury2/src/TransformNode.cpp =================================================================== --- Mercury2/src/TransformNode.cpp 2008-12-30 15:25:26 UTC (rev 97) +++ Mercury2/src/TransformNode.cpp 2008-12-30 19:21:53 UTC (rev 98) @@ -1,6 +1,7 @@ #include <TransformNode.h> REGISTER_NODE_TYPE(TransformNode); +REGISTER_NODE_TYPE(RotatorNode); TransformNode::TransformNode() :m_scale( MercuryPoint(1,1,1) ) @@ -143,6 +144,17 @@ } } +void RotatorNode::Update(float dTime) +{ + MercuryPoint r = GetRotation(); + r.x += (dTime)*2.5; + r.y += (dTime)*5; + + SetRotation( r ); + + TransformNode::Update(dTime); +} + /**************************************************************************** * Copyright (C) 2008 by Joshua Allen * * * Modified: Mercury2/src/TransformNode.h =================================================================== --- Mercury2/src/TransformNode.h 2008-12-30 15:25:26 UTC (rev 97) +++ Mercury2/src/TransformNode.h 2008-12-30 19:21:53 UTC (rev 98) @@ -12,7 +12,7 @@ public: TransformNode(); - void Update(float dTime); + virtual void Update(float dTime); void SetScale( const MercuryPoint& scale ); void SetPosition( const MercuryPoint& position ); @@ -41,13 +41,20 @@ MercuryPoint m_scale; MercuryPoint m_position; MercuryPoint m_rotation; - + // MercuryMatrix m_localMatrix; MercuryMatrix m_globalMatrix; bool m_tainted; }; +class RotatorNode : public TransformNode +{ + public: + virtual void Update(float dTime); + GENRTTI(TransformNode); +}; + #endif /**************************************************************************** Modified: Mercury2/src/X11Window.cpp =================================================================== --- Mercury2/src/X11Window.cpp 2008-12-30 15:25:26 UTC (rev 97) +++ Mercury2/src/X11Window.cpp 2008-12-30 19:21:53 UTC (rev 98) @@ -125,11 +125,13 @@ case KeyPress: { XKeyEvent* e = (XKeyEvent*)&event; + e->keycode; break; } case KeyRelease: { XKeyEvent* e = (XKeyEvent*)&event; + e->keycode; break; } case MotionNotify: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2008-12-30 22:10:33
|
Revision: 113 http://hgengine.svn.sourceforge.net/hgengine/?rev=113&view=rev Author: cnlohr Date: 2008-12-30 22:10:30 +0000 (Tue, 30 Dec 2008) Log Message: ----------- crash handler Modified Paths: -------------- Mercury2/adv_set.c Mercury2/src/Mercury2.cpp Added Paths: ----------- Mercury2/src/MercuryBacktrace.c Mercury2/src/MercuryBacktrace.h Mercury2/src/MercuryCrash.c Mercury2/src/MercuryCrash.h Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2008-12-30 21:37:42 UTC (rev 112) +++ Mercury2/adv_set.c 2008-12-30 22:10:30 UTC (rev 113) @@ -3,17 +3,12 @@ FOLDERS="src" -SOURCES="src/Mercury2.cpp src/MercuryAsset.cpp \ - src/MercuryNode.cpp src/MercuryPoint.cpp \ - src/MercuryThreads.cpp src/MercuryMath.cpp \ - src/MercuryWindow.cpp src/RenderableNode.cpp \ - src/TransformNode.cpp src/MercuryMatrix.cpp \ - src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \ - src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp \ - src/PNGLoader.cpp src/ImageLoader.cpp \ - src/MercuryVBO.cpp src/MSemaphore.cpp \ - src/UpdateThreader.cpp src/HGMDLMesh.cpp \ - src/HGMDLModel.cpp src/MercuryString.cpp" +SOURCES="src/Mercury2.cpp src/MercuryAsset.cpp src/MercuryNode.cpp src/MercuryPoint.cpp \ + src/MercuryThreads.cpp src/MercuryMath.cpp src/MercuryWindow.cpp src/RenderableNode.cpp \ + src/TransformNode.cpp src/MercuryMatrix.cpp src/Viewport.cpp src/Quad.cpp src/MercuryUtil.cpp \ + src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp src/PNGLoader.cpp src/ImageLoader.cpp \ + src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \ + src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c" #ifdef USE_LIBXML SOURCES="$SOURCES src/XMLParser.cpp" @@ -24,8 +19,8 @@ #endif PROJ="mercury" -CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc" -LDFLAGS="$LDFLAGS -rdynamic -g -fPIC" +CFLAGS="$CFLAGS -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -Isrc -g " +LDFLAGS="$LDFLAGS -rdynamic -g -fPIC " /* * (c) 2007-2008 Charles Lohr Modified: Mercury2/src/Mercury2.cpp =================================================================== --- Mercury2/src/Mercury2.cpp 2008-12-30 21:37:42 UTC (rev 112) +++ Mercury2/src/Mercury2.cpp 2008-12-30 22:10:30 UTC (rev 113) @@ -8,6 +8,9 @@ #include <RenderableNode.h> +#include <MercuryCrash.h> +#include <MercuryBacktrace.h> + MSemaphore UpdateLoopGo; void* UpdateThread(void* node) { @@ -19,11 +22,23 @@ return NULL; } +int SignalHandler( int signal ) +{ + char buffer[2048]; + printf( "Fatal error encountered in Mercury 2: %s\n", cn_get_crash_description( signal ) ); + cnget_backtrace( 1, buffer, 2047 ); + printf( "%s\n", buffer ); + + return 0; //Continue regular crash. +} + int main() { unsigned long m_count = 0; long m_time; - + + cnset_execute_on_crash( SignalHandler ); + MercuryWindow* w = MercuryWindow::MakeWindow(); MercuryNode* root = new MercuryNode(); Added: Mercury2/src/MercuryBacktrace.c =================================================================== --- Mercury2/src/MercuryBacktrace.c (rev 0) +++ Mercury2/src/MercuryBacktrace.c 2008-12-30 22:10:30 UTC (rev 113) @@ -0,0 +1,611 @@ +#include "MercuryBacktrace.h" + + +#ifdef WIN32 +#define _CWINDOWS +#else +#if defined( MACOSX ) || defined( __APPLE__ ) +#define _CMAC +#else +#define _CLINUX +#endif +#endif + + + +#if defined ( _CWINDOWS ) +#define CPU_X86 +#include <windows.h> +#include <dbghelp.h> +#pragma comment( lib, "dbghelp.lib" ) +/*Since we have inline code in windows, there are + warnings associated with disabling optimization, + ignore them. */ +#pragma warning( disable : 4748) +/*Ignore CRT_SECURE_NO_DEPRECIATE for snprintf */ +#pragma warning( disable : 4996) +#elif defined( _CMAC ) || defined( _CLINUX ) + +#ifdef _CLINUX +#include <malloc.h> +#include <execinfo.h> +#define HAVE_EXECINFO +#endif + + +#ifdef HAVE_LIBIBERTY + +/*Ok, even StepMania had this question!: + This is in libiberty. Where is it declared? */ +#ifdef __cplusplus +extern "C" { +#endif +char *cplus_demangle (const char *mangled, int options); +#ifdef __cplusplus +}; +#endif +#endif + +#if !defined( __USE_GNU ) && !defined( _CMAC ) + +typedef struct +{ + __const char *dli_fname; /* File name of defining object. */ + void *dli_fbase; /* Load address of that object. */ + __const char *dli_sname; /* Name of nearest symbol. */ + void *dli_saddr; /* Exact value of nearest symbol. */ +} Dl_info; + +extern int dladdr (__const void *__address, Dl_info *__info); +extern void *dlopen (__const char *__file, int __mode); +extern int dlclose (void *__handle); +extern void *dlsym (void *__restrict __handle, + __const char *__restrict __name); + +#endif + +#include <dlfcn.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> +#include <fcntl.h> +int bUseAddr2Line, DBGSetup = 0; + +#endif + + + + +struct BacktraceContext +{ + int dummy; +#if defined( _CWINDOWS) + CONTEXT context; + HANDLE hThread; + HANDLE hProcess; +#endif +}; + +#include <stdio.h> + +int GetBacktrace( void **buf, unsigned size, struct BacktraceContext *ctx ); +int GetBTName( const void * ptr, char * str, int maxlen, struct BacktraceContext * ctx ); +void SetupDBGHelp(); + + +int cnget_backtrace( int SkipFirst, char * buffer, int max_size ) +{ + char * tmpbuf = buffer; + + void * buf[256]; + int i = 0; + SetupDBGHelp(); + GetBacktrace( (void **)buf, 256, 0 ); + + for( ; i < SkipFirst; i++ ) + if( buf[i] == 0 ) + return 0; + + while( buf[i] != 0 ) + { + int space_left = max_size-(int)(tmpbuf-buffer)-2; + tmpbuf+=GetBTName( buf[i], tmpbuf, space_left, 0 ); + *tmpbuf='\n'; + tmpbuf++; + *tmpbuf='\0'; + i++; + } + + return i-1; +} + + + + + + + +#if defined( _CMAC ) || defined( _CLINUX ) +//Based off of http://stackoverflow.com/questions/289820/getting-the-current-stack-trace-on-mac-os-x + +int GetBacktrace( void **buffer, unsigned size, struct BacktraceContext *ctx ) +{ +#ifdef HAVE_EXECINFO + return backtrace( buffer, size ); +#else + //Todo: See if the return is beyond the end of a function. + + void **frame = (void **)__builtin_frame_address(0); + void **bp = ( void **)(*frame); + void *ip = frame[1]; + int i; + + for ( i = 0; bp && ip && i < size; i++ ) + { + *(buffer++) = ip; + ip = bp[1]; + bp = (void**)(bp[0]); + } + + return i; +#endif +} + +int Demangle( char * out, int maxlen, const char * in ) +{ + *out = 0; + if( !in ) + return 0; +#ifdef HAVE_LIBIBERTY + int pos = 0; + char * demangled = cplus_demangle( in, 0 ); + if( !demangled ) + return 0; + while( demangled[pos] != 0 && pos + 1 < maxlen ) + { + out[pos] = demangled[pos]; + pos++; + } + out[pos] = 0; + free( demangled ); + return pos; +#else + return 0; +#endif +} + + +int Addr2Line( char * out, char * demangled, int maxlen, const char * file, const void * offset ) +{ + int tmp; + char execline[1024]; + char buffer[1024]; + int fds[2]; + int readbytes; + int newlinepos; + int slashpos; + + *out = 0; + *demangled = 0; + + if( strlen( file ) < 1 ) + return 0; + + tmp = open( file, O_RDONLY ); + if( !tmp ) + return 0; + close( tmp ); + + if( pipe( fds ) != 0 ) + return 0; + +#ifdef _CMAC + sprintf( execline, "atos -o %s 0x%lx 1>&%d", file, (unsigned long)offset, fds[1] ); + printf( "Crash Progress: Executing command: %s\n", execline ); +#else + sprintf( execline, "addr2line -fC -e %s 0x%lx 1>&%d", file, (unsigned long)offset, fds[1] ); +#endif + system( execline ); + + readbytes = read( fds[0], buffer, 1024 ); + if( readbytes + 1 >= maxlen ) + readbytes = maxlen - 1; + close( fds[0] ); + close( fds[1] ); + + //Something went wrong. + if( readbytes < 3 ) + return 0; +#ifdef _CMAC + memcpy( out, buffer, readbytes - 1 ); + out[readbytes] = 0; + return 1; +#else + //??:0 is a bad return value. + if( buffer[0] == '?' ) + return 0; + + if( strstr( buffer, ": No such file" ) > 0 ) + return 0; + + newlinepos = 0; + for( tmp = 0; tmp < readbytes; tmp++ ) + if( buffer[tmp] == '\n' ) break; + newlinepos = tmp; + + if( tmp == readbytes ) + return 0; + + memcpy( demangled, buffer, newlinepos ); + demangled[newlinepos] = 0; + + slashpos = 0; + for( tmp = newlinepos; tmp < readbytes; tmp++ ) + { + if( buffer[tmp] == '/' ) slashpos = tmp; + } + + if( slashpos == 0 ) + slashpos = newlinepos; + slashpos++; + if( slashpos >= readbytes ) + slashpos = 0; + + readbytes -= slashpos; + memcpy( out, buffer + slashpos, readbytes ); + + if( readbytes > 1 ) + out[readbytes-1] = 0; + else + out[readbytes] = 0; + + return readbytes; +#endif + +} + + +int GetBTName( const void * ptr, char * str, int maxlen, struct BacktraceContext * ctx ) +{ + char demangled[1024], floc[1024]; + const char * symbol; + Dl_info dli; + int c = 0; + int useaddr=0; + + c = snprintf(str, maxlen, " [%0*lx]", (int)sizeof(void*)*2, (long unsigned int)ptr ); + + if (dladdr(ptr, &dli)) + { + unsigned offset; + symbol = dli.dli_sname; + + if( dli.dli_fbase && dli.dli_fname ) + { + if( bUseAddr2Line ) + { + unsigned long actualptr = (unsigned long)ptr; + int fnamelen = strlen( dli.dli_fname ); + + //If it's a .so, we need ot check relatively to the start of the .so + //since it was compiled with -fPIC + + if( dli.dli_fname[fnamelen-3] == '.' && + dli.dli_fname[fnamelen-2] == 's' && + dli.dli_fname[fnamelen-1] == 'o' ) + { + actualptr-=(unsigned long)dli.dli_fbase; + } + + if( Addr2Line( floc, demangled, 1024, dli.dli_fname, (void*)actualptr ) ) + { + symbol = demangled; + useaddr=1; + } + } + } + + //If addr2line doesn't work right, we can try using demangle from libiberty + if( !useaddr ) + if( Demangle( demangled, 1024, symbol ) ) + symbol = demangled; + + if( symbol ) + { + offset = ptr - dli.dli_saddr; + c += snprintf(str+c, maxlen-c, " (%s+0x%x (0x%lx))", symbol, offset,(unsigned long)dli.dli_saddr ); + } + if( dli.dli_fbase && dli.dli_fname ) + { + if( useaddr ) + c += snprintf(str+c, maxlen-c, " [%s]", floc ); + else + c += snprintf(str+c, maxlen-c, " [%s+0x%lx]", dli.dli_fname, (unsigned long)dli.dli_fbase ); + } + } + return c; +} + +void SetupDBGHelp() +{ + int fds[2]; + char execline[1024]; + if( DBGSetup ) + return; + DBGSetup = 1; + pipe( fds ); + +#ifdef _CMAC + sprintf( execline, "atos 2>&%d", fds[0] ); +#else + sprintf( execline, "addr2line -v 1>&%d", fds[0] ); +#endif + + if( system( execline ) == 0 ) + bUseAddr2Line = 1; + else + bUseAddr2Line = 0; + close( fds[0] ); + close( fds[1] ); +} + + +#elif defined( _CWINDOWS ) + +int wGetCurrentContext( struct BacktraceContext *CTX ) +{ + CTX->context.ContextFlags = CONTEXT_CONTROL; + CTX->hThread = GetCurrentThread(); + CTX->hProcess = GetCurrentProcess(); +#ifdef CPU_X86 + //no way to do it except in ASM, see below. +#else + if( !RtlCaptureContext( &CTX->context ) ) + { + printf( "Could not launch context helper.\n" ); + return -1; + } +#endif + return 0; +} + +int GetBacktrace( void **buf, size_t size, struct BacktraceContext *CTX ) +{ + const void **pLast = buf + size - 1; + int bFirst = 1; + DWORD MachineType; + CONTEXT * pContext; + HANDLE hThread; + HANDLE hProcess; + struct BacktraceContext MCTX; //in case we don't have a context. + int ActuallyThisThread = 0; + if( CTX == 0 ) + { + if( wGetCurrentContext( &MCTX ) != 0) + return -2; + pContext = &(MCTX.context); + hThread = MCTX.hThread; + hProcess = MCTX.hProcess; + ActuallyThisThread = 1; + } + else + { + pContext = &(CTX->context); + hThread = CTX->hThread; + hProcess = CTX->hProcess; + } + + { + size_t count = 0; + STACKFRAME64 sf64; + +#ifdef CPU_X86 + CONTEXT Context; + MachineType = IMAGE_FILE_MACHINE_I386; + + if( ActuallyThisThread ) + { + ZeroMemory( &Context, sizeof( CONTEXT ) ); + + //http://jpassing.wordpress.com/2008/03/12/walking-the-stack-of-the-current-thread/ + __asm + { + Label: + mov [Context.Ebp], ebp; + mov [Context.Esp], esp; + mov eax, [Label]; + mov [Context.Eip], eax; + } + Context.ContextFlags = CONTEXT_CONTROL; + pContext = &Context; + } + + memset( &sf64, '\0', sizeof sf64 ); + sf64.AddrPC.Offset = Context.Eip; + sf64.AddrPC.Mode = AddrModeFlat; + sf64.AddrFrame.Offset = Context.Ebp; + sf64.AddrFrame.Mode = AddrModeFlat; + sf64.AddrStack.Offset = Context.Esp; + sf64.AddrStack.Segment = AddrModeFlat; +#else + MachineType = IMAGE_FILE_MACHINE_AMD64; + memset( &sf64, '\0', sizeof sf64 ); + sf64.AddrPC.Offset = Context.Rip; + sf64.AddrPC.Mode = AddrModeFlat; + sf64.AddrFrame.Offset = Context.Rsp; + sf64.AddrFrame.Mode = AddrModeFlat; + sf64.AddrStack.Offset = Context.Rsp; + sf64.AddrStack.Segment = AddrModeFlat; +#endif + while( 1 ) + { + int ret; + SetLastError( 0 ); + ret = StackWalk64( MachineType, hProcess, hThread, &sf64, pContext, 0, + SymFunctionTableAccess64, SymGetModuleBase64, 0 ); + + if( !ret ) + { + break; + } + + if( sf64.AddrPC.Offset != 0) + *buf = (void*)sf64.AddrPC.Offset; + else + *buf = (void*)-1; + buf++; + count++; + if( count + 1 >= size ) break; + } + } + SetLastError( 0 ); + *buf = 0; + + return 0; +} + +int GetBTName( const void * ptr, char * str, int maxlen, struct BacktraceContext * ctx ) +{ + char lsymbol[1024], lfile[1024]; + IMAGEHLP_LINE64 Line; + PSYMBOL_INFO Symbol; + HANDLE hProcess; + int i, pwd = 0; + + Symbol = malloc( sizeof( SYMBOL_INFO ) + 501 ); + Line.SizeOfStruct = sizeof( IMAGEHLP_LINE64 ); + + Symbol->MaxNameLen = 500; + + if( ctx ) + hProcess = ctx->hProcess; + else + hProcess = GetCurrentProcess(); + + i = SymFromAddr( hProcess, (DWORD64)ptr, 0, Symbol ); + if( !i ) + { + return _snprintf( str, maxlen, "%p (unknown)", ptr ); + } + i = SymGetLineFromAddr64( hProcess, (DWORD64)ptr, &pwd, &Line ); + + if( i == 0) + { + Line.FileName = 0; + Line.LineNumber = 0; + } + + for( i = 0; i < 1023; i++ ) + { + TCHAR c = Symbol->Name[i]; + lsymbol[i] = (char)c; + if( c < 28 ) break; + } + lsymbol[i] = 0; + + if( Line.FileName ) + { + for( i = 0; i < 1023; i++ ) + { + TCHAR c = Line.FileName[i]; + lfile[i] = (char)c; + if( c < 28 ) break; + } + lfile[i] = 0; + } + + if( Line.FileName ) + return _snprintf( str, maxlen, "%p %s (%s:%d)", ptr, lsymbol, lfile, Line.LineNumber ); + else + return _snprintf( str, maxlen, "%p %s", ptr, lsymbol ); +} + +//Base off of example from http://www.debuginfo.com/example + +void SetupDBGHelp() +{ + int bRet = 0; + static int already_set_up = 0; + DWORD Options; + + if (already_set_up) return; + already_set_up = 1; + + Options = SymGetOptions(); + Options |= SYMOPT_DEBUG; + Options |= SYMOPT_LOAD_LINES; + SymSetOptions( Options ); + + bRet = SymInitialize ( + GetCurrentProcess(), // Process handle of the current process + NULL, // No user-defined search path -> use default + TRUE // Load symbols for all modules in the current process + ); + + if( !bRet ) + { + printf("Error: SymInitialize() failed. Error code: %u \n", GetLastError()); + return; + } + + { + TCHAR pFileName[2048]; + + DWORD64 ModBase; + DWORD64 BaseAddr = 0x10000000; + DWORD FileSize = 0; + + GetModuleFileName( 0, pFileName, 2048 ); + + if( !GetFileSize( pFileName, &FileSize ) ) + return; + + ModBase = SymLoadModule64 ( + GetCurrentProcess(), + NULL, + (PSTR)pFileName, + NULL, + BaseAddr, + FileSize + ); + + if( ModBase == 0 ) + { + printf( "Error: SymLoadModule64() failed. Error code: %u \n" , GetLastError()); + return; + } + } + + + return; +} + +#else +#error Neither _CWINDOWS, _CMAC OR _CLINUX are defined! +#endif + + +/* + * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ Added: Mercury2/src/MercuryBacktrace.h =================================================================== --- Mercury2/src/MercuryBacktrace.h (rev 0) +++ Mercury2/src/MercuryBacktrace.h 2008-12-30 22:10:30 UTC (rev 113) @@ -0,0 +1,39 @@ +#ifndef _HGBACKTRACE_H +#define _HGBACKTRACE_H + +#ifdef __cplusplus +extern "C" { +#endif + +int cnget_backtrace( int SkipFirst, char * buffer, int max_size ); + +#ifdef __cplusplus +}; +#endif + +#endif + +/* + * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ Added: Mercury2/src/MercuryCrash.c =================================================================== --- Mercury2/src/MercuryCrash.c (rev 0) +++ Mercury2/src/MercuryCrash.c 2008-12-30 22:10:30 UTC (rev 113) @@ -0,0 +1,214 @@ +#include "MercuryCrash.h" +#include <stdlib.h> +#include <stdio.h> + +#ifdef WIN32 +#define _CWINDOWS +#else +#if defined( MACOSX ) || defined( __APPLE__ ) +#define _CMAC +#else +#define _CLINUX +#endif +#endif + + + +#if defined( _CLINUX ) || defined( _CMAC ) + +#ifdef _CLINUX + +#ifndef __USE_POSIX +#define __USE_POSIX +#include <signal.h> +#undef__USE_POSIX +#else +#include <signal.h> +#endif + +#include <bits/siginfo.h> + +#else + +#include <signal.h> + +#endif + +int inCrashHandler = 0; + +static int msignals[] = +{ + SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGABRT, + SIGQUIT, SIGSEGV, SIGTRAP, SIGTERM, SIGVTALRM, SIGXCPU, SIGXFSZ, +#if defined(HAVE_DECL_SIGPWR) && HAVE_DECL_SIGPWR + SIGPWR, +#endif +#if defined(HAVE_DECL_SIGUSR1) && HAVE_DECL_SIGUSR1 + SIGUSR1, +#endif + -1 +}; + +static const struct ExceptionLookup { + int code; + const char *name; +} exceptions[]={ + { SIGALRM, "SIGALRM" }, + { SIGBUS, "SIGBUS" }, + { SIGFPE, "SIGFPE" }, + { SIGINT, "SIGINT" }, + { SIGABRT, "SIGABRT" }, + { SIGQUIT, "SIGQUIT" }, + { SIGSEGV, "Segmentation Fault", }, + { SIGTRAP, "SIGTRAP", }, + { SIGTERM, "SIGTERM", }, + { SIGXCPU, "SIGXCPU", }, + { SIGXFSZ, "SIGXFSZ", }, + { 0, "Unknown Exception", }, + { 0 }, +}; + +FNType chHandler; + +static void SigHandler( int signal, siginfo_t *si, void *ucp ) +{ + if( inCrashHandler ) + exit( -1 ); + + inCrashHandler = 1; + + if( chHandler( signal ) == 0x12121212 ) + return; + + inCrashHandler = 0; + if( signal == SIGINT || signal == SIGQUIT ) + { + printf( "Ctrl+Break Hit, Exit.\n" ); + exit( 1 ); + return; + } + + if( signal == SIGTERM || signal == SIGHUP ) + return; + + struct sigaction sa; + sa.sa_flags = 0; + sigemptyset( &sa.sa_mask ); + sa.sa_handler = SIG_DFL; + + struct sigaction old; + sigaction( signal, &sa, &old ); + raise( signal ); + sigaction( signal, &old, NULL ); +} + + +int cnset_execute_on_crash( FNType fn ) +{ + int i; + struct sigaction sa; + chHandler = fn; + + sa.sa_flags = 0; + sa.sa_flags |= SA_NODEFER; + sa.sa_flags |= SA_SIGINFO; + sigemptyset(&sa.sa_mask); + + // Set up our signal handlers. + sa.sa_sigaction = SigHandler; + for( i = 0; msignals[i] != -1; ++i ) + sigaction( msignals[i], &sa, NULL ); + + // Block SIGPIPE, so we get EPIPE. + sa.sa_handler = SIG_IGN; + sigaction( SIGPIPE, &sa, NULL ); + return 0; +} + +#elif defined( _CWINDOWS ) +#include <windows.h> + +FNType top; + +long __stdcall cnException( + struct _EXCEPTION_POINTERS * filter) +{ + int ret = 0; + ret = top( filter->ExceptionRecord->ExceptionCode ); + if( ret == 0x12121212 ) + return EXCEPTION_CONTINUE_EXECUTION; + else + return EXCEPTION_EXECUTE_HANDLER; +} + +int cnset_execute_on_crash( FNType fn ) +{ + top = fn; + SetUnhandledExceptionFilter(cnException); + return 0; +} + +static const struct ExceptionLookup { + DWORD code; + const char *name; +} exceptions[]={ + { EXCEPTION_ACCESS_VIOLATION, "Access Violation" }, + { EXCEPTION_BREAKPOINT, "Breakpoint" }, + { EXCEPTION_FLT_DENORMAL_OPERAND, "FP Denormal Operand" }, + { EXCEPTION_FLT_DIVIDE_BY_ZERO, "FP Divide-by-Zero" }, + { EXCEPTION_FLT_INEXACT_RESULT, "FP Inexact Result" }, + { EXCEPTION_FLT_INVALID_OPERATION, "FP Invalid Operation" }, + { EXCEPTION_FLT_OVERFLOW, "FP Overflow", }, + { EXCEPTION_FLT_STACK_CHECK, "FP Stack Check", }, + { EXCEPTION_FLT_UNDERFLOW, "FP Underflow", }, + { EXCEPTION_INT_DIVIDE_BY_ZERO, "Integer Divide-by-Zero", }, + { EXCEPTION_INT_OVERFLOW, "Integer Overflow", }, + { EXCEPTION_PRIV_INSTRUCTION, "Privileged Instruction", }, + { EXCEPTION_ILLEGAL_INSTRUCTION, "Illegal instruction" }, + { EXCEPTION_INVALID_HANDLE, "Invalid handle" }, + { EXCEPTION_STACK_OVERFLOW, "Stack overflow" }, + { 0xe06d7363, "Unhandled Microsoft C++ Exception", }, + { 0, "UNKNOWN EXCEPTION", }, + { 0 }, +}; + + +#endif + + +const char * cn_get_crash_description( int code ) +{ + int i; + + for( i = 0; exceptions[i].code; ++i ) + if( exceptions[i].code == code ) + return exceptions[i].name; + + return exceptions[i].name; +} + + +/* + * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ Added: Mercury2/src/MercuryCrash.h =================================================================== --- Mercury2/src/MercuryCrash.h (rev 0) +++ Mercury2/src/MercuryCrash.h 2008-12-30 22:10:30 UTC (rev 113) @@ -0,0 +1,44 @@ +#ifndef _HGCRASH_H +#define _HGCRASH_H + +#ifdef __cplusplus +extern "C" { +#endif + +//If you return 0x12121212, it will attempt not to crash. Otherwise, it will just do whatever it feels it should. +typedef int (*FNType)( int signal ); + +int cnset_execute_on_crash( FNType fn ); +const char * cn_get_crash_description( int code ); + +#ifdef __cplusplus +}; +#endif + +#endif + + +/* + * (c) 2003-2008 Glenn Maynard, Steve Checkoway, Avery Lee, Charles Lohr + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons to + * whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF + * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS + * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT + * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2008-12-31 15:02:39
|
Revision: 127 http://hgengine.svn.sourceforge.net/hgengine/?rev=127&view=rev Author: axlecrusher Date: 2008-12-31 15:02:36 +0000 (Wed, 31 Dec 2008) Log Message: ----------- instance models and change m_isLoaded to m_isInstanced, make the factory set the IsInstanced flag Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/HGMDLModel.cpp Mercury2/src/HGMDLModel.h Mercury2/src/MercuryAsset.cpp Mercury2/src/MercuryAsset.h Mercury2/src/Texture.cpp Mercury2/src/Texture.h Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2008-12-31 05:04:06 UTC (rev 126) +++ Mercury2/scenegraph.xml 2008-12-31 15:02:36 UTC (rev 127) @@ -26,4 +26,10 @@ <asset type="hgmdlmodel" file="beerhall.hgmdl"/> </node> </node> + <node type="rotatornode" movz="-2" movx="2" scalex="0.05" scaley="0.05" scalez="0.05" > + <node type="renderablenode"> + <asset type="texture" file="test.bmp"/> + <asset type="hgmdlmodel" file="beerhall.hgmdl"/> + </node> + </node> </SceneGraph> Modified: Mercury2/src/HGMDLModel.cpp =================================================================== --- Mercury2/src/HGMDLModel.cpp 2008-12-31 05:04:06 UTC (rev 126) +++ Mercury2/src/HGMDLModel.cpp 2008-12-31 15:02:36 UTC (rev 127) @@ -2,20 +2,20 @@ REGISTER_ASSET_TYPE(HGMDLModel); +HGMDLModel::HGMDLModel() + :MercuryAsset() +{ +} + +HGMDLModel::~HGMDLModel() +{ + REMOVE_ASSET_INSTANCE(HGMDLModel, m_path); +} + void HGMDLModel::LoadFromXML(const XMLNode& node) { - if ( !node.Attribute("file").empty() ) - { - //FILE* f = fopen( node.Attribute("file").c_str(), "rb" ); - MercuryFile * f = FILEMAN.Open( node.Attribute("file") ); - if( !f ) - { - printf( "Could not open file: \"%s\" for model\n", node.Attribute("file").c_str() ); - return; - } - LoadModel( f ); - delete f; - } + MString path = node.Attribute("file"); + LoadHGMDL( path ); } void HGMDLModel::LoadModel(MercuryFile* hgmdl) @@ -59,8 +59,27 @@ m_meshes[i]->Render(node); } +void HGMDLModel::LoadHGMDL( const MString& path ) +{ + if ( m_isInstanced ) return; + if ( !path.empty() ) + { + ADD_ASSET_INSTANCE(HGMDLModel, path, this); + m_path = path; + MercuryFile * f = FILEMAN.Open( path ); + if( !f ) + { + printf( "Could not open file: \"%s\" for model\n", path.c_str() ); + return; + } + LoadModel( f ); + delete f; + } +} + HGMDLModel* HGMDLModel::Generate() { + printf("new HGMDL\n"); return new HGMDLModel(); } Modified: Mercury2/src/HGMDLModel.h =================================================================== --- Mercury2/src/HGMDLModel.h 2008-12-31 05:04:06 UTC (rev 126) +++ Mercury2/src/HGMDLModel.h 2008-12-31 15:02:36 UTC (rev 127) @@ -10,6 +10,8 @@ class HGMDLModel : public MercuryAsset { public: + HGMDLModel(); + ~HGMDLModel(); virtual void LoadFromXML(const XMLNode& node); @@ -19,6 +21,9 @@ virtual void Render(MercuryNode* node); private: + void LoadHGMDL( const MString& path ); + + MString m_path; std::vector< MAutoPtr< HGMDLMesh > > m_meshes; }; Modified: Mercury2/src/MercuryAsset.cpp =================================================================== --- Mercury2/src/MercuryAsset.cpp 2008-12-31 05:04:06 UTC (rev 126) +++ Mercury2/src/MercuryAsset.cpp 2008-12-31 15:02:36 UTC (rev 127) @@ -1,6 +1,12 @@ #include <MercuryAsset.h> #include <RenderableNode.h> +MercuryAsset::MercuryAsset() + :m_isInstanced(false) +{ +} + + void MercuryAsset::Init(MercuryNode* node) { RenderableNode* rn; @@ -47,6 +53,7 @@ void AssetFactory::AddAssetInstance(const MString& key, MercuryAsset* asset) { + asset->IsInstanced(true); m_assetInstances[key] = asset; } @@ -54,7 +61,10 @@ { std::map<MString, MercuryAsset*>::iterator asset = m_assetInstances.find(key); if ( asset != m_assetInstances.end() ) + { m_assetInstances.erase( asset ); + printf("removed asset %s\n", key.c_str()); + } } std::map<MString, MercuryAsset*> AssetFactory::m_assetInstances; Modified: Mercury2/src/MercuryAsset.h =================================================================== --- Mercury2/src/MercuryAsset.h 2008-12-31 05:04:06 UTC (rev 126) +++ Mercury2/src/MercuryAsset.h 2008-12-31 15:02:36 UTC (rev 127) @@ -9,6 +9,7 @@ class MercuryAsset : public RefBase { public: + MercuryAsset(); virtual ~MercuryAsset() {}; virtual void Init(MercuryNode* node); @@ -19,6 +20,10 @@ ///Loads an asset from an XMLAsset representing itself virtual void LoadFromXML(const XMLNode& node) {}; + + inline void IsInstanced(bool b) { m_isInstanced = b; } + protected: + bool m_isInstanced; }; class AssetFactory Modified: Mercury2/src/Texture.cpp =================================================================== --- Mercury2/src/Texture.cpp 2008-12-31 05:04:06 UTC (rev 126) +++ Mercury2/src/Texture.cpp 2008-12-31 15:02:36 UTC (rev 127) @@ -12,7 +12,7 @@ REGISTER_ASSET_TYPE(Texture); Texture::Texture() - :m_raw(NULL),m_textureID(0),m_isLoaded(false) + :MercuryAsset(), m_raw(NULL),m_textureID(0) { if (!m_initTextureSuccess) { @@ -94,7 +94,6 @@ void Texture::LoadFromXML(const XMLNode& node) { - if (m_isLoaded) return; LoadImage( node.Attribute("file") ); } @@ -121,11 +120,11 @@ void Texture::LoadImage(const MString& path) { + if (m_isInstanced) return; if ( !path.empty() ) { - m_isLoaded = true; + ADD_ASSET_INSTANCE(Texture, path, this); m_filename = path; - ADD_ASSET_INSTANCE(Texture, m_filename, this); RawImageData* d = ImageLoader::GetInstance().LoadImage( m_filename ); if (d) LoadFromRaw( d ); } Modified: Mercury2/src/Texture.h =================================================================== --- Mercury2/src/Texture.h 2008-12-31 05:04:06 UTC (rev 126) +++ Mercury2/src/Texture.h 2008-12-31 15:02:36 UTC (rev 127) @@ -37,7 +37,6 @@ static unsigned short m_activeTextures; MString m_filename; - bool m_isLoaded; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-01 16:19:13
|
Revision: 151 http://hgengine.svn.sourceforge.net/hgengine/?rev=151&view=rev Author: axlecrusher Date: 2009-03-01 16:19:05 +0000 (Sun, 01 Mar 2009) Log Message: ----------- Update HGMDL with oriented bounding box as an extra data element for meshes Modified Paths: -------------- Mercury2/beerhall.hgmdl Mercury2/docs/MercuryBinaryModelFormat.odt Mercury2/mercury2.kdevelop Mercury2/scenegraph.xml Mercury2/src/HGMDLMesh.cpp Mercury2/src/HGMDLMesh.h Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp Modified: Mercury2/beerhall.hgmdl =================================================================== (Binary files differ) Modified: Mercury2/docs/MercuryBinaryModelFormat.odt =================================================================== (Binary files differ) Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2009-01-22 16:28:56 UTC (rev 150) +++ Mercury2/mercury2.kdevelop 2009-03-01 16:19:05 UTC (rev 151) @@ -2,7 +2,7 @@ <kdevelop> <general> <author>Joshua Allen</author> - <email></email> + <email/> <version>2.0</version> <projectmanagement>KDevAutoProject</projectmanagement> <primarylanguage>C++</primarylanguage> @@ -14,8 +14,8 @@ <projectname>Mercury2</projectname> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description></description> - <defaultencoding></defaultencoding> + <description/> + <defaultencoding/> <versioncontrol/> </general> <kdevautoproject> @@ -26,8 +26,8 @@ <run> <mainprogram>/home/josh/Mercury2/debug/src/mercury2</mainprogram> <terminal>false</terminal> - <programargs></programargs> - <globaldebugarguments></globaldebugarguments> + <programargs/> + <globaldebugarguments/> <globalcwd>/home/josh/Mercury2</globalcwd> <useglobalprogram>true</useglobalprogram> <autocompile>false</autocompile> @@ -43,15 +43,15 @@ <f77compiler>kdevg77options</f77compiler> <cxxflags>-O2 -g -Wall</cxxflags> <envvars/> - <configargs></configargs> - <topsourcedir></topsourcedir> + <configargs/> + <topsourcedir/> <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -DUSE_SSE</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> - <ccompilerbinary></ccompilerbinary> - <cxxcompilerbinary></cxxcompilerbinary> - <f77compilerbinary></f77compilerbinary> + <ccompilerbinary/> + <cxxcompilerbinary/> + <f77compilerbinary/> <cflags>-O2 -g -Wall</cflags> - <f77flags></f77flags> + <f77flags/> </optimized> <debug> <configargs>--enable-debug=full</configargs> @@ -61,14 +61,14 @@ <f77compiler>kdevg77options</f77compiler> <cxxflags>-O2 -g -Wall</cxxflags> <envvars/> - <topsourcedir></topsourcedir> + <topsourcedir/> <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -DUSE_SSE</cppflags> <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> - <ccompilerbinary></ccompilerbinary> - <cxxcompilerbinary></cxxcompilerbinary> - <f77compilerbinary></f77compilerbinary> + <ccompilerbinary/> + <cxxcompilerbinary/> + <f77compilerbinary/> <cflags>-O2 -g -Wall</cflags> - <f77flags></f77flags> + <f77flags/> </debug> <default> <envvars/> @@ -222,7 +222,7 @@ <includePaths>.;</includePaths> </codecompletion> <creategettersetter> - <prefixGet></prefixGet> + <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> @@ -243,11 +243,11 @@ </cppsupportpart> <kdevdebugger> <general> - <gdbpath></gdbpath> + <gdbpath/> <dbgshell>libtool</dbgshell> - <configGdbScript></configGdbScript> - <runShellScript></runShellScript> - <runGdbScript></runGdbScript> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-01-22 16:28:56 UTC (rev 150) +++ Mercury2/scenegraph.xml 2009-03-01 16:19:05 UTC (rev 151) @@ -20,13 +20,13 @@ <asset type="quad"/> </node> </node> - <node type="rotatornode" movz="-2" scalex="0.05" scaley="0.05" scalez="0.05" > + <node type="rotatornode" movz="-2" scalex="0.25" scaley="0.25" scalez="0.25" > <node type="renderablenode"> <asset type="texture" file="test.bmp"/> <asset type="hgmdlmodel" file="beerhall.hgmdl"/> </node> </node> - <node type="rotatornode" movz="-2" movx="2" scalex="0.05" scaley="0.05" scalez="0.05" > + <node type="rotatornode" movz="-2" movx="2" scalex="0.25" scaley="0.25" scalez="0.25" > <node type="renderablenode"> <asset type="texture" file="test.bmp"/> <asset type="hgmdlmodel" file="beerhall.hgmdl"/> Modified: Mercury2/src/HGMDLMesh.cpp =================================================================== --- Mercury2/src/HGMDLMesh.cpp 2009-01-22 16:28:56 UTC (rev 150) +++ Mercury2/src/HGMDLMesh.cpp 2009-03-01 16:19:05 UTC (rev 151) @@ -38,8 +38,28 @@ //fread(m_indexData.Buffer(), numIndices*sizeof(uint16_t), 1, hgmdl); hgmdl->Read( m_indexData.Buffer(), numIndices*sizeof(uint16_t) ); } + + uint32_t extraDataCount; + hgmdl->Read( &extraDataCount, sizeof( uint32_t ) ); + printf("has %d extras\n", extraDataCount); + for (uint32_t i = 0; i < extraDataCount; ++i) + { + ReadExtraData(hgmdl); + } } +void HGMDLMesh::ReadExtraData(MercuryFile* hgmdl) +{ + uint32_t type, length; + char* data = NULL; + hgmdl->Read( &type, sizeof(char)*4 ); + hgmdl->Read( &length, sizeof(uint32_t) ); + + data = new char[length]; + hgmdl->Read( data, length ); + delete data; +} + /**************************************************************************** * Copyright (C) 2008 by Joshua Allen * * * Modified: Mercury2/src/HGMDLMesh.h =================================================================== --- Mercury2/src/HGMDLMesh.h 2009-01-22 16:28:56 UTC (rev 150) +++ Mercury2/src/HGMDLMesh.h 2009-03-01 16:19:05 UTC (rev 151) @@ -8,6 +8,7 @@ { public: void LoadFromFile(MercuryFile* hgmdl); + void ReadExtraData(MercuryFile* hgmdl); private: MString m_name; bool m_cachable; Modified: Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp =================================================================== --- Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2009-01-22 16:28:56 UTC (rev 150) +++ Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2009-03-01 16:19:05 UTC (rev 151) @@ -4,13 +4,19 @@ #include <stdint.h> #include <MercuryPoint.h> #include <map> +#include <math.h> using namespace std; +float min(float x, float y) { return x<y?x:y; } +float max(float x, float y) { return x>y?x:y; } + vector< MercuryPoint > v; vector< MercuryPoint > vt; vector< MercuryPoint > vn; +float minX, maxX, minY, maxY, minZ, maxZ; + struct Vertex { MercuryPoint uv; @@ -25,25 +31,7 @@ vector< Vertex > vertice; vector< uint16_t > indice; -/* -struct Mesh -{ - uint32_t nameLength; - char* name; - bool bCache; - - //Mercury2 imposes a limit of 65535 vertice in one VBO mesh - uint32_t vertexDataLength; //in bytes - char* vertexData; - - //Mercury2 imposes a limit of 65535 indices in one VBO mesh - uint16_t numberOfIndices; - uint16_t* indices; -}; - -Mesh currentMesh; -*/ void LineParser(const string &line) { if (line.empty()) return; @@ -53,6 +41,14 @@ MercuryPoint tv; sscanf(line.c_str(), "v %f %f %f", &tv.x, &tv.y, &tv.z); v.push_back(tv); + + minX = min(minX, tv.x); + minY = min(minY, tv.y); + minZ = min(minZ, tv.z); + + maxX = max(maxX, tv.x); + maxY = max(maxY, tv.y); + maxZ = max(maxZ, tv.z); } else if (token == "vt") { @@ -110,6 +106,27 @@ } } +void WriteOBB(FILE *mbmf) +{ + char type[] = "OBB "; + fwrite(type, sizeof(char)*4, 1, mbmf); + + uint32_t tmp32 = sizeof(float)*6; fwrite(&tmp32, sizeof(uint32_t), 1, mbmf); + float tmp[3]; + + //center + tmp[0] = (maxX-minX)/2.0f; + tmp[1] = (maxY-minY)/2.0f; + tmp[2] = (maxZ-minZ)/2.0f; + fwrite(tmp, sizeof(float)*3, 1, mbmf); + + //extends + tmp[0] = fabs(tmp[0]); + tmp[1] = fabs(tmp[1]); + tmp[2] = fabs(tmp[2]); + fwrite(tmp, sizeof(float)*3, 1, mbmf); +} + void WriteMBMF( FILE *mbmf ) { uint32_t tmp32; @@ -140,6 +157,9 @@ tmp16 = indice.size(); fwrite(&tmp16, sizeof(uint16_t), 1, mbmf); for (uint16_t i = 0; i < indice.size(); ++i) fwrite(&indice[i], sizeof(uint16_t), 1, mbmf); + + tmp32 = 1; fwrite(&tmp32, sizeof(uint32_t), 1, mbmf); + WriteOBB(mbmf); } tmp32 = 0; @@ -159,13 +179,19 @@ mbmf = fopen(argv[2], "wb"); string line; + + minX = minY = minZ = 1000000.0f; + maxX = maxY = maxZ = -1000000.0f; - while ( getline(obj, line) ) { if (line.length() > 0) LineParser(line); } + printf("%f %f %f\n", minX, maxX, (maxX-minX)/2.0f ); + printf("%f %f %f\n", minY, maxY, (maxY-minY)/2.0f ); + printf("%f %f %f\n", minZ, maxZ, (maxZ-minZ)/2.0f ); + WriteMBMF( mbmf ); fclose( mbmf ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-01 20:22:13
|
Revision: 152 http://hgengine.svn.sourceforge.net/hgengine/?rev=152&view=rev Author: axlecrusher Date: 2009-03-01 19:49:51 +0000 (Sun, 01 Mar 2009) Log Message: ----------- show bounding boxes Modified Paths: -------------- Mercury2/src/HGMDLMesh.cpp Mercury2/src/HGMDLMesh.h Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp Modified: Mercury2/src/HGMDLMesh.cpp =================================================================== --- Mercury2/src/HGMDLMesh.cpp 2009-03-01 16:19:05 UTC (rev 151) +++ Mercury2/src/HGMDLMesh.cpp 2009-03-01 19:49:51 UTC (rev 152) @@ -1,5 +1,15 @@ #include <HGMDLMesh.h> +HGMDLMesh::HGMDLMesh() + :MercuryVBO(), m_boundingBox(NULL) +{ +} + +HGMDLMesh::~HGMDLMesh() +{ + SAFE_DELETE(m_boundingBox); +} + void HGMDLMesh::LoadFromFile(MercuryFile* hgmdl) { uint32_t nameLength; @@ -50,16 +60,154 @@ void HGMDLMesh::ReadExtraData(MercuryFile* hgmdl) { - uint32_t type, length; + uint32_t type; + hgmdl->Read( &type, sizeof(char)*4 ); + + switch( type ) + { + case 541213263: + { + LoadOBB(hgmdl); + break; + } + default: + { + printf("Junk extra type '%x'\n", type); + //read and discard as junk + uint32_t length; + hgmdl->Read( &length, sizeof(uint32_t) ); + if ( length > 0 ) + { + char* data = new char[length]; + hgmdl->Read( data, length ); + SAFE_DELETE_ARRAY(data); + } + break; + } + } +} + +void HGMDLMesh::LoadOBB(MercuryFile* hgmdl) +{ + uint32_t length; char* data = NULL; - hgmdl->Read( &type, sizeof(char)*4 ); + hgmdl->Read( &length, sizeof(uint32_t) ); + if (length > 0) + { + data = new char[length]; + hgmdl->Read( data, length ); + + m_boundingBox = new OBB(); + m_boundingBox->LoadFromBinary( data ); + } + + SAFE_DELETE_ARRAY(data); +} + +void OBB::LoadFromBinary(char* data) +{ + memcpy(center, data, sizeof(float)*3); + memcpy(extend, data, sizeof(float)*3); +} + +#include <GL/gl.h> +#include <GL/glext.h> + +void OBB::Render(MercuryNode* node) +{ + glPushAttrib( GL_CURRENT_BIT ); + glBegin(GL_LINES); + glColor3f(0,1.0f,0); + + //front + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + + //back + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + + //top + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + + //bottom + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + +/* + glBegin(GL_QUADS); + //front + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); - data = new char[length]; - hgmdl->Read( data, length ); - delete data; + //back + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + + //left side + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + + //right side + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + + //top + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + + //bottom + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); +*/ + glEnd(); + + glPointSize(4); + glBegin(GL_POINTS); + glVertex3f(center[0], center[1], center[2]); + glEnd(); + + glPopAttrib( ); } +void HGMDLMesh::Render(MercuryNode* node) +{ + MercuryVBO::Render(node); + + if (m_boundingBox) + m_boundingBox->Render(node); +} + /**************************************************************************** * Copyright (C) 2008 by Joshua Allen * * * Modified: Mercury2/src/HGMDLMesh.h =================================================================== --- Mercury2/src/HGMDLMesh.h 2009-03-01 16:19:05 UTC (rev 151) +++ Mercury2/src/HGMDLMesh.h 2009-03-01 19:49:51 UTC (rev 152) @@ -4,14 +4,33 @@ #include <MercuryVBO.h> #include <MercuryFile.h> +class OBB : public MercuryAsset +{ + public: + void LoadFromBinary(char* data); + + virtual void Render(MercuryNode* node); + + float center[3]; + float extend[3]; +}; + class HGMDLMesh : public MercuryVBO { public: + HGMDLMesh(); + ~HGMDLMesh(); void LoadFromFile(MercuryFile* hgmdl); void ReadExtraData(MercuryFile* hgmdl); + void LoadOBB(MercuryFile* hgmdl); + + virtual void Render(MercuryNode* node); + private: MString m_name; bool m_cachable; + + OBB* m_boundingBox; }; #endif Modified: Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp =================================================================== --- Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2009-03-01 16:19:05 UTC (rev 151) +++ Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2009-03-01 19:49:51 UTC (rev 152) @@ -188,9 +188,9 @@ if (line.length() > 0) LineParser(line); } - printf("%f %f %f\n", minX, maxX, (maxX-minX)/2.0f ); - printf("%f %f %f\n", minY, maxY, (maxY-minY)/2.0f ); - printf("%f %f %f\n", minZ, maxZ, (maxZ-minZ)/2.0f ); + printf("X min:%f max:%f %f\n", minX, maxX, (maxX-minX)/2.0f ); + printf("Y min:%f max:%f %f\n", minY, maxY, (maxY-minY)/2.0f ); + printf("Z min:%f max:%f %f\n", minZ, maxZ, (maxZ-minZ)/2.0f ); WriteMBMF( mbmf ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-01 21:10:19
|
Revision: 156 http://hgengine.svn.sourceforge.net/hgengine/?rev=156&view=rev Author: axlecrusher Date: 2009-03-01 21:10:09 +0000 (Sun, 01 Mar 2009) Log Message: ----------- Clean up bounding box Modified Paths: -------------- Mercury2/beerhall.hgmdl Mercury2/scenegraph.xml Mercury2/src/HGMDLMesh.cpp Mercury2/src/HGMDLMesh.h Mercury2/src/MercuryVBO.cpp Mercury2/src/MercuryVBO.h Added Paths: ----------- Mercury2/src/BoundingBox.cpp Mercury2/src/BoundingBox.h Modified: Mercury2/beerhall.hgmdl =================================================================== (Binary files differ) Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-03-01 20:22:29 UTC (rev 155) +++ Mercury2/scenegraph.xml 2009-03-01 21:10:09 UTC (rev 156) @@ -28,8 +28,8 @@ </node> <node type="rotatornode" movz="-2" movx="2" scalex="0.25" scaley="0.25" scalez="0.25" > <node type="renderablenode"> - <asset type="texture" file="test.bmp"/> - <asset type="hgmdlmodel" file="beerhall.hgmdl"/> + <asset type="texture" file="gunther.png"/> + <asset type="hgmdlmodel" file="gunther.hgmdl"/> </node> </node> </SceneGraph> Added: Mercury2/src/BoundingBox.cpp =================================================================== --- Mercury2/src/BoundingBox.cpp (rev 0) +++ Mercury2/src/BoundingBox.cpp 2009-03-01 21:10:09 UTC (rev 156) @@ -0,0 +1,97 @@ +#include <GL/gl.h> +#include <GL/glext.h> +#include <BoundingBox.h> + +void BoundingBox::LoadFromBinary(char* data) +{ + memcpy(m_center, data, sizeof(float)*3); + memcpy(m_extend, data+(sizeof(float)*3), sizeof(float)*3); +} + +RenderableBoundingBox::RenderableBoundingBox(const BoundingBox* bb) + :MercuryAsset(), m_bb(bb) +{ +} + +void RenderableBoundingBox::Render(MercuryNode* node) +{ + const float* center = m_bb->GetCenter(); + const float* extend = m_bb->GetExtend(); + + glPushAttrib( GL_CURRENT_BIT ); + glBegin(GL_LINES); + glColor3f(0,1.0f,0); + + //front + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + + //back + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + + //top + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); + + //bottom + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); + glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); + + glEnd(); + + glPointSize(4); + glBegin(GL_POINTS); + glVertex3f(center[0], center[1], center[2]); + glEnd(); + + glPopAttrib( ); +} + +/**************************************************************************** + * 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 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/BoundingBox.h =================================================================== --- Mercury2/src/BoundingBox.h (rev 0) +++ Mercury2/src/BoundingBox.h 2009-03-01 21:10:09 UTC (rev 156) @@ -0,0 +1,59 @@ +#ifndef BOUNDINGBOX_H +#define BOUNDINGBOX_H + +#include <MercuryAsset.h> + +class BoundingBox +{ + public: + void LoadFromBinary(char* data); + inline const float* GetCenter() const { return m_center; } + inline const float* GetExtend() const { return m_extend; } + private: + float m_center[3]; + float m_extend[3]; +}; + +class RenderableBoundingBox : public MercuryAsset +{ + public: + RenderableBoundingBox(const BoundingBox* bb); + virtual void Render(MercuryNode* node); + + private: + const BoundingBox* m_bb; +}; + +#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 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/HGMDLMesh.cpp =================================================================== --- Mercury2/src/HGMDLMesh.cpp 2009-03-01 20:22:29 UTC (rev 155) +++ Mercury2/src/HGMDLMesh.cpp 2009-03-01 21:10:09 UTC (rev 156) @@ -1,15 +1,5 @@ #include <HGMDLMesh.h> -HGMDLMesh::HGMDLMesh() - :MercuryVBO(), m_boundingBox(NULL) -{ -} - -HGMDLMesh::~HGMDLMesh() -{ - SAFE_DELETE(m_boundingBox); -} - void HGMDLMesh::LoadFromFile(MercuryFile* hgmdl) { uint32_t nameLength; @@ -98,117 +88,14 @@ data = new char[length]; hgmdl->Read( data, length ); - m_boundingBox = new OBB(); + m_boundingBox = new BoundingBox(); m_boundingBox->LoadFromBinary( data ); } SAFE_DELETE_ARRAY(data); } -void OBB::LoadFromBinary(char* data) -{ - memcpy(center, data, sizeof(float)*3); - memcpy(extend, data+(sizeof(float)*3), sizeof(float)*3); -} -#include <GL/gl.h> -#include <GL/glext.h> - -void OBB::Render(MercuryNode* node) -{ - glPushAttrib( GL_CURRENT_BIT ); - glBegin(GL_LINES); - glColor3f(0,1.0f,0); - - //front - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); - - //back - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); - - //top - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); - - //bottom - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); - - glEnd(); -/* - glBegin(GL_QUADS); - //front - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); - - //back - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); - - //left side - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); - - //right side - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); - - //top - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]-extend[2]); - glVertex3f(center[0]-extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]+extend[2]); - glVertex3f(center[0]+extend[0], center[1]+extend[1], center[2]-extend[2]); - - //bottom - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]-extend[2]); - glVertex3f(center[0]+extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]+extend[2]); - glVertex3f(center[0]-extend[0], center[1]-extend[1], center[2]-extend[2]); - - glEnd(); -*/ - glPointSize(4); - glBegin(GL_POINTS); - glVertex3f(center[0], center[1], center[2]); - glEnd(); - - glPopAttrib( ); -} - -void HGMDLMesh::Render(MercuryNode* node) -{ - MercuryVBO::Render(node); - - if (m_boundingBox) - m_boundingBox->Render(node); -} - /**************************************************************************** * Copyright (C) 2008 by Joshua Allen * * * Modified: Mercury2/src/HGMDLMesh.h =================================================================== --- Mercury2/src/HGMDLMesh.h 2009-03-01 20:22:29 UTC (rev 155) +++ Mercury2/src/HGMDLMesh.h 2009-03-01 21:10:09 UTC (rev 156) @@ -4,33 +4,16 @@ #include <MercuryVBO.h> #include <MercuryFile.h> -class OBB : public MercuryAsset -{ - public: - void LoadFromBinary(char* data); - - virtual void Render(MercuryNode* node); - - float center[3]; - float extend[3]; -}; - class HGMDLMesh : public MercuryVBO { public: - HGMDLMesh(); - ~HGMDLMesh(); void LoadFromFile(MercuryFile* hgmdl); void ReadExtraData(MercuryFile* hgmdl); void LoadOBB(MercuryFile* hgmdl); - - virtual void Render(MercuryNode* node); private: MString m_name; bool m_cachable; - - OBB* m_boundingBox; }; #endif Modified: Mercury2/src/MercuryVBO.cpp =================================================================== --- Mercury2/src/MercuryVBO.cpp 2009-03-01 20:22:29 UTC (rev 155) +++ Mercury2/src/MercuryVBO.cpp 2009-03-01 21:10:09 UTC (rev 156) @@ -10,7 +10,7 @@ #define BUFFER_OFFSET(i) ((char*)NULL + (i)) MercuryVBO::MercuryVBO() - :MercuryAsset(), m_initiated(false) + :MercuryAsset(), m_initiated(false), m_boundingBox(NULL) { m_bufferIDs[0] = m_bufferIDs[1] = 0; } @@ -19,6 +19,7 @@ { if (m_bufferIDs[0]) glDeleteBuffersARB(2, m_bufferIDs); m_bufferIDs[0] = m_bufferIDs[1] = 0; + SAFE_DELETE(m_boundingBox); } void MercuryVBO::Render(MercuryNode* node) @@ -51,6 +52,12 @@ glDrawRangeElements(GL_TRIANGLES, 0, m_indexData.Length()-1, m_indexData.Length(), GL_UNSIGNED_SHORT, NULL); m_lastVBOrendered = this; + + if (m_boundingBox) + { + RenderableBoundingBox rbb(m_boundingBox); + rbb.Render(node); + } } void MercuryVBO::InitVBO() Modified: Mercury2/src/MercuryVBO.h =================================================================== --- Mercury2/src/MercuryVBO.h 2009-03-01 20:22:29 UTC (rev 155) +++ Mercury2/src/MercuryVBO.h 2009-03-01 21:10:09 UTC (rev 156) @@ -3,6 +3,7 @@ #include <MercuryAsset.h> #include <AlignedBuffer.h> +#include <BoundingBox.h> class MercuryVBO : public MercuryAsset { @@ -25,6 +26,7 @@ protected: AlignedBuffer<float> m_vertexData; AlignedBuffer<uint16_t> m_indexData; + BoundingBox* m_boundingBox; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-02 01:59:33
|
Revision: 157 http://hgengine.svn.sourceforge.net/hgengine/?rev=157&view=rev Author: axlecrusher Date: 2009-03-02 01:59:30 +0000 (Mon, 02 Mar 2009) Log Message: ----------- fixing up frustum, preparing for culling Modified Paths: -------------- Mercury2/beerhall.hgmdl Mercury2/docs/MercuryBinaryModelFormat.odt Mercury2/mercury2.kdevelop Mercury2/src/HGMDLModel.cpp Mercury2/src/MercuryUtil.cpp Mercury2/src/MercuryUtil.h Mercury2/src/Viewport.cpp Mercury2/src/Viewport.h Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp Added Paths: ----------- Mercury2/src/MercuryVertex.cpp Mercury2/src/MercuryVertex.h Modified: Mercury2/beerhall.hgmdl =================================================================== (Binary files differ) Modified: Mercury2/docs/MercuryBinaryModelFormat.odt =================================================================== (Binary files differ) Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2009-03-01 21:10:09 UTC (rev 156) +++ Mercury2/mercury2.kdevelop 2009-03-02 01:59:30 UTC (rev 157) @@ -2,7 +2,7 @@ <kdevelop> <general> <author>Joshua Allen</author> - <email/> + <email></email> <version>2.0</version> <projectmanagement>KDevAutoProject</projectmanagement> <primarylanguage>C++</primarylanguage> @@ -14,8 +14,8 @@ <projectname>Mercury2</projectname> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description/> - <defaultencoding/> + <description></description> + <defaultencoding></defaultencoding> <versioncontrol/> </general> <kdevautoproject> @@ -222,7 +222,7 @@ <includePaths>.;</includePaths> </codecompletion> <creategettersetter> - <prefixGet/> + <prefixGet></prefixGet> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> @@ -243,11 +243,11 @@ </cppsupportpart> <kdevdebugger> <general> - <gdbpath/> + <gdbpath></gdbpath> <dbgshell>libtool</dbgshell> - <configGdbScript/> - <runShellScript/> - <runGdbScript/> + <configGdbScript></configGdbScript> + <runShellScript></runShellScript> + <runGdbScript></runGdbScript> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> Modified: Mercury2/src/HGMDLModel.cpp =================================================================== --- Mercury2/src/HGMDLModel.cpp 2009-03-01 21:10:09 UTC (rev 156) +++ Mercury2/src/HGMDLModel.cpp 2009-03-02 01:59:30 UTC (rev 157) @@ -2,6 +2,9 @@ REGISTER_ASSET_TYPE(HGMDLModel); +const uint16_t EXPCTMJRV = 2; +const uint16_t EXPCTMNRV = 3; + HGMDLModel::HGMDLModel() :MercuryAsset() { @@ -32,13 +35,15 @@ return; } - uint32_t version; - //fread(&version, 4, 1, hgmdl); - hgmdl->Read( &version, 4 ); + uint16_t majorVersion; + uint16_t minorVersion; - if (version != 200) + hgmdl->Read( &majorVersion, 2 ); + hgmdl->Read( &minorVersion, 2 ); + + if ((majorVersion != EXPCTMJRV) || (minorVersion != EXPCTMNRV)) { - printf("Invalid HGMDL version %d\n", version); + printf("Can only read HGMDL version %d.%d, this file is %d.%d\n", EXPCTMJRV,EXPCTMNRV,majorVersion,minorVersion); return; } Modified: Mercury2/src/MercuryUtil.cpp =================================================================== --- Mercury2/src/MercuryUtil.cpp 2009-03-01 21:10:09 UTC (rev 156) +++ Mercury2/src/MercuryUtil.cpp 2009-03-02 01:59:30 UTC (rev 157) @@ -66,7 +66,6 @@ return length; } - /*************************************************************************** * Copyright (C) 2008 by Joshua Allen * * * Modified: Mercury2/src/MercuryUtil.h =================================================================== --- Mercury2/src/MercuryUtil.h 2009-03-01 21:10:09 UTC (rev 156) +++ Mercury2/src/MercuryUtil.h 2009-03-02 01:59:30 UTC (rev 157) @@ -31,6 +31,18 @@ float StrToFloat(const MString & s); +template<typename T> +const T& max(const T& t1, const T& t2) +{ + return t1>t2?t1:t2; +} + +template<typename T> +const T& min(const T& t1, const T& t2) +{ + return t1<t2?t1:t2; +} + //This counter is used with singletons to //ensure proper destruction order of the //singleton Added: Mercury2/src/MercuryVertex.cpp =================================================================== --- Mercury2/src/MercuryVertex.cpp (rev 0) +++ Mercury2/src/MercuryVertex.cpp 2009-03-02 01:59:30 UTC (rev 157) @@ -0,0 +1,120 @@ +#include <MercuryVertex.h> +#include <MercuryUtil.h> +#include <MercuryMath.h> + +MercuryVertex::MercuryVertex() +{ + m_xyz[0] = m_xyz[1] = m_xyz[2] = 0; +} + +MercuryVertex::MercuryVertex( float ix, float iy, float iz ) +{ + m_xyz[0] = ix; + m_xyz[1] = iy; + m_xyz[2] = iz; +} + +MercuryVertex::MercuryVertex( const float * in ) +{ + for (unsigned int i = 0; i < 3; ++i) + m_xyz[i] *= in[i]; +} + +void MercuryVertex::NormalizeSelf() +{ + float imag = 1.0f/Length(); + for (unsigned int i = 0; i < 3; ++i) + m_xyz[i] *= imag; +} + +MercuryVertex MercuryVertex::Normalize() const +{ + MercuryVertex r(*this); + r.NormalizeSelf(); + return r; +} + +float MercuryVertex::Length() const +{ + float length = m_xyz[0]*m_xyz[0]; + length += m_xyz[1]*m_xyz[1]; + length += m_xyz[2]*m_xyz[2]; + return SQRT(length); +} + +float MercuryVertex::GetBiggestElement() const +{ + float tmp = m_xyz[0]; + tmp = max<float>(tmp, m_xyz[1]); + return max<float>(tmp, m_xyz[2]); +} + +const MercuryVertex& MercuryVertex::operator *= (const MercuryVertex& p) +{ + for (unsigned int i = 0; i < 3; ++i) + m_xyz[i] *= p.m_xyz[i]; + return *this; +} + +const MercuryVertex& MercuryVertex::operator /= (const MercuryVertex& p) +{ + for (unsigned int i = 0; i < 3; ++i) + m_xyz[i] /= p.m_xyz[i]; + return *this; +} + +bool MercuryVertex::operator==(const MercuryVertex& p) const +{ + for (unsigned int i = 0; i < 3; ++i) + if (m_xyz[i] != p.m_xyz[i]) return false; + return true; +} + +bool MercuryVertex::operator==(const float f) const +{ + for (unsigned int i = 0; i < 3; ++i) + if (m_xyz[i] != f) return false; + return true; +} + +MercuryVertex MercuryVertex::CrossProduct(const MercuryVertex& p) const +{ + MercuryVertex ret; + ret.m_xyz[0] = m_xyz[1]*p.m_xyz[2] - m_xyz[2]*p.m_xyz[1]; + ret.m_xyz[1] = m_xyz[2]*p.m_xyz[0] - m_xyz[0]*p.m_xyz[2]; + ret.m_xyz[2] = m_xyz[0]*p.m_xyz[1] - m_xyz[1]*p.m_xyz[0]; + return ret; +} + + +/**************************************************************************** + * 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/MercuryVertex.h =================================================================== --- Mercury2/src/MercuryVertex.h (rev 0) +++ Mercury2/src/MercuryVertex.h 2009-03-02 01:59:30 UTC (rev 157) @@ -0,0 +1,101 @@ +#ifndef MERCURYVECTOR_H +#define MERCURYVECTOR_H + +class MercuryVertex +{ + public: + MercuryVertex(); + MercuryVertex( float ix, float iy, float iz ); + MercuryVertex( const float * in ); + + ///Direct conversion to float* + operator float* () { return m_xyz; } + ///Direct conversion to const float* + operator const float* () const { return m_xyz; } + + inline const float GetX() const { return m_xyz[0]; } + inline const float GetY() const { return m_xyz[1]; } + inline const float GetZ() const { return m_xyz[2]; } + inline void SetX(const float ix) { m_xyz[0] = ix; } + inline void SetY(const float iy) { m_xyz[1] = iy; } + inline void SetZ(const float iz) { m_xyz[2] = iz; } + + inline void Zero() { m_xyz[0] = 0; m_xyz[1] = 0; m_xyz[2] = 0; } + + ///Normalize (make |point| = 1) + void NormalizeSelf(); + ///Return a normalized point + MercuryVertex Normalize() const; + ///Return the length of |this| + float Length() const; + + float GetBiggestElement() const; + + ///Write out to be = to this point + inline void ConvertToVector3( float* out ) const { out[0] = m_xyz[0]; out[1] = m_xyz[1]; out[2] = m_xyz[2]; } + ///Write out to be = to this point, however the 4th element will be 0 + inline void ConvertToVector4( float* out ) const { out[0] = m_xyz[0]; out[1] = m_xyz[1]; out[2] = m_xyz[2]; out[3] = 0; } + ///Write out to be = - to this point, however the 4th element will be 0 + inline void ConvertToIVector4( float* out ) const { out[0] = -m_xyz[0]; out[1] = -m_xyz[1]; out[2] = -m_xyz[2]; out[3] = 0; } + + const MercuryVertex& operator *= (const MercuryVertex& p); + const MercuryVertex& operator /= (const MercuryVertex& p); + inline MercuryVertex operator * (const MercuryVertex& p) const { MercuryVertex r(*this); r*=p; return r; } + inline MercuryVertex operator / (const MercuryVertex& p) const { MercuryVertex r(*this); r/=p; return r; } + + inline MercuryVertex& operator += ( const MercuryVertex& other ) { m_xyz[0]+=other.m_xyz[0]; m_xyz[1]+=other.m_xyz[1]; m_xyz[2]+=other.m_xyz[2]; return *this; } + inline MercuryVertex& operator -= ( const MercuryVertex& other ) { m_xyz[0]-=other.m_xyz[0]; m_xyz[1]-=other.m_xyz[1]; m_xyz[2]-=other.m_xyz[2]; return *this; } + inline MercuryVertex& operator *= ( float f ) { m_xyz[0]*=f; m_xyz[1]*=f; m_xyz[2]*=f; return *this; } + inline MercuryVertex& operator /= ( float f ) { m_xyz[0]/=f; m_xyz[1]/=f; m_xyz[2]/=f; return *this; } + + inline MercuryVertex operator + ( const MercuryVertex& other ) const { return MercuryVertex( m_xyz[0]+other.m_xyz[0], m_xyz[1]+other.m_xyz[1], m_xyz[2]+other.m_xyz[2] ); } + inline MercuryVertex operator - ( const MercuryVertex& other ) const { return MercuryVertex( m_xyz[0]-other.m_xyz[0], m_xyz[1]-other.m_xyz[1], m_xyz[2]-other.m_xyz[2] ); } + inline MercuryVertex operator * ( float f ) const { return MercuryVertex( m_xyz[0]*f, m_xyz[1]*f, m_xyz[2]*f ); } + inline MercuryVertex operator / ( float f ) const { return MercuryVertex( m_xyz[0]/f, m_xyz[1]/f, m_xyz[2]/f ); } + + bool operator==(const MercuryVertex& p) const; + inline bool operator!=(const MercuryVertex& p) const { return !(*this == p); } + + bool operator==(const float f) const; + inline bool operator!=(const float f) const { return !(*this == f); } + + ///Obtain the cross product (*this) x p + MercuryVertex CrossProduct(const MercuryVertex& p) const; + + float m_xyz[3]; +}; + +typedef MercuryVertex MercuryVector; + +#endif +/**************************************************************************** + * Copyright (C) 2009 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Modified: Mercury2/src/Viewport.cpp =================================================================== --- Mercury2/src/Viewport.cpp 2009-03-01 21:10:09 UTC (rev 156) +++ Mercury2/src/Viewport.cpp 2009-03-02 01:59:30 UTC (rev 157) @@ -11,27 +11,49 @@ MercuryMatrix m = FindGlobalMatrix(); m.Transpose(); - glLoadMatrixf( (m * m_frustum).Ptr() ); + glLoadMatrixf( (m * m_frustum.GetMatrix()).Ptr() ); //The following 2 are equivelent to above // glLoadMatrixf( m_frustum.Ptr() ); // glMultMatrixf( m.Ptr() ); - + glMatrixMode(GL_MODELVIEW); } -void Viewport::Perspective( float fov, float aspect, float znear, float zfar ) +void Viewport::LoadFromXML(const XMLNode& node) { + m_frustum.SetPerspective( StrToFloat(node.Attribute("fov")), + StrToFloat(node.Attribute("aspect")), + StrToFloat(node.Attribute("near")), + StrToFloat(node.Attribute("far"))); + + m_frustum.LookAt(MercuryVertex(), MercuryVertex(0,0,1), MercuryVertex(0,1,0)); + + RenderableNode::LoadFromXML(node); +} + +void Frustum::SetPerspective( float fov, float aspect, float znear, float zfar ) +{ float xmin, xmax, ymin, ymax; - ymax = znear * TAN(fov * Q_PI / 360.0); + m_fov = fov; + m_aspect = aspect; + m_zNear = znear; + m_zFar = zfar; + + float tang = TAN(m_fov * Q_PI / 360.0); + + m_nh = ymax = m_zNear * tang; //nh ymin = -ymax; - xmin = ymin * aspect; - xmax = ymax * aspect; + xmin = ymin * m_aspect; + m_nw = xmax = ymax * m_aspect; //nw + + m_fh = m_zFar*tang; + m_fw = m_fh*aspect; - ComputeFrustum(xmin, xmax, ymin, ymax, znear, zfar); + ComputeFrustum(xmin, xmax, ymin, ymax, m_zNear, m_zFar); } -void Viewport::ComputeFrustum(float left, float right, float bottom, float top, float zNear, float zFar) +void Frustum::ComputeFrustum(float left, float right, float bottom, float top, float zNear, float zFar) { float near2 = 2*zNear; float rml = right-left; @@ -57,16 +79,59 @@ m_frustum.Transpose(); //XXX fix it to remove this } -void Viewport::LoadFromXML(const XMLNode& node) +void Frustum::LookAt(const MercuryVertex& eye, const MercuryVector& look, const MercuryVector& up) { - Perspective( StrToFloat(node.Attribute("fov")), - StrToFloat(node.Attribute("aspect")), - StrToFloat(node.Attribute("near")), - StrToFloat(node.Attribute("far"))); + //Right now this only builds the frustum planes + MercuryVector X,Y,Z; - RenderableNode::LoadFromXML(node); + Z = (eye - look).Normalize(); //direction behind camera + X = (up * Z).Normalize(); //X axis + Y = Z.CrossProduct( X ); //real up + + m_nc = up - Z * m_zNear; + m_fc = up - Z * m_zFar; + + m_planes[PNEAR].Setup(m_nc, Z*-1); + m_planes[PFAR].Setup(m_fc, Z); + + MercuryVector aux,normal; + + aux = (m_nc + Y*m_nh) - eye; + aux.NormalizeSelf(); + normal = aux * X; + m_planes[PTOP].Setup(m_nc+Y*m_nh,normal); + + aux = (m_nc - Y*m_nh) - eye; + aux.NormalizeSelf(); + normal = X * aux; + m_planes[PBOTTOM].Setup(m_nc-Y*m_nh,normal); + + aux = (m_nc - X*m_nw) - eye; + aux.NormalizeSelf(); + normal = aux * Y; + m_planes[PLEFT].Setup(m_nc-X*m_nw,normal); + + aux = (m_nc + X*m_nw) - eye; + aux.NormalizeSelf(); + normal = Y * aux; + m_planes[PRIGHT].Setup(m_nc+X*m_nw,normal); } +/* +void Frustum::LookAt() +{ + +} +*/ +/* +bool Frustum::IsPointInFrustum( float x, float y, float z ) +{ + for( uint16_t i = 0; i < 6; ++i ) + if( frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] <= 0 ) + return false; + return true; +}*/ + /*************************************************************************** * Copyright (C) 2008 by Joshua Allen * * * Modified: Mercury2/src/Viewport.h =================================================================== --- Mercury2/src/Viewport.h 2009-03-01 21:10:09 UTC (rev 156) +++ Mercury2/src/Viewport.h 2009-03-02 01:59:30 UTC (rev 157) @@ -3,18 +3,47 @@ #include <RenderableNode.h> #include <MercuryMatrix.h> +#include <MercuryVertex.h> +#include <MercuryPlane.h> + +class Frustum +{ + enum PlanePos + { + PTOP = 0, + PBOTTOM, + PLEFT, + PRIGHT, + PNEAR, + PFAR + }; + + public: + void SetPerspective( float fov, float aspect, float znear, float zfar ); + const MercuryMatrix& GetMatrix() const { return m_frustum; } + void ComputeFrustum(float left, float right, float bottom, float top, float zNear, float zFar); + + void LookAt(const MercuryVertex& eye, const MercuryVector& look, const MercuryVector& up); + private: + MercuryMatrix m_frustum; + + float m_aspect, m_fov, m_zNear, m_zFar; + float m_nh, m_nw, m_fh, m_fw; + + MercuryVector m_nc, m_fc; + MercuryPlane m_planes[6]; +}; + class Viewport : public RenderableNode { public: virtual void Render(); - void Perspective( float fov, float aspect, float znear, float zfar ); virtual void LoadFromXML(const XMLNode& node); GENRTTI(Viewport); private: - void ComputeFrustum(float left, float right, float bottom, float top, float zNear, float zFar); - MercuryMatrix m_frustum; + Frustum m_frustum; }; #endif Modified: Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp =================================================================== --- Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2009-03-01 21:10:09 UTC (rev 156) +++ Mercury2/tools/obj2hgmdl/obj2hgmdl.cpp 2009-03-02 01:59:30 UTC (rev 157) @@ -136,7 +136,8 @@ bool b; fwrite("MBMF", 4, 1, mbmf); - tmp32 = 200; fwrite(&tmp32, sizeof(uint32_t), 1, mbmf); + tmp16 = 2; fwrite(&tmp16, sizeof(uint16_t), 1, mbmf); + tmp16 = 3; fwrite(&tmp16, sizeof(uint16_t), 1, mbmf); tmp16 = 1; fwrite(&tmp16, sizeof(uint16_t), 1, mbmf); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-02 20:07:39
|
Revision: 163 http://hgengine.svn.sourceforge.net/hgengine/?rev=163&view=rev Author: axlecrusher Date: 2009-03-02 20:07:37 +0000 (Mon, 02 Mar 2009) Log Message: ----------- update Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/MercuryMatrix.cpp Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-03-02 20:00:18 UTC (rev 162) +++ Mercury2/scenegraph.xml 2009-03-02 20:07:37 UTC (rev 163) @@ -20,7 +20,7 @@ <asset type="quad"/> </node> </node> - <node type="rotatornode" movy="0" movz="-20" scalex="0.25" scaley="0.25" scalez="0.25" > + <node type="rotatornode" movy="0" movz="-2" scalex="0.25" scaley="0.25" scalez="0.25" > <node type="renderablenode"> <asset type="texture" file="gunther.png"/> <asset type="hgmdlmodel" file="gunther.hgmdl"/> Modified: Mercury2/src/MercuryMatrix.cpp =================================================================== --- Mercury2/src/MercuryMatrix.cpp 2009-03-02 20:00:18 UTC (rev 162) +++ Mercury2/src/MercuryMatrix.cpp 2009-03-02 20:07:37 UTC (rev 163) @@ -198,11 +198,13 @@ MercuryVector MercuryMatrix::operator*(const MercuryVector& v) const { float tmp[4]; + FloatRow r, tvo; + v.ConvertToVector4( tmp ); - FloatRow r, tvo; Float2FloatRow( tmp, &r ); VectorMultiply4f( m_matrix, &r, &tvo); FloatRow2Float( &tvo, tmp ); + return MercuryVertex(tmp); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-02 20:00:26
|
Revision: 162 http://hgengine.svn.sourceforge.net/hgengine/?rev=162&view=rev Author: axlecrusher Date: 2009-03-02 20:00:18 +0000 (Mon, 02 Mar 2009) Log Message: ----------- update Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/BoundingBox.cpp Mercury2/src/MercuryMatrix.cpp Mercury2/src/MercuryVertex.cpp Mercury2/src/MercuryVertex.h Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-03-02 19:51:29 UTC (rev 161) +++ Mercury2/scenegraph.xml 2009-03-02 20:00:18 UTC (rev 162) @@ -20,7 +20,7 @@ <asset type="quad"/> </node> </node> - <node type="rotatornode" movy="0" movz="-2" scalex="0.25" scaley="0.25" scalez="0.25" > + <node type="rotatornode" movy="0" movz="-20" scalex="0.25" scaley="0.25" scalez="0.25" > <node type="renderablenode"> <asset type="texture" file="gunther.png"/> <asset type="hgmdlmodel" file="gunther.hgmdl"/> Modified: Mercury2/src/BoundingBox.cpp =================================================================== --- Mercury2/src/BoundingBox.cpp 2009-03-02 19:51:29 UTC (rev 161) +++ Mercury2/src/BoundingBox.cpp 2009-03-02 20:00:18 UTC (rev 162) @@ -22,7 +22,7 @@ MercuryVertex c = GetGlobalMatrix() * m_bb->GetCenter(); // GetGlobalMatrix().Print(); -// c.Print(); + c.Print(); BoundingBox gbb( c, bb.GetExtend() ); Modified: Mercury2/src/MercuryMatrix.cpp =================================================================== --- Mercury2/src/MercuryMatrix.cpp 2009-03-02 19:51:29 UTC (rev 161) +++ Mercury2/src/MercuryMatrix.cpp 2009-03-02 20:00:18 UTC (rev 162) @@ -203,7 +203,6 @@ Float2FloatRow( tmp, &r ); VectorMultiply4f( m_matrix, &r, &tvo); FloatRow2Float( &tvo, tmp ); - MercuryVertex(tmp).Print(); return MercuryVertex(tmp); } Modified: Mercury2/src/MercuryVertex.cpp =================================================================== --- Mercury2/src/MercuryVertex.cpp 2009-03-02 19:51:29 UTC (rev 161) +++ Mercury2/src/MercuryVertex.cpp 2009-03-02 20:00:18 UTC (rev 162) @@ -20,6 +20,12 @@ m_xyz[i] = in[i]; } +MercuryVertex::MercuryVertex( const MercuryVertex& v) +{ + for (unsigned int i = 0; i < 3; ++i) + m_xyz[i] = v.m_xyz[i]; +} + void MercuryVertex::NormalizeSelf() { float imag = 1.0f/Length(); Modified: Mercury2/src/MercuryVertex.h =================================================================== --- Mercury2/src/MercuryVertex.h 2009-03-02 19:51:29 UTC (rev 161) +++ Mercury2/src/MercuryVertex.h 2009-03-02 20:00:18 UTC (rev 162) @@ -7,6 +7,7 @@ MercuryVertex(); MercuryVertex( float ix, float iy, float iz ); MercuryVertex( const float * in ); + MercuryVertex( const MercuryVertex& v); ///Direct conversion to float* operator float* () { return m_xyz; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-03-02 21:59:18
|
Revision: 167 http://hgengine.svn.sourceforge.net/hgengine/?rev=167&view=rev Author: cnlohr Date: 2009-03-02 21:59:02 +0000 (Mon, 02 Mar 2009) Log Message: ----------- add extra files to build system Modified Paths: -------------- Mercury2/adv_set.c Mercury2/base_set.sh Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-03-02 21:07:12 UTC (rev 166) +++ Mercury2/adv_set.c 2009-03-02 21:59:02 UTC (rev 167) @@ -9,9 +9,9 @@ src/Texture.cpp src/RawImageData.cpp src/BMPLoader.cpp src/PNGLoader.cpp src/ImageLoader.cpp \ src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \ - src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp" + src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ + src/MercuryPlane.cpp src/BoundingBox.cpp" - SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2009-03-02 21:07:12 UTC (rev 166) +++ Mercury2/base_set.sh 2009-03-02 21:59:02 UTC (rev 167) @@ -8,13 +8,14 @@ ISMAC=1; fi -OPTIONS="X11 libxml OGL" +OPTIONS="X11 libxml OGL sse" OPT_X11=1 OPT_OGL=1 OPT_libxml=1 +OPT_sse=1 DEFINES="WAS_CONFIGURED USE_MSTRING" -CC_BASE="-O2 -g0 -Wall -DUSE_SSE" +CC_BASE="-O2 -g0 -Wall" for i in $*; do if test $i = "--help"; then @@ -65,7 +66,7 @@ NEED_L="$NEED_L GL" fi -if test $OPT_sse = 1; then +if test $OPT_ss = 1; then DEFINES="$DEFINES USE_SSE" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-03-20 01:55:25
|
Revision: 185 http://hgengine.svn.sourceforge.net/hgengine/?rev=185&view=rev Author: axlecrusher Date: 2009-03-20 01:55:12 +0000 (Fri, 20 Mar 2009) Log Message: ----------- fallback enabled XML attributes Modified Paths: -------------- Mercury2/scenegraph.xml Mercury2/src/XMLParser.cpp Mercury2/src/XMLParser.h Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-03-19 22:45:56 UTC (rev 184) +++ Mercury2/scenegraph.xml 2009-03-20 01:55:12 UTC (rev 185) @@ -2,18 +2,23 @@ <node type="transformnode" movz="0" roty="0"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> </node> - <node type="transformnode" movz="-3"> + <node type="transformnode" movz="-3" name="fallbackTest"> <node type="renderablenode"> <asset type="texture" file="test.bmp"/> <asset type="quad"/> </node> + <node type="transformnode" movx="-1" movy="-1" fallback="fallbackTest"> + <node type="renderablenode"> + <asset type="quad"/> + </node> + </node> </node> - <node type="transformnode" movz="-3" movx="-1" movy="-1"> + <node type="transformnode" movx="-1" movy="-1" fallback="fallbackTest"> <node type="renderablenode"> <asset type="quad"/> </node> </node> - <node type="transformnode" movz="-3" movx="1" movy="-1"> + <node type="transformnode" movx="1" movy="-1" fallback="fallbackTest"> <node type="renderablenode"> <asset type="texture" file="test2.png"/> <asset type="texture" file="test.bmp"/> Modified: Mercury2/src/XMLParser.cpp =================================================================== --- Mercury2/src/XMLParser.cpp 2009-03-19 22:45:56 UTC (rev 184) +++ Mercury2/src/XMLParser.cpp 2009-03-20 01:55:12 UTC (rev 185) @@ -23,35 +23,60 @@ XMLNode XMLNode::NextNode() const { - for (xmlNode* node = m_node->next; node; node=node->next) - if (node->type == XML_ELEMENT_NODE) - return XMLNode(node,m_doc); + if ( IsValid() ) + { + for (xmlNode* node = m_node->next; node; node=node->next) + if (node->type == XML_ELEMENT_NODE) + return XMLNode(node,m_doc); + +//falling back here seem like a bad idea, high chance of infinite loops? +// XMLNode fall = FindFallbackNode(); +// return fall.NextNode(); + } return XMLNode(); } XMLNode XMLNode::PreviousNode() const { - for (xmlNode* node = m_node->prev; node; node=node->prev) - if (node->type == XML_ELEMENT_NODE) - return XMLNode(node,m_doc); + if ( IsValid() ) + { + for (xmlNode* node = m_node->prev; node; node=node->prev) + if (node->type == XML_ELEMENT_NODE) + return XMLNode(node,m_doc); + +//falling back here seem like a bad idea, high chance of infinite loops? +// XMLNode fall = FindFallbackNode(); +// return fall.PreviousNode(); + } return XMLNode(); } XMLNode XMLNode::Child() const { - for (xmlNode* node = m_node->children; node; node=node->next) - if (node->type == XML_ELEMENT_NODE) return XMLNode(node,m_doc); + if ( IsValid() ) + { + for (xmlNode* node = m_node->children; node; node=node->next) + if (node->type == XML_ELEMENT_NODE) return XMLNode(node,m_doc); + +//falling back here seem like a bad idea, high chance of infinite loops? +// XMLNode fall = FindFallbackNode(); +// return fall.Child(); + } return XMLNode(); } MString XMLNode::Name() const { - return MString((const char*)m_node->name); //XXX fix utf8 + if ( !IsValid() ) return ""; + return MString((const char*)m_node->name); } MString XMLNode::Content() const { MString data; + + if ( !IsValid() ) return data; + // xmlChar* d = xmlNodeListGetString(m_doc, m_node->xmlChildrenNode, 1); xmlChar* d = xmlNodeGetContent(m_node); @@ -67,6 +92,9 @@ MString XMLNode::Attribute(const MString& tag) const { MString data; + + if ( !IsValid() ) return data; + xmlChar* d = xmlGetProp(m_node, (const xmlChar*)tag.c_str()); if (d) @@ -76,43 +104,44 @@ } else { - d = xmlGetProp(m_node, (const xmlChar*)"fallback"); - if (d) - { - //start searching at the root - XMLNode root( xmlDocGetRootElement(m_doc) ); - //prevent infinite recursion on self - if ( root.m_node != m_node ) - { - XMLNode fall = root.FindFallbackNode( MString((const char*)d) ); - data = fall.Attribute(tag); - } - } + XMLNode fall = FindFallbackNode(); + data = fall.Attribute(tag); } - if (d) xmlFree(d); - return data; } -/* -MString XMLNode::FindFallbackAttribute(const MString& path) + +XMLNode XMLNode::FindFallbackNode() const { - - xmlChar* d = xmlGetProp(m_node, (const xmlChar*)tag.c_str()); + xmlChar* d = xmlGetProp(m_node, (const xmlChar*)"fallback"); + XMLNode n; + if (d) { - + //start searching at the root + XMLNode root( xmlDocGetRootElement(m_doc) ); + //prevent infinite recursion on self + if ( root.m_node != m_node ) + { + n = root.RecursiveFindFallbackNode( MString((const char*)d) ); + } + xmlFree(d); } - MString p = path; + + return n; } -*/ -XMLNode XMLNode::FindFallbackNode(const MString& path) const + +XMLNode XMLNode::RecursiveFindFallbackNode(const MString& path) const { + if ( !IsValid() ) return XMLNode(); + if (path.length() > 0) { - MString name = path.substr(0, path.find(".")); + int pos = path.find("."); + MString name = pos<=0?path:path.substr(0, pos); + MString rpath = pos<=0?"":path.substr(pos); for (XMLNode n = this->Child(); n.IsValid(); n = n.NextNode()) - if (n.Attribute("name") == name) return n.FindFallbackNode(path); + if (n.Attribute("name") == name) return n.RecursiveFindFallbackNode(rpath); return XMLNode(); } return *this; Modified: Mercury2/src/XMLParser.h =================================================================== --- Mercury2/src/XMLParser.h 2009-03-19 22:45:56 UTC (rev 184) +++ Mercury2/src/XMLParser.h 2009-03-20 01:55:12 UTC (rev 185) @@ -30,11 +30,12 @@ MString Attribute(const MString & tag) const; // MString FindFallbackAttribute(); - XMLNode FindFallbackNode(const MString& path) const; inline bool IsValid() const { return m_node!=NULL; } - + XMLNode FindFallbackNode() const; private: + XMLNode RecursiveFindFallbackNode(const MString& path) const; + xmlNode* m_node; xmlDoc* m_doc; //parent doc, don't free }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-03-20 03:37:29
|
Revision: 186 http://hgengine.svn.sourceforge.net/hgengine/?rev=186&view=rev Author: cnlohr Date: 2009-03-20 03:37:22 +0000 (Fri, 20 Mar 2009) Log Message: ----------- prepare for shaders Modified Paths: -------------- Mercury2/adv_set.c Mercury2/src/MercuryFile.h Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-03-20 01:55:12 UTC (rev 185) +++ Mercury2/adv_set.c 2009-03-20 03:37:22 UTC (rev 186) @@ -10,7 +10,7 @@ src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \ src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ - src/MercuryPlane.cpp src/BoundingBox.cpp" + src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/src/MercuryFile.h =================================================================== --- Mercury2/src/MercuryFile.h 2009-03-20 01:55:12 UTC (rev 185) +++ Mercury2/src/MercuryFile.h 2009-03-20 03:37:22 UTC (rev 186) @@ -44,7 +44,12 @@ virtual bool Check() = 0; ///Return true if end of file virtual bool Eof() = 0; - ///Return the last time the file was modified, if 0, this means unknown. + ///Return the last time the file was modified. + /** If the time is unknown, 0 is returned. This time has nothing to + do with actual changed time. It is system dependent and should + only be used to see if a file has been changed, unless the user + wishes to take advantage of something they know about the + underlying system. */ virtual unsigned long GetModTime() { return 0; } const MString& GetName() const { return m_sPath; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-04-12 16:31:21
|
Revision: 207 http://hgengine.svn.sourceforge.net/hgengine/?rev=207&view=rev Author: axlecrusher Date: 2009-04-12 16:31:19 +0000 (Sun, 12 Apr 2009) Log Message: ----------- new test models Modified Paths: -------------- Mercury2/mercury2.kdevelop Added Paths: ----------- Mercury2/lamp.hgmdl Mercury2/lamp.png Mercury2/map.hgmdl Mercury2/map.png Added: Mercury2/lamp.hgmdl =================================================================== (Binary files differ) Property changes on: Mercury2/lamp.hgmdl ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/lamp.png =================================================================== (Binary files differ) Property changes on: Mercury2/lamp.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/map.hgmdl =================================================================== (Binary files differ) Property changes on: Mercury2/map.hgmdl ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/map.png =================================================================== (Binary files differ) Property changes on: Mercury2/map.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: Mercury2/mercury2.kdevelop =================================================================== --- Mercury2/mercury2.kdevelop 2009-04-12 16:29:42 UTC (rev 206) +++ Mercury2/mercury2.kdevelop 2009-04-12 16:31:19 UTC (rev 207) @@ -2,7 +2,7 @@ <kdevelop> <general> <author>Joshua Allen</author> - <email/> + <email></email> <version>2.0</version> <projectmanagement>KDevAutoProject</projectmanagement> <primarylanguage>C++</primarylanguage> @@ -14,8 +14,8 @@ <projectname>Mercury2</projectname> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description/> - <defaultencoding/> + <description></description> + <defaultencoding></defaultencoding> <versioncontrol/> </general> <kdevautoproject> @@ -61,14 +61,14 @@ <f77compiler>kdevg77options</f77compiler> <cxxflags>-O0 -g -Wall</cxxflags> <envvars/> - <topsourcedir/> - <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER</cppflags> - <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng</ldflags> - <ccompilerbinary/> - <cxxcompilerbinary/> - <f77compilerbinary/> + <topsourcedir></topsourcedir> + <cppflags>-Isrc/ -I/usr/include/libxml2/ -DHGENGINE -DRUN_FROM_START_FOLDER -pg</cppflags> + <ldflags>-lpthread -lX11 -lGL -lxml2 -lpng -pg</ldflags> + <ccompilerbinary></ccompilerbinary> + <cxxcompilerbinary></cxxcompilerbinary> + <f77compilerbinary></f77compilerbinary> <cflags>-O0 -g -Wall</cflags> - <f77flags/> + <f77flags></f77flags> </debug> <default> <envvars/> @@ -222,7 +222,7 @@ <includePaths>.;</includePaths> </codecompletion> <creategettersetter> - <prefixGet/> + <prefixGet></prefixGet> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> @@ -243,11 +243,11 @@ </cppsupportpart> <kdevdebugger> <general> - <gdbpath/> + <gdbpath></gdbpath> <dbgshell>libtool</dbgshell> - <configGdbScript/> - <runShellScript/> - <runGdbScript/> + <configGdbScript></configGdbScript> + <runShellScript></runShellScript> + <runGdbScript></runGdbScript> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-04-24 02:03:30
|
Revision: 215 http://hgengine.svn.sourceforge.net/hgengine/?rev=215&view=rev Author: cnlohr Date: 2009-04-24 02:03:21 +0000 (Fri, 24 Apr 2009) Log Message: ----------- oops forgot to commit Modified Paths: -------------- Mercury2/adv_set.c Mercury2/base_set.sh Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-04-18 13:44:00 UTC (rev 214) +++ Mercury2/adv_set.c 2009-04-24 02:03:21 UTC (rev 215) @@ -10,7 +10,7 @@ src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \ src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ - src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp" + src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/base_set.sh =================================================================== --- Mercury2/base_set.sh 2009-04-18 13:44:00 UTC (rev 214) +++ Mercury2/base_set.sh 2009-04-24 02:03:21 UTC (rev 215) @@ -63,10 +63,10 @@ if test $OPT_OGL = 1; then NEED_H="GL/gl.h" - NEED_L="$NEED_L GL" + NEED_L="$NEED_L GL GLU" fi -if test $OPT_ss = 1; then +if test $OPT_sse = 1; then DEFINES="$DEFINES USE_SSE" fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-05-15 02:22:46
|
Revision: 248 http://hgengine.svn.sourceforge.net/hgengine/?rev=248&view=rev Author: axlecrusher Date: 2009-05-15 01:38:18 +0000 (Fri, 15 May 2009) Log Message: ----------- kdevelop needs these Added Paths: ----------- Mercury2/Makefile.am Mercury2/Makefile.cvs Mercury2/configure.in Added: Mercury2/Makefile.am =================================================================== --- Mercury2/Makefile.am (rev 0) +++ Mercury2/Makefile.am 2009-05-15 01:38:18 UTC (rev 248) @@ -0,0 +1,5 @@ +# not a GNU package. You can remove this line, if +# have all needed files, that a GNU package needs +AUTOMAKE_OPTIONS = foreign 1.4 + +SUBDIRS = src Added: Mercury2/Makefile.cvs =================================================================== --- Mercury2/Makefile.cvs (rev 0) +++ Mercury2/Makefile.cvs 2009-05-15 01:38:18 UTC (rev 248) @@ -0,0 +1,8 @@ +default: all + +all: + aclocal + autoheader + automake + autoconf + Added: Mercury2/configure.in =================================================================== --- Mercury2/configure.in (rev 0) +++ Mercury2/configure.in 2009-05-15 01:38:18 UTC (rev 248) @@ -0,0 +1,10 @@ +AC_INIT(configure.in) + +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE(mercury2, 2.0) + +AC_LANG_CPLUSPLUS +AC_PROG_CXX +AM_PROG_LIBTOOL + +AC_OUTPUT(Makefile src/Makefile) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-05-16 02:44:00
|
Revision: 253 http://hgengine.svn.sourceforge.net/hgengine/?rev=253&view=rev Author: axlecrusher Date: 2009-05-16 02:43:50 +0000 (Sat, 16 May 2009) Log Message: ----------- updates Modified Paths: -------------- Mercury2/adv_set.c Mercury2/scenegraph.xml Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-05-16 02:41:31 UTC (rev 252) +++ Mercury2/adv_set.c 2009-05-16 02:43:50 UTC (rev 253) @@ -10,7 +10,8 @@ src/MercuryVBO.cpp src/MSemaphore.cpp src/UpdateThreader.cpp src/HGMDLMesh.cpp \ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \ src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ - src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp" + src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \ + src/BillboardNode.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Modified: Mercury2/scenegraph.xml =================================================================== --- Mercury2/scenegraph.xml 2009-05-16 02:41:31 UTC (rev 252) +++ Mercury2/scenegraph.xml 2009-05-16 02:43:50 UTC (rev 253) @@ -1,5 +1,5 @@ <SceneGraph> - <node type="transformnode" movz="0" roty="0"> + <node type="transformnode" movy="-8" rotx="90"> <node type="viewport" fov="45" aspect="1.3333" near="0.01" far="100"/> </node> <node type="transformnode" rotx="-90" movz="-10" movx="0" movy="-5"> @@ -12,7 +12,7 @@ <asset type="texture" file="lamp.png"/> <node type="transformnode" movz="-5" movx="0" movy="0" name="lamprow" > <node type="transformnode" rotx="-90" name="lamp"> - <node type="renderablenode" > + <node type="billboard" > <asset type="hgmdlmodel" file="lamp.hgmdl" /> </node> </node> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-05-26 02:51:43
|
Revision: 277 http://hgengine.svn.sourceforge.net/hgengine/?rev=277&view=rev Author: cnlohr Date: 2009-05-26 02:51:42 +0000 (Tue, 26 May 2009) Log Message: ----------- fix up stuff for modules to enable proper building Modified Paths: -------------- Mercury2/cnconfigure Mercury2/src/MercuryNode.h Modified: Mercury2/cnconfigure =================================================================== --- Mercury2/cnconfigure 2009-05-26 02:23:47 UTC (rev 276) +++ Mercury2/cnconfigure 2009-05-26 02:51:42 UTC (rev 277) @@ -191,7 +191,7 @@ echo "CFLAGS=$CC_BASE $CFLAGS" >> Makefile echo "LDFLAGS=$LDFLAGS" >> Makefile echo "">>Makefile -echo -e "all : \$(PROJ) library" >> Makefile +echo -e "all : \$(PROJ) library allmodules" >> Makefile echo -e "\$(PROJ) : \$(OBJ)" >> Makefile echo -e "\tg++ -o \$@ \$^ \$(LDFLAGS)" >> Makefile echo -e "help : " >> Makefile @@ -216,11 +216,14 @@ # echo -e "\t@if \$(CC) \$(CFLAGS) -c -o \$@ \$<; then echo -e \"[\$\\\\\\\\033[32mOK\\\\\\\\033[0m]\"; else echo -e \"[\\\\\\\\033[31mFAIL\\\\\\\\033[0m]\"; fi" >> Makefile done +echo "allmodules :" >> Makefile +echo -ne "\t(cd modules&&make&&cd ..)\n" >> Makefile echo "clean:" >> Makefile echo -ne "\trm -f " >> Makefile for i in $FOLDERS; do echo -ne "$i/*.o $i/*~ $i/core.* " >>Makefile done echo "\$(PROJ) \$(PROJ).so" >> Makefile +echo -ne "\trm -f modules/*.so modules/*.o modules/*~\n" >>Makefile Modified: Mercury2/src/MercuryNode.h =================================================================== --- Mercury2/src/MercuryNode.h 2009-05-26 02:23:47 UTC (rev 276) +++ Mercury2/src/MercuryNode.h 2009-05-26 02:51:42 UTC (rev 277) @@ -93,7 +93,7 @@ MercuryNode* FactoryFunct##class() { return new class(); } \ Callback0R<MercuryNode*> factoryclbk##class( FactoryFunct##class ); \ bool GlobalRegisterSuccess##class = NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); \ - extern "C" { int Install##class() { printf( "Installing "#class ); return NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); } } + extern "C" { int Install##class() { printf( "Installing "#class "\n" ); NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); return 0; } } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cn...@us...> - 2009-05-26 03:38:11
|
Revision: 280 http://hgengine.svn.sourceforge.net/hgengine/?rev=280&view=rev Author: cnlohr Date: 2009-05-26 03:38:08 +0000 (Tue, 26 May 2009) Log Message: ----------- Add a module, since I can't get the Windows build system working yet. Modified Paths: -------------- Mercury2/Mercury2.sln Mercury2/Mercury2.vcproj Modified: Mercury2/Mercury2.sln =================================================================== --- Mercury2/Mercury2.sln 2009-05-26 03:26:06 UTC (rev 279) +++ Mercury2/Mercury2.sln 2009-05-26 03:38:08 UTC (rev 280) @@ -1,16 +1,26 @@ Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 +# Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mercury2", "Mercury2.vcproj", "{071CC088-86A7-4A9F-9FEE-50BD69132886}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Win32 = Debug|Win32 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {071CC088-86A7-4A9F-9FEE-50BD69132886}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {071CC088-86A7-4A9F-9FEE-50BD69132886}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32 + {071CC088-86A7-4A9F-9FEE-50BD69132886}.Debug|Mixed Platforms.Build.0 = Debug|Win32 {071CC088-86A7-4A9F-9FEE-50BD69132886}.Debug|Win32.ActiveCfg = Debug|Win32 {071CC088-86A7-4A9F-9FEE-50BD69132886}.Debug|Win32.Build.0 = Debug|Win32 + {071CC088-86A7-4A9F-9FEE-50BD69132886}.Release|Any CPU.ActiveCfg = Release|Win32 + {071CC088-86A7-4A9F-9FEE-50BD69132886}.Release|Mixed Platforms.ActiveCfg = Release|Win32 + {071CC088-86A7-4A9F-9FEE-50BD69132886}.Release|Mixed Platforms.Build.0 = Release|Win32 {071CC088-86A7-4A9F-9FEE-50BD69132886}.Release|Win32.ActiveCfg = Release|Win32 {071CC088-86A7-4A9F-9FEE-50BD69132886}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection Modified: Mercury2/Mercury2.vcproj =================================================================== --- Mercury2/Mercury2.vcproj 2009-05-26 03:26:06 UTC (rev 279) +++ Mercury2/Mercury2.vcproj 2009-05-26 03:38:08 UTC (rev 280) @@ -578,6 +578,22 @@ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" > </Filter> + <Filter + Name="Modules" + > + <File + RelativePath=".\modules\BillboardNode.cpp" + > + </File> + <File + RelativePath=".\modules\BillboardNode.h" + > + </File> + </Filter> + <File + RelativePath=".\scenegraph.xml" + > + </File> </Files> <Globals> </Globals> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <axl...@us...> - 2009-05-11 23:45:32
|
Revision: 220 http://hgengine.svn.sourceforge.net/hgengine/?rev=220&view=rev Author: axlecrusher Date: 2009-05-11 23:45:21 +0000 (Mon, 11 May 2009) Log Message: ----------- Work on windows compile Modified Paths: -------------- Mercury2/Mercury2.sln Mercury2/Mercury2.vcproj Mercury2/src/AlignedBuffer.h Mercury2/src/BoundingBox.cpp Mercury2/src/BoundingBox.h Mercury2/src/MAutoPtr.h Mercury2/src/MSemaphore.cpp Mercury2/src/MSemaphore.h Mercury2/src/MercuryFileDriverDirect.cpp Mercury2/src/MercuryMath.cpp Mercury2/src/MercuryMessageManager.h Mercury2/src/MercuryTimer.cpp Mercury2/src/MercuryTimer.h Mercury2/src/MercuryUtil.cpp Mercury2/src/MercuryUtil.h Mercury2/src/MercuryVBO.cpp Mercury2/src/MercuryVertex.cpp Mercury2/src/MercuryVertex.h Mercury2/src/MercuryWindow.h Mercury2/src/MessageHandler.h Mercury2/src/PNGLoader.cpp Mercury2/src/Quad.cpp Mercury2/src/RenderGraph.cpp Mercury2/src/RenderableNode.cpp Mercury2/src/RenderableNode.h Mercury2/src/Shader.cpp Mercury2/src/Texture.cpp Mercury2/src/Texture.h Mercury2/src/TransformNode.cpp Mercury2/src/Viewport.cpp Mercury2/src/Win32Window.cpp Mercury2/src/Win32Window.h Added Paths: ----------- Mercury2/freeglut.dll Mercury2/freeglut.lib Mercury2/iconv.dll Mercury2/libpng.lib Mercury2/libpng3.dll Mercury2/libxml2.dll Mercury2/libxml2.lib Mercury2/src/GLHeaders.h Mercury2/src/Mint.h Mercury2/src/glext.h Mercury2/src/global.h Mercury2/src/include/ Mercury2/src/include/freeglut/ Mercury2/src/include/freeglut/freeglut.h Mercury2/src/include/freeglut/freeglut_ext.h Mercury2/src/include/freeglut/freeglut_std.h Mercury2/src/include/freeglut/glut.h Mercury2/src/include/iconv.h Mercury2/src/include/libxml/ Mercury2/src/include/libxml/DOCBparser.h Mercury2/src/include/libxml/HTMLparser.h Mercury2/src/include/libxml/HTMLtree.h Mercury2/src/include/libxml/SAX.h Mercury2/src/include/libxml/SAX2.h Mercury2/src/include/libxml/c14n.h Mercury2/src/include/libxml/catalog.h Mercury2/src/include/libxml/chvalid.h Mercury2/src/include/libxml/debugXML.h Mercury2/src/include/libxml/dict.h Mercury2/src/include/libxml/encoding.h Mercury2/src/include/libxml/entities.h Mercury2/src/include/libxml/globals.h Mercury2/src/include/libxml/hash.h Mercury2/src/include/libxml/list.h Mercury2/src/include/libxml/nanoftp.h Mercury2/src/include/libxml/nanohttp.h Mercury2/src/include/libxml/parser.h Mercury2/src/include/libxml/parserInternals.h Mercury2/src/include/libxml/pattern.h Mercury2/src/include/libxml/relaxng.h Mercury2/src/include/libxml/schemasInternals.h Mercury2/src/include/libxml/schematron.h Mercury2/src/include/libxml/threads.h Mercury2/src/include/libxml/tree.h Mercury2/src/include/libxml/uri.h Mercury2/src/include/libxml/valid.h Mercury2/src/include/libxml/xinclude.h Mercury2/src/include/libxml/xlink.h Mercury2/src/include/libxml/xmlIO.h Mercury2/src/include/libxml/xmlautomata.h Mercury2/src/include/libxml/xmlerror.h Mercury2/src/include/libxml/xmlexports.h Mercury2/src/include/libxml/xmlmemory.h Mercury2/src/include/libxml/xmlmodule.h Mercury2/src/include/libxml/xmlreader.h Mercury2/src/include/libxml/xmlregexp.h Mercury2/src/include/libxml/xmlsave.h Mercury2/src/include/libxml/xmlschemas.h Mercury2/src/include/libxml/xmlschemastypes.h Mercury2/src/include/libxml/xmlstring.h Mercury2/src/include/libxml/xmlunicode.h Mercury2/src/include/libxml/xmlversion.h Mercury2/src/include/libxml/xmlwin32version.h Mercury2/src/include/libxml/xmlwriter.h Mercury2/src/include/libxml/xpath.h Mercury2/src/include/libxml/xpathInternals.h Mercury2/src/include/libxml/xpointer.h Mercury2/src/include/png/ Mercury2/src/include/png/libpng12/ Mercury2/src/include/png/libpng12/png.h Mercury2/src/include/png/libpng12/pngconf.h Mercury2/src/include/png/png.h Mercury2/src/include/png/pngconf.h Mercury2/src/include/zlib/ Mercury2/src/include/zlib/zconf.h Mercury2/src/include/zlib/zlib.h Mercury2/zdll.lib Modified: Mercury2/Mercury2.sln =================================================================== --- Mercury2/Mercury2.sln 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/Mercury2.sln 2009-05-11 23:45:21 UTC (rev 220) @@ -1,6 +1,6 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mercury2", "Mercury2.vcproj", "{071CC088-86A7-4A9F-9FEE-50BD69132886}" EndProject Global Modified: Mercury2/Mercury2.vcproj =================================================================== --- Mercury2/Mercury2.vcproj 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/Mercury2.vcproj 2009-05-11 23:45:21 UTC (rev 220) @@ -1,11 +1,12 @@ <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject ProjectType="Visual C++" - Version="8.00" + Version="9.00" Name="Mercury2" ProjectGUID="{071CC088-86A7-4A9F-9FEE-50BD69132886}" RootNamespace="Mercury2" Keyword="Win32Proj" + TargetFrameworkVersion="131072" > <Platforms> <Platform @@ -40,8 +41,8 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="src/" - PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + AdditionalIncludeDirectories="src/;src/include;src/include/zlib;src/include/png;src/include/libxml2;src/include/freeglut" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HGENGINE" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -61,10 +62,12 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="opengl32.lib" + AdditionalDependencies="zdll.lib libpng.lib libxml2.lib opengl32.lib" LinkIncremental="2" GenerateDebugInformation="true" SubSystem="1" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> <Tool @@ -86,9 +89,6 @@ Name="VCAppVerifierTool" /> <Tool - Name="VCWebDeploymentTool" - /> - <Tool Name="VCPostBuildEventTool" /> </Configuration> @@ -142,6 +142,8 @@ SubSystem="1" OptimizeReferences="2" EnableCOMDATFolding="2" + RandomizedBaseAddress="1" + DataExecutionPrevention="0" TargetMachine="1" /> <Tool @@ -163,9 +165,6 @@ Name="VCAppVerifierTool" /> <Tool - Name="VCWebDeploymentTool" - /> - <Tool Name="VCPostBuildEventTool" /> </Configuration> @@ -179,10 +178,58 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File + RelativePath=".\src\BMPLoader.cpp" + > + </File> + <File + RelativePath=".\src\BoundingBox.cpp" + > + </File> + <File + RelativePath=".\src\Frustum.cpp" + > + </File> + <File + RelativePath=".\src\HGMDLMesh.cpp" + > + </File> + <File + RelativePath=".\src\HGMDLModel.cpp" + > + </File> + <File + RelativePath=".\src\ImageLoader.cpp" + > + </File> + <File RelativePath=".\src\Mercury2.cpp" > </File> <File + RelativePath=".\src\MercuryAsset.cpp" + > + </File> + <File + RelativePath=".\src\MercuryFile.cpp" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverDirect.cpp" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverMem.cpp" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverPacked.cpp" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverZipped.cpp" + > + </File> + <File RelativePath=".\src\MercuryMath.cpp" > </File> @@ -191,17 +238,101 @@ > </File> <File + RelativePath=".\src\MercuryMessageManager.cpp" + > + </File> + <File + RelativePath=".\src\MercuryNode.cpp" + > + </File> + <File + RelativePath=".\src\MercuryPlane.cpp" + > + </File> + <File + RelativePath=".\src\MercuryPoint.cpp" + > + </File> + <File + RelativePath=".\src\MercuryString.cpp" + > + </File> + <File RelativePath=".\src\MercuryThreads.cpp" > </File> <File + RelativePath=".\src\MercuryTimer.cpp" + > + </File> + <File + RelativePath=".\src\MercuryUtil.cpp" + > + </File> + <File + RelativePath=".\src\MercuryVBO.cpp" + > + </File> + <File + RelativePath=".\src\MercuryVertex.cpp" + > + </File> + <File RelativePath=".\src\MercuryWindow.cpp" > </File> <File + RelativePath=".\src\MSemaphore.cpp" + > + </File> + <File + RelativePath=".\src\PNGLoader.cpp" + > + </File> + <File + RelativePath=".\src\Quad.cpp" + > + </File> + <File + RelativePath=".\src\RawImageData.cpp" + > + </File> + <File + RelativePath=".\src\RenderableNode.cpp" + > + </File> + <File + RelativePath=".\src\RenderGraph.cpp" + > + </File> + <File + RelativePath=".\src\Shader.cpp" + > + </File> + <File + RelativePath=".\src\Texture.cpp" + > + </File> + <File + RelativePath=".\src\TransformNode.cpp" + > + </File> + <File + RelativePath=".\src\UpdateThreader.cpp" + > + </File> + <File + RelativePath=".\src\Viewport.cpp" + > + </File> + <File RelativePath=".\src\Win32Window.cpp" > </File> + <File + RelativePath=".\src\XMLParser.cpp" + > + </File> </Filter> <Filter Name="Header Files" @@ -209,14 +340,86 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File + RelativePath=".\src\AlignedBuffer.h" + > + </File> + <File + RelativePath=".\src\BoundingBox.h" + > + </File> + <File RelativePath=".\src\Callback.h" > </File> <File + RelativePath=".\src\Frustum.h" + > + </File> + <File + RelativePath=".\src\glext.h" + > + </File> + <File + RelativePath=".\src\GLHeaders.h" + > + </File> + <File + RelativePath=".\src\global.h" + > + </File> + <File + RelativePath=".\src\HGMDLMesh.h" + > + </File> + <File + RelativePath=".\src\HGMDLModel.h" + > + </File> + <File + RelativePath=".\src\ImageLoader.h" + > + </File> + <File RelativePath=".\src\MAutoPtr.h" > </File> <File + RelativePath=".\src\MercuryAsset.h" + > + </File> + <File + RelativePath=".\src\MercuryBacktrace.h" + > + </File> + <File + RelativePath=".\src\MercuryCrash.h" + > + </File> + <File + RelativePath=".\src\MercuryFile.h" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverDirect.h" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverMem.h" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverPacked.h" + > + </File> + <File + RelativePath=".\src\MercuryFileDriverZipped.h" + > + </File> + <File + RelativePath=".\src\MercuryList.h" + > + </File> + <File RelativePath=".\src\MercuryMath.h" > </File> @@ -225,25 +428,117 @@ > </File> <File + RelativePath=".\src\MercuryMessageManager.h" + > + </File> + <File + RelativePath=".\src\MercuryNode.h" + > + </File> + <File + RelativePath=".\src\MercuryPlane.h" + > + </File> + <File + RelativePath=".\src\MercuryPoint.h" + > + </File> + <File + RelativePath=".\src\MercuryString.h" + > + </File> + <File RelativePath=".\src\MercuryThreads.h" > </File> <File + RelativePath=".\src\MercuryTimer.h" + > + </File> + <File RelativePath=".\src\MercuryUtil.h" > </File> <File + RelativePath=".\src\MercuryVBO.h" + > + </File> + <File + RelativePath=".\src\MercuryVertex.h" + > + </File> + <File RelativePath=".\src\MercuryWindow.h" > </File> <File + RelativePath=".\src\MessageHandler.h" + > + </File> + <File + RelativePath=".\src\Mint.h" + > + </File> + <File + RelativePath=".\src\MQueue.h" + > + </File> + <File RelativePath=".\src\MScopedArray.h" > </File> <File + RelativePath=".\src\MSemaphore.h" + > + </File> + <File + RelativePath=".\src\PriorityQueue.h" + > + </File> + <File + RelativePath=".\src\Quad.h" + > + </File> + <File + RelativePath=".\src\RawImageData.h" + > + </File> + <File + RelativePath=".\src\RenderableNode.h" + > + </File> + <File + RelativePath=".\src\RenderGraph.h" + > + </File> + <File + RelativePath=".\src\Shader.h" + > + </File> + <File + RelativePath=".\src\Texture.h" + > + </File> + <File + RelativePath=".\src\TransformNode.h" + > + </File> + <File + RelativePath=".\src\UpdateThreader.h" + > + </File> + <File + RelativePath=".\src\Viewport.h" + > + </File> + <File RelativePath=".\src\Win32Window.h" > </File> + <File + RelativePath=".\src\XMLParser.h" + > + </File> </Filter> <Filter Name="Resource Files" Added: Mercury2/freeglut.dll =================================================================== (Binary files differ) Property changes on: Mercury2/freeglut.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/freeglut.lib =================================================================== (Binary files differ) Property changes on: Mercury2/freeglut.lib ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/iconv.dll =================================================================== (Binary files differ) Property changes on: Mercury2/iconv.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/libpng.lib =================================================================== (Binary files differ) Property changes on: Mercury2/libpng.lib ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/libpng3.dll =================================================================== (Binary files differ) Property changes on: Mercury2/libpng3.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/libxml2.dll =================================================================== (Binary files differ) Property changes on: Mercury2/libxml2.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: Mercury2/libxml2.lib =================================================================== (Binary files differ) Property changes on: Mercury2/libxml2.lib ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: Mercury2/src/AlignedBuffer.h =================================================================== --- Mercury2/src/AlignedBuffer.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/AlignedBuffer.h 2009-05-11 23:45:21 UTC (rev 220) @@ -1,7 +1,7 @@ #ifndef ALIGNEDBUFFER_H #define ALIGNEDBUFFER_H -#include <stdint.h> +#include <Mint.h> template <typename T> class AlignedBuffer Modified: Mercury2/src/BoundingBox.cpp =================================================================== --- Mercury2/src/BoundingBox.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/BoundingBox.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,5 +1,4 @@ -#include <GL/gl.h> -#include <GL/glext.h> +#include <GLHeaders.h> #include <BoundingBox.h> #include <string.h> #include <Viewport.h> Modified: Mercury2/src/BoundingBox.h =================================================================== --- Mercury2/src/BoundingBox.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/BoundingBox.h 2009-05-11 23:45:21 UTC (rev 220) @@ -5,7 +5,7 @@ #include <MercuryVertex.h> #include <MercuryMatrix.h> #include <Frustum.h> -#include <stdint.h> +#include <Mint.h> #include <MercuryPlane.h> class BoundingVolume Added: Mercury2/src/GLHeaders.h =================================================================== --- Mercury2/src/GLHeaders.h (rev 0) +++ Mercury2/src/GLHeaders.h 2009-05-11 23:45:21 UTC (rev 220) @@ -0,0 +1,18 @@ +#ifndef GLHEADERS_H +#define GLHEADERS_H + +#ifdef WIN32 +#include <windows.h> +#endif + +#include <GL/gl.h> + +#ifdef WIN32 +#include <glext.h> +#else +#include <GL/glext.h> +#endif + +#include <glut.h> + +#endif \ No newline at end of file Modified: Mercury2/src/MAutoPtr.h =================================================================== --- Mercury2/src/MAutoPtr.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MAutoPtr.h 2009-05-11 23:45:21 UTC (rev 220) @@ -2,6 +2,7 @@ #define MAUTOPTR_H #include <MercuryThreads.h> +#include <stdlib.h> class RefBase { Modified: Mercury2/src/MSemaphore.cpp =================================================================== --- Mercury2/src/MSemaphore.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MSemaphore.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,94 +1,162 @@ -#include <MSemaphore.h> - -MSemaphore::MSemaphore() - :m_counter(0) -{ -} - -unsigned long MSemaphore::Read() -{ - return __sync_or_and_fetch(&m_counter, 0); -} - -unsigned long MSemaphore::ReadAndClear() -{ - return __sync_fetch_and_and(&m_counter, 0); -} - -unsigned long MSemaphore::Decrement() -{ - return __sync_sub_and_fetch(&m_counter, 1); -} - -unsigned long MSemaphore::Increment() -{ - return __sync_add_and_fetch(&m_counter, 1); -} - -void MSemaphore::WaitAndSet(unsigned long value, unsigned long newVal) -{ - while ( !__sync_bool_compare_and_swap(&m_counter, value, newVal) ); -} - -MSemaphoreLock::MSemaphoreLock(MSemaphore* s) - :m_s(s) -{ - m_s->WaitAndSet(0,1); -} - -MSemaphoreLock::~MSemaphoreLock() -{ - m_s->WaitAndSet(1,0); -} - -MSemaphoreIncOnDestroy::MSemaphoreIncOnDestroy(MSemaphore* s) - :m_s(s) -{ -} - -MSemaphoreIncOnDestroy::~MSemaphoreIncOnDestroy() -{ - m_s->Increment(); -} - -MSemaphoreDecOnDestroy::MSemaphoreDecOnDestroy(MSemaphore* s) - :m_s(s) -{ -} - -MSemaphoreDecOnDestroy::~MSemaphoreDecOnDestroy() -{ - m_s->Decrement(); -} - -/**************************************************************************** - * 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 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. * - ***************************************************************************/ +#include <MSemaphore.h> + +MSemaphore::MSemaphore() + :m_counter(0) +{ +} +#ifndef WIN32 + +unsigned long MSemaphore::Read() +{ + return __sync_or_and_fetch(&m_counter, 0); +} + +unsigned long MSemaphore::ReadAndClear() +{ + return __sync_fetch_and_and(&m_counter, 0); +} + +unsigned long MSemaphore::Decrement() +{ + return __sync_sub_and_fetch(&m_counter, 1); +} + +unsigned long MSemaphore::Increment() +{ + return __sync_add_and_fetch(&m_counter, 1); +} + +void MSemaphore::WaitAndSet(unsigned long value, unsigned long newVal) +{ + while ( !__sync_bool_compare_and_swap(&m_counter, value, newVal) ); +} + +#else + +//These functions seem to be missing from x86 WinBase +FORCEINLINE +LONG +MyInterlockedOr ( + __inout LONG volatile *Destination, + __in LONG Value + ) +{ + LONG Old; + + do { + Old = *Destination; + } while (InterlockedCompareExchange(Destination, + Old | Value, + Old) != Old); + + return Old; +} + +FORCEINLINE +LONG +MyInterlockedAnd ( + __inout LONG volatile *Destination, + __in LONG Value + ) +{ + LONG Old; + + do { + Old = *Destination; + } while (InterlockedCompareExchange(Destination, + Old & Value, + Old) != Old); + + return Old; +} + +unsigned long MSemaphore::Read() +{ + return MyInterlockedOr(&m_counter, 0); +} + +unsigned long MSemaphore::ReadAndClear() +{ + return MyInterlockedAnd(&m_counter, 0); +} + +unsigned long MSemaphore::Decrement() +{ + return InterlockedDecrement(&m_counter); +} + +unsigned long MSemaphore::Increment() +{ + return InterlockedIncrement(&m_counter); +} + +void MSemaphore::WaitAndSet(unsigned long value, unsigned long newVal) +{ + InterlockedCompareExchange(&m_counter, newVal, value); +// while ( !__sync_bool_compare_and_swap(&m_counter, value, newVal) ); +} + +#endif + +MSemaphoreLock::MSemaphoreLock(MSemaphore* s) + :m_s(s) +{ + m_s->WaitAndSet(0,1); +} + +MSemaphoreLock::~MSemaphoreLock() +{ + m_s->WaitAndSet(1,0); +} + +MSemaphoreIncOnDestroy::MSemaphoreIncOnDestroy(MSemaphore* s) + :m_s(s) +{ +} + +MSemaphoreIncOnDestroy::~MSemaphoreIncOnDestroy() +{ + m_s->Increment(); +} + +MSemaphoreDecOnDestroy::MSemaphoreDecOnDestroy(MSemaphore* s) + :m_s(s) +{ +} + +MSemaphoreDecOnDestroy::~MSemaphoreDecOnDestroy() +{ + m_s->Decrement(); +} + +/**************************************************************************** + * 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 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/MSemaphore.h =================================================================== --- Mercury2/src/MSemaphore.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MSemaphore.h 2009-05-11 23:45:21 UTC (rev 220) @@ -1,6 +1,12 @@ #ifndef MSEMAPHORE_H #define MSEMAPHORE_H +#include <global.h> + +#ifdef WIN32 +#include <windows.h> +#endif + class MSemaphore { public: @@ -13,7 +19,12 @@ void WaitAndSet(unsigned long value, unsigned long newVal); private: - unsigned long m_counter; + +#ifndef WIN32 + int32_t m_counter; +#else + volatile LONG m_counter; +#endif }; class MSemaphoreLock Modified: Mercury2/src/MercuryFileDriverDirect.cpp =================================================================== --- Mercury2/src/MercuryFileDriverDirect.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryFileDriverDirect.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,11 +1,13 @@ #include "MercuryFileDriverDirect.h" -#if !defined(WIN32) +#ifndef WIN32 #include <dirent.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> +#else +#include <windows.h> #endif #if defined(_EE) @@ -169,7 +171,7 @@ if( !m_fF ) return 0; #if defined(WIN32) - HANDLE hFile = CreateFile( m_sPath.c_str(), GENERIC_READ, FILE_SHARE_READ, + HANDLE hFile = CreateFile( (LPCWSTR)(m_sPath.c_str()), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); if( !hFile ) return 0; @@ -203,7 +205,7 @@ char buffer[1024]; char * path_end; int retcode = 0; - if( ( retcode = GetModuleFileName( NULL, buffer, 1024 ) ) < 0 ) + if( ( retcode = GetModuleFileName( NULL, (LPWCH)buffer, 1024 ) ) < 0 ) { fprintf( stderr, "WARNING: Could not change path of program to path of executable! Faild to get it with response: %d\n", retcode ); } @@ -213,7 +215,7 @@ fprintf( stderr, "WARNING: Could not change path of program to path of executable! Path retreived: \"%s\".\n", buffer ); } *path_end = 0; - if( !SetCurrentDirectory( buffer ) ) + if( !SetCurrentDirectory( (LPCWSTR)buffer ) ) { fprintf( stderr, "WARNING: Could not set operational folder.", buffer ); } @@ -256,7 +258,7 @@ { #if defined(WIN32) WIN32_FIND_DATA fd; - HANDLE hFind = ::FindFirstFile( sPath, &fd ); + HANDLE hFind = ::FindFirstFile( (LPCWSTR)(sPath.c_str()), &fd ); if( INVALID_HANDLE_VALUE == hFind ) // no files found return; do @@ -267,7 +269,7 @@ if( (!bDirsOnly) && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ) continue; // skip - MString sDirName( fd.cFileName ); + MString sDirName( ((char*)fd.cFileName) ); if( sDirName == "." || sDirName == ".." ) continue; Modified: Mercury2/src/MercuryMath.cpp =================================================================== --- Mercury2/src/MercuryMath.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryMath.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,4 +1,4 @@ -#include <stdint.h> +#include <Mint.h> #include "MercuryMath.h" //the SSE version of this was really slow, this is quicker Modified: Mercury2/src/MercuryMessageManager.h =================================================================== --- Mercury2/src/MercuryMessageManager.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryMessageManager.h 2009-05-11 23:45:21 UTC (rev 220) @@ -7,7 +7,7 @@ #include <PriorityQueue.h> #include <MercuryString.h> #include <MercuryUtil.h> -#include <stdint.h> +#include <Mint.h> /* This message system uses absolute integer time values to fire off events. This ensures accuarate firing times while eliminating floating point error. Modified: Mercury2/src/MercuryTimer.cpp =================================================================== --- Mercury2/src/MercuryTimer.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryTimer.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -4,14 +4,19 @@ #include <sys/time.h> #else #include <windows.h> + + #endif int64_t GetTimeInMicroSeconds() { +#ifndef WIN32 struct timeval tv; gettimeofday( &tv, 0 ); - return (int64_t(tv.tv_sec) * 1000000) + tv.tv_usec; +#else + return timeGetTime() * uint64_t(1000); +#endif } MercuryTimer::MercuryTimer() Modified: Mercury2/src/MercuryTimer.h =================================================================== --- Mercury2/src/MercuryTimer.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryTimer.h 2009-05-11 23:45:21 UTC (rev 220) @@ -1,7 +1,7 @@ #ifndef MERCURYTIMER_H #define MERCURYTIMER_H -#include <stdint.h> +#include <Mint.h> int64_t GetTimeInMicroSeconds(); Modified: Mercury2/src/MercuryUtil.cpp =================================================================== --- Mercury2/src/MercuryUtil.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryUtil.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,6 +1,6 @@ #include <MercuryUtil.h> #include <MercuryFile.h> -#include <stdint.h> +#include <Mint.h> MString ToUpper(const MString& s) { @@ -21,6 +21,12 @@ return x; } +int32_t StrToInt(const MString & s, int32_t d) +{ + int32_t x = d; + if ( s.length() > 0) sscanf(s.c_str(), "%d", &x); + return x; +} void* mmemalign(size_t align, size_t size, void*& mem) { uintptr_t mask = ~(uintptr_t)(align - 1); Modified: Mercury2/src/MercuryUtil.h =================================================================== --- Mercury2/src/MercuryUtil.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryUtil.h 2009-05-11 23:45:21 UTC (rev 220) @@ -4,6 +4,7 @@ #include <stdlib.h> #include <MercuryString.h> #include <assert.h> +#include <global.h> /*#ifndef NULL #define NULL 0 @@ -30,15 +31,16 @@ MString ToUpper(const MString & s); float StrToFloat(const MString & s, float d = 0); +int32_t StrToInt(const MString & s, int32_t d = 0); template<typename T> -const T& max(const T& t1, const T& t2) +const T& MAX(const T& t1, const T& t2) { return t1>t2?t1:t2; } template<typename T> -const T& min(const T& t1, const T& t2) +const T& MIN(const T& t1, const T& t2) { return t1<t2?t1:t2; } Modified: Mercury2/src/MercuryVBO.cpp =================================================================== --- Mercury2/src/MercuryVBO.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryVBO.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -2,9 +2,9 @@ #define GL_GLEXT_PROTOTYPES -#include <GL/gl.h> -#include <GL/glext.h> +#include <GLHeaders.h> + #include <Texture.h> #define BUFFER_OFFSET(i) ((char*)NULL + (i)) @@ -45,7 +45,7 @@ ++m_vboBinds; } - //apply all the active textures + //apply all the active Textures for (uint8_t i = 0; i < numTextures; ++i) { glActiveTexture( GL_TEXTURE0+i ); Modified: Mercury2/src/MercuryVertex.cpp =================================================================== --- Mercury2/src/MercuryVertex.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryVertex.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -51,8 +51,8 @@ float MercuryVertex::GetBiggestElement() const { float tmp = (*this)[0]; - tmp = max<float>(tmp, (*this)[1]); - return max<float>(tmp, (*this)[2]); + tmp = MAX<float>(tmp, (*this)[1]); + return MAX<float>(tmp, (*this)[2]); } const MercuryVertex& MercuryVertex::operator *= (const MercuryVertex& p) Modified: Mercury2/src/MercuryVertex.h =================================================================== --- Mercury2/src/MercuryVertex.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryVertex.h 2009-05-11 23:45:21 UTC (rev 220) @@ -3,7 +3,11 @@ #include <MercuryMath.h> -# define __inline__ __inline__ __attribute__((always_inline)) +#ifndef WIN32 +#define __inline__ __inline__ __attribute__((always_inline)) +#else +#define __inline__ inline +#endif class MercuryVertex { Modified: Mercury2/src/MercuryWindow.h =================================================================== --- Mercury2/src/MercuryWindow.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MercuryWindow.h 2009-05-11 23:45:21 UTC (rev 220) @@ -1,6 +1,7 @@ #ifndef MERCURYWINDOW_H #define MERCURYWINDOW_H +#include <global.h> #include <MercuryUtil.h> #include <list> #include <Callback.h> @@ -36,7 +37,8 @@ static MercuryWindow* m_windowInstance; MString m_title; - int m_width, m_height, m_bits, m_depthBits; + int m_width, m_height; + uint8_t m_bits, m_depthBits; bool m_fullscreen; }; Modified: Mercury2/src/MessageHandler.h =================================================================== --- Mercury2/src/MessageHandler.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/MessageHandler.h 2009-05-11 23:45:21 UTC (rev 220) @@ -2,6 +2,7 @@ #define MESSAGEHANDLER_H #include <MercuryString.h> +#include <global.h> class MessageHandler { Added: Mercury2/src/Mint.h =================================================================== --- Mercury2/src/Mint.h (rev 0) +++ Mercury2/src/Mint.h 2009-05-11 23:45:21 UTC (rev 220) @@ -0,0 +1,17 @@ +#ifndef MINT_H +#define MINT_H + +#ifdef WIN32 +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#else +#include <stdint.h> +#endif + +#endif \ No newline at end of file Modified: Mercury2/src/PNGLoader.cpp =================================================================== --- Mercury2/src/PNGLoader.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/PNGLoader.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -171,4 +171,4 @@ * 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. - */ + */ \ No newline at end of file Modified: Mercury2/src/Quad.cpp =================================================================== --- Mercury2/src/Quad.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/Quad.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -2,9 +2,9 @@ #define GL_GLEXT_PROTOTYPES -#include <GL/gl.h> -#include <GL/glext.h> +#include <GLHeaders.h> + REGISTER_ASSET_TYPE(Quad); Quad::Quad() Modified: Mercury2/src/RenderGraph.cpp =================================================================== --- Mercury2/src/RenderGraph.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/RenderGraph.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,7 +1,7 @@ #include <MercuryMatrix.h> #include <RenderGraph.h> -#include <GL/gl.h> +#include <GLHeaders.h> void RenderGraphEntry::Render() { Modified: Mercury2/src/RenderableNode.cpp =================================================================== --- Mercury2/src/RenderableNode.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/RenderableNode.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,8 +1,8 @@ #include <RenderableNode.h> #include <assert.h> -#include <GL/gl.h> +#include <GLHeaders.h> #include <TransformNode.h> -#include <unistd.h> +//#include <unistd.h> #include <Viewport.h> using namespace std; @@ -67,8 +67,11 @@ MercuryNode* n = NULL; TransformNode* tn; for (n = Parent(); n; n = n->Parent()) - if ( (tn = TransformNode::Cast(n)) ) + { + tn = TransformNode::Cast(n); + if ( tn ) return tn->GetGlobalMatrix(); + } return MercuryMatrix::Identity(); } Modified: Mercury2/src/RenderableNode.h =================================================================== --- Mercury2/src/RenderableNode.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/RenderableNode.h 2009-05-11 23:45:21 UTC (rev 220) @@ -6,7 +6,7 @@ #include <MercuryAsset.h> #include <MercuryMatrix.h> #include <MSemaphore.h> -#include <stdint.h> +#include <Mint.h> #define MCHECKASSETS Modified: Mercury2/src/Shader.cpp =================================================================== --- Mercury2/src/Shader.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/Shader.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -4,9 +4,9 @@ #define GL_GLEXT_PROTOTYPES -#include <GL/gl.h> -#include <GL/glext.h> +#include <GLHeaders.h> + #include <string.h> using namespace std; @@ -47,8 +47,8 @@ void Shader::Init(MercuryNode* node) { MercuryAsset::Init( node ); - RenderableNode* rn; - if ( (rn=RenderableNode::Cast( node )) ) + RenderableNode* rn = RenderableNode::Cast( node ); + if ( rn ) rn->AddPostRender( this ); } @@ -84,7 +84,7 @@ void Shader::LoadFromXML(const XMLNode& node) { sShaderName = node.Attribute("file"); - fPriority = atof( node.Attribute("priority").c_str() ); + fPriority = StrToFloat( node.Attribute("priority").c_str() ); LoadShader( ); } Modified: Mercury2/src/Texture.cpp =================================================================== --- Mercury2/src/Texture.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/Texture.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -4,10 +4,7 @@ #define GL_GLEXT_PROTOTYPES -#include <GL/gl.h> -#include <GL/glext.h> -#include <GL/glu.h> - +#include <GLHeaders.h> using namespace std; REGISTER_ASSET_TYPE(Texture); @@ -36,8 +33,8 @@ { MercuryAsset::Init( node ); - RenderableNode* rn; - if ( (rn=RenderableNode::Cast( node )) ) + RenderableNode* rn = RenderableNode::Cast( node ); + if ( rn ) rn->AddPostRender( this ); } @@ -106,7 +103,7 @@ void Texture::LoadFromXML(const XMLNode& node) { - LoadImage( node.Attribute("file") ); + LoadImagePath( node.Attribute("file") ); } void Texture::BindTexture() @@ -131,7 +128,7 @@ --m_activeTextures; } -void Texture::LoadImage(const MString& path) +void Texture::LoadImagePath(const MString& path) { if (m_isInstanced) return; if ( !path.empty() ) @@ -165,12 +162,12 @@ { MAutoPtr< MercuryAsset > t( AssetFactory::GetInstance().Generate("Texture", path) ); Texture *a = (Texture*)t.Ptr(); - a->LoadImage( path ); + a->LoadImagePath( path ); return a; } bool Texture::m_initTextureSuccess = false; -unsigned short Texture::m_activeTextures = 0; +uint8_t Texture::m_activeTextures = 0; uint32_t Texture::m_textureBinds = 0; /*************************************************************************** Modified: Mercury2/src/Texture.h =================================================================== --- Mercury2/src/Texture.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/Texture.h 2009-05-11 23:45:21 UTC (rev 220) @@ -19,7 +19,7 @@ void LoadFromRaw(); - inline static unsigned short NumberActiveTextures() { return m_activeTextures; } + inline static uint8_t NumberActiveTextures() { return m_activeTextures; } inline static uint32_t ReadAndResetBindCount() { uint32_t t = m_textureBinds; m_textureBinds = 0; return t; } static Texture* Generate(); @@ -27,7 +27,7 @@ void SetRawData(RawImageData* raw); private: - void LoadImage(const MString& path); + void LoadImagePath(const MString& path); void BindTexture(); void UnbindTexture(); @@ -37,7 +37,7 @@ unsigned int m_textureResource; static bool m_initTextureSuccess; - static unsigned short m_activeTextures; + static uint8_t m_activeTextures; static uint32_t m_textureBinds; // MString m_filename; Modified: Mercury2/src/TransformNode.cpp =================================================================== --- Mercury2/src/TransformNode.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/TransformNode.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -67,7 +67,9 @@ const TransformNode* tn; while (n) { - if ( (tn = TransformNode::Cast( n )) ) return tn->GetGlobalMatrix(); + tn = TransformNode::Cast( n ); + tn = TransformNode::Cast( n ); + if ( tn ) return tn->GetGlobalMatrix(); n = n->Parent(); } @@ -83,7 +85,8 @@ for (i = m_children.begin(); i != m_children.end(); ++i ) { - if ( (tn = TransformNode::Cast(*i)) ) + tn = TransformNode::Cast(*i); + if ( tn ) tn->SetTaint( true ); } } @@ -135,7 +138,8 @@ TransformNode* tn; while (n) { - if ( (tn = TransformNode::Cast( n )) ) + tn = TransformNode::Cast( n ); + if ( tn ) { tn->RippleTaintDown(); return; Modified: Mercury2/src/Viewport.cpp =================================================================== --- Mercury2/src/Viewport.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/Viewport.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -1,5 +1,5 @@ #include <Viewport.h> -#include <GL/gl.h> +#include <GLHeaders.h> #include <MercuryWindow.h> REGISTER_NODE_TYPE(Viewport); @@ -15,7 +15,7 @@ FRUSTUM = &m_frustum; MercuryWindow* w = MercuryWindow::GetCurrentWindow(); - glViewport(m_minx, m_miny, w->Width()*m_xFactor, w->Height()*m_yFactor); + glViewport(m_minx, m_miny, (GLsizei)(w->Width()*m_xFactor), (GLsizei)(w->Height()*m_yFactor)); glMatrixMode(GL_PROJECTION); @@ -34,8 +34,8 @@ { m_xFactor = StrToFloat(node.Attribute("xfactor"), 1.0f); m_yFactor = StrToFloat(node.Attribute("yfactor"), 1.0f); - m_minx = StrToFloat(node.Attribute("minx"), 0); - m_miny = StrToFloat(node.Attribute("miny"), 0); + m_minx = StrToInt(node.Attribute("minx"), 0); + m_miny = StrToInt(node.Attribute("miny"), 0); MercuryWindow* w = MercuryWindow::GetCurrentWindow(); Modified: Mercury2/src/Win32Window.cpp =================================================================== --- Mercury2/src/Win32Window.cpp 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/Win32Window.cpp 2009-05-11 23:45:21 UTC (rev 220) @@ -195,6 +195,16 @@ return true; } +void* Win32Window::GetProcAddress(const MString& x) +{ + return NULL; +} + +void Win32Window::Clear() +{ +} + + LRESULT CALLBACK WindowCallback(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) Modified: Mercury2/src/Win32Window.h =================================================================== --- Mercury2/src/Win32Window.h 2009-04-26 16:46:17 UTC (rev 219) +++ Mercury2/src/Win32Window.h 2009-05-11 23:45:21 UTC (rev 220) @@ -15,6 +15,8 @@ virtual bool PumpMessages(); static MercuryWindow* GenWin32Window(); + virtual void* GetProcAddress(const MString& x); + virtual void Clear(); private: void GenWindow(); Added: Mercury2/src/glext.h =================================================================== --- Mercury2/src/glext.h (rev 0) +++ Mercury2/src/glext.h 2009-05-11 23:45:21 UTC (rev 220) @@ -0,0 +1,8782 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007-2009 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2009-05-05 15:27:42 -0700 (Tue, 05 May 2009) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 52 + +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include <windows.h> +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_VERSION_1_2_DEPRECATED +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_ARB_imaging_DEPRECATED +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#endif + +#ifndef GL_VERSION_1_3_DEPRECATED +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#endif + +#ifndef GL_VERSION_1_4_DEPRECATED +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#endif + +#ifndef GL_VERSION_1_5_DEPRECATED +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING... [truncated message content] |
From: <cn...@us...> - 2009-05-26 02:23:52
|
Revision: 276 http://hgengine.svn.sourceforge.net/hgengine/?rev=276&view=rev Author: cnlohr Date: 2009-05-26 02:23:47 +0000 (Tue, 26 May 2009) Log Message: ----------- modularize things Modified Paths: -------------- Mercury2/adv_set.c Mercury2/src/Mercury2.cpp Mercury2/src/MercuryNode.h Mercury2/src/MercuryUtil.cpp Mercury2/src/MercuryUtil.h Added Paths: ----------- Mercury2/modules/ Mercury2/modules/BillboardNode.cpp Mercury2/modules/BillboardNode.h Mercury2/modules/Makefile Mercury2/modules.xml Mercury2/src/MercuryHash.h Mercury2/src/MercuryVector.h Mercury2/src/ModuleManager.cpp Mercury2/src/ModuleManager.h Removed Paths: ------------- Mercury2/src/BillboardNode.cpp Mercury2/src/BillboardNode.h Modified: Mercury2/adv_set.c =================================================================== --- Mercury2/adv_set.c 2009-05-26 00:28:09 UTC (rev 275) +++ Mercury2/adv_set.c 2009-05-26 02:23:47 UTC (rev 276) @@ -11,7 +11,7 @@ src/HGMDLModel.cpp src/MercuryString.cpp src/MercuryCrash.c src/MercuryBacktrace.c \ src/MercuryFile.cpp src/MercuryTimer.cpp src/MercuryMessageManager.cpp src/MercuryVertex.cpp \ src/MercuryPlane.cpp src/BoundingBox.cpp src/Shader.cpp src/RenderGraph.cpp src/Frustum.cpp \ - src/BillboardNode.cpp src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp" + src/Camera.cpp src/MercuryInput.cpp src/MQuaternion.cpp src/ModuleManager.cpp" SOURCES="$SOURCES src/MercuryFileDriverDirect.cpp src/MercuryFileDriverMem.cpp \ src/MercuryFileDriverPacked.cpp src/MercuryFileDriverZipped.cpp" Added: Mercury2/modules/BillboardNode.cpp =================================================================== --- Mercury2/modules/BillboardNode.cpp (rev 0) +++ Mercury2/modules/BillboardNode.cpp 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,95 @@ +#include "BillboardNode.h" +#include <MercuryVertex.h> +#include <Viewport.h> + +REGISTER_NODE_TYPE(BillboardNode); + +MercuryMatrix BillboardNode::ManipulateMatrix(const MercuryMatrix& matrix) +{ + MercuryMatrix m = RenderableNode::ManipulateMatrix( matrix ); + + //Compute the object's center point (position?) in world space + MercuryVertex center(0,0,0,1); + center = matrix * center; + + MercuryVector objToEye = (EYE - center); + MercuryVector objToEyeProj( objToEye ); + + //vector from object to eye projected on XZ + objToEyeProj[1] = 0; objToEyeProj.NormalizeSelf(); + +// MercuryVector objLookAt(0,0,1); //origional look vector of object +// objLookAt = matrix * objLookAt; //convert to world space +// objLookAt.NormalizeSelf(); + +// objLookAt.Print(); + +// MercuryVector up = (objLookAt.CrossProduct( objToEyeProj )).Normalize(); +// up = objLookAt; +// up.Print(); + + MercuryVector up(0,0,1); //we wan't the camera's up + + float angleCos = LOOKAT.DotProduct(objToEyeProj); + + if ((angleCos < 0.99990) && (angleCos > -0.9999)) + { + float f = ACOS(angleCos)*RADDEG; + MercuryMatrix mtmp; + mtmp.RotateAngAxis(f, up[0], up[1], up[2]); + m = m * mtmp; + } + + //spherical below + objToEye.NormalizeSelf(); + angleCos = objToEyeProj.DotProduct( objToEye ); + if ((angleCos < 0.99990) && (angleCos > -0.9999)) + { + printf("%f\n", angleCos); + float f = ACOS(angleCos)*RADDEG; + MercuryMatrix mtmp; + if (objToEye[1] < 0) + mtmp.RotateAngAxis(f, 1, 0, 0); + else + mtmp.RotateAngAxis(f, -1, 0, 0); +// m.Print(); + m = m * mtmp; +// m.Print(); + printf("********************\n"); +// mtmp.Print(); + } + + return m; +} + +/**************************************************************************** + * Copyright (C) 2009 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Added: Mercury2/modules/BillboardNode.h =================================================================== --- Mercury2/modules/BillboardNode.h (rev 0) +++ Mercury2/modules/BillboardNode.h 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,47 @@ +#ifndef BILLBOARDNODE_H +#define BILLBOARDNODE_H + +#include <RenderableNode.h> + +class BillboardNode : public RenderableNode +{ + public: + virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix); + + private: +}; + +#endif + + +/**************************************************************************** + * Copyright (C) 2009 by Joshua Allen * + * * + * * + * All rights reserved. * + * * + * Redistribution and use in source and binary forms, with or without * + * modification, are permitted provided that the following conditions * + * are met: * + * * Redistributions of source code must retain the above copyright * + * notice, this list of conditions and the following disclaimer. * + * * Redistributions in binary form must reproduce the above * + * copyright notice, this list of conditions and the following * + * disclaimer in the documentation and/or other materials provided * + * with the distribution. * + * * Neither the name of the Mercury Engine nor the names of its * + * contributors may be used to endorse or promote products derived * + * from this software without specific prior written permission. * + * * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * + ***************************************************************************/ Added: Mercury2/modules/Makefile =================================================================== --- Mercury2/modules/Makefile (rev 0) +++ Mercury2/modules/Makefile 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,12 @@ +CFLAGS=-O2 -g0 -Wall -I/usr/include/libxml2 -DHAVE_CONFIG -DHGENGINE -fno-exceptions -fPIC -I../src -g +CXXFLAGS=${CFLAGS} +LDFLAGS=-shared + +all : BillboardNode.so + +clean : + rm -rf *~ *.o *.so + +BillboardNode.so : BillboardNode.o + g++ -o$@ $^ ${LDFLAGS} + Added: Mercury2/modules.xml =================================================================== --- Mercury2/modules.xml (rev 0) +++ Mercury2/modules.xml 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,3 @@ +<Modules> + <Module src="modules/BillboardNode.c" obj="modules/BillboardNode" func="InstallBillboardNode" /> +</Modules> Deleted: Mercury2/src/BillboardNode.cpp =================================================================== --- Mercury2/src/BillboardNode.cpp 2009-05-26 00:28:09 UTC (rev 275) +++ Mercury2/src/BillboardNode.cpp 2009-05-26 02:23:47 UTC (rev 276) @@ -1,95 +0,0 @@ -#include <BillboardNode.h> -#include <MercuryVertex.h> -#include <Viewport.h> - -REGISTER_NODE_TYPE(Billboard); - -MercuryMatrix Billboard::ManipulateMatrix(const MercuryMatrix& matrix) -{ - MercuryMatrix m = RenderableNode::ManipulateMatrix( matrix ); - - //Compute the object's center point (position?) in world space - MercuryVertex center(0,0,0,1); - center = matrix * center; - - MercuryVector objToEye = (EYE - center); - MercuryVector objToEyeProj( objToEye ); - - //vector from object to eye projected on XZ - objToEyeProj[1] = 0; objToEyeProj.NormalizeSelf(); - -// MercuryVector objLookAt(0,0,1); //origional look vector of object -// objLookAt = matrix * objLookAt; //convert to world space -// objLookAt.NormalizeSelf(); - -// objLookAt.Print(); - -// MercuryVector up = (objLookAt.CrossProduct( objToEyeProj )).Normalize(); -// up = objLookAt; -// up.Print(); - - MercuryVector up(0,0,1); //we wan't the camera's up - - float angleCos = LOOKAT.DotProduct(objToEyeProj); - - if ((angleCos < 0.99990) && (angleCos > -0.9999)) - { - float f = ACOS(angleCos)*RADDEG; - MercuryMatrix mtmp; - mtmp.RotateAngAxis(f, up[0], up[1], up[2]); - m = m * mtmp; - } - - //spherical below - objToEye.NormalizeSelf(); - angleCos = objToEyeProj.DotProduct( objToEye ); - if ((angleCos < 0.99990) && (angleCos > -0.9999)) - { - printf("%f\n", angleCos); - float f = ACOS(angleCos)*RADDEG; - MercuryMatrix mtmp; - if (objToEye[1] < 0) - mtmp.RotateAngAxis(f, 1, 0, 0); - else - mtmp.RotateAngAxis(f, -1, 0, 0); -// m.Print(); - m = m * mtmp; -// m.Print(); - printf("********************\n"); -// mtmp.Print(); - } - - return m; -} - -/**************************************************************************** - * 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/BillboardNode.h =================================================================== --- Mercury2/src/BillboardNode.h 2009-05-26 00:28:09 UTC (rev 275) +++ Mercury2/src/BillboardNode.h 2009-05-26 02:23:47 UTC (rev 276) @@ -1,47 +0,0 @@ -#ifndef BILLBOARDNODE_H -#define BILLBOARDNODE_H - -#include <RenderableNode.h> - -class Billboard : public RenderableNode -{ - public: - virtual MercuryMatrix ManipulateMatrix(const MercuryMatrix& matrix); - - private: -}; - -#endif - - -/**************************************************************************** - * Copyright (C) 2009 by Joshua Allen * - * * - * * - * All rights reserved. * - * * - * Redistribution and use in source and binary forms, with or without * - * modification, are permitted provided that the following conditions * - * are met: * - * * Redistributions of source code must retain the above copyright * - * notice, this list of conditions and the following disclaimer. * - * * Redistributions in binary form must reproduce the above * - * copyright notice, this list of conditions and the following * - * disclaimer in the documentation and/or other materials provided * - * with the distribution. * - * * Neither the name of the Mercury Engine nor the names of its * - * contributors may be used to endorse or promote products derived * - * from this software without specific prior written permission. * - * * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - ***************************************************************************/ Modified: Mercury2/src/Mercury2.cpp =================================================================== --- Mercury2/src/Mercury2.cpp 2009-05-26 00:28:09 UTC (rev 275) +++ Mercury2/src/Mercury2.cpp 2009-05-26 02:23:47 UTC (rev 276) @@ -16,6 +16,7 @@ #include <RenderGraph.h> #include <Texture.h> #include <GLHeaders.h> +#include <ModuleManager.h> bool SHOWBOUNDINGVOLUME = false; @@ -52,13 +53,14 @@ SetupOGLExtensions(); #endif + ModuleManager::GetInstance().InitializeAllModules(); + MercuryNode* root = new MercuryNode(); XMLDocument* doc = XMLDocument::Load("scenegraph.xml"); - XMLNode r = doc->GetRootNode(); root->LoadFromXML( r ); - + SAFE_DELETE(doc); MercuryTimer timer; Added: Mercury2/src/MercuryHash.h =================================================================== --- Mercury2/src/MercuryHash.h (rev 0) +++ Mercury2/src/MercuryHash.h 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,254 @@ +#ifndef MERCURYHASH_H +#define MERCURYHASH_H + +#include "global.h" +#include <MercuryVector.h> + +///Mercury Hash Table for Strings +template<typename T> +class MHash +{ +public: + MHash( ) : m_iSize( GetAPrime( m_iPrimest = 1 ) ) + { + m_pTable = new MHashNode<T> * [m_iSize]; ///XXX what? and how does this affect delete? + memset( m_pTable, 0, m_iSize * sizeof( MHashNode<T>* ) ); + m_iCount = 0; + } + + MHash( const MHash & rhs ) + { + m_iPrimest = rhs.m_iPrimest; + m_iCount = rhs.m_iCount; + m_pTable = new MHashNode<T> * [rhs.m_iSize]; + m_iSize = rhs.m_iSize; + + memset( m_pTable, 0, m_iSize * sizeof( MHashNode<T>* ) ); + + for( unsigned i = 0; i < m_iSize; ++i ) + { + MHashNode <T> * TMP = rhs.m_pTable[i]; + while (TMP) + { + m_pTable[i] = new MHashNode<T>( m_pTable[i], TMP->Index, TMP->Data ); + TMP = TMP->Next; + } + } + } + + MHash & operator = ( const MHash & rhs ) + { + m_iPrimest = rhs.m_iPrimest; + m_iCount = rhs.m_iCount; + m_pTable = new MHashNode<T> * [rhs.m_iSize]; + m_iSize = rhs.m_iSize; + + memset( m_pTable, 0, m_iSize * sizeof( MHashNode<T>* ) ); + + for( unsigned i = 0; i < m_iSize; ++i ) + { + MHashNode <T> * TMP = rhs.m_pTable[i]; + while (TMP) + { + m_pTable[i] = new MHashNode<T>( m_pTable[i], TMP->Index, TMP->Data ); + TMP = TMP->Next; + } + } + return *this; + } + + void resize( int iNewSize ) + { + MHashNode <T> ** pOldTable = m_pTable; + int iOldSize = m_iSize; + + m_pTable = new MHashNode<T> * [iNewSize]; + m_iSize = iNewSize; + memset( m_pTable, 0, iNewSize * sizeof( MHashNode<T>* ) ); + + for( int i = 0; i < iOldSize; ++i ) + { + while (pOldTable[i]) + { + MHashNode <T> * TMP = pOldTable[i]; + pOldTable[i] = TMP->Next; + + int iNewHash = TMP->Index.hash(); + MHashNode <T> * TMP2 = m_pTable[iNewHash%m_iSize]; + m_pTable[iNewHash%m_iSize] = TMP; + TMP->Next = TMP2; + } + } + + //I think a delete[] is OK here because its an allocated array of pointers. No destructors are called + SAFE_DELETE_ARRAY(pOldTable); + } + + ~MHash() + { + for( unsigned i = 0; i < m_iSize; ++i ) + while (m_pTable[i]) + { + MHashNode <T> * TMP = m_pTable[i]; + m_pTable[i] = TMP->Next; + SAFE_DELETE( TMP ); + } + SAFE_DELETE_ARRAY( m_pTable ); + } + + void clear() + { + for( unsigned i = 0; i < m_iSize; ++i ) + { + while (m_pTable[i]) + { + MHashNode <T> * TMP = m_pTable[i]; + m_pTable[i] = TMP->Next; + SAFE_DELETE( TMP ); + } + m_pTable[i] = 0; + } + m_iCount = 0; + } + + ///Return reference to data in the index's cell, if no data exists, it is generated + T & operator[]( const MString & pIndex ) + { + unsigned int iHash = pIndex.hash(); + MHashNode<T> * m_pTmp = m_pTable[iHash%m_iSize]; + + while( m_pTmp ) + if( m_pTmp->Index == pIndex ) + return m_pTmp->Data; + else + m_pTmp = m_pTmp->Next; + + insert( pIndex, T() ); + + m_pTmp = m_pTable[iHash%m_iSize]; + + while( m_pTmp ) + if( m_pTmp->Index == pIndex ) + return m_pTmp->Data; + else + m_pTmp = m_pTmp->Next; + + //This should NEVER HAPPEN. + assert( "FAIL! Hash insertion failed!" ); + return m_pNil; + } + + ///Insert pData into pIndex's cell + void insert( const MString & pIndex, const T & pData ) + { + unsigned int iHash = pIndex.hash(); + m_pTable[iHash%m_iSize] = new MHashNode<T>( m_pTable[iHash%m_iSize], pIndex, pData ); + + if( ++m_iCount > m_iSize + 5 ) + resize( GetAPrime( ++m_iPrimest ) ); + } + + ///Get pointer to pIndex's cell, if no data exists, NULL is returned. + T * get( const MString & pIndex ) + { + unsigned int iHash = pIndex.hash(); + MHashNode<T> * m_pTmp = m_pTable[iHash%m_iSize]; + + while( m_pTmp ) + if( m_pTmp->Index == pIndex ) + return &m_pTmp->Data; + else + m_pTmp = m_pTmp->Next; + + return 0; + } + + bool remove( const MString & pIndex ) + { + unsigned int iHash = pIndex.hash(); + MHashNode<T> * m_pPrev = 0; + MHashNode<T> * m_pTmp = m_pTable[iHash%m_iSize]; + + while( m_pTmp ) + if( m_pTmp->Index == pIndex ) + { + if( m_pPrev ) + m_pPrev->Next = m_pTmp->Next; + else + m_pTable[iHash%m_iSize] = m_pTable[iHash%m_iSize]->Next; + SAFE_DELETE( m_pTmp ); + m_iCount--; + return true; + } + else + { + m_pPrev = m_pTmp; + m_pTmp = m_pTmp->Next; + } + + return false; + } + + void VectorIndicies( MVector < MString > & vOut ) + { + unsigned int i; + MHashNode<T> * m_pTmp; + for( i = 0; i < m_iSize; i++ ) + { + m_pTmp = m_pTable[i]; + while( m_pTmp ) + { + vOut.push_back( m_pTmp->Index ); + m_pTmp = m_pTmp->Next; + } + } + } + +private: + template<typename TC> + struct MHashNode + { + MHashNode() : Next(0) { } + MHashNode( MHashNode<TC> * pA, const MString & pIn, const TC & pD ) : Next( pA ), Index( pIn ), Data( pD ) { } + + MHashNode <TC> * Next; + MString Index; + TC Data; + }; + + MHashNode <T> ** m_pTable; + T m_pNil; + unsigned int m_iSize; + unsigned int m_iPrimest; + unsigned int m_iCount; +}; + +#endif + +/* + * Copyright (c) 2006-2009 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/MercuryNode.h =================================================================== --- Mercury2/src/MercuryNode.h 2009-05-26 00:28:09 UTC (rev 275) +++ Mercury2/src/MercuryNode.h 2009-05-26 02:23:47 UTC (rev 276) @@ -92,8 +92,10 @@ #define REGISTER_NODE_TYPE(class)\ MercuryNode* FactoryFunct##class() { return new class(); } \ Callback0R<MercuryNode*> factoryclbk##class( FactoryFunct##class ); \ - bool GlobalRegisterSuccess##class = NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); + bool GlobalRegisterSuccess##class = NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); \ + extern "C" { int Install##class() { printf( "Installing "#class ); return NodeFactory::GetInstance().RegisterFactoryCallback(#class, factoryclbk##class); } } + #endif /*************************************************************************** Modified: Mercury2/src/MercuryUtil.cpp =================================================================== --- Mercury2/src/MercuryUtil.cpp 2009-05-26 00:28:09 UTC (rev 275) +++ Mercury2/src/MercuryUtil.cpp 2009-05-26 02:23:47 UTC (rev 276) @@ -80,26 +80,36 @@ return length; } -/*************************************************************************** - * 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. * - ***************************************************************************/ +int GeneralUsePrimes[] = { 3, 13, 37, 73, 131, 229, 337, 821, 2477, 4594, 8941, 14797, 24953, 39041, 60811, 104729 }; + +int GetAPrime( int ith ) +{ + return (ith<0)?3:(ith>15)?GeneralUsePrimes[15]:GeneralUsePrimes[ith]; +} + +/* Copyright (c) 2009, Joshua Allen and 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/MercuryUtil.h =================================================================== --- Mercury2/src/MercuryUtil.h 2009-05-26 00:28:09 UTC (rev 275) +++ Mercury2/src/MercuryUtil.h 2009-05-26 02:23:47 UTC (rev 276) @@ -85,9 +85,20 @@ ///The return value is -1 if there was an issue, otherwise it is valid. long FileToString( const MString & sFileName, char * & data ); +/* These two functions are very different */ +/// nextPow2 will go to the NEXT power of 2 even if x is already a power of 2. +inline int nextPow2(int x) { int num = 1; while(num <= x) num <<= 1; return num; } +///makePow2 will make sure the number is a power of 2 at least equal to x. +inline int makePow2(int x) { int num = 1; while(num < x) num <<= 1; return num; } +inline bool isPow2(int x) { int num = 1; while(num < x) num<<=1; return num==x; } + +///Return a prime number. Note this is NOT sequential. The general(but not guarenteed) +///pattern is the next prime number that's roughly two times the last. +int GetAPrime( int ith ); + #endif -/* Copyright (c) 2008, Joshua Allen +/* Copyright (c) 2009, Joshua Allen and Charles Lohr * All rights reserved. * * Redistribution and use in source and binary forms, with or Added: Mercury2/src/MercuryVector.h =================================================================== --- Mercury2/src/MercuryVector.h (rev 0) +++ Mercury2/src/MercuryVector.h 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,233 @@ +#ifndef _MERCURY_VECTOR_H +#define _MERCURY_VECTOR_H + +#include <string.h> + +///Stripped down and fast vector class +template<typename T> +class MVector +{ + public: + MVector() + :m_reserved(0), m_size(0), m_data(0) + { } + ~MVector() + { + clear(); + } + MVector(const MVector<T>& v) + :m_reserved(v.m_reserved), m_size(v.m_size) + { + m_data = (T*)malloc(sizeof(T)*m_reserved); + for (unsigned int i = 0; i < m_size; ++i) + { + new( &m_data[i] ) T (v.m_data[i]); + #if defined( _DEBUG_MEMORY ) + MercuryAFree( &m_data[i] ); + #endif + } + } + void push_back(const T& element); + inline unsigned int size() const { return m_size; } + inline bool empty() const { return m_size == 0; } + void resize(unsigned int newSize); + void reserve(unsigned int newSize); + inline T& operator[](unsigned int x) { return m_data[x]; } + inline const T& operator[](unsigned int x) const { return m_data[x]; } + inline T& at( unsigned int x ) { return m_data[x]; } + inline const T& at( unsigned int x ) const { return m_data[x]; } + const MVector<T>& operator=(const MVector<T>& v); + void clear(); + void remove( int iPlace ); + void insert( int iPlace, const T & data ); + private: + unsigned int m_reserved; //available space + unsigned int m_size; //number of valid (constructed) objects + T * m_data; +}; + +#include "MercuryUtil.h" + +template<typename T> +void MVector<T>::push_back(const T& element) +{ + if (m_size >= m_reserved) + { + if (m_reserved <= 0) + { + SAFE_FREE( m_data ); + m_data = (T*)malloc(sizeof(T)); + m_reserved = 1; + } + else + { + int tsize = nextPow2(m_reserved); + int size = m_size; + reserve(tsize); + m_size = size; + } + } + + new( &m_data[m_size] ) T ( element ); + + ++m_size; +} + +template<typename T> +void MVector<T>::resize(unsigned int newSize) +{ + if (newSize == 0) + { + clear(); + return; + } + //Fully reserve space and initalize constructors + //Make larger and reserve space + if (newSize == m_size) + { + return; + } + else if(newSize > m_size) + { + if (newSize > m_reserved) + { + m_reserved = newSize; + m_data = (T*)realloc(m_data, sizeof(T)*m_reserved); + } + + for (unsigned int i = m_size; i < newSize; ++i) + { + new (&m_data[i]) (T); + #if defined( _DEBUG_MEMORY ) + MercuryAFree( &m_data[i] ); + #endif + + } + } + else + { + //get smaller + m_reserved = newSize; + + //destroy data that will be lost + for (unsigned int i = m_reserved; i < m_size; ++i) + (&m_data[i])->~T(); + + m_data = (T*)realloc(m_data, sizeof(T)*m_reserved); + } + m_size = newSize; +} + +template<typename T> +void MVector<T>::reserve(unsigned int newSize) +{ + if (newSize == 0) + { + clear(); + return; + } + if (newSize == m_reserved) + { + return; + } + else if (newSize > m_reserved) + { + m_reserved = newSize; + m_data = (T*)realloc(m_data, sizeof(T)*m_reserved); + } + else + { + m_reserved = newSize; + + //destroy data that will be lost + for (unsigned int i = m_reserved; i < m_size; ++i) + (&m_data[i])->~T(); + + m_data = (T*)realloc(m_data, sizeof(T)*m_reserved); + m_size = newSize; + } +} + +template<typename T> +void MVector<T>::remove( int iPlace ) +{ + m_size--; + (&m_data[iPlace])->~T(); + for (unsigned long i = iPlace; i < m_size; ++i) + memcpy( &m_data[i], &m_data[i+1], sizeof(T) ); +} + +#include <stdio.h> +#include <new> +template<typename T> +void MVector<T>::insert( int iPlace, const T & data ) +{ + int i; + resize( m_size + 1 ); + + (&m_data[m_size-1])->~T(); + for( i = m_size - 1; i > iPlace; i-- ) + memcpy( &m_data[i], &m_data[i-1], sizeof (T) ); + + new ( &m_data[iPlace] ) T( data ); + #if defined( _DEBUG_MEMORY ) + MercuryAFree( &m_data[iPlace] ); + #endif + +} + +template<typename T> +void MVector<T>::clear() +{ + for (unsigned int i = 0; i < m_size; ++i) + (&m_data[i])->~T(); + + SAFE_FREE(m_data); + m_size = m_reserved = 0; +} +template<typename T> +const MVector<T>& MVector<T>::operator=(const MVector<T>& v) +{ + clear(); + m_reserved = v.m_reserved; + m_size = v.m_size; + m_data = (T*)malloc(sizeof(T)*m_reserved); + for (unsigned int i = 0; i < m_size; ++i) + { + new( &m_data[i]) T( v.m_data[i] ); +#if defined( _DEBUG_MEMORY ) + MercuryAFree( &m_data[i] ); +#endif + } + return *this; +} + + +#endif +/* + * Copyright (c) 2006-2009 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/ModuleManager.cpp =================================================================== --- Mercury2/src/ModuleManager.cpp (rev 0) +++ Mercury2/src/ModuleManager.cpp 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,125 @@ +#include <ModuleManager.h> +#include <XMLParser.h> + +#ifndef WIN32 +#include <dlfcn.h> +#else +#include <windows.h> + +//These are only synonyms for the POSIX stuff. +#define RTLD_NOW 0 +#define RTLD_GLOBAL 0 + +void * dlopen( const char * sFile, int dummy ) { return LoadLibrary( sFile ); } +void dlclose( void * handle ) { FreeLibrary( (HMODULE)handle ); } +void * dlsym( void * handle, const char * sym ) { return GetProcAddress( (HMODULE) handle, sym ); } + +#endif + + +extern "C" +{ +typedef int (*LoaderFunction)(); +}; + +ModuleManager::ModuleManager() +{ +} + +ModuleManager & ModuleManager::GetInstance() +{ + static ModuleManager *instance = NULL; + if (!instance) + instance = new ModuleManager(); + return *instance; +} + +void ModuleManager::InitializeAllModules() +{ + XMLDocument* doc = XMLDocument::Load("modules.xml"); + XMLNode r = doc->GetRootNode(); + for (XMLNode child = r.Child(); child.IsValid(); child = r.NextNode()) + { + if( child.Name() != "Module" ) + { + fprintf( stderr, "Invalid element in modules: %s\n", child.Name().c_str() ); + } +#ifdef WIN32 + MString ModuleName = child.Attribute( "obj" ) + ".dll"; +#else + MString ModuleName = child.Attribute( "obj" ) + ".so"; +#endif + MString LoadFunct = child.Attribute( "func" ); + LoadModule( ModuleName, LoadFunct ); + } +} + +void ModuleManager::UnloadModule( const MString & ModuleName ) +{ + if( m_hAllHandles[ModuleName] ) + dlclose( m_hAllHandles[ModuleName] ); +} + +bool ModuleManager::LoadModule( const MString & ModuleName, const MString & LoadFunction ) +{ + if( m_hAllHandles[ModuleName] ) UnloadModule( ModuleName ); + m_hAllHandles[ModuleName] = dlopen( ModuleName.c_str(), RTLD_NOW | RTLD_GLOBAL ); + + if( !m_hAllHandles[ModuleName] ) + { + fprintf( stderr, "Error opening: %s\n", ModuleName.c_str() ); + return false; + } + + //If no load funct, just exit early. + if( LoadFunction == "" ) + return true; + + LoaderFunction T = (LoaderFunction)dlsym( m_hAllHandles[ModuleName], LoadFunction.c_str() ); + if( !T ) + { + fprintf( stderr, "Error finding: %s() in %s\n", LoadFunction.c_str(), ModuleName.c_str() ); + return false; + } + + int ret = T(); + if( ret ) + { + fprintf( stderr, "Error executing (Returned error %d): %s() in %s\n", ret, LoadFunction.c_str(), ModuleName.c_str() ); + return false; + } + + return true; +} + +/**************************************************************************** + * 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/ModuleManager.h =================================================================== --- Mercury2/src/ModuleManager.h (rev 0) +++ Mercury2/src/ModuleManager.h 2009-05-26 02:23:47 UTC (rev 276) @@ -0,0 +1,59 @@ +#ifndef _MODULE_LOADER_H +#define _MODULE_LOADER_H + +#include <MercuryUtil.h> +#include <MercuryHash.h> + +/* This is the module loader mechanism. This allows for run-time loading of + new modules. Eventually, it will allow for run-time re-loading of modules. + For now, it uses modules to determine what to load at startup. */ + +class ModuleManager +{ +public: + ModuleManager(); + static ModuleManager & GetInstance(); + void InitializeAllModules(); + + bool LoadModule( const MString & ModuleName, const MString & LoadFunction ); + void UnloadModule( const MString & ModuleName ); + MHash< void * > m_hAllHandles; +}; + +static InstanceCounter<ModuleManager> ModMancounter("ModuleManager"); + + + +/**************************************************************************** + * 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. * + ***************************************************************************/ + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |