You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(38) |
Jun
(25) |
Jul
(16) |
Aug
(52) |
Sep
(1) |
Oct
(3) |
Nov
(18) |
Dec
(7) |
---|
From: <zcc...@us...> - 2009-08-05 10:42:41
|
Revision: 94 http://sirrf.svn.sourceforge.net/sirrf/?rev=94&view=rev Author: zccdark203 Date: 2009-08-05 10:42:35 +0000 (Wed, 05 Aug 2009) Log Message: ----------- The OctTreeComponent class now properly inherits from the MeshComponent class (just as in Irrlicht itself). Besides that I've also integrated the behaviour for dealing with asset groups into the OctTreeComponent class. And there are of course the usual minor fixes/improvements. Modified Paths: -------------- trunk/CHANGES trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/ImageComponent.cpp trunk/src/components/scene/ImageComponent.h trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/MeshComponent.h trunk/src/components/scene/OctTreeComponent.cpp trunk/src/components/scene/OctTreeComponent.h trunk/src/scripting/components/scene/asBillboardComponent.h trunk/src/scripting/components/scene/asMeshComponent.cpp trunk/src/scripting/components/scene/asMeshComponent.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/CHANGES 2009-08-05 10:42:35 UTC (rev 94) @@ -2,6 +2,9 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * The OctTreeComponent class now properly inherits from the + MeshComponent class. + * Made various minor changes to the ImageComponent class. Most noticeable is the way the clipping rectangle is handled. Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) @@ -51,7 +51,7 @@ mSceneNode = NULL; } -// Common initialization method. +// Common initialisation method. void AnimatedMeshComponent::init(const vector3df &rotation, const vector3df &scale) { // Get pointers to needed sub-systems of the Game Manager. Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-05 10:42:35 UTC (rev 94) @@ -142,7 +142,7 @@ private: // Private methods. - //! Common initialization method. + //! Common initialisation method. void init(const vector3df &rotation = vector3df(0, 0, 0), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/ImageComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) @@ -61,7 +61,7 @@ mTexture->drop(); } -// Common initialization method. +// Common initialisation method. void ImageComponent::init() { // Set misc. variables. Modified: trunk/src/components/scene/ImageComponent.h =================================================================== --- trunk/src/components/scene/ImageComponent.h 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/ImageComponent.h 2009-08-05 10:42:35 UTC (rev 94) @@ -128,7 +128,7 @@ private: // Private methods. - //! Common initialization method. + //! Common initialisation method. void init(); // Private members Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/MeshComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) @@ -44,6 +44,12 @@ setMesh(mesh); } +// MeshComponent constructor (derivatives). +MeshComponent::MeshComponent(Entity *parent, bool isDerived) +: SceneComponent(parent, true) +{ +} + // MeshComponent deconstructor. MeshComponent::~MeshComponent() { @@ -51,7 +57,7 @@ mSceneNode = NULL; } -// Common initialization method. +// Common initialisation method. void MeshComponent::init(const vector3df &rotation, const vector3df &scale) { // Get pointers to needed sub-systems of the Game Manager. @@ -139,49 +145,43 @@ // Parses for a MeshComponent. bool MeshComponent::parseXML(IXMLReader *file, Entity *entity) { - // Forward declaration. - MeshComponent *component = NULL; + // Forward declaration. + MeshComponent *component = NULL; - // Are we dealing with a MeshComponent? - if(file->getNodeType() == io::EXN_ELEMENT) - { - if(stringw("MeshComponent") == file->getNodeName()) - { - // Initialise the component. - component = new MeshComponent(entity); - } - } + // Are we dealing with a MeshComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("MeshComponent") == file->getNodeName()) + { + // Initialise the component. + component = new MeshComponent(entity); + } + } - if(component == NULL) - return false; + if(component == NULL) + return false; - // Continue parsing the file. - while(file->read()) - { - switch(file->getNodeType()) - { - case io::EXN_ELEMENT: + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: - // <mesh> - if(stringw("mesh") == file->getNodeName()) - { - stringc fileName = file->getAttributeValue(L"fileName"); - component->setMesh(fileName.c_str()); - } + // Derived elements. + if(!MeshComponent::parseBaseXML(file, component)) + SceneComponent::parseBaseXML(file, component); - // Derived elements. - else SceneComponent::parseBaseXML(file, component); + break; - break; + case io::EXN_ELEMENT_END: - case io::EXN_ELEMENT_END: + // </MeshComponent> + if(stringw("MeshComponent") == file->getNodeName()) + return true; - // </MeshComponent> - if(stringw("MeshComponent") == file->getNodeName()) - return true; + break; - break; - default: break; @@ -193,4 +193,20 @@ return false; } +// Parses for the base elements of a MeshComponent. +bool MeshComponent::parseBaseXML(IXMLReader *file, MeshComponent *component) +{ + // <mesh> + if(stringw("mesh") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + component->setMesh(fileName.c_str()); + + return true; + } + + // We couldn't find any known elements. + return false; +} + // End of File Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/MeshComponent.h 2009-08-05 10:42:35 UTC (rev 94) @@ -62,32 +62,40 @@ //! Loads and sets a new mesh to display. //! fileName Filename of the mesh to load. - void setMesh(const std::string &fileName); + virtual void setMesh(const std::string &fileName); //! Sets a new mesh to display. //! @param mesh Pointer to the loaded animated mesh to be displayed. //! @note Not available in AngelScript. - void setMesh(IMesh *mesh); + virtual void setMesh(IMesh *mesh); // Events //! Responds to changes of the mesh attached to this component. //! @note For internal use only! - void onMesh(void *p); + virtual void onMesh(void *p); //! Parses for a MeshComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); + //! Parses for the base elements of a MeshComponent. + //! @note For internal use only! + static bool parseBaseXML(IXMLReader *file, MeshComponent *component); +protected: + + // Initialisation + //! Constructor for derived classes. + MeshComponent(Entity *parent, bool isDerived); + + // Protected members + IMeshSceneNode *mMeshSN; + std::string mMeshFileName; + private: // Private methods. - //! Common initialization method. + //! Common initialisation method. void init(const vector3df &rotation = vector3df(0, 0, 0), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); - - // Members - IMeshSceneNode *mMeshSN; - - std::string mMeshFileName; }; #endif Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) @@ -20,60 +20,143 @@ // OctTreeComponent class +// OctTreeComponent constructor (default). +OctTreeComponent::OctTreeComponent(Entity *parent, s32 minPolysPerNode) +: MeshComponent(parent, true) +{ + init(minPolysPerNode); +} + // OctTreeComponent constructor. OctTreeComponent::OctTreeComponent(Entity *parent, const std::string &fileName, s32 minPolysPerNode) -: SceneComponent(parent, true) +: MeshComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - // Create the internal scene node. - IMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); - mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); - mSceneNode->setPosition(parent->getPosition()); - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(minPolysPerNode); + setMesh(fileName); } // OctTreeComponent constructor. OctTreeComponent::OctTreeComponent(Entity *parent, IMesh *mesh, s32 minPolysPerNode) -: SceneComponent(parent, true) +: MeshComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - // Create the internal scene node. - mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); - mSceneNode->setPosition(parent->getPosition()); - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(minPolysPerNode); + setMesh(mesh); } // OctTreeComponent constructor. OctTreeComponent::OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, s32 minPolysPerNode) -: SceneComponent(parent, true) +: MeshComponent(parent, true) { + init(minPolysPerNode); + setMesh(mesh); +} + +// OctTreeComponent deconstructor. +OctTreeComponent::~OctTreeComponent() +{ +} + +// Common initialisation method. +void OctTreeComponent::init(s32 minPolysPerNode) +{ // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); - mSceneNode->setPosition(parent->getPosition()); + mMeshSN = pSceneMgr->addOctTreeSceneNode((IMesh*)0, 0, pParent->getID(), minPolysPerNode, true); + mSceneNode = mMeshSN; + mSceneNode->setPosition(pParent->getPosition()); + // Misc. variables. + mMinPolysPerNode = minPolysPerNode; + // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); + mLocalMetaSelector = pSceneMgr->createMetaTriangleSelector(); + mTriSelector = mLocalMetaSelector; mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } -// OctTreeComponent deconstructor. -OctTreeComponent::~OctTreeComponent() +// Loads and sets a new mesh to display. +void OctTreeComponent::setMesh(const std::string &fileName) { + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + IMesh *mesh = 0; + + // Retrieve pointer to the mesh. + if(assets != NULL) + { + // Unsubscribe from previous asset. + assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); + + // Get mesh. + mesh = assets->getMesh(fileName); + + if(mesh) + { + assets->connectEventSignal(std::string("meshes/") + fileName, this, + &OctTreeComponent::onMesh); + mMeshFileName = fileName; + } + } + + else + mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); + + // Remove previous triangle selector. + mLocalMetaSelector->removeTriangleSelector(mOctTreeSelector); + + // Set mesh. + mMeshSN->setMesh(mesh); + + // Set new triangle selector. + mOctTreeSelector = GameManager::Instance()->getSceneManager()-> + createTriangleSelector(mesh, mMeshSN); + mLocalMetaSelector->addTriangleSelector(mOctTreeSelector); } +// Sets a new mesh to display. +void OctTreeComponent::setMesh(IMesh *mesh) +{ + // Check if we need to unsubscribe from an asset group mesh. + AssetGroup *assets = pParent->getAssetGroup(); + + if(assets != NULL) + { + assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); + mMeshFileName = ""; + } + + // Remove previous triangle selector. + mLocalMetaSelector->removeTriangleSelector(mOctTreeSelector); + + // Set mesh. + mMeshSN->setMesh(mesh); + + // Set new triangle selector. + mOctTreeSelector = GameManager::Instance()->getSceneManager()-> + createOctTreeTriangleSelector(mesh, mMeshSN, mMinPolysPerNode); + mLocalMetaSelector->addTriangleSelector(mOctTreeSelector); +} + +// Responds to changes of the mesh attached to this component. +void OctTreeComponent::onMesh(void *p) +{ + // Get pointer to the new mesh. + IMesh *mesh = &reinterpret_cast<IMesh*>(p)[0]; + + // Remove previous triangle selector. + mLocalMetaSelector->removeTriangleSelector(mOctTreeSelector); + + // Set new mesh. + mMeshSN->setMesh(mesh); + + // Set new triangle selector. + mOctTreeSelector = GameManager::Instance()->getSceneManager()-> + createOctTreeTriangleSelector(mesh, mMeshSN, mMinPolysPerNode); + mLocalMetaSelector->addTriangleSelector(mOctTreeSelector); +} + // Parses for a OctTreeComponent. bool OctTreeComponent::parseXML(IXMLReader *file, Entity *entity) { @@ -86,10 +169,10 @@ if(stringw("OctTreeComponent") == file->getNodeName()) { // Get attributes. - stringc fileName = file->getAttributeValue(L"fileName"); + f32 minPolysPerNode = file->getAttributeValueAsFloat(L"minPolysPerNode"); // Initialise the component. - component = new OctTreeComponent(entity, fileName.c_str()); + component = new OctTreeComponent(entity, minPolysPerNode); } } @@ -102,7 +185,8 @@ switch(file->getNodeType()) { // Derived elements. - SceneComponent::parseBaseXML(file, component); + if(!MeshComponent::parseBaseXML(file, component)) + SceneComponent::parseBaseXML(file, component); break; Modified: trunk/src/components/scene/OctTreeComponent.h =================================================================== --- trunk/src/components/scene/OctTreeComponent.h 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/components/scene/OctTreeComponent.h 2009-08-05 10:42:35 UTC (rev 94) @@ -18,16 +18,22 @@ // Include files #include "../../dependencies.h" -#include "SceneComponent.h" +#include "MeshComponent.h" // OctTreeComponent class //! Component wrapper of Irrlicht's SceneManager function addOctTreeSceneNode(...). -class OctTreeComponent : public SceneComponent +class OctTreeComponent : public MeshComponent { public: // Initialisation and deinitialisation + //! Constructor (default) + //! @param parent The parent entity to which the component should be added. + //! @param minPolysPerNode Specifies the minimal polygons contained a octree node. If a node + //! gets less polys than this value it will not be split into smaller + //! nodes. + OctTreeComponent(Entity *parent, s32 minPolysPerNode = 256); //! Constructor //! @param parent The parent entity to which the component should be added. //! @param fileName Filename of the mesh to load. @@ -54,9 +60,36 @@ //! Deconstructor ~OctTreeComponent(); + // Methods + //! Loads and sets a new mesh to display. + //! fileName Filename of the mesh to load. + void setMesh(const std::string &fileName); + //! Sets a new mesh to display. + //! @param mesh Pointer to the loaded animated mesh to be displayed. + //! @note Not available in AngelScript. + void setMesh(IMesh *mesh); + + // Events + //! Responds to changes of the mesh attached to this component. + //! @note For internal use only! + void onMesh(void *p); + + // XML //! Parses for a OctTreeComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); + +private: + + // Private methods + //! Common initialisation method. + void init(s32 minPolysPerNode); + + // Private members + ITriangleSelector *mOctTreeSelector; + IMetaTriangleSelector *mLocalMetaSelector; + + s32 mMinPolysPerNode; }; #endif Modified: trunk/src/scripting/components/scene/asBillboardComponent.h =================================================================== --- trunk/src/scripting/components/scene/asBillboardComponent.h 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/scripting/components/scene/asBillboardComponent.h 2009-08-05 10:42:35 UTC (rev 94) @@ -38,7 +38,7 @@ std::string sType = type; // Bind inherited functions. - bindSceneComponentBase<BillboardComponent>(engine, type); + bindSceneComponentBase<T>(engine, type); // Set common behaviour. r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, std::string(sType + "@ f(BillboardComponent @)").c_str(), Modified: trunk/src/scripting/components/scene/asMeshComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asMeshComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/scripting/components/scene/asMeshComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) @@ -19,11 +19,8 @@ #ifdef __COMPILE_WITH_ANGELSCRIPT__ #include "../../ScriptHelper.h" -#include "asSceneComponent.h" -#include "../../../components/scene/MeshComponent.h" - //! Reference factory for the MeshComponent class. MeshComponent* createMeshComponent(Entity *parent) { @@ -47,7 +44,7 @@ r = engine->RegisterObjectType("MeshComponent", sizeof(MeshComponent), asOBJ_REF); assert(r >= 0); // Bind inherited functions. - bindSceneComponentBase<MeshComponent>(engine, "MeshComponent"); + bindMeshComponentBase<MeshComponent>(engine, "MeshComponent"); // Set MeshComponent behaviour. r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_FACTORY, "MeshComponent@ f(Entity @+)", @@ -59,10 +56,6 @@ r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_ASSIGNMENT, "MeshComponent& f(const MeshComponent &in)", asFUNCTION(assignT<MeshComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); - - // Bind MeshComponent class functions. - r = engine->RegisterObjectMethod("MeshComponent", "void setMesh(const string &in)", - asMETHODPR(MeshComponent, setMesh, (const std::string&), void), asCALL_THISCALL); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/components/scene/asMeshComponent.h =================================================================== --- trunk/src/scripting/components/scene/asMeshComponent.h 2009-08-04 14:52:14 UTC (rev 93) +++ trunk/src/scripting/components/scene/asMeshComponent.h 2009-08-05 10:42:35 UTC (rev 94) @@ -19,12 +19,38 @@ // Include files #include "../../../dependencies.h" +#include "asSceneComponent.h" +#include "../../../components/scene/MeshComponent.h" + #ifdef __COMPILE_WITH_ANGELSCRIPT__ //! Binds the MeshComponent class to AngelScript. extern void bindMeshComponent(asIScriptEngine *engine); +//! Binds the base behaviours and methods of the MeshComponent to the given class in +//! AngelScript. +template<typename T> +void bindMeshComponentBase(asIScriptEngine *engine, const char *type) +{ + // Forward declaration. + int r; + std::string sType = type; + + // Bind inherited functions. + bindSceneComponentBase<T>(engine, type); + + // Set common behaviour. + r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, std::string(sType + "@ f(MeshComponent @)").c_str(), + asFUNCTION((asRefCast<MeshComponent,T>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, std::string("MeshComponent@ f(" + sType +" @)").c_str(), + asFUNCTION((asRefCast<T,MeshComponent>)), asCALL_CDECL); assert( r >= 0 ); + + // Bind common class functions. + r = engine->RegisterObjectMethod(type, "void setMesh(const string &in)", + asMETHODPR(T, setMesh, (const std::string&), void), asCALL_THISCALL); assert(r >= 0); +} + #endif // __COMPILE_WITH_ANGELSCRIPT__ #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-04 14:52:28
|
Revision: 93 http://sirrf.svn.sourceforge.net/sirrf/?rev=93&view=rev Author: zccdark203 Date: 2009-08-04 14:52:14 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Started with the integration of the asset management in all components. Currently AnimatedMeshComponent, BillboardComponent, CameraComponent, ImageComponent, LightComponent and MeshComponent have checked (but not necessarily adjusted). Furthermore minor changes have been applied to some of the named code in order to improve the organization of the code. Modified Paths: -------------- trunk/CHANGES trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/ImageComponent.cpp trunk/src/components/scene/ImageComponent.h trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/MeshComponent.h trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp trunk/src/scripting/components/scene/asImageComponent.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/CHANGES 2009-08-04 14:52:14 UTC (rev 93) @@ -2,6 +2,9 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Made various minor changes to the ImageComponent class. Most + noticeable is the way the clipping rectangle is handled. + * Fixed the disconnectEventSignal method in both the EventManager class and the HasEvents class. Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) @@ -23,19 +23,7 @@ AnimatedMeshComponent::AnimatedMeshComponent(Entity *parent) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - // Create the internal scene node. - mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(0, 0, parent->getID(), - parent->getPosition(), vector3df(0, 0, 0), - vector3df(1.0f, 1.0f, 1.0f), true); - mSceneNode = mAnimatedMeshSN; - mShadowVolumeSN = NULL; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mAnimatedMeshSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(); } // AnimatedMeshComponent constructor. @@ -43,19 +31,8 @@ const vector3df &rotation, const vector3df &scale) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - // Create the internal scene node. - mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(pSceneMgr->getMesh(fileName.c_str()), 0, - parent->getID(), parent->getPosition(), - rotation, scale, true); - mSceneNode = mAnimatedMeshSN; - mShadowVolumeSN = NULL; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mAnimatedMeshSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(rotation, scale); + setMesh(fileName); } // AnimatedMeshComponent constructor. @@ -63,25 +40,35 @@ const vector3df &rotation, const vector3df &scale) : SceneComponent(parent, true) { + init(rotation, scale); + setMesh(mesh); +} + +// AnimatedMeshComponent deconstructor. +AnimatedMeshComponent::~AnimatedMeshComponent() +{ + mAnimatedMeshSN->remove(); + mSceneNode = NULL; +} + +// Common initialization method. +void AnimatedMeshComponent::init(const vector3df &rotation, const vector3df &scale) +{ + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(mesh, 0, parent->getID(), - parent->getPosition(), rotation, scale, + // Create the internal scene node. + mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(0, 0, pParent->getID(), + pParent->getPosition(), rotation, scale, true); mSceneNode = mAnimatedMeshSN; + mShadowVolumeSN = NULL; // Set-up internal mechanism for collision detection. mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mAnimatedMeshSN); mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } -// AnimatedMeshComponent deconstructor. -AnimatedMeshComponent::~AnimatedMeshComponent() -{ - mAnimatedMeshSN->remove(); - mSceneNode = NULL; -} - // Returns a direct pointer to the IAnimatedMeshSceneNode. IAnimatedMeshSceneNode* AnimatedMeshComponent::getAnimatedMeshSceneNode() { @@ -163,27 +150,112 @@ // Loads and sets a new mesh to display. void AnimatedMeshComponent::setMesh(const std::string &fileName) { - IAnimatedMesh *mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); - if(mesh) - mAnimatedMeshSN->setMesh(mesh); + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + IAnimatedMesh *mesh = 0; + + // Retrieve pointer to the mesh. + if(assets != NULL) + { + // Unsubscribe from previous asset. + assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); + + // Get mesh. + mesh = assets->getMesh(fileName); + + if(mesh) + { + assets->connectEventSignal(std::string("meshes/") + fileName, this, + &AnimatedMeshComponent::onMesh); + mMeshFileName = fileName; + } + } + + else + mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); + + // Set mesh. + mAnimatedMeshSN->setMesh(mesh); } // Sets a new mesh to display. void AnimatedMeshComponent::setMesh(IAnimatedMesh *mesh) { + // Check if we need to unsubscribe from an asset group mesh. + AssetGroup *assets = pParent->getAssetGroup(); + + if(assets != NULL) + { + assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); + mMeshFileName = ""; + } + + // Set mesh. mAnimatedMeshSN->setMesh(mesh); } +// Sets the mesh of the IShadowVolumeSceneNode attached to this component. +void AnimatedMeshComponent::setShadowVolumeMesh(const std::string &fileName) +{ + // Did we already create a IShadowVolumeSceneNode? + if(mShadowVolumeSN) + { + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + IMesh *mesh = 0; + + // Retrieve pointer to the mesh. + if(assets != NULL) + { + // Unsubscribe from previous asset. + assets->disconnectEventSignal(std::string("meshes/") + mShadowVolumeMeshFileName, this); + + // Get mesh. + mesh = assets->getMesh(fileName); + + if(mesh) + { + assets->connectEventSignal(std::string("meshes/") + fileName, this, + &AnimatedMeshComponent::onShadowVolumeMesh); + mShadowVolumeMeshFileName = fileName; + } + } + + else + mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); + + // Set mesh. + mShadowVolumeSN->setShadowMesh(mesh); + } +} + +// Sets the mesh of the IShadowVolumeSceneNode attached to this component. +void AnimatedMeshComponent::setShadowVolumeMesh(IMesh *mesh) +{ + // Check if we need to unsubscribe from an asset group mesh. + AssetGroup *assets = pParent->getAssetGroup(); + + if(assets != NULL) + { + assets->disconnectEventSignal(std::string("meshes/") + mShadowVolumeMeshFileName, this); + mShadowVolumeMeshFileName = ""; + } + + // Set mesh. + mShadowVolumeSN->setShadowMesh(mesh); +} + // Loads and sets a new IShadowVolumeSceneNode to the component. void AnimatedMeshComponent::setShadowVolumeSceneNode(const std::string &fileName, bool zfailmethod, f32 infinity) { if(!mShadowVolumeSN) { - IMesh *mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); - if(mesh) - mShadowVolumeSN = mAnimatedMeshSN->addShadowVolumeSceneNode(mesh, pParent->getID(), + // Create the shadow volume scene node. + mShadowVolumeSN = mAnimatedMeshSN->addShadowVolumeSceneNode(0, pParent->getID(), zfailmethod, infinity); + + setShadowVolumeMesh(fileName); } } @@ -203,6 +275,26 @@ mAnimatedMeshSN->setTransitionTime(time); } +// Responds to changes of the mesh attached to this component. +void AnimatedMeshComponent::onMesh(void *p) +{ + // Get pointer to the new mesh. + IAnimatedMesh *mesh = &reinterpret_cast<IAnimatedMesh*>(p)[0]; + + // Set new mesh. + mAnimatedMeshSN->setMesh(mesh); +} + +// Responds to changes of the mesh attached to the shadow volume scene node of this component. +void AnimatedMeshComponent::onShadowVolumeMesh(void *p) +{ + // Get pointer to the new mesh. + IMesh *mesh = &reinterpret_cast<IMesh*>(p)[0]; + + // Set new mesh. + mShadowVolumeSN->setShadowMesh(mesh); +} + // Parses for a AnimatedMeshComponent. bool AnimatedMeshComponent::parseXML(IXMLReader *file, Entity *entity) { Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-04 14:52:14 UTC (rev 93) @@ -100,6 +100,14 @@ //! @param mesh Pointer to the loaded animated mesh to be displayed. //! @note Not available in AngelScript. void setMesh(IAnimatedMesh *mesh); + //! Sets the mesh of the IShadowVolumeSceneNode attached to this component. + //! @param fileName Filename of the mesh to load. + //! @note You must first call setShadowVolumeSceneNode! + void setShadowVolumeMesh(const std::string &fileName); + //! Sets the mesh of the IShadowVolumeSceneNode attached to this component. + //! @param mesh Pointer to the loaded mesh to be used. + //! @note You must first call setShadowVolumeSceneNode! + void setShadowVolumeMesh(IMesh *mesh); //! Loads and sets a new IShadowVolumeSceneNode to the component. //! @param fileName Filename of the mesh to load. //! @param zfailmethod If set to true, the shadow will use the zfail method, if not, @@ -119,15 +127,31 @@ //! @param time Transition time in seconds. void setTransitionTime(f32 time); + // Events + //! Responds to changes of the mesh attached to this component. + //! @note For internal use only! + void onMesh(void *p); + //! Responds to changes of the mesh attached to the shadow volume scene node of this component. + //! @note For internal use only! + void onShadowVolumeMesh(void *p); + //! Parses for a AnimatedMeshComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); private: + // Private methods. + //! Common initialization method. + void init(const vector3df &rotation = vector3df(0, 0, 0), + const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); + // Members IAnimatedMeshSceneNode *mAnimatedMeshSN; IShadowVolumeSceneNode *mShadowVolumeSN; + + std::string mMeshFileName; + std::string mShadowVolumeMeshFileName; }; #endif Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/components/scene/ImageComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) @@ -21,58 +21,49 @@ // ImageComponent class // ImageComponent constructor (default) ImageComponent::ImageComponent(Entity *parent) -: EntityComponent(parent), mTexture(NULL), mAlphaColor(SColor(255, 255, 255, 255)), mClipRect(NULL), - mColor(SColor(255, 255, 255, 255)), mPosition(vector2di(0, 0)), - mSourceRect(rect<s32>(0, 0, 0, 0)), mVisible(true), mUseAlphaColor(false) +: EntityComponent(parent), mTexture(NULL), mPosition(vector2di(0, 0)), + mSourceRect(rect<s32>(0, 0, 0, 0)), mClipRect(rect<s32>(0, 0, 0, 0)), + mColor(SColor(255, 255, 255, 255)), mAlphaColor(SColor(255, 255, 255, 255)), mVisible(true), + mUseAlphaColor(false) { - // Set misc. variables. - mName = "ImageComponent"; - - // Register events. - pParent->connectEventSignal("onRender", this, &ImageComponent::onRender); - pParent->connectEventSignal("onPause", this, &ImageComponent::onPause); - pParent->connectEventSignal("onUnPause", this, &ImageComponent::onUnPause); + init(); } // ImageComponent constructor. ImageComponent::ImageComponent(Entity *parent, const std::string &fileName, const vector2di &position, const rect<s32> &sourceRect, - rect<s32> *clipRect, const SColor &color, + const rect<s32> &clipRect, const SColor &color, const SColor &alphaColor, bool useAlphaColor) -: EntityComponent(parent), mAlphaColor(alphaColor), mClipRect(NULL), mColor(color), - mPosition(position), mSourceRect(sourceRect), mVisible(true), mUseAlphaColor(useAlphaColor) +: EntityComponent(parent), mPosition(position), mSourceRect(sourceRect), mClipRect(clipRect), + mColor(color), mAlphaColor(alphaColor), mVisible(true), mUseAlphaColor(useAlphaColor) { - // Load the texture. - mTexture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); - - // Set the clip rect. - if(clipRect != NULL) - mClipRect = new rect<s32>(*clipRect); - - // Set misc. variables. - mName = "ImageComponent"; - - // Register events. - pParent->connectEventSignal("onRender", this, &ImageComponent::onRender); - pParent->connectEventSignal("onPause", this, &ImageComponent::onPause); - pParent->connectEventSignal("onUnPause", this, &ImageComponent::onUnPause); + init(); + setTexture(fileName); } // ImageComponent constructor. ImageComponent::ImageComponent(Entity *parent, ITexture *texture, const vector2di &position, const rect<s32> &sourceRect, - rect<s32> *clipRect, const SColor &color, + const rect<s32> &clipRect, const SColor &color, const SColor &alphaColor, bool useAlphaColor) -: EntityComponent(parent), mAlphaColor(alphaColor), mClipRect(clipRect), mColor(color), - mPosition(position), mSourceRect(sourceRect), mVisible(true), mUseAlphaColor(useAlphaColor) +: EntityComponent(parent), mPosition(position), mSourceRect(sourceRect), mClipRect(clipRect), + mColor(color), mAlphaColor(alphaColor), mVisible(true), mUseAlphaColor(useAlphaColor) { - // Load the texture. - mTexture = texture; + init(); + setTexture(texture); +} - // Set the clip rect. - if(clipRect != NULL) - mClipRect = new rect<s32>(*clipRect); +// ImageComponent deconstructor. +ImageComponent::~ImageComponent() +{ + if(mTexture) + mTexture->drop(); +} + +// Common initialization method. +void ImageComponent::init() +{ // Set misc. variables. mName = "ImageComponent"; @@ -82,12 +73,6 @@ pParent->connectEventSignal("onUnPause", this, &ImageComponent::onUnPause); } - -// ImageComponent deconstructor. -ImageComponent::~ImageComponent() -{ -} - // Gets the alpha color. const SColor& ImageComponent::getAlphaColor() const { @@ -95,7 +80,7 @@ } // Gets the clipping rectangle. -const rect<s32>* ImageComponent::getClipRect() const +const rect<s32>& ImageComponent::getClipRect() const { return mClipRect; } @@ -140,16 +125,9 @@ } // Sets where the image is clipped to. -void ImageComponent::setClipRect(rect<s32> *rectangle) +void ImageComponent::setClipRect(const rect<s32> &rectangle) { - if(mClipRect != NULL) - { - delete mClipRect; - mClipRect = NULL; - } - - if(rectangle != NULL) - mClipRect = new rect<s32>(*rectangle); + mClipRect = rectangle; } // Sets the color with which the image is drawn. @@ -173,19 +151,68 @@ // Loads a texture from the given file and sets it as the texture to be drawn. void ImageComponent::setTexture(const std::string &fileName) { - mTexture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); + // Drop reference to previous texture. + if(mTexture) + mTexture->drop(); + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + ITexture *texture = 0; + + // Retrieve pointer to the texture. + if(assets != NULL) + { + // Unsubscribe from previous asset. + assets->disconnectEventSignal(std::string("textures/") + mTextureFileName, this); + + // Get texture. + texture = assets->getTexture(fileName); + + if(texture) + { + assets->connectEventSignal(std::string("textures/") + fileName, this, + &ImageComponent::onTexture); + mTextureFileName = fileName; + } + } + + else + texture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); + + // Set texture. + mTexture = texture; + if(mTexture) - GameManager::Instance()->getDriver()->makeColorKeyTexture(mTexture, mAlphaColor); + { + GameManager::Instance()->getDriver()->makeColorKeyTexture(mTexture, mAlphaColor); + mTexture->grab(); + } } // Sets the texture which should be drawn. void ImageComponent::setTexture(ITexture *texture) { + // Drop reference to previous texture. + if(mTexture) + mTexture->drop(); + + // Check if we need to unsubscribe from an asset group texture. + AssetGroup *assets = pParent->getAssetGroup(); + + if(assets != NULL) + { + assets->disconnectEventSignal(std::string("textures/") + mTextureFileName, this); + mTextureFileName = ""; + } + + // Set texture. mTexture = texture; if(mTexture) - GameManager::Instance()->getDriver()->makeColorKeyTexture(mTexture, mAlphaColor); + { + GameManager::Instance()->getDriver()->makeColorKeyTexture(mTexture, mAlphaColor); + mTexture->grab(); + } } // Sets whether the alpha color should be used. @@ -202,7 +229,7 @@ if(mTexture && mVisible) { IVideoDriver *driver = GameManager::Instance()->getDriver(); - driver->draw2DImage(mTexture, mPosition, mSourceRect, mClipRect, mColor, mUseAlphaColor); + driver->draw2DImage(mTexture, mPosition, mSourceRect, &mClipRect, mColor, mUseAlphaColor); } } @@ -218,6 +245,24 @@ mVisible = mWasVisible; } +// Responds to changes of the texture attached to this component. +void ImageComponent::onTexture(void *p) +{ + // Get pointer to the new texture. + ITexture *texture = &reinterpret_cast<ITexture*>(p)[0]; + + // Drop reference to previous texture. + if(mTexture) // Technically unneeded, but rather safe than sorry. + mTexture->drop(); + + // Set new texture. + mTexture = texture; + + // Get reference to the new texture. + if(mTexture) + mTexture->grab(); +} + // Parses for a ImageComponent. bool ImageComponent::parseXML(IXMLReader *file, Entity *entity) { @@ -261,7 +306,7 @@ file->getAttributeValueAsInt(L"x2"), file->getAttributeValueAsInt(L"y2") ); - component->setClipRect(&clipRect); + component->setClipRect(clipRect); } // <color> Modified: trunk/src/components/scene/ImageComponent.h =================================================================== --- trunk/src/components/scene/ImageComponent.h 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/components/scene/ImageComponent.h 2009-08-04 14:52:14 UTC (rev 93) @@ -42,7 +42,7 @@ //! @param alphaColor Alpha color of the image. //! @param useAlphaColor If true, the alpha channel of the texture is used to draw the image. ImageComponent(Entity *parent, const std::string &fileName, const vector2di &position, - const rect<s32> &sourceRect, rect<s32> *clipRect = NULL, + const rect<s32> &sourceRect, const rect<s32> &clipRect, const SColor &color = SColor(255, 255, 255, 255), const SColor &alphaColor = SColor(255, 255, 255, 255), bool useAlphaColor = false); @@ -57,7 +57,7 @@ //! @param alphaColor Alpha color of the image. //! @param useAlphaColor If true, the alpha channel of the texture is used to draw the image. ImageComponent(Entity *parent, ITexture *texture, const vector2di &position, - const rect<s32> &sourceRect, rect<s32> *clipRect = NULL, + const rect<s32> &sourceRect, const rect<s32> &clipRect, const SColor &color = SColor(255, 255, 255, 255), const SColor &alphaColor = SColor(255, 255, 255, 255), bool useAlphaColor = false); @@ -68,7 +68,7 @@ //! Gets the alpha color. const SColor& getAlphaColor() const; //! Gets the clipping rectangle. - const rect<s32>* getClipRect() const; + const rect<s32>& getClipRect() const; //! Gets the color with which the image is drawn. const SColor& getColor() const; //! Gets the upper left 2d screen position where the image will be drawn. @@ -86,7 +86,7 @@ //! Sets where the image is clipped to. //! @param rectangle Pointer to rectangle on the screen where the image is clipped to. //! If this pointer is NULL the image is not clipped. - void setClipRect(rect<s32> *rectangle); + void setClipRect(const rect<s32> &rectangle); //! Sets the color with which the image is drawn. //! @param color New color. void setColor(const SColor &color); @@ -117,6 +117,9 @@ //! Unpauses the component if the parent is unpaused. //! @note For internal use only! void onUnPause(void *p); + //! Responds to changes of the texture attached to this component. + //! @note For internal use only! + void onTexture(void *p); //! Parses for a ImageComponent. //! @note For internal use only! @@ -124,19 +127,24 @@ private: + // Private methods. + //! Common initialization method. + void init(); + // Private members ITexture *mTexture; - SColor mAlphaColor; - rect<s32> *mClipRect; - SColor mColor; vector2di mPosition; rect<s32> mSourceRect; + rect<s32> mClipRect; + SColor mColor; + SColor mAlphaColor; bool mVisible; bool mUseAlphaColor; bool mWasVisible; + std::string mTextureFileName; }; #endif Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/components/scene/MeshComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) @@ -23,17 +23,7 @@ MeshComponent::MeshComponent(Entity *parent) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - // Create the internal scene node. - mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, parent->getID(), parent->getPosition(), - vector3df(0, 0, 0), vector3df(1.0f, 1.0f, 1.0f), true); - mSceneNode = mMeshSN; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mMeshSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(); } // MeshComponent constructor. @@ -41,18 +31,8 @@ const vector3df &rotation, const vector3df &scale) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - // Create the internal scene node. - mMeshSN = pSceneMgr->addMeshSceneNode(pSceneMgr->getMesh(fileName.c_str()), 0, - parent->getID(), parent->getPosition(), rotation, scale, - true); - mSceneNode = mMeshSN; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mMeshSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(rotation, scale); + setMesh(fileName); } // MeshComponent constructor. @@ -60,11 +40,25 @@ const vector3df &scale) : SceneComponent(parent, true) { + init(rotation, scale); + setMesh(mesh); +} + +// MeshComponent deconstructor. +MeshComponent::~MeshComponent() +{ + mMeshSN->remove(); + mSceneNode = NULL; +} + +// Common initialization method. +void MeshComponent::init(const vector3df &rotation, const vector3df &scale) +{ // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mMeshSN = pSceneMgr->addMeshSceneNode(mesh, 0, parent->getID(), parent->getPosition(), rotation, + mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, pParent->getID(), pParent->getPosition(), rotation, scale, true); mSceneNode = mMeshSN; @@ -73,13 +67,6 @@ mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } -// MeshComponent deconstructor. -MeshComponent::~MeshComponent() -{ - mMeshSN->remove(); - mSceneNode = NULL; -} - // Returns a direct pointer to the IMeshSceneNode. IMeshSceneNode* MeshComponent::getMeshSceneNode() { @@ -105,12 +92,13 @@ // Unsubscribe from previous asset. assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); + // Get mesh. mesh = assets->getMesh(fileName); if(mesh) { assets->connectEventSignal(std::string("meshes/") + fileName, this, - &MeshComponent::onMeshAsset); + &MeshComponent::onMesh); mMeshFileName = fileName; } } @@ -125,11 +113,21 @@ // Sets a new mesh to display. void MeshComponent::setMesh(IMesh *mesh) { + // Check if we need to unsubscribe from an asset group mesh. + AssetGroup *assets = pParent->getAssetGroup(); + + if(assets != NULL) + { + assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); + mMeshFileName = ""; + } + + // Set mesh. mMeshSN->setMesh(mesh); } -// Responds to changes of a loaded mesh from the asset management. -void MeshComponent::onMeshAsset(void *p) +// Responds to changes of the mesh attached to this component. +void MeshComponent::onMesh(void *p) { // Get pointer to the new mesh. IMesh *mesh = &reinterpret_cast<IMesh*>(p)[0]; Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/components/scene/MeshComponent.h 2009-08-04 14:52:14 UTC (rev 93) @@ -68,9 +68,10 @@ //! @note Not available in AngelScript. void setMesh(IMesh *mesh); - //! Responds to changes of a loaded mesh from the asset management. + // Events + //! Responds to changes of the mesh attached to this component. //! @note For internal use only! - void onMeshAsset(void *p); + void onMesh(void *p); //! Parses for a MeshComponent. //! @note For internal use only! @@ -78,6 +79,11 @@ private: + // Private methods. + //! Common initialization method. + void init(const vector3df &rotation = vector3df(0, 0, 0), + const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); + // Members IMeshSceneNode *mMeshSN; Modified: trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) @@ -89,6 +89,9 @@ r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setMesh(const string &in)", asMETHODPR(AnimatedMeshComponent, setMesh, (const std::string&), void), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setShadowVolumeMesh(const string &in)", + asMETHODPR(AnimatedMeshComponent, setShadowVolumeMesh, (const std::string&), void), + asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setShadowVolumeSceneNode(const string &in, " \ "bool, f32)", asMETHODPR(AnimatedMeshComponent, setShadowVolumeSceneNode, (const std::string&, bool, f32), void), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/components/scene/asImageComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asImageComponent.cpp 2009-08-04 12:00:11 UTC (rev 92) +++ trunk/src/scripting/components/scene/asImageComponent.cpp 2009-08-04 14:52:14 UTC (rev 93) @@ -33,7 +33,7 @@ //! Reference factory for the ImageComponent clas. ImageComponent* createImageComponent(Entity *parent, const std::string &fileName, const vector2di &position, const rect<s32> &sourceRect, - rect<s32> *clipRect, const SColor &color, + const rect<s32> &clipRect, const SColor &color, const SColor &alphaColor, bool useAlphaColor) { return new ImageComponent(parent, fileName, position, sourceRect, clipRect, color, alphaColor, @@ -61,10 +61,10 @@ r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_FACTORY, "ImageComponent@ f(Entity @+)", asFUNCTIONPR(createImageComponent, (Entity*), ImageComponent*), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_FACTORY, "ImageComponent@ f(Entity @+, " \ - "const string &in, const vector2di &in, const recti &in, recti &in, " \ + "const string &in, const vector2di &in, const recti &in, const recti &in, " \ "const SColor &in, const SColor &in, bool)", asFUNCTIONPR(createImageComponent, (Entity*, const std::string&, - const vector2di&, const rect<s32>&, rect<s32>*, const SColor&, + const vector2di&, const rect<s32>&, const rect<s32>&, const SColor&, const SColor&, bool), ImageComponent*), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_ASSIGNMENT, "ImageComponent& f(const ImageComponent &in)", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-04 12:00:18
|
Revision: 92 http://sirrf.svn.sourceforge.net/sirrf/?rev=92&view=rev Author: zccdark203 Date: 2009-08-04 12:00:11 +0000 (Tue, 04 Aug 2009) Log Message: ----------- Derived the AssetGroup class from the HasEvents class. I also immediately added all the code that the AssetGroup class needed to handle the event management. Besides yesterdays integration, of the AssetGroup class and entities and their components, has been extended to benefit from the AssetGroup events. So far only MeshComponent is affected by this. Modified Paths: -------------- trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/MeshComponent.h trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-08-03 19:44:43 UTC (rev 91) +++ trunk/src/components/scene/MeshComponent.cpp 2009-08-04 12:00:11 UTC (rev 92) @@ -103,12 +103,16 @@ if(assets != NULL) { // Unsubscribe from previous asset. - //assets->disconnectEventSignal + assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); mesh = assets->getMesh(fileName); - //if(mesh) - //assets->connectEventSingal + if(mesh) + { + assets->connectEventSignal(std::string("meshes/") + fileName, this, + &MeshComponent::onMeshAsset); + mMeshFileName = fileName; + } } else @@ -124,6 +128,16 @@ mMeshSN->setMesh(mesh); } +// Responds to changes of a loaded mesh from the asset management. +void MeshComponent::onMeshAsset(void *p) +{ + // Get pointer to the new mesh. + IMesh *mesh = &reinterpret_cast<IMesh*>(p)[0]; + + // Set new mesh. + mMeshSN->setMesh(mesh); +} + // Parses for a MeshComponent. bool MeshComponent::parseXML(IXMLReader *file, Entity *entity) { Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-08-03 19:44:43 UTC (rev 91) +++ trunk/src/components/scene/MeshComponent.h 2009-08-04 12:00:11 UTC (rev 92) @@ -68,6 +68,10 @@ //! @note Not available in AngelScript. void setMesh(IMesh *mesh); + //! Responds to changes of a loaded mesh from the asset management. + //! @note For internal use only! + void onMeshAsset(void *p); + //! Parses for a MeshComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); @@ -76,6 +80,8 @@ // Members IMeshSceneNode *mMeshSN; + + std::string mMeshFileName; }; #endif Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-03 19:44:43 UTC (rev 91) +++ trunk/src/core/AssetGroup.cpp 2009-08-04 12:00:11 UTC (rev 92) @@ -24,7 +24,7 @@ // AssetGroup constructor. AssetGroup::AssetGroup(const std::string &name, const std::string &dirName) -: mName(name) +: mName(name), mIsReloading(false) { mID = mIDCount++; mBaseDir = (GameManager::Instance()->getDevice()->getFileSystem() @@ -103,8 +103,19 @@ if(mesh) { + // Store the mesh. mMeshes[fileName] = mesh; mesh->grab(); + + // Remove the mesh from Irrlicht's global mesh cache. + GameManager::Instance()->getSceneManager()->getMeshCache()->removeMesh(mesh); + + // Handle events. + if(mIsReloading) + emitEvent(std::string("meshes/") + fileName, mesh); + + else + createEventSlot(std::string("meshes/") + fileName); } // Clean up. @@ -145,8 +156,19 @@ if(mesh) { + // Store the mesh. mMeshes[fileName] = mesh; mesh->grab(); + + // Remove the mesh from Irrlicht's global mesh cache. + GameManager::Instance()->getSceneManager()->getMeshCache()->removeMesh(mesh); + + // Handle events. + if(mIsReloading) + emitEvent(std::string("meshes/") + fileName, mesh); + + else + createEventSlot(std::string("meshes/") + fileName); } } @@ -178,8 +200,16 @@ if(script->loadScript(fileName)) { + // Store scripts. mScripts[fileName] = script; cout << "Loaded script: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + emitEvent(std::string("scripts/") + fileName, script); + + else + createEventSlot(std::string("scripts/") + fileName); } else @@ -206,7 +236,7 @@ if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) return; - if(!fileSystem->changeWorkingDirectoryTo("./textures/")) + if(!fileSystem->changeWorkingDirectoryTo("./scripts/")) return; // Read the textures. @@ -225,8 +255,16 @@ if(script->loadScript(fileName)) { + // Store script. mScripts[fileName] = script; cout << "Loaded script: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + emitEvent(std::string("scripts/") + fileName, script); + + else + createEventSlot(std::string("scripts/") + fileName); } else delete script; @@ -262,6 +300,7 @@ if(file) { + // Retrieve data. long fSize = file->getSize(); c8 *fBuffer = new c8[fSize+1]; memset(fBuffer, 0, fSize+1); @@ -269,9 +308,16 @@ file->read(fBuffer, fSize); file->drop(); + // Store data. mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded sound: " << fileName << "\n"; - cout << "Loaded sound: " << fileName << "\n"; + // Handle events. + if(mIsReloading) + emitEvent(std::string("sounds/") + fileName, &mSounds[fileName]); + + else + createEventSlot(std::string("sounds/") + fileName); } // Clean up. @@ -311,6 +357,7 @@ if(file) { + // Retrieve data. long fSize = file->getSize(); c8 *fBuffer = new c8[fSize+1]; memset(fBuffer, 0, fSize+1); @@ -318,9 +365,16 @@ file->read(fBuffer, fSize); file->drop(); + // Store data. mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded script: " << fileName << "\n"; - cout << "Loaded script: " << fileName << "\n"; + // Handle events. + if(mIsReloading) + emitEvent(std::string("sounds/") + fileName, &mSounds[fileName]); + + else + createEventSlot(std::string("sounds/") + fileName); } } @@ -353,8 +407,19 @@ if(texture) { + // Store texture. mTextures[fileName] = texture; texture->grab(); + + // Remove the texture from the internal driver. + GameManager::Instance()->getDriver()->removeTexture(texture); + + // Handle events. + if(mIsReloading) + emitEvent(std::string("textures/") + fileName, texture); + + else + createEventSlot(std::string("textures/") + fileName); } // Clean up. @@ -395,8 +460,19 @@ if(texture) { + // Store texture. mTextures[fileName] = texture; texture->grab(); + + // Remove the texture from the internal driver. + GameManager::Instance()->getDriver()->removeTexture(texture); + + // Handle events. + if(mIsReloading) + emitEvent(std::string("textures/") + fileName, texture); + + else + createEventSlot(std::string("textures/") + fileName); } } @@ -509,22 +585,36 @@ void AssetGroup::reloadAssets() { // Remove assets. + mIsReloading = true; + removeAssets(); loadAssets(); + + mIsReloading = false; } // Reloads the mesh with the given filename. bool AssetGroup::reloadMesh(const std::string &fileName) { + mIsReloading = true; + removeMesh(fileName); - return loadMesh(fileName); + bool succeeded = loadMesh(fileName); + + mIsReloading = false; + + return succeeded; } // Reloads all meshes in this asset group. void AssetGroup::reloadMeshes() { + mIsReloading = true; + removeMeshes(); loadMeshes(); + + mIsReloading = false; } #ifdef __COMPILE_WITH_ANGELSCRIPT__ @@ -532,15 +622,25 @@ // Reloads the script with the given filename. bool AssetGroup::reloadScript(const std::string &fileName) { + mIsReloading = true; + removeScript(fileName); - return loadScript(fileName); + bool succeeded = loadScript(fileName); + + mIsReloading = false; + + return succeeded; } // Reloads all script in this asset group. void AssetGroup::reloadScripts() { + mIsReloading = true; + removeScripts(); loadScripts(); + + mIsReloading = false; } #endif // __COMPILE_WITH_ANGELSCRIPT__ @@ -550,15 +650,25 @@ // Reloads the sound with the given filename. bool AssetGroup::reloadSound(const std::string &fileName) { + mIsReloading = true; + removeSound(fileName); - return loadSound(fileName); + bool succeeded = loadSound(fileName); + + mIsReloading = false; + + return succeeded; } // Reloads all sounds in this asset group. void AssetGroup::reloadSounds() { + mIsReloading = true; + removeSounds(); loadSounds(); + + mIsReloading = false; } #endif // __COMPILE_WITH_SFML_AUDIO__ @@ -566,15 +676,25 @@ // Reloads the texture with the given filename. bool AssetGroup::reloadTexture(const std::string &fileName) { + mIsReloading = true; + removeTexture(fileName); - return loadTexture(fileName); + bool succeeded = loadTexture(fileName); + + mIsReloading = false; + + return succeeded; } // Reloads all textures in this asset group. void AssetGroup::reloadTextures() { + mIsReloading = true; + removeTextures(); loadTextures(); + + mIsReloading = false; } // Removes the asset with the given name. @@ -656,9 +776,17 @@ // Did we find the mesh? if(mesh == it->second) { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("meshes/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + // Delete the mesh. mesh->drop(); - GameManager::Instance()->getSceneManager()->getMeshCache()->removeMesh(mesh); mMeshes.erase(it); return true; @@ -678,12 +806,18 @@ // Did we find the mesh? if(it != mMeshes.end()) { - // Get pointer to the found mesh. - IAnimatedMesh *mesh = it->second; + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("meshes/") + it->first; + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + // Delete the mesh. + IAnimatedMesh *mesh = it->second; mesh->drop(); - GameManager::Instance()->getSceneManager()->getMeshCache()->removeMesh(mesh); mMeshes.erase(it); return true; @@ -696,18 +830,23 @@ // Removes all meshes from this asset group. void AssetGroup::removeMeshes() { - // Get a pointer to the mesh cache. - IMeshCache *pMeshCache = GameManager::Instance()->getSceneManager()->getMeshCache(); - // Delete the meshes. std::map<std::string, IAnimatedMesh*>::iterator it; for(it = mMeshes.begin(); it != mMeshes.end(); it++) { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("meshes/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + + // Delete the mesh. IAnimatedMesh *mesh = it->second; - mesh->drop(); - pMeshCache->removeMesh(mesh); } // Clear the mesh map. @@ -727,6 +866,15 @@ // Did we find the script? if(script == it->second) { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("scripts/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + // Delete the script. script->drop(); mScripts.erase(it); @@ -748,10 +896,17 @@ // Did we find the script? if(it != mScripts.end()) { - // Get pointer to the found script. - Script *script = it->second; + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("scripts/") + it->first; + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + // Delete the script. + Script *script = it->second; script->drop(); mScripts.erase(it); @@ -770,6 +925,16 @@ for(it = mScripts.begin(); it != mScripts.end(); it++) { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("scripts/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + + // Delete the script. Script *script = it->second; script->drop(); } @@ -791,10 +956,17 @@ // Did we find the sound? if(it != mSounds.end()) { - // Get reference to the internal buffer. + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("sounds/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + + // Delete the sound. c8 *fBuffer = (it->second).first; - - // Delete the script. delete [] fBuffer; mSounds.erase(it); @@ -813,6 +985,16 @@ for(it = mSounds.begin(); it != mSounds.end(); it++) { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("sounds/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + + // Delete the sound. c8 *fBuffer = (it->second).first; delete [] fBuffer; } @@ -834,9 +1016,17 @@ // Did we find the texture? if(texture == it->second) { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("textures/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + // Delete the texture. texture->drop(); - GameManager::Instance()->getDriver()->removeTexture(texture); mTextures.erase(it); return true; @@ -856,12 +1046,18 @@ // Did we find the texture? if(it != mTextures.end()) { - // Get pointer to the found texture. - ITexture *texture = it->second; + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("textures/") + it->first; + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + // Delete the texture. + ITexture *texture = it->second; texture->drop(); - GameManager::Instance()->getDriver()->removeTexture(texture); mTextures.erase(it); return true; @@ -874,18 +1070,23 @@ // Removes all textures from this asset group. void AssetGroup::removeTextures() { - // Get a pointer to the driver.. - IVideoDriver *pDriver = GameManager::Instance()->getDriver(); - // Delete the textures. std::map<std::string, ITexture*>::iterator it; for(it = mTextures.begin(); it != mTextures.end(); it++) { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("textures/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + + // Delete the texture. ITexture *texture = it->second; - texture->drop(); - pDriver->removeTexture(texture); } // Clear the texture map. Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-08-03 19:44:43 UTC (rev 91) +++ trunk/src/core/AssetGroup.h 2009-08-04 12:00:11 UTC (rev 92) @@ -18,6 +18,7 @@ // Include files #include "../dependencies.h" +#include "HasEvents.h" #include "ReferenceCounted.h" #ifdef __COMPILE_WITH_ANGELSCRIPT__ @@ -27,7 +28,7 @@ // AssetGroup class //! Represents a collection of assets (meshes, textures, etc). -class AssetGroup : public ReferenceCounted +class AssetGroup : public ReferenceCounted, public HasEvents { public: @@ -182,6 +183,8 @@ #ifdef __COMPILE_WITH_SFML_AUDIO__ std::map<std::string, std::pair<c8*, long> > mSounds; #endif // __COMPILE_WITH_SFML_AUDIO__ + + bool mIsReloading; }; #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-03 19:44:53
|
Revision: 91 http://sirrf.svn.sourceforge.net/sirrf/?rev=91&view=rev Author: zccdark203 Date: 2009-08-03 19:44:43 +0000 (Mon, 03 Aug 2009) Log Message: ----------- Proof of concept implementation of the integration of the AssetGroup into entities and their components. Modified Paths: -------------- trunk/src/components/scene/MeshComponent.cpp trunk/src/core/AssetGroup.cpp trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-08-02 11:26:10 UTC (rev 90) +++ trunk/src/components/scene/MeshComponent.cpp 2009-08-03 19:44:43 UTC (rev 91) @@ -95,9 +95,27 @@ // Loads and sets a new mesh to display. void MeshComponent::setMesh(const std::string &fileName) { - IMesh *mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); - if(mesh) - mMeshSN->setMesh(mesh); + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + IMesh *mesh = 0; + + // Retrieve pointer to the mesh. + if(assets != NULL) + { + // Unsubscribe from previous asset. + //assets->disconnectEventSignal + + mesh = assets->getMesh(fileName); + + //if(mesh) + //assets->connectEventSingal + } + + else + mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); + + // Set mesh. + mMeshSN->setMesh(mesh); } // Sets a new mesh to display. Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-02 11:26:10 UTC (rev 90) +++ trunk/src/core/AssetGroup.cpp 2009-08-03 19:44:43 UTC (rev 91) @@ -30,8 +30,6 @@ mBaseDir = (GameManager::Instance()->getDevice()->getFileSystem() ->getAbsolutePath(dirName.c_str())).c_str(); - cout << mBaseDir << "\n"; - init(); } Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-08-02 11:26:10 UTC (rev 90) +++ trunk/src/core/Entity.cpp 2009-08-03 19:44:43 UTC (rev 91) @@ -23,8 +23,8 @@ u32 Entity::mIDCount = 0; // Entity constructor. -Entity::Entity(const std::string &name, Entity *parent) -: pParent(NULL), mName(name), mPosition(0, 0, 0), mIsAddingChild(false) +Entity::Entity(const std::string &name, Entity *parent, AssetGroup *group) +: pParent(NULL), pAssetGroup(group), mName(name), mPosition(0, 0, 0), mIsAddingChild(false) { mID = mIDCount++; @@ -104,6 +104,12 @@ return true; } +// Gets pointer to the AssetGroup that is linked to this entity. +AssetGroup* Entity::getAssetGroup() +{ + return pAssetGroup; +} + // Gets the child with the given ID from this entity. Entity* Entity::getChild(const u32 id) { Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-08-02 11:26:10 UTC (rev 90) +++ trunk/src/core/Entity.h 2009-08-03 19:44:43 UTC (rev 91) @@ -19,6 +19,7 @@ // Include files #include "../dependencies.h" #include "ReferenceCounted.h" +#include "AssetGroup.h" #include "HasEvents.h" #include "EntityComponent.h" @@ -36,7 +37,9 @@ //! Constructor //! @param name Name of the entity. //! @param parent Parent of the entity. - Entity(const std::string &name, Entity *parent = NULL); + //! @param group Pointer to the AssetGroup that will be used as an alternative source + //! for loading assets instead of the global unmanaged asset pool. + Entity(const std::string &name, Entity *parent = NULL, AssetGroup *group = NULL); //! Deconstructor ~Entity(); @@ -55,6 +58,10 @@ //! @return True if addition was successful, false if addition was a failure. bool addComponent(EntityComponent *component); + //! Gets pointer to the AssetGroup that is linked to this entity. + //! @return Pointer to the AssetGroup if available, else NULL. + AssetGroup* getAssetGroup(); + //! Gets the child with the given ID from this entity. //! @return Pointer to the child if found, else NULL. Entity* getChild(const u32 id); @@ -138,6 +145,7 @@ // Normal members Entity *pParent; + AssetGroup *pAssetGroup; u32 mID; std::string mName; Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-08-02 11:26:10 UTC (rev 90) +++ trunk/src/core/EntityManager.cpp 2009-08-03 19:44:43 UTC (rev 91) @@ -116,7 +116,7 @@ } // Loads an entity from the given file. -Entity* EntityManager::loadEntityXML(const std::string &fileName, bool grab) +Entity* EntityManager::loadEntityXML(const std::string &fileName, AssetGroup *assets, bool grab) { // Get pointer to the File System of Irrlicht. IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); @@ -144,7 +144,7 @@ if(stringw("entity") == file->getNodeName()) { stringc name = file->getAttributeValue(L"name"); - entity = new Entity(name.c_str()); + entity = new Entity(name.c_str(), NULL, assets); } // <components> Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-08-02 11:26:10 UTC (rev 90) +++ trunk/src/core/EntityManager.h 2009-08-03 19:44:43 UTC (rev 91) @@ -71,8 +71,10 @@ //! Loads an entity from the given file. //! @param fileName Filename of the entity. + //! @param group Pointer to the AssetGroup that will be used as an alternative + //! source for loading assets instead of the global unmanaged pool. //! @param grab Should the EntityManager add the loaded entity to the internal list? - Entity* loadEntityXML(const std::string &fileName, bool grab = true); + Entity* loadEntityXML(const std::string &fileName, AssetGroup *assets = NULL, bool grab = true); //! Removes all entities from the EntityManager. void removeEntities(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-02 11:26:20
|
Revision: 90 http://sirrf.svn.sourceforge.net/sirrf/?rev=90&view=rev Author: zccdark203 Date: 2009-08-02 11:26:10 +0000 (Sun, 02 Aug 2009) Log Message: ----------- Added the onGUIEvent slot to the event group of the global EventManager. Modified Paths: -------------- trunk/src/core/EventManager.cpp Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-08-01 10:34:25 UTC (rev 89) +++ trunk/src/core/EventManager.cpp 2009-08-02 11:26:10 UTC (rev 90) @@ -61,6 +61,9 @@ eventGroup[strOnKeyDown + it->second] = slot1; eventGroup[strOnKeyUp + it->second] = slot2; } + + // Add misc. event slots. + createEventSlot("EventManager", "onGUIEvent"); } // Clears the Event Manager. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-01 10:34:31
|
Revision: 89 http://sirrf.svn.sourceforge.net/sirrf/?rev=89&view=rev Author: zccdark203 Date: 2009-08-01 10:34:25 +0000 (Sat, 01 Aug 2009) Log Message: ----------- Fixed bug reported by Christian Clavet. The onUpdate event of the Entity class was assigned to the onPositionChange method. Due to this entities and their components moved seemingly without a reason. Modified Paths: -------------- trunk/src/components/scene/SceneComponent.cpp trunk/src/core/Entity.cpp Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-07-31 12:04:12 UTC (rev 88) +++ trunk/src/components/scene/SceneComponent.cpp 2009-08-01 10:34:25 UTC (rev 89) @@ -38,6 +38,7 @@ mName = "SceneComponent"; mCanAffectParent = false; mEvokedParentChange = false; + mLastPos = getPosition(); // Register events. pParent->connectEventSignal("onPositionChange", this, &SceneComponent::onPositionChange); Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-07-31 12:04:12 UTC (rev 88) +++ trunk/src/core/Entity.cpp 2009-08-01 10:34:25 UTC (rev 89) @@ -384,7 +384,7 @@ setPosition(pParent->getPosition()); // Register events. - pParent->connectEventSignal("onUpdate", this, &Entity::onPositionChange); + pParent->connectEventSignal("onPositionChange", this, &Entity::onPositionChange); pParent->connectEventSignal("onUpdate", this, &Entity::onUpdate); pParent->connectEventSignal("onRender", this, &Entity::onRender); pParent->connectEventSignal("onPause", this, &Entity::onPause); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-31 12:04:26
|
Revision: 88 http://sirrf.svn.sourceforge.net/sirrf/?rev=88&view=rev Author: zccdark203 Date: 2009-07-31 12:04:12 +0000 (Fri, 31 Jul 2009) Log Message: ----------- Updated the AngelScript binding of the Entity class in response to the changes of the previous revision. Modified Paths: -------------- trunk/src/scripting/core/asEntity.cpp Modified: trunk/src/scripting/core/asEntity.cpp =================================================================== --- trunk/src/scripting/core/asEntity.cpp 2009-07-30 16:20:21 UTC (rev 87) +++ trunk/src/scripting/core/asEntity.cpp 2009-07-31 12:04:12 UTC (rev 88) @@ -99,6 +99,11 @@ r = engine->RegisterObjectMethod("Entity", "bool removeComponent(const string &in)", asMETHODPR(Entity, removeComponent, (const std::string&), bool), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void removeParent()", + asMETHOD(Entity, removeParent), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("Entity", "void setParent(Entity @+)", + asMETHOD(Entity, setParent), asCALL_THISCALL); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-30 16:20:29
|
Revision: 87 http://sirrf.svn.sourceforge.net/sirrf/?rev=87&view=rev Author: zccdark203 Date: 2009-07-30 16:20:21 +0000 (Thu, 30 Jul 2009) Log Message: ----------- The Entity class now supports post-initialization addition (and replacement) of parent entities. You can use the setParent and addChild methods for this. Besides that I also fixed the disconnectEventSignal methods of both the EventManager and HasEvents classes. Modified Paths: -------------- trunk/CHANGES trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EventManager.h trunk/src/core/GameState.h trunk/src/core/HasEvents.h trunk/src/scripting/core/asEntity.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-07-30 10:36:09 UTC (rev 86) +++ trunk/CHANGES 2009-07-30 16:20:21 UTC (rev 87) @@ -2,6 +2,12 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Fixed the disconnectEventSignal method in both the EventManager class + and the HasEvents class. + + * The Entity class now supports post-initialization addition of a + parent entity. Use the setParent and addChild methods for this. + * The Entity class now derives from the HasEvents class. This means that entities and their components no longer use the global event management system for basic communication. Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-07-30 10:36:09 UTC (rev 86) +++ trunk/src/core/Entity.cpp 2009-07-30 16:20:21 UTC (rev 87) @@ -24,45 +24,28 @@ // Entity constructor. Entity::Entity(const std::string &name, Entity *parent) -: mName(name), mPosition(0, 0, 0) +: pParent(NULL), mName(name), mPosition(0, 0, 0), mIsAddingChild(false) { mID = mIDCount++; - // Add to its parent. - if(parent != NULL) - { - if(parent->addChild(this)) - pParent = parent; - - else pParent = NULL; - } - - else pParent = NULL; - - // Create an event group and event slots. + // Create event slots. createEventSlot("onPositionChange"); createEventSlot("onUpdate"); createEventSlot("onRender"); createEventSlot("onPause"); createEventSlot("onUnPause"); - // Subscribe to parents event slots. - if(pParent != NULL) - { - pParent->connectEventSignal("onUpdate", this, &Entity::onPositionChange); - pParent->connectEventSignal("onUpdate", this, &Entity::onUpdate); - pParent->connectEventSignal("onRender", this, &Entity::onRender); - pParent->connectEventSignal("onPause", this, &Entity::onPause); - pParent->connectEventSignal("onUnPause", this, &Entity::onUnPause); - } + // Set parent. + setParent(parent); } // Entity deconstructor. Entity::~Entity() { - // Remove all children and components. + // Remove all children, components and parent. removeChildren(); removeComponents(); + removeParent(); } // Gets the ID of this entity. @@ -80,6 +63,10 @@ // Adds a child to the entity. bool Entity::addChild(Entity *entity) { + // Are we already adding a child? + if(mIsAddingChild) + return true; + // Did we get a pointer to a entity? if(entity == NULL) return false; @@ -89,6 +76,10 @@ return false; // Add new component. + mIsAddingChild = true; + entity->setParent(this); + mIsAddingChild = false; + mChildren.push_back(entity); entity->grab(); @@ -176,13 +167,12 @@ // Removes all children. void Entity::removeChildren() { - for(u32 i = 0; i < mChildren.size(); i++) + while(mChildren.size() <= 0) { - if(!GameManager::Instance()->getEntityManager()->removeEntity(mChildren[i])) - mChildren[i]->drop(); + // We don't have to do anything else as the removeParent function calls + // removeChild internally. + mChildren[0]->removeParent(); } - - mChildren.clear(); } // Removes all components. @@ -210,8 +200,9 @@ if(ent == entity) { + mChildren.erase(it); + ent->removeParent(); ent->drop(); - mChildren.erase(it); return true; } } @@ -232,8 +223,9 @@ if(ent->getID() == id) { + mChildren.erase(it); + ent->removeParent(); ent->drop(); - mChildren.erase(it); return true; } } @@ -254,8 +246,9 @@ if(ent->getName() == name) { + mChildren.erase(it); + ent->removeParent(); ent->drop(); - mChildren.erase(it); return true; } } @@ -334,6 +327,25 @@ return false; } +// Removes the current parent of this entity. +void Entity::removeParent() +{ + if(pParent != NULL) + { + Entity *parent = pParent; + pParent = NULL; + + parent->removeChild(this); + parent->drop(); + + parent->disconnectEventSignal("onUpdate", this); + parent->disconnectEventSignal("onUpdate", this); + parent->disconnectEventSignal("onRender", this); + parent->disconnectEventSignal("onPause", this); + parent->disconnectEventSignal("onUnPause", this); + } +} + // Sets the position of the entity. void Entity::setPosition(const vector3df &position) { @@ -343,6 +355,47 @@ emitEvent("onPositionChange", &diff); } +// Sets the parent of the entity. +bool Entity::setParent(Entity *parent) +{ + // Did we get a valid pointer? + if(parent == NULL) + return false; + + // Get an extra reference so that this entity doesn't get deleted. + // Normally this is unneeded, but it's possible that nothing else + // holds a reference to this entity. + grab(); + + // Remove previous parent. + removeParent(); + + // Add this entity to the parent. + if(!parent->addChild(this)) + { + drop(); // Remove extra reference. + return false; + } + + pParent = parent; + pParent->grab(); + + // Inherit position. + setPosition(pParent->getPosition()); + + // Register events. + pParent->connectEventSignal("onUpdate", this, &Entity::onPositionChange); + pParent->connectEventSignal("onUpdate", this, &Entity::onUpdate); + pParent->connectEventSignal("onRender", this, &Entity::onRender); + pParent->connectEventSignal("onPause", this, &Entity::onPause); + pParent->connectEventSignal("onUnPause", this, &Entity::onUnPause); + + // Release extra reference. + drop(); + + return true; +} + // Updates the position of the entity after its parent has been updated. void Entity::onPositionChange(void *p) { Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-07-30 10:36:09 UTC (rev 86) +++ trunk/src/core/Entity.h 2009-07-30 16:20:21 UTC (rev 87) @@ -46,6 +46,10 @@ //! Gets the name of this entity. const std::string& getName() const; + //! Adds a child to the entity. + //! @param entity Pointer to the child to add. + //! @return True if addition was successful, false if addition was a failure. + bool addChild(Entity *entity); //! Adds a component to the entity. //! @param component Pointer to the component to add. //! @return True if addition was successful, false if addition was a failure. @@ -99,11 +103,17 @@ //! @param name Name of the component to remove. //! @return True if removal was successful, false if removal was a failure. bool removeComponent(const std::string &name); + //! Removes the current parent of this entity. + void removeParent(); //! Sets the position of the entity. //! @param position New position of the entity. void setPosition(const vector3df &position); + //! Sets the parent of the entity. + //! @param parent Parent of the entity. + bool setParent(Entity *parent); + // Events //! Updates the position of the entity after its parent has been updated. //! @note For internal use only! @@ -123,9 +133,6 @@ private: - // Private methods - bool addChild(Entity *entity); - // Static members static u32 mIDCount; @@ -137,6 +144,8 @@ vector3df mPosition; + bool mIsAddingChild; + vector<Entity*> mChildren; vector<EntityComponent*> mComponents; }; Modified: trunk/src/core/EventManager.h =================================================================== --- trunk/src/core/EventManager.h 2009-07-30 10:36:09 UTC (rev 86) +++ trunk/src/core/EventManager.h 2009-07-30 16:20:21 UTC (rev 87) @@ -97,10 +97,8 @@ //! @param slotName Name of the event slot. //! @param t Pointer to the object that will function as this-object when the //! connect function is called. - //! @param m Pointer to the function. template<typename T> - bool disconnectEventSignal(const std::string &groupName, const std::string &slotName, - T *t, void (T::*m)(void*)) + bool disconnectEventSignal(const std::string &groupName, const std::string &slotName, T *t) { // Get the given event group. std::map<std::string, std::map<std::string, EventSlot> >::iterator itGroups; @@ -120,7 +118,7 @@ EventSlot &signal = itSlots->second; // Disconnect from the signal. - signal.disconnect(t, m); + signal.disconnect(t); return true; }; Modified: trunk/src/core/GameState.h =================================================================== --- trunk/src/core/GameState.h 2009-07-30 10:36:09 UTC (rev 86) +++ trunk/src/core/GameState.h 2009-07-30 16:20:21 UTC (rev 87) @@ -81,7 +81,6 @@ // Private members u32 mID; - std::string mEventGroup; }; #endif Modified: trunk/src/core/HasEvents.h =================================================================== --- trunk/src/core/HasEvents.h 2009-07-30 10:36:09 UTC (rev 86) +++ trunk/src/core/HasEvents.h 2009-07-30 16:20:21 UTC (rev 87) @@ -66,9 +66,8 @@ //! @param slotName Name of the event slot. //! @param t Pointer to the object that will function as this-object when the //! connect function is called. - //! @param m Pointer to the function. template<typename T> - bool disconnectEventSignal(const std::string &slotName, T *t, void (T::*m)(void*)) + bool disconnectEventSignal(const std::string &slotName, T *t) { // Get the given event slot. std::map<std::string, EventSlot>::iterator itSlots = mEventSlots.find(slotName); @@ -79,7 +78,7 @@ EventSlot &signal = itSlots->second; // Disconnect from the signal. - signal.disconnect(t, m); + signal.disconnect(t); return true; }; Modified: trunk/src/scripting/core/asEntity.cpp =================================================================== --- trunk/src/scripting/core/asEntity.cpp 2009-07-30 10:36:09 UTC (rev 86) +++ trunk/src/scripting/core/asEntity.cpp 2009-07-30 16:20:21 UTC (rev 87) @@ -56,6 +56,8 @@ r = engine->RegisterObjectMethod("Entity", "const string& getName()", asMETHOD(Entity, getName), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "bool addChild(Entity @+)", + asMETHOD(Entity, addChild), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "bool addComponent(EntityComponent @+)", asMETHOD(Entity, addComponent), asCALL_THISCALL); assert(r >= 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-30 10:36:24
|
Revision: 86 http://sirrf.svn.sourceforge.net/sirrf/?rev=86&view=rev Author: zccdark203 Date: 2009-07-30 10:36:09 +0000 (Thu, 30 Jul 2009) Log Message: ----------- The Entity class now inherits from the HasEvents class. Entities and their components now rely on the decentralized event management system of the entities. Of course both entities and components can still use the global event manager, but it shouldn't be needed for basic communication. As a result overall performance should increase. Modified Paths: -------------- trunk/CHANGES trunk/src/components/scene/ImageComponent.cpp trunk/src/components/scene/SceneComponent.cpp trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/GameState.cpp trunk/src/core/HasEvents.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/CHANGES 2009-07-30 10:36:09 UTC (rev 86) @@ -2,6 +2,10 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * The Entity class now derives from the HasEvents class. This means that + entities and their components no longer use the global event + management system for basic communication. + * Created the HasEvents class. This class provides a base for classes that need a decentralized event system. @@ -21,8 +25,12 @@ * Added loadSoundBufferFromMemory to the SoundManager class. With this method you can pass a self-loaded buffer to the SoundManager. Additionaly a loadSoundBufferFromAssetGroup method has been added to - the SoundManager class. + the SoundManager class. + * Created the AssetGroup class which represents a collection of assets + (meshes, textures, etc). The AssetManager class is responsible for + managing these groups. + * Renamed all removeAll* functions to remove*. Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/components/scene/ImageComponent.cpp 2009-07-30 10:36:09 UTC (rev 86) @@ -25,19 +25,13 @@ mColor(SColor(255, 255, 255, 255)), mPosition(vector2di(0, 0)), mSourceRect(rect<s32>(0, 0, 0, 0)), mVisible(true), mUseAlphaColor(false) { - // Get a pointer to sub-systems of the Game Manager. - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Set misc. variables. mName = "ImageComponent"; // Register events. - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onRender", - this, &ImageComponent::onRender); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPause", - this, &ImageComponent::onPause); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onUnPause", - this, &ImageComponent::onUnPause); + pParent->connectEventSignal("onRender", this, &ImageComponent::onRender); + pParent->connectEventSignal("onPause", this, &ImageComponent::onPause); + pParent->connectEventSignal("onUnPause", this, &ImageComponent::onUnPause); } // ImageComponent constructor. @@ -48,9 +42,6 @@ : EntityComponent(parent), mAlphaColor(alphaColor), mClipRect(NULL), mColor(color), mPosition(position), mSourceRect(sourceRect), mVisible(true), mUseAlphaColor(useAlphaColor) { - // Get a pointer to sub-systems of the Game Manager. - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Load the texture. mTexture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); @@ -62,12 +53,9 @@ mName = "ImageComponent"; // Register events. - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onRender", - this, &ImageComponent::onRender); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPause", - this, &ImageComponent::onPause); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onUnPause", - this, &ImageComponent::onUnPause); + pParent->connectEventSignal("onRender", this, &ImageComponent::onRender); + pParent->connectEventSignal("onPause", this, &ImageComponent::onPause); + pParent->connectEventSignal("onUnPause", this, &ImageComponent::onUnPause); } // ImageComponent constructor. @@ -78,9 +66,6 @@ : EntityComponent(parent), mAlphaColor(alphaColor), mClipRect(clipRect), mColor(color), mPosition(position), mSourceRect(sourceRect), mVisible(true), mUseAlphaColor(useAlphaColor) { - // Get a pointer to sub-systems of the Game Manager. - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Load the texture. mTexture = texture; @@ -92,12 +77,9 @@ mName = "ImageComponent"; // Register events. - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onRender", - this, &ImageComponent::onRender); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPause", - this, &ImageComponent::onPause); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onUnPause", - this, &ImageComponent::onUnPause); + pParent->connectEventSignal("onRender", this, &ImageComponent::onRender); + pParent->connectEventSignal("onPause", this, &ImageComponent::onPause); + pParent->connectEventSignal("onUnPause", this, &ImageComponent::onUnPause); } Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/components/scene/SceneComponent.cpp 2009-07-30 10:36:09 UTC (rev 86) @@ -25,7 +25,6 @@ { // Get a pointer to the scene manager. ISceneManager *pScnMgr = GameManager::Instance()->getSceneManager(); - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); // Initialise the internal scene node. mSceneNode = pScnMgr->addEmptySceneNode(0, parent->getID()); @@ -33,7 +32,7 @@ // Set up collision detection for this component. mTriSelector = pScnMgr->createTriangleSelectorFromBoundingBox(mSceneNode); - mMetaSelector =pScnMgr->createMetaTriangleSelector(); + mMetaSelector = pScnMgr->createMetaTriangleSelector(); // Set misc. variables. mName = "SceneComponent"; @@ -41,29 +40,24 @@ mEvokedParentChange = false; // Register events. - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", - this, &SceneComponent::onPositionChange); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onUpdate", - this, &SceneComponent::onUpdate); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPause", - this, &SceneComponent::onPause); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onUnPause", - this, &SceneComponent::onUnPause); + pParent->connectEventSignal("onPositionChange", this, &SceneComponent::onPositionChange); + pParent->connectEventSignal("onUpdate", this, &SceneComponent::onUpdate); + pParent->connectEventSignal("onPause", this, &SceneComponent::onPause); + pParent->connectEventSignal("onUnPause", this, &SceneComponent::onUnPause); } // SceneComponent constructor (derivatives). SceneComponent::SceneComponent(Entity *parent, bool isDerived) : EntityComponent(parent) { - // Get a pointer to the scene manager. - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Set misc. variables. mName = "SceneComponent"; // Register events. - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", - this, &SceneComponent::onPositionChange); + pParent->connectEventSignal("onPositionChange", this, &SceneComponent::onPositionChange); + pParent->connectEventSignal("onUpdate", this, &SceneComponent::onUpdate); + pParent->connectEventSignal("onPause", this, &SceneComponent::onPause); + pParent->connectEventSignal("onUnPause", this, &SceneComponent::onUnPause); } // SceneComponent deconstructor. @@ -323,7 +317,7 @@ vector3df diff = mSceneNode->getPosition() - mLastPos; mLastPos = mSceneNode->getPosition(); - if(diff == vector3df(0)) + if(diff != vector3df(0)) { mEvokedParentChange = true; pParent->setPosition(pParent->getPosition() + diff); Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-30 10:36:09 UTC (rev 86) @@ -27,9 +27,6 @@ SoundListenerComponent::SoundListenerComponent(Entity *parent, bool isMainListener) : EntityComponent(parent), mPosition(parent->getPosition()), mTarget(vector3df(0, 0, 0)) { - // Get a pointer to sub-systems of the Game Manager. - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Is this the new main listener? if(isMainListener) { @@ -43,12 +40,9 @@ mName = "SoundListenerComponent"; // Register events. - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", - this, &SoundListenerComponent::onPositionChange); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPause", - this, &SoundListenerComponent::onPause); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onUnPause", - this, &SoundListenerComponent::onUnPause); + pParent->connectEventSignal("onPositionChange", this, &SoundListenerComponent::onPositionChange); + pParent->connectEventSignal("onPause", this, &SoundListenerComponent::onPause); + pParent->connectEventSignal("onUnPause", this, &SoundListenerComponent::onUnPause); } // SoundListenerComponent deconstructor. Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-07-30 10:36:09 UTC (rev 86) @@ -25,19 +25,13 @@ : EntityComponent(parent), mSound(NULL), mMusic(NULL), mBuffer(NULL), mAttenuation(1.0f), mLoop(false), mMinDistance(1.0f), mPitch(1.0f), mPosition(parent->getPosition()), mVolume(100) { - // Get a pointer to sub-systems of the Game Manager. - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Set misc. variables. mName = "SoundSourceComponent"; // Register events. - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", - this, &SoundSourceComponent::onPositionChange); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPause", - this, &SoundSourceComponent::onPause); - pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onUnPause", - this, &SoundSourceComponent::onUnPause); + pParent->connectEventSignal("onPositionChange", this, &SoundSourceComponent::onPositionChange); + pParent->connectEventSignal("onPause", this, &SoundSourceComponent::onPause); + pParent->connectEventSignal("onUnPause", this, &SoundSourceComponent::onUnPause); } // SoundSourceComponent deconstructor. Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/core/Entity.cpp 2009-07-30 10:36:09 UTC (rev 86) @@ -40,26 +40,20 @@ else pParent = NULL; // Create an event group and event slots. - EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - std::string groupName; + createEventSlot("onPositionChange"); + createEventSlot("onUpdate"); + createEventSlot("onRender"); + createEventSlot("onPause"); + createEventSlot("onUnPause"); - groupName = "ent#" + mName; - pEventMgr->createEventGroup(groupName); - pEventMgr->createEventSlot(groupName, "onPositionChange"); - pEventMgr->createEventSlot(groupName, "onUpdate"); - pEventMgr->createEventSlot(groupName, "onRender"); - pEventMgr->createEventSlot(groupName, "onPause"); - pEventMgr->createEventSlot(groupName, "onUnPause"); - // Subscribe to parents event slots. if(pParent != NULL) { - groupName = "ent#" + pParent->getName(); - pEventMgr->connectEventSignal(groupName, "onUpdate", this, &Entity::onPositionChange); - pEventMgr->connectEventSignal(groupName, "onUpdate", this, &Entity::onUpdate); - pEventMgr->connectEventSignal(groupName, "onRender", this, &Entity::onRender); - pEventMgr->connectEventSignal(groupName, "onPause", this, &Entity::onPause); - pEventMgr->connectEventSignal(groupName, "onUnPause", this, &Entity::onUnPause); + pParent->connectEventSignal("onUpdate", this, &Entity::onPositionChange); + pParent->connectEventSignal("onUpdate", this, &Entity::onUpdate); + pParent->connectEventSignal("onRender", this, &Entity::onRender); + pParent->connectEventSignal("onPause", this, &Entity::onPause); + pParent->connectEventSignal("onUnPause", this, &Entity::onUnPause); } } @@ -69,9 +63,6 @@ // Remove all children and components. removeChildren(); removeComponents(); - - // Remove events. - GameManager::Instance()->getEventManager()->removeEventGroup(std::string("ent#") + mName); } // Gets the ID of this entity. @@ -346,15 +337,10 @@ // Sets the position of the entity. void Entity::setPosition(const vector3df &position) { - // Determine difference. vector3df diff = position - mPosition; - - // Set position. mPosition = position; - // Set position for children, components and misc. subscribers. - GameManager::Instance()->getEventManager()->emitEvent(std::string("ent#") + mName, - "onPositionChange", &diff); + emitEvent("onPositionChange", &diff); } // Updates the position of the entity after its parent has been updated. @@ -362,34 +348,32 @@ { vector3df diff = static_cast<vector3df*>(p)[0]; mPosition += diff; + + emitEvent("onPositionChange", &diff); } // Updates the entity if the parent is updated. void Entity::onUpdate(void *p) { - GameManager::Instance()->getEventManager()->emitEvent(std::string("ent#") + mName, - "onUpdate", p); + emitEvent("onUpdate", p); } // Renders the entity if the parent is rendered. void Entity::onRender(void *p) { - GameManager::Instance()->getEventManager()->emitEvent(std::string("ent#") + mName, - "onRender", p); + emitEvent("onRender", p); } // Pauses the entity if the parent is paused. void Entity::onPause(void *p) { - GameManager::Instance()->getEventManager()->emitEvent(std::string("ent#") + mName, - "onPause", p); + emitEvent("onPause", p); } // Updates the entity if the parent is unpaused. void Entity::onUnPause(void *p) { - GameManager::Instance()->getEventManager()->emitEvent(std::string("ent#") + mName, - "onUnPause", p); + emitEvent("onUnPause", p); } // End of File Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/core/Entity.h 2009-07-30 10:36:09 UTC (rev 86) @@ -19,6 +19,7 @@ // Include files #include "../dependencies.h" #include "ReferenceCounted.h" +#include "HasEvents.h" #include "EntityComponent.h" // Forward declarations @@ -27,7 +28,7 @@ // Entity class //! Represents an object in the game world. -class Entity : public sigslot::has_slots<>, public ReferenceCounted +class Entity : public sigslot::has_slots<>, public ReferenceCounted, public HasEvents { public: Modified: trunk/src/core/GameState.cpp =================================================================== --- trunk/src/core/GameState.cpp 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/core/GameState.cpp 2009-07-30 10:36:09 UTC (rev 86) @@ -32,9 +32,6 @@ std::stringstream ss; ss << "GameState#" << mID; mBaseEntity = GameManager::Instance()->getEntityManager()->createEntity(ss.str()); - - // Store the name of the event group of this state. - mEventGroup = "ent#" + ss.str(); } // Deconstructor of the GameState class. @@ -77,25 +74,25 @@ // Sends the "onUpdate" event to all entities subscribed to this state. void GameState::onUpdate(f32 deltaTime) { - GameManager::Instance()->getEventManager()->emitEvent(mEventGroup, "onUpdate", &deltaTime); + mBaseEntity->emitEvent("onUpdate", &deltaTime); } // Sends the "onUpdate" event to all entities subscribed to this state. void GameState::onRender() { - GameManager::Instance()->getEventManager()->emitEvent(mEventGroup, "onRender"); + mBaseEntity->emitEvent("onRender"); } // Sends the "onPause" event to all entities subscribed to this state. void GameState::onPause() { - GameManager::Instance()->getEventManager()->emitEvent(mEventGroup, "onPause"); + mBaseEntity->emitEvent("onPause"); } // Sends the "onUnPause" event to all entities subscribed to this state. void GameState::onUnPause() { - GameManager::Instance()->getEventManager()->emitEvent(mEventGroup, "onUnPause"); + mBaseEntity->emitEvent("onUnPause"); } // End of File Modified: trunk/src/core/HasEvents.h =================================================================== --- trunk/src/core/HasEvents.h 2009-07-29 19:31:22 UTC (rev 85) +++ trunk/src/core/HasEvents.h 2009-07-30 10:36:09 UTC (rev 86) @@ -47,8 +47,7 @@ //! connect function is called. //! @param m Pointer to the function. template<typename T> - bool connectEventSignal(const std::string &groupName, const std::string &slotName, - T *t, void (T::*m)(void*)) + bool connectEventSignal(const std::string &slotName, T *t, void (T::*m)(void*)) { // Get the given event slot. std::map<std::string, EventSlot>::iterator itSlots = mEventSlots.find(slotName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-29 19:31:32
|
Revision: 85 http://sirrf.svn.sourceforge.net/sirrf/?rev=85&view=rev Author: zccdark203 Date: 2009-07-29 19:31:22 +0000 (Wed, 29 Jul 2009) Log Message: ----------- Created the HasEvents class. This class provides a base for classes that need a decentralized event system. I also made a small fix to main.cpp; it wasn't completely cross-platform and created warnings on GCC. And there are also some documentation fixes. Modified Paths: -------------- trunk/CHANGES trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/core/EventManager.h trunk/src/core/ReferenceCounted.cpp trunk/src/main.cpp Added Paths: ----------- trunk/src/core/HasEvents.cpp trunk/src/core/HasEvents.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-07-21 16:05:30 UTC (rev 84) +++ trunk/CHANGES 2009-07-29 19:31:22 UTC (rev 85) @@ -2,6 +2,9 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Created the HasEvents class. This class provides a base for classes + that need a decentralized event system. + * Added MSVC 2008 project files. Thanks to FuzzYspo0N for making them. * Made some additions to the AngelScript bindings of aabbox3d<T>, Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-07-21 16:05:30 UTC (rev 84) +++ trunk/build/CMake/CMakeLists.txt 2009-07-29 19:31:22 UTC (rev 85) @@ -43,6 +43,7 @@ ${SOURCE_DIR}core/EventManager.cpp ${SOURCE_DIR}core/GameManager.cpp ${SOURCE_DIR}core/GameState.cpp + ${SOURCE_DIR}core/HasEvents.cpp ${SOURCE_DIR}core/ReferenceCounted.cpp # /src/game Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-07-21 16:05:30 UTC (rev 84) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-07-29 19:31:22 UTC (rev 85) @@ -111,6 +111,8 @@ <Unit filename="../../src/core/GameManager.h" /> <Unit filename="../../src/core/GameState.cpp" /> <Unit filename="../../src/core/GameState.h" /> + <Unit filename="../../src/core/HasEvents.cpp" /> + <Unit filename="../../src/core/HasEvents.h" /> <Unit filename="../../src/core/ReferenceCounted.cpp" /> <Unit filename="../../src/core/ReferenceCounted.h" /> <Unit filename="../../src/dependencies.h" /> Modified: trunk/src/core/EventManager.h =================================================================== --- trunk/src/core/EventManager.h 2009-07-21 16:05:30 UTC (rev 84) +++ trunk/src/core/EventManager.h 2009-07-29 19:31:22 UTC (rev 85) @@ -157,6 +157,7 @@ //! Removes the given event slot from the given event group. //! @param groupName Name of the event group. //! @param slotName Name of the event slot to remove. + //! @return True if removal was successful, false if removal was a failure. bool removeEventSlot(const std::string &groupName, const std::string &slotName); //! Handles the events sent by the Irrlicht engine. Added: trunk/src/core/HasEvents.cpp =================================================================== --- trunk/src/core/HasEvents.cpp (rev 0) +++ trunk/src/core/HasEvents.cpp 2009-07-29 19:31:22 UTC (rev 85) @@ -0,0 +1,88 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: HasEvents.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : The HasEvents class provides a base for classes that need a +// decentralized event system. By deriving from this class, +// the derived class gains all needed methods for the +// management of a decentralized event system. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +// Include files +#include "HasEvents.h" + + +// HasEvents class +// HasEvents constructor. +HasEvents::HasEvents() +{ +} + +// HasEvents deconstructor. +HasEvents::~HasEvents() +{ + removeEventSlots(); +} + +// Creates a new event slot. +bool HasEvents::createEventSlot(const std::string &slotName) +{ + // Check if the given slot doesnt already exist. + std::map<std::string, EventSlot>::iterator itSlots = mEventSlots.find(slotName); + + if(itSlots != mEventSlots.end()) + return false; + + // Create a new event slot. + EventSlot slot; + mEventSlots[slotName] = slot; + + return true; +} + +// Emits an event to the given event slot. +bool HasEvents::emitEvent(const std::string &slotName, void* p) +{ + // Get the given event slot. + std::map<std::string, EventSlot>::iterator itSlots = mEventSlots.find(slotName); + + if(itSlots == mEventSlots.end()) + return false; + + EventSlot &slot = itSlots->second; + + // Emit event. + slot.emit(p); + return true; +} + +// Removes all event slots. +void HasEvents::removeEventSlots() +{ + mEventSlots.clear(); +} + +// Removes the given event slot. +bool HasEvents::removeEventSlot(const std::string &slotName) +{ + // Get the given event slot. + std::map<std::string, EventSlot>::iterator itSlots = mEventSlots.find(slotName); + + if(itSlots == mEventSlots.end()) + return false; + + // Remove it. + mEventSlots.erase(itSlots); + return true; + +} + +// End of File Added: trunk/src/core/HasEvents.h =================================================================== --- trunk/src/core/HasEvents.h (rev 0) +++ trunk/src/core/HasEvents.h 2009-07-29 19:31:22 UTC (rev 85) @@ -0,0 +1,105 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: HasEvents.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the HasEvents class. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +#ifndef __HASEVENTS_H__ +#define __HASEVENTS_H__ + +// Include files +#include "../dependencies.h" +#include "EventManager.h" + + +// HasEvents class +//! This class provides a base for classes that need a decentralized event system. +//! By deriving from this class, the derived class gains all needed methods for +//! the management of a decentralized event system. +class HasEvents +{ +public: + + // Initialisation and deinitialisation + //! Constructor + HasEvents(); + //! Deconstructor + virtual ~HasEvents(); + + // Public methods + //! Creates a new event slot. + //! @param slotName Name of the event slot. + //! @return True if creation was successful, false if creation was a failure. + bool createEventSlot(const std::string &slotName); + + //! Connects a function to the given event slot. + //! @param slotName Name of the event slot. + //! @param t Pointer to the object that will function as this-object when the + //! connect function is called. + //! @param m Pointer to the function. + template<typename T> + bool connectEventSignal(const std::string &groupName, const std::string &slotName, + T *t, void (T::*m)(void*)) + { + // Get the given event slot. + std::map<std::string, EventSlot>::iterator itSlots = mEventSlots.find(slotName); + + if(itSlots == mEventSlots.end()) + return false; + + EventSlot &signal = itSlots->second; + + // Connect to the signal. + signal.connect(t, m); + return true; + }; + + //! Disconnects a function from the given event slot. + //! @param slotName Name of the event slot. + //! @param t Pointer to the object that will function as this-object when the + //! connect function is called. + //! @param m Pointer to the function. + template<typename T> + bool disconnectEventSignal(const std::string &slotName, T *t, void (T::*m)(void*)) + { + // Get the given event slot. + std::map<std::string, EventSlot>::iterator itSlots = mEventSlots.find(slotName); + + if(itSlots == mEventSlots.end()) + return false; + + EventSlot &signal = itSlots->second; + + // Disconnect from the signal. + signal.disconnect(t, m); + return true; + }; + + //! Emits an event to the given event slot. + //! @param slotName Name of the event slot. + //! @param p Pointer to data which will be passed to all functions called. + bool emitEvent(const std::string &slotName, void* p = 0); + + //! Removes all event slots. + void removeEventSlots(); + //! Removes the given event slot. + //! @param slotName Name of the event slot to remove. + //! @return True if removal was successful, false if removal was a failure. + bool removeEventSlot(const std::string &slotName); + +private: + + // Private members + std::map<std::string, EventSlot> mEventSlots; +}; + +#endif Modified: trunk/src/core/ReferenceCounted.cpp =================================================================== --- trunk/src/core/ReferenceCounted.cpp 2009-07-21 16:05:30 UTC (rev 84) +++ trunk/src/core/ReferenceCounted.cpp 2009-07-29 19:31:22 UTC (rev 85) @@ -3,7 +3,10 @@ // Name: ReferenceCounted.cpp // Author: Michael Bartsch (ZCCdark203) // -// Desc : Declaration of the ReferenceCounted class. +// Desc : This class provides reference counting through the methods +// grab() and drop(). Most objects with the framework are +// derived from ReferenceCounted, and so they are reference +// counted. // // License: Copyright (C) 2009 Michael Bartsch and Contributors // Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2009-07-21 16:05:30 UTC (rev 84) +++ trunk/src/main.cpp 2009-07-29 19:31:22 UTC (rev 85) @@ -38,11 +38,13 @@ //Uncomment below for console in release mode #define _SIRRF_SHOWCONSOLE -#if(defined(WIN32) && (!defined(_DEBUG)) && (!defined(_SIRRF_SHOWCONSOLE))) - #pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") -#elif (defined(_SIRRF_SHOWCONSOLE) || defined(_DEBUG)) - #pragma comment(linker, "/SUBSYSTEM:CONSOLE") -#endif +#if(defined(WIN32)) + #if(defined((!defined(_DEBUG)) && (!defined(_SIRRF_SHOWCONSOLE))) + #pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") + #elif (defined(_SIRRF_SHOWCONSOLE) || defined(_DEBUG)) + #pragma comment(linker, "/SUBSYSTEM:CONSOLE") + #endif +#endif // Main function //! Main entry point to the application. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fuz...@us...> - 2009-07-21 16:05:37
|
Revision: 84 http://sirrf.svn.sourceforge.net/sirrf/?rev=84&view=rev Author: fuzzyspo0n Date: 2009-07-21 16:05:30 +0000 (Tue, 21 Jul 2009) Log Message: ----------- adding windows only solution to missing libs (although its inherent that you must add them seeing as you have to add the paths to them anyway) Modified Paths: -------------- trunk/src/dependencies.h Modified: trunk/src/dependencies.h =================================================================== --- trunk/src/dependencies.h 2009-07-21 00:18:30 UTC (rev 83) +++ trunk/src/dependencies.h 2009-07-21 16:05:30 UTC (rev 84) @@ -36,9 +36,18 @@ // Irrlicht #include <irrlicht.h> +#ifdef _MSC_VER + #pragma comment(lib, "Irrlicht.lib") +#endif //_MSC_VER Only do this on msvc compilers. + // Angelscript #ifdef __COMPILE_WITH_ANGELSCRIPT__ #include <angelscript.h> + + #ifdef _MSC_VER + #pragma comment(lib, "angelscript.lib") + #endif //_MSC_VER Only do this on msvc compilers. + #endif // Sigslot @@ -48,6 +57,12 @@ #ifdef __COMPILE_WITH_SFML_AUDIO__ #include <SFML/System.hpp> #include <SFML/Audio.hpp> + + #ifdef _MSC_VER + #pragma comment(lib, "sfml-system.lib") + #pragma comment(lib, "sfml-audio.lib") + #endif //_MSC_VER Only do this on msvc compilers. + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fuz...@us...> - 2009-07-21 00:18:32
|
Revision: 83 http://sirrf.svn.sourceforge.net/sirrf/?rev=83&view=rev Author: fuzzyspo0n Date: 2009-07-21 00:18:30 +0000 (Tue, 21 Jul 2009) Log Message: ----------- Compiling with f32 instead of s32 works, because the fabs is [F]abs , its always a float. perhaps casting to s32 on return is better, but this works and keeps the support for now. Modified Paths: -------------- trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp Modified: trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp =================================================================== --- trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-07-20 23:44:57 UTC (rev 82) +++ trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-07-21 00:18:30 UTC (rev 83) @@ -212,7 +212,7 @@ void bindAabbox3d(asIScriptEngine *engine) { bindAabbox3dT<f32>(engine, "aabbox3df", "f32"); - //bindAabbox3dT<s32>(engine, "aabbox3di", "s32"); //Removed for now : FuzzYspo0N + bindAabbox3dT<s32>(engine, "aabbox3di", "f32"); //Removed for now : FuzzYspo0N // These functions are binded separetely due to a compile error with MSVC (Thanks FuzzYspo0n) int r; @@ -222,9 +222,9 @@ asCALL_THISCALL); assert(r >= 0); //Removed for now : FuzzYspo0N (this is the cause of the error in the fabs) - /*r = engine->RegisterObjectMethod("aabbox3di", "bool intersectsWithLine(line3di &in)", - asMETHODPR(aabbox3d<s32>, intersectsWithLine, (const line3d<s32>&) const, bool), - asCALL_THISCALL); assert(r >= 0);*/ + r = engine->RegisterObjectMethod("aabbox3di", "bool intersectsWithLine(line3di &in)", + asMETHODPR(aabbox3d<f32>, intersectsWithLine, (const line3d<f32>&) const, bool), + asCALL_THISCALL); assert(r >= 0); } //! Gets the name of the aabbox3d<T> registered within AngelScript. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fuz...@us...> - 2009-07-20 23:45:04
|
Revision: 82 http://sirrf.svn.sourceforge.net/sirrf/?rev=82&view=rev Author: fuzzyspo0n Date: 2009-07-20 23:44:57 +0000 (Mon, 20 Jul 2009) Log Message: ----------- Fixed broken project settings in release mode removed extra paths in the settings for the project Fixed the console and added _SIRRF_SHOWCONSOLE in main.cpp (might move to the options rather) Fixed the asDWORD to float conversion error Removed the s32 version of aabbox3d because thats what breaks the build. Will investigate more soon. Modified Paths: -------------- trunk/build/msvc2008/sirrf.vcproj trunk/src/main.cpp trunk/src/scripting/core/asGameState.cpp trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp Modified: trunk/build/msvc2008/sirrf.vcproj =================================================================== --- trunk/build/msvc2008/sirrf.vcproj 2009-07-17 14:13:06 UTC (rev 81) +++ trunk/build/msvc2008/sirrf.vcproj 2009-07-20 23:44:57 UTC (rev 82) @@ -61,10 +61,10 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="irrlicht.lib angelscript.lib" + AdditionalDependencies="irrlicht.lib" OutputFile="../../bin/$(ProjectName)_debug.exe" LinkIncremental="2" - AdditionalLibraryDirectories="G:\dev\shadowracer\libs\angelscript_2.16.1\sdk\angelscript\lib;"G:\dev\irrlicht\lib\Win32-visualstudio"" + AdditionalLibraryDirectories="" GenerateDebugInformation="true" SubSystem="1" TargetMachine="1" @@ -119,12 +119,12 @@ Optimization="2" EnableIntrinsicFunctions="true" AdditionalIncludeDirectories="../../src/vendor;../../src" - PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + PreprocessorDefinitions="WIN32;NDEBUG;" RuntimeLibrary="2" EnableFunctionLevelLinking="true" UsePrecompiledHeader="0" WarningLevel="3" - DebugInformationFormat="3" + DebugInformationFormat="0" /> <Tool Name="VCManagedResourceCompilerTool" @@ -137,12 +137,12 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="irrlicht.lib angelscript.lib" + AdditionalDependencies="irrlicht.lib" OutputFile="../../bin/$(ProjectName).exe" LinkIncremental="1" - AdditionalLibraryDirectories="G:\dev\shadowracer\libs\angelscript_2.16.1\sdk\angelscript\lib;"G:\dev\irrlicht\lib\Win32-visualstudio"" - GenerateDebugInformation="true" - SubSystem="1" + AdditionalLibraryDirectories="" + GenerateDebugInformation="false" + SubSystem="2" OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1" Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2009-07-17 14:13:06 UTC (rev 81) +++ trunk/src/main.cpp 2009-07-20 23:44:57 UTC (rev 82) @@ -35,18 +35,18 @@ // Include files #include "core/GameManager.h" -// Windows specifics for the console -#if defined(WIN32) -#include <windows.h> -#endif //WIN32 +//Uncomment below for console in release mode +#define _SIRRF_SHOWCONSOLE +#if(defined(WIN32) && (!defined(_DEBUG)) && (!defined(_SIRRF_SHOWCONSOLE))) + #pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") +#elif (defined(_SIRRF_SHOWCONSOLE) || defined(_DEBUG)) + #pragma comment(linker, "/SUBSYSTEM:CONSOLE") +#endif + // Main function //! Main entry point to the application. -#if (defined(WIN32) && (!defined(_DEBUG))) -int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) -#else int main() -#endif { // Initialise the game. GameManager *game = GameManager::Instance(); Modified: trunk/src/scripting/core/asGameState.cpp =================================================================== --- trunk/src/scripting/core/asGameState.cpp 2009-07-17 14:13:06 UTC (rev 81) +++ trunk/src/scripting/core/asGameState.cpp 2009-07-20 23:44:57 UTC (rev 82) @@ -79,7 +79,7 @@ mContext->Prepare(id); mContext->SetObject(mObject); - mContext->SetArgDWord(0, deltaTime); + mContext->SetArgDWord(0, (asDWORD)deltaTime); mContext->Execute(); } Modified: trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp =================================================================== --- trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-07-17 14:13:06 UTC (rev 81) +++ trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-07-20 23:44:57 UTC (rev 82) @@ -212,7 +212,7 @@ void bindAabbox3d(asIScriptEngine *engine) { bindAabbox3dT<f32>(engine, "aabbox3df", "f32"); - bindAabbox3dT<s32>(engine, "aabbox3di", "s32"); + //bindAabbox3dT<s32>(engine, "aabbox3di", "s32"); //Removed for now : FuzzYspo0N // These functions are binded separetely due to a compile error with MSVC (Thanks FuzzYspo0n) int r; @@ -220,9 +220,11 @@ r = engine->RegisterObjectMethod("aabbox3df", "bool intersectsWithLine(line3df &in)", asMETHODPR(aabbox3d<f32>, intersectsWithLine, (const line3d<f32>&) const, bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("aabbox3di", "bool intersectsWithLine(line3di &in)", + + //Removed for now : FuzzYspo0N (this is the cause of the error in the fabs) + /*r = engine->RegisterObjectMethod("aabbox3di", "bool intersectsWithLine(line3di &in)", asMETHODPR(aabbox3d<s32>, intersectsWithLine, (const line3d<s32>&) const, bool), - asCALL_THISCALL); assert(r >= 0); + asCALL_THISCALL); assert(r >= 0);*/ } //! Gets the name of the aabbox3d<T> registered within AngelScript. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-17 14:13:14
|
Revision: 81 http://sirrf.svn.sourceforge.net/sirrf/?rev=81&view=rev Author: zccdark203 Date: 2009-07-17 14:13:06 +0000 (Fri, 17 Jul 2009) Log Message: ----------- Finished the implementation of the XML-parser of the SceneComponent class. Modified Paths: -------------- trunk/src/components/components.cpp trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h Modified: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp 2009-07-15 11:24:37 UTC (rev 80) +++ trunk/src/components/components.cpp 2009-07-17 14:13:06 UTC (rev 81) @@ -35,7 +35,7 @@ parsers.push_back(MeshComponent::parseXML); parsers.push_back(OctTreeComponent::parseXML); //parsers.push_back(ParticleSysComponent::parseXML); - //parsers.push_back(SceneComponent::parseXML); + parsers.push_back(SceneComponent::parseXML); //parsers.push_back(SkyBoxComponent::parseXML); //parsers.push_back(SkyDomeComponent::parseXML); parsers.push_back(TerrainComponent::parseXML); Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) +++ trunk/src/components/scene/SceneComponent.cpp 2009-07-17 14:13:06 UTC (rev 81) @@ -349,11 +349,252 @@ mSceneNode->setVisible(true); } +// Parses for a SceneComponent. +bool SceneComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + SceneComponent *component = NULL; + + // Are we dealing with a SceneComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("SceneComponent") == file->getNodeName()) + { + // Initialise the component. + component = new SceneComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // Derived elements. + SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </SceneComponent> + if(stringw("SceneComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // Parses for the base elements of a SceneComponent. void SceneComponent::parseBaseXML(IXMLReader *file, SceneComponent *component) { + // <collisionResponseAnimator> + if(stringw("collisionResponseAnimator") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df ellipsoidRadius; + vector3df gravityPerSecond; + vector3df ellipsoidTranslation; + f32 slidingValue; + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <ellipsoidRadius> + if(stringw("ellipsoidRadius") == file->getNodeName()) + { + ellipsoidRadius = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <gravityPerSecond> + else if(stringw("gravityPerSecond") == file->getNodeName()) + { + gravityPerSecond = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <ellipsoidTranslation> + else if(stringw("ellipsoidTranslation") == file->getNodeName()) + { + ellipsoidTranslation = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <slidingValue> + else if(stringw("slidingValue") == file->getNodeName()) + slidingValue = file->getAttributeValueAsFloat(L"value"); + + break; + + case io::EXN_ELEMENT_END: + + // </collisionRespondAnimator> + if(stringw("collisionRespondAnimator") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the animator. + component->addCollisionResponseAnimator(ellipsoidRadius, gravityPerSecond, + ellipsoidTranslation, slidingValue); + } + + // <flyCircleAnimator> + else if(stringw("flyCircleAnimator") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df center; + f32 radius; + f32 speed; + vector3df direction; + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <center> + if(stringw("center") == file->getNodeName()) + { + center = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <radius> + else if(stringw("radius") == file->getNodeName()) + radius = file->getAttributeValueAsFloat(L"value"); + + // <slidingValue> + else if(stringw("speed") == file->getNodeName()) + speed = file->getAttributeValueAsFloat(L"value"); + + // <direction> + if(stringw("direction") == file->getNodeName()) + { + direction = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + break; + + case io::EXN_ELEMENT_END: + + // </flyCircleAnimator> + if(stringw("flyCircleAnimator") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the animator. + component->addFlyCircleAnimator(center, radius, speed, direction); + } + + // <flyStraightAnimator> + else if(stringw("flyStraightAnimator") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df startPoint; + vector3df endPoint; + u32 timeForWay; + bool loop; + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <startPoint> + if(stringw("startPoint") == file->getNodeName()) + { + startPoint = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <endPoint> + else if(stringw("endPoint") == file->getNodeName()) + { + endPoint = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <timeForWay> + else if(stringw("timeForWay") == file->getNodeName()) + timeForWay = (u32)file->getAttributeValueAsInt(L"timeForWay"); + + // <slidingValue> + else if(stringw("slidingValue") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + loop = (value == "true") ? true : false ; + } + + break; + + case io::EXN_ELEMENT_END: + + // </flyStraightAnimator> + if(stringw("flyStraightAnimator") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the animator. + component->addFlyStraightAnimator(startPoint, endPoint, timeForWay, loop); + } + // <absolutePosition> - if(stringw("absolutePosition") == file->getNodeName()) + else if(stringw("absolutePosition") == file->getNodeName()) { component->setAbsolutePosition( vector3df(file->getAttributeValueAsFloat(L"x"), file->getAttributeValueAsFloat(L"y"), @@ -361,7 +602,7 @@ } // <automaticCulling> - if(stringw("automaticCulling") == file->getNodeName()) + else if(stringw("automaticCulling") == file->getNodeName()) { stringc value = file->getAttributeValue(L"value"); E_CULLING_TYPE type; @@ -384,14 +625,14 @@ } // <canAffectParent> - if(stringw("canAffectParent") == file->getNodeName()) + else if(stringw("canAffectParent") == file->getNodeName()) { stringc value = file->getAttributeValue(L"value"); component->setCanAffectParent( (value == "true") ? true : false ); } // <materialFlag> - if(stringw("materialFlag") == file->getNodeName()) + else if(stringw("materialFlag") == file->getNodeName()) { stringc fileflag = file->getAttributeValue(L"fileflag"); E_MATERIAL_FLAG flag; @@ -426,14 +667,14 @@ } // <materialTexture> - if(stringw("materialTexture") == file->getNodeName()) + else if(stringw("materialTexture") == file->getNodeName()) { stringc fileName = file->getAttributeValue(L"fileName"); component->setMaterialTexture(file->getAttributeValueAsInt(L"layer"), fileName.c_str()); } // <materialType> - if(stringw("materialType") == file->getNodeName()) + else if(stringw("materialType") == file->getNodeName()) { stringc value = file->getAttributeValue(L"value"); E_MATERIAL_TYPE type; @@ -476,7 +717,7 @@ } // <position> - if(stringw("position") == file->getNodeName()) + else if(stringw("position") == file->getNodeName()) { component->setPosition( vector3df(file->getAttributeValueAsFloat(L"x"), file->getAttributeValueAsFloat(L"y"), @@ -484,7 +725,7 @@ } // <rotation> - if(stringw("rotation") == file->getNodeName()) + else if(stringw("rotation") == file->getNodeName()) { component->setRotation( vector3df(file->getAttributeValueAsFloat(L"x"), file->getAttributeValueAsFloat(L"y"), @@ -492,7 +733,7 @@ } // <scale> - if(stringw("scale") == file->getNodeName()) + else if(stringw("scale") == file->getNodeName()) { component->setScale( vector3df(file->getAttributeValueAsFloat(L"x"), file->getAttributeValueAsFloat(L"y"), Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-07-15 11:24:37 UTC (rev 80) +++ trunk/src/components/scene/SceneComponent.h 2009-07-17 14:13:06 UTC (rev 81) @@ -178,6 +178,9 @@ //! @note For internal use only! void onUnPause(void *p); + //! Parses for a SceneComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); //! Parses for the base elements of a SceneComponent. //! @note For internal use only! static void parseBaseXML(IXMLReader *file, SceneComponent *component); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-15 11:24:39
|
Revision: 80 http://sirrf.svn.sourceforge.net/sirrf/?rev=80&view=rev Author: zccdark203 Date: 2009-07-15 11:24:37 +0000 (Wed, 15 Jul 2009) Log Message: ----------- Added XML-parsers for the BillboardComponent, ImageComponent, MeshComponent, OctTreeComponent, TerrainComponent and TextBillboardComponent classes. Furthermore I made a slight adjustmest to the initialisation through XML-parsing of the SoundListenerComponent class. Modified Paths: -------------- trunk/src/components/components.cpp trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/BillboardComponent.cpp trunk/src/components/scene/BillboardComponent.h trunk/src/components/scene/ImageComponent.cpp trunk/src/components/scene/ImageComponent.h trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/MeshComponent.h trunk/src/components/scene/OctTreeComponent.cpp trunk/src/components/scene/OctTreeComponent.h trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/scene/TerrainComponent.h trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/components/scene/TextBillboardComponent.h trunk/src/components/sound/SoundListenerComponent.cpp Modified: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/components.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -28,6 +28,18 @@ std::vector<bool (*)(IXMLReader*, Entity*)> parsers; parsers.push_back(AnimatedMeshComponent::parseXML); + parsers.push_back(BillboardComponent::parseXML); + //parsers.push_back(CameraComponent::parseXML); + parsers.push_back(ImageComponent::parseXML); + //parsers.push_back(LightComponent::parseXML); + parsers.push_back(MeshComponent::parseXML); + parsers.push_back(OctTreeComponent::parseXML); + //parsers.push_back(ParticleSysComponent::parseXML); + //parsers.push_back(SceneComponent::parseXML); + //parsers.push_back(SkyBoxComponent::parseXML); + //parsers.push_back(SkyDomeComponent::parseXML); + parsers.push_back(TerrainComponent::parseXML); + parsers.push_back(TextBillboardComponent::parseXML); #ifdef __COMPILE_WITH_SFML_AUDIO__ parsers.push_back(SoundListenerComponent::parseXML); Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -276,7 +276,7 @@ else if(stringw("transitionTime") == file->getNodeName()) component->setTransitionTime(file->getAttributeValueAsFloat(L"value")); - // Is the element derived from SceneComponent? + // Derived elements. else SceneComponent::parseBaseXML(file, component); break; Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -89,4 +89,99 @@ mBillboardSN->setSize(size); } +// Parses for a BillboardComponent. +bool BillboardComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + BillboardComponent *component = NULL; + + // Are we dealing with a BillboardComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("BillboardComponent") == file->getNodeName()) + { + // Initialise the component. + component = new BillboardComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // Derived elements. + if(!BillboardComponent::parseBaseXML(file, component)) + SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </BillboardComponent> + if(stringw("BillboardComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + +// Parses for the base elements of a BillboardComponent. +bool BillboardComponent::parseBaseXML(IXMLReader *file, BillboardComponent *component) +{ + // <color> + if(stringw("color") == file->getNodeName()) + { + if(stringw("") != file->getAttributeValue(L"overallR")) + { + component->setColor( SColor( file->getAttributeValueAsInt(L"overallR"), + file->getAttributeValueAsInt(L"overallG"), + file->getAttributeValueAsInt(L"overallB"), + file->getAttributeValueAsInt(L"overallA") ) ); + + return true; + } + + else + { + component->setColor( SColor( file->getAttributeValueAsInt(L"topR"), + file->getAttributeValueAsInt(L"topG"), + file->getAttributeValueAsInt(L"topB"), + file->getAttributeValueAsInt(L"topA") ), + SColor( file->getAttributeValueAsInt(L"bottomR"), + file->getAttributeValueAsInt(L"bottomG"), + file->getAttributeValueAsInt(L"bottomB"), + file->getAttributeValueAsInt(L"bottomA") ) ); + + return true; + } + } + + // <size> + else if(stringw("size") == file->getNodeName()) + { + component->setSize(dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height") ) ); + + return true; + } + + // We couldn't find any known elements. + return false; +} + // End of File Modified: trunk/src/components/scene/BillboardComponent.h =================================================================== --- trunk/src/components/scene/BillboardComponent.h 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/BillboardComponent.h 2009-07-15 11:24:37 UTC (rev 80) @@ -62,6 +62,14 @@ //! @param size Size of the billboard. void setSize(const dimension2df &size); + //! Parses for a BillboardComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + + //! Parses for the base elements of a BillboardComponent. + //! @note For internal use only! + static bool parseBaseXML(IXMLReader *file, BillboardComponent *component); + protected: // Initialisation Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/ImageComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -236,4 +236,102 @@ mVisible = mWasVisible; } +// Parses for a ImageComponent. +bool ImageComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + ImageComponent *component = NULL; + + // Are we dealing with a ImageComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("ImageComponent") == file->getNodeName()) + { + // Initialise the component. + component = new ImageComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <alphaColor> + if(stringw("alphaColor") == file->getNodeName()) + { + component->setAlphaColor( SColor(file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b"), + file->getAttributeValueAsInt(L"a")) ); + } + + // <clipRect> + if(stringw("clipRect") == file->getNodeName()) + { + rect<s32> clipRect = rect<s32>( file->getAttributeValueAsInt(L"x1"), + file->getAttributeValueAsInt(L"y1"), + file->getAttributeValueAsInt(L"x2"), + file->getAttributeValueAsInt(L"y2") ); + + component->setClipRect(&clipRect); + } + + // <color> + if(stringw("color") == file->getNodeName()) + { + component->setColor( SColor(file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b"), + file->getAttributeValueAsInt(L"a")) ); + } + + // <position> + if(stringw("position") == file->getNodeName()) + { + component->setPosition(vector2di(file->getAttributeValueAsInt(L"x"), + file->getAttributeValueAsInt(L"y")) ); + } + + // <texture> + if(stringw("texture") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + component->setTexture(fileName.c_str()); + } + + // <useAlphaColor> + if(stringw("useAlphaColor") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setUseAlphaColor( (value == "true") ? true : false ); + } + + + break; + + case io::EXN_ELEMENT_END: + + // </ImageComponent> + if(stringw("ImageComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/ImageComponent.h =================================================================== --- trunk/src/components/scene/ImageComponent.h 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/ImageComponent.h 2009-07-15 11:24:37 UTC (rev 80) @@ -118,6 +118,10 @@ //! @note For internal use only! void onUnPause(void *p); + //! Parses for a ImageComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Private members Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/MeshComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -106,4 +106,61 @@ mMeshSN->setMesh(mesh); } +// Parses for a MeshComponent. +bool MeshComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + MeshComponent *component = NULL; + + // Are we dealing with a MeshComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("MeshComponent") == file->getNodeName()) + { + // Initialise the component. + component = new MeshComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <mesh> + if(stringw("mesh") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + component->setMesh(fileName.c_str()); + } + + // Derived elements. + else SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </MeshComponent> + if(stringw("MeshComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/MeshComponent.h 2009-07-15 11:24:37 UTC (rev 80) @@ -68,6 +68,10 @@ //! @note Not available in AngelScript. void setMesh(IMesh *mesh); + //! Parses for a MeshComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Members Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -74,4 +74,55 @@ { } +// Parses for a OctTreeComponent. +bool OctTreeComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + OctTreeComponent *component = NULL; + + // Are we dealing with a OctTreeComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("OctTreeComponent") == file->getNodeName()) + { + // Get attributes. + stringc fileName = file->getAttributeValue(L"fileName"); + + // Initialise the component. + component = new OctTreeComponent(entity, fileName.c_str()); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + // Derived elements. + SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </OctTreeComponent> + if(stringw("OctTreeComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/OctTreeComponent.h =================================================================== --- trunk/src/components/scene/OctTreeComponent.h 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/OctTreeComponent.h 2009-07-15 11:24:37 UTC (rev 80) @@ -53,6 +53,10 @@ OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, s32 minPolysPerNode = 512); //! Deconstructor ~OctTreeComponent(); + + //! Parses for a OctTreeComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); }; #endif Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -120,4 +120,68 @@ mTerrainSN->scaleTexture(scale, scale2); } +// Parses for a TerrainComponent. +bool TerrainComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + TerrainComponent *component = NULL; + + // Are we dealing with a MeshComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("TerrainComponent") == file->getNodeName()) + { + // Initialise the component. + component = new TerrainComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <heightMap> + if(stringw("heightMap") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + component->loadHeightMap(fileName.c_str()); + } + + // <textureScale> + else if(stringw("textureScale") == file->getNodeName()) + { + component->scaleTexture(file->getAttributeValueAsFloat(L"scale"), + file->getAttributeValueAsFloat(L"scale2")); + } + + // Derived elements. + else SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </TerrainComponent> + if(stringw("TerrainComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/TerrainComponent.h =================================================================== --- trunk/src/components/scene/TerrainComponent.h 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/TerrainComponent.h 2009-07-15 11:24:37 UTC (rev 80) @@ -82,6 +82,9 @@ //! coordinate set by this value. void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f); + //! Parses for a TerrainComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); private: Modified: trunk/src/components/scene/TextBillboardComponent.cpp =================================================================== --- trunk/src/components/scene/TextBillboardComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/TextBillboardComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -118,4 +118,71 @@ mBillboardTextSN->setTextColor(color); } +// Parses for a TextBillboardComponent. +bool TextBillboardComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + TextBillboardComponent *component = NULL; + + // Are we dealing with a TextBillboardComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("TextBillboardComponent") == file->getNodeName()) + { + // Initialise the component. + component = new TextBillboardComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <text> + if(stringw("text") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setText(value.c_str()); + } + + // <textColor> + else if(stringw("textColor") == file->getNodeName()) + { + component->setColor( SColor( file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b"), + file->getAttributeValueAsInt(L"a") ) ); + } + + // Derived elements. + else if(!BillboardComponent::parseBaseXML(file, component)) + SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </TextBillboardComponent> + if(stringw("TextBillboardComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/TextBillboardComponent.h =================================================================== --- trunk/src/components/scene/TextBillboardComponent.h 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/scene/TextBillboardComponent.h 2009-07-15 11:24:37 UTC (rev 80) @@ -72,6 +72,10 @@ //! @param color New color of the text. void setTextColor(const SColor &color); + //! Parses for a TextBillboardComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Members Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-15 11:24:37 UTC (rev 80) @@ -133,7 +133,7 @@ if(stringw("SoundListenerComponent") == file->getNodeName()) { // Initialise the component. - component = new SoundListenerComponent(entity, true); + component = new SoundListenerComponent(entity, false); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-14 17:11:21
|
Revision: 79 http://sirrf.svn.sourceforge.net/sirrf/?rev=79&view=rev Author: zccdark203 Date: 2009-07-14 17:11:20 +0000 (Tue, 14 Jul 2009) Log Message: ----------- Made some additions to the AngelScript bindings of aabbox3d<T>, vector2d<T> and vector3d<T>. These should now compile on MSVC. Also, MSVC 2008 project files have been added. Both changes were possible thanks to FuzzYspo0N. Modified Paths: -------------- trunk/CHANGES trunk/CONTRIBUTORS trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/core/DataStack.cpp trunk/src/main.cpp trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp trunk/src/scripting/vendor/irrlicht/asVector2d.cpp trunk/src/scripting/vendor/irrlicht/asVector3d.cpp Added Paths: ----------- trunk/build/msvc2008/ trunk/build/msvc2008/sirrf.sln trunk/build/msvc2008/sirrf.vcproj Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/CHANGES 2009-07-14 17:11:20 UTC (rev 79) @@ -2,6 +2,12 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Added MSVC 2008 project files. Thanks to FuzzYspo0N for making them. + + * Made some additions to the AngelScript bindings of aabbox3d<T>, + vector2d<T> and vector3d<T>. These should now compile on MSVC. + Thanks to FuzzYspo0N for reporting! + * The SoundListenerComponent and SoundSourceComponent classes now properly inherit the position of their parent entity. Modified: trunk/CONTRIBUTORS =================================================================== --- trunk/CONTRIBUTORS 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/CONTRIBUTORS 2009-07-14 17:11:20 UTC (rev 79) @@ -6,3 +6,4 @@ FuzzYspo0N - Made various small bug-fixes in order to let Sirrf run on the Windows platform; + Provided MSVC 2008 project files; Added: trunk/build/msvc2008/sirrf.sln =================================================================== --- trunk/build/msvc2008/sirrf.sln (rev 0) +++ trunk/build/msvc2008/sirrf.sln 2009-07-14 17:11:20 UTC (rev 79) @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C++ Express 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sirrf", "sirrf.vcproj", "{E4EFD3BA-8A8E-41DB-98C2-49721BD17C35}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E4EFD3BA-8A8E-41DB-98C2-49721BD17C35}.Debug|Win32.ActiveCfg = Debug|Win32 + {E4EFD3BA-8A8E-41DB-98C2-49721BD17C35}.Debug|Win32.Build.0 = Debug|Win32 + {E4EFD3BA-8A8E-41DB-98C2-49721BD17C35}.Release|Win32.ActiveCfg = Release|Win32 + {E4EFD3BA-8A8E-41DB-98C2-49721BD17C35}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: trunk/build/msvc2008/sirrf.vcproj =================================================================== --- trunk/build/msvc2008/sirrf.vcproj (rev 0) +++ trunk/build/msvc2008/sirrf.vcproj 2009-07-14 17:11:20 UTC (rev 79) @@ -0,0 +1,835 @@ +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="sirrf project" + ProjectGUID="{E4EFD3BA-8A8E-41DB-98C2-49721BD17C35}" + RootNamespace="sirrf" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories="../../src/vendor;../../src" + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="irrlicht.lib angelscript.lib" + OutputFile="../../bin/$(ProjectName)_debug.exe" + LinkIncremental="2" + AdditionalLibraryDirectories="G:\dev\shadowracer\libs\angelscript_2.16.1\sdk\angelscript\lib;"G:\dev\irrlicht\lib\Win32-visualstudio"" + GenerateDebugInformation="true" + SubSystem="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(SolutionDir)$(ConfigurationName)" + IntermediateDirectory="$(ConfigurationName)" + ConfigurationType="1" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + AdditionalIncludeDirectories="../../src/vendor;../../src" + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="irrlicht.lib angelscript.lib" + OutputFile="../../bin/$(ProjectName).exe" + LinkIncremental="1" + AdditionalLibraryDirectories="G:\dev\shadowracer\libs\angelscript_2.16.1\sdk\angelscript\lib;"G:\dev\irrlicht\lib\Win32-visualstudio"" + GenerateDebugInformation="true" + SubSystem="1" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="sirrf" + > + <File + RelativePath="..\..\src\config.h" + > + </File> + <File + RelativePath="..\..\src\dependencies.h" + > + </File> + <File + RelativePath="..\..\src\main.cpp" + > + </File> + <Filter + Name="components" + > + <File + RelativePath="..\..\src\components\components.cpp" + > + </File> + <File + RelativePath="..\..\src\components\components.h" + > + </File> + <Filter + Name="sound" + > + <File + RelativePath="..\..\src\components\sound\SoundListenerComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\sound\SoundListenerComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\sound\SoundSourceComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\sound\SoundSourceComponent.h" + > + </File> + </Filter> + <Filter + Name="scene" + > + <File + RelativePath="..\..\src\components\scene\AnimatedMeshComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\AnimatedMeshComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\BillboardComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\BillboardComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\CameraComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\CameraComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\ImageComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\ImageComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\LightComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\LightComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\MeshComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\MeshComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\OctTreeComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\OctTreeComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\ParticleSysComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\ParticleSysComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\SceneComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\SceneComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\SkyBoxComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\SkyBoxComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\SkyDomeComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\SkyDomeComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\TerrainComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\TerrainComponent.h" + > + </File> + <File + RelativePath="..\..\src\components\scene\TextBillboardComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\components\scene\TextBillboardComponent.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="core" + > + <File + RelativePath="..\..\src\core\AssetGroup.cpp" + > + </File> + <File + RelativePath="..\..\src\core\AssetGroup.h" + > + </File> + <File + RelativePath="..\..\src\core\AssetManager.cpp" + > + </File> + <File + RelativePath="..\..\src\core\AssetManager.h" + > + </File> + <File + RelativePath="..\..\src\core\DataStack.cpp" + > + </File> + <File + RelativePath="..\..\src\core\DataStack.h" + > + </File> + <File + RelativePath="..\..\src\core\DataStore.cpp" + > + </File> + <File + RelativePath="..\..\src\core\DataStore.h" + > + </File> + <File + RelativePath="..\..\src\core\Entity.cpp" + > + </File> + <File + RelativePath="..\..\src\core\Entity.h" + > + </File> + <File + RelativePath="..\..\src\core\EntityComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\core\EntityComponent.h" + > + </File> + <File + RelativePath="..\..\src\core\EntityManager.cpp" + > + </File> + <File + RelativePath="..\..\src\core\EntityManager.h" + > + </File> + <File + RelativePath="..\..\src\core\EventManager.cpp" + > + </File> + <File + RelativePath="..\..\src\core\EventManager.h" + > + </File> + <File + RelativePath="..\..\src\core\GameManager.cpp" + > + </File> + <File + RelativePath="..\..\src\core\GameManager.h" + > + </File> + <File + RelativePath="..\..\src\core\GameState.cpp" + > + </File> + <File + RelativePath="..\..\src\core\GameState.h" + > + </File> + <File + RelativePath="..\..\src\core\ReferenceCounted.cpp" + > + </File> + <File + RelativePath="..\..\src\core\ReferenceCounted.h" + > + </File> + </Filter> + <Filter + Name="game" + > + <File + RelativePath="..\..\src\game\readme.txt" + > + </File> + </Filter> + <Filter + Name="scripting" + > + <File + RelativePath="..\..\src\scripting\Script.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\Script.h" + > + </File> + <File + RelativePath="..\..\src\scripting\ScriptHelper.h" + > + </File> + <File + RelativePath="..\..\src\scripting\ScriptManager.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\ScriptManager.h" + > + </File> + <Filter + Name="vendor" + > + <Filter + Name="angelscript" + > + <File + RelativePath="..\..\src\scripting\vendor\angelscript\scriptstdstring.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\angelscript\scriptstdstring.h" + > + </File> + </Filter> + <Filter + Name="irrlicht" + > + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asAabbox3d.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asAabbox3d.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asDimension2d.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asDimension2d.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asIrrHelper.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asIrrlicht.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asIrrlicht.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asLine2d.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asLine2d.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asLine3d.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asLine3d.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asMatrix4.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asMatrix4.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asRect.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asRect.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asSColor.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asSColor.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asVector2d.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asVector2d.h" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asVector3d.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\vendor\irrlicht\asVector3d.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="sound" + > + <File + RelativePath="..\..\src\scripting\sound\asSoundManager.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\sound\asSoundManager.h" + > + </File> + </Filter> + <Filter + Name="components" + > + <File + RelativePath="..\..\src\scripting\components\asComponents.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\asComponents.h" + > + </File> + <Filter + Name="sound" + > + <File + RelativePath="..\..\src\scripting\components\sound\asSoundListenerComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\sound\asSoundListenerComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\sound\asSoundSourceComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\sound\asSoundSourceComponent.h" + > + </File> + </Filter> + <Filter + Name="scene" + > + <File + RelativePath="..\..\src\scripting\components\scene\asAnimatedMeshComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asAnimatedMeshComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asBillboardComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asBillboardComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asCameraComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asCameraComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asImageComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asImageComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asLightComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asLightComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asMeshComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asMeshComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asOctTreeComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asOctTreeComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asParticleSysComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asParticleSysComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asSceneComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asSceneComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asSkyBoxComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asSkyBoxComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asSkyDome.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asSkyDomeComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asTerrainComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asTerrainComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asTextBillboardComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\components\scene\asTextBillboardComponent.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="core" + > + <File + RelativePath="..\..\src\scripting\core\asDataStack.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asDataStack.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asDataStore.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asDataStore.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEntity.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEntity.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEntityComponent.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEntityComponent.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEntityManager.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEntityManager.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEventManager.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asEventManager.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asGameManager.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asGameManager.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asGameState.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asGameState.h" + > + </File> + </Filter> + <Filter + Name="game" + > + </Filter> + <Filter + Name="scripting" + > + <File + RelativePath="..\..\src\scripting\scripting\asScript.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\scripting\asScript.h" + > + </File> + <File + RelativePath="..\..\src\scripting\scripting\asScriptManager.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\scripting\asScriptManager.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="vendor" + > + <Filter + Name="sigslot" + > + <File + RelativePath="..\..\src\vendor\sigslot\sigslot.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="sound" + > + <File + RelativePath="..\..\src\sound\SoundManager.cpp" + > + </File> + <File + RelativePath="..\..\src\sound\SoundManager.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="game" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-07-14 17:11:20 UTC (rev 79) @@ -236,8 +236,8 @@ // <frameLoop> else if(stringw("frameloop") == file->getNodeName()) { - component->setFrameLoop(file->getAttributeValueAsFloat(L"start"), - file->getAttributeValueAsFloat(L"end")); + component->setFrameLoop(file->getAttributeValueAsInt(L"start"), + file->getAttributeValueAsInt(L"end")); } // <loopMode> Modified: trunk/src/core/DataStack.cpp =================================================================== --- trunk/src/core/DataStack.cpp 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/src/core/DataStack.cpp 2009-07-14 17:11:20 UTC (rev 79) @@ -152,7 +152,7 @@ // Open the given file and load the contents to the buffer. IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); - long fSize = file->getSize(); + unsigned long fSize = file->getSize(); c8 *fBuffer = new c8[fSize+1]; file->read(fBuffer, fSize); file->drop(); @@ -170,11 +170,11 @@ std::stringstream bCountStream; unsigned long bCount = 0; - int state = 0; + s32 state = 0; std::string key; std::string value; - for(unsigned int i = 25; i < fSize; i++) + for(unsigned long i = 25; i < fSize; i++) { if(bCount != 0) { Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/src/main.cpp 2009-07-14 17:11:20 UTC (rev 79) @@ -35,10 +35,18 @@ // Include files #include "core/GameManager.h" +// Windows specifics for the console +#if defined(WIN32) +#include <windows.h> +#endif //WIN32 // Main function //! Main entry point to the application. +#if (defined(WIN32) && (!defined(_DEBUG))) +int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow) +#else int main() +#endif { // Initialise the game. GameManager *game = GameManager::Instance(); Modified: trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp =================================================================== --- trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-07-14 17:11:20 UTC (rev 79) @@ -162,12 +162,6 @@ asMETHOD(aabbox3d<T>, intersectsWithBox), asCALL_THISCALL); assert(r >= 0); ss.str(""); - ss << "bool intersectsWithLine(const " << getLine3dName(asType) << " &in)"; - r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), - asMETHODPR(aabbox3d<T>, intersectsWithLine, (const line3d<T>&) const, bool), - asCALL_THISCALL); assert(r >= 0); - - ss.str(""); ss << "bool isFullInside(const " << typeName << " &in)"; r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), asMETHOD(aabbox3d<T>, isFullInside), asCALL_THISCALL); assert(r >= 0); @@ -219,6 +213,16 @@ { bindAabbox3dT<f32>(engine, "aabbox3df", "f32"); bindAabbox3dT<s32>(engine, "aabbox3di", "s32"); + + // These functions are binded separetely due to a compile error with MSVC (Thanks FuzzYspo0n) + int r; + + r = engine->RegisterObjectMethod("aabbox3df", "bool intersectsWithLine(line3df &in)", + asMETHODPR(aabbox3d<f32>, intersectsWithLine, (const line3d<f32>&) const, bool), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("aabbox3di", "bool intersectsWithLine(line3di &in)", + asMETHODPR(aabbox3d<s32>, intersectsWithLine, (const line3d<s32>&) const, bool), + asCALL_THISCALL); assert(r >= 0); } //! Gets the name of the aabbox3d<T> registered within AngelScript. Modified: trunk/src/scripting/vendor/irrlicht/asVector2d.cpp =================================================================== --- trunk/src/scripting/vendor/irrlicht/asVector2d.cpp 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/src/scripting/vendor/irrlicht/asVector2d.cpp 2009-07-14 17:11:20 UTC (rev 79) @@ -227,7 +227,7 @@ asMETHOD(vector2d<T>, getAngle), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(typeName, "f64 getAngleTrig()", - asMETHOD(vector2d<T>, getAngleTrig), asCALL_THISCALL); assert(r >= 0); + asMETHOD(vector2d<f64>, getAngleTrig), asCALL_THISCALL); assert(r >= 0); ss.str(""); ss << "f64 getAngleWith(const " << typeName << " &in)"; Modified: trunk/src/scripting/vendor/irrlicht/asVector3d.cpp =================================================================== --- trunk/src/scripting/vendor/irrlicht/asVector3d.cpp 2009-07-13 18:59:44 UTC (rev 78) +++ trunk/src/scripting/vendor/irrlicht/asVector3d.cpp 2009-07-14 17:11:20 UTC (rev 79) @@ -241,7 +241,7 @@ ss.str(""); ss << typeName << " getHorizontalAngle()"; r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), - asMETHOD(vector3d<T>, getHorizontalAngle), asCALL_THISCALL); assert(r >= 0); + asMETHOD(vector3d<f64>, getHorizontalAngle), asCALL_THISCALL); assert(r >= 0); ss.str(""); ss << typeName << " getInterpolated(const " << typeName << " &in, f64)"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-13 18:59:47
|
Revision: 78 http://sirrf.svn.sourceforge.net/sirrf/?rev=78&view=rev Author: zccdark203 Date: 2009-07-13 18:59:44 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Added some more XML-based parsers for various components. I also fixed the position inheritance of the SoundSourceComponent class. Modified Paths: -------------- trunk/CHANGES trunk/src/components/components.cpp trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/CHANGES 2009-07-13 18:59:44 UTC (rev 78) @@ -2,8 +2,8 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== - * The SoundListenerComponent class now properly inherits the position - of his parent entity. + * The SoundListenerComponent and SoundSourceComponent classes now + properly inherit the position of their parent entity. * Added loadMusicFromMemory to the SoundSourceComponent class. With this method you can pass a self-loaded buffer to the component. Modified: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/components.cpp 2009-07-13 18:59:44 UTC (rev 78) @@ -27,8 +27,11 @@ // Create a list of available parse functions. std::vector<bool (*)(IXMLReader*, Entity*)> parsers; + parsers.push_back(AnimatedMeshComponent::parseXML); + #ifdef __COMPILE_WITH_SFML_AUDIO__ parsers.push_back(SoundListenerComponent::parseXML); + parsers.push_back(SoundSourceComponent::parseXML); #endif // __COMPILE_WITH_SFML_AUDIO__ // Read from the file. Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-07-13 18:59:44 UTC (rev 78) @@ -203,4 +203,101 @@ mAnimatedMeshSN->setTransitionTime(time); } +// Parses for a AnimatedMeshComponent. +bool AnimatedMeshComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + AnimatedMeshComponent *component = NULL; + + // Are we dealing with a AnimatedMeshComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("AnimatedMeshComponent") == file->getNodeName()) + { + // Initialise the component. + component = new AnimatedMeshComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <animationSpeed> + if(stringw("animationSpeed") == file->getNodeName()) + component->setAnimationSpeed(file->getAttributeValueAsFloat(L"value")); + + // <frameLoop> + else if(stringw("frameloop") == file->getNodeName()) + { + component->setFrameLoop(file->getAttributeValueAsFloat(L"start"), + file->getAttributeValueAsFloat(L"end")); + } + + // <loopMode> + else if(stringw("loopMode") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setLoopMode( (value == "true") ? true : false ); + } + + // <MD2Animation> + else if(stringw("MD2Animation") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setMD2Animation(value.c_str()); + } + + // <mesh> + else if(stringw("mesh") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + component->setMesh(fileName.c_str()); + } + + // <shadowVolumeMeshSceneNode> + else if(stringw("shadowVolumeMeshSceneNode") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + stringc zfailmethod = file->getAttributeValue(L"value"); + + component->setShadowVolumeSceneNode(fileName.c_str(), + (zfailmethod == "true") ? true : false, + file->getAttributeValueAsFloat(L"infinity")); + } + + // <transitionTime> + else if(stringw("transitionTime") == file->getNodeName()) + component->setTransitionTime(file->getAttributeValueAsFloat(L"value")); + + // Is the element derived from SceneComponent? + else SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </AnimatedMeshComponent> + if(stringw("AnimatedMeshComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-07-13 18:59:44 UTC (rev 78) @@ -119,6 +119,10 @@ //! @param time Transition time in seconds. void setTransitionTime(f32 time); + //! Parses for a AnimatedMeshComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Members Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/scene/SceneComponent.cpp 2009-07-13 18:59:44 UTC (rev 78) @@ -349,4 +349,162 @@ mSceneNode->setVisible(true); } +// Parses for the base elements of a SceneComponent. +void SceneComponent::parseBaseXML(IXMLReader *file, SceneComponent *component) +{ + // <absolutePosition> + if(stringw("absolutePosition") == file->getNodeName()) + { + component->setAbsolutePosition( vector3df(file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ) ); + } + + // <automaticCulling> + if(stringw("automaticCulling") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + E_CULLING_TYPE type; + +#define retrieveCullingType(x) \ +else if(value == #x) \ + type = x + + if(value == "") + type = EAC_OFF; // Dummy behaviour. + + retrieveCullingType(EAC_OFF); + retrieveCullingType(EAC_BOX); + retrieveCullingType(EAC_FRUSTUM_BOX); + retrieveCullingType(EAC_FRUSTUM_SPHERE); + +#undef retrieveCullingType + + component->setAutomaticCulling(type); + } + + // <canAffectParent> + if(stringw("canAffectParent") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setCanAffectParent( (value == "true") ? true : false ); + } + + // <materialFlag> + if(stringw("materialFlag") == file->getNodeName()) + { + stringc fileflag = file->getAttributeValue(L"fileflag"); + E_MATERIAL_FLAG flag; + +#define retrieveMaterialFlag(x) \ +else if(fileflag == #x) \ + flag = x + + if(fileflag == "") + flag = EMF_WIREFRAME; // Dummy behaviour. + + retrieveMaterialFlag(EMF_WIREFRAME); + retrieveMaterialFlag(EMF_POINTCLOUD); + retrieveMaterialFlag(EMF_GOURAUD_SHADING); + retrieveMaterialFlag(EMF_LIGHTING); + retrieveMaterialFlag(EMF_ZBUFFER); + retrieveMaterialFlag(EMF_ZWRITE_ENABLE); + retrieveMaterialFlag(EMF_BACK_FACE_CULLING); + retrieveMaterialFlag(EMF_FRONT_FACE_CULLING); + retrieveMaterialFlag(EMF_BILINEAR_FILTER); + retrieveMaterialFlag(EMF_TRILINEAR_FILTER); + retrieveMaterialFlag(EMF_ANISOTROPIC_FILTER); + retrieveMaterialFlag(EMF_FOG_ENABLE); + retrieveMaterialFlag(EMF_NORMALIZE_NORMALS); + retrieveMaterialFlag(EMF_TEXTURE_WRAP); + +#undef retrieveMaterialFlag + + stringc value = file->getAttributeValue(L"value"); + + component->setMaterialFlag(flag, (value == "true") ? true : false ); + } + + // <materialTexture> + if(stringw("materialTexture") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + component->setMaterialTexture(file->getAttributeValueAsInt(L"layer"), fileName.c_str()); + } + + // <materialType> + if(stringw("materialType") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + E_MATERIAL_TYPE type; + +#define retrieveMaterialType(x) \ +else if(value == #x) \ + type = x + + if(value == "") + type = EMT_SOLID; // Dummy behaviour. + + retrieveMaterialType(EMT_SOLID); + retrieveMaterialType(EMT_SOLID_2_LAYER); + retrieveMaterialType(EMT_LIGHTMAP); + retrieveMaterialType(EMT_LIGHTMAP_ADD); + retrieveMaterialType(EMT_LIGHTMAP_M2); + retrieveMaterialType(EMT_LIGHTMAP_M4); + retrieveMaterialType(EMT_LIGHTMAP_LIGHTING); + retrieveMaterialType(EMT_LIGHTMAP_LIGHTING_M2); + retrieveMaterialType(EMT_LIGHTMAP_LIGHTING_M4); + retrieveMaterialType(EMT_DETAIL_MAP); + retrieveMaterialType(EMT_SPHERE_MAP); + retrieveMaterialType(EMT_REFLECTION_2_LAYER); + retrieveMaterialType(EMT_TRANSPARENT_ADD_COLOR); + retrieveMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL); + retrieveMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL_REF); + retrieveMaterialType(EMT_TRANSPARENT_VERTEX_ALPHA); + retrieveMaterialType(EMT_TRANSPARENT_REFLECTION_2_LAYER); + retrieveMaterialType(EMT_NORMAL_MAP_SOLID); + retrieveMaterialType(EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR); + retrieveMaterialType(EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA); + retrieveMaterialType(EMT_PARALLAX_MAP_SOLID); + retrieveMaterialType(EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR); + retrieveMaterialType(EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA); + retrieveMaterialType(EMT_ONETEXTURE_BLEND); + +#undef retrieveMaterialType + + component->setMaterialType(type); + } + + // <position> + if(stringw("position") == file->getNodeName()) + { + component->setPosition( vector3df(file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ) ); + } + + // <rotation> + if(stringw("rotation") == file->getNodeName()) + { + component->setRotation( vector3df(file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ) ); + } + + // <scale> + if(stringw("scale") == file->getNodeName()) + { + component->setScale( vector3df(file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ) ); + } + + // <visisble> + else if(stringw("visible") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setVisible( (value == "true") ? true : false ); + } +} + // End of File Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/scene/SceneComponent.h 2009-07-13 18:59:44 UTC (rev 78) @@ -178,6 +178,10 @@ //! @note For internal use only! void onUnPause(void *p); + //! Parses for the base elements of a SceneComponent. + //! @note For internal use only! + static void parseBaseXML(IXMLReader *file, SceneComponent *component); + protected: // Initialisation Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-13 18:59:44 UTC (rev 78) @@ -121,8 +121,7 @@ setIsMainListener(true); } -//! Parses for a SoundListenerComponent. -//! @note For internal use only! +// Parses for a SoundListenerComponent. bool SoundListenerComponent::parseXML(IXMLReader *file, Entity *entity) { // Forward declaration. @@ -134,7 +133,7 @@ if(stringw("SoundListenerComponent") == file->getNodeName()) { // Initialise the component. - component = new SoundListenerComponent(entity, false); + component = new SoundListenerComponent(entity, true); } } @@ -148,8 +147,15 @@ { case io::EXN_ELEMENT: + // <isMainListener> + if(stringw("isMainListener") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setIsMainListener( (value == "true") ? true : false ); + } + // <target> - if(stringw("target") == file->getNodeName()) + else if(stringw("target") == file->getNodeName()) { f32 x, y, z; x = file->getAttributeValueAsFloat(L"x"); Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-07-13 18:59:44 UTC (rev 78) @@ -23,7 +23,7 @@ // SoundSource constructor. SoundSourceComponent::SoundSourceComponent(Entity *parent) : EntityComponent(parent), mSound(NULL), mMusic(NULL), mBuffer(NULL), mAttenuation(1.0f), - mLoop(false), mMinDistance(1.0f), mPitch(1.0f), mPosition(vector3df(0, 0, 0)), mVolume(100) + mLoop(false), mMinDistance(1.0f), mPitch(1.0f), mPosition(parent->getPosition()), mVolume(100) { // Get a pointer to sub-systems of the Game Manager. EventManager *pEventMgr = GameManager::Instance()->getEventManager(); @@ -426,6 +426,89 @@ play(); } +// Parses for a SoundSourceComponent. +bool SoundSourceComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + SoundSourceComponent *component = NULL; + + // Are we dealing with a SoundSourceComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("SoundSourceComponent") == file->getNodeName()) + { + // Initialise the component. + component = new SoundSourceComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <attenuation> + if(stringw("attenuation") == file->getNodeName()) + component->setAttenuation(file->getAttributeValueAsFloat(L"value")); + + // <loop> + else if(stringw("loop") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setLoop( (value == "true") ? true : false ); + } + + // <minDistance> + else if(stringw("minDistance") == file->getNodeName()) + component->setMinDistance(file->getAttributeValueAsFloat(L"value")); + + // <music> + else if(stringw("music") == file->getNodeName()) + { + stringc fileName = file->getAttributeValue(L"fileName"); + component->loadMusic(fileName.c_str()); + } + + // <pitch> + else if(stringw("pitch") == file->getNodeName()) + component->setPitch(file->getAttributeValueAsFloat(L"value")); + + else if(stringw("soundBuffer") == file->getNodeName()) + { + stringc bufferName = file->getAttributeValue(L"bufferName"); + component->loadSoundBuffer(bufferName.c_str()); + } + + // <volume> + else if(stringw("volume") == file->getNodeName()) + component->setVolume(file->getAttributeValueAsFloat(L"value")); + + break; + + case io::EXN_ELEMENT_END: + + // </SoundSourceComponent> + if(stringw("SoundSourceComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + #endif // __COMPILE_WITH_SFML_AUDIO__ // End of File Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-07-13 14:42:35 UTC (rev 77) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-07-13 18:59:44 UTC (rev 78) @@ -121,6 +121,10 @@ //! @note For internal use only! void onUnPause(void *p); + //! Parses for a SoundSourceComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Members This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-13 14:42:39
|
Revision: 77 http://sirrf.svn.sourceforge.net/sirrf/?rev=77&view=rev Author: zccdark203 Date: 2009-07-13 14:42:35 +0000 (Mon, 13 Jul 2009) Log Message: ----------- Started with the implementation of an parser for XML-based entity files. Currently the parser is still very limited, but the base is done. Also, I made a small bugfix in the SoundListenerComponent class. Modified Paths: -------------- trunk/CHANGES trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/components/components.h trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundListenerComponent.h trunk/src/core/DataStack.cpp trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h Added Paths: ----------- trunk/src/components/components.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/CHANGES 2009-07-13 14:42:35 UTC (rev 77) @@ -2,6 +2,9 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * The SoundListenerComponent class now properly inherits the position + of his parent entity. + * Added loadMusicFromMemory to the SoundSourceComponent class. With this method you can pass a self-loaded buffer to the component. A loadMusicFromAssetGroup method has also been added. Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/build/CMake/CMakeLists.txt 2009-07-13 14:42:35 UTC (rev 77) @@ -13,6 +13,7 @@ ${SOURCE_DIR}main.cpp # src/components + ${SOURCE_DIR}components/components.cpp # src/components/scene ${SOURCE_DIR}components/scene/AnimatedMeshComponent.cpp ${SOURCE_DIR}components/scene/BillboardComponent.cpp Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-07-13 14:42:35 UTC (rev 77) @@ -58,6 +58,7 @@ <Add option="-Wall" /> <Add directory="../../src/vendor" /> </Compiler> + <Unit filename="../../src/components/components.cpp" /> <Unit filename="../../src/components/components.h" /> <Unit filename="../../src/components/scene/AnimatedMeshComponent.cpp" /> <Unit filename="../../src/components/scene/AnimatedMeshComponent.h" /> Added: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp (rev 0) +++ trunk/src/components/components.cpp 2009-07-13 14:42:35 UTC (rev 77) @@ -0,0 +1,63 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: components.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Implements global functions regarding components. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +// Include files +#include "components.h" + + +// Parses the given XML file for components. +void parseComponentsXML(IXMLReader *file, Entity *entity) +{ + // Did we get a valid pointer? + if(!file) + return; + + // Create a list of available parse functions. + std::vector<bool (*)(IXMLReader*, Entity*)> parsers; + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + parsers.push_back(SoundListenerComponent::parseXML); +#endif // __COMPILE_WITH_SFML_AUDIO__ + + // Read from the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT_END: + + // </components> + if(stringw("components") == file->getNodeName()) + return; + + break; + + default: + + // Parse for components. + std::vector<bool (*)(IXMLReader*, Entity*)>::iterator it; + + for(it = parsers.begin(); it != parsers.end(); it++) + { + if( (*it)(file, entity) ) + break; + } + + break; + } + } +} + +// End of File Modified: trunk/src/components/components.h =================================================================== --- trunk/src/components/components.h 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/src/components/components.h 2009-07-13 14:42:35 UTC (rev 77) @@ -36,5 +36,10 @@ #include "sound/SoundListenerComponent.h" #include "sound/SoundSourceComponent.h" + +// Functions +//! Parses the given XML file for components. +extern void parseComponentsXML(IXMLReader *file, Entity *entity); + #endif Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-07-13 14:42:35 UTC (rev 77) @@ -25,7 +25,7 @@ // SoundListener constructor. SoundListenerComponent::SoundListenerComponent(Entity *parent, bool isMainListener) -: EntityComponent(parent), mPosition(vector3df(0, 0, 0)), mTarget(vector3df(0, 0, 0)) +: EntityComponent(parent), mPosition(parent->getPosition()), mTarget(vector3df(0, 0, 0)) { // Get a pointer to sub-systems of the Game Manager. EventManager *pEventMgr = GameManager::Instance()->getEventManager(); @@ -121,6 +121,66 @@ setIsMainListener(true); } +//! Parses for a SoundListenerComponent. +//! @note For internal use only! +bool SoundListenerComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + SoundListenerComponent *component = NULL; + + // Are we dealing with a SoundListenerComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("SoundListenerComponent") == file->getNodeName()) + { + // Initialise the component. + component = new SoundListenerComponent(entity, false); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <target> + if(stringw("target") == file->getNodeName()) + { + f32 x, y, z; + x = file->getAttributeValueAsFloat(L"x"); + y = file->getAttributeValueAsFloat(L"y"); + z = file->getAttributeValueAsFloat(L"z"); + + component->setTarget(vector3df(x, y, z)); + } + + + break; + + case io::EXN_ELEMENT_END: + + // </SoundListenerComponent> + if(stringw("SoundListenerComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + #endif // __COMPILE_WITH_SFML_AUDIO__ // End of File Modified: trunk/src/components/sound/SoundListenerComponent.h =================================================================== --- trunk/src/components/sound/SoundListenerComponent.h 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/src/components/sound/SoundListenerComponent.h 2009-07-13 14:42:35 UTC (rev 77) @@ -60,6 +60,10 @@ //! @note For internal use only! void onUnPause(void *p); + //! Parses for a SoundListenerComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Static Members Modified: trunk/src/core/DataStack.cpp =================================================================== --- trunk/src/core/DataStack.cpp 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/src/core/DataStack.cpp 2009-07-13 14:42:35 UTC (rev 77) @@ -277,16 +277,16 @@ case io::EXN_ELEMENT: // Did we find a <datastack>? - if(core::stringw("datastack") == file->getNodeName()) + if(stringw("datastack") == file->getNodeName()) isDataStack = true; // Did we find a <var>? if(isDataStack) { - if(core::stringw("var") == file->getNodeName()) + if(stringw("var") == file->getNodeName()) { - core::stringc name = file->getAttributeValue(L"name"); - core::stringc value = file->getAttributeValue(L"value"); + stringc name = file->getAttributeValue(L"name"); + stringc value = file->getAttributeValue(L"value"); mVars[name.c_str()] = value.c_str(); } } Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/src/core/EntityManager.cpp 2009-07-13 14:42:35 UTC (rev 77) @@ -18,7 +18,9 @@ #include "EntityManager.h" #include "GameManager.h" +#include "../components/components.h" + // EntityManager class // EntityManager constructor. EntityManager::EntityManager() @@ -113,6 +115,60 @@ return NULL; } +// Loads an entity from the given file. +Entity* EntityManager::loadEntityXML(const std::string &fileName, bool grab) +{ + // Get pointer to the File System of Irrlicht. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Does the file exist? + if(!fileSystem->existFile(fileName.c_str())) + return NULL; + + // Open the file. + IXMLReader *file = fileSystem->createXMLReader(fileName.c_str()); + + if(!file) + return false; + + // Read from the file. + Entity *entity; + + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <entity> + if(stringw("entity") == file->getNodeName()) + { + stringc name = file->getAttributeValue(L"name"); + entity = new Entity(name.c_str()); + } + + // <components> + if(stringw("components") == file->getNodeName()) + parseComponentsXML(file, entity); + + break; + + default: + break; + } + } + + // Add the entity. + if(grab && entity != NULL) + { + mEntities.push_back(entity); + entity->grab(); + } + + // We return the entity. + return entity; +} + // Removes all entities. void EntityManager::removeEntities() { Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-07-12 10:58:26 UTC (rev 76) +++ trunk/src/core/EntityManager.h 2009-07-13 14:42:35 UTC (rev 77) @@ -69,6 +69,11 @@ //! @return Pointer to the Entity if found, else NULL. Entity* getEntity(const std::string &name); + //! Loads an entity from the given file. + //! @param fileName Filename of the entity. + //! @param grab Should the EntityManager add the loaded entity to the internal list? + Entity* loadEntityXML(const std::string &fileName, bool grab = true); + //! Removes all entities from the EntityManager. void removeEntities(); //! Removes the given Entity. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-12 10:58:30
|
Revision: 76 http://sirrf.svn.sourceforge.net/sirrf/?rev=76&view=rev Author: zccdark203 Date: 2009-07-12 10:58:26 +0000 (Sun, 12 Jul 2009) Log Message: ----------- Added the loadSoundBufferFromMemory and loadSoundBufferFromAssetGroup methods to the SoundManager class. I also added the loadMusicFromMemory and loadMusicFromAssetGroup methods to the SoundSourceComponent class. In both cases these methods can be used to load sound data from memory or directly from an AssetGroup. The AngelScript bindings of both affected classes have also been updated. For now the added methods have been commented out, because the AngelScript binding of the AssetGroup class is still unavailable. Modified Paths: -------------- trunk/CHANGES trunk/build/CodeBlocks/sirrf.cbp trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h trunk/src/scripting/components/sound/asSoundSourceComponent.cpp trunk/src/scripting/sound/asSoundManager.cpp trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/CHANGES 2009-07-12 10:58:26 UTC (rev 76) @@ -2,6 +2,15 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Added loadMusicFromMemory to the SoundSourceComponent class. With this + method you can pass a self-loaded buffer to the component. + A loadMusicFromAssetGroup method has also been added. + + * Added loadSoundBufferFromMemory to the SoundManager class. With this + method you can pass a self-loaded buffer to the SoundManager. + Additionaly a loadSoundBufferFromAssetGroup method has been added to + the SoundManager class. + * Renamed all removeAll* functions to remove*. Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-07-12 10:58:26 UTC (rev 76) @@ -13,13 +13,11 @@ <Option type="1" /> <Option compiler="gcc" /> <Compiler> - <Add option="-pg" /> <Add option="-g" /> <Add directory="/usr/local/include/" /> <Add directory="/usr/local/include/irrlicht" /> </Compiler> <Linker> - <Add option="-pg" /> <Add option="-lGL" /> <Add option="-lXxf86vm" /> <Add option="-lXext" /> Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-07-12 10:58:26 UTC (rev 76) @@ -101,6 +101,57 @@ return true; } +// Loads the sound data as a music (streaming) object from memory. +bool SoundSourceComponent::loadMusicFromMemory(c8 *buffer, long length) +{ + // Delete the previous data. + unloadData(); + + // Create SFML's music object. + mMusic = new sf::Music(); + mMusic->OpenFromMemory(buffer, length); + + // Initialize variables. + mMusic->SetAttenuation(mAttenuation); + mMusic->SetLoop(mLoop); + mMusic->SetMinDistance(mMinDistance); + mMusic->SetPitch(mPitch); + mMusic->SetPosition(mPosition.X, mPosition.Y, mPosition.Z); + mMusic->SetVolume(mVolume); + + return true; +} + +// Loads the sound data as a music (streaming) object from an AssetGroup. +bool SoundSourceComponent::loadMusicFromAssetGroup(AssetGroup *group, const std::string &fileName) +{ + // Delete the previous data. + unloadData(); + + // Check if we got an valid pointer. + if(group != NULL) + return false; + + // Get data from the AssetGroup. + c8 *buffer = 0; + long length = 0; + group->getSound(fileName, buffer, length); + + // Create SFML's music object. + mMusic = new sf::Music(); + mMusic->OpenFromMemory(buffer, length); + + // Initialize variables. + mMusic->SetAttenuation(mAttenuation); + mMusic->SetLoop(mLoop); + mMusic->SetMinDistance(mMinDistance); + mMusic->SetPitch(mPitch); + mMusic->SetPosition(mPosition.X, mPosition.Y, mPosition.Z); + mMusic->SetVolume(mVolume); + + return true; +} + // Loads the sound data from a sound buffer. bool SoundSourceComponent::loadSoundBuffer(const std::string &bufferName) { Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-07-12 10:58:26 UTC (rev 76) @@ -21,7 +21,9 @@ #ifdef __COMPILE_WITH_SFML_AUDIO__ #include "../../core/EntityComponent.h" +#include "../../core/AssetGroup.h" + // SoundSourceComponent class //! Component wrapper of SFML's sf::Sound and sf::Music. class SoundSourceComponent : public EntityComponent @@ -46,6 +48,14 @@ //! Loads the sound data as a music (streaming) object. //! @param fileName Filename of the music object to load. bool loadMusic(const std::string &fileName); + //! Loads the sound data as a music (streaming) object from memory. + //! @param buffer Pointer to the start of the buffer. + //! @param length Length of the buffer. + bool loadMusicFromMemory(c8 *buffer, long length); + //! Loads the sound data as a music (streaming) object from an AssetGroup. + //! @param group Pointer to the AssetGroup. + //! @param fileName Filename of the sound to retrieve. + bool loadMusicFromAssetGroup(AssetGroup *group, const std::string &fileName); //! Loads the sound data from a sound buffer. //! @param bufferName Name of the buffer to load. //! @see SoundManager Modified: trunk/src/scripting/components/sound/asSoundSourceComponent.cpp =================================================================== --- trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-07-12 10:58:26 UTC (rev 76) @@ -59,6 +59,8 @@ // Bind SoundSourceComponent class functions. r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadMusic(const string &in)", asMETHOD(SoundSourceComponent, loadMusic), asCALL_THISCALL); assert(r >= 0); + //r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadMusicFromAssetGroup(AssetGroup @in, const string &in)", + // asMETHOD(SoundSourceComponent, loadMusicFromAssetGroup), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadSoundBuffer(const string &in)", asMETHOD(SoundSourceComponent, loadSoundBuffer), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/sound/asSoundManager.cpp =================================================================== --- trunk/src/scripting/sound/asSoundManager.cpp 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/src/scripting/sound/asSoundManager.cpp 2009-07-12 10:58:26 UTC (rev 76) @@ -50,6 +50,8 @@ r = engine->RegisterObjectMethod("SoundManager", "bool loadSoundBuffer(const string &in)", asMETHOD(SoundManager, loadSoundBuffer), asCALL_THISCALL); assert(r >= 0); + //r = engine->RegisterObjectMethod("SoundManager", "bool loadSoundBufferFromAssetGroup(AssetGroup @in, const string &in)", + // asMETHOD(SoundManager, loadSoundBufferFromAssetGroup), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("SoundManager", "void removeSoundBuffers()", asMETHOD(SoundManager, removeSoundBuffers), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/src/sound/SoundManager.cpp 2009-07-12 10:58:26 UTC (rev 76) @@ -83,8 +83,7 @@ core::stringw wFilename = core::stringw(fileName.c_str()); std::string fileBase = (fileSystem->getFileBasename(wFilename)).c_str(); - std::map<std::string, sf::SoundBuffer*>::iterator it = mSoundBuffers.find(fileBase); - if(it != mSoundBuffers.end()) + if(getSoundBuffer(fileBase) != NULL) return false; // Does the file exist? @@ -94,6 +93,9 @@ // Open the given file and load the contents to the buffer. IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + if(!file) + return false; + long fSize = file->getSize(); c8 *fBuffer = new c8[fSize+1]; memset(fBuffer, 0, fSize+1); @@ -113,6 +115,54 @@ return true; } +// Creates a sound buffer from memory. +bool SoundManager::loadSoundBufferFromMemory(const std::string &name, c8 *buffer, long length) +{ + // Has a sound buffer with the same name already been loaded? + if(getSoundBuffer(name) != NULL) + return false; + + // Create the sound buffer and add it to the map. + sf::SoundBuffer *soundBuffer = new sf::SoundBuffer(); + soundBuffer->LoadFromMemory(buffer, length); + + mSoundBuffers[name] = soundBuffer; + + // Clean up. + return true; +} + +// Creates a sound buffer from an AssetGroup. +bool SoundManager::loadSoundBufferFromAssetGroup(AssetGroup *group, const std::string &fileName) +{ + // Get pointer to the File System of Irrlicht. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Check if we got an valid pointer. + if(group != NULL) + return false; + + // Has the sound buffer already been loaded? + core::stringw wFilename = core::stringw(fileName.c_str()); + std::string fileBase = (fileSystem->getFileBasename(wFilename)).c_str(); + + if(getSoundBuffer(fileBase) != NULL) + return false; + + // Create the sound buffer and add it to the map. + c8 *buffer = 0; + long length = 0; + group->getSound(fileName, buffer, length); + + sf::SoundBuffer *soundBuffer = new sf::SoundBuffer(); + soundBuffer->LoadFromMemory(buffer, length); + + mSoundBuffers[fileBase] = soundBuffer; + + // Clean up. + return true; +} + // Removes all sound buffers. void SoundManager::removeSoundBuffers() { Modified: trunk/src/sound/SoundManager.h =================================================================== --- trunk/src/sound/SoundManager.h 2009-07-11 20:00:15 UTC (rev 75) +++ trunk/src/sound/SoundManager.h 2009-07-12 10:58:26 UTC (rev 76) @@ -21,7 +21,9 @@ #ifdef __COMPILE_WITH_SFML_AUDIO__ #include "../core/ReferenceCounted.h" +#include "../core/AssetGroup.h" + // SoundManager class //! The Sound Manager is the central interface point to all sound related functions of this program. class SoundManager : public ReferenceCounted @@ -58,6 +60,15 @@ //! Creates a sound buffer from the given file. //! @param fileName Filename where the buffer should be loaded from. bool loadSoundBuffer(const std::string &fileName); + //! Creates a sound buffer from memory. + //! @param name Name of the new sound buffer. + //! @param buffer Pointer to the start of the buffer. + //! @param length Length of the buffer. + bool loadSoundBufferFromMemory(const std::string &name, c8 *buffer, long length); + //! Creates a sound buffer from an AssetGroup. + //! @param group Pointer to the AssetGroup. + //! @param fileName Filename of the sound to retrieve. + bool loadSoundBufferFromAssetGroup(AssetGroup *group, const std::string &fileName); //! Removes all sound buffers. void removeSoundBuffers(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-11 20:00:19
|
Revision: 75 http://sirrf.svn.sourceforge.net/sirrf/?rev=75&view=rev Author: zccdark203 Date: 2009-07-11 20:00:15 +0000 (Sat, 11 Jul 2009) Log Message: ----------- Now the AssetGroup class can also load scripts and sounds from an asset directory. In order to use AssetGroup sounds I'll need to add some new functions. That will come tomorrow. Modified Paths: -------------- trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h trunk/src/core/AssetManager.h Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-07-11 11:04:56 UTC (rev 74) +++ trunk/src/core/AssetGroup.cpp 2009-07-11 20:00:15 UTC (rev 75) @@ -30,6 +30,8 @@ mBaseDir = (GameManager::Instance()->getDevice()->getFileSystem() ->getAbsolutePath(dirName.c_str())).c_str(); + cout << mBaseDir << "\n"; + init(); } @@ -73,6 +75,12 @@ void AssetGroup::loadAssets() { loadMeshes(); +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + loadScripts(); +#endif // __COMPILE_WITH_ANGELSCRIPT__ +#ifdef __COMPILE_WITH_SFML_AUDIO__ + loadSounds(); +#endif // __COMPILE_WITH_SFML_AUDIO__ loadTextures(); } @@ -150,6 +158,182 @@ fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); } +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +// Loads the script with the given filename. +bool AssetGroup::loadScript(const std::string &fileName) +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the scripts directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./scripts/")) + return false; + + // Read the script. + Script *script = new Script(fileName); + + if(script->loadScript(fileName)) + { + mScripts[fileName] = script; + cout << "Loaded script: " << fileName << "\n"; + } + + else + { + delete script; + script = NULL; + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (script != NULL) ? true : false; +} + +// Loads the scripts associated with this asset group. +void AssetGroup::loadScripts() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the textures directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return; + + if(!fileSystem->changeWorkingDirectoryTo("./textures/")) + return; + + // Read the textures. + IFileList *fileList = fileSystem->createFileList(); + + for(u32 i = 0; i < fileList->getFileCount(); i++) + { + // Get file name. + std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + + if(fileName == "..") + continue; + + // Load the script. + Script *script = new Script(fileName); + + if(script->loadScript(fileName)) + { + mScripts[fileName] = script; + cout << "Loaded script: " << fileName << "\n"; + } + + else delete script; + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + +// Loads the sound with the given filename. +bool AssetGroup::loadSound(const std::string &fileName) +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the textures directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./sounds/")) + return false; + + // Load the sound. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); + + cout << "Loaded sound: " << fileName << "\n"; + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (file) ? true : false; +} + +// Loads the sounds associated with this asset group. +void AssetGroup::loadSounds() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the textures directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return; + + if(!fileSystem->changeWorkingDirectoryTo("./sounds/")) + return; + + // Read the textures. + IFileList *fileList = fileSystem->createFileList(); + + for(u32 i = 0; i < fileList->getFileCount(); i++) + { + // Get file name. + std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + + if(fileName == "..") + continue; + + // Load the sound. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); + + cout << "Loaded script: " << fileName << "\n"; + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +#endif // __COMPILE_WITH_SFML_AUDIO__ + // Loads the texture with the given filename. bool AssetGroup::loadTexture(const std::string &fileName) { @@ -235,6 +419,36 @@ return NULL; } +#ifdef __COMPILE_WITH_ANGELSCRIPT__ +// Gets the script with the given filename. +Script* AssetGroup::getScript(const std::string &fileName) +{ + std::map<std::string, Script*>::iterator it = mScripts.find(fileName); + + if(it != mScripts.end()) + return it->second; + + return NULL; +} +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ +bool AssetGroup::getSound(const std::string &fileName, c8 *buffer, long &length) +{ + std::map<std::string, std::pair<c8*, long> >::iterator it = mSounds.find(fileName); + + if(it != mSounds.end()) + { + buffer = (it->second).first; + length = (it->second).second; + return true; + } + + return false; +} + +#endif // __COMPILE_WITH_SFML_AUDIO__ + // Gets the texture with the given filename. ITexture* AssetGroup::getTexture(const std::string &fileName) { @@ -275,6 +489,14 @@ return true; } +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + else if(assetType == "scripts") + { + if(reloadScript(assetName)) + return true; + } +#endif // __COMPILE_WITH_ANGELSCRIPT__ + else if(assetType == "textures") { if(reloadTexture(assetName)) @@ -307,6 +529,42 @@ loadMeshes(); } +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +// Reloads the script with the given filename. +bool AssetGroup::reloadScript(const std::string &fileName) +{ + removeScript(fileName); + return loadScript(fileName); +} + +// Reloads all script in this asset group. +void AssetGroup::reloadScripts() +{ + removeScripts(); + loadScripts(); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + +// Reloads the sound with the given filename. +bool AssetGroup::reloadSound(const std::string &fileName) +{ + removeSound(fileName); + return loadSound(fileName); +} + +// Reloads all sounds in this asset group. +void AssetGroup::reloadSounds() +{ + removeSounds(); + loadSounds(); +} + +#endif // __COMPILE_WITH_SFML_AUDIO__ + // Reloads the texture with the given filename. bool AssetGroup::reloadTexture(const std::string &fileName) { @@ -350,6 +608,22 @@ return true; } +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + else if(assetType == "scripts") + { + if(removeScript(assetName)) + return true; + } +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + else if(assetType == "sounds") + { + if(removeSound(assetName)) + return true; + } +#endif // __COMPILE_WITH_SFML_AUDIO__ + else if(assetType == "textures") { if(removeTexture(assetName)) @@ -364,6 +638,12 @@ void AssetGroup::removeAssets() { removeMeshes(); +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + removeScripts(); +#endif // __COMPILE_WITH_ANGELSCRIPT__ +#ifdef __COMPILE_WITH_SFML_AUDIO__ + removeSounds(); +#endif // __COMPILE_WITH_SFML_AUDIO__ removeTextures(); } @@ -436,6 +716,115 @@ mMeshes.clear(); } +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +// Removes the given script. +bool AssetGroup::removeScript(Script *script) +{ + // Try to find the given script. + std::map<std::string, Script*>::iterator it; + + for(it = mScripts.begin(); it != mScripts.end(); it++) + { + // Did we find the script? + if(script == it->second) + { + // Delete the script. + script->drop(); + mScripts.erase(it); + + return true; + } + } + + // We didn't find the script; the texture remains untouched. + return false; +} + +// Removes the script with the given name. +bool AssetGroup::removeScript(const std::string &fileName) +{ + // Try to find the given script. + std::map<std::string, Script*>::iterator it = mScripts.find(fileName); + + // Did we find the script? + if(it != mScripts.end()) + { + // Get pointer to the found script. + Script *script = it->second; + + // Delete the script. + script->drop(); + mScripts.erase(it); + + return true; + } + + // We didn't find the script. + else return false; +} + +// Removes all script from this asset group. +void AssetGroup::removeScripts() +{ + // Delete the scripts. + std::map<std::string, Script*>::iterator it; + + for(it = mScripts.begin(); it != mScripts.end(); it++) + { + Script *script = it->second; + script->drop(); + } + + // Clear the scripts map. + mScripts.clear(); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + +// Removes the sound with the given name. +bool AssetGroup::removeSound(const std::string &fileName) +{ + // Try to find the given sound. + std::map<std::string, std::pair<c8*, long> >::iterator it = mSounds.find(fileName); + + // Did we find the sound? + if(it != mSounds.end()) + { + // Get reference to the internal buffer. + c8 *fBuffer = (it->second).first; + + // Delete the script. + delete [] fBuffer; + mSounds.erase(it); + + return true; + } + + // We didn't find the sounds. + else return false; +} + +// Removes all sounds from this asset group. +void AssetGroup::removeSounds() +{ + // Delete the sounds. + std::map<std::string, std::pair<c8*, long> >::iterator it; + + for(it = mSounds.begin(); it != mSounds.end(); it++) + { + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + } + + // Clear the sounds map. + mSounds.clear(); +} + +#endif // __COMPILE_WITH_SFML_AUDIO__ + // Removes the given texture. bool AssetGroup::removeTexture(ITexture *texture) { @@ -490,7 +879,7 @@ // Get a pointer to the driver.. IVideoDriver *pDriver = GameManager::Instance()->getDriver(); - // Delete the meshes. + // Delete the textures. std::map<std::string, ITexture*>::iterator it; for(it = mTextures.begin(); it != mTextures.end(); it++) Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-07-11 11:04:56 UTC (rev 74) +++ trunk/src/core/AssetGroup.h 2009-07-11 20:00:15 UTC (rev 75) @@ -20,7 +20,11 @@ #include "../dependencies.h" #include "ReferenceCounted.h" +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + #include "../scripting/Script.h" +#endif // __COMPILE_WITH_ANGELSCRIPT__ + // AssetGroup class //! Represents a collection of assets (meshes, textures, etc). class AssetGroup : public ReferenceCounted @@ -49,10 +53,23 @@ const std::string& getBaseDir() const; //! Gets the mesh with the given filename. - //! @param name Filename of the mesh. + //! @param fileName Filename of the mesh. IAnimatedMesh* getMesh(const std::string &fileName); +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + //! Gets the script with the given filename. + //! @param fileName Filename of the script. + Script *getScript(const std::string &fileName); +#endif // __COMPILE_WITH_ANGELSCRIPT__ +#ifdef __COMPILE_WITH_SFML_AUDIO__ + //! Gets the sound with the given filename as memory. + //! @param fileName Filename of the sound. + //! @param buffer A pointer to the start of the sound buffer. + //! @param Length Length of the buffer. + //! @return True on success, false on failure. + bool getSound(const std::string &fileName, c8 *buffer, long &length); +#endif // __COMPILE_WITH_SFML_AUDIO__ //! Gets the texture with the given filename. - //! @param name Filename of the texture. + //! @param fileName Filename of the texture. ITexture* getTexture(const std::string &fileName); //! Reloads the asset with the given name. @@ -60,13 +77,31 @@ bool reloadAsset(const std::string &name); //! Reloads all assets in this asset group. void reloadAssets(); + //! Reloads the mesh with the given filename. - //! @param name Filename of the mesh. + //! @param fileName Filename of the mesh. bool reloadMesh(const std::string &fileName); //! Reloads all meshes in this asset group. void reloadMeshes(); + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + //! Reloads the script with the given filename. + //! @param fileName Filename of the script. + bool reloadScript(const std::string &fileName); + //! Reloads all scripts in this asset group. + void reloadScripts(); +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + //! Reloads the sound with the given filename. + //! @param fileName Filename of the sound. + bool reloadSound(const std::string &fileName); + //! Reloads all sounds in this asset group. + void reloadSounds(); +#endif // __COMPILE_WITH_SFML_AUDIO__ + //! Reloads the texture with the given filename. - //! @param name Filename of the texture. + //! @param fileName Filename of the texture. bool reloadTexture(const std::string &fileName); //! Reloads all textures in this asset group. void reloadTextures(); @@ -81,27 +116,53 @@ //! @param mesh Mesh to remove. bool removeMesh(IAnimatedMesh *mesh); //! Removes the mesh with the given filename. - //! @param name Filename of the mesh. + //! @param fileName Filename of the mesh. bool removeMesh(const std::string &fileName); //! Removes all meshes in this asset group. void removeMeshes(); +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + //! Removes the given script. + //! @param script Script to remove. + bool removeScript(Script *script); + //! Removes the script with the given filename. + //! @param fileName Filename of the script. + bool removeScript(const std::string &fileName); + //! Removes all scripts in this asset group. + void removeScripts(); +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + //! Removes the sound with the given filename. + //! @param fileName Filename of the mesh. + bool removeSound(const std::string &fileName); + //! Removes all sounds in this asset group. + void removeSounds(); +#endif // __COMPILE_WITH_SFML_AUDIO__ + //! Removes the given texture. //! @param texture Texture to remove. bool removeTexture(ITexture *texture); //! Removes the texture with the given filename. - //! @param name Filename of the texture. + //! @param fileName Filename of the texture. bool removeTexture(const std::string &fileName); //! Removes all textures in this asset group. void removeTextures(); - private: // Private methods void loadAssets(); bool loadMesh(const std::string &fileName); void loadMeshes(); +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + bool loadScript(const std::string &fileName); + void loadScripts(); +#endif // __COMPILE_WITH_ANGELSCRIPT__ +#ifdef __COMPILE_WITH_SFML_AUDIO__ + bool loadSound(const std::string &fileName); + void loadSounds(); +#endif // __COMPILE_WITH_SFML_AUDIO__ bool loadTexture(const std::string &fileName); void loadTextures(); @@ -115,6 +176,12 @@ std::map<std::string, IAnimatedMesh*> mMeshes; std::map<std::string, ITexture*> mTextures; +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + std::map<std::string, Script*> mScripts; +#endif // __COMPILE_WITH_ANGELSCRIPT__ +#ifdef __COMPILE_WITH_SFML_AUDIO__ + std::map<std::string, std::pair<c8*, long> > mSounds; +#endif // __COMPILE_WITH_SFML_AUDIO__ }; #endif Modified: trunk/src/core/AssetManager.h =================================================================== --- trunk/src/core/AssetManager.h 2009-07-11 11:04:56 UTC (rev 74) +++ trunk/src/core/AssetManager.h 2009-07-11 20:00:15 UTC (rev 75) @@ -70,7 +70,7 @@ //! Removes all AssetGroups from the AssetManager. void removeAssetGroups(); //! Removes the given AssetGroup. - //! @param stack Pointer to the AssetGroup to remove. + //! @param group Pointer to the AssetGroup to remove. //! @return True if removal was successful, false if removal was a failure. bool removeAssetGroup(AssetGroup *group); //! Removes the given AssetGroup with the given ID. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-11 11:05:02
|
Revision: 74 http://sirrf.svn.sourceforge.net/sirrf/?rev=74&view=rev Author: zccdark203 Date: 2009-07-11 11:04:56 +0000 (Sat, 11 Jul 2009) Log Message: ----------- Finally got to work on Sirrf again. The AssetGroup still hasn't been finished, but the core functions (load, reload, remove) for meshes and textures have been finished. Please note that a reload currently only affects the AssetGroup, but I've something in mind that will make it possible to reload assets framework-wide. Modified Paths: -------------- trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-07-04 15:41:36 UTC (rev 73) +++ trunk/src/core/AssetGroup.cpp 2009-07-11 11:04:56 UTC (rev 74) @@ -24,9 +24,12 @@ // AssetGroup constructor. AssetGroup::AssetGroup(const std::string &name, const std::string &dirName) -: mName(name), mBaseDir(dirName) +: mName(name) { mID = mIDCount++; + mBaseDir = (GameManager::Instance()->getDevice()->getFileSystem() + ->getAbsolutePath(dirName.c_str())).c_str(); + init(); } @@ -39,17 +42,7 @@ // Initialises the AssetGroup. void AssetGroup::init() { - // Retrieve pointer to Irrlicht's file system. - IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); - - // Change to the root of asset directory. - std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); - - if(fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) - loadAssets(); - - // Set original working directory. - fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + loadAssets(); } // Clears the AssetGroup. @@ -70,7 +63,7 @@ return mName; } -//! Gets the base directory of the AssetGroup. +// Gets the base directory of the AssetGroup. const std::string& AssetGroup::getBaseDir() const { return mBaseDir; @@ -83,6 +76,37 @@ loadTextures(); } +// Loads the mesh with the given filename. +bool AssetGroup::loadMesh(const std::string &fileName) +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + // Change the working directory to the meshes directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./meshes/")) + return false; + + // Read the texture. + IAnimatedMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); + + if(mesh) + { + mMeshes[fileName] = mesh; + mesh->grab(); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (mesh) ? true : false; +} + // Loads the meshes associated with this asset group. void AssetGroup::loadMeshes() { @@ -91,6 +115,11 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Change the working directory to the meshes directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return; + if(!fileSystem->changeWorkingDirectoryTo("./meshes/")) return; @@ -118,9 +147,40 @@ // Clean up. fileList->drop(); - fileSystem->changeWorkingDirectoryTo(".."); + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); } +// Loads the texture with the given filename. +bool AssetGroup::loadTexture(const std::string &fileName) +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + IVideoDriver *pDriver = GameManager::Instance()->getDriver(); + + // Change the working directory to the textures directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./textures/")) + return false; + + // Read the texture. + ITexture *texture = pDriver->getTexture(fileName.c_str()); + + if(texture) + { + mTextures[fileName] = texture; + texture->grab(); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (texture) ? true : false; +} + // Loads the textures associated with this asset group. void AssetGroup::loadTextures() { @@ -128,11 +188,16 @@ IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); IVideoDriver *pDriver = GameManager::Instance()->getDriver(); - // Change the working directory to the meshes directory. + // Change the working directory to the textures directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return; + if(!fileSystem->changeWorkingDirectoryTo("./textures/")) return; - // Read the meshes. + // Read the textures. IFileList *fileList = fileSystem->createFileList(); for(u32 i = 0; i < fileList->getFileCount(); i++) @@ -156,13 +221,13 @@ // Clean up. fileList->drop(); - fileSystem->changeWorkingDirectoryTo(".."); + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); } // Gets the mesh with the given filename. -IAnimatedMesh* AssetGroup::getMesh(const std::string &name) +IAnimatedMesh* AssetGroup::getMesh(const std::string &fileName) { - std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(name); + std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(fileName); if(it != mMeshes.end()) return it->second; @@ -171,9 +236,9 @@ } // Gets the texture with the given filename. -ITexture* AssetGroup::getTexture(const std::string &name) +ITexture* AssetGroup::getTexture(const std::string &fileName) { - std::map<std::string, ITexture*>::iterator it = mTextures.find(name); + std::map<std::string, ITexture*>::iterator it = mTextures.find(fileName); if(it != mTextures.end()) return it->second; @@ -184,8 +249,40 @@ // Reloads the asset with the given name. bool AssetGroup::reloadAsset(const std::string &name) { - // TODO - return true; + // Determine the asset type we're dealing with. + std::string assetType; + size_t pos; + + pos = name.find("/"); + if(pos == std::string::npos) + { + pos = name.find("\""); + if(pos == std::string::npos) + { + return false; + } + } + + assetType = name.substr(0, pos); + + // Determine the asset name. + std::string assetName = name.substr(pos+1, name.size()-pos); + + // Reload the asset. + if(assetType == "meshes") + { + if(reloadMesh(assetName)) + return true; + } + + else if(assetType == "textures") + { + if(reloadTexture(assetName)) + return true; + } + + // We couldn't reload the asset. + return false; } // Reloads all assets in this asset group. @@ -196,6 +293,13 @@ loadAssets(); } +// Reloads the mesh with the given filename. +bool AssetGroup::reloadMesh(const std::string &fileName) +{ + removeMesh(fileName); + return loadMesh(fileName); +} + // Reloads all meshes in this asset group. void AssetGroup::reloadMeshes() { @@ -203,6 +307,13 @@ loadMeshes(); } +// Reloads the texture with the given filename. +bool AssetGroup::reloadTexture(const std::string &fileName) +{ + removeTexture(fileName); + return loadTexture(fileName); +} + // Reloads all textures in this asset group. void AssetGroup::reloadTextures() { @@ -240,7 +351,7 @@ } else if(assetType == "textures") - { + { if(removeTexture(assetName)) return true; } @@ -281,10 +392,10 @@ } // Removes the mesh with the given name. -bool AssetGroup::removeMesh(const std::string &name) +bool AssetGroup::removeMesh(const std::string &fileName) { // Try to find the given mesh. - std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(name); + std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(fileName); // Did we find the mesh? if(it != mMeshes.end()) @@ -350,10 +461,10 @@ } // Removes the texture with the given name. -bool AssetGroup::removeTexture(const std::string &name) +bool AssetGroup::removeTexture(const std::string &fileName) { // Try to find the given texture. - std::map<std::string, ITexture*>::iterator it = mTextures.find(name); + std::map<std::string, ITexture*>::iterator it = mTextures.find(fileName); // Did we find the texture? if(it != mTextures.end()) Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-07-04 15:41:36 UTC (rev 73) +++ trunk/src/core/AssetGroup.h 2009-07-11 11:04:56 UTC (rev 74) @@ -50,17 +50,24 @@ //! Gets the mesh with the given filename. //! @param name Filename of the mesh. - IAnimatedMesh* getMesh(const std::string &name); + IAnimatedMesh* getMesh(const std::string &fileName); //! Gets the texture with the given filename. //! @param name Filename of the texture. - ITexture* getTexture(const std::string &name); + ITexture* getTexture(const std::string &fileName); //! Reloads the asset with the given name. + //! @param name Directory and name (dir/file.*) of the asset. bool reloadAsset(const std::string &name); //! Reloads all assets in this asset group. void reloadAssets(); + //! Reloads the mesh with the given filename. + //! @param name Filename of the mesh. + bool reloadMesh(const std::string &fileName); //! Reloads all meshes in this asset group. void reloadMeshes(); + //! Reloads the texture with the given filename. + //! @param name Filename of the texture. + bool reloadTexture(const std::string &fileName); //! Reloads all textures in this asset group. void reloadTextures(); @@ -75,7 +82,7 @@ bool removeMesh(IAnimatedMesh *mesh); //! Removes the mesh with the given filename. //! @param name Filename of the mesh. - bool removeMesh(const std::string &name); + bool removeMesh(const std::string &fileName); //! Removes all meshes in this asset group. void removeMeshes(); @@ -84,7 +91,7 @@ bool removeTexture(ITexture *texture); //! Removes the texture with the given filename. //! @param name Filename of the texture. - bool removeTexture(const std::string &name); + bool removeTexture(const std::string &fileName); //! Removes all textures in this asset group. void removeTextures(); @@ -93,7 +100,9 @@ // Private methods void loadAssets(); + bool loadMesh(const std::string &fileName); void loadMeshes(); + bool loadTexture(const std::string &fileName); void loadTextures(); // Static members This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-07-04 15:41:48
|
Revision: 73 http://sirrf.svn.sourceforge.net/sirrf/?rev=73&view=rev Author: zccdark203 Date: 2009-07-04 15:41:36 +0000 (Sat, 04 Jul 2009) Log Message: ----------- Extended the AssetGroup class. The implementation of the AssetGroup will be most likely be finished upon the next revision, but the next revision will have to wait for a review of the current code. Furthermore an AssetManager class has been implemented. It works similar to DataStore, EntityManager, etc. Modified Paths: -------------- trunk/CHANGES trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h trunk/src/core/DataStack.cpp trunk/src/core/DataStack.h trunk/src/core/DataStore.cpp trunk/src/core/DataStore.h trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h trunk/src/core/EventManager.cpp trunk/src/core/EventManager.h trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/ScriptManager.h trunk/src/scripting/core/asDataStack.cpp trunk/src/scripting/core/asDataStore.cpp trunk/src/scripting/core/asEntity.cpp trunk/src/scripting/core/asEntityManager.cpp trunk/src/scripting/core/asEventManager.cpp trunk/src/scripting/scripting/asScriptManager.cpp trunk/src/scripting/sound/asSoundManager.cpp trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Added Paths: ----------- trunk/src/core/AssetManager.cpp trunk/src/core/AssetManager.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/CHANGES 2009-07-04 15:41:36 UTC (rev 73) @@ -2,6 +2,9 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Renamed all removeAll* functions to remove*. + + ========================================================================== Sirrf version 0.1.1 - Changes ========================================================================== Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/build/CMake/CMakeLists.txt 2009-07-04 15:41:36 UTC (rev 73) @@ -33,6 +33,7 @@ # /src/core ${SOURCE_DIR}core/AssetGroup.cpp + ${SOURCE_DIR}core/AssetManager.cpp ${SOURCE_DIR}core/DataStack.cpp ${SOURCE_DIR}core/DataStore.cpp ${SOURCE_DIR}core/Entity.cpp Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-07-04 15:41:36 UTC (rev 73) @@ -13,11 +13,13 @@ <Option type="1" /> <Option compiler="gcc" /> <Compiler> + <Add option="-pg" /> <Add option="-g" /> <Add directory="/usr/local/include/" /> <Add directory="/usr/local/include/irrlicht" /> </Compiler> <Linker> + <Add option="-pg" /> <Add option="-lGL" /> <Add option="-lXxf86vm" /> <Add option="-lXext" /> @@ -92,6 +94,8 @@ <Unit filename="../../src/config.h" /> <Unit filename="../../src/core/AssetGroup.cpp" /> <Unit filename="../../src/core/AssetGroup.h" /> + <Unit filename="../../src/core/AssetManager.cpp" /> + <Unit filename="../../src/core/AssetManager.h" /> <Unit filename="../../src/core/DataStack.cpp" /> <Unit filename="../../src/core/DataStack.h" /> <Unit filename="../../src/core/DataStore.cpp" /> Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/AssetGroup.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -3,7 +3,7 @@ // Name: AssetGroup.cpp // Author: Michael Bartsch (ZCCdark203) // -// Desc : +// Desc : Represents a collection of assets (meshes, textures, etc). // // License: Copyright (C) 2009 Michael Bartsch and Contributors // @@ -44,11 +44,9 @@ // Change to the root of asset directory. std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); - fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str()); - // Load the meshes. - loadMeshes(); - loadTextures(); + if(fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + loadAssets(); // Set original working directory. fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); @@ -57,11 +55,35 @@ // Clears the AssetGroup. void AssetGroup::clear() { - removeTextures(); - removeMeshes(); + removeAssets(); } +// Gets the ID of the AssetGroup. +u32 AssetGroup::getID() const +{ + return mID; +} + +// Gets the name of the AssetGroup. +const std::string& AssetGroup::getName() const +{ + return mName; +} + +//! Gets the base directory of the AssetGroup. +const std::string& AssetGroup::getBaseDir() const +{ + return mBaseDir; +} + // Loads the meshes associated with this asset group. +void AssetGroup::loadAssets() +{ + loadMeshes(); + loadTextures(); +} + +// Loads the meshes associated with this asset group. void AssetGroup::loadMeshes() { // Retrieve pointers to sub-sytems of the Irrlicht engine. @@ -159,6 +181,81 @@ return NULL; } +// Reloads the asset with the given name. +bool AssetGroup::reloadAsset(const std::string &name) +{ + // TODO + return true; +} + +// Reloads all assets in this asset group. +void AssetGroup::reloadAssets() +{ + // Remove assets. + removeAssets(); + loadAssets(); +} + +// Reloads all meshes in this asset group. +void AssetGroup::reloadMeshes() +{ + removeMeshes(); + loadMeshes(); +} + +// Reloads all textures in this asset group. +void AssetGroup::reloadTextures() +{ + removeTextures(); + loadTextures(); +} + +// Removes the asset with the given name. +bool AssetGroup::removeAsset(const std::string &name) +{ + // Determine the asset type we're dealing with. + std::string assetType; + size_t pos; + + pos = name.find("/"); + if(pos == std::string::npos) + { + pos = name.find("\""); + if(pos == std::string::npos) + { + return false; + } + } + + assetType = name.substr(0, pos); + + // Determine the asset name. + std::string assetName = name.substr(pos+1, name.size()-pos); + + // Remove the asset. + if(assetType == "meshes") + { + if(removeMesh(assetName)) + return true; + } + + else if(assetType == "textures") + { + if(removeTexture(assetName)) + return true; + } + + // We failed to remove the asset. + return false; +} + +// Removes all assets in this asset group. +void AssetGroup::removeAssets() +{ + removeMeshes(); + removeTextures(); +} + // Removes the given mesh. bool AssetGroup::removeMesh(IAnimatedMesh *mesh) { Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/AssetGroup.h 2009-07-04 15:41:36 UTC (rev 73) @@ -21,7 +21,8 @@ #include "ReferenceCounted.h" -// Entity class +// AssetGroup class +//! Represents a collection of assets (meshes, textures, etc). class AssetGroup : public ReferenceCounted { public: @@ -40,6 +41,13 @@ void clear(); // Public methods + //! Gets the ID of the AssetGroup. + u32 getID() const; + //! Gets the name of the AssetGroup. + const std::string& getName() const; + //! Gets the base directory of the AssetGroup. + const std::string& getBaseDir() const; + //! Gets the mesh with the given filename. //! @param name Filename of the mesh. IAnimatedMesh* getMesh(const std::string &name); @@ -47,11 +55,21 @@ //! @param name Filename of the texture. ITexture* getTexture(const std::string &name); - /*void reloadAsset(const std::string &name); + //! Reloads the asset with the given name. + bool reloadAsset(const std::string &name); + //! Reloads all assets in this asset group. void reloadAssets(); + //! Reloads all meshes in this asset group. void reloadMeshes(); - void reloadTextures();*/ + //! Reloads all textures in this asset group. + void reloadTextures(); + //! Removes the asset with the given name. + //! @param name Directory and name (dir/file.*) of the asset. + bool removeAsset(const std::string &name); + //! Removes all assets. + void removeAssets(); + //! Removes the given mesh. //! @param mesh Mesh to remove. bool removeMesh(IAnimatedMesh *mesh); @@ -70,9 +88,11 @@ //! Removes all textures in this asset group. void removeTextures(); + private: // Private methods + void loadAssets(); void loadMeshes(); void loadTextures(); Added: trunk/src/core/AssetManager.cpp =================================================================== --- trunk/src/core/AssetManager.cpp (rev 0) +++ trunk/src/core/AssetManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -0,0 +1,194 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: AssetManager.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : The AssetManager class manages the AssetGroups that are being +// used by the framework. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +// Include files +#include "AssetManager.h" + + +// AssetManager class +// AssetManager constructor. +AssetManager::AssetManager() +{ + init(); +} + +// AssetManager deconstructor. +AssetManager::~AssetManager() +{ + clear(); +} + +// Initialises the AssetManager. +void AssetManager::init() +{ +} + +// Clears the AssetManager. +void AssetManager::clear() +{ + removeAssetGroups(); +} + +// Increases the reference counter. +void AssetManager::grab() +{ + // Dummy function. +} + +// Decreases the reference counter. +void AssetManager::drop() +{ + // Dummy function. +} + +// Adds the given AssetGroup to the AssetManager. +bool AssetManager::addAssetGroup(AssetGroup *group) +{ + // Did we get a valid pointer? + if(group == NULL) + return false; + + // Does a AssetGroup with the same name exist? + if(getAssetGroup(group->getName())) + return false; + + // Add the AssetGroup to the vector. + mGroups.push_back(group); + group->grab(); + + return true; +} + +// Creates (and adds) a AssetGroup with the given name. +AssetGroup* AssetManager::createAssetGroup(const std::string &name, const std::string &dirName) +{ + // Does a Data group with the same name exist? + if(getAssetGroup(name)) + return NULL; + + // Create the AssetGroup and add it to the vector. + AssetGroup *group = new AssetGroup(name, dirName); + mGroups.push_back(group); + group->grab(); + + return group; +} + +// Gets the AssetGroup with the given ID. +AssetGroup* AssetManager::getAssetGroup(const u32 id) +{ + for(u32 i = 0; i < mGroups.size(); i++) + { + if(mGroups[i]->getID() == id) + return mGroups[i]; + } + + return NULL; +} + +// Gets the AssetGroup with the given name. +AssetGroup* AssetManager::getAssetGroup(const std::string &name) +{ + for(u32 i = 0; i < mGroups.size(); i++) + { + if(mGroups[i]->getName() == name) + return mGroups[i]; + } + + return NULL; +} + +// Removes all AssetGroups from this AssetManager. +void AssetManager::removeAssetGroups() +{ + // Clear the AssetGroups. + for(u32 i = 0; i < mGroups.size(); i++) + mGroups[i]->drop(); + + mGroups.clear(); +} + +// Removes the given AssetGroup. +bool AssetManager::removeAssetGroup(AssetGroup *group) +{ + // Did we get a valid pointer? + if(group == NULL) + return false; + + // Try to remove the AssetGroup. + vector<AssetGroup*>::iterator it; + + for(it = mGroups.begin(); it < mGroups.end(); it++) + { + AssetGroup *agroup = *it; + + if(agroup == group) + { + agroup->drop(); + mGroups.erase(it); + return true; + } + } + + // We couldn't find the AssetGroup and thus couldn't remove it. + return false; +} + +// Removes the given AssetGroup with the given ID. +bool AssetManager::removeAssetGroup(const u32 id) +{ + // Try to remove the AssetGroup. + vector<AssetGroup*>::iterator it; + + for(it = mGroups.begin(); it < mGroups.end(); it++) + { + AssetGroup *agroup = *it; + + if(agroup->getID() == id) + { + agroup->drop(); + mGroups.erase(it); + return true; + } + } + + // We couldn't find the AssetGroup and thus couldn't remove it. + return false; +} + +// Removes the given AssetGroup with the given name. +bool AssetManager::removeAssetGroup(const std::string &name) +{ + // Try to remove the AssetGroup. + vector<AssetGroup*>::iterator it; + + for(it = mGroups.begin(); it < mGroups.end(); it++) + { + AssetGroup *agroup = *it; + + if(agroup->getName() == name) + { + agroup->drop(); + mGroups.erase(it); + return true; + } + } + + // We couldn't find the AssetGroup and thus couldn't remove it. + return false; +} + +// End of File Added: trunk/src/core/AssetManager.h =================================================================== --- trunk/src/core/AssetManager.h (rev 0) +++ trunk/src/core/AssetManager.h 2009-07-04 15:41:36 UTC (rev 73) @@ -0,0 +1,93 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: AssetManager.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the AssetManager class. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +#ifndef __ASSETMANAGAER_H__ +#define __ASSETMANAGAER_H__ + +// Include files +#include "../dependencies.h" +#include "AssetGroup.h" + +// Forward declarations +class AssetGroup; + + +// AssetManager class +//! The AssetManager class manages the AssetGroups that are being used by the framework. +class AssetManager +{ +public: + + // Initialisation and deinitialisation + //! Constructor + AssetManager(); + //! Deconstructor + ~AssetManager(); + + //! Initialises the AssetManager. + void init(); + //! Clears the AssetManager. + void clear(); + + // Reference counting + //! Increases the reference counter. + //! @note This is a dummy function. + void grab(); + //! Decreases the reference counter. + //! @note This is a dummy function. + void drop(); + + // Methods + //! Adds the given AssetGroup to the DataStore. + //! @param stack Pointer to the AssetGroup to add. + //! @return True if addition was successful, false if addition was a failure. + bool addAssetGroup(AssetGroup *stack); + //! Creates (and adds) a AssetGroup with the given name. + //! @param name Name of the AssetGroup. + //! @param dirName Name of the base directory of the asset group. + //! @return Pointer to the AssetGroup on success, NULL on failure. + AssetGroup* createAssetGroup(const std::string &name, const std::string &dirName); + + //! Gets the AssetGroup with the given ID. + //! @return Pointer to the AssetGroup if found, else NULL. + AssetGroup* getAssetGroup(const u32 id); + //! Gets the AssetGroup with the given name. + //! @return Pointer to the AssetGroup if found, else NULL. + AssetGroup* getAssetGroup(const std::string &name); + + //! Removes all AssetGroups from the AssetManager. + void removeAssetGroups(); + //! Removes the given AssetGroup. + //! @param stack Pointer to the AssetGroup to remove. + //! @return True if removal was successful, false if removal was a failure. + bool removeAssetGroup(AssetGroup *group); + //! Removes the given AssetGroup with the given ID. + //! @param id ID of the AssetGroup to remove. + //! @return True if removal was successful, false if removal was a failure. + bool removeAssetGroup(const u32 id); + //! Removes the given AssetGroup with the given name. + //! @param name Name of the AssetGroup to remove. + //! @return True if removal was successful, false if removal was a failure. + bool removeAssetGroup(const std::string &name); + +private: + + // Normal members + std::vector<AssetGroup*> mGroups; + +}; + +#endif + Modified: trunk/src/core/DataStack.cpp =================================================================== --- trunk/src/core/DataStack.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/DataStack.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -46,7 +46,7 @@ // Clears the DataStack. void DataStack::clear() { - removeAll(); + removeVars(); } // Gets the ID of the DataStack. @@ -83,7 +83,7 @@ } // Removes all variables from this DataStack. -void DataStack::removeAll() +void DataStack::removeVars() { mVars.clear(); } @@ -164,7 +164,7 @@ return false; // Delete any previous data. - removeAll(); + removeVars(); // Get remaining data from the file. std::stringstream bCountStream; Modified: trunk/src/core/DataStack.h =================================================================== --- trunk/src/core/DataStack.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/DataStack.h 2009-07-04 15:41:36 UTC (rev 73) @@ -111,7 +111,7 @@ std::string getVar(const std::string &name); //! Removes all variables from this DataStack. - void removeAll(); + void removeVars(); //! Removes the variable with the given name. //! @param name Name of the variable. bool removeVar(const std::string &name); Modified: trunk/src/core/DataStore.cpp =================================================================== --- trunk/src/core/DataStore.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/DataStore.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -39,7 +39,7 @@ // Clears the DataStore. void DataStore::clear() { - removeAllDataStacks(); + removeDataStacks(); } // Increases the reference counter. @@ -112,7 +112,7 @@ } // Removes all DataStacks from this DataStore. -void DataStore::removeAllDataStacks() +void DataStore::removeDataStacks() { // Clear the DataStacks. for(u32 i = 0; i < mStacks.size(); i++) Modified: trunk/src/core/DataStore.h =================================================================== --- trunk/src/core/DataStore.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/DataStore.h 2009-07-04 15:41:36 UTC (rev 73) @@ -67,7 +67,7 @@ DataStack* getDataStack(const std::string &name); //! Removes all DataStacks from the DataStore. - void removeAllDataStacks(); + void removeDataStacks(); //! Removes the given DataStack. //! @param stack Pointer to the DataStack to remove. //! @return True if removal was successful, false if removal was a failure. Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/Entity.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -67,8 +67,8 @@ Entity::~Entity() { // Remove all children and components. - removeAllChildren(); - removeAllComponents(); + removeChildren(); + removeComponents(); // Remove events. GameManager::Instance()->getEventManager()->removeEventGroup(std::string("ent#") + mName); @@ -183,7 +183,7 @@ } // Removes all children. -void Entity::removeAllChildren() +void Entity::removeChildren() { for(u32 i = 0; i < mChildren.size(); i++) { @@ -195,7 +195,7 @@ } // Removes all components. -void Entity::removeAllComponents() +void Entity::removeComponents() { for(u32 i = 0; i < mComponents.size(); i++) mComponents[i]->drop(); Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/Entity.h 2009-07-04 15:41:36 UTC (rev 73) @@ -71,9 +71,9 @@ const vector3df& getPosition() const; //! Removes all children. - void removeAllChildren(); + void removeChildren(); //! Removes all components. - void removeAllComponents(); + void removeComponents(); //! Removes the given child. //! @param entity Pointer to the child to remove. //! @return True if removal was successful, false if removal was a failure. Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/EntityManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -41,7 +41,7 @@ void EntityManager::clear() { // Clear entities. - removeAllEntities(); + removeEntities(); } // Increases the reference counter. @@ -114,7 +114,7 @@ } // Removes all entities. -void EntityManager::removeAllEntities() +void EntityManager::removeEntities() { for(u32 i = 0; i < mEntities.size(); i++) mEntities[i]->drop(); Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/EntityManager.h 2009-07-04 15:41:36 UTC (rev 73) @@ -70,7 +70,7 @@ Entity* getEntity(const std::string &name); //! Removes all entities from the EntityManager. - void removeAllEntities(); + void removeEntities(); //! Removes the given Entity. //! @param entity Pointer to the Entity to remove. //! @return True if removal was successful, false if removal was a failure. Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/EventManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -336,14 +336,14 @@ // Removes all event groups from the Event Manager. -void EventManager::removeAllEventGroups() +void EventManager::removeEventGroups() { // Remove all groups. mEvents.clear(); } // Removes all event slots from the given event group. -bool EventManager::removeAllEventSlots(const std::string &groupName) +bool EventManager::removeEventSlots(const std::string &groupName) { // Get the given event group. std::map<std::string, std::map<std::string, EventSlot> >::iterator itGroups; Modified: trunk/src/core/EventManager.h =================================================================== --- trunk/src/core/EventManager.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/EventManager.h 2009-07-04 15:41:36 UTC (rev 73) @@ -145,11 +145,11 @@ f32 getMouseWheel() const; //! Removes all event groups from the EventManager. - void removeAllEventGroups(); + void removeEventGroups(); //! Removes all event slots from the given event group. //! @param groupName Name of the event group. //! @return True if removal was successful, false if removal was a failure. - bool removeAllEventSlots(const std::string &groupName); + bool removeEventSlots(const std::string &groupName); //! Removes the given event group from the Event Manager. //! @param groupName Name of the event group to remove. //! @return True if removal was successful, false if removal was a failure. Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/GameManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -72,6 +72,7 @@ pGUIEnvironment = pDevice->getGUIEnvironment(); // Initialise subsystems of the framework (stage 2); + pAssetManager = new AssetManager(); pEntityManager = new EntityManager(); #ifdef __COMPILE_WITH_SFML_AUDIO__ @@ -137,6 +138,7 @@ #endif // __COMPILE_WITH_SFML_AUDIO__ delete pEventManager; + delete pAssetManager; delete pEntityManager; delete pDataStore; @@ -266,6 +268,12 @@ return pGUIEnvironment; } +// Returns a pointer to the AssetManager. +AssetManager* GameManager::getAssetManager() +{ + return pAssetManager; +} + // Returns a pointer to the DataStore. DataStore* GameManager::getDataStore() { Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/core/GameManager.h 2009-07-04 15:41:36 UTC (rev 73) @@ -20,6 +20,7 @@ #include "../dependencies.h" #include "ReferenceCounted.h" +#include "AssetManager.h" #include "DataStore.h" #include "EntityManager.h" #include "EventManager.h" @@ -108,6 +109,8 @@ //! @note Not available in AngelScript. IGUIEnvironment* getGUIEnvironment(); + //! Returns a pointer to the AssetManager. + AssetManager* getAssetManager(); //! Returns a pointer to the DataStore. DataStore* getDataStore(); //! Returns a pointer to the EntityManager. @@ -145,6 +148,7 @@ ISceneManager *pSceneManager; IGUIEnvironment *pGUIEnvironment; + AssetManager *pAssetManager; DataStore *pDataStore; EntityManager *pEntityManager; EventManager *pEventManager; Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/ScriptManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -97,7 +97,7 @@ void ScriptManager::clear() { // Remove scripts. - removeAllScripts(); + removeScripts(); // Remove script sections. mScriptSections.clear(); @@ -233,7 +233,7 @@ } // Removes all scripts. -void ScriptManager::removeAllScripts() +void ScriptManager::removeScripts() { for(u32 i = 0; i < mScripts.size(); i++) mScripts[i]->drop(); @@ -242,7 +242,7 @@ } // Removes all script sections, -void ScriptManager::removeAllScriptSections() +void ScriptManager::removeScriptSections() { mScriptSections.clear(); } Modified: trunk/src/scripting/ScriptManager.h =================================================================== --- trunk/src/scripting/ScriptManager.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/ScriptManager.h 2009-07-04 15:41:36 UTC (rev 73) @@ -89,9 +89,9 @@ Script* getScript(const std::string &name); //! Removes all scripts from the ScriptManager. - void removeAllScripts(); + void removeScripts(); //! Removes all script sections from the ScriptManager. - void removeAllScriptSections(); + void removeScriptSections(); //! Removes the given Script. //! @param script Pointer to the Script to remove. //! @return True if removal was successful, false if removal was a failure. Modified: trunk/src/scripting/core/asDataStack.cpp =================================================================== --- trunk/src/scripting/core/asDataStack.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/core/asDataStack.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -94,8 +94,8 @@ bindSetGetVar<u8>(engine, "u8"); bindSetGetVar<std::string>(engine, "string"); - r = engine->RegisterObjectMethod("DataStack", "void removeAll()", - asMETHOD(DataStack, removeAll), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("DataStack", "void removeVars()", + asMETHOD(DataStack, removeVars), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("DataStack", "bool removeVar(const string &in)", asMETHOD(DataStack, removeVar), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/core/asDataStore.cpp =================================================================== --- trunk/src/scripting/core/asDataStore.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/core/asDataStore.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -56,8 +56,8 @@ asMETHODPR(DataStore, getDataStack, (const std::string &), DataStack*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "void removeAllDataStacks()", - asMETHOD(DataStore, removeAllDataStacks), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("DataStore", "void removeDataStacks()", + asMETHOD(DataStore, removeDataStacks), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("DataStore", "bool removeDataStack(DataStack @+)", asMETHODPR(DataStore, removeDataStack, (DataStack*), bool), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/core/asEntity.cpp =================================================================== --- trunk/src/scripting/core/asEntity.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/core/asEntity.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -75,10 +75,10 @@ r = engine->RegisterObjectMethod("Entity", "Entity@ getParent()", asMETHOD(Entity, getParent), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "void removeAllChildren()", - asMETHOD(Entity, removeAllChildren), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "void removeAllComponents()", - asMETHOD(Entity, removeAllComponents), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void removeChildren()", + asMETHOD(Entity, removeChildren), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void removeComponents()", + asMETHOD(Entity, removeComponents), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "bool removeChild(Entity @+)", asMETHODPR(Entity, removeChild, (Entity*), bool), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/core/asEntityManager.cpp =================================================================== --- trunk/src/scripting/core/asEntityManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/core/asEntityManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -56,8 +56,8 @@ asMETHODPR(EntityManager, getEntity, (const std::string &), Entity*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "void removeAllEntities()", - asMETHOD(EntityManager, removeAllEntities), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EntityManager", "void removeEntities()", + asMETHOD(EntityManager, removeEntities), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(Entity @+)", asMETHODPR(EntityManager, removeEntity, (Entity*), bool), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/core/asEventManager.cpp =================================================================== --- trunk/src/scripting/core/asEventManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/core/asEventManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -61,10 +61,10 @@ r = engine->RegisterObjectMethod("EventManager", "f32 getMouseWheel()", asMETHOD(EventManager, getMouseWheel), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EventManager", "void removeAllEventGroups()", - asMETHOD(EventManager, removeAllEventGroups), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EventManager", "bool removeAllEventSlots(const string &in)", - asMETHOD(EventManager, removeAllEventSlots), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "void removeEventGroups()", + asMETHOD(EventManager, removeEventGroups), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "bool removeEventSlots(const string &in)", + asMETHOD(EventManager, removeEventSlots), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EventManager", "bool removeEventGroup(const string &in)", asMETHOD(EventManager, removeEventGroup), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EventManager", "bool removeEventSlot(const string &in, const string &in)", Modified: trunk/src/scripting/scripting/asScriptManager.cpp =================================================================== --- trunk/src/scripting/scripting/asScriptManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/scripting/asScriptManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -59,8 +59,8 @@ asMETHODPR(ScriptManager, getScript, (const std::string &), Script*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("ScriptManager", "void removeAllScripts()", - asMETHOD(ScriptManager, removeAllScripts), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ScriptManager", "void removeScripts()", + asMETHOD(ScriptManager, removeScripts), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("ScriptManager", "bool removeScript(Script @+)", asMETHODPR(ScriptManager, removeScript, (Script*), bool), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/sound/asSoundManager.cpp =================================================================== --- trunk/src/scripting/sound/asSoundManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/scripting/sound/asSoundManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -51,8 +51,8 @@ r = engine->RegisterObjectMethod("SoundManager", "bool loadSoundBuffer(const string &in)", asMETHOD(SoundManager, loadSoundBuffer), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("SoundManager", "void removeAll()", - asMETHOD(SoundManager, removeAll), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundManager", "void removeSoundBuffers()", + asMETHOD(SoundManager, removeSoundBuffers), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("SoundManager", "bool removeSoundBuffer(const string &in)", asMETHOD(SoundManager, removeSoundBuffer), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/sound/SoundManager.cpp 2009-07-04 15:41:36 UTC (rev 73) @@ -41,7 +41,7 @@ // Clears the Sound Manager. void SoundManager::clear() { - removeAll(); + removeSoundBuffers(); } // Angelscript: Increases the reference counter. @@ -114,7 +114,7 @@ } // Removes all sound buffers. -void SoundManager::removeAll() +void SoundManager::removeSoundBuffers() { std::map<std::string, sf::SoundBuffer*>::iterator it; for(it = mSoundBuffers.begin(); it != mSoundBuffers.end(); it++) Modified: trunk/src/sound/SoundManager.h =================================================================== --- trunk/src/sound/SoundManager.h 2009-06-29 20:39:40 UTC (rev 72) +++ trunk/src/sound/SoundManager.h 2009-07-04 15:41:36 UTC (rev 73) @@ -60,7 +60,7 @@ bool loadSoundBuffer(const std::string &fileName); //! Removes all sound buffers. - void removeAll(); + void removeSoundBuffers(); //! Removes the sound buffer with the given filename. //! @param fileName Name of the buffer to remove. bool removeSoundBuffer(const std::string &fileName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-06-29 20:39:43
|
Revision: 72 http://sirrf.svn.sourceforge.net/sirrf/?rev=72&view=rev Author: zccdark203 Date: 2009-06-29 20:39:40 +0000 (Mon, 29 Jun 2009) Log Message: ----------- Added the initial implementation of the AssetGroup class. Modified Paths: -------------- trunk/CHANGES trunk/CONTRIBUTORS trunk/README trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/docs/doxyfile trunk/src/scripting/core/asGameManager.cpp trunk/src/scripting/scripting/asScriptManager.cpp Added Paths: ----------- trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/CHANGES 2009-06-29 20:39:40 UTC (rev 72) @@ -1,7 +1,11 @@ ========================================================================== -Sirrf version 0.1.1 (SVN) - Changes +Sirrf version 0.2.0 (SVN) - Changes ========================================================================== +========================================================================== +Sirrf version 0.1.1 - Changes +========================================================================== + * Changed the reference counting system. Sirrf now uses a reference counting system similar to that of the Irrlicht engine. Modified: trunk/CONTRIBUTORS =================================================================== --- trunk/CONTRIBUTORS 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/CONTRIBUTORS 2009-06-29 20:39:40 UTC (rev 72) @@ -1,5 +1,5 @@ ========================================================================== -Sirrf version 0.1.1 (SVN) - Contributors +Sirrf version 0.2.0 (SVN) - Contributors ========================================================================== Please also note contributors who have contributed to the framework: Modified: trunk/README =================================================================== --- trunk/README 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/README 2009-06-29 20:39:40 UTC (rev 72) @@ -1,5 +1,5 @@ ========================================================================== -Sirrf version 0.1.1 (SVN) - Readme +Sirrf version 0.2.0 (SVN) - Readme ========================================================================== Content of this file: @@ -31,8 +31,8 @@ 2. Getting Started ========================================================================== - See the following tutorial on Sirrf's development hub: - http://apps.sf.net/trac/sirrf/wiki/Tutorials/v0.1.0/GettingStarted + See the appropriate tutorial on Sirrf's development hub: + http://apps.sf.net/trac/sirrf/wiki/Tutorials/v0.1.1/ ========================================================================== Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/build/CMake/CMakeLists.txt 2009-06-29 20:39:40 UTC (rev 72) @@ -32,6 +32,7 @@ ${SOURCE_DIR}components/sound/SoundSourceComponent.cpp # /src/core + ${SOURCE_DIR}core/AssetGroup.cpp ${SOURCE_DIR}core/DataStack.cpp ${SOURCE_DIR}core/DataStore.cpp ${SOURCE_DIR}core/Entity.cpp Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-06-29 20:39:40 UTC (rev 72) @@ -90,6 +90,8 @@ <Unit filename="../../src/components/sound/SoundSourceComponent.cpp" /> <Unit filename="../../src/components/sound/SoundSourceComponent.h" /> <Unit filename="../../src/config.h" /> + <Unit filename="../../src/core/AssetGroup.cpp" /> + <Unit filename="../../src/core/AssetGroup.h" /> <Unit filename="../../src/core/DataStack.cpp" /> <Unit filename="../../src/core/DataStack.h" /> <Unit filename="../../src/core/DataStore.cpp" /> Modified: trunk/docs/doxyfile =================================================================== --- trunk/docs/doxyfile 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/docs/doxyfile 2009-06-29 20:39:40 UTC (rev 72) @@ -31,7 +31,7 @@ # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = v0.1.0 +PROJECT_NUMBER = v0.2.0 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. Added: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp (rev 0) +++ trunk/src/core/AssetGroup.cpp 2009-06-29 20:39:40 UTC (rev 72) @@ -0,0 +1,300 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: AssetGroup.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +// Include files +#include "AssetGroup.h" +#include "GameManager.h" + + +// AssetGroup class +// Static variables. +u32 AssetGroup::mIDCount = 0; + +// AssetGroup constructor. +AssetGroup::AssetGroup(const std::string &name, const std::string &dirName) +: mName(name), mBaseDir(dirName) +{ + mID = mIDCount++; + init(); +} + +// AssetGroup deconstructor. +AssetGroup::~AssetGroup() +{ + clear(); +} + +// Initialises the AssetGroup. +void AssetGroup::init() +{ + // Retrieve pointer to Irrlicht's file system. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change to the root of asset directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str()); + + // Load the meshes. + loadMeshes(); + loadTextures(); + + // Set original working directory. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +// Clears the AssetGroup. +void AssetGroup::clear() +{ + removeTextures(); + removeMeshes(); +} + +// Loads the meshes associated with this asset group. +void AssetGroup::loadMeshes() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + // Change the working directory to the meshes directory. + if(!fileSystem->changeWorkingDirectoryTo("./meshes/")) + return; + + // Read the meshes. + IFileList *fileList = fileSystem->createFileList(); + + for(u32 i = 0; i < fileList->getFileCount(); i++) + { + // Get file name. + std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + + if(fileName == "..") + continue; + + // Load the mesh. + IAnimatedMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); + + if(mesh) + { + mMeshes[fileName] = mesh; + mesh->grab(); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(".."); +} + +// Loads the textures associated with this asset group. +void AssetGroup::loadTextures() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + IVideoDriver *pDriver = GameManager::Instance()->getDriver(); + + // Change the working directory to the meshes directory. + if(!fileSystem->changeWorkingDirectoryTo("./textures/")) + return; + + // Read the meshes. + IFileList *fileList = fileSystem->createFileList(); + + for(u32 i = 0; i < fileList->getFileCount(); i++) + { + // Get file name. + std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + + if(fileName == "..") + continue; + + // Load the mesh. + ITexture *texture = pDriver->getTexture(fileName.c_str()); + + if(texture) + { + mTextures[fileName] = texture; + texture->grab(); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(".."); +} + +// Gets the mesh with the given filename. +IAnimatedMesh* AssetGroup::getMesh(const std::string &name) +{ + std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(name); + + if(it != mMeshes.end()) + return it->second; + + return NULL; +} + +// Gets the texture with the given filename. +ITexture* AssetGroup::getTexture(const std::string &name) +{ + std::map<std::string, ITexture*>::iterator it = mTextures.find(name); + + if(it != mTextures.end()) + return it->second; + + return NULL; +} + +// Removes the given mesh. +bool AssetGroup::removeMesh(IAnimatedMesh *mesh) +{ + // Try to find the given mesh. + std::map<std::string, IAnimatedMesh*>::iterator it; + + for(it = mMeshes.begin(); it != mMeshes.end(); it++) + { + // Did we find the mesh? + if(mesh == it->second) + { + // Delete the mesh. + mesh->drop(); + GameManager::Instance()->getSceneManager()->getMeshCache()->removeMesh(mesh); + mMeshes.erase(it); + + return true; + } + } + + // We didn't find the mesh; the mesh remains untouched. + return false; +} + +// Removes the mesh with the given name. +bool AssetGroup::removeMesh(const std::string &name) +{ + // Try to find the given mesh. + std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(name); + + // Did we find the mesh? + if(it != mMeshes.end()) + { + // Get pointer to the found mesh. + IAnimatedMesh *mesh = it->second; + + // Delete the mesh. + mesh->drop(); + GameManager::Instance()->getSceneManager()->getMeshCache()->removeMesh(mesh); + mMeshes.erase(it); + + return true; + } + + // We didn't find the mesh. + else return false; +} + +// Removes all meshes from this asset group. +void AssetGroup::removeMeshes() +{ + // Get a pointer to the mesh cache. + IMeshCache *pMeshCache = GameManager::Instance()->getSceneManager()->getMeshCache(); + + // Delete the meshes. + std::map<std::string, IAnimatedMesh*>::iterator it; + + for(it = mMeshes.begin(); it != mMeshes.end(); it++) + { + IAnimatedMesh *mesh = it->second; + + mesh->drop(); + pMeshCache->removeMesh(mesh); + } + + // Clear the mesh map. + mMeshes.clear(); +} + +// Removes the given texture. +bool AssetGroup::removeTexture(ITexture *texture) +{ + // Try to find the given texture. + std::map<std::string, ITexture*>::iterator it; + + for(it = mTextures.begin(); it != mTextures.end(); it++) + { + // Did we find the texture? + if(texture == it->second) + { + // Delete the texture. + texture->drop(); + GameManager::Instance()->getDriver()->removeTexture(texture); + mTextures.erase(it); + + return true; + } + } + + // We didn't find the texture; the texture remains untouched. + return false; +} + +// Removes the texture with the given name. +bool AssetGroup::removeTexture(const std::string &name) +{ + // Try to find the given texture. + std::map<std::string, ITexture*>::iterator it = mTextures.find(name); + + // Did we find the texture? + if(it != mTextures.end()) + { + // Get pointer to the found texture. + ITexture *texture = it->second; + + // Delete the texture. + texture->drop(); + GameManager::Instance()->getDriver()->removeTexture(texture); + mTextures.erase(it); + + return true; + } + + // We didn't find the texture. + else return false; +} + +// Removes all textures from this asset group. +void AssetGroup::removeTextures() +{ + // Get a pointer to the driver.. + IVideoDriver *pDriver = GameManager::Instance()->getDriver(); + + // Delete the meshes. + std::map<std::string, ITexture*>::iterator it; + + for(it = mTextures.begin(); it != mTextures.end(); it++) + { + ITexture *texture = it->second; + + texture->drop(); + pDriver->removeTexture(texture); + } + + // Clear the texture map. + mTextures.clear(); +} + +// End of File Added: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h (rev 0) +++ trunk/src/core/AssetGroup.h 2009-06-29 20:39:40 UTC (rev 72) @@ -0,0 +1,91 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: AssetGroup.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the AssetGroup class. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +#ifndef __ASSETGROUP_H__ +#define __ASSETGROUP_H__ + +// Include files +#include "../dependencies.h" +#include "ReferenceCounted.h" + + +// Entity class +class AssetGroup : public ReferenceCounted +{ +public: + + // Initialisation and deinitialisation + //! Constructor + //! @param name Name of the asset group. + //! @param dirName Name of the base directory of the asset group. + AssetGroup(const std::string &name, const std::string &dirName); + //! Deconstructor + ~AssetGroup(); + + //! Initialises the AssetGroup. + void init(); + //! Clears the AssetGroup. + void clear(); + + // Public methods + //! Gets the mesh with the given filename. + //! @param name Filename of the mesh. + IAnimatedMesh* getMesh(const std::string &name); + //! Gets the texture with the given filename. + //! @param name Filename of the texture. + ITexture* getTexture(const std::string &name); + + /*void reloadAsset(const std::string &name); + void reloadAssets(); + void reloadMeshes(); + void reloadTextures();*/ + + //! Removes the given mesh. + //! @param mesh Mesh to remove. + bool removeMesh(IAnimatedMesh *mesh); + //! Removes the mesh with the given filename. + //! @param name Filename of the mesh. + bool removeMesh(const std::string &name); + //! Removes all meshes in this asset group. + void removeMeshes(); + + //! Removes the given texture. + //! @param texture Texture to remove. + bool removeTexture(ITexture *texture); + //! Removes the texture with the given filename. + //! @param name Filename of the texture. + bool removeTexture(const std::string &name); + //! Removes all textures in this asset group. + void removeTextures(); + +private: + + // Private methods + void loadMeshes(); + void loadTextures(); + + // Static members + static u32 mIDCount; + + // Private members + u32 mID; + std::string mName; + std::string mBaseDir; + + std::map<std::string, IAnimatedMesh*> mMeshes; + std::map<std::string, ITexture*> mTextures; +}; + +#endif Modified: trunk/src/scripting/core/asGameManager.cpp =================================================================== --- trunk/src/scripting/core/asGameManager.cpp 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/src/scripting/core/asGameManager.cpp 2009-06-29 20:39:40 UTC (rev 72) @@ -48,16 +48,16 @@ r = engine->RegisterGlobalFunction("GameManager& getGameManager()", asFUNCTION(GameManager::Instance), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @)", + r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @+)", asMETHODPR(GameManager, changeState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "void changeState(IGameState @)", + r = engine->RegisterObjectMethod("GameManager", "void changeState(IGameState @+)", asMETHODPR(GameManager, changeState, (asIScriptObject*), void), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "void pushState(GameState @)", + r = engine->RegisterObjectMethod("GameManager", "void pushState(GameState @+)", asMETHODPR(GameManager, pushState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "void pushState(IGameState @)", + r = engine->RegisterObjectMethod("GameManager", "void pushState(IGameState @+)", asMETHODPR(GameManager, pushState, (asIScriptObject*), void), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void popState()", Modified: trunk/src/scripting/scripting/asScriptManager.cpp =================================================================== --- trunk/src/scripting/scripting/asScriptManager.cpp 2009-06-21 13:56:54 UTC (rev 71) +++ trunk/src/scripting/scripting/asScriptManager.cpp 2009-06-29 20:39:40 UTC (rev 72) @@ -45,7 +45,7 @@ r = engine->RegisterObjectMethod("ScriptManager", "void clear()", asMETHOD(ScriptManager, clear), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("ScriptManager", "bool addScript(Script @)", + r = engine->RegisterObjectMethod("ScriptManager", "bool addScript(Script @+)", asMETHOD(ScriptManager, addScript), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScript(const string &in)", asMETHOD(ScriptManager, createScript), asCALL_THISCALL); assert(r >= 0); @@ -61,7 +61,7 @@ r = engine->RegisterObjectMethod("ScriptManager", "void removeAllScripts()", asMETHOD(ScriptManager, removeAllScripts), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("ScriptManager", "bool removeScript(Script @)", + r = engine->RegisterObjectMethod("ScriptManager", "bool removeScript(Script @+)", asMETHODPR(ScriptManager, removeScript, (Script*), bool), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("ScriptManager", "bool removeScript(const u32)", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-06-21 14:01:27
|
Revision: 71 http://sirrf.svn.sourceforge.net/sirrf/?rev=71&view=rev Author: zccdark203 Date: 2009-06-21 13:56:54 +0000 (Sun, 21 Jun 2009) Log Message: ----------- Sirrf 0.1.1 has been released Added Paths: ----------- tags/0.x/0.1.x/0.1.1/ tags/0.x/0.1.x/0.1.1/CHANGES tags/0.x/0.1.x/0.1.1/CONTRIBUTORS tags/0.x/0.1.x/0.1.1/README tags/0.x/0.1.x/0.1.1/bin/ tags/0.x/0.1.x/0.1.1/build/ tags/0.x/0.1.x/0.1.1/build/CMake/ tags/0.x/0.1.x/0.1.1/build/CMake/CMakeLists.txt tags/0.x/0.1.x/0.1.1/build/CodeBlocks/ tags/0.x/0.1.x/0.1.1/build/CodeBlocks/sirrf.cbp tags/0.x/0.1.x/0.1.1/docs/ tags/0.x/0.1.x/0.1.1/docs/docs/ tags/0.x/0.1.x/0.1.1/docs/docs/mainpage.txt tags/0.x/0.1.x/0.1.1/docs/doxyfile tags/0.x/0.1.x/0.1.1/share/ tags/0.x/0.1.x/0.1.1/src/ tags/0.x/0.1.x/0.1.1/src/components/ tags/0.x/0.1.x/0.1.1/src/components/components.h tags/0.x/0.1.x/0.1.1/src/components/scene/ tags/0.x/0.1.x/0.1.1/src/components/scene/AnimatedMeshComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/AnimatedMeshComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/BillboardComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/BillboardComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/CameraComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/CameraComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/ImageComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/ImageComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/LightComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/LightComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/MeshComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/MeshComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/OctTreeComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/OctTreeComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/ParticleSysComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/ParticleSysComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/SceneComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/SceneComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/SkyBoxComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/SkyBoxComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/SkyDomeComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/SkyDomeComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/TerrainComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/TerrainComponent.h tags/0.x/0.1.x/0.1.1/src/components/scene/TextBillboardComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/scene/TextBillboardComponent.h tags/0.x/0.1.x/0.1.1/src/components/sound/ tags/0.x/0.1.x/0.1.1/src/components/sound/SoundListenerComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/sound/SoundListenerComponent.h tags/0.x/0.1.x/0.1.1/src/components/sound/SoundSourceComponent.cpp tags/0.x/0.1.x/0.1.1/src/components/sound/SoundSourceComponent.h tags/0.x/0.1.x/0.1.1/src/config.h tags/0.x/0.1.x/0.1.1/src/core/ tags/0.x/0.1.x/0.1.1/src/core/DataStack.cpp tags/0.x/0.1.x/0.1.1/src/core/DataStack.h tags/0.x/0.1.x/0.1.1/src/core/DataStore.cpp tags/0.x/0.1.x/0.1.1/src/core/DataStore.h tags/0.x/0.1.x/0.1.1/src/core/Entity.cpp tags/0.x/0.1.x/0.1.1/src/core/Entity.h tags/0.x/0.1.x/0.1.1/src/core/EntityComponent.cpp tags/0.x/0.1.x/0.1.1/src/core/EntityComponent.h tags/0.x/0.1.x/0.1.1/src/core/EntityManager.cpp tags/0.x/0.1.x/0.1.1/src/core/EntityManager.h tags/0.x/0.1.x/0.1.1/src/core/EventManager.cpp tags/0.x/0.1.x/0.1.1/src/core/EventManager.h tags/0.x/0.1.x/0.1.1/src/core/GameManager.cpp tags/0.x/0.1.x/0.1.1/src/core/GameManager.h tags/0.x/0.1.x/0.1.1/src/core/GameState.cpp tags/0.x/0.1.x/0.1.1/src/core/GameState.h tags/0.x/0.1.x/0.1.1/src/core/ReferenceCounted.cpp tags/0.x/0.1.x/0.1.1/src/core/ReferenceCounted.h tags/0.x/0.1.x/0.1.1/src/dependencies.h tags/0.x/0.1.x/0.1.1/src/game/ tags/0.x/0.1.x/0.1.1/src/game/readme.txt tags/0.x/0.1.x/0.1.1/src/main.cpp tags/0.x/0.1.x/0.1.1/src/scripting/ tags/0.x/0.1.x/0.1.1/src/scripting/Script.cpp tags/0.x/0.1.x/0.1.1/src/scripting/Script.h tags/0.x/0.1.x/0.1.1/src/scripting/ScriptHelper.h tags/0.x/0.1.x/0.1.1/src/scripting/ScriptManager.cpp tags/0.x/0.1.x/0.1.1/src/scripting/ScriptManager.h tags/0.x/0.1.x/0.1.1/src/scripting/components/ tags/0.x/0.1.x/0.1.1/src/scripting/components/asComponents.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/asComponents.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/ tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asAnimatedMeshComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asAnimatedMeshComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asBillboardComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asBillboardComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asCameraComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asCameraComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asImageComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asImageComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asLightComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asLightComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asMeshComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asMeshComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asOctTreeComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asOctTreeComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asParticleSysComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asParticleSysComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asSceneComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asSceneComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asSkyBoxComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asSkyBoxComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asSkyDome.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asSkyDomeComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asTerrainComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asTerrainComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asTextBillboardComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/scene/asTextBillboardComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/sound/ tags/0.x/0.1.x/0.1.1/src/scripting/components/sound/asSoundListenerComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/sound/asSoundListenerComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/components/sound/asSoundSourceComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/components/sound/asSoundSourceComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/core/ tags/0.x/0.1.x/0.1.1/src/scripting/core/asDataStack.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asDataStack.h tags/0.x/0.1.x/0.1.1/src/scripting/core/asDataStore.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asDataStore.h tags/0.x/0.1.x/0.1.1/src/scripting/core/asEntity.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asEntity.h tags/0.x/0.1.x/0.1.1/src/scripting/core/asEntityComponent.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asEntityComponent.h tags/0.x/0.1.x/0.1.1/src/scripting/core/asEntityManager.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asEntityManager.h tags/0.x/0.1.x/0.1.1/src/scripting/core/asEventManager.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asEventManager.h tags/0.x/0.1.x/0.1.1/src/scripting/core/asGameManager.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asGameManager.h tags/0.x/0.1.x/0.1.1/src/scripting/core/asGameState.cpp tags/0.x/0.1.x/0.1.1/src/scripting/core/asGameState.h tags/0.x/0.1.x/0.1.1/src/scripting/game/ tags/0.x/0.1.x/0.1.1/src/scripting/scripting/ tags/0.x/0.1.x/0.1.1/src/scripting/scripting/asScript.cpp tags/0.x/0.1.x/0.1.1/src/scripting/scripting/asScript.h tags/0.x/0.1.x/0.1.1/src/scripting/scripting/asScriptManager.cpp tags/0.x/0.1.x/0.1.1/src/scripting/scripting/asScriptManager.h tags/0.x/0.1.x/0.1.1/src/scripting/sound/ tags/0.x/0.1.x/0.1.1/src/scripting/sound/asSoundManager.cpp tags/0.x/0.1.x/0.1.1/src/scripting/sound/asSoundManager.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/ tags/0.x/0.1.x/0.1.1/src/scripting/vendor/angelscript/ tags/0.x/0.1.x/0.1.1/src/scripting/vendor/angelscript/scriptstdstring.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/angelscript/scriptstdstring.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/ tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asAabbox3d.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asAabbox3d.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asDimension2d.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asDimension2d.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asIrrHelper.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asIrrlicht.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asIrrlicht.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asLine2d.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asLine2d.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asLine3d.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asLine3d.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asMatrix4.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asMatrix4.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asRect.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asRect.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asSColor.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asSColor.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asVector2d.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asVector2d.h tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asVector3d.cpp tags/0.x/0.1.x/0.1.1/src/scripting/vendor/irrlicht/asVector3d.h tags/0.x/0.1.x/0.1.1/src/sound/ tags/0.x/0.1.x/0.1.1/src/sound/SoundManager.cpp tags/0.x/0.1.x/0.1.1/src/sound/SoundManager.h tags/0.x/0.1.x/0.1.1/src/vendor/ tags/0.x/0.1.x/0.1.1/src/vendor/sigslot/ tags/0.x/0.1.x/0.1.1/src/vendor/sigslot/sigslot.h Added: tags/0.x/0.1.x/0.1.1/CHANGES =================================================================== --- tags/0.x/0.1.x/0.1.1/CHANGES (rev 0) +++ tags/0.x/0.1.x/0.1.1/CHANGES 2009-06-21 13:56:54 UTC (rev 71) @@ -0,0 +1,25 @@ +========================================================================== +Sirrf version 0.1.1 - Changes +========================================================================== + + * Changed the reference counting system. Sirrf now uses a reference + counting system similar to that of the Irrlicht engine. + + * Implemented the __COMPILE_WITH_SFML_AUDIO__ and + __COMPILE_WITH_ANGELSCRIPT__ compilation flags. With these flags it's + possible to enable/disable features of Sirrf without having to remove + them completely. These flags should also give an idea what should be + removed when a feature has to be removed completely. + + * Separated the AngelScript binding functions from the source and + header files where Sirrf classes are declared and implemented. + + * All objects which can be instanciated have been given assignment/copy + behaviours. + + * Switched from the scriptstring AngelScript add-on to the + scriptstdstring AngelScript add-on. + + * Changed the rendering order. In v0.1.0 Sirrf first rendered the scene, + then the subscribed entities, and finally the state. This order has + been reversed. Added: tags/0.x/0.1.x/0.1.1/CONTRIBUTORS =================================================================== --- tags/0.x/0.1.x/0.1.1/CONTRIBUTORS (rev 0) +++ tags/0.x/0.1.x/0.1.1/CONTRIBUTORS 2009-06-21 13:56:54 UTC (rev 71) @@ -0,0 +1,8 @@ +========================================================================== +Sirrf version 0.1.1 - Contributors +========================================================================== + + Please also note contributors who have contributed to the framework: + + FuzzYspo0N - Made various small bug-fixes in order to + let Sirrf run on the Windows platform; Added: tags/0.x/0.1.x/0.1.1/README =================================================================== --- tags/0.x/0.1.x/0.1.1/README (rev 0) +++ tags/0.x/0.1.x/0.1.1/README 2009-06-21 13:56:54 UTC (rev 71) @@ -0,0 +1,76 @@ +========================================================================== +Sirrf version 0.1.1 - Readme +========================================================================== + + Content of this file: + + 1. Directory Structure Overview + 2. How To Start + 3. License + 4. Contact + + +========================================================================== +1. Directory Structure Overview +========================================================================== + + After uncompressing the archive you'll find the following directories: + + /bin Binaries build with the provided build files will be + put in this directory. + /build Contains build files for various build systems and + IDEs. + /CMake CMake build files. + /CodeBlocks Code::Blocks project files. + /docs Documentation of Sirrf. + /share Put here the resources (i.e. models) your game uses. + /src The source code of Sirrf. + + +========================================================================== +2. Getting Started +========================================================================== + + See the appropriate tutorial on Sirrf's development hub: + http://apps.sf.net/trac/sirrf/wiki/Tutorials/v0.1.x/ + + +========================================================================== +3. License +========================================================================== + + Copyright (c) 2009 Michael Bartsch and Contributors + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. + + +========================================================================== +4. Contact +========================================================================== + + If you have problems, questions or suggestions, please visit the + official homepage of Sirrf: + + http://sourceforge.net/projects/sirrf + + If you want to contact the team, please send an email to Michael Bartsch: + + zcc...@us... + Added: tags/0.x/0.1.x/0.1.1/build/CMake/CMakeLists.txt =================================================================== --- tags/0.x/0.1.x/0.1.1/build/CMake/CMakeLists.txt (rev 0) +++ tags/0.x/0.1.x/0.1.1/build/CMake/CMakeLists.txt 2009-06-21 13:56:54 UTC (rev 71) @@ -0,0 +1,163 @@ +# CMake required minimum version. +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +# Project +PROJECT(SIRRF) +SET(PROJECT_NAME sirrf) + +# Define source files. +SET(SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../src/) + +SET(SOURCES + # /src + ${SOURCE_DIR}main.cpp + + # src/components + # src/components/scene + ${SOURCE_DIR}components/scene/AnimatedMeshComponent.cpp + ${SOURCE_DIR}components/scene/BillboardComponent.cpp + ${SOURCE_DIR}components/scene/CameraComponent.cpp + ${SOURCE_DIR}components/scene/ImageComponent.cpp + ${SOURCE_DIR}components/scene/LightComponent.cpp + ${SOURCE_DIR}components/scene/MeshComponent.cpp + ${SOURCE_DIR}components/scene/OctTreeComponent.cpp + ${SOURCE_DIR}components/scene/ParticleSysComponent.cpp + ${SOURCE_DIR}components/scene/SceneComponent.cpp + ${SOURCE_DIR}components/scene/SkyBoxComponent.cpp + ${SOURCE_DIR}components/scene/SkyDomeComponent.cpp + ${SOURCE_DIR}components/scene/TerrainComponent.cpp + ${SOURCE_DIR}components/scene/TextBillboardComponent.cpp + # src/components/sound + ${SOURCE_DIR}components/sound/SoundListenerComponent.cpp + ${SOURCE_DIR}components/sound/SoundSourceComponent.cpp + + # /src/core + ${SOURCE_DIR}core/DataStack.cpp + ${SOURCE_DIR}core/DataStore.cpp + ${SOURCE_DIR}core/Entity.cpp + ${SOURCE_DIR}core/EntityComponent.cpp + ${SOURCE_DIR}core/EntityManager.cpp + ${SOURCE_DIR}core/EventManager.cpp + ${SOURCE_DIR}core/GameManager.cpp + ${SOURCE_DIR}core/GameState.cpp + ${SOURCE_DIR}core/ReferenceCounted.cpp + + # /src/game + # Define here your own source files. + + # /src/scripting + ${SOURCE_DIR}scripting/Script.cpp + ${SOURCE_DIR}scripting/ScriptManager.cpp + # /src/scripting/components + ${SOURCE_DIR}scripting/components/asComponents.cpp + # /src/scripting/components/scene + ${SOURCE_DIR}scripting/components/scene/asAnimatedMeshComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asBillboardComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asCameraComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asImageComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asLightComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asMeshComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asOctTreeComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asParticleSysComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asSceneComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asSkyBoxComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asSkyDomeComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asTerrainComponent.cpp + ${SOURCE_DIR}scripting/components/scene/asTextBillboardComponent.cpp + # /src/scripting/components/sound + ${SOURCE_DIR}scripting/components/sound/asSoundListenerComponent.cpp + ${SOURCE_DIR}scripting/components/sound/asSoundSourceComponent.cpp + # /src/scripting/core + ${SOURCE_DIR}scripting/core/asDataStack.cpp + ${SOURCE_DIR}scripting/core/asDataStore.cpp + ${SOURCE_DIR}scripting/core/asEntity.cpp + ${SOURCE_DIR}scripting/core/asEntityComponent.cpp + ${SOURCE_DIR}scripting/core/asEntityManager.cpp + ${SOURCE_DIR}scripting/core/asEventManager.cpp + ${SOURCE_DIR}scripting/core/asGameManager.cpp + ${SOURCE_DIR}scripting/core/asGameState.cpp + # /src/scripting/scripting + ${SOURCE_DIR}scripting/scripting/asScript.cpp + ${SOURCE_DIR}scripting/scripting/asScriptManager.cpp + # /src/scripting/sound + ${SOURCE_DIR}scripting/sound/asSoundManager.cpp + # /src/scripting/vendor/angelscript + ${SOURCE_DIR}scripting/vendor/angelscript/scriptstdstring.cpp + # /src/scripting/vendor/irrlicht + ${SOURCE_DIR}scripting/vendor/irrlicht/asAabbox3d.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asDimension2d.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asIrrlicht.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asLine2d.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asLine3d.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asMatrix4.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asRect.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asSColor.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asVector2d.cpp + ${SOURCE_DIR}scripting/vendor/irrlicht/asVector3d.cpp + + # /src/sound + ${SOURCE_DIR}sound/SoundManager.cpp + ) + +MESSAGE("${SOURCES}") + +# Define include directories for third-party libraries. +SET(INCLUDE_DIRS + ${SOURCE_DIR}vendor + $ENV{PATH} + # Change the following lines to set the right include directories. + /usr/local/include/irrlicht + /usr/local/include/SFML + ) + +INCLUDE_DIRECTORIES(${INCLUDE_DIRS}) + +# Define library directories for third-party libraries. +SET(LIB_DIRS + $ENV{PATH} + ) + +LINK_DIRECTORIES(${LIB_DIRS}) + +# Define libraries with which we have to link. +IF(UNIX) + IF(APPLE) + ELSE(APPLE) + FIND_LIBRARY(LIB_GL GL REQUIRED) + FIND_LIBRARY(LIB_XXF86VM Xxf86vm REQUIRED) + FIND_LIBRARY(LIB_XEXT Xext REQUIRED) + FIND_LIBRARY(LIB_X11 X11 REQUIRED) + ENDIF(APPLE) +ENDIF(UNIX) + +FIND_LIBRARY(LIB_IRR Irrlicht REQUIRED) +FIND_LIBRARY(LIB_AS angelscript REQUIRED) +FIND_LIBRARY(LIB_SFML_SYSTEM sfml-system REQUIRED) +FIND_LIBRARY(LIB_SFML_AUDIO sfml-audio REQUIRED) + +IF(UNIX) + IF(APPLE) + ELSE(APPLE) + SET(LIBS + ${LIB_GL} + ${LIB_XXF86VM} + ${LIB_XEXT} + ${LIB_X11} + ) + ENDIF(APPLE) +ENDIF(UNIX) + +SET(LIBS + ${LIBS} + ${LIB_IRR} + ${LIB_AS} + ${LIB_SFML_SYSTEM} + ${LIB_SFML_AUDIO} + ) + +# Create the executable. +SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../bin) +ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIBS}) + Added: tags/0.x/0.1.x/0.1.1/build/CodeBlocks/sirrf.cbp =================================================================== --- tags/0.x/0.1.x/0.1.1/build/CodeBlocks/sirrf.cbp (rev 0) +++ tags/0.x/0.1.x/0.1.1/build/CodeBlocks/sirrf.cbp 2009-06-21 13:56:54 UTC (rev 71) @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> +<CodeBlocks_project_file> + <FileVersion major="1" minor="6" /> + <Project> + <Option title="Sirrf" /> + <Option pch_mode="2" /> + <Option compiler="gcc" /> + <Build> + <Target title="linux-debug"> + <Option output="../../bin/sirrf" prefix_auto="1" extension_auto="1" /> + <Option working_dir="../../bin" /> + <Option object_output="obj/linux/debug" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-g" /> + <Add directory="/usr/local/include/" /> + <Add directory="/usr/local/include/irrlicht" /> + </Compiler> + <Linker> + <Add option="-lGL" /> + <Add option="-lXxf86vm" /> + <Add option="-lXext" /> + <Add option="-lX11" /> + <Add option="-lsfml-system -lsfml-audio" /> + <Add library="libIrrlicht.a" /> + <Add library="libangelscript.a" /> + <Add directory="/usr/lib/" /> + <Add directory="/usr/local/lib/" /> + </Linker> + </Target> + <Target title="linux-release"> + <Option output="../../bin/sirrf" prefix_auto="1" extension_auto="1" /> + <Option working_dir="../../bin" /> + <Option object_output="obj/linux/release" /> + <Option type="1" /> + <Option compiler="gcc" /> + <Compiler> + <Add option="-O3" /> + <Add directory="/usr/local/include/" /> + <Add directory="/usr/local/include/irrlicht" /> + </Compiler> + <Linker> + <Add option="-s" /> + <Add option="-lGL" /> + <Add option="-lXxf86vm" /> + <Add option="-lXext" /> + <Add option="-lX11" /> + <Add option="-lsfml-system -lsfml-audio" /> + <Add library="libIrrlicht.a" /> + <Add library="libangelscript.a" /> + <Add directory="/usr/lib/" /> + <Add directory="/usr/local/lib/" /> + </Linker> + </Target> + </Build> + <Compiler> + <Add option="-Wall" /> + <Add directory="../../src/vendor" /> + </Compiler> + <Unit filename="../../src/components/components.h" /> + <Unit filename="../../src/components/scene/AnimatedMeshComponent.cpp" /> + <Unit filename="../../src/components/scene/AnimatedMeshComponent.h" /> + <Unit filename="../../src/components/scene/BillboardComponent.cpp" /> + <Unit filename="../../src/components/scene/BillboardComponent.h" /> + <Unit filename="../../src/components/scene/CameraComponent.cpp" /> + <Unit filename="../../src/components/scene/CameraComponent.h" /> + <Unit filename="../../src/components/scene/ImageComponent.cpp" /> + <Unit filename="../../src/components/scene/ImageComponent.h" /> + <Unit filename="../../src/components/scene/LightComponent.cpp" /> + <Unit filename="../../src/components/scene/LightComponent.h" /> + <Unit filename="../../src/components/scene/MeshComponent.cpp" /> + <Unit filename="../../src/components/scene/MeshComponent.h" /> + <Unit filename="../../src/components/scene/OctTreeComponent.cpp" /> + <Unit filename="../../src/components/scene/OctTreeComponent.h" /> + <Unit filename="../../src/components/scene/ParticleSysComponent.cpp" /> + <Unit filename="../../src/components/scene/ParticleSysComponent.h" /> + <Unit filename="../../src/components/scene/SceneComponent.cpp" /> + <Unit filename="../../src/components/scene/SceneComponent.h" /> + <Unit filename="../../src/components/scene/SkyBoxComponent.cpp" /> + <Unit filename="../../src/components/scene/SkyBoxComponent.h" /> + <Unit filename="../../src/components/scene/SkyDomeComponent.cpp" /> + <Unit filename="../../src/components/scene/SkyDomeComponent.h" /> + <Unit filename="../../src/components/scene/TerrainComponent.cpp" /> + <Unit filename="../../src/components/scene/TerrainComponent.h" /> + <Unit filename="../../src/components/scene/TextBillboardComponent.cpp" /> + <Unit filename="../../src/components/scene/TextBillboardComponent.h" /> + <Unit filename="../../src/components/sound/SoundListenerComponent.cpp" /> + <Unit filename="../../src/components/sound/SoundListenerComponent.h" /> + <Unit filename="../../src/components/sound/SoundSourceComponent.cpp" /> + <Unit filename="../../src/components/sound/SoundSourceComponent.h" /> + <Unit filename="../../src/config.h" /> + <Unit filename="../../src/core/DataStack.cpp" /> + <Unit filename="../../src/core/DataStack.h" /> + <Unit filename="../../src/core/DataStore.cpp" /> + <Unit filename="../../src/core/DataStore.h" /> + <Unit filename="../../src/core/Entity.cpp" /> + <Unit filename="../../src/core/Entity.h" /> + <Unit filename="../../src/core/EntityComponent.cpp" /> + <Unit filename="../../src/core/EntityComponent.h" /> + <Unit filename="../../src/core/EntityManager.cpp" /> + <Unit filename="../../src/core/EntityManager.h" /> + <Unit filename="../../src/core/EventManager.cpp" /> + <Unit filename="../../src/core/EventManager.h" /> + <Unit filename="../../src/core/GameManager.cpp" /> + <Unit filename="../../src/core/GameManager.h" /> + <Unit filename="../../src/core/GameState.cpp" /> + <Unit filename="../../src/core/GameState.h" /> + <Unit filename="../../src/core/ReferenceCounted.cpp" /> + <Unit filename="../../src/core/ReferenceCounted.h" /> + <Unit filename="../../src/dependencies.h" /> + <Unit filename="../../src/main.cpp" /> + <Unit filename="../../src/scripting/Script.cpp" /> + <Unit filename="../../src/scripting/Script.h" /> + <Unit filename="../../src/scripting/ScriptHelper.h" /> + <Unit filename="../../src/scripting/ScriptManager.cpp" /> + <Unit filename="../../src/scripting/ScriptManager.h" /> + <Unit filename="../../src/scripting/components/asComponents.cpp" /> + <Unit filename="../../src/scripting/components/asComponents.h" /> + <Unit filename="../../src/scripting/components/scene/asAnimatedMeshComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asAnimatedMeshComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asBillboardComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asBillboardComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asCameraComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asCameraComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asImageComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asImageComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asLightComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asLightComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asMeshComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asMeshComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asOctTreeComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asOctTreeComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asParticleSysComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asParticleSysComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asSceneComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asSceneComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asSkyBoxComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asSkyBoxComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asSkyDome.cpp" /> + <Unit filename="../../src/scripting/components/scene/asSkyDomeComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asTerrainComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asTerrainComponent.h" /> + <Unit filename="../../src/scripting/components/scene/asTextBillboardComponent.cpp" /> + <Unit filename="../../src/scripting/components/scene/asTextBillboardComponent.h" /> + <Unit filename="../../src/scripting/components/sound/asSoundListenerComponent.cpp" /> + <Unit filename="../../src/scripting/components/sound/asSoundListenerComponent.h" /> + <Unit filename="../../src/scripting/components/sound/asSoundSourceComponent.cpp" /> + <Unit filename="../../src/scripting/components/sound/asSoundSourceComponent.h" /> + <Unit filename="../../src/scripting/core/asDataStack.cpp" /> + <Unit filename="../../src/scripting/core/asDataStack.h" /> + <Unit filename="../../src/scripting/core/asDataStore.cpp" /> + <Unit filename="../../src/scripting/core/asDataStore.h" /> + <Unit filename="../../src/scripting/core/asEntity.cpp" /> + <Unit filename="../../src/scripting/core/asEntity.h" /> + <Unit filename="../../src/scripting/core/asEntityComponent.cpp" /> + <Unit filename="../../src/scripting/core/asEntityComponent.h" /> + <Unit filename="../../src/scripting/core/asEntityManager.cpp" /> + <Unit filename="../../src/scripting/core/asEntityManager.h" /> + <Unit filename="../../src/scripting/core/asEventManager.cpp" /> + <Unit filename="../../src/scripting/core/asEventManager.h" /> + <Unit filename="../../src/scripting/core/asGameManager.cpp" /> + <Unit filename="../../src/scripting/core/asGameManager.h" /> + <Unit filename="../../src/scripting/core/asGameState.cpp" /> + <Unit filename="../../src/scripting/core/asGameState.h" /> + <Unit filename="../../src/scripting/scripting/asScript.cpp" /> + <Unit filename="../../src/scripting/scripting/asScript.h" /> + <Unit filename="../../src/scripting/scripting/asScriptManager.cpp" /> + <Unit filename="../../src/scripting/scripting/asScriptManager.h" /> + <Unit filename="../../src/scripting/sound/asSoundManager.cpp" /> + <Unit filename="../../src/scripting/sound/asSoundManager.h" /> + <Unit filename="../../src/scripting/vendor/angelscript/scriptstdstring.cpp" /> + <Unit filename="../../src/scripting/vendor/angelscript/scriptstdstring.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asAabbox3d.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asAabbox3d.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asDimension2d.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asDimension2d.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asIrrHelper.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asIrrlicht.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asIrrlicht.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asLine2d.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asLine2d.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asLine3d.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asLine3d.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asMatrix4.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asMatrix4.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asRect.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asRect.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asSColor.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asSColor.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asVector2d.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asVector2d.h" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asVector3d.cpp" /> + <Unit filename="../../src/scripting/vendor/irrlicht/asVector3d.h" /> + <Unit filename="../../src/sound/SoundManager.cpp" /> + <Unit filename="../../src/sound/SoundManager.h" /> + <Extensions> + <code_completion /> + <envvars /> + <debugger /> + </Extensions> + </Project> +</CodeBlocks_project_file> Added: tags/0.x/0.1.x/0.1.1/docs/docs/mainpage.txt =================================================================== --- tags/0.x/0.1.x/0.1.1/docs/docs/mainpage.txt (rev 0) +++ tags/0.x/0.1.x/0.1.1/docs/docs/mainpage.txt 2009-06-21 13:56:54 UTC (rev 71) @@ -0,0 +1,6 @@ +//! \mainpage +//! Sirrf, the Simple Irrlicht Framework, is a free, open source, extendible, +//! and cross-platform framework for building games based upon the popular +//! Irrlicht Engine. +//! +//! The official website of the framework is: http://sf.net/projects/sirrf Added: tags/0.x/0.1.x/0.1.1/docs/doxyfile =================================================================== --- tags/0.x/0.1.x/0.1.1/docs/doxyfile (rev 0) +++ tags/0.x/0.1.x/0.1.1/docs/doxyfile 2009-06-21 13:56:54 UTC (rev 71) @@ -0,0 +1,1514 @@ +# Doxyfile 1.5.8 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = "Sirrf - Simple Irrlicht Framework" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = v0.1.0 + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = YES + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, +# Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), +# Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, +# Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, Slovene, +# Spanish, Swedish, and Ukrainian. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = ../src + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful is your file systems +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = YES + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = YES + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = YES + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or define consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and defines in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# This WARN_NO_PARAMDOC option can be abled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../src ./docs + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx +... [truncated message content] |
From: <zcc...@us...> - 2009-06-21 12:55:38
|
Revision: 70 http://sirrf.svn.sourceforge.net/sirrf/?rev=70&view=rev Author: zccdark203 Date: 2009-06-21 12:54:13 +0000 (Sun, 21 Jun 2009) Log Message: ----------- Changed Sirrf's reference counting system. The framework is now using a system similar to that of the Irrlicht Engine. Modified Paths: -------------- trunk/CHANGES trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/BillboardComponent.cpp trunk/src/components/scene/BillboardComponent.h trunk/src/components/scene/CameraComponent.cpp trunk/src/components/scene/CameraComponent.h trunk/src/components/scene/ImageComponent.cpp trunk/src/components/scene/ImageComponent.h trunk/src/components/scene/LightComponent.cpp trunk/src/components/scene/LightComponent.h trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/MeshComponent.h trunk/src/components/scene/OctTreeComponent.cpp trunk/src/components/scene/OctTreeComponent.h trunk/src/components/scene/ParticleSysComponent.cpp trunk/src/components/scene/ParticleSysComponent.h trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/components/scene/SkyBoxComponent.cpp trunk/src/components/scene/SkyBoxComponent.h trunk/src/components/scene/SkyDomeComponent.cpp trunk/src/components/scene/SkyDomeComponent.h trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/scene/TerrainComponent.h trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/components/scene/TextBillboardComponent.h trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundListenerComponent.h trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h trunk/src/core/DataStack.cpp trunk/src/core/DataStack.h trunk/src/core/DataStore.cpp trunk/src/core/DataStore.h trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityComponent.cpp trunk/src/core/EntityComponent.h trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h trunk/src/core/EventManager.cpp trunk/src/core/EventManager.h trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/core/GameState.cpp trunk/src/core/GameState.h trunk/src/scripting/Script.cpp trunk/src/scripting/Script.h trunk/src/scripting/ScriptHelper.h trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/ScriptManager.h trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp trunk/src/scripting/components/scene/asBillboardComponent.cpp trunk/src/scripting/components/scene/asCameraComponent.cpp trunk/src/scripting/components/scene/asImageComponent.cpp trunk/src/scripting/components/scene/asLightComponent.cpp trunk/src/scripting/components/scene/asMeshComponent.cpp trunk/src/scripting/components/scene/asOctTreeComponent.cpp trunk/src/scripting/components/scene/asParticleSysComponent.cpp trunk/src/scripting/components/scene/asSceneComponent.cpp trunk/src/scripting/components/scene/asSkyBoxComponent.cpp trunk/src/scripting/components/scene/asSkyDome.cpp trunk/src/scripting/components/scene/asTerrainComponent.cpp trunk/src/scripting/components/scene/asTextBillboardComponent.cpp trunk/src/scripting/components/sound/asSoundListenerComponent.cpp trunk/src/scripting/components/sound/asSoundSourceComponent.cpp trunk/src/scripting/core/asDataStack.cpp trunk/src/scripting/core/asDataStore.cpp trunk/src/scripting/core/asEntity.cpp trunk/src/scripting/core/asEntityComponent.cpp trunk/src/scripting/core/asEntityComponent.h trunk/src/scripting/core/asEntityManager.cpp trunk/src/scripting/core/asEventManager.cpp trunk/src/scripting/core/asGameManager.cpp trunk/src/scripting/core/asGameState.cpp trunk/src/scripting/scripting/asScript.cpp trunk/src/scripting/scripting/asScriptManager.cpp trunk/src/scripting/sound/asSoundManager.cpp trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Added Paths: ----------- trunk/src/core/ReferenceCounted.cpp trunk/src/core/ReferenceCounted.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/CHANGES 2009-06-21 12:54:13 UTC (rev 70) @@ -2,6 +2,9 @@ Sirrf version 0.1.1 (SVN) - Changes ========================================================================== + * Changed the reference counting system. Sirrf now uses a reference + counting system similar to that of the Irrlicht engine. + * Implemented the __COMPILE_WITH_SFML_AUDIO__ and __COMPILE_WITH_ANGELSCRIPT__ compilation flags. With these flags it's possible to enable/disable features of Sirrf without having to remove Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/build/CMake/CMakeLists.txt 2009-06-21 12:54:13 UTC (rev 70) @@ -40,6 +40,7 @@ ${SOURCE_DIR}core/EventManager.cpp ${SOURCE_DIR}core/GameManager.cpp ${SOURCE_DIR}core/GameState.cpp + ${SOURCE_DIR}core/ReferenceCounted.cpp # /src/game # Define here your own source files. Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-06-21 12:54:13 UTC (rev 70) @@ -106,6 +106,8 @@ <Unit filename="../../src/core/GameManager.h" /> <Unit filename="../../src/core/GameState.cpp" /> <Unit filename="../../src/core/GameState.h" /> + <Unit filename="../../src/core/ReferenceCounted.cpp" /> + <Unit filename="../../src/core/ReferenceCounted.h" /> <Unit filename="../../src/dependencies.h" /> <Unit filename="../../src/main.cpp" /> <Unit filename="../../src/scripting/Script.cpp" /> Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -82,20 +82,6 @@ mSceneNode = NULL; } -// AngelScript: Will be used to instanciate objects of this class. -AnimatedMeshComponent* AnimatedMeshComponent::refFactory(Entity *parent) -{ - return new AnimatedMeshComponent(parent); -} - -// AngelScript: Will be used to instanciate objects of this class. -AnimatedMeshComponent* AnimatedMeshComponent::refFactory(Entity *parent, const std::string &fileName, - const vector3df &rotation, - const vector3df &scale) -{ - return new AnimatedMeshComponent(parent, fileName, rotation, scale); -} - // Returns a direct pointer to the IAnimatedMeshSceneNode. IAnimatedMeshSceneNode* AnimatedMeshComponent::getAnimatedMeshSceneNode() { Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -51,15 +51,6 @@ //! Deconstructor ~AnimatedMeshComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static AnimatedMeshComponent* refFactory(Entity *parent); - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static AnimatedMeshComponent* refFactory(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale); - // Methods //! Returns a direct pointer to the IAnimatedMeshSceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -53,19 +53,6 @@ } } -// AngelScript: Will be used to instanciate objects of this class. -BillboardComponent* BillboardComponent::refFactory(Entity *parent) -{ - return new BillboardComponent(parent); -} - -// AngelScript: Will be used to instanciate objects of this class. -BillboardComponent* BillboardComponent::refFactory(Entity *parent, const dimension2df &size, - const SColor &colorTop, const SColor &colorBottom) -{ - return new BillboardComponent(parent, size, colorTop, colorBottom); -} - // Returns a direct pointer to the IBillboardSceneNode. IBillboardSceneNode* BillboardComponent::getBillboardSceneNode() { Modified: trunk/src/components/scene/BillboardComponent.h =================================================================== --- trunk/src/components/scene/BillboardComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/BillboardComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -39,15 +39,6 @@ //! Deconstructor ~BillboardComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static BillboardComponent* refFactory(Entity *parent); - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static BillboardComponent* refFactory(Entity *parent, const dimension2df &size, - const SColor &colorTop, const SColor &colorBottom); - // Methods //! Returns a direct pointer to the IBillboardSceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/CameraComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -44,18 +44,6 @@ mSceneNode = NULL; } -// AngelScript: Will be used to instanciate objects of this class. -CameraComponent* CameraComponent::refFactory(Entity *parent) -{ - return new CameraComponent(parent); -} - -// AngelScript: Will be used to instanciate objects of this class. -CameraComponent* CameraComponent::refFactory(Entity *parent, const vector3df &lookat) -{ - return new CameraComponent(parent, lookat); -} - // Returns a direct pointer to the ICameraSceneNode. ICameraSceneNode* CameraComponent::getCameraSceneNode() { Modified: trunk/src/components/scene/CameraComponent.h =================================================================== --- trunk/src/components/scene/CameraComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/CameraComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -35,14 +35,6 @@ //! Deconstructor ~CameraComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static CameraComponent* refFactory(Entity *parent); - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static CameraComponent* refFactory(Entity *parent, const vector3df &lookat); - // Methods //! Returns a direct pointer to the ICameraSceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/ImageComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -45,15 +45,19 @@ const vector2di &position, const rect<s32> &sourceRect, rect<s32> *clipRect, const SColor &color, const SColor &alphaColor, bool useAlphaColor) -: EntityComponent(parent), mAlphaColor(alphaColor), mClipRect(clipRect), mColor(color), +: EntityComponent(parent), mAlphaColor(alphaColor), mClipRect(NULL), mColor(color), mPosition(position), mSourceRect(sourceRect), mVisible(true), mUseAlphaColor(useAlphaColor) { // Get a pointer to sub-systems of the Game Manager. EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Load the texture/ + // Load the texture. mTexture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); + // Set the clip rect. + if(clipRect != NULL) + mClipRect = new rect<s32>(*clipRect); + // Set misc. variables. mName = "ImageComponent"; @@ -77,9 +81,13 @@ // Get a pointer to sub-systems of the Game Manager. EventManager *pEventMgr = GameManager::Instance()->getEventManager(); - // Load the texture/ + // Load the texture. mTexture = texture; + // Set the clip rect. + if(clipRect != NULL) + mClipRect = new rect<s32>(*clipRect); + // Set misc. variables. mName = "ImageComponent"; @@ -98,12 +106,6 @@ { } -// AngelScript: Will be used to instanciate objects of this class. -ImageComponent* ImageComponent::refFactory(Entity *parent) -{ - return new ImageComponent(parent); -} - // Gets the alpha color. const SColor& ImageComponent::getAlphaColor() const { Modified: trunk/src/components/scene/ImageComponent.h =================================================================== --- trunk/src/components/scene/ImageComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/ImageComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -64,11 +64,6 @@ //! Deconstructor ~ImageComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static ImageComponent* refFactory(Entity *parent); - // Public methods //! Gets the alpha color. const SColor& getAlphaColor() const; Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/LightComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -43,18 +43,6 @@ mSceneNode = NULL; } -// AngelScript: Will be used to instanciate objects of this class. -LightComponent* LightComponent::refFactory(Entity *parent) -{ - return new LightComponent(parent); -} - -// AngelScript: Will be used to instanciate objects of this class. -LightComponent* LightComponent::refFactory(Entity *parent, const SColor &color, f32 radius) -{ - return new LightComponent(parent, color, radius); -} - // Returns a direct pointer to the ILightSceneNode. ILightSceneNode* LightComponent::getLightSceneNode() { Modified: trunk/src/components/scene/LightComponent.h =================================================================== --- trunk/src/components/scene/LightComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/LightComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -37,14 +37,6 @@ //! Deconstructor ~LightComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static LightComponent* refFactory(Entity *parent); - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static LightComponent* refFactory(Entity *parent, const SColor &color, f32 radius); - // Methods //! Returns a direct pointer to the ILightSceneNode. ILightSceneNode* getLightSceneNode(); Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/MeshComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -80,19 +80,6 @@ mSceneNode = NULL; } -// AngelScript: Will be used to instanciate objects of this class. -MeshComponent* MeshComponent::refFactory(Entity *parent) -{ - return new MeshComponent(parent); -} - -// AngelScript: Will be used to instanciate objects of this class. -MeshComponent* MeshComponent::refFactory(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale) -{ - return new MeshComponent(parent, fileName, rotation, scale); -} - // Returns a direct pointer to the IMeshSceneNode. IMeshSceneNode* MeshComponent::getMeshSceneNode() { Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/MeshComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -51,15 +51,6 @@ //! Deconstructor ~MeshComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static MeshComponent* refFactory(Entity *parent); - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static MeshComponent* refFactory(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale); - // Methods //! Returns a direct pointer to the IMeshSceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -74,11 +74,4 @@ { } -// AngelScript: Will be used to instanciate objects of this class. -OctTreeComponent* OctTreeComponent::refFactory(Entity *parent, const std::string &fileName, - s32 minPolysPerNode) -{ - return new OctTreeComponent(parent, fileName, minPolysPerNode); -} - // End of File Modified: trunk/src/components/scene/OctTreeComponent.h =================================================================== --- trunk/src/components/scene/OctTreeComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/OctTreeComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -53,12 +53,6 @@ OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, s32 minPolysPerNode = 512); //! Deconstructor ~OctTreeComponent(); - - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static OctTreeComponent* refFactory(Entity *parent, const std::string &fileName, - s32 minPolysPerNode); }; #endif Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -45,13 +45,6 @@ mSceneNode = NULL; } -// AngelScript: Will be used to instanciate objects of this class. -ParticleSysComponent* ParticleSysComponent::refFactory(Entity *parent, const vector3df &rotation, - const vector3df &scale) -{ - return new ParticleSysComponent(parent, rotation, scale); -} - // Returns a direct pointer to the IParticleSystemSceneNode. IParticleSystemSceneNode* ParticleSysComponent::getParticleSystemSceneNode() { Modified: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -37,12 +37,6 @@ //! Deconstructor ~ParticleSysComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static ParticleSysComponent* refFactory(Entity *parent, const vector3df &rotation, - const vector3df &scale); - // Methods //! Returns a direct pointer to the IParticleSystemSceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/SceneComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -74,12 +74,6 @@ if(mMetaSelector != NULL) mMetaSelector->drop(); } -// AngelScript: Will be used to instanciate objects of this class. -SceneComponent* SceneComponent::refFactory(Entity* parent) -{ - return new SceneComponent(parent); -} - // Returns a direct pointer to the ISceneNode. ISceneNode* SceneComponent::getSceneNode() { Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/SceneComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -33,11 +33,6 @@ //! Deconstructor ~SceneComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static SceneComponent* refFactory(Entity *parent); - // Methods //! Returns a direct pointer to the ISceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/scene/SkyBoxComponent.cpp =================================================================== --- trunk/src/components/scene/SkyBoxComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/SkyBoxComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -66,13 +66,4 @@ { } -// AngelScript: Will be used to instanciate objects of this class. -SkyBoxComponent* SkyBoxComponent::refFactory(Entity *parent, const std::string &top, - const std::string &bottom, const std::string &left, - const std::string &right, const std::string &front, - const std::string &back) -{ - return new SkyBoxComponent(parent, top, bottom, left, right, front, back); -} - // End of File Modified: trunk/src/components/scene/SkyBoxComponent.h =================================================================== --- trunk/src/components/scene/SkyBoxComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/SkyBoxComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -52,14 +52,6 @@ const std::string &back); //! Deconstructor ~SkyBoxComponent(); - - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static SkyBoxComponent* refFactory(Entity *parent, const std::string &top, - const std::string &bottom, const std::string &left, - const std::string &right, const std::string &front, - const std::string &back); }; #endif Modified: trunk/src/components/scene/SkyDomeComponent.cpp =================================================================== --- trunk/src/components/scene/SkyDomeComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/SkyDomeComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -60,12 +60,4 @@ { } -// AngelScript: Will be used to instanciate objects of this class. -SkyDomeComponent* SkyDomeComponent::refFactory(Entity *parent, const std::string &fileName, - u32 hRes, u32 vRes, f32 texturePerc, f32 spherePerc, - f32 radius) -{ - return new SkyDomeComponent(parent, fileName, hRes, vRes, texturePerc, spherePerc, radius); -} - // End of File Modified: trunk/src/components/scene/SkyDomeComponent.h =================================================================== --- trunk/src/components/scene/SkyDomeComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/SkyDomeComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -54,12 +54,6 @@ f32 texturePerc = 0.9f, f32 spherePerc = 2.0f, f32 radius = 1000.0f); //! Deconstructor ~SkyDomeComponent(); - - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static SkyDomeComponent* refFactory(Entity *parent, const std::string &fileName, u32 hRes, - u32 vRes, f32 texturePerc, f32 spherePerc, f32 radius); }; #endif Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -65,21 +65,6 @@ mSceneNode = NULL; } -// AngelScript: Will be used to instanciate objects of this class. -TerrainComponent* TerrainComponent::refFactory(Entity *parent) -{ - return new TerrainComponent(parent); -} - -// AngelScript: Will be used to instanciate objects of this class. -TerrainComponent* TerrainComponent::refFactory(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale, - const SColor &vertexColor, s32 maxLOD, - s32 smoothFactor) -{ - return new TerrainComponent(parent, fileName, rotation, scale, vertexColor, maxLOD, smoothFactor); -} - // Returns a direct pointer to the ITerrainSceneNode. ITerrainSceneNode* TerrainComponent::getTerrainSceneNode() { Modified: trunk/src/components/scene/TerrainComponent.h =================================================================== --- trunk/src/components/scene/TerrainComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/TerrainComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -47,16 +47,6 @@ //! Deconstructor ~TerrainComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static TerrainComponent* refFactory(Entity *parent); - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static TerrainComponent* refFactory(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale, - const SColor &vertexColor, s32 maxLOD, s32 smoothFactor); - // Methods //! Returns a direct pointer to the ITerrainSceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/scene/TextBillboardComponent.cpp =================================================================== --- trunk/src/components/scene/TextBillboardComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/TextBillboardComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -93,23 +93,6 @@ mSceneNode = NULL; } -// AngelScript: Will be used to instanciate objects of this class. -TextBillboardComponent* TextBillboardComponent::refFactory(Entity *parent) -{ - return new TextBillboardComponent(parent); -} - -// AngelScript: Will be used to instanciate objects of this class. -TextBillboardComponent* TextBillboardComponent::refFactory(Entity *parent, - const std::string &fontFileName, - const std::string &text, - const dimension2df &size, - const SColor &colorTop, - const SColor &colorBottom) -{ - return new TextBillboardComponent(parent, fontFileName, text, size, colorTop, colorBottom); -} - // Returns a direct pointer to the IBillboardTextSceneNode. IBillboardTextSceneNode* TextBillboardComponent::getBillboardTextSceneNode() { Modified: trunk/src/components/scene/TextBillboardComponent.h =================================================================== --- trunk/src/components/scene/TextBillboardComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/scene/TextBillboardComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -56,16 +56,6 @@ //! Deconstructor ~TextBillboardComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static TextBillboardComponent* refFactory(Entity *parent); - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static TextBillboardComponent* refFactory(Entity *parent, const std::string &fontFileName, - const std::string &text, const dimension2df &size, - const SColor &colorTop, const SColor &colorBottom); - // Methods //! Returns a direct pointer to the IBillboardTextSceneNode. //! @note Not available in AngelScript. Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -57,12 +57,6 @@ setIsMainListener(false); } -// AngelScript: Will be used to instanciate objects of this class. -SoundListenerComponent* SoundListenerComponent::refFactory(Entity *parent, bool isMainListener) -{ - return new SoundListenerComponent(parent, isMainListener); -} - // Checks if this listener is the main listener. bool SoundListenerComponent::getIsMainListener() const { Modified: trunk/src/components/sound/SoundListenerComponent.h =================================================================== --- trunk/src/components/sound/SoundListenerComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/sound/SoundListenerComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -36,11 +36,6 @@ //! Deconstructor ~SoundListenerComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static SoundListenerComponent* refFactory(Entity *parent, bool isMainListener = true); - // Methods //! Checks if this listener is the main listener. bool getIsMainListener() const; Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -53,12 +53,6 @@ delete[] mBuffer; } -// AngelScript: Will be used to instanciate objects of this class. -SoundSourceComponent* SoundSourceComponent::refFactory(Entity *parent) -{ - return new SoundSourceComponent(parent); -} - // Returns a direct pointer to the sf::Sound object in this component. sf::Sound* SoundSourceComponent::getSound() { Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -35,11 +35,6 @@ //! Deconstructor ~SoundSourceComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static SoundSourceComponent* refFactory(Entity *parent); - // Methods //! Returns a direct pointer to the sf::Sound object in this component. //! @note Not available in AngelScript. Modified: trunk/src/core/DataStack.cpp =================================================================== --- trunk/src/core/DataStack.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/DataStack.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -27,7 +27,7 @@ // DataStack constructor. DataStack::DataStack(const std::string &name) -: mRefCount(1), mName(name) +: mName(name) { mID = mIDCount++; } @@ -49,28 +49,6 @@ removeAll(); } -// AngelScript: Will be used to instanciate objects of this class. -DataStack* DataStack::refFactory(const std::string &name) -{ - return new DataStack(name); -} - -// Angelscript: Increases the reference counter. -void DataStack::refAdd() -{ - mRefCount++; -} - -// Angelscript: Decreases the reference counter. -void DataStack::refRelease() -{ - if(--mRefCount == 0) - { - if(!GameManager::Instance()->getDataStore()->removeDataStack(this)) - delete this; - } -} - // Gets the ID of the DataStack. u32 DataStack::getID() const { Modified: trunk/src/core/DataStack.h =================================================================== --- trunk/src/core/DataStack.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/DataStack.h 2009-06-21 12:54:13 UTC (rev 70) @@ -18,6 +18,7 @@ // Include files #include "../dependencies.h" +#include "ReferenceCounted.h" #include "DataStore.h" // Forward declarations. @@ -29,7 +30,7 @@ //! variables that can be accessed from anywhere within the //! framework. Furthermore it's also possible to save these //! variables into files. -class DataStack +class DataStack : public ReferenceCounted { public: @@ -45,18 +46,6 @@ //! Clears the DataStack. void clear(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static DataStack* refFactory(const std::string &name); - //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); - //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); - - // Methods //! Gets the ID of the DataStack. u32 getID() const; @@ -146,9 +135,6 @@ // Static members static u32 mIDCount; - // Angelscript members - s32 mRefCount; - // Normal members u32 mID; std::string mName; Modified: trunk/src/core/DataStore.cpp =================================================================== --- trunk/src/core/DataStore.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/DataStore.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -42,14 +42,14 @@ removeAllDataStacks(); } -// Angelscript: Increases the reference counter. -void DataStore::refAdd() +// Increases the reference counter. +void DataStore::grab() { // Dummy function. } -// Angelscript: Decreases the reference counter. -void DataStore::refRelease() +// Decreases the reference counter. +void DataStore::drop() { // Dummy function. } @@ -67,7 +67,7 @@ // Add the DataStack to the vector. mStacks.push_back(stack); - stack->refAdd(); + stack->grab(); return true; } @@ -81,8 +81,8 @@ // Create the DataStack and add it to the vector. DataStack *stack = new DataStack(name); - stack->refAdd(); mStacks.push_back(stack); + stack->grab(); return stack; } @@ -116,7 +116,7 @@ { // Clear the DataStacks. for(u32 i = 0; i < mStacks.size(); i++) - delete mStacks[i]; + mStacks[i]->drop(); mStacks.clear(); } @@ -137,7 +137,7 @@ if(dstack == stack) { - delete dstack; + dstack->drop(); mStacks.erase(it); return true; } @@ -159,7 +159,7 @@ if(dstack->getID() == id) { - delete dstack; + dstack->drop(); mStacks.erase(it); return true; } @@ -181,7 +181,7 @@ if(dstack->getName() == name) { - delete dstack; + dstack->drop(); mStacks.erase(it); return true; } Modified: trunk/src/core/DataStore.h =================================================================== --- trunk/src/core/DataStore.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/DataStore.h 2009-06-21 12:54:13 UTC (rev 70) @@ -41,13 +41,13 @@ //! Clears the DataStore. void clear(); - // AngelScript binding + // Reference counting //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); + //! @note This is a dummy function. + void grab(); //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); + //! @note This is a dummy function. + void drop(); // Methods //! Adds the given DataStack to the DataStore. Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/Entity.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -24,7 +24,7 @@ // Entity constructor. Entity::Entity(const std::string &name, Entity *parent) -: mRefCount(1), mName(name), mPosition(0, 0, 0) +: mName(name), mPosition(0, 0, 0) { mID = mIDCount++; @@ -74,37 +74,6 @@ GameManager::Instance()->getEventManager()->removeEventGroup(std::string("ent#") + mName); } -// AngelScript: Will be used to instanciate objects of this class. -Entity* Entity::refFactory(const std::string &name) -{ - return new Entity(name); -} - -// Angelscript: Increases the reference counter. -void Entity::refAdd() -{ - mRefCount++; -} - -// Angelscript: Decreases the reference counter. -void Entity::refRelease() -{ - if(--mRefCount == 0) - { - if(pParent != NULL) - { - if(!pParent->removeChild(this)) - { - if(!GameManager::Instance()->getEntityManager()->removeEntity(this)) - delete this; - } - } - - else if(!GameManager::Instance()->getEntityManager()->removeEntity(this)) - delete this; - } -} - // Gets the ID of this entity. u32 Entity::getID() const { @@ -130,7 +99,7 @@ // Add new component. mChildren.push_back(entity); - entity->refAdd(); + entity->grab(); return true; } @@ -148,7 +117,7 @@ // Add new component. mComponents.push_back(component); - component->refAdd(); + component->grab(); return true; } @@ -219,7 +188,7 @@ for(u32 i = 0; i < mChildren.size(); i++) { if(!GameManager::Instance()->getEntityManager()->removeEntity(mChildren[i])) - delete mChildren[i]; + mChildren[i]->drop(); } mChildren.clear(); @@ -229,7 +198,7 @@ void Entity::removeAllComponents() { for(u32 i = 0; i < mComponents.size(); i++) - delete mComponents[i]; + mComponents[i]->drop(); mComponents.clear(); } @@ -250,9 +219,7 @@ if(ent == entity) { - if(!GameManager::Instance()->getEntityManager()->removeEntity(ent)) - delete ent; - + ent->drop(); mChildren.erase(it); return true; } @@ -274,9 +241,7 @@ if(ent->getID() == id) { - if(!GameManager::Instance()->getEntityManager()->removeEntity(ent)) - delete ent; - + ent->drop(); mChildren.erase(it); return true; } @@ -298,9 +263,7 @@ if(ent->getName() == name) { - if(!GameManager::Instance()->getEntityManager()->removeEntity(ent)) - delete ent; - + ent->drop(); mChildren.erase(it); return true; } @@ -326,7 +289,7 @@ if(comp == component) { - delete comp; + comp->drop(); mComponents.erase(it); return true; } @@ -348,7 +311,7 @@ if(comp->getID() == id) { - delete comp; + comp->drop(); mComponents.erase(it); return true; } @@ -370,7 +333,7 @@ if(comp->getName() == name) { - delete comp; + comp->drop(); mComponents.erase(it); return true; } Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/Entity.h 2009-06-21 12:54:13 UTC (rev 70) @@ -18,6 +18,7 @@ // Include files #include "../dependencies.h" +#include "ReferenceCounted.h" #include "EntityComponent.h" // Forward declarations @@ -26,7 +27,7 @@ // Entity class //! Represents an object in the game world. -class Entity : public sigslot::has_slots<> +class Entity : public sigslot::has_slots<>, public ReferenceCounted { public: @@ -38,17 +39,6 @@ //! Deconstructor ~Entity(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static Entity* refFactory(const std::string &name); - //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); - //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); - // Methods //! Gets the ID of this entity. u32 getID() const; @@ -138,9 +128,6 @@ // Static members static u32 mIDCount; - // Angelscript members - s32 mRefCount; - // Normal members Entity *pParent; Modified: trunk/src/core/EntityComponent.cpp =================================================================== --- trunk/src/core/EntityComponent.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/EntityComponent.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -24,7 +24,6 @@ // EntityComponent constructor. EntityComponent::EntityComponent(Entity *parent) -: mRefCount(1) { // Get new unique ID. mID = mIDCount++; @@ -33,7 +32,10 @@ if(parent != NULL) { if(parent->addComponent(this)) - pParent = parent; + { + pParent = parent; + parent->grab(); + } else pParent = NULL; } @@ -44,35 +46,10 @@ // EntityComponent deconstructor. EntityComponent::~EntityComponent() { + if(pParent != NULL) + pParent->drop(); } -// AngelScript: Will be used to instanciate objects of this class. -EntityComponent* EntityComponent::refFactory(Entity* parent) -{ - return new EntityComponent(parent); -} - -// Angelscript: Increases the reference counter. -void EntityComponent::refAdd() -{ - mRefCount++; -} - -// Angelscript: Decreases the reference counter. -void EntityComponent::refRelease() -{ - if(--mRefCount == 0) - { - if(pParent != NULL) - { - if(!pParent->removeComponent(this)) - delete this; - } - - else delete this; - } -} - // Gets the ID of the component. u32 EntityComponent::getID() const { Modified: trunk/src/core/EntityComponent.h =================================================================== --- trunk/src/core/EntityComponent.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/EntityComponent.h 2009-06-21 12:54:13 UTC (rev 70) @@ -18,6 +18,7 @@ // Include files #include "../dependencies.h" +#include "ReferenceCounted.h" #include "Entity.h" // Forward declarations @@ -26,7 +27,7 @@ // EntityComponent class //! Abstraction base class for adding new functionalities to entities. -class EntityComponent : public sigslot::has_slots<> +class EntityComponent : public sigslot::has_slots<>, public ReferenceCounted { public: @@ -37,17 +38,6 @@ //! Deconstructor virtual ~EntityComponent(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static EntityComponent* refFactory(Entity *parent); - //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); - //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); - // Methods //! Gets the ID of this component. u32 getID() const; @@ -72,9 +62,6 @@ // Static members static u32 mIDCount; - - // Angelscript members - s32 mRefCount; }; #endif Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/EntityManager.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -44,14 +44,14 @@ removeAllEntities(); } -// Angelscript: Increases the reference counter. -void EntityManager::refAdd() +// Increases the reference counter. +void EntityManager::grab() { // Dummy function. } -// Angelscript: Decreases the reference counter. -void EntityManager::refRelease() +// Decreases the reference counter. +void EntityManager::drop() { // Dummy function. } @@ -69,7 +69,7 @@ // Add the entity. mEntities.push_back(entity); - entity->refAdd(); + entity->grab(); return true; } @@ -83,8 +83,9 @@ // Add the entity. Entity *entity = new Entity(name, parent); - entity->refAdd(); mEntities.push_back(entity); + entity->grab(); + return entity; } @@ -116,7 +117,7 @@ void EntityManager::removeAllEntities() { for(u32 i = 0; i < mEntities.size(); i++) - delete mEntities[i]; + mEntities[i]->drop(); mEntities.clear(); } @@ -137,7 +138,7 @@ if(ent == entity) { - delete ent; + ent->drop(); mEntities.erase(it); return true; } @@ -159,7 +160,7 @@ if(ent->getID() == id) { - delete ent; + ent->drop(); mEntities.erase(it); return true; } @@ -181,7 +182,7 @@ if(ent->getName() == name) { - delete ent; + ent->drop(); mEntities.erase(it); return true; } Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/EntityManager.h 2009-06-21 12:54:13 UTC (rev 70) @@ -18,6 +18,7 @@ // Include files #include "../dependencies.h" +#include "ReferenceCounted.h" #include "Entity.h" // Forward declarations @@ -27,7 +28,7 @@ // EntityManager class //! The Entity Manager is the central interface point to all entity related functions of this //! program. -class EntityManager +class EntityManager : public ReferenceCounted { public: @@ -42,13 +43,13 @@ //! Clears the EntityManager. void clear(); - // AngelScript binding + // Reference counting //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); + //! @note This is a dummy function. + void grab(); //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); + //! @note This is a dummy function. + void drop(); // Methods //! Adds the given Entity to the EntityManager Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/EventManager.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -219,14 +219,14 @@ #undef addToKeyMap } -// Angelscript: Increases the reference counter. -void EventManager::refAdd() +// Increases the reference counter. +void EventManager::grab() { // Dummy function. } -// Angelscript: Decreases the reference counter. -void EventManager::refRelease() +// Decreases the reference counter. +void EventManager::drop() { // Dummy function. } Modified: trunk/src/core/EventManager.h =================================================================== --- trunk/src/core/EventManager.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/EventManager.h 2009-06-21 12:54:13 UTC (rev 70) @@ -18,6 +18,7 @@ // Include files #include "../dependencies.h" +#include "ReferenceCounted.h" // Typedefs typedef sigslot::signal1<void*> EventSlot; @@ -25,7 +26,7 @@ // EventManager class //! The Event Manager is the central interface point to all event related functions of this program. -class EventManager : public IEventReceiver +class EventManager : public IEventReceiver, public ReferenceCounted { public: @@ -40,13 +41,13 @@ //! Clears the EventManager. void clear(); - // AngelScript binding + // Reference counting //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); + //! @note This is a dummy function. + void grab(); //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); + //! @note This is a dummy function. + void drop(); // Methods //! Creates a new event group, a collection of events. Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/GameManager.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -144,20 +144,14 @@ pDevice->drop(); } -// AngelScript: Will be used to instanciate objects of this class. -GameManager* GameManager::refFactory() +// Increases the reference counter. +void GameManager::grab() { - return GameManager::Instance(); -} - -// Angelscript: Increases the reference counter. -void GameManager::refAdd() -{ // Dummy function. } -// Angelscript: Decreases the reference counter. -void GameManager::refRelease() +// Decreases the reference counter. +void GameManager::drop() { // Dummy function. } @@ -172,7 +166,7 @@ if(state != NULL) { mGameStates.push_back(state); - state->refAdd(); + state->grab(); state->init(); } } @@ -207,7 +201,7 @@ if(state != NULL) { mGameStates.push_back(state); - state->refAdd(); + state->grab(); state->init(); } } @@ -239,7 +233,7 @@ if(!mGameStates.empty()) { mGameStates.back()->clear(); - delete mGameStates.back(); + mGameStates.back()->drop(); mGameStates.pop_back(); } Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/GameManager.h 2009-06-21 12:54:13 UTC (rev 70) @@ -18,20 +18,20 @@ // Include files #include "../dependencies.h" +#include "ReferenceCounted.h" #include "DataStore.h" #include "EntityManager.h" #include "EventManager.h" #ifdef __COMPILE_WITH_SFML_AUDIO__ -#include "../sound/SoundManager.h" + #include "../sound/SoundManager.h" #endif // __COMPILE_WITH_SFML_AUDIO__ #ifdef __COMPILE_WITH_ANGELSCRIPT__ -#include "../scripting/ScriptManager.h" + #include "../scripting/ScriptManager.h" #endif // __COMPILE_WITH_ANGELSCRIPT__ - #include "../components/components.h" #include "GameState.h" @@ -45,7 +45,7 @@ //! The Game Manager is the central access point to the game. //! It is able to perform generic game initialisation and deinitialisation. It's main purpose, //! though, is to control the flow of the game. -class GameManager +class GameManager : public ReferenceCounted { public: @@ -67,16 +67,13 @@ //! Clears the GameManager. void clear(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static GameManager* refFactory(); + // Reference counting //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); + //! @note This is a dummy function. + void grab(); //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); + //! @note This is a dummy function. + void drop(); // Public methods //! Close the current state and change to the given state. Modified: trunk/src/core/GameState.cpp =================================================================== --- trunk/src/core/GameState.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/GameState.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -25,7 +25,6 @@ // Constructer of the GameState class. GameState::GameState() -: mRefCount(1) { mID = mIDCount++; @@ -68,26 +67,6 @@ { } -// AngelScript binding -// AngelScript: Will be used to instanciate objects of this class. -GameState* GameState::refFactory() -{ - return new GameState(); -} - -// Angelscript: Increases the reference counter. -void GameState::refAdd() -{ - mRefCount++; -} - -// Angelscript: Decreases the reference counter. -void GameState::refRelease() -{ - if(--mRefCount == 0) - delete this; -} - // Returns the base entity. const Entity* GameState::getBaseEntity() const { Modified: trunk/src/core/GameState.h =================================================================== --- trunk/src/core/GameState.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/core/GameState.h 2009-06-21 12:54:13 UTC (rev 70) @@ -25,7 +25,7 @@ // GameState class //! The GameState object is a base class which is implemented through derived sub-classes. -class GameState +class GameState : public ReferenceCounted { friend class ScriptedGameState; @@ -48,17 +48,6 @@ //! Renders the GameState. virtual void render(); - // AngelScript binding - //! Will be used to instanciate objects of this class. - //! @note For internal use only! - static GameState* refFactory(); - //! Increases the reference counter. - //! @note For internal use only! - void refAdd(); - //! Decreases the reference counter. - //! @note For internal use only! - void refRelease(); - // Public functions //! Returns a pointer to the base pointer of the GameState. const Entity* getBaseEntity() const; Added: trunk/src/core/ReferenceCounted.cpp =================================================================== --- trunk/src/core/ReferenceCounted.cpp (rev 0) +++ trunk/src/core/ReferenceCounted.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -0,0 +1,51 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: ReferenceCounted.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the ReferenceCounted class. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +// Include files +#include "ReferenceCounted.h" + + +// ReferenceCounted class +// ReferenceCounted constructor. +ReferenceCounted::ReferenceCounted() +: mRefCount(1) +{ +} + +// ReferenceCounted deconstructor. +ReferenceCounted::~ReferenceCounted() +{ +} + +// Gets the reference count. +s32 ReferenceCounted::getReferenceCount() +{ + return mRefCount; +} + +// Increases the reference counter. +void ReferenceCounted::grab() +{ + ++mRefCount; +} + +// Decreases the reference counter. +void ReferenceCounted::drop() +{ + if(--mRefCount == 0) + delete this; +} + +// End of File Added: trunk/src/core/ReferenceCounted.h =================================================================== --- trunk/src/core/ReferenceCounted.h (rev 0) +++ trunk/src/core/ReferenceCounted.h 2009-06-21 12:54:13 UTC (rev 70) @@ -0,0 +1,61 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: ReferenceCounted.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the ReferenceCounted class. +// +// License: Copyright (C) 2009 Michael Bartsch and Contributors +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +#ifndef __REFERENCECOUNTED_H__ +#define __REFERENCECOUNTED_H__ + +// Include files +#include "../dependencies.h" + + +// ReferenceCounted class +//! This class provides reference counting through the methods grab() and drop(). +//! Most objects with the framework are derived from ReferenceCounted, and so they +//! are reference counted. +//! +//! When you create an object within the framework, calling a method which starts +//! with 'create', an object is created, and you get a pointer to the new object. +//! If you no longer need the object, you have to call drop(). This will destroy +//! the object, if grab() was not called in another part of you program, because +//! this part still needs the object. Note, that you only need to call drop() to +//! the object, if you created it, and the method had a 'create' in it. +//! +//! @note Adapted from the Irrlicht API documentation. +class ReferenceCounted +{ +public: + + // Initialisation and deinitialisation + //! Constructor + ReferenceCounted(); + //! Deconstructor + virtual ~ReferenceCounted(); + + // Public methods + //! Increases the reference counter. + virtual void grab(); + //! Decreases the reference counter. + virtual void drop(); + + //! Gets the reference count. + s32 getReferenceCount(); + +private: + + // Private members + s32 mRefCount; +}; + +#endif Modified: trunk/src/scripting/Script.cpp =================================================================== --- trunk/src/scripting/Script.cpp 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/scripting/Script.cpp 2009-06-21 12:54:13 UTC (rev 70) @@ -53,28 +53,6 @@ mContext->Release(); } -// AngelScript: Will be used to instanciate objects of this class. -Script* Script::refFactory(const std::string &name) -{ - return new Script(name); -} - -// Angelscript: Increases the reference counter. -void Script::refAdd() -{ - mRefCount++; -} - -// Angelscript: Decreases the reference counter. -void Script::refRelease() -{ - if(--mRefCount == 0) - { - if(!GameManager::Instance()->getScriptManager()->removeScript(this)) - delete this; - } -} - // Gets the ID of this script. u32 Script::getID() const { Modified: trunk/src/scripting/Script.h =================================================================== --- trunk/src/scripting/Script.h 2009-06-17 17:31:40 UTC (rev 69) +++ trunk/src/scripting/Script.h 2009-06-21 12:54:13 UTC (rev 70) @@ -18,6 +18,7 @@ // Include files #include "../dependencies.h" +#include "../core/ReferenceCounted.h" #ifdef __COMPILE_WITH_ANGELSCRIPT__ @@ -30,7 +31,7 @@ // Script class //! The Script class is technically a wrapper for every AngelScript file that is loaded by the //! framework. -class Script +class Script : public ReferenceCounted { public: @@ -41,7 +42,7 @@ //! Deconstructor ~S... [truncated message content] |