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: <fuz...@us...> - 2009-08-21 13:18:29
|
Revision: 119 http://sirrf.svn.sourceforge.net/sirrf/?rev=119&view=rev Author: fuzzyspo0n Date: 2009-08-21 13:18:18 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Fixed projects readying for 0.2.0 release Fixed minor warnings Adjusted Contributors file Modified Paths: -------------- trunk/CONTRIBUTORS trunk/build/msvc2008/sirrf.sln trunk/build/msvc2008/sirrf.vcproj trunk/src/components/scene/OctTreeComponent.cpp Modified: trunk/CONTRIBUTORS =================================================================== --- trunk/CONTRIBUTORS 2009-08-21 11:22:50 UTC (rev 118) +++ trunk/CONTRIBUTORS 2009-08-21 13:18:18 UTC (rev 119) @@ -16,9 +16,7 @@ Michael Bartsch - Project founder and developer; - FuzzYspo0N - Made various small bug-fixes in order to - let Sirrf run on the Windows platform; - Provided MSVC 2008 project files; + FuzzYspo0N - Windows maintainer and developer; ========================================================================== Modified: trunk/build/msvc2008/sirrf.sln =================================================================== --- trunk/build/msvc2008/sirrf.sln 2009-08-21 11:22:50 UTC (rev 118) +++ trunk/build/msvc2008/sirrf.sln 2009-08-21 13:18:18 UTC (rev 119) @@ -1,7 +1,7 @@ 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}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sirrf project", "sirrf.vcproj", "{E4EFD3BA-8A8E-41DB-98C2-49721BD17C35}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Modified: trunk/build/msvc2008/sirrf.vcproj =================================================================== --- trunk/build/msvc2008/sirrf.vcproj 2009-08-21 11:22:50 UTC (rev 118) +++ trunk/build/msvc2008/sirrf.vcproj 2009-08-21 13:18:18 UTC (rev 119) @@ -61,7 +61,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="irrlicht.lib" + AdditionalDependencies="irrlicht.lib angelscript.lib" OutputFile="../../bin/$(ProjectName)_debug.exe" LinkIncremental="2" AdditionalLibraryDirectories="" @@ -118,7 +118,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="../../src/vendor;../../src" + AdditionalIncludeDirectories="../../src/vendor;../../src;" PreprocessorDefinitions="WIN32;NDEBUG;" RuntimeLibrary="2" EnableFunctionLevelLinking="true" @@ -348,6 +348,14 @@ > </File> <File + RelativePath="..\..\src\core\AssetProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\core\AssetProcessor.h" + > + </File> + <File RelativePath="..\..\src\core\DataStack.cpp" > </File> @@ -694,7 +702,7 @@ > </File> <File - RelativePath="..\..\src\scripting\components\scene\asSkyDome.cpp" + RelativePath="..\..\src\scripting\components\scene\asSkyDomeComponent.cpp" > </File> <File @@ -723,6 +731,30 @@ Name="core" > <File + RelativePath="..\..\src\scripting\core\asAssetGroup.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asAssetGroup.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asAssetManager.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asAssetManager.h" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asAssetProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\core\asAssetProcessor.h" + > + </File> + <File RelativePath="..\..\src\scripting\core\asDataStack.cpp" > </File> @@ -811,6 +843,34 @@ > </File> </Filter> + <Filter + Name="assets" + > + <File + RelativePath="..\..\src\scripting\assets\asEntityProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\assets\asEntityProcessor.h" + > + </File> + <File + RelativePath="..\..\src\scripting\assets\asProcessors.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\assets\asProcessors.h" + > + </File> + <File + RelativePath="..\..\src\scripting\assets\asScriptProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\scripting\assets\asScriptProcessor.h" + > + </File> + </Filter> </Filter> <Filter Name="vendor" @@ -836,6 +896,66 @@ > </File> </Filter> + <Filter + Name="assets" + > + <File + RelativePath="..\..\src\assets\EntityProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\assets\EntityProcessor.h" + > + </File> + <File + RelativePath="..\..\src\assets\HeightmapProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\assets\HeightmapProcessor.h" + > + </File> + <File + RelativePath="..\..\src\assets\MeshProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\assets\MeshProcessor.h" + > + </File> + <File + RelativePath="..\..\src\assets\processors.cpp" + > + </File> + <File + RelativePath="..\..\src\assets\processors.h" + > + </File> + <File + RelativePath="..\..\src\assets\ScriptProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\assets\ScriptProcessor.h" + > + </File> + <File + RelativePath="..\..\src\assets\SoundProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\assets\SoundProcessor.h" + > + </File> + <File + RelativePath="..\..\src\assets\TextureProcessor.cpp" + > + </File> + <File + RelativePath="..\..\src\assets\TextureProcessor.h" + > + </File> + </Filter> </Filter> <Filter Name="game" Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-08-21 11:22:50 UTC (rev 118) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-08-21 13:18:18 UTC (rev 119) @@ -174,7 +174,7 @@ f32 minPolysPerNode = file->getAttributeValueAsFloat(L"minPolysPerNode"); // Initialise the component. - component = new OctTreeComponent(entity, minPolysPerNode); + component = new OctTreeComponent(entity, s32(minPolysPerNode)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-21 11:22:59
|
Revision: 118 http://sirrf.svn.sourceforge.net/sirrf/?rev=118&view=rev Author: zccdark203 Date: 2009-08-21 11:22:50 +0000 (Fri, 21 Aug 2009) Log Message: ----------- Final changes on my part before the release of Sirrf v0.2.0. Modified Paths: -------------- trunk/CHANGES trunk/CONTRIBUTORS trunk/README trunk/src/assets/EntityProcessor.cpp trunk/src/game/InitState.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-20 19:05:03 UTC (rev 117) +++ trunk/CHANGES 2009-08-21 11:22:50 UTC (rev 118) @@ -1,5 +1,5 @@ ========================================================================== -Sirrf version 0.2.0 (SVN) - Changes +Sirrf version 0.2.0 - Changes ========================================================================== * Removed the AngelScript specific changeState and pushState methods Modified: trunk/CONTRIBUTORS =================================================================== --- trunk/CONTRIBUTORS 2009-08-20 19:05:03 UTC (rev 117) +++ trunk/CONTRIBUTORS 2009-08-21 11:22:50 UTC (rev 118) @@ -1,9 +1,31 @@ ========================================================================== -Sirrf version 0.2.0 (SVN) - Contributors +Sirrf version 0.2.0 - Contributors ========================================================================== + Content of this file: + + 1. Development Team + 2. Contributors + + +========================================================================== +1. Development Team +========================================================================== + Please also note contributors who have contributed to the framework: + Michael Bartsch - Project founder and developer; + FuzzYspo0N - Made various small bug-fixes in order to let Sirrf run on the Windows platform; Provided MSVC 2008 project files; + + +========================================================================== +2 Contributors +========================================================================== + + Please also note contributors who have contributed to the framework: + + Christian Clavet - Reported various bugs in early version of + the framework; Modified: trunk/README =================================================================== --- trunk/README 2009-08-20 19:05:03 UTC (rev 117) +++ trunk/README 2009-08-21 11:22:50 UTC (rev 118) @@ -1,5 +1,5 @@ ========================================================================== -Sirrf version 0.2.0 (SVN) - Readme +Sirrf version 0.2.0 - Readme ========================================================================== Content of this file: @@ -22,6 +22,7 @@ IDEs. /CMake CMake build files. /CodeBlocks Code::Blocks project files. + /msvc2008 Microsoft Visual C++ 2008 project files. /docs Documentation of Sirrf. /share Put here the resources (i.e. models) your game uses. /src The source code of Sirrf. @@ -32,7 +33,7 @@ ========================================================================== See the appropriate tutorial on Sirrf's development hub: - http://apps.sf.net/trac/sirrf/wiki/Tutorials/v0.1.1/ + http://apps.sf.net/trac/sirrf/wiki/Tutorials/v0.2.0/ ========================================================================== Modified: trunk/src/assets/EntityProcessor.cpp =================================================================== --- trunk/src/assets/EntityProcessor.cpp 2009-08-20 19:05:03 UTC (rev 117) +++ trunk/src/assets/EntityProcessor.cpp 2009-08-21 11:22:50 UTC (rev 118) @@ -122,10 +122,15 @@ Entity *entity = it->second; + entity->removeComponents(); entity->removeChildren(); - entity->setAbsolutePosition(entity->getParent()->getAbsolutePosition()); - entity->setAbsoluteRotation(entity->getParent()->getAbsoluteRotation()); + if(entity->getParent() != NULL) + { + entity->setAbsolutePosition(entity->getParent()->getAbsolutePosition()); + entity->setAbsoluteRotation(entity->getParent()->getAbsoluteRotation()); + } + entity->loadXML(xml); xml->drop(); @@ -196,6 +201,7 @@ Entity *entity = it->second; + entity->removeComponents(); entity->removeChildren(); if(entity->getParent() != NULL) Modified: trunk/src/game/InitState.cpp =================================================================== --- trunk/src/game/InitState.cpp 2009-08-20 19:05:03 UTC (rev 117) +++ trunk/src/game/InitState.cpp 2009-08-21 11:22:50 UTC (rev 118) @@ -36,6 +36,20 @@ // Initialises the InitState class. void InitState::init() { + IGUIEnvironment *pGUI = GameManager::Instance()->getGUIEnvironment(); + + IGUIWindow *window = pGUI->addWindow(rect<s32>(256, 320, 768, 448), true, L"Welcome to Sirrf"); + window->getCloseButton()->setVisible(false); + + pGUI->addStaticText(L"You have properly configured and compiled the framework. The framework has been compiled with:\n\n" + L"- Irrlicht\n" +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + L"- AngelScript\n" +#endif // __COMPILE_WITH_ANGELSCRIPT__ +#ifdef __COMPILE_WITH_SFML_AUDIO__ + L"- SFML-Audio\n" +#endif // __COMPILE_WITH_SFML_AUDIO__ + L"\nYou are now ready to start building your application.", rect<s32>(10, 30, 400, 100), false, true, window); } // Clears the InitState class. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-20 19:05:10
|
Revision: 117 http://sirrf.svn.sourceforge.net/sirrf/?rev=117&view=rev Author: zccdark203 Date: 2009-08-20 19:05:03 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Removed the changeState and pushState methods from the GameManager class. The same behaviour is now provided by two separate functions in asGameManager.cpp. Modified Paths: -------------- trunk/CHANGES trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/scripting/core/asGameManager.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-20 15:41:14 UTC (rev 116) +++ trunk/CHANGES 2009-08-20 19:05:03 UTC (rev 117) @@ -2,6 +2,10 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Removed the AngelScript specific changeState and pushState methods + from the GameManager class. The same behaviour is now provided + by two separate functions in asGameManager.cpp. + * Added "grab" parameter to AssetManager::createAssetGroup, DataStore::createDataStack, EntityManager::createEntity, ScriptManager::createScript and ScriptManager::createScriptFromFile. Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-08-20 15:41:14 UTC (rev 116) +++ trunk/src/core/GameManager.cpp 2009-08-20 19:05:03 UTC (rev 117) @@ -20,11 +20,7 @@ #include "GameManager.h" #include "../game/InitState.h" -#ifdef __COMPILE_WITH_ANGELSCRIPT__ -#include "../scripting/core/asGameState.h" // We need the ScriptedGameState class. -#endif // __COMPILE_WITH_ANGELSCRIPT__ - // GameManager class // Constructor of the GameManager class. GameManager::GameManager() @@ -182,25 +178,6 @@ } } -#ifdef __COMPILE_WITH_ANGELSCRIPT__ - -// Close the current state and change to the given state. -void GameManager::changeState(asIScriptObject *object) -{ - // Clear the current state. - popState(); - - // Initialise the state. - if(object != NULL) - { - ScriptedGameState *state = new ScriptedGameState(object); - mGameStates.push_back(state); - state->init(); - } -} - -#endif // __COMPILE_WITH_ANGELSCRIPT__ - // Pause the current state and change to the given state. void GameManager::pushState(GameState *state) { @@ -217,26 +194,6 @@ } } -#ifdef __COMPILE_WITH_ANGELSCRIPT__ - -// Pause the current state and change to the given state. -void GameManager::pushState(asIScriptObject *object) -{ - // Pause the current state. - if(!mGameStates.empty()) - mGameStates.back()->onPause(); - - // Initialise the state. - if(object != NULL) - { - ScriptedGameState *state = new ScriptedGameState(object); - mGameStates.push_back(state); - state->init(); - } -} - -#endif // __COMPILE_WITH_ANGELSCRIPT__ - // Close the current state and resume the previous state. void GameManager::popState() { Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-08-20 15:41:14 UTC (rev 116) +++ trunk/src/core/GameManager.h 2009-08-20 19:05:03 UTC (rev 117) @@ -80,19 +80,9 @@ //! Close the current state and change to the given state. //! @param state Pointer to the new state. void changeState(GameState *state); -#ifdef __COMPILE_WITH_ANGELSCRIPT__ - //! Close the current state and change to the given state. - //! @note For internal use only! - void changeState(asIScriptObject *object); -#endif // __COMPILE_WITH_ANGELSCRIPT__ //! Pause the current state and change to the given state. //! @param state Pointer to the new state. void pushState(GameState *state); -#ifdef __COMPILE_WITH_ANGELSCRIPT__ - //! Pause the current state and change to the given state. - //! @note For internal use only! - void pushState(asIScriptObject *object); -#endif // __COMPILE_WITH_ANGELSCRIPT__ //! Close the current state and resume the previous state. void popState(); Modified: trunk/src/scripting/core/asGameManager.cpp =================================================================== --- trunk/src/scripting/core/asGameManager.cpp 2009-08-20 15:41:14 UTC (rev 116) +++ trunk/src/scripting/core/asGameManager.cpp 2009-08-20 19:05:03 UTC (rev 117) @@ -18,6 +18,7 @@ #ifdef __COMPILE_WITH_ANGELSCRIPT__ +#include "asGameState.h" #include "../../core/GameManager.h" @@ -27,6 +28,24 @@ return GameManager::Instance(); } +//! Wrapper function to allow classes "derived" from the GameState class to be +//! used by the GameManager::changeState. +void changeState(asIScriptObject *object, GameManager *pGameMgr) +{ + ScriptedGameState *state = new ScriptedGameState(object); + pGameMgr->changeState(state); + state->drop(); +} + +//! Wrapper function to allow classes "derived" from the GameState class to be +//! used by the GameManager::pushState. +void pushState(asIScriptObject *object, GameManager *pGameMgr) +{ + ScriptedGameState *state = new ScriptedGameState(object); + pGameMgr->pushState(state); + state->drop(); +} + //! Binds the GameManager class to AngelScript. void bindGameManager(asIScriptEngine *engine) { @@ -52,14 +71,12 @@ asMETHODPR(GameManager, changeState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void changeState(IGameState @+)", - asMETHODPR(GameManager, changeState, (asIScriptObject*), void), - asCALL_THISCALL); assert(r >= 0); + asFUNCTION(changeState), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void pushState(GameState @+)", asMETHODPR(GameManager, pushState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void pushState(IGameState @+)", - asMETHODPR(GameManager, pushState, (asIScriptObject*), void), - asCALL_THISCALL); assert(r >= 0); + asFUNCTION(pushState), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void popState()", asMETHOD(GameManager, popState), 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-08-20 15:41:23
|
Revision: 116 http://sirrf.svn.sourceforge.net/sirrf/?rev=116&view=rev Author: zccdark203 Date: 2009-08-20 15:41:14 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Fixed an error in the CMake configuration file and renamed asSkyDome.cpp (in src/scripting/components/scene/) to asSkyDomeComponent.cpp. Modified Paths: -------------- trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp Added Paths: ----------- trunk/src/scripting/components/scene/asSkyDomeComponent.cpp Removed Paths: ------------- trunk/src/scripting/components/scene/asSkyDome.cpp Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-08-20 15:29:47 UTC (rev 115) +++ trunk/build/CMake/CMakeLists.txt 2009-08-20 15:41:14 UTC (rev 116) @@ -19,7 +19,7 @@ ${SOURCE_DIR}assets/TextureProcessor.cpp ${SOURCE_DIR}assets/ScriptProcessor.cpp ${SOURCE_DIR}assets/SoundProcessor.cpp - ${SOURCE_DIR}assets/processor.cpp + ${SOURCE_DIR}assets/processors.cpp # src/components ${SOURCE_DIR}components/components.cpp Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-08-20 15:29:47 UTC (rev 115) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-08-20 15:41:14 UTC (rev 116) @@ -168,7 +168,7 @@ <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.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" /> Deleted: trunk/src/scripting/components/scene/asSkyDome.cpp =================================================================== --- trunk/src/scripting/components/scene/asSkyDome.cpp 2009-08-20 15:29:47 UTC (rev 115) +++ trunk/src/scripting/components/scene/asSkyDome.cpp 2009-08-20 15:41:14 UTC (rev 116) @@ -1,80 +0,0 @@ -// ///////////////////////////////////////////////////////////////////////////// -// -// Name: asSkyDomeComponent.cpp -// Author: Michael Bartsch (ZCCdark203) -// -// Desc : Binds the SkyDomeComponent class to AngelScript -// -// 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 "asSkyDomeComponent.h" - - -#ifdef __COMPILE_WITH_ANGELSCRIPT__ - -#include "../../ScriptHelper.h" -#include "asSceneComponent.h" - -#include "../../../components/scene/SkyDomeComponent.h" - - -//! Reference factory for the SkyDomeComponent class. -SkyDomeComponent* createSkyDomeComponent(Entity *parent) -{ - return new SkyDomeComponent(parent); -} - -//! Reference factory for the SkyDomeComponent class. -SkyDomeComponent* createSkyDomeComponent(Entity *parent, u32 hRes, u32 vRes, f32 texturePerc, - f32 spherePerc, f32 radius) -{ - return new SkyDomeComponent(parent, hRes, vRes, texturePerc, spherePerc, radius); -} - -//! Reference factory for the SkyDomeComponent class. -SkyDomeComponent* createSkyDomeComponent(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); -} - -//! Binds the SkyDomeComponent class to AngelScript. -void bindSkyDomeComponent(asIScriptEngine *engine) -{ - // Forward declarations. - int r; - - // Bind SkyDomeComponent class. - r = engine->RegisterObjectType("SkyDomeComponent", sizeof(SkyDomeComponent), asOBJ_REF); assert(r >= 0); - - // Bind inherited functions. - bindSceneComponentBase<SkyDomeComponent>(engine, "SkyDomeComponent"); - - // Set SkyDomeComponent behaviour. - r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+)", - asFUNCTIONPR(createSkyDomeComponent, (Entity*), SkyDomeComponent*), - asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+, " \ - "u32, u32, f32, f32, f32)", - asFUNCTIONPR(createSkyDomeComponent, (Entity*, u32, u32, f32, f32, f32), - SkyDomeComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+, " \ - "const string &in, u32, u32, f32, f32, f32)", - asFUNCTIONPR(createSkyDomeComponent, (Entity*, const std::string&, - u32, u32, f32, f32, f32), SkyDomeComponent*), asCALL_CDECL); assert(r >= 0); - - r = engine->RegisterObjectMethod("SkyDomeComponent", "SkyDomeComponent& opAssign(const SkyDomeComponent &in)", - asFUNCTION(assignT<SkyDomeComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); -} - -#endif // __COMPILE_WITH_ANGELSCRIPT__ - -// End of File Copied: trunk/src/scripting/components/scene/asSkyDomeComponent.cpp (from rev 107, trunk/src/scripting/components/scene/asSkyDome.cpp) =================================================================== --- trunk/src/scripting/components/scene/asSkyDomeComponent.cpp (rev 0) +++ trunk/src/scripting/components/scene/asSkyDomeComponent.cpp 2009-08-20 15:41:14 UTC (rev 116) @@ -0,0 +1,80 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asSkyDomeComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the SkyDomeComponent class to AngelScript +// +// 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 "asSkyDomeComponent.h" + + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../../ScriptHelper.h" +#include "asSceneComponent.h" + +#include "../../../components/scene/SkyDomeComponent.h" + + +//! Reference factory for the SkyDomeComponent class. +SkyDomeComponent* createSkyDomeComponent(Entity *parent) +{ + return new SkyDomeComponent(parent); +} + +//! Reference factory for the SkyDomeComponent class. +SkyDomeComponent* createSkyDomeComponent(Entity *parent, u32 hRes, u32 vRes, f32 texturePerc, + f32 spherePerc, f32 radius) +{ + return new SkyDomeComponent(parent, hRes, vRes, texturePerc, spherePerc, radius); +} + +//! Reference factory for the SkyDomeComponent class. +SkyDomeComponent* createSkyDomeComponent(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); +} + +//! Binds the SkyDomeComponent class to AngelScript. +void bindSkyDomeComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SkyDomeComponent class. + r = engine->RegisterObjectType("SkyDomeComponent", sizeof(SkyDomeComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<SkyDomeComponent>(engine, "SkyDomeComponent"); + + // Set SkyDomeComponent behaviour. + r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+)", + asFUNCTIONPR(createSkyDomeComponent, (Entity*), SkyDomeComponent*), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+, " \ + "u32, u32, f32, f32, f32)", + asFUNCTIONPR(createSkyDomeComponent, (Entity*, u32, u32, f32, f32, f32), + SkyDomeComponent*), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+, " \ + "const string &in, u32, u32, f32, f32, f32)", + asFUNCTIONPR(createSkyDomeComponent, (Entity*, const std::string&, + u32, u32, f32, f32, f32), SkyDomeComponent*), asCALL_CDECL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SkyDomeComponent", "SkyDomeComponent& opAssign(const SkyDomeComponent &in)", + asFUNCTION(assignT<SkyDomeComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-20 15:29:55
|
Revision: 115 http://sirrf.svn.sourceforge.net/sirrf/?rev=115&view=rev Author: zccdark203 Date: 2009-08-20 15:29:47 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Added the AngelScript bindings of the asset management system. Furthermore I made various small improvements to the framework as a whole. Modified Paths: -------------- trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/core/AssetGroup.h trunk/src/core/AssetManager.h trunk/src/core/AssetProcessor.cpp trunk/src/core/AssetProcessor.h trunk/src/core/DataStore.h trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/components/asComponents.h trunk/src/scripting/components/sound/asSoundListenerComponent.cpp trunk/src/scripting/components/sound/asSoundSourceComponent.cpp trunk/src/scripting/core/asEntityManager.cpp trunk/src/scripting/core/asGameManager.cpp Added Paths: ----------- trunk/src/scripting/assets/ trunk/src/scripting/assets/asEntityProcessor.cpp trunk/src/scripting/assets/asEntityProcessor.h trunk/src/scripting/assets/asProcessors.cpp trunk/src/scripting/assets/asProcessors.h trunk/src/scripting/assets/asScriptProcessor.cpp trunk/src/scripting/assets/asScriptProcessor.h trunk/src/scripting/core/asAssetGroup.cpp trunk/src/scripting/core/asAssetGroup.h trunk/src/scripting/core/asAssetManager.cpp trunk/src/scripting/core/asAssetManager.h trunk/src/scripting/core/asAssetProcessor.cpp trunk/src/scripting/core/asAssetProcessor.h Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/build/CMake/CMakeLists.txt 2009-08-20 15:29:47 UTC (rev 115) @@ -62,6 +62,10 @@ # /src/scripting ${SOURCE_DIR}scripting/Script.cpp ${SOURCE_DIR}scripting/ScriptManager.cpp + # /src/scripting/assets + ${SOURCE_DIR}scripting/assets/asEntityProcessor.cpp + ${SOURCE_DIR}scripting/assets/asProcessors.cpp + ${SOURCE_DIR}scripting/assets/asScriptProcessor.cpp # /src/scripting/components ${SOURCE_DIR}scripting/components/asComponents.cpp # /src/scripting/components/scene @@ -82,6 +86,9 @@ ${SOURCE_DIR}scripting/components/sound/asSoundListenerComponent.cpp ${SOURCE_DIR}scripting/components/sound/asSoundSourceComponent.cpp # /src/scripting/core + ${SOURCE_DIR}scripting/core/asAssetGroup.cpp + ${SOURCE_DIR}scripting/core/asAssetManager.cpp + ${SOURCE_DIR}scripting/core/asAssetProcessor.cpp ${SOURCE_DIR}scripting/core/asDataStack.cpp ${SOURCE_DIR}scripting/core/asDataStore.cpp ${SOURCE_DIR}scripting/core/asEntity.cpp Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-08-20 15:29:47 UTC (rev 115) @@ -140,6 +140,12 @@ <Unit filename="../../src/scripting/ScriptHelper.h" /> <Unit filename="../../src/scripting/ScriptManager.cpp" /> <Unit filename="../../src/scripting/ScriptManager.h" /> + <Unit filename="../../src/scripting/assets/asEntityProcessor.cpp" /> + <Unit filename="../../src/scripting/assets/asEntityProcessor.h" /> + <Unit filename="../../src/scripting/assets/asProcessors.cpp" /> + <Unit filename="../../src/scripting/assets/asProcessors.h" /> + <Unit filename="../../src/scripting/assets/asScriptProcessor.cpp" /> + <Unit filename="../../src/scripting/assets/asScriptProcessor.h" /> <Unit filename="../../src/scripting/components/asComponents.cpp" /> <Unit filename="../../src/scripting/components/asComponents.h" /> <Unit filename="../../src/scripting/components/scene/asAnimatedMeshComponent.cpp" /> @@ -172,6 +178,12 @@ <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/asAssetGroup.cpp" /> + <Unit filename="../../src/scripting/core/asAssetGroup.h" /> + <Unit filename="../../src/scripting/core/asAssetManager.cpp" /> + <Unit filename="../../src/scripting/core/asAssetManager.h" /> + <Unit filename="../../src/scripting/core/asAssetProcessor.cpp" /> + <Unit filename="../../src/scripting/core/asAssetProcessor.h" /> <Unit filename="../../src/scripting/core/asDataStack.cpp" /> <Unit filename="../../src/scripting/core/asDataStack.h" /> <Unit filename="../../src/scripting/core/asDataStore.cpp" /> Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/core/AssetGroup.h 2009-08-20 15:29:47 UTC (rev 115) @@ -76,9 +76,6 @@ // Private methods void loadAssets(); - bool loadTexture(const std::string &fileName); - void loadTextures(); - // Static members static u32 mIDCount; Modified: trunk/src/core/AssetManager.h =================================================================== --- trunk/src/core/AssetManager.h 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/core/AssetManager.h 2009-08-20 15:29:47 UTC (rev 115) @@ -30,7 +30,11 @@ // AssetManager class //! The AssetManager class manages the AssetGroups that are being used by the framework. -class AssetManager +//! An asset managed by the AssetManager is only accessible through the AssetManager and +//! its related classes. That means that you can access assets through their respective +//! "normal" managers (i.e. meshes by Irrlicht's IMeshCache or entities by Sirrf's +//! EntityManager). +class AssetManager : public ReferenceCounted { friend class AssetGroup; @@ -57,9 +61,9 @@ // Methods //! Adds the given AssetGroup to the DataStore. - //! @param stack Pointer to the AssetGroup to add. + //! @param group Pointer to the AssetGroup to add. //! @return True if addition was successful, false if addition was a failure. - bool addAssetGroup(AssetGroup *stack); + bool addAssetGroup(AssetGroup *group); //! 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. Modified: trunk/src/core/AssetProcessor.cpp =================================================================== --- trunk/src/core/AssetProcessor.cpp 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/core/AssetProcessor.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -48,4 +48,39 @@ return pParent; } +// The following methods are dummy methods, which are needed to prevent problems +// with binding them to AngelScript. +// Loads all assets with the give name. +bool AssetProcessor::loadAsset(const std::string &fileName) +{ + return false; +} + +// Loads all assets. +void AssetProcessor::loadAssets() +{ +} + +// Reloads the asset with the given filename. +bool AssetProcessor::reloadAsset(const std::string &fileName) +{ + return false; +} + +// Reloads all assets. +void AssetProcessor::reloadAssets() +{ +} + +// Removes the asset with the given filename. +bool AssetProcessor::removeAsset(const std::string &fileName) +{ + return false; +} + +// Removes all assets. +void AssetProcessor::removeAssets() +{ +} + // End of File Modified: trunk/src/core/AssetProcessor.h =================================================================== --- trunk/src/core/AssetProcessor.h 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/core/AssetProcessor.h 2009-08-20 15:29:47 UTC (rev 115) @@ -50,16 +50,16 @@ //! Reloads the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful reload, false otherwise. - virtual bool reloadAsset(const std::string &fileName) = 0; + virtual bool reloadAsset(const std::string &fileName); //! Reloads all assets. - virtual void reloadAssets() = 0; + virtual void reloadAssets(); //! Removes the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful removal, false otherwise. - virtual bool removeAsset(const std::string &fileName) = 0; + virtual bool removeAsset(const std::string &fileName); //! Removes all assets. - virtual void removeAssets() = 0; + virtual void removeAssets(); protected: @@ -67,9 +67,9 @@ //! Loads the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful loading, false otherwise. - virtual bool loadAsset(const std::string &fileName) = 0; + virtual bool loadAsset(const std::string &fileName); //! Loads all assets. - virtual void loadAssets() = 0; + virtual void loadAssets(); // Protected members //! Parent of this processor. Modified: trunk/src/core/DataStore.h =================================================================== --- trunk/src/core/DataStore.h 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/core/DataStore.h 2009-08-20 15:29:47 UTC (rev 115) @@ -26,7 +26,7 @@ // DataStore class //! The DataStore class manages the DataStacks that are being used by the framework. -class DataStore +class DataStore : public ReferenceCounted { public: Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/scripting/ScriptManager.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -26,8 +26,12 @@ #include "vendor/angelscript/scriptstdstring.h" // Standard Angelscript add-on. #include "vendor/irrlicht/asIrrlicht.h" +#include "assets/asProcessors.h" #include "components/asComponents.h" +#include "core/asAssetGroup.h" +#include "core/asAssetManager.h" +#include "core/asAssetProcessor.h" #include "core/asDataStack.h" #include "core/asDataStore.h" #include "core/asEntity.h" @@ -77,18 +81,29 @@ bindIrrlicht(pEngine); // Register classes and functions. + bindAssetGroup(pEngine); + bindAssetManager(pEngine); + bindAssetProcessor(pEngine); + + bindDataStack(pEngine); + bindDataStore(pEngine); + bindEntity(pEngine); bindEntityComponent(pEngine); - bindComponents(pEngine); bindEntityManager(pEngine); + bindEventManager(pEngine); - bindDataStack(pEngine); - bindDataStore(pEngine); + #ifdef __COMPILE_WITH_SFML_AUDIO__ bindSoundManager(pEngine); #endif // __COMPILE_WITH_SFML_AUDIO__ + bindScript(pEngine); bindScriptManager(pEngine); + + bindAssetProcessors(pEngine); + bindComponents(pEngine); + bindGameState(pEngine); bindGameManager(pEngine); } Added: trunk/src/scripting/assets/asEntityProcessor.cpp =================================================================== --- trunk/src/scripting/assets/asEntityProcessor.cpp (rev 0) +++ trunk/src/scripting/assets/asEntityProcessor.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,49 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asEntityProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the EntityProcessor class to AngelScript +// +// 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 "asEntityProcessor.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../ScriptHelper.h" +#include "../core/asAssetProcessor.h" + +#include "../../assets/EntityProcessor.h" + +//! Binds the EntityProcessor class to AngelScript. +void bindEntityProcessor(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind EntityProcessor class. + r = engine->RegisterObjectType("EntityProcessor", sizeof(EntityProcessor), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindAssetProcessorBase<EntityProcessor>(engine, "EntityProcessor"); + + // Set EntityProcessor behaviour. + r = engine->RegisterObjectMethod("EntityProcessor", "EntityProcessor& opAssign(const EntityProcessor &in)", + asFUNCTION(assignT<EntityProcessor>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + + // Bind EntityProcessor class functions. + r = engine->RegisterObjectMethod("EntityProcessor", "Entity@ getEntity(const string &in)", + asMETHOD(EntityProcessor, getEntity), asCALL_THISCALL); assert(r >= 0); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File Added: trunk/src/scripting/assets/asEntityProcessor.h =================================================================== --- trunk/src/scripting/assets/asEntityProcessor.h (rev 0) +++ trunk/src/scripting/assets/asEntityProcessor.h 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,32 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asEntityProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the EntityProcessor class to AngelScript +// +// 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 __ASENTITYPROCESSOR_H__ +#define __ASENTITYPROCESSOR_H__ + +// Include files +#include "../../dependencies.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + + +//! Binds the EntityProcessor class to AngelScript. +extern void bindEntityProcessor(asIScriptEngine *engine); + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#endif + + Added: trunk/src/scripting/assets/asProcessors.cpp =================================================================== --- trunk/src/scripting/assets/asProcessors.cpp (rev 0) +++ trunk/src/scripting/assets/asProcessors.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,35 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asProcessors.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds all AssetProcessors to AngelScript. +// +// 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 "asProcessors.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "asEntityProcessor.h" +#include "asScriptProcessor.h" + + +//! Bind all AssetProcessors so that they can be used within scripts. +void bindAssetProcessors(asIScriptEngine *engine) +{ + bindEntityProcessor(engine); + bindScriptProcessor(engine); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File + Added: trunk/src/scripting/assets/asProcessors.h =================================================================== --- trunk/src/scripting/assets/asProcessors.h (rev 0) +++ trunk/src/scripting/assets/asProcessors.h 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,31 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asProcessors.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds all AssetProcessors to AngelScript +// +// 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 __ASPROCESSORS_H__ +#define __ASPROCESSORS_H__ + +// Include files +#include "../../dependencies.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + + +//! Bind all AssetProcessors so that they can be used within scripts. +extern void bindAssetProcessors(asIScriptEngine *engine); + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#endif + Added: trunk/src/scripting/assets/asScriptProcessor.cpp =================================================================== --- trunk/src/scripting/assets/asScriptProcessor.cpp (rev 0) +++ trunk/src/scripting/assets/asScriptProcessor.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,50 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asScriptProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the ScriptProcessor class to AngelScript +// +// 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 "asScriptProcessor.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../ScriptHelper.h" +#include "../core/asAssetProcessor.h" + +#include "../../assets/ScriptProcessor.h" + +//! Binds the ScriptProcessor class to AngelScript. +void bindScriptProcessor(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind ScriptProcessor class. + r = engine->RegisterObjectType("ScriptProcessor", sizeof(ScriptProcessor), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindAssetProcessorBase<ScriptProcessor>(engine, "ScriptProcessor"); + + // Set ScriptProcessor behaviour. + r = engine->RegisterObjectMethod("ScriptProcessor", "ScriptProcessor& opAssign(const ScriptProcessor &in)", + asFUNCTION(assignT<ScriptProcessor>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + + // Bind ScriptProcessor class functions. + r = engine->RegisterObjectMethod("ScriptProcessor", "Script@ getScript(const string &in)", + asMETHOD(ScriptProcessor, getScript), asCALL_THISCALL); assert(r >= 0); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File + Added: trunk/src/scripting/assets/asScriptProcessor.h =================================================================== --- trunk/src/scripting/assets/asScriptProcessor.h (rev 0) +++ trunk/src/scripting/assets/asScriptProcessor.h 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,33 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asScriptProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the ScriptProcessor class to AngelScript +// +// 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 __ASSCRIPTPROCESSOR_H__ +#define __ASSCRIPTPROCESSOR_H__ + +// Include files +#include "../../dependencies.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + + +//! Binds the ScriptProcessor class to AngelScript. +extern void bindScriptProcessor(asIScriptEngine *engine); + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#endif + + + Modified: trunk/src/scripting/components/asComponents.h =================================================================== --- trunk/src/scripting/components/asComponents.h 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/scripting/components/asComponents.h 2009-08-20 15:29:47 UTC (rev 115) @@ -1,6 +1,6 @@ // ///////////////////////////////////////////////////////////////////////////// // -// Name: components.h +// Name: asComponents.h // Author: Michael Bartsch (ZCCdark203) // // Desc : Binds all components to AngelScript Modified: trunk/src/scripting/components/sound/asSoundListenerComponent.cpp =================================================================== --- trunk/src/scripting/components/sound/asSoundListenerComponent.cpp 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/scripting/components/sound/asSoundListenerComponent.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -44,11 +44,6 @@ bindEntityComponentBase<SoundListenerComponent>(engine, "SoundListenerComponent"); // Set SoundListenerComponent behaviour. - r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, "SoundListenerComponent@ f()", - asFUNCTION((asRefCast<EntityComponent,SoundListenerComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f()", - asFUNCTION((asRefCast<SoundListenerComponent,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @+)", asFUNCTION(createSoundListenerComponent), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @+, bool)", Modified: trunk/src/scripting/components/sound/asSoundSourceComponent.cpp =================================================================== --- trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -44,11 +44,6 @@ bindEntityComponentBase<SoundSourceComponent>(engine, "SoundSourceComponent"); // Set SoundSourceComponent behaviour. - r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, "SoundSourceComponent@ f()", - asFUNCTION((asRefCast<EntityComponent,SoundSourceComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("SoundSourceComponent", asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f()", - asFUNCTION((asRefCast<SoundSourceComponent,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("SoundSourceComponent", asBEHAVE_FACTORY, "SoundSourceComponent@ f(Entity @+)", asFUNCTION(createSoundSourceComponent), asCALL_CDECL); assert(r >= 0); Added: trunk/src/scripting/core/asAssetGroup.cpp =================================================================== --- trunk/src/scripting/core/asAssetGroup.cpp (rev 0) +++ trunk/src/scripting/core/asAssetGroup.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,78 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asAssetGroup.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the AssetGroup class to AngelScript +// +// 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 "asAssetGroup.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../ScriptHelper.h" + +#include "../../core/AssetGroup.h" + + +//! Reference factory for the AssetGroup class. +AssetGroup* createAssetGroup(const std::string &name, const std::string &dirName) +{ + return new AssetGroup(name, dirName); +} + +//! Binds the AssetGroup class to AngelScript. +void bindAssetGroup(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind AssetGroup class (and dependencies). + r = engine->RegisterObjectType("AssetGroup", sizeof(AssetGroup), asOBJ_REF); + r = engine->RegisterObjectType("AssetProcessor", sizeof(AssetProcessor), asOBJ_REF); + + // Set AssetGroup behaviour. + r = engine->RegisterObjectBehaviour("AssetGroup", asBEHAVE_FACTORY, "AssetGroup@ f(const string &in, " \ + " const string &in)", asFUNCTION(createAssetGroup), asCALL_CDECL); + assert(r >= 0); + r = engine->RegisterObjectBehaviour("AssetGroup", asBEHAVE_ADDREF, "void f()", + asMETHOD(AssetGroup, grab), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("AssetGroup", asBEHAVE_RELEASE, "void f()", + asMETHOD(AssetGroup, drop), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetGroup", "AssetGroup& opAssign(const AssetGroup &in)", + asFUNCTION(assignT<AssetGroup>), asCALL_CDECL_OBJLAST); assert(r >= 0); + + // Bind AssetGroup class functions. + r = engine->RegisterObjectMethod("AssetGroup", "u32 getID()", + asMETHOD(AssetGroup, getID), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetGroup", "const string& getName()", + asMETHOD(AssetGroup, getName), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetGroup", "const string& getBaseDir()", + asMETHOD(AssetGroup, getBaseDir), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetGroup", "AssetProcessor@ getAssetProcessor(const string &in)", + asMETHOD(AssetGroup, getAssetProcessor), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetGroup", "bool reloadAsset(const string &in)", + asMETHOD(AssetGroup, reloadAsset), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetGroup", "void reloadAssets()", + asMETHOD(AssetGroup, reloadAssets), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetGroup", "bool removeAsset(const string &in)", + asMETHOD(AssetGroup, removeAsset), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetGroup", "void removeAssets()", + asMETHOD(AssetGroup, removeAssets), asCALL_THISCALL); assert(r >= 0); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File Added: trunk/src/scripting/core/asAssetGroup.h =================================================================== --- trunk/src/scripting/core/asAssetGroup.h (rev 0) +++ trunk/src/scripting/core/asAssetGroup.h 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,32 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asAssetGroup.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the AssetGroup class to AngelScript +// +// 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 __ASASSETGROUP_H__ +#define __ASASSETGROUP_H__ + +// Include files +#include "../../dependencies.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + + +//! Binds the AssetGroup class to AngelScript. +extern void bindAssetGroup(asIScriptEngine *engine); + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#endif + + Added: trunk/src/scripting/core/asAssetManager.cpp =================================================================== --- trunk/src/scripting/core/asAssetManager.cpp (rev 0) +++ trunk/src/scripting/core/asAssetManager.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,74 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asAssetManager.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the AssetManager class to AngelScript +// +// 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 "asAssetManager.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../../core/AssetManager.h" + + +//! Binds the AssetManager class to AngelScript. +void bindAssetManager(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind AssetManager class. + r = engine->RegisterObjectType("AssetManager", sizeof(AssetManager), asOBJ_REF); assert(r >= 0); + + // Set AssetManager behaviour. + r = engine->RegisterObjectBehaviour("AssetManager", asBEHAVE_ADDREF, "void f()", + asMETHOD(AssetManager, grab), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("AssetManager", asBEHAVE_RELEASE, "void f()", + asMETHOD(AssetManager, drop), asCALL_THISCALL); assert(r >= 0); + + // Bind AssetManager class functions. + r = engine->RegisterObjectMethod("AssetManager", "void init()", + asMETHOD(AssetManager, init), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetManager", "void clear()", + asMETHOD(AssetManager, clear), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetManager", "bool addAssetGroup(AssetGroup @+)", + asMETHOD(AssetManager, addAssetGroup), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetManager", "void createAssetGroup(const string &in, const string &in)", + asMETHOD(AssetManager, createAssetGroup), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetManager", "void createAssetGroup(const string &in, const string &in, bool)", + asMETHOD(AssetManager, createAssetGroup), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetManager", "AssetGroup@ getAssetGroup(const u32)", + asMETHODPR(AssetManager, getAssetGroup, (const u32), AssetGroup*), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetManager", "AssetGroup@ getAssetGroup(const string &in)", + asMETHODPR(AssetManager, getAssetGroup, (const std::string&), AssetGroup*), + asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetManager", "void removeAssetGroups()", + asMETHOD(AssetManager, removeAssetGroups), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetManager", "bool removeAssetGroup(AssetGroup @+)", + asMETHODPR(AssetManager, removeAssetGroup, (AssetGroup*), bool), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetManager", "bool removeAssetGroup(const u32)", + asMETHODPR(AssetManager, removeAssetGroup, (const u32), bool), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AssetManager", "bool removeAssetGroup(const string &in)", + asMETHODPR(AssetManager, removeAssetGroup, (const std::string&), bool), + asCALL_THISCALL); assert(r >= 0); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File Added: trunk/src/scripting/core/asAssetManager.h =================================================================== --- trunk/src/scripting/core/asAssetManager.h (rev 0) +++ trunk/src/scripting/core/asAssetManager.h 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,31 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asAssetManager.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the AssetManager class to AngelScript +// +// 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 __ASASSETMANAGER_H__ +#define __ASASSETMANAGER_H__ + +// Include files +#include "../../dependencies.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + + +//! Binds the AssetManager class to AngelScript. +extern void bindAssetManager(asIScriptEngine *engine); + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#endif + Added: trunk/src/scripting/core/asAssetProcessor.cpp =================================================================== --- trunk/src/scripting/core/asAssetProcessor.cpp (rev 0) +++ trunk/src/scripting/core/asAssetProcessor.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,56 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asAssetProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the AssetProcessor class to AngelScript +// +// 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 "asAssetProcessor.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../ScriptHelper.h" + +#include "../../core/AssetProcessor.h" + + +//! Reference factory for the AssetProcessor class. +AssetProcessor* createAssetProcessor(AssetGroup *parent, const std::string &baseName) +{ + return new AssetProcessor(parent, baseName); +} + +//! Binds the AssetProcessor class to AngelScript. +void bindAssetProcessor(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind AssetProcessor class (and dependencies). + r = engine->RegisterObjectType("AssetProcessor", sizeof(AssetProcessor), asOBJ_REF); + r = engine->RegisterObjectType("AssetGroup", sizeof(AssetGroup), asOBJ_REF); + + // Get AssetProcessor base functions. + bindAssetProcessorBase<AssetProcessor>(engine, "AssetProcessor"); + + // Set AssetProcessor behaviour. + r = engine->RegisterObjectBehaviour("AssetProcessor", asBEHAVE_FACTORY, "AssetProcessor@ f(AssetGroup @+, " \ + "const string &in)", asFUNCTION(createAssetProcessor), asCALL_CDECL); + assert(r >= 0); + + r = engine->RegisterObjectMethod("AssetProcessor", "AssetProcessor& opAssign(const AssetProcessor &in)", + asFUNCTION(assignT<AssetProcessor>), asCALL_CDECL_OBJFIRST); assert(r >= 0); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File Added: trunk/src/scripting/core/asAssetProcessor.h =================================================================== --- trunk/src/scripting/core/asAssetProcessor.h (rev 0) +++ trunk/src/scripting/core/asAssetProcessor.h 2009-08-20 15:29:47 UTC (rev 115) @@ -0,0 +1,70 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asAssetProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the AssetProcessor class to AngelScript +// +// 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 __ASASSETPROCESSOR_H__ +#define __ASASSETPROCESSOR_H__ + +// Include files +#include "../../dependencies.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../../core/AssetProcessor.h" +#include "../ScriptHelper.h" + + +//! Binds the AssetProcessor class to AngelScript. +extern void bindAssetProcessor(asIScriptEngine *engine); + +//! Binds the base behaviours and methods of the AssetProcessor to the given class in +//! AngelScript. +template<typename T> +void bindAssetProcessorBase(asIScriptEngine *engine, const char *type) +{ + // Forward declaration. + int r; + std::string sType = type; + + // Set common behaviour. + r = engine->RegisterObjectBehaviour(type, asBEHAVE_ADDREF, "void f()", + asMETHOD(T, grab), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour(type, asBEHAVE_RELEASE, "void f()", + asMETHOD(T, drop), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectBehaviour("AssetProcessor", asBEHAVE_REF_CAST, std::string(sType + "@ f()").c_str(), + asFUNCTION((asRefCast<AssetProcessor,T>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour(type, asBEHAVE_IMPLICIT_REF_CAST, std::string("AssetProcessor@ f()").c_str(), + asFUNCTION((asRefCast<T,AssetProcessor>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + + // Bind common class functions. + r = engine->RegisterObjectMethod(type, "const string& getBaseName()", + asMETHOD(T, getBaseName), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "AssetGroup@ getParent()", + asMETHOD(T, getParent), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "bool reloadAsset(const string &in)", + asMETHOD(T, reloadAsset), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void reloadAssets()", + asMETHOD(T, reloadAssets), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "bool removeAsset(const string &in)", + asMETHOD(T, removeAsset), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void removeAssets()", + asMETHOD(T, removeAssets), asCALL_THISCALL); assert(r >= 0); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#endif Modified: trunk/src/scripting/core/asEntityManager.cpp =================================================================== --- trunk/src/scripting/core/asEntityManager.cpp 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/scripting/core/asEntityManager.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -49,12 +49,12 @@ asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+)", asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); - /*r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+, " \ + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+, " \ "AssetGroup @+)", asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+, " \ "AssetGroup @+, bool)", asMETHOD(EntityManager, createEntity), - asCALL_THISCALL); assert(r >= 0);*/ + asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in)", asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*, @@ -62,14 +62,14 @@ r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+)", asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*, AssetGroup*, bool), Entity*), asCALL_THISCALL); assert(r >= 0); - /*r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+, " \ + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+, " \ "AssetGroup @+)", asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*, AssetGroup*, bool), Entity*), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+, " \ "AssetGroup @+, bool)", asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*, AssetGroup*, bool), Entity*), asCALL_THISCALL); - assert(r >= 0);*/ + assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const u32)", asMETHODPR(EntityManager, getEntity, (const u32), Entity*), Modified: trunk/src/scripting/core/asGameManager.cpp =================================================================== --- trunk/src/scripting/core/asGameManager.cpp 2009-08-20 13:36:24 UTC (rev 114) +++ trunk/src/scripting/core/asGameManager.cpp 2009-08-20 15:29:47 UTC (rev 115) @@ -63,6 +63,8 @@ r = engine->RegisterObjectMethod("GameManager", "void popState()", asMETHOD(GameManager, popState), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("GameManager", "AssetManager@ getAssetManager()", + asMETHOD(GameManager, getAssetManager), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "DataStore@ getDataStore()", asMETHOD(GameManager, getDataStore), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "EntityManager@ getEntityManager()", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-20 13:36:31
|
Revision: 114 http://sirrf.svn.sourceforge.net/sirrf/?rev=114&view=rev Author: zccdark203 Date: 2009-08-20 13:36:24 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Added 'grab' parameter to AssetManager::createAssetGroup, DataStore::createDataStack, EntityManager::createEntity, ScriptManager and ScriptManager::createScriptFromFile. This boolean parameter can be used to specify whether the created object should be stored in the respective manager or not. Modified Paths: -------------- trunk/CHANGES trunk/src/assets/ScriptProcessor.cpp trunk/src/core/AssetManager.cpp trunk/src/core/AssetManager.h trunk/src/core/DataStore.cpp trunk/src/core/DataStore.h trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/ScriptManager.h trunk/src/scripting/core/asDataStore.cpp trunk/src/scripting/core/asEntity.cpp trunk/src/scripting/core/asEntityManager.cpp trunk/src/scripting/scripting/asScriptManager.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/CHANGES 2009-08-20 13:36:24 UTC (rev 114) @@ -2,6 +2,12 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Added "grab" parameter to AssetManager::createAssetGroup, + DataStore::createDataStack, EntityManager::createEntity, + ScriptManager::createScript and ScriptManager::createScriptFromFile. + This boolean parameter can be used to specify whether the created + object should be stored in the respective manager or not. + * Added a new createScriptFromFile to the ScriptManager class. With the new method one can load script files from a IReadFile. Modified: trunk/src/assets/ScriptProcessor.cpp =================================================================== --- trunk/src/assets/ScriptProcessor.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/assets/ScriptProcessor.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -64,7 +64,7 @@ // Create the script. Script *script = GameManager::Instance()->getScriptManager() - ->createScriptFromFile(file); + ->createScriptFromFile(file, false); mScripts[fileName] = script; script->grab(); Modified: trunk/src/core/AssetManager.cpp =================================================================== --- trunk/src/core/AssetManager.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/core/AssetManager.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -72,17 +72,21 @@ } // Creates (and adds) a AssetGroup with the given name. -AssetGroup* AssetManager::createAssetGroup(const std::string &name, const std::string &dirName) +AssetGroup* AssetManager::createAssetGroup(const std::string &name, const std::string &dirName, bool grab) { // Does a Data group with the same name exist? - if(getAssetGroup(name)) + if(grab && 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(); + if(grab) + { + mGroups.push_back(group); + group->grab(); + } + return group; } Modified: trunk/src/core/AssetManager.h =================================================================== --- trunk/src/core/AssetManager.h 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/core/AssetManager.h 2009-08-20 13:36:24 UTC (rev 114) @@ -63,8 +63,11 @@ //! 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. + //! @param grab Should the AssetsManager add the loaded asset group to the + //! internal list? //! @return Pointer to the AssetGroup on success, NULL on failure. - AssetGroup* createAssetGroup(const std::string &name, const std::string &dirName); + AssetGroup* createAssetGroup(const std::string &name, const std::string &dirName, + bool grab = true); //! Gets the AssetGroup with the given ID. //! @return Pointer to the AssetGroup if found, else NULL. Modified: trunk/src/core/DataStore.cpp =================================================================== --- trunk/src/core/DataStore.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/core/DataStore.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -73,17 +73,21 @@ } // Creates (and adds) a DataStack with the given name. -DataStack* DataStore::createDataStack(const std::string &name) +DataStack* DataStore::createDataStack(const std::string &name, bool grab) { // Does a Data Stack with the same name exist? - if(getDataStack(name)) + if(grab && getDataStack(name)) return NULL; // Create the DataStack and add it to the vector. DataStack *stack = new DataStack(name); - mStacks.push_back(stack); - stack->grab(); + if(grab) + { + mStacks.push_back(stack); + stack->grab(); + } + return stack; } Modified: trunk/src/core/DataStore.h =================================================================== --- trunk/src/core/DataStore.h 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/core/DataStore.h 2009-08-20 13:36:24 UTC (rev 114) @@ -56,8 +56,9 @@ bool addDataStack(DataStack *stack); //! Creates (and adds) a DataStack with the given name. //! @param name Name of the DataStack. + //! @param grab Should the DataStore add the loaded DataStack to the internal list? //! @return Pointer to the DataStack on success, NULL on failure. - DataStack* createDataStack(const std::string &name); + DataStack* createDataStack(const std::string &name, bool grab = true); //! Gets the DataStack with the given ID. //! @return Pointer to the DataStack if found, else NULL. Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/core/EntityManager.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -77,17 +77,21 @@ } // Creates (and adds) an entity with the given name and adds it to the Entity Manager. -Entity* EntityManager::createEntity(const std::string &name, Entity *parent) +Entity* EntityManager::createEntity(const std::string &name, Entity *parent, bool grab) { // Look if a entity with given name doesn't already exist. - if(getEntity(name)) + if(grab && getEntity(name)) return NULL; // Add the entity. Entity *entity = new Entity(name, parent); - mEntities.push_back(entity); - entity->grab(); + if(grab) + { + mEntities.push_back(entity); + entity->grab(); + } + return entity; } Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/core/EntityManager.h 2009-08-20 13:36:24 UTC (rev 114) @@ -59,8 +59,9 @@ //! Creates (and adds) an Entity with the given name. //! @param name Name of the Entity. //! @param parent Parent of the entity that is going to be created. + //! @param grab Should the EntityManager add the loaded entity to the internal list? //! @return Pointer to the Entity on success, NULL on failure. - Entity* createEntity(const std::string &name, Entity *parent = NULL); + Entity* createEntity(const std::string &name, Entity *parent = NULL, bool grab = true); //! Creates an Entity from the given XML file. //! @param fileName Filename of the entity. //! @param parent Parent of the entity that is going to be created. Will override Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/scripting/ScriptManager.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -171,22 +171,26 @@ } // Creates (and adds) an script with the given name. -Script* ScriptManager::createScript(const std::string &name) +Script* ScriptManager::createScript(const std::string &name, bool grab) { // Look if a script with given name doesn't already exist. - if(getScript(name)) + if(grab && getScript(name)) return NULL; // Add the script. Script *script = new Script(name); - mScripts.push_back(script); - script->grab(); + if(grab) + { + mScripts.push_back(script); + script->grab(); + } + return script; } // Creates an script with the given name, loaded from the given file. -Script* ScriptManager::createScriptFromFile(const std::string &fileName) +Script* ScriptManager::createScriptFromFile(const std::string &fileName, bool grab) { // Get pointer to the File System of Irrlicht. IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); @@ -196,31 +200,40 @@ std::string fileBase = (fileSystem->getFileBasename(wFilename)).c_str(); // Look if a script with given name doesn't already exist. - if(getScript(fileBase)) + if(grab && getScript(fileBase)) return NULL; // Add the script. Script *script = new Script(fileBase); script->loadScript(fileName); - mScripts.push_back(script); - script->grab(); + + if(grab) + { + mScripts.push_back(script); + script->grab(); + } + return script; } // Creates an script with the given name, loaded from the given file. -Script* ScriptManager::createScriptFromFile(IReadFile *file) +Script* ScriptManager::createScriptFromFile(IReadFile *file, bool grab) { // Look if a script with given name doesn't already exist. - if(getScript( (file->getFileName()).c_str() )) + if(grab && getScript( (file->getFileName()).c_str() )) return NULL; // Add the script. Script *script = new Script( (file->getFileName()).c_str() ); script->loadScript(file); - mScripts.push_back(script); - script->grab(); + if(grab) + { + mScripts.push_back(script); + script->grab(); + } + return script; } Modified: trunk/src/scripting/ScriptManager.h =================================================================== --- trunk/src/scripting/ScriptManager.h 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/scripting/ScriptManager.h 2009-08-20 13:36:24 UTC (rev 114) @@ -74,16 +74,19 @@ //! Creates (and adds) an script with the given name. //! @param name Name of the script. + //! @param grab Should the ScriptManager add the loaded script to the internal list? //! @return Pointer to the Script on success, NULL on failure. - Script* createScript(const std::string &name); + Script* createScript(const std::string &name, bool grab = true); //! Creates an script with the given name, loaded from the given file. //! @param fileName Filename of the file to load. + //! @param grab Should the ScriptManager add the loaded script to the internal list? //! @return Pointer to the Script on success, NULL on failure. - Script* createScriptFromFile(const std::string &fileName); + Script* createScriptFromFile(const std::string &fileName, bool grab = true); //! Creates an script with the given name, loaded from the given file. //! @param file Pointer to the IReadFile that will be used. + //! @param grab Should the ScriptManager add the loaded script to the internal list? //! @return Pointer to the Script on success, NULL on failure. - Script* createScriptFromFile(IReadFile *file); + Script* createScriptFromFile(IReadFile *file, bool grab = true); //! Gets the Script with the given ID. //! @return Pointer to the Script if found, else NULL. Modified: trunk/src/scripting/core/asDataStore.cpp =================================================================== --- trunk/src/scripting/core/asDataStore.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/scripting/core/asDataStore.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -48,6 +48,8 @@ asMETHOD(DataStore, addDataStack), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("DataStore", "DataStack@ createDataStack(const string &in)", asMETHOD(DataStore, createDataStack), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("DataStore", "DataStack@ createDataStack(const string &in, bool)", + asMETHOD(DataStore, createDataStack), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("DataStore", "DataStack@ getDataStack(const u32)", asMETHODPR(DataStore, getDataStack, (const u32), DataStack*), Modified: trunk/src/scripting/core/asEntity.cpp =================================================================== --- trunk/src/scripting/core/asEntity.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/scripting/core/asEntity.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -77,6 +77,10 @@ r = engine->RegisterObjectMethod("Entity", "Entity@ getParent()", asMETHOD(Entity, getParent), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "bool loadXML(const string &in)", + asMETHODPR(Entity, loadXML, (const std::string&), bool), 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()", Modified: trunk/src/scripting/core/asEntityManager.cpp =================================================================== --- trunk/src/scripting/core/asEntityManager.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/scripting/core/asEntityManager.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -44,11 +44,33 @@ r = engine->RegisterObjectMethod("EntityManager", "bool addEntity(Entity @+)", asMETHOD(EntityManager, addEntity), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in)", asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+)", asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); + /*r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+, " \ + "AssetGroup @+)", asMETHOD(EntityManager, createEntity), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &in, Entity @+, " \ + "AssetGroup @+, bool)", asMETHOD(EntityManager, createEntity), + asCALL_THISCALL); assert(r >= 0);*/ + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in)", + asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*, + AssetGroup*, bool), Entity*), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+)", + asMETHODPR(EntityManager, createEntityFromXML, (const std::string&, Entity*, + AssetGroup*, bool), Entity*), asCALL_THISCALL); assert(r >= 0); + /*r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+, " \ + "AssetGroup @+)", asMETHODPR(EntityManager, createEntityFromXML, + (const std::string&, Entity*, AssetGroup*, bool), Entity*), asCALL_THISCALL); + assert(r >= 0); + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntityFromXML(const string &in, Entity @+, " \ + "AssetGroup @+, bool)", asMETHODPR(EntityManager, createEntityFromXML, + (const std::string&, Entity*, AssetGroup*, bool), Entity*), asCALL_THISCALL); + assert(r >= 0);*/ + r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const u32)", asMETHODPR(EntityManager, getEntity, (const u32), Entity*), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/scripting/asScriptManager.cpp =================================================================== --- trunk/src/scripting/scripting/asScriptManager.cpp 2009-08-20 12:52:10 UTC (rev 113) +++ trunk/src/scripting/scripting/asScriptManager.cpp 2009-08-20 13:36:24 UTC (rev 114) @@ -47,11 +47,18 @@ 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); + r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScript(const string &in, bool)", + asMETHOD(ScriptManager, createScript), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScriptFromFile(const string &in)", - asMETHODPR(ScriptManager, createScriptFromFile, (const std::string&), Script*), + asMETHODPR(ScriptManager, createScriptFromFile, (const std::string&, bool), Script*), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScriptFromFile(const string &in, bool)", + asMETHODPR(ScriptManager, createScriptFromFile, (const std::string&, bool), Script*), + asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("ScriptManager", "Script@ getScript(const u32)", asMETHODPR(ScriptManager, getScript, (const u32), Script*), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-20 12:52:19
|
Revision: 113 http://sirrf.svn.sourceforge.net/sirrf/?rev=113&view=rev Author: zccdark203 Date: 2009-08-20 12:52:10 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Changed how the ScriptProcessor processes scripts; it now works similar to the EntityProcessor. Additionaly I've added extra documentation to the HeightMapProcessor, MeshProcessor, SoundProcessor and TextureProcessor classes. Also I've added some new methods for loading scripts from a IReadFile. Modified Paths: -------------- trunk/CHANGES trunk/src/assets/EntityProcessor.cpp trunk/src/assets/HeightmapProcessor.h trunk/src/assets/MeshProcessor.h trunk/src/assets/ScriptProcessor.cpp trunk/src/assets/ScriptProcessor.h trunk/src/assets/SoundProcessor.h trunk/src/assets/TextureProcessor.h trunk/src/game/InitState.cpp trunk/src/scripting/Script.cpp trunk/src/scripting/Script.h trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/ScriptManager.h trunk/src/scripting/scripting/asScript.cpp trunk/src/scripting/scripting/asScriptManager.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/CHANGES 2009-08-20 12:52:10 UTC (rev 113) @@ -2,6 +2,12 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Added a new createScriptFromFile to the ScriptManager class. With the + new method one can load script files from a IReadFile. + + * Added a new loadScript method to the Script class. With the new + method one can load script files from a IReadFile. + * Created the AssetGroup class which represents a collection of assets (meshes, textures, etc). The AssetManager class is responsible for managing these groups. Behaviour for specific assets is defined by a Modified: trunk/src/assets/EntityProcessor.cpp =================================================================== --- trunk/src/assets/EntityProcessor.cpp 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/assets/EntityProcessor.cpp 2009-08-20 12:52:10 UTC (rev 113) @@ -75,7 +75,7 @@ return entity; } - // We didn't find anythin. + // We didn't find anything. return NULL; } @@ -117,6 +117,7 @@ if(it != mEntities.end()) { + file->seek(0); IXMLReader *xml = fileSystem->createXMLReader(file); Entity *entity = it->second; @@ -190,6 +191,7 @@ if(it != mEntities.end()) { + file->seek(0); IXMLReader *xml = fileSystem->createXMLReader(file); Entity *entity = it->second; Modified: trunk/src/assets/HeightmapProcessor.h =================================================================== --- trunk/src/assets/HeightmapProcessor.h 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/assets/HeightmapProcessor.h 2009-08-20 12:52:10 UTC (rev 113) @@ -23,6 +23,10 @@ // HeightmapProcessor class //! AssetProcessor for processing heightmaps in an AssetGroup. +//! In order to properly reload a heightmap from an asset group the class that uses the heightmap +//! needs to implement a event method for the "heightmaps/<filename>" event. When the heightmaps +//! is reloaded a event will be emitted to the appropriate slot with the new heightmap as the +//! parameter. See TerrainComponent::onHeightMap. class HeightmapProcessor : public AssetProcessor { public: Modified: trunk/src/assets/MeshProcessor.h =================================================================== --- trunk/src/assets/MeshProcessor.h 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/assets/MeshProcessor.h 2009-08-20 12:52:10 UTC (rev 113) @@ -23,6 +23,10 @@ // MeshProcessor class //! AssetProcessor for processing meshes in an AssetGroup. +//! In order to properly reload a mesh from an asset group the class that uses the mesh +//! needs to implement a event method for the "meshes/<filename>" event. When the mesh +//! is reloaded a event will be emitted to the appropriate slot with the new mesh as the +//! parameter. See MeshComponent::onMesh or AnimatedMeshComponent::onMesh for an example. class MeshProcessor : public AssetProcessor { public: Modified: trunk/src/assets/ScriptProcessor.cpp =================================================================== --- trunk/src/assets/ScriptProcessor.cpp 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/assets/ScriptProcessor.cpp 2009-08-20 12:52:10 UTC (rev 113) @@ -37,11 +37,46 @@ // Gets the script with the given filename. Script* ScriptProcessor::getScript(const std::string &fileName) { - std::map<std::string, Script*>::iterator it = mScripts.find(fileName); + // Did we already instanciate the script? + std::map<std::string, Script*>::iterator itScripts = mScripts.find(fileName); - if(it != mScripts.end()) - return it->second; + if(itScripts != mScripts.end()) + { + Script *script = itScripts->second; + script->grab(); + return script; + } + + // Do we have the file in memory so that we can instanciate the script from there? + std::map<std::string, std::pair<c8*, long> >::iterator itFiles = mScriptFiles.find(fileName); + + if(itFiles != mScriptFiles.end()) + { + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Create a memory read file. + long fSize = (itFiles->second).second; + c8 *fBuffer = (itFiles->second).first; + + IReadFile *file = fileSystem->createMemoryReadFile(fBuffer, fSize, fileName.c_str()); + + // Create the script. + Script *script = GameManager::Instance()->getScriptManager() + ->createScriptFromFile(file); + + mScripts[fileName] = script; + script->grab(); + + // Clean up. + file->drop(); + + // Return the script. + return script; + } + + // We didn't find anything. return NULL; } @@ -60,33 +95,45 @@ if(!fileSystem->changeWorkingDirectoryTo("./scripts/")) return false; - // Read the script. - Script *script = new Script(fileName); + // Load the script. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); - if(script->loadScript(fileName)) + if(file) { - // Store scripts. - mScripts[fileName] = script; + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + + // Store data. + mScriptFiles[fileName] = std::pair<c8*, long>(fBuffer, fSize); cout << "Loaded script: " << fileName << "\n"; - // Handle events. + // Handle reload. if(mIsReloading) - pParent->emitEvent(std::string("scripts/") + fileName, script); + { + std::map<std::string, Script*>::iterator it = mScripts.find(fileName); - else - pParent->createEventSlot(std::string("scripts/") + fileName); - } + if(it != mScripts.end()) + { + file->seek(0); - else - { - delete script; - script = NULL; + Script *script = it->second; + script->unloadScript(); + script->loadScript(file); + } + } + + // Clean up. + file->drop(); } // Clean up. fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); - return (script != NULL) ? true : false; + return (file) ? true : false; } // Loads the meshes associated with this asset group. @@ -104,7 +151,7 @@ if(!fileSystem->changeWorkingDirectoryTo("./scripts/")) return; - // Read the textures. + // Read the scripts. IFileList *fileList = fileSystem->createFileList(); for(u32 i = 0; i < fileList->getFileCount(); i++) @@ -116,23 +163,39 @@ continue; // Load the script. - Script *script = new Script(fileName); + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); - if(script->loadScript(fileName)) + if(file) { - // Store script. - mScripts[fileName] = script; + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + + // Store data. + mScriptFiles[fileName] = std::pair<c8*, long>(fBuffer, fSize); cout << "Loaded script: " << fileName << "\n"; - // Handle events. + // Handle reload. if(mIsReloading) - pParent->emitEvent(std::string("scripts/") + fileName, script); + { + std::map<std::string, Script*>::iterator it = mScripts.find(fileName); - else - pParent->createEventSlot(std::string("scripts/") + fileName); + if(it != mScripts.end()) + { + file->seek(0); + + Script *script = it->second; + script->unloadScript(); + script->loadScript(file); + } + } + + // Clean up. + file->drop(); } - - else delete script; } // Clean up. @@ -157,68 +220,105 @@ // Reloads all assets. void ScriptProcessor::reloadAssets() { + // We do a regular reload. mIsReloading = true; removeAssets(); loadAssets(); mIsReloading = false; + + // We need to resync our scripts map. + // Create a new map with all existing scripts. + std::map<std::string, Script*> newMap; + + std::map<std::string, std::pair<c8*, long> >::iterator itFiles; + for(itFiles = mScriptFiles.begin(); itFiles != mScriptFiles.end(); itFiles++) + { + std::map<std::string, Script*>::iterator itScripts = mScripts.find(itFiles->first); + + if(itScripts != mScripts.end()) + { + newMap[itScripts->first] = itScripts->second; + mScripts.erase(itScripts); + } + } + + // Remove redundant scripts. + std::map<std::string, Script*>::iterator itScripts; + for(itScripts = mScripts.begin(); itScripts != mScripts.end(); itScripts++) + (itScripts->second)->drop(); + + mScripts.clear(); + + // Set new map. + mScripts = newMap; } // Removes the asset with the given filename. bool ScriptProcessor::removeAsset(const std::string &fileName) { - // Try to find the given script. - std::map<std::string, Script*>::iterator it = mScripts.find(fileName); + // Predeclaration of succeeded variable. + bool succeeded = false; - // Did we find the script? - if(it != mScripts.end()) + // Try to find the given script file. + std::map<std::string, std::pair<c8*, long> >::iterator it = mScriptFiles.find(fileName); + + // Did we find the script file? + if(it != mScriptFiles.end()) { - // Handle events. - if(!mIsReloading) - { - std::string slotName = std::string("scripts/") + it->first; + // Delete the script file. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + mScriptFiles.erase(it); - pParent->emitEvent(slotName, NULL); - pParent->removeEventSlot(slotName); - } + succeeded = true; + } - // Delete the script. - Script *script = it->second; - script->drop(); - mScripts.erase(it); + // Try to find the given script, but only if we're not reloading. + if(succeeded && !mIsReloading) + { + std::map<std::string, Script*>::iterator it = mScripts.find(fileName); - return true; + // Did we find the script? + if(it != mScripts.end()) + { + (it->second)->drop(); + mScripts.erase(it); + } } - // We didn't find the script. - else return false; + // Return whether we succeeded or not. + return succeeded; } // Removes all asssets. void ScriptProcessor::removeAssets() { - // Delete the scripts. - std::map<std::string, Script*>::iterator it; + // Delete the script files. + std::map<std::string, std::pair<c8*, long> >::iterator itFiles; - for(it = mScripts.begin(); it != mScripts.end(); it++) + for(itFiles = mScriptFiles.begin(); itFiles != mScriptFiles.end(); itFiles++) { - // Handle events. - if(!mIsReloading) - { - std::string slotName = std::string("scripts/") + it->first; + // Delete the script file. + c8 *fBuffer = (itFiles->second).first; + delete [] fBuffer; + } - pParent->emitEvent(slotName, NULL); - pParent->removeEventSlot(slotName); - } + // Clear the script files map. + mScriptFiles.clear(); - // Delete the script. - Script *script = it->second; - script->drop(); + // Remove the scripts, but only if we're not reloading. + if(!mIsReloading) + { + std::map<std::string, Script*>::iterator itScripts; + + for(itScripts = mScripts.begin(); itScripts != mScripts.end(); itScripts++) + (itScripts->second)->drop(); + + // Clear the scripts map. + mScripts.clear(); } - - // Clear the scripts map. - mScripts.clear(); } // Creates a new ScriptProcessor. Modified: trunk/src/assets/ScriptProcessor.h =================================================================== --- trunk/src/assets/ScriptProcessor.h 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/assets/ScriptProcessor.h 2009-08-20 12:52:10 UTC (rev 113) @@ -74,6 +74,7 @@ private: // Private members + std::map<std::string, std::pair<c8*, long> > mScriptFiles; std::map<std::string, Script*> mScripts; bool mIsReloading; Modified: trunk/src/assets/SoundProcessor.h =================================================================== --- trunk/src/assets/SoundProcessor.h 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/assets/SoundProcessor.h 2009-08-20 12:52:10 UTC (rev 113) @@ -26,6 +26,10 @@ // SoundProcessor class //! AssetProcessor for processing sounds in an AssetGroup. +//! In order to properly reload a sound from an asset group the class that uses the sound +//! needs to implement a event method for the "sounds/<filename>" event. When the sound +//! is reloaded a event will be emitted to the appropriate slot with the new sound as the +//! parameter. See SoundSourceComponent::onSound for an example. class SoundProcessor : public AssetProcessor { public: Modified: trunk/src/assets/TextureProcessor.h =================================================================== --- trunk/src/assets/TextureProcessor.h 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/assets/TextureProcessor.h 2009-08-20 12:52:10 UTC (rev 113) @@ -23,6 +23,10 @@ // TextureProcessor class //! AssetProcessor for processing textures in an AssetGroup. +//! In order to properly reload a texture from an asset group the class that uses the texture +//! needs to implement a event method for the "textures/<filename>" event. When the texture +//! is reloaded a event will be emitted to the appropriate slot with the new texture as the +//! parameter. See SceneComponent::onTexture or ImageComponent::onTexture for an example. class TextureProcessor : public AssetProcessor { public: Modified: trunk/src/game/InitState.cpp =================================================================== --- trunk/src/game/InitState.cpp 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/game/InitState.cpp 2009-08-20 12:52:10 UTC (rev 113) @@ -21,7 +21,6 @@ #include "InitState.h" #include "../core/GameManager.h" -#include "../assets/MeshProcessor.h" // InitState class // InitState constructor. Modified: trunk/src/scripting/Script.cpp =================================================================== --- trunk/src/scripting/Script.cpp 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/scripting/Script.cpp 2009-08-20 12:52:10 UTC (rev 113) @@ -123,6 +123,48 @@ return true; } +// Loads a script file and builds it. +bool Script::loadScript(IReadFile *file) +{ + // Get pointers to sub-systems of the Game Manager. + ScriptManager *scriptMgr = GameManager::Instance()->getScriptManager(); + + // Reset previous data. + if(mModule != NULL) + { + scriptMgr->getEngine()->DiscardModule(mName.c_str()); + mModule = NULL; + } + + // Is the pointer valid? + if(!file) + return false; + + // Create the module. + mModule = scriptMgr->getEngine()->GetModule(mName.c_str(), asGM_ALWAYS_CREATE); + + // Read from given file and load the contents to the buffer. + long fSize = file->getSize(); + c8 * fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + + // Add a script section to the earlier created module. + mModule->AddScriptSection("main", fBuffer); + scriptMgr->addScriptSectionsToScript(this); + + // Build the script. + int r = mModule->Build(); + if(r < 0) + return false; + + // Clean up. + delete[] fBuffer; + + return true; +} + // Unloads the loaded script. bool Script::unloadScript() { Modified: trunk/src/scripting/Script.h =================================================================== --- trunk/src/scripting/Script.h 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/scripting/Script.h 2009-08-20 12:52:10 UTC (rev 113) @@ -68,6 +68,10 @@ //! @param fileName Filename of the file from where the script should be retrieved. //! @return True on successful loading, else false on failure. bool loadScript(const std::string &fileName); + //! Loads a script file and builds it. + //! @param file Pointer to the IReadFile that will be used. + //! @return True on successful loading, else false on failure. + bool loadScript(IReadFile *file); //! Unloads the loaded script. //! @return True on success, false on failure. bool unloadScript(); Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/scripting/ScriptManager.cpp 2009-08-20 12:52:10 UTC (rev 113) @@ -208,6 +208,22 @@ return script; } +// Creates an script with the given name, loaded from the given file. +Script* ScriptManager::createScriptFromFile(IReadFile *file) +{ + // Look if a script with given name doesn't already exist. + if(getScript( (file->getFileName()).c_str() )) + return NULL; + + // Add the script. + Script *script = new Script( (file->getFileName()).c_str() ); + script->loadScript(file); + mScripts.push_back(script); + script->grab(); + + return script; +} + // Gets the script with the given ID. Script* ScriptManager::getScript(const u32 id) { Modified: trunk/src/scripting/ScriptManager.h =================================================================== --- trunk/src/scripting/ScriptManager.h 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/scripting/ScriptManager.h 2009-08-20 12:52:10 UTC (rev 113) @@ -80,6 +80,10 @@ //! @param fileName Filename of the file to load. //! @return Pointer to the Script on success, NULL on failure. Script* createScriptFromFile(const std::string &fileName); + //! Creates an script with the given name, loaded from the given file. + //! @param file Pointer to the IReadFile that will be used. + //! @return Pointer to the Script on success, NULL on failure. + Script* createScriptFromFile(IReadFile *file); //! Gets the Script with the given ID. //! @return Pointer to the Script if found, else NULL. Modified: trunk/src/scripting/scripting/asScript.cpp =================================================================== --- trunk/src/scripting/scripting/asScript.cpp 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/scripting/scripting/asScript.cpp 2009-08-20 12:52:10 UTC (rev 113) @@ -53,12 +53,13 @@ asMETHOD(Script, getName), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Script", "bool loadScript(const string &in)", - asMETHOD(Script, loadScript), asCALL_THISCALL);assert(r >= 0); + asMETHODPR(Script, loadScript, (const std::string&), bool), + asCALL_THISCALL);assert(r >= 0); r = engine->RegisterObjectMethod("Script", "bool unloadScript()", asMETHOD(Script, unloadScript), asCALL_THISCALL);assert(r >= 0); r = engine->RegisterObjectMethod("Script", "bool executeFunctionByName(const string &in, const string &in)", - asMETHOD(Script, loadScript), asCALL_THISCALL);assert(r >= 0); + asMETHOD(Script, executeFunctionByName), asCALL_THISCALL);assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/scripting/asScriptManager.cpp =================================================================== --- trunk/src/scripting/scripting/asScriptManager.cpp 2009-08-19 21:22:19 UTC (rev 112) +++ trunk/src/scripting/scripting/asScriptManager.cpp 2009-08-20 12:52:10 UTC (rev 113) @@ -50,7 +50,8 @@ r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScript(const string &in)", asMETHOD(ScriptManager, createScript), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("ScriptManager", "Script@ createScriptFromFile(const string &in)", - asMETHOD(ScriptManager, createScriptFromFile), asCALL_THISCALL); assert(r >= 0); + asMETHODPR(ScriptManager, createScriptFromFile, (const std::string&), Script*), + asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("ScriptManager", "Script@ getScript(const u32)", asMETHODPR(ScriptManager, getScript, (const u32), Script*), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-19 21:22:28
|
Revision: 112 http://sirrf.svn.sourceforge.net/sirrf/?rev=112&view=rev Author: zccdark203 Date: 2009-08-19 21:22:19 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Finished both asset management and the ability to load entities from XML. Modified Paths: -------------- trunk/CHANGES trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/assets/HeightmapProcessor.h trunk/src/assets/MeshProcessor.cpp trunk/src/assets/MeshProcessor.h trunk/src/assets/ScriptProcessor.h trunk/src/assets/SoundProcessor.h trunk/src/assets/TextureProcessor.h trunk/src/assets/processors.cpp trunk/src/assets/processors.h trunk/src/components/scene/SkyBoxComponent.cpp trunk/src/core/Entity.cpp trunk/src/core/EntityManager.cpp Added Paths: ----------- trunk/src/assets/EntityProcessor.cpp trunk/src/assets/EntityProcessor.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/CHANGES 2009-08-19 21:22:19 UTC (rev 112) @@ -2,6 +2,16 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Created the AssetGroup class which represents a collection of assets + (meshes, textures, etc). The AssetManager class is responsible for + managing these groups. Behaviour for specific assets is defined by a + class derived from AssetProcessor class. + + * Entities and their components can now be loaded from a XML-file + through: + - EntityManager::createEntityFromXML + - Entity::loadXML + * Updated to AngelScript 2.17.0. * Mouse, Key, GUI events emitted by the EventManager now pass the @@ -60,10 +70,6 @@ * Added loadSoundBufferFromMemory to the SoundManager class. With this method you can pass a self-loaded buffer to the SoundManager. - * 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/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/build/CMake/CMakeLists.txt 2009-08-19 21:22:19 UTC (rev 112) @@ -13,6 +13,7 @@ ${SOURCE_DIR}main.cpp # src/assets + ${SOURCE_DIR}assets/EntityProcessor.cpp ${SOURCE_DIR}assets/HeightmapProcessor.cpp ${SOURCE_DIR}assets/MeshProcessor.cpp ${SOURCE_DIR}assets/TextureProcessor.cpp Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-08-19 21:22:19 UTC (rev 112) @@ -58,6 +58,8 @@ <Add option="-Wall" /> <Add directory="../../src/vendor" /> </Compiler> + <Unit filename="../../src/assets/EntityProcessor.cpp" /> + <Unit filename="../../src/assets/EntityProcessor.h" /> <Unit filename="../../src/assets/HeightmapProcessor.cpp" /> <Unit filename="../../src/assets/HeightmapProcessor.h" /> <Unit filename="../../src/assets/MeshProcessor.cpp" /> Added: trunk/src/assets/EntityProcessor.cpp =================================================================== --- trunk/src/assets/EntityProcessor.cpp (rev 0) +++ trunk/src/assets/EntityProcessor.cpp 2009-08-19 21:22:19 UTC (rev 112) @@ -0,0 +1,345 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: EntityProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : AssetProcessor for processing entities in an AssetGroup. +// +// 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 "EntityProcessor.h" +#include "../core/GameManager.h" + + +// EntityProcessor class +// EntityProcessor constructor. +EntityProcessor::EntityProcessor(AssetGroup *parent) +: AssetProcessor(parent, "entities"), mIsReloading(false) +{ +} + +// EntityProcessor deconstructor. +EntityProcessor::~EntityProcessor() +{ + removeAssets(); +} + +// Gets the entity with the given filename. +Entity* EntityProcessor::getEntity(const std::string &fileName) +{ + // Did we already instanciate the entity? + std::map<std::string, Entity*>::iterator itEntities = mEntities.find(fileName); + + if(itEntities != mEntities.end()) + { + Entity *entity = itEntities->second; + + entity->grab(); + return entity; + } + + // Do we have the file in memory so that we can instanciate the entity from there? + std::map<std::string, std::pair<c8*, long> >::iterator itFiles = mEntityFiles.find(fileName); + + if(itFiles != mEntityFiles.end()) + { + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Create a memory read file. + long fSize = (itFiles->second).second; + c8 *fBuffer = (itFiles->second).first; + + IReadFile *file = fileSystem->createMemoryReadFile(fBuffer, fSize, fileName.c_str()); + IXMLReader *xml = fileSystem->createXMLReader(file); + + // Create the entity. + Entity *entity = GameManager::Instance()->getEntityManager() + ->createEntityFromXML(xml, NULL, pParent, false); + + mEntities[fileName] = entity; + entity->grab(); + + // Clean up. + xml->drop(); + file->drop(); + + // Return the entity. + return entity; + } + + // We didn't find anythin. + return NULL; +} + +// Loads the mesh with the given filename. +bool EntityProcessor::loadAsset(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 entities directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo( (pParent->getBaseDir()).c_str() ) ) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./entities/")) + return false; + + // Load the entity. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + + // Store data. + mEntityFiles[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded entity: " << fileName << "\n"; + + // Handle reload. + if(mIsReloading) + { + std::map<std::string, Entity*>::iterator it = mEntities.find(fileName); + + if(it != mEntities.end()) + { + IXMLReader *xml = fileSystem->createXMLReader(file); + + Entity *entity = it->second; + + entity->removeChildren(); + entity->setAbsolutePosition(entity->getParent()->getAbsolutePosition()); + entity->setAbsoluteRotation(entity->getParent()->getAbsoluteRotation()); + + entity->loadXML(xml); + + xml->drop(); + } + } + + // Clean up. + file->drop(); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (file) ? true : false; +} + +// Loads the meshes associated with this asset group. +void EntityProcessor::loadAssets() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the entities directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo( (pParent->getBaseDir()).c_str() ) ) + return; + + if(!fileSystem->changeWorkingDirectoryTo("./entities/")) + return; + + // Read the entities. + IFileList *fileList = fileSystem->createFileList(); + + for(u32 i = 0; i < fileList->getFileCount(); i++) + { + // Get file name. + std::string fileName = (fileList->getFileName(i)).c_str(); + + if(fileName == "..") + continue; + + // Load the entities. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + + // Store data. + mEntityFiles[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded entity: " << fileName << "\n"; + + // Handle reload. + if(mIsReloading) + { + std::map<std::string, Entity*>::iterator it = mEntities.find(fileName); + + if(it != mEntities.end()) + { + IXMLReader *xml = fileSystem->createXMLReader(file); + + Entity *entity = it->second; + + entity->removeChildren(); + + if(entity->getParent() != NULL) + { + entity->setAbsolutePosition(entity->getParent()->getAbsolutePosition()); + entity->setAbsoluteRotation(entity->getParent()->getAbsoluteRotation()); + } + + entity->loadXML(xml); + + xml->drop(); + } + } + + // Clean up. + file->drop(); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +// Reloads the asset with the given filename. +bool EntityProcessor::reloadAsset(const std::string &fileName) +{ + mIsReloading = true; + + removeAsset(fileName); + bool succeeded = loadAsset(fileName); + + mIsReloading = false; + + return succeeded; +} + +// Reloads all assets. +void EntityProcessor::reloadAssets() +{ + // We do a regular reload. + mIsReloading = true; + + removeAssets(); + loadAssets(); + + mIsReloading = false; + + // We need to resync our entities map. + // Create a new map with all existing entities. + std::map<std::string, Entity*> newMap; + + std::map<std::string, std::pair<c8*, long> >::iterator itFiles; + for(itFiles = mEntityFiles.begin(); itFiles != mEntityFiles.end(); itFiles++) + { + std::map<std::string, Entity*>::iterator itEntities = mEntities.find(itFiles->first); + + if(itEntities != mEntities.end()) + { + newMap[itEntities->first] = itEntities->second; + mEntities.erase(itEntities); + } + } + + // Remove redundant entities. + std::map<std::string, Entity*>::iterator itEntities; + for(itEntities = mEntities.begin(); itEntities != mEntities.end(); itEntities++) + (itEntities->second)->drop(); + + mEntities.clear(); + + // Set new map. + mEntities = newMap; +} + +// Removes the asset with the given filename. +bool EntityProcessor::removeAsset(const std::string &fileName) +{ + // Predeclaration of succeeded variable. + bool succeeded = false; + + // Try to find the given entity file. + std::map<std::string, std::pair<c8*, long> >::iterator it = mEntityFiles.find(fileName); + + // Did we find the entity file? + if(it != mEntityFiles.end()) + { + // Delete the entity file. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + mEntityFiles.erase(it); + + succeeded = true; + } + + // Try to find the given entity, but only if we're not reloading. + if(succeeded && !mIsReloading) + { + std::map<std::string, Entity*>::iterator it = mEntities.find(fileName); + + // Did we find the entity? + if(it != mEntities.end()) + { + (it->second)->drop(); + mEntities.erase(it); + } + } + + // Return whether we succeeded or not. + return succeeded; +} + +// Removes all asssets. +void EntityProcessor::removeAssets() +{ + // Delete the entity files. + std::map<std::string, std::pair<c8*, long> >::iterator itFiles; + + for(itFiles = mEntityFiles.begin(); itFiles != mEntityFiles.end(); itFiles++) + { + // Delete the entity file. + c8 *fBuffer = (itFiles->second).first; + delete [] fBuffer; + } + + // Clear the entity files map. + mEntityFiles.clear(); + + // Remove the entities, but only if we're not reloading. + if(!mIsReloading) + { + std::map<std::string, Entity*>::iterator itEntities; + + for(itEntities = mEntities.begin(); itEntities != mEntities.end(); itEntities++) + (itEntities->second)->drop(); + + // Clear the entities map. + mEntities.clear(); + } +} + +// Creates a new EntityProcessor. +AssetProcessor* EntityProcessor::createProcessor(AssetGroup *parent) +{ + return new EntityProcessor(parent); +} + +// End of File Added: trunk/src/assets/EntityProcessor.h =================================================================== --- trunk/src/assets/EntityProcessor.h (rev 0) +++ trunk/src/assets/EntityProcessor.h 2009-08-19 21:22:19 UTC (rev 112) @@ -0,0 +1,80 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: EntityProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the EntityProcessor 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 __ENTITYPROCESSOR_H__ +#define __ENTITYPROCESSOR_H__ + +// Include files +#include "../dependencies.h" +#include "../core/AssetProcessor.h" +#include "../core/EntityManager.h" + + +// EntityProcessor class +//! AssetProcessor for processing entities in an AssetGroup. +class EntityProcessor : public AssetProcessor +{ +public: + + // Initialisation and deinitialisation + //! Constructor + EntityProcessor(AssetGroup *parent); + //! Deconstructor + ~EntityProcessor(); + + // Public methods + //! Gets the entity with the given filename. + //! @param fileName Filename of the mesh. + Entity* getEntity(const std::string &fileName); + + //! Reloads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool reloadAsset(const std::string &fileName); + //! Reloads all assets. + void reloadAssets(); + + //! Removes the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool removeAsset(const std::string &fileName) ; + //! Removes all assets. + void removeAssets(); + + //! Creates a new EntityProcessor. + //! @note For internal use only! + static AssetProcessor* createProcessor(AssetGroup *parent); + +protected: + + // Protected methods + //! Loads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful loading, false otherwise. + bool loadAsset(const std::string &fileName); + //! Loads all assets. + void loadAssets(); + + +private: + + // Private members + std::map<std::string, std::pair<c8*, long> > mEntityFiles; + std::map<std::string, Entity*> mEntities; + + bool mIsReloading; +}; + +#endif Modified: trunk/src/assets/HeightmapProcessor.h =================================================================== --- trunk/src/assets/HeightmapProcessor.h 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/HeightmapProcessor.h 2009-08-19 21:22:19 UTC (rev 112) @@ -59,7 +59,7 @@ protected: - // Private methods + // Protected methods //! Loads the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful loading, false otherwise. Modified: trunk/src/assets/MeshProcessor.cpp =================================================================== --- trunk/src/assets/MeshProcessor.cpp 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/MeshProcessor.cpp 2009-08-19 21:22:19 UTC (rev 112) @@ -39,7 +39,7 @@ if(it != mMeshes.end()) return it->second; - return NULL; + return 0; } // Loads the mesh with the given filename. Modified: trunk/src/assets/MeshProcessor.h =================================================================== --- trunk/src/assets/MeshProcessor.h 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/MeshProcessor.h 2009-08-19 21:22:19 UTC (rev 112) @@ -58,7 +58,7 @@ protected: - // Private methods + // Protected methods //! Loads the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful loading, false otherwise. Modified: trunk/src/assets/ScriptProcessor.h =================================================================== --- trunk/src/assets/ScriptProcessor.h 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/ScriptProcessor.h 2009-08-19 21:22:19 UTC (rev 112) @@ -62,7 +62,7 @@ protected: - // Private methods + // Protected methods //! Loads the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful loading, false otherwise. Modified: trunk/src/assets/SoundProcessor.h =================================================================== --- trunk/src/assets/SoundProcessor.h 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/SoundProcessor.h 2009-08-19 21:22:19 UTC (rev 112) @@ -64,7 +64,7 @@ protected: - // Private methods + // Protected methods //! Loads the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful loading, false otherwise. Modified: trunk/src/assets/TextureProcessor.h =================================================================== --- trunk/src/assets/TextureProcessor.h 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/TextureProcessor.h 2009-08-19 21:22:19 UTC (rev 112) @@ -58,7 +58,7 @@ protected: - // Private methods + // Protected methods //! Loads the asset with the given filename. //! @param fileName Filename of the asset. //! @return True on succesful loading, false otherwise. Modified: trunk/src/assets/processors.cpp =================================================================== --- trunk/src/assets/processors.cpp 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/processors.cpp 2009-08-19 21:22:19 UTC (rev 112) @@ -24,7 +24,7 @@ AssetManager *pAssetMgr = GameManager::Instance()->getAssetManager(); // Register factories. - pAssetMgr->registerProcessorFactory("heightmpas", HeightmapProcessor::createProcessor); + pAssetMgr->registerProcessorFactory("heightmaps", HeightmapProcessor::createProcessor); pAssetMgr->registerProcessorFactory("meshes", MeshProcessor::createProcessor); pAssetMgr->registerProcessorFactory("textures", TextureProcessor::createProcessor); @@ -35,6 +35,8 @@ #ifdef __COMPILE_WITH_SFML_AUDIO__ pAssetMgr->registerProcessorFactory("sounds", SoundProcessor::createProcessor); #endif // __COMPILE_WITH_SFML_AUDIO__ + + pAssetMgr->registerProcessorFactory("entities", EntityProcessor::createProcessor); } // End of File Modified: trunk/src/assets/processors.h =================================================================== --- trunk/src/assets/processors.h 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/assets/processors.h 2009-08-19 21:22:19 UTC (rev 112) @@ -17,6 +17,7 @@ #define __PROCESSORS_H__ // Include files +#include "EntityProcessor.h" #include "HeightmapProcessor.h" #include "MeshProcessor.h" #include "TextureProcessor.h" Modified: trunk/src/components/scene/SkyBoxComponent.cpp =================================================================== --- trunk/src/components/scene/SkyBoxComponent.cpp 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/components/scene/SkyBoxComponent.cpp 2009-08-19 21:22:19 UTC (rev 112) @@ -202,7 +202,7 @@ // Are we dealing with a SkyBoxComponent? if(file->getNodeType() == io::EXN_ELEMENT) { - if(stringw("SkyDomeComponent") == file->getNodeName()) + if(stringw("SkyBoxComponent") == file->getNodeName()) { // Initialise the component. component = new SkyBoxComponent(entity); Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/core/Entity.cpp 2009-08-19 21:22:19 UTC (rev 112) @@ -233,10 +233,15 @@ // Try to get a pointer to the parent. Entity *retrievedParent = NULL; - //if(pAssetGroup != NULL) - // retrievedParent = pAssetGroup->getEntity(parentFile.c_str()); + if(pAssetGroup != NULL) + { + EntityProcessor *processor = static_cast<EntityProcessor*> + (pAssetGroup->getAssetProcessor("entities")); - //else + retrievedParent = processor->getEntity(parentFile.c_str()); + } + + else retrievedParent = GameManager::Instance()->getEntityManager()->getEntity(parentFile.c_str()); if(retrievedParent == NULL && pAssetGroup == NULL) @@ -292,8 +297,8 @@ file->getAttributeValueAsFloat(L"z") )); } - // <Components> - else if(stringw("Components") == file->getNodeName()) + // <components> + else if(stringw("components") == file->getNodeName()) parseComponentsXML(file, this); break; @@ -318,7 +323,7 @@ // Removes all children. void Entity::removeChildren() { - while(mChildren.size() <= 0) + while(mChildren.size() > 0) { // We don't have to do anything else as the removeParent function calls // removeChild internally. Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-08-19 14:55:09 UTC (rev 111) +++ trunk/src/core/EntityManager.cpp 2009-08-19 21:22:19 UTC (rev 112) @@ -147,13 +147,18 @@ // Try to get a pointer to the parent. Entity *retrievedParent = NULL; - //if(assets != NULL) - // retrievedParent = assets->getEntity(parentFile.c_str()); + if(assets != NULL) + { + EntityProcessor *processor = static_cast<EntityProcessor*> + (assets->getAssetProcessor("entities")); - //else - retrievedParent = GameManager::Instance()->getEntityManager() - ->getEntity(parentFile.c_str()); + retrievedParent = processor->getEntity(parentFile.c_str()); + } + else + retrievedParent = GameManager::Instance()->getEntityManager() + ->getEntity(parentFile.c_str()); + if(retrievedParent == NULL && assets == NULL) { parent = GameManager::Instance()->getEntityManager()-> @@ -202,8 +207,8 @@ file->getAttributeValueAsFloat(L"z") )); } - // <Components> - else if(stringw("Components") == file->getNodeName()) + // <components> + else if(stringw("components") == file->getNodeName()) parseComponentsXML(file, entity); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-19 14:55:24
|
Revision: 111 http://sirrf.svn.sourceforge.net/sirrf/?rev=111&view=rev Author: zccdark203 Date: 2009-08-19 14:55:09 +0000 (Wed, 19 Aug 2009) Log Message: ----------- The AssetGroup class is working normally again, but using the new AssetProcessor class as a backbone. Modified Paths: -------------- trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/assets/MeshProcessor.h trunk/src/assets/processors.cpp trunk/src/assets/processors.h trunk/src/components/scene/ImageComponent.cpp trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SkyBoxComponent.cpp trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h trunk/src/core/AssetProcessor.h Added Paths: ----------- trunk/src/assets/HeightmapProcessor.cpp trunk/src/assets/HeightmapProcessor.h trunk/src/assets/ScriptProcessor.cpp trunk/src/assets/ScriptProcessor.h trunk/src/assets/SoundProcessor.cpp trunk/src/assets/SoundProcessor.h trunk/src/assets/TextureProcessor.cpp trunk/src/assets/TextureProcessor.h Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/build/CMake/CMakeLists.txt 2009-08-19 14:55:09 UTC (rev 111) @@ -13,7 +13,11 @@ ${SOURCE_DIR}main.cpp # src/assets + ${SOURCE_DIR}assets/HeightmapProcessor.cpp ${SOURCE_DIR}assets/MeshProcessor.cpp + ${SOURCE_DIR}assets/TextureProcessor.cpp + ${SOURCE_DIR}assets/ScriptProcessor.cpp + ${SOURCE_DIR}assets/SoundProcessor.cpp ${SOURCE_DIR}assets/processor.cpp # src/components Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-08-19 14:55:09 UTC (rev 111) @@ -58,8 +58,16 @@ <Add option="-Wall" /> <Add directory="../../src/vendor" /> </Compiler> + <Unit filename="../../src/assets/HeightmapProcessor.cpp" /> + <Unit filename="../../src/assets/HeightmapProcessor.h" /> <Unit filename="../../src/assets/MeshProcessor.cpp" /> <Unit filename="../../src/assets/MeshProcessor.h" /> + <Unit filename="../../src/assets/ScriptProcessor.cpp" /> + <Unit filename="../../src/assets/ScriptProcessor.h" /> + <Unit filename="../../src/assets/SoundProcessor.cpp" /> + <Unit filename="../../src/assets/SoundProcessor.h" /> + <Unit filename="../../src/assets/TextureProcessor.cpp" /> + <Unit filename="../../src/assets/TextureProcessor.h" /> <Unit filename="../../src/assets/processors.cpp" /> <Unit filename="../../src/assets/processors.h" /> <Unit filename="../../src/components/components.cpp" /> Added: trunk/src/assets/HeightmapProcessor.cpp =================================================================== --- trunk/src/assets/HeightmapProcessor.cpp (rev 0) +++ trunk/src/assets/HeightmapProcessor.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,250 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: HeightmapProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : AssetProcessor for processing heightmaps in an AssetGroup. +// +// 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 "HeightmapProcessor.h" +#include "../core/GameManager.h" + + +// HeightmapProcessor class +// HeightmapProcessor constructor. +HeightmapProcessor::HeightmapProcessor(AssetGroup *parent) +: AssetProcessor(parent, "heightmaps"), mIsReloading(false) +{ +} + +// HeightmapProcessor deconstructor. +HeightmapProcessor::~HeightmapProcessor() +{ + removeAssets(); +} + +// Gets the heightmap with the given filename. +IReadFile* HeightmapProcessor::getHeightMap(const std::string &fileName) +{ + std::map<std::string, std::pair<c8*, long> >::iterator it = mHeightMaps.find(fileName); + + if(it != mHeightMaps.end()) + { + c8 *fBuffer = (it->second).first; + s32 fSize = static_cast<s32>((it->second).second); + + IReadFile *file = GameManager::Instance()->getDevice()->getFileSystem() + ->createMemoryReadFile(fBuffer, fSize, fileName.c_str()); + return file; + } + + return NULL; +} + +// Loads the mesh with the given filename. +bool HeightmapProcessor::loadAsset(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 heightmap directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo( (pParent->getBaseDir()).c_str() ) ) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./heightmaps/")) + return false; + + // Load the heightmap. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + // Store data. + mHeightMaps[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded heightmap: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + { + IReadFile *heightMap = fileSystem->createMemoryReadFile(fBuffer, static_cast<s32>(fSize), + fileName.c_str()); + pParent->emitEvent(std::string("heightmaps/") + fileName, heightMap); + } + + else + pParent->createEventSlot(std::string("heightmaps/") + fileName); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (file) ? true : false; +} + +// Loads the meshes associated with this asset group. +void HeightmapProcessor::loadAssets() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the heightmaps directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo( (pParent->getBaseDir()).c_str() ) ) + return; + + if(!fileSystem->changeWorkingDirectoryTo("./heightmaps/")) + return; + + // Read the heightmaps. + IFileList *fileList = fileSystem->createFileList(); + + for(u32 i = 0; i < fileList->getFileCount(); i++) + { + // Get file name. + std::string fileName = (fileList->getFileName(i)).c_str(); + + if(fileName == "..") + continue; + + // Load the heightmap. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + // Store data. + mHeightMaps[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded heightmap: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + { + IReadFile *heightMap = fileSystem->createMemoryReadFile(fBuffer, static_cast<s32>(fSize), + fileName.c_str()); + pParent->emitEvent(std::string("heightmaps/") + fileName, heightMap); + } + + else + pParent->createEventSlot(std::string("heightmaps/") + fileName); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +// Reloads the asset with the given filename. +bool HeightmapProcessor::reloadAsset(const std::string &fileName) +{ + mIsReloading = true; + + removeAsset(fileName); + bool succeeded = loadAsset(fileName); + + mIsReloading = false; + + return succeeded; +} + +// Reloads all assets. +void HeightmapProcessor::reloadAssets() +{ + mIsReloading = true; + + removeAssets(); + loadAssets(); + + mIsReloading = false; +} + +// Removes the asset with the given filename. +bool HeightmapProcessor::removeAsset(const std::string &fileName) +{ + // Try to find the given heightmap. + std::map<std::string, std::pair<c8*, long> >::iterator it = mHeightMaps.find(fileName); + + // Did we find the heightmap? + if(it != mHeightMaps.end()) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("heightmaps/") + it->first; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the heightmap. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + mHeightMaps.erase(it); + + return true; + } + + // We didn't find the heightmap. + else return false; +} + +// Removes all asssets. +void HeightmapProcessor::removeAssets() +{ + // Delete the heightmaps. + std::map<std::string, std::pair<c8*, long> >::iterator it; + + for(it = mHeightMaps.begin(); it != mHeightMaps.end(); it++) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("heightmaps/") + it->first; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the heightmap. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + } + + // Clear the heightmaps map. + mHeightMaps.clear(); +} + +// Creates a new HeightmapProcessor. +AssetProcessor* HeightmapProcessor::createProcessor(AssetGroup *parent) +{ + return new HeightmapProcessor(parent); +} + +// End of File Added: trunk/src/assets/HeightmapProcessor.h =================================================================== --- trunk/src/assets/HeightmapProcessor.h (rev 0) +++ trunk/src/assets/HeightmapProcessor.h 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,79 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: HeightmapProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the HeightmapProcessor 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 __HEIGHTMAPPROCESSOR_H__ +#define __HEIGHTMAPPROCESSOR_H__ + +// Include files +#include "../dependencies.h" +#include "../core/AssetProcessor.h" + + +// HeightmapProcessor class +//! AssetProcessor for processing heightmaps in an AssetGroup. +class HeightmapProcessor : public AssetProcessor +{ +public: + + // Initialisation and deinitialisation + //! Constructor + HeightmapProcessor(AssetGroup *parent); + //! Deconstructor + ~HeightmapProcessor(); + + // Public methods + //! Gets the heightmap with the given filename. + //! @param fileName Filename of the heightmap. + //! @note Don't forget to drop the file as soon as you're done with it. + IReadFile* getHeightMap(const std::string &fileName); + + //! Reloads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool reloadAsset(const std::string &fileName); + //! Reloads all assets. + void reloadAssets(); + + //! Removes the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool removeAsset(const std::string &fileName) ; + //! Removes all assets. + void removeAssets(); + + //! Creates a new HeightmapProcessor. + //! @note For internal use only! + static AssetProcessor* createProcessor(AssetGroup *parent); + +protected: + + // Private methods + //! Loads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful loading, false otherwise. + bool loadAsset(const std::string &fileName); + //! Loads all assets. + void loadAssets(); + + +private: + + // Private members + std::map<std::string, std::pair<c8*, long> > mHeightMaps; + + bool mIsReloading; +}; + +#endif Modified: trunk/src/assets/MeshProcessor.h =================================================================== --- trunk/src/assets/MeshProcessor.h 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/assets/MeshProcessor.h 2009-08-19 14:55:09 UTC (rev 111) @@ -56,18 +56,23 @@ //! @note For internal use only! static AssetProcessor* createProcessor(AssetGroup *parent); -private: +protected: // Private methods + //! Loads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful loading, false otherwise. bool loadAsset(const std::string &fileName); + //! Loads all assets. void loadAssets(); + +private: + // Private members std::map<std::string, IAnimatedMesh*> mMeshes; bool mIsReloading; - }; #endif - Added: trunk/src/assets/ScriptProcessor.cpp =================================================================== --- trunk/src/assets/ScriptProcessor.cpp (rev 0) +++ trunk/src/assets/ScriptProcessor.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,232 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: ScriptProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : AssetProcessor for processing scripts in an AssetGroup. +// +// 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 "ScriptProcessor.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../core/GameManager.h" + + +// ScriptProcessor class +// ScriptProcessor constructor. +ScriptProcessor::ScriptProcessor(AssetGroup *parent) +: AssetProcessor(parent, "scripts"), mIsReloading(false) +{ +} + +// ScriptProcessor deconstructor. +ScriptProcessor::~ScriptProcessor() +{ + removeAssets(); +} + +// Gets the script with the given filename. +Script* ScriptProcessor::getScript(const std::string &fileName) +{ + std::map<std::string, Script*>::iterator it = mScripts.find(fileName); + + if(it != mScripts.end()) + return it->second; + + return NULL; +} + +// Loads the mesh with the given filename. +bool ScriptProcessor::loadAsset(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( (pParent->getBaseDir()).c_str() ) ) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./scripts/")) + return false; + + // Read the script. + Script *script = new Script(fileName); + + if(script->loadScript(fileName)) + { + // Store scripts. + mScripts[fileName] = script; + cout << "Loaded script: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + pParent->emitEvent(std::string("scripts/") + fileName, script); + + else + pParent->createEventSlot(std::string("scripts/") + fileName); + } + + else + { + delete script; + script = NULL; + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (script != NULL) ? true : false; +} + +// Loads the meshes associated with this asset group. +void ScriptProcessor::loadAssets() +{ + // 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( (pParent->getBaseDir()).c_str() ) ) + return; + + if(!fileSystem->changeWorkingDirectoryTo("./scripts/")) + return; + + // Read the textures. + IFileList *fileList = fileSystem->createFileList(); + + for(u32 i = 0; i < fileList->getFileCount(); i++) + { + // Get file name. + std::string fileName = (fileList->getFileName(i)).c_str(); + + if(fileName == "..") + continue; + + // Load the script. + Script *script = new Script(fileName); + + if(script->loadScript(fileName)) + { + // Store script. + mScripts[fileName] = script; + cout << "Loaded script: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + pParent->emitEvent(std::string("scripts/") + fileName, script); + + else + pParent->createEventSlot(std::string("scripts/") + fileName); + } + + else delete script; + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +// Reloads the asset with the given filename. +bool ScriptProcessor::reloadAsset(const std::string &fileName) +{ + mIsReloading = true; + + removeAsset(fileName); + bool succeeded = loadAsset(fileName); + + mIsReloading = false; + + return succeeded; +} + +// Reloads all assets. +void ScriptProcessor::reloadAssets() +{ + mIsReloading = true; + + removeAssets(); + loadAssets(); + + mIsReloading = false; +} + +// Removes the asset with the given filename. +bool ScriptProcessor::removeAsset(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()) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("scripts/") + it->first; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the script. + Script *script = it->second; + script->drop(); + mScripts.erase(it); + + return true; + } + + // We didn't find the script. + else return false; +} + +// Removes all asssets. +void ScriptProcessor::removeAssets() +{ + // Delete the scripts. + std::map<std::string, Script*>::iterator it; + + for(it = mScripts.begin(); it != mScripts.end(); it++) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("scripts/") + it->first; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the script. + Script *script = it->second; + script->drop(); + } + + // Clear the scripts map. + mScripts.clear(); +} + +// Creates a new ScriptProcessor. +AssetProcessor* ScriptProcessor::createProcessor(AssetGroup *parent) +{ + return new ScriptProcessor(parent); +} + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +// End of File Added: trunk/src/assets/ScriptProcessor.h =================================================================== --- trunk/src/assets/ScriptProcessor.h (rev 0) +++ trunk/src/assets/ScriptProcessor.h 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,84 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: ScriptProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the ScriptProcessor 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 __SCRIPTPROCESSOR_H__ +#define __SCRIPTPROCESSOR_H__ + +// Include files +#include "../dependencies.h" + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + +#include "../core/AssetProcessor.h" +#include "../scripting/Script.h" + + +// ScriptProcessor class +//! AssetProcessor for processing scripts in an AssetGroup. +class ScriptProcessor : public AssetProcessor +{ +public: + + // Initialisation and deinitialisation + //! Constructor + ScriptProcessor(AssetGroup *parent); + //! Deconstructor + ~ScriptProcessor(); + + // Public methods + //! Gets the script with the given filename. + //! @param fileName Filename of the script. + Script *getScript(const std::string &fileName); + + //! Reloads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool reloadAsset(const std::string &fileName); + //! Reloads all assets. + void reloadAssets(); + + //! Removes the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool removeAsset(const std::string &fileName) ; + //! Removes all assets. + void removeAssets(); + + //! Creates a new ScriptProcessor. + //! @note For internal use only! + static AssetProcessor* createProcessor(AssetGroup *parent); + +protected: + + // Private methods + //! Loads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful loading, false otherwise. + bool loadAsset(const std::string &fileName); + //! Loads all assets. + void loadAssets(); + + +private: + + // Private members + std::map<std::string, Script*> mScripts; + + bool mIsReloading; +}; + +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#endif Added: trunk/src/assets/SoundProcessor.cpp =================================================================== --- trunk/src/assets/SoundProcessor.cpp (rev 0) +++ trunk/src/assets/SoundProcessor.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,245 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SoundProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : AssetProcessor for processing meshes in an AssetGroup. +// +// 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 "SoundProcessor.h" + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + +#include "../core/GameManager.h" + + +// SoundProcessor class +// SoundProcessor constructor. +SoundProcessor::SoundProcessor(AssetGroup *parent) +: AssetProcessor(parent, "sounds"), mIsReloading(false) +{ +} + +// SoundProcessor deconstructor. +SoundProcessor::~SoundProcessor() +{ + removeAssets(); +} + +// Gets the sound with the given filename. +bool SoundProcessor::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; +} + +// Loads the mesh with the given filename. +bool SoundProcessor::loadAsset(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 sounds directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo( (pParent->getBaseDir()).c_str() ) ) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./sounds/")) + return false; + + // Load the sound. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + // Store data. + mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded sound: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + pParent->emitEvent(std::string("sounds/") + fileName, &mSounds[fileName]); + + else + pParent->createEventSlot(std::string("sounds/") + fileName); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (file) ? true : false; +} + +// Loads the meshes associated with this asset group. +void SoundProcessor::loadAssets() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the sounds directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo( (pParent->getBaseDir()).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 = (fileList->getFileName(i)).c_str(); + + if(fileName == "..") + continue; + + // Load the sound. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + // Store data. + mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded sound: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + pParent->emitEvent(std::string("sounds/") + fileName, &mSounds[fileName]); + + else + pParent->createEventSlot(std::string("sounds/") + fileName); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +// Reloads the asset with the given filename. +bool SoundProcessor::reloadAsset(const std::string &fileName) +{ + mIsReloading = true; + + removeAsset(fileName); + bool succeeded = loadAsset(fileName); + + mIsReloading = false; + + return succeeded; +} + +// Reloads all assets. +void SoundProcessor::reloadAssets() +{ + mIsReloading = true; + + removeAssets(); + loadAssets(); + + mIsReloading = false; +} + +// Removes the asset with the given filename. +bool SoundProcessor::removeAsset(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()) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("sounds/") + it->first; + std::pair<c8*, long> emptySound = std::pair<c8*, long>(NULL, 0); + + pParent->emitEvent(slotName, &emptySound); + pParent->removeEventSlot(slotName); + } + + // Delete the sound. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + mSounds.erase(it); + + return true; + } + + // We didn't find the sounds. + else return false; +} + +// Removes all asssets. +void SoundProcessor::removeAssets() +{ +// Delete the sounds. + std::map<std::string, std::pair<c8*, long> >::iterator it; + + for(it = mSounds.begin(); it != mSounds.end(); it++) + { + // Handle events. + std::string slotName = std::string("sounds/") + it->first; + std::pair<c8*, long> emptySound = std::pair<c8*, long>(NULL, 0); + + pParent->emitEvent(slotName, &emptySound); + + if(!mIsReloading) + pParent->removeEventSlot(slotName); + + // Delete the sound. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + } + + // Clear the sounds map. + mSounds.clear(); +} + +// Creates a new SoundProcessor. +AssetProcessor* SoundProcessor::createProcessor(AssetGroup *parent) +{ + return new SoundProcessor(parent); +} + +#endif // __COMPILE_WITH_SFML_AUDIO__ + +// End of File Added: trunk/src/assets/SoundProcessor.h =================================================================== --- trunk/src/assets/SoundProcessor.h (rev 0) +++ trunk/src/assets/SoundProcessor.h 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,86 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SoundProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the SoundProcessor 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 __SOUNDPROCESSOR_H__ +#define __SOUNDPROCESSOR_H__ + +// Include files +#include "../dependencies.h" + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + +#include "../core/AssetProcessor.h" + + +// SoundProcessor class +//! AssetProcessor for processing sounds in an AssetGroup. +class SoundProcessor : public AssetProcessor +{ +public: + + // Initialisation and deinitialisation + //! Constructor + SoundProcessor(AssetGroup *parent); + //! Deconstructor + ~SoundProcessor(); + + // Public methods + //! 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); + + //! Reloads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool reloadAsset(const std::string &fileName); + //! Reloads all assets. + void reloadAssets(); + + //! Removes the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool removeAsset(const std::string &fileName) ; + //! Removes all assets. + void removeAssets(); + + //! Creates a new SoundProcessor. + //! @note For internal use only! + static AssetProcessor* createProcessor(AssetGroup *parent); + +protected: + + // Private methods + //! Loads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful loading, false otherwise. + bool loadAsset(const std::string &fileName); + //! Loads all assets. + void loadAssets(); + + +private: + + // Private members + std::map<std::string, std::pair<c8*, long> > mSounds; + + bool mIsReloading; +}; + +#endif // __COMPILE_WITH_SFML_AUDIO__ + +#endif Added: trunk/src/assets/TextureProcessor.cpp =================================================================== --- trunk/src/assets/TextureProcessor.cpp (rev 0) +++ trunk/src/assets/TextureProcessor.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,227 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: TextureProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : AssetProcessor for processing textures in an AssetGroup. +// +// 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 "TextureProcessor.h" +#include "../core/GameManager.h" + + +// TextureProcessor class +// TextureProcessor constructor. +TextureProcessor::TextureProcessor(AssetGroup *parent) +: AssetProcessor(parent, "textures"), mIsReloading(false) +{ +} + +// TextureProcessor deconstructor. +TextureProcessor::~TextureProcessor() +{ + removeAssets(); +} + +// Gets the texture with the given filename. +ITexture* TextureProcessor::getTexture(const std::string &fileName) +{ + std::map<std::string, ITexture*>::iterator it = mTextures.find(fileName); + + if(it != mTextures.end()) + return it->second; + + return NULL; +} + +// Loads the mesh with the given filename. +bool TextureProcessor::loadAsset(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( (pParent->getBaseDir()).c_str() ) ) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./textures/")) + return false; + + // Read the texture. + ITexture *texture = pDriver->getTexture(fileName.c_str()); + + 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) + pParent->emitEvent(std::string("textures/") + fileName, texture); + + else + pParent->createEventSlot(std::string("textures/") + fileName); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (texture) ? true : false; +} + +// Loads the meshes associated with this asset group. +void TextureProcessor::loadAssets() +{ + // 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( (pParent->getBaseDir()).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 = (fileList->getFileName(i)).c_str(); + + if(fileName == "..") + continue; + + // Load the mesh. + ITexture *texture = pDriver->getTexture(fileName.c_str()); + + 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) + pParent->emitEvent(std::string("textures/") + fileName, texture); + + else + pParent->createEventSlot(std::string("textures/") + fileName); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +// Reloads the asset with the given filename. +bool TextureProcessor::reloadAsset(const std::string &fileName) +{ + mIsReloading = true; + + removeAsset(fileName); + bool succeeded = loadAsset(fileName); + + mIsReloading = false; + + return succeeded; +} + +// Reloads all assets. +void TextureProcessor::reloadAssets() +{ + mIsReloading = true; + + removeAssets(); + loadAssets(); + + mIsReloading = false; +} + +// Removes the asset with the given filename. +bool TextureProcessor::removeAsset(const std::string &fileName) +{ + // Try to find the given texture. + std::map<std::string, ITexture*>::iterator it = mTextures.find(fileName); + + // Did we find the texture? + if(it != mTextures.end()) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("textures/") + it->first; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the texture. + ITexture *texture = it->second; + texture->drop(); + mTextures.erase(it); + + return true; + } + + // We didn't find the texture. + else return false; +} + +// Removes all asssets. +void TextureProcessor::removeAssets() +{ + // 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; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the texture. + ITexture *texture = it->second; + texture->drop(); + } + + // Clear the texture map. + mTextures.clear(); +} + +// Creates a new TextureProcessor. +AssetProcessor* TextureProcessor::createProcessor(AssetGroup *parent) +{ + return new TextureProcessor(parent); +} + +// End of File Added: trunk/src/assets/TextureProcessor.h =================================================================== --- trunk/src/assets/TextureProcessor.h (rev 0) +++ trunk/src/assets/TextureProcessor.h 2009-08-19 14:55:09 UTC (rev 111) @@ -0,0 +1,78 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: TextureProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the TextureProcessor 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 __TEXTUREPROCESSOR_H__ +#define __TEXTUREPROCESSOR_H__ + +// Include files +#include "../dependencies.h" +#include "../core/AssetProcessor.h" + + +// TextureProcessor class +//! AssetProcessor for processing textures in an AssetGroup. +class TextureProcessor : public AssetProcessor +{ +public: + + // Initialisation and deinitialisation + //! Constructor + TextureProcessor(AssetGroup *parent); + //! Deconstructor + ~TextureProcessor(); + + // Public methods + //! Gets the texture with the given filename. + //! @param fileName Filename of the texture. + ITexture* getTexture(const std::string &fileName); + + //! Reloads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool reloadAsset(const std::string &fileName); + //! Reloads all assets. + void reloadAssets(); + + //! Removes the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool removeAsset(const std::string &fileName) ; + //! Removes all assets. + void removeAssets(); + + //! Creates a new TextureProcessor. + //! @note For internal use only! + static AssetProcessor* createProcessor(AssetGroup *parent); + +protected: + + // Private methods + //! Loads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful loading, false otherwise. + bool loadAsset(const std::string &fileName); + //! Loads all assets. + void loadAssets(); + + +private: + + // Private members + std::map<std::string, ITexture*> mTextures; + + bool mIsReloading; +}; + +#endif Modified: trunk/src/assets/processors.cpp =================================================================== --- trunk/src/assets/processors.cpp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/assets/processors.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -24,7 +24,17 @@ AssetManager *pAssetMgr = GameManager::Instance()->getAssetManager(); // Register factories. + pAssetMgr->registerProcessorFactory("heightmpas", HeightmapProcessor::createProcessor); pAssetMgr->registerProcessorFactory("meshes", MeshProcessor::createProcessor); + pAssetMgr->registerProcessorFactory("textures", TextureProcessor::createProcessor); + +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + pAssetMgr->registerProcessorFactory("scripts", ScriptProcessor::createProcessor); +#endif // __COMPILE_WITH_ANGELSCRIPT__ + +#ifdef __COMPILE_WITH_SFML_AUDIO__ + pAssetMgr->registerProcessorFactory("sounds", SoundProcessor::createProcessor); +#endif // __COMPILE_WITH_SFML_AUDIO__ } // End of File Modified: trunk/src/assets/processors.h =================================================================== --- trunk/src/assets/processors.h 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/assets/processors.h 2009-08-19 14:55:09 UTC (rev 111) @@ -17,9 +17,19 @@ #define __PROCESSORS_H__ // Include files +#include "HeightmapProcessor.h" #include "MeshProcessor.h" +#include "TextureProcessor.h" +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + #include "ScriptProcessor.h" +#endif // __COMPILE_WITH_ANGELSCRIPT__ +#ifdef __COMPILE_WITH_SFML_AUDIO__ + #include "SoundProcessor.h" +#endif // __COMPILE_WITH_SFML_AUDIO__ + + // Functions //! Registers all available AssetProcessor factories. extern void registerProcessorFactories(); Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/components/scene/ImageComponent.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -166,7 +166,9 @@ assets->disconnectEventSignal(std::string("textures/") + mTextureFileName, this); // Get texture. - texture = assets->getTexture(fileName); + TextureProcessor *processor = static_cast<TextureProcessor*> + (assets->getAssetProcessor("textures")); + texture = processor->getTexture(fileName); if(texture) { Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/components/scene/SceneComponent.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -269,7 +269,9 @@ assets->disconnectEventSignal(std::string("textures/") + it->second, this); // Get texture. - texture = assets->getTexture(fileName); + TextureProcessor *processor = static_cast<TextureProcessor*> + (assets->getAssetProcessor("textures")); + texture = processor->getTexture(fileName); if(texture) { Modified: trunk/src/components/scene/SkyBoxComponent.cpp =================================================================== --- trunk/src/components/scene/SkyBoxComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/components/scene/SkyBoxComponent.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -129,7 +129,9 @@ assets->disconnectEventSignal(std::string("textures/") + mTextureFileNames[side], this); // Get texture. - texture = assets->getTexture(fileName); + TextureProcessor *processor = static_cast<TextureProcessor*> + (assets->getAssetProcessor("textures")); + texture = processor->getTexture(fileName); if(texture) { Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -113,7 +113,8 @@ assets->disconnectEventSignal(std::string("heightmaps/") + mHeightMapFileName, this); // Get heightmap. - heightMap = assets->getHeightMap(fileName); + HeightmapProcessor *processor = static_cast<HeightmapProcessor*>(assets->getAssetProcessor("heightmaps")); + heightMap = processor->getHeightMap(fileName); if(heightMap) { Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -74,7 +74,10 @@ if(assets != NULL) { // Try to retrieve sound from the parent's AssetGroup. - if(assets->getSound(fileName, mBuffer, mBufferSize)) + SoundProcessor *processor = static_cast<SoundProcessor*> + (assets->getAssetProcessor("sounds")); + + if(processor->getSound(fileName, mBuffer, mBufferSize)) { assets->connectEventSignal(std::string("sounds/") + fileName, this, &SoundSourceComponent::onSound); Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-19 11:59:39 UTC (rev 110) +++ trunk/src/core/AssetGroup.cpp 2009-08-19 14:55:09 UTC (rev 111) @@ -24,7 +24,7 @@ // AssetGroup constructor. AssetGroup::AssetGroup(const std::string &name, const std::string &dirName) -: mName(name), mIsReloading(false) +: mName(name) { mID = mIDCount++; mBaseDir = (GameManager::Instance()->getDevice()->getFileSystem() @@ -94,493 +94,9 @@ vector<AssetProcessor*>::iterator it; for(it = mAssetProcessors.begin(); it != mAssetProcessors.end(); it++) - (*it)->reloadAssets(); - - loadHeightMaps(); -#ifdef __COMPILE_WITH_ANGELSCRIPT__ - loadScripts(); -#endif // __COMPILE_WITH_ANGELSCRIPT__ -#ifdef __COMPILE_WITH_SFML_AUDIO__ - loadSounds(); -#endif // __COMPILE_WITH_SFML_AUDIO__ - loadTextures(); + (*it)->loadAssets(); } -// Loads the heightmap with the given filename. -bool AssetGroup::loadHeightMap(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 heightmap directory. - std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); - - if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) - return false; - - if(!fileSystem->changeWorkingDirectoryTo("./heightmaps/")) - return false; - - // Load the heightmap. - IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); - - if(file) - { - // Retrieve data. - long fSize = file->getSize(); - c8 *fBuffer = new c8[fSize+1]; - memset(fBuffer, 0, fSize+1); - - file->read(fBuffer, fSize); - file->drop(); - - // Store data. - mHeightMaps[fileName] = std::pair<c8*, long>(fBuffer, fSize); - cout << "Loaded heightmap: " << fileName << "\n"; - - // Handle events. - if(mIsReloading) - { - IReadFile *heightMap = fileSystem->createMemoryReadFile(fBuffer, static_cast<s32>(fSize), - fileName.c_str()); - emitEvent(std::string("heightmaps/") + fileName, heightMap); - } - - else - createEventSlot(std::string("heightmaps/") + fileName); - } - - // Clean up. - fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); - - return (file) ? true : false; -} - -// Loads the heightmaps associated with this asset group. -void AssetGroup::loadHeightMaps() -{ - // Retrieve pointers to sub-sytems of the Irrlicht engine. - IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); - - // Change the working directory to the heightmaps directory. - std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); - - if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) - return; - - if(!fileSystem->changeWorkingDirectoryTo("./heightmaps/")) - return; - - // Read the heightmaps. - IFileList *fileList = fileSystem->createFileList(); - - for(u32 i = 0; i < fileList->getFileCount(); i++) - { - // Get file name. - std::string fileName = (fileList->getFileName(i)).c_str(); - - if(fileName == "..") - continue; - - // Load the heightmap. - IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); - - if(file) - { - // Retrieve data. - long fSize = file->getSize(); - c8 *fBuffer = new c8[fSize+1]; - memset(fBuffer, 0, fSize+1); - - file->read(fBuffer, fSize); - file->drop(); - - // Store data. - mHeightMaps[fileName] = std::pair<c8*, long>(fBuffer, fSize); - cout << "Loaded heightmap: " << fileName << "\n"; - - // Handle events. - if(mIsReloading) - { - IReadFile *heightMap = fileSystem->createMemoryReadFile(fBuffer, static_cast<s32>(fSize), - fileName.c_str()); - emitEvent(std::string("heightmaps/") + fileName, heightMap); - } - - else - createEventSlot(std::string("heightmaps/") + fileName); - } - } - - // Clean up. - fileList->drop(); - - 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)) - { - // 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 - { - 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("./scripts/")) - return; - - // Read the textures. - IFileList *fileList = fileSystem->createFileList(); - - for(u32 i = 0; i < fileList->getFileCount(); i++) - { - // Get file name. - std::string fileName = (fileList->getFileName(i)).c_str(); - - if(fileName == "..") - continue; - - // Load the script. - Script *script = new Script(fileName); - - 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; - } - - // 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 sounds 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) - { - // Retrieve data. - long fSize = file->getSize(); - c8 *fBuffer = new c8[fSize+1]; - memset(fBuffer, 0, fSize+1); - - file->read(fBuffer, fSize); - file->drop(); - - // Store data. - mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); - cout << "Loaded sound: " << fileName << "\n"; - - // Handle events. - if(mIsReloading) - emitEvent(std::string("sounds/") + fileName, &mSounds[fileName]); - - else - createEventSlot(std::string("sounds/") + fileName); - } - - // 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 sounds 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 = (fileList->getFileName(i)).c_str(); - - if(fileName == "..") - continue; - - // Load the sound. - IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); - - if(file) - { - // Retrieve data. - long fSize = file->getSize(); - c8 *fBuffer = new c8[fSize+1]; - memset(fBuffer, 0, fSize+1); - - file->read(fBuffer, fSize); - file->drop(); - - // Store data. - mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); - cout << "Loaded sound: " << fileName << "\n"; - - // Handle events. - if(mIsReloading) - emitEvent(std::string("sounds/") + fileName, &mSounds[fileName]); - - else - createEventSlot(std::string("sounds/") + fileName); - } - } - - // 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) -{ - // 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) - { - // 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. - fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); - - return (texture) ? true : false; -} - -// 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 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->getFileCou... [truncated message content] |
From: <zcc...@us...> - 2009-08-19 11:59:47
|
Revision: 110 http://sirrf.svn.sourceforge.net/sirrf/?rev=110&view=rev Author: zccdark203 Date: 2009-08-19 11:59:39 +0000 (Wed, 19 Aug 2009) Log Message: ----------- Reimplementing asset management. Code for specific asset types should now be put into a class derived from the AssetProcessor class. Please note that the current code is not yet optimized. Modified Paths: -------------- trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/OctTreeComponent.cpp trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h trunk/src/core/AssetManager.cpp trunk/src/core/AssetManager.h trunk/src/core/GameManager.cpp trunk/src/game/InitState.cpp Added Paths: ----------- trunk/src/assets/ trunk/src/assets/MeshProcessor.cpp trunk/src/assets/MeshProcessor.h trunk/src/assets/processors.cpp trunk/src/assets/processors.h trunk/src/core/AssetProcessor.cpp trunk/src/core/AssetProcessor.h Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/build/CMake/CMakeLists.txt 2009-08-19 11:59:39 UTC (rev 110) @@ -12,6 +12,10 @@ # /src ${SOURCE_DIR}main.cpp + # src/assets + ${SOURCE_DIR}assets/MeshProcessor.cpp + ${SOURCE_DIR}assets/processor.cpp + # src/components ${SOURCE_DIR}components/components.cpp # src/components/scene @@ -35,6 +39,7 @@ # /src/core ${SOURCE_DIR}core/AssetGroup.cpp ${SOURCE_DIR}core/AssetManager.cpp + ${SOURCE_DIR}core/AssetProcessor.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-08-18 19:11:50 UTC (rev 109) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-08-19 11:59:39 UTC (rev 110) @@ -58,6 +58,10 @@ <Add option="-Wall" /> <Add directory="../../src/vendor" /> </Compiler> + <Unit filename="../../src/assets/MeshProcessor.cpp" /> + <Unit filename="../../src/assets/MeshProcessor.h" /> + <Unit filename="../../src/assets/processors.cpp" /> + <Unit filename="../../src/assets/processors.h" /> <Unit filename="../../src/components/components.cpp" /> <Unit filename="../../src/components/components.h" /> <Unit filename="../../src/components/scene/AnimatedMeshComponent.cpp" /> @@ -95,6 +99,8 @@ <Unit filename="../../src/core/AssetGroup.h" /> <Unit filename="../../src/core/AssetManager.cpp" /> <Unit filename="../../src/core/AssetManager.h" /> + <Unit filename="../../src/core/AssetProcessor.cpp" /> + <Unit filename="../../src/core/AssetProcessor.h" /> <Unit filename="../../src/core/DataStack.cpp" /> <Unit filename="../../src/core/DataStack.h" /> <Unit filename="../../src/core/DataStore.cpp" /> Added: trunk/src/assets/MeshProcessor.cpp =================================================================== --- trunk/src/assets/MeshProcessor.cpp (rev 0) +++ trunk/src/assets/MeshProcessor.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -0,0 +1,227 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: MeshProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : AssetProcessor for processing meshes in an AssetGroup. +// +// 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 "MeshProcessor.h" +#include "../core/GameManager.h" + + +// MeshProcessor class +// MeshProcessor constructor. +MeshProcessor::MeshProcessor(AssetGroup *parent) +: AssetProcessor(parent, "meshes"), mIsReloading(false) +{ +} + +// MeshProcessor deconstructor. +MeshProcessor::~MeshProcessor() +{ + removeAssets(); +} + +// Gets the mesh with the given filename. +IAnimatedMesh* MeshProcessor::getMesh(const std::string &fileName) +{ + std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(fileName); + + if(it != mMeshes.end()) + return it->second; + + return NULL; +} + +// Loads the mesh with the given filename. +bool MeshProcessor::loadAsset(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( (pParent->getBaseDir()).c_str() ) ) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./meshes/")) + return false; + + // Read the texture. + IAnimatedMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); + + 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) + pParent->emitEvent(std::string("meshes/") + fileName, mesh); + + else + pParent->createEventSlot(std::string("meshes/") + fileName); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (mesh) ? true : false; +} + +// Loads the meshes associated with this asset group. +void MeshProcessor::loadAssets() +{ + // 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( (pParent->getBaseDir()).c_str() ) ) + return; + + 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 = (fileList->getFileName(i)).c_str(); + + if(fileName == "..") + continue; + + // Load the mesh. + IAnimatedMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); + + 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) + pParent->emitEvent(std::string("meshes/") + fileName, mesh); + + else + pParent->createEventSlot(std::string("meshes/") + fileName); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + +// Reloads the asset with the given filename. +bool MeshProcessor::reloadAsset(const std::string &fileName) +{ + mIsReloading = true; + + removeAsset(fileName); + bool succeeded = loadAsset(fileName); + + mIsReloading = false; + + return succeeded; +} + +// Reloads all assets. +void MeshProcessor::reloadAssets() +{ + mIsReloading = true; + + removeAssets(); + loadAssets(); + + mIsReloading = false; +} + +// Removes the asset with the given filename. +bool MeshProcessor::removeAsset(const std::string &fileName) +{ + // Try to find the given mesh. + std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(fileName); + + // Did we find the mesh? + if(it != mMeshes.end()) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("meshes/") + it->first; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the mesh. + IAnimatedMesh *mesh = it->second; + mesh->drop(); + mMeshes.erase(it); + + return true; + } + + // We didn't find the mesh. + else return false; +} + +// Removes all asssets. +void MeshProcessor::removeAssets() +{ + // 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; + + pParent->emitEvent(slotName, NULL); + pParent->removeEventSlot(slotName); + } + + // Delete the mesh. + IAnimatedMesh *mesh = it->second; + mesh->drop(); + } + + // Clear the mesh map. + mMeshes.clear(); +} + +// Creates a new MeshProcessor. +AssetProcessor* MeshProcessor::createProcessor(AssetGroup *parent) +{ + return new MeshProcessor(parent); +} + +// End of File Added: trunk/src/assets/MeshProcessor.h =================================================================== --- trunk/src/assets/MeshProcessor.h (rev 0) +++ trunk/src/assets/MeshProcessor.h 2009-08-19 11:59:39 UTC (rev 110) @@ -0,0 +1,73 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: MeshProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the MeshProcessor 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 __MESHPROCESSOR_H__ +#define __MESHPROCESSOR_H__ + +// Include files +#include "../dependencies.h" +#include "../core/AssetProcessor.h" + + +// MeshProcessor class +//! AssetProcessor for processing meshes in an AssetGroup. +class MeshProcessor : public AssetProcessor +{ +public: + + // Initialisation and deinitialisation + //! Constructor + MeshProcessor(AssetGroup *parent); + //! Deconstructor + ~MeshProcessor(); + + // Public methods + //! Gets the mesh with the given filename. + //! @param fileName Filename of the mesh. + IAnimatedMesh* getMesh(const std::string &fileName); + + //! Reloads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool reloadAsset(const std::string &fileName); + //! Reloads all assets. + void reloadAssets(); + + //! Removes the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + bool removeAsset(const std::string &fileName) ; + //! Removes all assets. + void removeAssets(); + + //! Creates a new MeshProcessor. + //! @note For internal use only! + static AssetProcessor* createProcessor(AssetGroup *parent); + +private: + + // Private methods + bool loadAsset(const std::string &fileName); + void loadAssets(); + + // Private members + std::map<std::string, IAnimatedMesh*> mMeshes; + + bool mIsReloading; + +}; + +#endif + Added: trunk/src/assets/processors.cpp =================================================================== --- trunk/src/assets/processors.cpp (rev 0) +++ trunk/src/assets/processors.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -0,0 +1,30 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: processors.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Implements global functions regarding AssetProcessors. +// +// 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 "processors.h" +#include "../core/GameManager.h" + +// Registers all available AssetProcessor factories. +void registerProcessorFactories() +{ + // Get pointer to the AssetManager. + AssetManager *pAssetMgr = GameManager::Instance()->getAssetManager(); + + // Register factories. + pAssetMgr->registerProcessorFactory("meshes", MeshProcessor::createProcessor); +} + +// End of File Added: trunk/src/assets/processors.h =================================================================== --- trunk/src/assets/processors.h (rev 0) +++ trunk/src/assets/processors.h 2009-08-19 11:59:39 UTC (rev 110) @@ -0,0 +1,29 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: processors.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Header file with all AssetProcessors. +// +// 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 __PROCESSORS_H__ +#define __PROCESSORS_H__ + +// Include files +#include "MeshProcessor.h" + + +// Functions +//! Registers all available AssetProcessor factories. +extern void registerProcessorFactories(); + +#endif + + Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -162,7 +162,8 @@ assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); // Get mesh. - mesh = assets->getMesh(fileName); + MeshProcessor *processor = static_cast<MeshProcessor*>(assets->getAssetProcessor("meshes")); + mesh = processor->getMesh(fileName); if(mesh) { @@ -212,7 +213,8 @@ assets->disconnectEventSignal(std::string("meshes/") + mShadowVolumeMeshFileName, this); // Get mesh. - mesh = assets->getMesh(fileName); + MeshProcessor *processor = static_cast<MeshProcessor*>(assets->getAssetProcessor("meshes")); + mesh = processor->getMesh(fileName); if(mesh) { Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/components/scene/MeshComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -97,7 +97,8 @@ assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); // Get mesh. - mesh = assets->getMesh(fileName); + MeshProcessor *processor = static_cast<MeshProcessor*>(assets->getAssetProcessor("meshes")); + mesh = processor->getMesh(fileName); if(mesh) { Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -91,7 +91,8 @@ assets->disconnectEventSignal(std::string("meshes/") + mMeshFileName, this); // Get mesh. - mesh = assets->getMesh(fileName); + MeshProcessor *processor = static_cast<MeshProcessor*>(assets->getAssetProcessor("meshes")); + mesh = processor->getMesh(fileName); if(mesh) { Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/core/AssetGroup.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -42,6 +42,7 @@ // Initialises the AssetGroup. void AssetGroup::init() { + GameManager::Instance()->getAssetManager()->getAssetProcessors(this, mAssetProcessors); loadAssets(); } @@ -69,11 +70,33 @@ return mBaseDir; } +// Gets the AssetProcessor with the given base name. +AssetProcessor* AssetGroup::getAssetProcessor(const std::string &baseName) +{ + // Try to find the AssetProcessor. + vector<AssetProcessor*>::iterator it; + + for(it = mAssetProcessors.begin(); it != mAssetProcessors.end(); it++) + { + AssetProcessor *processor = *it; + + if(processor->getBaseName() == baseName) + return processor; + } + + // We didn't find the AssetProcessor and thus return a NULL value. + return NULL; +} + // Loads the meshes associated with this asset group. void AssetGroup::loadAssets() { + vector<AssetProcessor*>::iterator it; + + for(it = mAssetProcessors.begin(); it != mAssetProcessors.end(); it++) + (*it)->reloadAssets(); + loadHeightMaps(); - loadMeshes(); #ifdef __COMPILE_WITH_ANGELSCRIPT__ loadScripts(); #endif // __COMPILE_WITH_ANGELSCRIPT__ @@ -195,102 +218,6 @@ fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); } -// 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) - { - // 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. - fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); - - return (mesh) ? true : false; -} - -// 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. - std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); - - if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) - return; - - 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 = (fileList->getFileName(i)).c_str(); - - if(fileName == "..") - continue; - - // Load the mesh. - IAnimatedMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); - - 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. - fileList->drop(); - - fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); -} - #ifdef __COMPILE_WITH_ANGELSCRIPT__ // Loads the script with the given filename. @@ -613,17 +540,6 @@ return NULL; } -// Gets the mesh with the given filename. -IAnimatedMesh* AssetGroup::getMesh(const std::string &fileName) -{ - std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(fileName); - - if(it != mMeshes.end()) - return it->second; - - return NULL; -} - #ifdef __COMPILE_WITH_ANGELSCRIPT__ // Gets the script with the given filename. Script* AssetGroup::getScript(const std::string &fileName) @@ -688,15 +604,22 @@ std::string assetName = name.substr(pos+1, name.size()-pos); // Reload the asset. - if(assetType == "heightmaps") + vector<AssetProcessor*>::iterator it; + + for(it = mAssetProcessors.begin(); it != mAssetProcessors.end(); it++) { - if(reloadHeightMap(assetName)) - return true; + AssetProcessor *processor = *it; + + if(processor->getBaseName() == assetType) + { + processor->reloadAsset(assetName); + break; + } } - else if(assetType == "meshes") + if(assetType == "heightmaps") { - if(reloadMesh(assetName)) + if(reloadHeightMap(assetName)) return true; } @@ -754,30 +677,6 @@ mIsReloading = false; } -// Reloads the mesh with the given filename. -bool AssetGroup::reloadMesh(const std::string &fileName) -{ - mIsReloading = true; - - removeMesh(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__ // Reloads the script with the given filename. @@ -881,15 +780,22 @@ std::string assetName = name.substr(pos+1, name.size()-pos); // Remove the asset. - if(assetType == "heightmaps") + vector<AssetProcessor*>::iterator it; + + for(it = mAssetProcessors.begin(); it != mAssetProcessors.end(); it++) { - if(removeHeightMap(assetName)) - return true; + AssetProcessor *processor = *it; + + if(processor->getBaseName() == assetType) + { + processor->removeAsset(assetName); + break; + } } - else if(assetType == "meshes") + if(assetType == "heightmaps") { - if(removeMesh(assetName)) + if(removeHeightMap(assetName)) return true; } @@ -923,7 +829,6 @@ void AssetGroup::removeAssets() { removeHeightMaps(); - removeMeshes(); #ifdef __COMPILE_WITH_ANGELSCRIPT__ removeScripts(); #endif // __COMPILE_WITH_ANGELSCRIPT__ @@ -989,94 +894,6 @@ mHeightMaps.clear(); } -// 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) - { - // Handle events. - if(!mIsReloading) - { - std::string slotName = std::string("meshes/") + it->first; - - emitEvent(slotName, NULL); - removeEventSlot(slotName); - } - - // Delete the mesh. - mesh->drop(); - 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 &fileName) -{ - // Try to find the given mesh. - std::map<std::string, IAnimatedMesh*>::iterator it = mMeshes.find(fileName); - - // Did we find the mesh? - if(it != mMeshes.end()) - { - // 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(); - mMeshes.erase(it); - - return true; - } - - // We didn't find the mesh. - else return false; -} - -// Removes all meshes from this asset group. -void AssetGroup::removeMeshes() -{ - // 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(); - } - - // Clear the mesh map. - mMeshes.clear(); -} - #ifdef __COMPILE_WITH_ANGELSCRIPT__ // Removes the given script. Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/core/AssetGroup.h 2009-08-19 11:59:39 UTC (rev 110) @@ -21,11 +21,16 @@ #include "HasEvents.h" #include "ReferenceCounted.h" +#include "AssetProcessor.h" + #ifdef __COMPILE_WITH_ANGELSCRIPT__ #include "../scripting/Script.h" #endif // __COMPILE_WITH_ANGELSCRIPT__ +// Forward declarations +class AssetProcessor; + // AssetGroup class //! Represents a collection of assets (meshes, textures, etc). class AssetGroup : public ReferenceCounted, public HasEvents @@ -53,13 +58,15 @@ //! Gets the base directory of the AssetGroup. const std::string& getBaseDir() const; + //! Gets the AssetProcessor with the given base name. + //! @param baseName Basename of the AssetProcessor. + //! @return Pointer to the AssetProcessor if found, else NULL. + AssetProcessor* getAssetProcessor(const std::string &baseName); + //! Gets the heightmap with the given filename. //! @param fileName Filename of the heightmap. //! @note Don't forget to drop the file as soon as you're done with it. IReadFile* getHeightMap(const std::string &fileName); - //! Gets the mesh with the given filename. - //! @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. @@ -89,12 +96,6 @@ //! Reloads all heightmaps in this asset group. void reloadHeightMaps(); - //! Reloads the mesh with the given filename. - //! @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. @@ -129,15 +130,6 @@ //! Removes all heightmaps in this asset group. void removeHeightMaps(); - //! Removes the given mesh. - //! @param mesh Mesh to remove. - bool removeMesh(IAnimatedMesh *mesh); - //! Removes the mesh with the given filename. - //! @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. @@ -193,7 +185,8 @@ std::string mName; std::string mBaseDir; - std::map<std::string, IAnimatedMesh*> mMeshes; + std::vector<AssetProcessor*> mAssetProcessors; + std::map<std::string, ITexture*> mTextures; std::map<std::string, std::pair<c8*, long> > mHeightMaps; #ifdef __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/core/AssetManager.cpp =================================================================== --- trunk/src/core/AssetManager.cpp 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/core/AssetManager.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -22,18 +22,17 @@ // AssetManager constructor. AssetManager::AssetManager() { - init(); } // AssetManager deconstructor. AssetManager::~AssetManager() { - clear(); } // Initialises the AssetManager. void AssetManager::init() { + registerProcessorFactories(); } // Clears the AssetManager. @@ -111,6 +110,55 @@ return NULL; } +// Stores new instances of asset processors in the given vector. +void AssetManager::getAssetProcessors(AssetGroup *group, + std::vector<AssetProcessor*> &assetProcessors) +{ + std::map<std::string, AssetProcessor* (*)(AssetGroup*)>::iterator it; + + for(it = mProcessorFactories.begin(); it != mProcessorFactories.end(); it++) + assetProcessors.push_back( (*(it->second))(group) ); +} + +// Registers a factory function for a AssetProcessor. +bool AssetManager::registerProcessorFactory(const std::string &name, + AssetProcessor* (*f)(AssetGroup*)) +{ + // Does a processor factory with the same name exist? + std::map<std::string, AssetProcessor* (*)(AssetGroup*)>::iterator it; + it = mProcessorFactories.find(name); + + if(it != mProcessorFactories.end()) + return false; + + // Add the processor factory to the map. + mProcessorFactories[name] = f; + return true; +} + +// Unregisters a factory function for a AssetProcessor. +bool AssetManager::unregisterProcessorFactory(const std::string &name) +{ + // Try to remove the processor factory. + std::map<std::string, AssetProcessor* (*)(AssetGroup*)>::iterator it; + it = mProcessorFactories.find(name); + + if(it != mProcessorFactories.end()) + { + mProcessorFactories.erase(it); + return true; + } + + // We couldn't find the factory and thus couldn't remove it. + return false; +} + +// Unregisters all AssetProcessor factory functions. +void AssetManager::unregisterProcessorFactories() +{ + mProcessorFactories.clear(); +} + // Removes all AssetGroups from this AssetManager. void AssetManager::removeAssetGroups() { Modified: trunk/src/core/AssetManager.h =================================================================== --- trunk/src/core/AssetManager.h 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/core/AssetManager.h 2009-08-19 11:59:39 UTC (rev 110) @@ -19,15 +19,21 @@ // Include files #include "../dependencies.h" #include "AssetGroup.h" +#include "AssetProcessor.h" +#include "../assets/processors.h" + // Forward declarations class AssetGroup; +class AssetProcessor; // AssetManager class //! The AssetManager class manages the AssetGroups that are being used by the framework. class AssetManager { + friend class AssetGroup; + public: // Initialisation and deinitialisation @@ -67,6 +73,15 @@ //! @return Pointer to the AssetGroup if found, else NULL. AssetGroup* getAssetGroup(const std::string &name); + //! Registers an AssetProcessor factory function. + //! @return True if addition was succesful, false if addition was a failure. + bool registerProcessorFactory(const std::string &name, AssetProcessor* (*f)(AssetGroup*)); + //! Unregisters an AssetProcessor factory function. + //! @return True if removal was successful, false if removal was a failure. + bool unregisterProcessorFactory(const std::string &name); + //! Unregisters all AssetProcessor factory functions. + void unregisterProcessorFactories(); + //! Removes all AssetGroups from the AssetManager. void removeAssetGroups(); //! Removes the given AssetGroup. @@ -84,8 +99,12 @@ private: + // Private methods + void getAssetProcessors(AssetGroup *group, std::vector<AssetProcessor*> &assetProcessors); + // Normal members std::vector<AssetGroup*> mGroups; + std::map<std::string, AssetProcessor* (*)(AssetGroup*)> mProcessorFactories; }; Added: trunk/src/core/AssetProcessor.cpp =================================================================== --- trunk/src/core/AssetProcessor.cpp (rev 0) +++ trunk/src/core/AssetProcessor.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -0,0 +1,51 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: AssetProcessor.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : The AssetProcessor class is responsible for processing all +// assets in a sub-directory of an AssetGroup. Behaviour for +// specific assets is implemented by deriving from the +// AssetProcessor 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 "AssetProcessor.h" + + +// AssetProcessor class +// AssetProcessor constructor. +AssetProcessor::AssetProcessor(AssetGroup *parent, const std::string &baseName) +: pParent(parent), mBaseName(baseName) +{ + if(pParent != NULL) + pParent->grab(); +} + +// AssetProcessor deconstructor. +AssetProcessor::~AssetProcessor() +{ + if(pParent != NULL) + pParent->drop(); +} + +// Returns the base name. +const std::string& AssetProcessor::getBaseName() const +{ + return mBaseName; +} + +// Gets the parent of this processor. +AssetGroup* AssetProcessor::getParent() const +{ + return pParent; +} + +// End of File Added: trunk/src/core/AssetProcessor.h =================================================================== --- trunk/src/core/AssetProcessor.h (rev 0) +++ trunk/src/core/AssetProcessor.h 2009-08-19 11:59:39 UTC (rev 110) @@ -0,0 +1,70 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: AssetProcessor.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the AssetProcessor 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 __ASSETPROCESSOR_H__ +#define __ASSETPROCESSOR_H__ + +// Include files +#include "../dependencies.h" +#include "ReferenceCounted.h" +#include "AssetGroup.h" + +// Forward declarations +class AssetGroup; + + +// AssetProcessor class +//! The AssetProcessor class is responsible for processing all assets in a sub-directory of an +//! AssetGroup. Behaviour for specific assets is implemented by deriving from the AssetProcessor +//! class. +class AssetProcessor : public ReferenceCounted +{ +public: + + // Initialisation and deinitialisation + //! Constructor + AssetProcessor(AssetGroup *parent, const std::string &baseName); + //! Deconstructor + ~AssetProcessor(); + + // Public methods + //! Returns the base name. + const std::string& getBaseName() const; + //! Gets the parent of this processor. + AssetGroup* getParent() const; + + //! Reloads the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + virtual bool reloadAsset(const std::string &fileName) = 0; + //! Reloads all assets. + virtual void reloadAssets() = 0; + + //! Removes the asset with the given filename. + //! @param fileName Filename of the asset. + //! @return True on succesful removal, false otherwise. + virtual bool removeAsset(const std::string &fileName) = 0; + //! Removes all assets. + virtual void removeAssets() = 0; + +protected: + + //! Parent of this processor. + AssetGroup *pParent; + //! The base name is the name (i.e. meshes) of the directory that this processor will process. + std::string mBaseName; +}; + +#endif Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/core/GameManager.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -74,6 +74,8 @@ // Initialise subsystems of the framework (stage 2); pAssetManager = new AssetManager(); + pAssetManager->init(); + pEntityManager = new EntityManager(); #ifdef __COMPILE_WITH_SFML_AUDIO__ @@ -141,9 +143,12 @@ delete pSoundManager; #endif // __COMPILE_WITH_SFML_AUDIO__ + delete pEntityManager; + + pAssetManager->clear(); + delete pAssetManager; + delete pEventManager; - delete pAssetManager; - delete pEntityManager; delete pDataStore; // Clean up Irrlicht. Modified: trunk/src/game/InitState.cpp =================================================================== --- trunk/src/game/InitState.cpp 2009-08-18 19:11:50 UTC (rev 109) +++ trunk/src/game/InitState.cpp 2009-08-19 11:59:39 UTC (rev 110) @@ -21,6 +21,7 @@ #include "InitState.h" #include "../core/GameManager.h" +#include "../assets/MeshProcessor.h" // InitState class // InitState constructor. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-18 19:12:08
|
Revision: 109 http://sirrf.svn.sourceforge.net/sirrf/?rev=109&view=rev Author: zccdark203 Date: 2009-08-18 19:11:50 +0000 (Tue, 18 Aug 2009) Log Message: ----------- Started with the final (in terms of v0.2.0) implementation of parsing XML-based entity files. Modified Paths: -------------- trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-08-17 17:36:43 UTC (rev 108) +++ trunk/src/core/Entity.cpp 2009-08-18 19:11:50 UTC (rev 109) @@ -189,6 +189,132 @@ return mRotation; } +// Loads Entity data from a XML file. +bool Entity::loadXML(const std::string &fileName) +{ + // 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 false; + + // Open the file. + IXMLReader *file = fileSystem->createXMLReader(fileName.c_str()); + + bool result = loadXML(file); + + file->drop(); + return result; +} + +// Loads Entity data from a XML file through a IXMLReader object. +bool Entity::loadXML(IXMLReader *file) +{ + // Did we get a valid pointer? + if(!file) + return false; + + // Read from the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <Entity> + if(stringw("Entity") == file->getNodeName()) + { + stringc parentFile = file->getAttributeValue(L"parent"); + + // Check the value we retrieved. + if(parentFile != "") + { + // Try to get a pointer to the parent. + Entity *retrievedParent = NULL; + + //if(pAssetGroup != NULL) + // retrievedParent = pAssetGroup->getEntity(parentFile.c_str()); + + //else + retrievedParent = GameManager::Instance()->getEntityManager()->getEntity(parentFile.c_str()); + + if(retrievedParent == NULL && pAssetGroup == NULL) + { + if(GameManager::Instance()->getEntityManager()->getEntity(mName) != NULL) + { + retrievedParent = GameManager::Instance()->getEntityManager()-> + createEntityFromXML(parentFile.c_str()); + } + + else + { + retrievedParent = GameManager::Instance()->getEntityManager()-> + createEntityFromXML(parentFile.c_str(), NULL, NULL, false); + } + } + + // Set parent, if available. + if(retrievedParent != NULL) + setParent(retrievedParent); + } + } + + // <absolutePosition> + if(stringw("absolutePosition") == file->getNodeName()) + { + setAbsolutePosition(vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") )); + } + + // <position> + else if(stringw("position") == file->getNodeName()) + { + setPosition(vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") )); + } + + // <absoluteRotation> + else if(stringw("absoluteRotation") == file->getNodeName()) + { + setAbsoluteRotation(vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") )); + } + + // <rotation> + else if(stringw("rotation") == file->getNodeName()) + { + setRotation(vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") )); + } + + // <Components> + else if(stringw("Components") == file->getNodeName()) + parseComponentsXML(file, this); + + break; + + case io::EXN_ELEMENT_END: + + // </Entityr> + if(stringw("Entity") == file->getNodeName()) + return true; + + break; + + default: + break; + } + } + + // The code shouldn't get here. + return false; +} + // Removes all children. void Entity::removeChildren() { Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-08-17 17:36:43 UTC (rev 108) +++ trunk/src/core/Entity.h 2009-08-18 19:11:50 UTC (rev 109) @@ -32,7 +32,7 @@ //! //! <b>XML:</b> //! \code -//! <Entity name=""> +//! <Entity name="" parent=""> //! <!-- Properties --> //! <Components> //! <!-- Components --> @@ -98,6 +98,13 @@ //! Gets the rotation of the entity. const vector3df& getRotation() const; + //! Loads Entity data from a XML file. + //! @param fileName Filename of the file where the data is retrieved from. + bool loadXML(const std::string &fileName); + //! Loads Entity data from a XML file through a IXMLReader object. + //! @param file Pointer to the IXMLReader object that will be used. + bool loadXML(IXMLReader *file); + //! Removes all children. void removeChildren(); //! Removes all components. Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-08-17 17:36:43 UTC (rev 108) +++ trunk/src/core/EntityManager.cpp 2009-08-18 19:11:50 UTC (rev 109) @@ -91,33 +91,9 @@ return entity; } -// Gets the entity with the given ID. -Entity* EntityManager::getEntity(const u32 id) +// Creates an entity from the given XML file. +Entity* EntityManager::createEntityFromXML(const std::string &fileName, Entity *parent, AssetGroup *assets, bool grab) { - for(u32 i = 0; i < mEntities.size(); i++) - { - if(mEntities[i]->getID() == id) - return mEntities[i]; - } - - return NULL; -} - -// Gets the entity with the given name. -Entity* EntityManager::getEntity(const std::string &name) -{ - for(u32 i = 0; i < mEntities.size(); i++) - { - if(mEntities[i]->getName() == name) - return mEntities[i]; - } - - return NULL; -} - -// Loads an entity from the given file. -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(); @@ -128,8 +104,15 @@ // Open the file. IXMLReader *file = fileSystem->createXMLReader(fileName.c_str()); + return createEntityFromXML(file, parent, assets, grab); +} + +// Creates an Entity from a XML file through a IXMLReader object. +Entity* EntityManager::createEntityFromXML(IXMLReader *file, Entity *parent, AssetGroup *assets, bool grab) +{ + // Did we get a valid pointer? if(!file) - return false; + return NULL; // Read from the file. Entity *entity = NULL; @@ -144,8 +127,44 @@ // <Entity> if(stringw("Entity") == file->getNodeName()) { - stringc name = file->getAttributeValue(L"name"); - entity = new Entity(name.c_str(), NULL, assets); + // Initialisation + stringc name = file->getAttributeValue(L"name"); + + if(grab && getEntity(name.c_str()) != NULL) + return NULL; + + entity = new Entity(name.c_str(), parent, assets); + + // If we don't have a parent, we try to load the one specified in the file. + if(parent == NULL) + { + // Get the filename of the parent. + stringc parentFile = file->getAttributeValue(L"parent"); + + // Check the value we retrieved. + if(parentFile != "") + { + // Try to get a pointer to the parent. + Entity *retrievedParent = NULL; + + //if(assets != NULL) + // retrievedParent = assets->getEntity(parentFile.c_str()); + + //else + retrievedParent = GameManager::Instance()->getEntityManager() + ->getEntity(parentFile.c_str()); + + if(retrievedParent == NULL && assets == NULL) + { + parent = GameManager::Instance()->getEntityManager()-> + createEntityFromXML(parentFile.c_str(), NULL, NULL, grab); + } + + // Set parent, if available. + if(retrievedParent != NULL) + entity->setParent(retrievedParent); + } + } } // Do we already have an entity? @@ -214,6 +233,30 @@ return entity; } +// Gets the entity with the given ID. +Entity* EntityManager::getEntity(const u32 id) +{ + for(u32 i = 0; i < mEntities.size(); i++) + { + if(mEntities[i]->getID() == id) + return mEntities[i]; + } + + return NULL; +} + +// Gets the entity with the given name. +Entity* EntityManager::getEntity(const std::string &name) +{ + for(u32 i = 0; i < mEntities.size(); i++) + { + if(mEntities[i]->getName() == name) + return mEntities[i]; + } + + return NULL; +} + // Removes all entities. void EntityManager::removeEntities() { Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-08-17 17:36:43 UTC (rev 108) +++ trunk/src/core/EntityManager.h 2009-08-18 19:11:50 UTC (rev 109) @@ -61,6 +61,24 @@ //! @param parent Parent of the entity that is going to be created. //! @return Pointer to the Entity on success, NULL on failure. Entity* createEntity(const std::string &name, Entity *parent = NULL); + //! Creates an Entity from the given XML file. + //! @param fileName Filename of the entity. + //! @param parent Parent of the entity that is going to be created. Will override + //! parent mentioned in the XML file. + //! @param assets 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* createEntityFromXML(const std::string &fileName, Entity *parent = NULL, + AssetGroup *assets = NULL, bool grab = true); + //! Creates an Entity from a XML file through a IXMLReader object. + //! @param file Pointer to the IXMLReader object that will be used. + //! @param parent Parent of the entity that is going to be created. Will override + //! parent mentioned in the XML file. + //! @param assets 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* createEntityFromXML(IXMLReader *file, Entity *parent = NULL, AssetGroup *assets = NULL, + bool grab = true); //! Gets the Entity with the given ID. //! @return Pointer to the Entity if found, else NULL. @@ -69,13 +87,6 @@ //! @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 assets 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, AssetGroup *assets = NULL, 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-08-17 17:36:51
|
Revision: 108 http://sirrf.svn.sourceforge.net/sirrf/?rev=108&view=rev Author: zccdark203 Date: 2009-08-17 17:36:43 +0000 (Mon, 17 Aug 2009) Log Message: ----------- Restored original compile flags (__COMPILE_WITH_SFML_AUDIO__ was disabled). Also, restored the compile flag for stdscriptstring.*. Modified Paths: -------------- trunk/src/config.h trunk/src/main.cpp trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp trunk/src/scripting/vendor/angelscript/scriptstdstring.h Modified: trunk/src/config.h =================================================================== --- trunk/src/config.h 2009-08-16 17:37:28 UTC (rev 107) +++ trunk/src/config.h 2009-08-17 17:36:43 UTC (rev 108) @@ -17,7 +17,7 @@ #define __CONFIG_H__ //! Define __COMPILE_WITH_SFML_AUDIO__ to compile with SFML-Audio. -//#define __COMPILE_WITH_SFML_AUDIO__ +#define __COMPILE_WITH_SFML_AUDIO__ //! Define __COMPILE_WITH_ANGELSCRIPT__ to compile with AngelScript. #define __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2009-08-16 17:37:28 UTC (rev 107) +++ trunk/src/main.cpp 2009-08-17 17:36:43 UTC (rev 108) @@ -43,8 +43,8 @@ #pragma comment(linker, "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") #elif (defined(_SIRRF_SHOWCONSOLE) || defined(_DEBUG)) #pragma comment(linker, "/SUBSYSTEM:CONSOLE") - #endif -#endif + #endif +#endif // Main function //! Main entry point to the application. @@ -60,3 +60,5 @@ return 0; } + +// End of File Modified: trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp =================================================================== --- trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp 2009-08-16 17:37:28 UTC (rev 107) +++ trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp 2009-08-17 17:36:43 UTC (rev 108) @@ -1,3 +1,6 @@ +#include "../../../config.h" +#ifdef __COMPILE_WITH_ANGELSCRIPT__ + #include <assert.h> #include <sstream> #include "scriptstdstring.h" @@ -122,7 +125,7 @@ } } -void AssignInt2StringGeneric(asIScriptGeneric *gen) +void AssignInt2StringGeneric(asIScriptGeneric *gen) { int *a = static_cast<int*>(gen->GetAddressOfArg(0)); string *self = static_cast<string*>(gen->GetObject()); @@ -132,7 +135,7 @@ gen->SetReturnAddress(self); } -void AssignUInt2StringGeneric(asIScriptGeneric *gen) +void AssignUInt2StringGeneric(asIScriptGeneric *gen) { unsigned int *a = static_cast<unsigned int*>(gen->GetAddressOfArg(0)); string *self = static_cast<string*>(gen->GetObject()); @@ -142,7 +145,7 @@ gen->SetReturnAddress(self); } -void AssignDouble2StringGeneric(asIScriptGeneric *gen) +void AssignDouble2StringGeneric(asIScriptGeneric *gen) { double *a = static_cast<double*>(gen->GetAddressOfArg(0)); string *self = static_cast<string*>(gen->GetObject()); @@ -481,3 +484,4 @@ +#endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/vendor/angelscript/scriptstdstring.h =================================================================== --- trunk/src/scripting/vendor/angelscript/scriptstdstring.h 2009-08-16 17:37:28 UTC (rev 107) +++ trunk/src/scripting/vendor/angelscript/scriptstdstring.h 2009-08-17 17:36:43 UTC (rev 108) @@ -3,13 +3,16 @@ // // This function registers the std::string type with AngelScript to be used as the default string type. // -// The string type is registered as a value type, thus may have performance issues if a lot of +// The string type is registered as a value type, thus may have performance issues if a lot of // string operations are performed in the script. However, for relatively few operations, this should // not cause any problem for most applications. // #ifndef SCRIPTSTDSTRING_H #define SCRIPTSTDSTRING_H + +#include "../../../config.h" +#ifdef __COMPILE_WITH_ANGELSCRIPT__ #include <angelscript.h> #include <string> @@ -19,5 +22,7 @@ void RegisterStdString(asIScriptEngine *engine); END_AS_NAMESPACE + +#endif // __COPILE_WITH_ANGELSCRIPT__ #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fuz...@us...> - 2009-08-16 17:37:38
|
Revision: 107 http://sirrf.svn.sourceforge.net/sirrf/?rev=107&view=rev Author: fuzzyspo0n Date: 2009-08-16 17:37:28 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Fixed some minor bugs in the windows build : a) AssetGroup was iterating the mSounds instead of mHeightMaps array b) main.cpp was broken by the gcc fix (hopefully this is a real fix again:) c) updated the msvc project with new files etc Modified Paths: -------------- trunk/build/msvc2008/sirrf.vcproj trunk/src/config.h trunk/src/core/AssetGroup.cpp trunk/src/main.cpp Modified: trunk/build/msvc2008/sirrf.vcproj =================================================================== --- trunk/build/msvc2008/sirrf.vcproj 2009-08-16 15:42:42 UTC (rev 106) +++ trunk/build/msvc2008/sirrf.vcproj 2009-08-16 17:37:28 UTC (rev 107) @@ -137,7 +137,7 @@ /> <Tool Name="VCLinkerTool" - AdditionalDependencies="irrlicht.lib" + AdditionalDependencies="irrlicht.lib angelscript.lib" OutputFile="../../bin/$(ProjectName).exe" LinkIncremental="1" AdditionalLibraryDirectories="" @@ -412,6 +412,14 @@ > </File> <File + RelativePath="..\..\src\core\HasEvents.cpp" + > + </File> + <File + RelativePath="..\..\src\core\HasEvents.h" + > + </File> + <File RelativePath="..\..\src\core\ReferenceCounted.cpp" > </File> @@ -424,9 +432,13 @@ Name="game" > <File - RelativePath="..\..\src\game\readme.txt" + RelativePath="..\..\src\game\InitState.cpp" > </File> + <File + RelativePath="..\..\src\game\InitState.h" + > + </File> </Filter> <Filter Name="scripting" Modified: trunk/src/config.h =================================================================== --- trunk/src/config.h 2009-08-16 15:42:42 UTC (rev 106) +++ trunk/src/config.h 2009-08-16 17:37:28 UTC (rev 107) @@ -17,7 +17,7 @@ #define __CONFIG_H__ //! Define __COMPILE_WITH_SFML_AUDIO__ to compile with SFML-Audio. -#define __COMPILE_WITH_SFML_AUDIO__ +//#define __COMPILE_WITH_SFML_AUDIO__ //! Define __COMPILE_WITH_ANGELSCRIPT__ to compile with AngelScript. #define __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-16 15:42:42 UTC (rev 106) +++ trunk/src/core/AssetGroup.cpp 2009-08-16 17:37:28 UTC (rev 107) @@ -600,7 +600,7 @@ { std::map<std::string, std::pair<c8*, long> >::iterator it = mHeightMaps.find(fileName); - if(it != mSounds.end()) + if(it != mHeightMaps.end()) { c8 *fBuffer = (it->second).first; s32 fSize = static_cast<s32>((it->second).second); Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2009-08-16 15:42:42 UTC (rev 106) +++ trunk/src/main.cpp 2009-08-16 17:37:28 UTC (rev 107) @@ -39,12 +39,12 @@ #define _SIRRF_SHOWCONSOLE #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 + #if((!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: <zcc...@us...> - 2009-08-16 15:42:55
|
Revision: 106 http://sirrf.svn.sourceforge.net/sirrf/?rev=106&view=rev Author: zccdark203 Date: 2009-08-16 15:42:42 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Updated to AngelScript 2.17.0. Please note that AngelScript 2.17.0 is NOT compatible with < AngelScript 2.16.2. Modified Paths: -------------- trunk/CHANGES trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp trunk/src/scripting/components/scene/asBillboardComponent.cpp trunk/src/scripting/components/scene/asBillboardComponent.h 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/asMeshComponent.h 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/asSceneComponent.h 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/asEntity.cpp trunk/src/scripting/core/asEntityComponent.cpp trunk/src/scripting/core/asEntityComponent.h trunk/src/scripting/core/asGameState.cpp trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp trunk/src/scripting/vendor/angelscript/scriptstdstring.h trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp trunk/src/scripting/vendor/irrlicht/asDimension2d.cpp trunk/src/scripting/vendor/irrlicht/asIrrHelper.h trunk/src/scripting/vendor/irrlicht/asLine2d.cpp trunk/src/scripting/vendor/irrlicht/asLine3d.cpp trunk/src/scripting/vendor/irrlicht/asMatrix4.cpp trunk/src/scripting/vendor/irrlicht/asRect.cpp trunk/src/scripting/vendor/irrlicht/asSColor.cpp trunk/src/scripting/vendor/irrlicht/asVector2d.cpp trunk/src/scripting/vendor/irrlicht/asVector3d.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/CHANGES 2009-08-16 15:42:42 UTC (rev 106) @@ -2,6 +2,8 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Updated to AngelScript 2.17.0. + * Mouse, Key, GUI events emitted by the EventManager now pass the appropriate event structure (SMouseInput, SKeyInput and SGUIEvent) as a parameter. Modified: trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -58,9 +58,8 @@ (Entity*, const std::string&, const vector3df&), AnimatedMeshComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("AnimatedMeshComponent", asBEHAVE_ASSIGNMENT, "AnimatedMeshComponent&" \ - " f(const AnimatedMeshComponent &in)", - asFUNCTION(assignT<AnimatedMeshComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "AnimatedMeshComponent& opAssign(const AnimatedMeshComponent &in)", + asFUNCTION(assignT<AnimatedMeshComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind AnimatedMeshComponent class functions. r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void animate()", Modified: trunk/src/scripting/components/scene/asBillboardComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asBillboardComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asBillboardComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -56,9 +56,8 @@ const SColor&, const SColor&), BillboardComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("BillboardComponent", asBEHAVE_ASSIGNMENT, "BillboardComponent& " \ - "f(const BillboardComponent &in)", - asFUNCTION(assignT<BillboardComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("BillboardComponent", "BillboardComponent& opAssign(const BillboardComponent &in)", + asFUNCTION(assignT<BillboardComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/components/scene/asBillboardComponent.h =================================================================== --- trunk/src/scripting/components/scene/asBillboardComponent.h 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asBillboardComponent.h 2009-08-16 15:42:42 UTC (rev 106) @@ -41,10 +41,10 @@ bindSceneComponentBase<T>(engine, type); // Set common behaviour. - r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, std::string(sType + "@ f(BillboardComponent @)").c_str(), - asFUNCTION((asRefCast<BillboardComponent,T>)), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, std::string("BillboardComponent@ f(" + sType +" @)").c_str(), - asFUNCTION((asRefCast<T,BillboardComponent>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("BillboardComponent", asBEHAVE_REF_CAST, std::string(sType + "@ f()").c_str(), + asFUNCTION((asRefCast<BillboardComponent,T>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour(type, asBEHAVE_IMPLICIT_REF_CAST, std::string("BillboardComponent@ f()").c_str(), + asFUNCTION((asRefCast<T,BillboardComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); // Bind common class functions. r = engine->RegisterObjectMethod(type, "void getColor(SColor &out, SColor &out)", Modified: trunk/src/scripting/components/scene/asCameraComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asCameraComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asCameraComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -56,9 +56,8 @@ "const vector3df &in)", asFUNCTIONPR(createCameraComponent, (Entity*, const vector3df&), CameraComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("CameraComponent", asBEHAVE_ASSIGNMENT, "CameraComponent& " \ - "f(const CameraComponent &in)", - asFUNCTION(assignT<CameraComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "CameraComponent& opAssign(const CameraComponent &in)", + asFUNCTION(assignT<CameraComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind CameraComponent class functions. r = engine->RegisterObjectMethod("CameraComponent", "void bindTargetAndRotation(bool)", Modified: trunk/src/scripting/components/scene/asImageComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asImageComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asImageComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -53,10 +53,10 @@ bindEntityComponentBase<ImageComponent>(engine, "ImageComponent"); // Set ImageComponent behaviour. - r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "ImageComponent@ f(EntityComponent @)", - asFUNCTION((asRefCast<EntityComponent,ImageComponent>)), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f(ImageComponent @)", - asFUNCTION((asRefCast<ImageComponent,EntityComponent>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, "ImageComponent@ f()", + asFUNCTION((asRefCast<EntityComponent,ImageComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f()", + asFUNCTION((asRefCast<ImageComponent,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("ImageComponent", asBEHAVE_FACTORY, "ImageComponent@ f(Entity @+)", asFUNCTIONPR(createImageComponent, (Entity*), ImageComponent*), asCALL_CDECL); assert(r >= 0); @@ -67,8 +67,8 @@ 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)", - asFUNCTION(assignT<ImageComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("ImageComponent", "ImageComponent& opAssign(const ImageComponent &in)", + asFUNCTION(assignT<ImageComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind ImageComponent class functions. r = engine->RegisterObjectMethod("ImageComponent", "void setAlphaColor(const SColor &in)", Modified: trunk/src/scripting/components/scene/asLightComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asLightComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asLightComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -57,8 +57,8 @@ (Entity*, const SColor &color, f32), LightComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("LightComponent", asBEHAVE_ASSIGNMENT, "LightComponent& f(const LightComponent &in)", - asFUNCTION(assignT<LightComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("LightComponent", "LightComponent& opAssign(const LightComponent &in)", + asFUNCTION(assignT<LightComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind LightComponent class functions. r = engine->RegisterObjectMethod("LightComponent", "bool getCastShadow()", Modified: trunk/src/scripting/components/scene/asMeshComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asMeshComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asMeshComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -53,8 +53,8 @@ "const vector3df &in)", asFUNCTIONPR(createMeshComponent, (Entity*, const std::string&, const vector3df&), MeshComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_ASSIGNMENT, "MeshComponent& f(const MeshComponent &in)", - asFUNCTION(assignT<MeshComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("MeshComponent", "MeshComponent& opAssign(const MeshComponent &in)", + asFUNCTION(assignT<MeshComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/components/scene/asMeshComponent.h =================================================================== --- trunk/src/scripting/components/scene/asMeshComponent.h 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asMeshComponent.h 2009-08-16 15:42:42 UTC (rev 106) @@ -41,10 +41,10 @@ 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 ); + r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_REF_CAST, std::string(sType + "@ f()").c_str(), + asFUNCTION((asRefCast<MeshComponent,T>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour(type, asBEHAVE_IMPLICIT_REF_CAST, std::string("MeshComponent@ f()").c_str(), + asFUNCTION((asRefCast<T,MeshComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); // Bind common class functions. r = engine->RegisterObjectMethod(type, "void setMesh(const string &in)", Modified: trunk/src/scripting/components/scene/asOctTreeComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asOctTreeComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asOctTreeComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -68,9 +68,8 @@ asFUNCTIONPR(createOctTreeComponent, (Entity*, const std::string&, s32), OctTreeComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("OctTreeComponent", asBEHAVE_ASSIGNMENT, "OctTreeComponent& " \ - "f(const OctTreeComponent &in)", - asFUNCTION(assignT<OctTreeComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("OctTreeComponent", "OctTreeComponent& opAssign(const OctTreeComponent &in)", + asFUNCTION(assignT<OctTreeComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/components/scene/asParticleSysComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asParticleSysComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asParticleSysComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -47,9 +47,8 @@ "const vector3df &in)", asFUNCTIONPR(createParticleSysComponent, (Entity*, const vector3df&), ParticleSysComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("ParticleSysComponent", asBEHAVE_ASSIGNMENT, "ParticleSysComponent& " \ - "f(const ParticleSysComponent &in)", - asFUNCTION(assignT<ParticleSysComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "ParticleSysComponent& opAssign(const ParticleSysComponent &in)", + asFUNCTION(assignT<ParticleSysComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind ParticleSysComponent class methods. r = engine->RegisterObjectMethod("ParticleSysComponent", "void addAttractionAffector(const vector3df &in, f32, " \ Modified: trunk/src/scripting/components/scene/asSceneComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asSceneComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asSceneComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -44,7 +44,7 @@ asFUNCTIONPR(createSceneComponent, (Entity*), SceneComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("SceneComponent", asBEHAVE_ASSIGNMENT, "SceneComponent& f(const SceneComponent &in)", + r = engine->RegisterObjectMethod("SceneComponent", "SceneComponent& opAssign(const SceneComponent &in)", asFUNCTION(assignT<SceneComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); } Modified: trunk/src/scripting/components/scene/asSceneComponent.h =================================================================== --- trunk/src/scripting/components/scene/asSceneComponent.h 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asSceneComponent.h 2009-08-16 15:42:42 UTC (rev 106) @@ -43,10 +43,10 @@ bindEntityComponentBase<SceneComponent>(engine, type); // Set common behaviour. - r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, std::string(sType + "@ f(SceneComponent @)").c_str(), - asFUNCTION((asRefCast<SceneComponent,T>)), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, std::string("SceneComponent@ f(" + sType +" @)").c_str(), - asFUNCTION((asRefCast<T,SceneComponent>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("SceneComponent", asBEHAVE_REF_CAST, std::string(sType + "@ f()").c_str(), + asFUNCTION((asRefCast<SceneComponent,T>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour(type, asBEHAVE_IMPLICIT_REF_CAST, std::string("SceneComponent@ f()").c_str(), + asFUNCTION((asRefCast<T,SceneComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); // Bind common class functions. r = engine->RegisterObjectMethod(type, "void addCollisionResponseAnimator(const vector3df &in, " \ Modified: trunk/src/scripting/components/scene/asSkyBoxComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asSkyBoxComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asSkyBoxComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -62,9 +62,8 @@ const std::string&, const std::string&, const std::string&, const std::string&, const std::string&), SkyBoxComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("SkyBoxComponent", asBEHAVE_ASSIGNMENT, "SkyBoxComponent& " \ - "f(const SkyBoxComponent &in)", - asFUNCTION(assignT<SkyBoxComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("SkyBoxComponent", "SkyBoxComponent& opAssign(const SkyBoxComponent &in)", + asFUNCTION(assignT<SkyBoxComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind CameraComponent class functions. r = engine->RegisterObjectMethod("SkyBoxComponent", "void setTextures(const string &in, const string &in," \ Modified: trunk/src/scripting/components/scene/asSkyDome.cpp =================================================================== --- trunk/src/scripting/components/scene/asSkyDome.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asSkyDome.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -71,9 +71,8 @@ asFUNCTIONPR(createSkyDomeComponent, (Entity*, const std::string&, u32, u32, f32, f32, f32), SkyDomeComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_ASSIGNMENT, "SkyDomeComponent& " \ - "f(const SkyDomeComponent &in)", - asFUNCTION(assignT<SkyDomeComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("SkyDomeComponent", "SkyDomeComponent& opAssign(const SkyDomeComponent &in)", + asFUNCTION(assignT<SkyDomeComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/components/scene/asTerrainComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asTerrainComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asTerrainComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -60,9 +60,8 @@ const vector3df &, const SColor &, s32, s32), TerrainComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("TerrainComponent", asBEHAVE_ASSIGNMENT, "TerrainComponent& " \ - "f(const TerrainComponent &in)", - asFUNCTION(assignT<TerrainComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("TerrainComponent", "TerrainComponent& opAssign(const TerrainComponent &in)", + asFUNCTION(assignT<TerrainComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind TerrainComponent class functions. r = engine->RegisterObjectMethod("TerrainComponent", "const aabbox3df& getBoundingBox(s32, s32)", Modified: trunk/src/scripting/components/scene/asTextBillboardComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asTextBillboardComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/scene/asTextBillboardComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -64,9 +64,8 @@ const SColor&, const SColor&), TextBillboardComponent*), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("TextBillboardComponent", asBEHAVE_ASSIGNMENT, "TextBillboardComponent& " \ - "f(const TextBillboardComponent &in)", - asFUNCTION(assignT<TextBillboardComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("TextBillboardComponent", "TextBillboardComponent& opAssign(const TextBillboardComponent &in)", + asFUNCTION(assignT<TextBillboardComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind TextBillboardComponent class functions. r = engine->RegisterObjectMethod("TextBillboardComponent", "void setText(const string &in)", Modified: trunk/src/scripting/components/sound/asSoundListenerComponent.cpp =================================================================== --- trunk/src/scripting/components/sound/asSoundListenerComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/sound/asSoundListenerComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -44,19 +44,18 @@ bindEntityComponentBase<SoundListenerComponent>(engine, "SoundListenerComponent"); // Set SoundListenerComponent behaviour. - r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "SoundListenerComponent@ f(EntityComponent @)", - asFUNCTION((asRefCast<EntityComponent,SoundListenerComponent>)), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f(SoundListenerComponent @)", - asFUNCTION((asRefCast<SoundListenerComponent,EntityComponent>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, "SoundListenerComponent@ f()", + asFUNCTION((asRefCast<EntityComponent,SoundListenerComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f()", + asFUNCTION((asRefCast<SoundListenerComponent,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @+)", asFUNCTION(createSoundListenerComponent), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @+, bool)", asFUNCTION(createSoundListenerComponent), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_ASSIGNMENT, "SoundListenerComponent& " \ - "f(const SoundListenerComponent &in)", - asFUNCTION(assignT<SoundListenerComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundListenerComponent", "SoundListenerComponent& opAssign(const SoundListenerComponent &in)", + asFUNCTION(assignT<SoundListenerComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind SoundListenerComponent class functions. r = engine->RegisterObjectMethod("SoundListenerComponent", "bool getIsMainListener()", Modified: trunk/src/scripting/components/sound/asSoundSourceComponent.cpp =================================================================== --- trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -44,17 +44,16 @@ bindEntityComponentBase<SoundSourceComponent>(engine, "SoundSourceComponent"); // Set SoundSourceComponent behaviour. - r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "SoundSourceComponent@ f(EntityComponent @)", - asFUNCTION((asRefCast<EntityComponent,SoundSourceComponent>)), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f(SoundSourceComponent @)", - asFUNCTION((asRefCast<SoundSourceComponent,EntityComponent>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, "SoundSourceComponent@ f()", + asFUNCTION((asRefCast<EntityComponent,SoundSourceComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("SoundSourceComponent", asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f()", + asFUNCTION((asRefCast<SoundSourceComponent,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("SoundSourceComponent", asBEHAVE_FACTORY, "SoundSourceComponent@ f(Entity @+)", asFUNCTION(createSoundSourceComponent), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("SoundSourceComponent", asBEHAVE_ASSIGNMENT, "SoundSourceComponent& " \ - "f(const SoundSourceComponent &in)", - asFUNCTION(assignT<SoundSourceComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "SoundSourceComponent& opAssign(const SoundSourceComponent &in)", + asFUNCTION(assignT<SoundSourceComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind SoundSourceComponent class functions. r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadMusic(const string &in)", Modified: trunk/src/scripting/core/asDataStack.cpp =================================================================== --- trunk/src/scripting/core/asDataStack.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/core/asDataStack.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -69,8 +69,8 @@ r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_RELEASE, "void f()", asMETHOD(DataStack, drop), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_ASSIGNMENT, "DataStack& f(const DataStack &in)", - asFUNCTION(assignT<DataStack>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("DataStack", "DataStack& opAssign(const DataStack &in)", + asFUNCTION(assignT<DataStack>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind DataStack class functions. r = engine->RegisterObjectMethod("DataStack", "void init()", Modified: trunk/src/scripting/core/asEntity.cpp =================================================================== --- trunk/src/scripting/core/asEntity.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/core/asEntity.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -47,7 +47,7 @@ r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_RELEASE, "void f()", asMETHOD(Entity, drop), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_ASSIGNMENT, "Entity& f(const Entity &in)", + r = engine->RegisterObjectMethod("Entity", "Entity& opAssign(const Entity &in)", asFUNCTION(assignT<Entity>), asCALL_CDECL_OBJLAST); assert(r >= 0); // Bind Entity class functions. Modified: trunk/src/scripting/core/asEntityComponent.cpp =================================================================== --- trunk/src/scripting/core/asEntityComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/core/asEntityComponent.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -46,8 +46,8 @@ r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_FACTORY, "EntityComponent@ f(Entity @+)", asFUNCTION(createEntityComponent), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_ASSIGNMENT, "EntityComponent& f(const EntityComponent &in)", - asFUNCTION(assignT<EntityComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("EntityComponent", "EntityComponent& opAssign(const EntityComponent &in)", + asFUNCTION(assignT<EntityComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/core/asEntityComponent.h =================================================================== --- trunk/src/scripting/core/asEntityComponent.h 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/core/asEntityComponent.h 2009-08-16 15:42:42 UTC (rev 106) @@ -43,10 +43,10 @@ r = engine->RegisterObjectBehaviour(type, asBEHAVE_RELEASE, "void f()", asMETHOD(T, drop), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, std::string(sType + "@ f(EntityComponent @)").c_str(), - asFUNCTION((asRefCast<EntityComponent,T>)), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, std::string("EntityComponent@ f(" + sType +" @)").c_str(), - asFUNCTION((asRefCast<T,EntityComponent>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_REF_CAST, std::string(sType + "@ f()").c_str(), + asFUNCTION((asRefCast<EntityComponent,T>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectBehaviour(type, asBEHAVE_IMPLICIT_REF_CAST, std::string("EntityComponent@ f()").c_str(), + asFUNCTION((asRefCast<T,EntityComponent>)), asCALL_CDECL_OBJLAST); assert( r >= 0 ); // Bind common class functions. r = engine->RegisterObjectMethod(type, "u32 getID()", Modified: trunk/src/scripting/core/asGameState.cpp =================================================================== --- trunk/src/scripting/core/asGameState.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/core/asGameState.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -116,8 +116,8 @@ r = engine->RegisterObjectBehaviour("GameState", asBEHAVE_RELEASE, "void f()", asMETHOD(GameState, drop), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("GameState", asBEHAVE_ASSIGNMENT, "GameState& f(const GameState &in)", - asFUNCTION(assignT<GameState>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + r = engine->RegisterObjectMethod("GameState", "GameState& opAssign(const GameState &in)", + asFUNCTION(assignT<GameState>), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Bind GameState class functions. r = engine->RegisterObjectMethod("GameState", "void init()", Modified: trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp =================================================================== --- trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/vendor/angelscript/scriptstdstring.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -1,9 +1,7 @@ #include <assert.h> #include <sstream> #include "scriptstdstring.h" -#include <string.h> // strstr - -#ifdef __COMPILE_WITH_ANGELSCRIPT__ +#include <string.h> // strstr using namespace std; @@ -45,6 +43,23 @@ *(bool*)gen->GetAddressOfReturnLocation() = (*a == *b); } +static void StringEqualsGeneric(asIScriptGeneric * gen) { + string * a = static_cast<string *>(gen->GetObject()); + string * b = static_cast<string *>(gen->GetArgAddress(0)); + *(bool*)gen->GetAddressOfReturnLocation() = (*a == *b); +} + +static void StringCmpGeneric(asIScriptGeneric * gen) { + string * a = static_cast<string *>(gen->GetObject()); + string * b = static_cast<string *>(gen->GetArgAddress(0)); + + int cmp = 0; + if( *a < *b ) cmp = -1; + else if( *a > *b ) cmp = 1; + + *(int*)gen->GetAddressOfReturnLocation() = cmp; +} + static void StringNotEqualGeneric(asIScriptGeneric * gen) { string * a = static_cast<string *>(gen->GetArgAddress(0)); string * b = static_cast<string *>(gen->GetArgAddress(1)); @@ -76,8 +91,8 @@ } static void StringAddGeneric(asIScriptGeneric * gen) { - string * a = static_cast<string *>(gen->GetArgAddress(0)); - string * b = static_cast<string *>(gen->GetArgAddress(1)); + string * a = static_cast<string *>(gen->GetObject()); + string * b = static_cast<string *>(gen->GetArgAddress(0)); string ret_val = *a + *b; gen->SetReturnObject(&ret_val); } @@ -107,7 +122,7 @@ } } -void AssignInt2StringGeneric(asIScriptGeneric *gen) +void AssignInt2StringGeneric(asIScriptGeneric *gen) { int *a = static_cast<int*>(gen->GetAddressOfArg(0)); string *self = static_cast<string*>(gen->GetObject()); @@ -117,7 +132,7 @@ gen->SetReturnAddress(self); } -void AssignUInt2StringGeneric(asIScriptGeneric *gen) +void AssignUInt2StringGeneric(asIScriptGeneric *gen) { unsigned int *a = static_cast<unsigned int*>(gen->GetAddressOfArg(0)); string *self = static_cast<string*>(gen->GetObject()); @@ -127,7 +142,7 @@ gen->SetReturnAddress(self); } -void AssignDouble2StringGeneric(asIScriptGeneric *gen) +void AssignDouble2StringGeneric(asIScriptGeneric *gen) { double *a = static_cast<double*>(gen->GetAddressOfArg(0)); string *self = static_cast<string*>(gen->GetObject()); @@ -165,8 +180,8 @@ } void AddString2DoubleGeneric(asIScriptGeneric * gen) { - string * a = static_cast<string *>(gen->GetArgAddress(0)); - double * b = static_cast<double *>(gen->GetAddressOfArg(1)); + string * a = static_cast<string *>(gen->GetObject()); + double * b = static_cast<double *>(gen->GetAddressOfArg(0)); std::stringstream sstr; sstr << *a << *b; std::string ret_val = sstr.str(); @@ -174,8 +189,8 @@ } void AddString2IntGeneric(asIScriptGeneric * gen) { - string * a = static_cast<string *>(gen->GetArgAddress(0)); - int * b = static_cast<int *>(gen->GetAddressOfArg(1)); + string * a = static_cast<string *>(gen->GetObject()); + int * b = static_cast<int *>(gen->GetAddressOfArg(0)); std::stringstream sstr; sstr << *a << *b; std::string ret_val = sstr.str(); @@ -183,8 +198,8 @@ } void AddString2UIntGeneric(asIScriptGeneric * gen) { - string * a = static_cast<string *>(gen->GetArgAddress(0)); - unsigned int * b = static_cast<unsigned int *>(gen->GetAddressOfArg(1)); + string * a = static_cast<string *>(gen->GetObject()); + unsigned int * b = static_cast<unsigned int *>(gen->GetAddressOfArg(0)); std::stringstream sstr; sstr << *a << *b; std::string ret_val = sstr.str(); @@ -193,7 +208,7 @@ void AddDouble2StringGeneric(asIScriptGeneric * gen) { double* a = static_cast<double *>(gen->GetAddressOfArg(0)); - string * b = static_cast<string *>(gen->GetArgAddress(1)); + string * b = static_cast<string *>(gen->GetObject()); std::stringstream sstr; sstr << *a << *b; std::string ret_val = sstr.str(); @@ -202,7 +217,7 @@ void AddInt2StringGeneric(asIScriptGeneric * gen) { int* a = static_cast<int *>(gen->GetAddressOfArg(0)); - string * b = static_cast<string *>(gen->GetArgAddress(1)); + string * b = static_cast<string *>(gen->GetObject()); std::stringstream sstr; sstr << *a << *b; std::string ret_val = sstr.str(); @@ -211,7 +226,7 @@ void AddUInt2StringGeneric(asIScriptGeneric * gen) { unsigned int* a = static_cast<unsigned int *>(gen->GetAddressOfArg(0)); - string * b = static_cast<string *>(gen->GetArgAddress(1)); + string * b = static_cast<string *>(gen->GetObject()); std::stringstream sstr; sstr << *a << *b; std::string ret_val = sstr.str(); @@ -231,19 +246,13 @@ // Register the object operator overloads r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructStringGeneric), asCALL_GENERIC); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("string", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructStringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(const string &in)", asFUNCTION(AssignStringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(const string &in)", asFUNCTION(AddAssignStringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(const string &in)", asFUNCTION(AssignStringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(const string &in)", asFUNCTION(AddAssignStringGeneric), asCALL_GENERIC); assert( r >= 0 ); - // Register the global operator overloads - r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, "bool f(const string &in, const string &in)", asFUNCTION(StringEqualGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, "bool f(const string &in, const string &in)", asFUNCTION(StringNotEqualGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL, "bool f(const string &in, const string &in)", asFUNCTION(StringLEqualGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL, "bool f(const string &in, const string &in)", asFUNCTION(StringGEqualGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN, "bool f(const string &in, const string &in)", asFUNCTION(StringLessThanGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const string &in, const string &in)", asFUNCTION(StringGreaterThanGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "bool opEquals(const string &in) const", asFUNCTION(StringEqualsGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "int opCmp(const string &in) const", asFUNCTION(StringCmpGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(const string &in) const", asFUNCTION(StringAddGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string &in, const string &in)", asFUNCTION(StringAddGeneric), asCALL_GENERIC); assert( r >= 0 ); - // Register the object methods if (sizeof(size_t) == 4) { r = engine->RegisterObjectMethod("string", "uint length() const", asFUNCTION(StringLengthGeneric), asCALL_GENERIC); assert( r >= 0 ); @@ -258,20 +267,20 @@ r = engine->RegisterObjectBehaviour("string", asBEHAVE_INDEX, "const uint8 &f(uint) const", asFUNCTION(StringCharAtGeneric), asCALL_GENERIC); assert( r >= 0 ); // Automatic conversion from values - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(double)", asFUNCTION(AssignDouble2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(double)", asFUNCTION(AddAssignDouble2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string & in, double)", asFUNCTION(AddString2DoubleGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(double, const string & in)", asFUNCTION(AddDouble2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(double)", asFUNCTION(AssignDouble2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(double)", asFUNCTION(AddAssignDouble2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(double) const", asFUNCTION(AddString2DoubleGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd_r(double) const", asFUNCTION(AddDouble2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(int)", asFUNCTION(AssignInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(int)", asFUNCTION(AddAssignInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string & in, int)", asFUNCTION(AddString2IntGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(int, const string & in)", asFUNCTION(AddInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(int)", asFUNCTION(AssignInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(int)", asFUNCTION(AddAssignInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(int) const", asFUNCTION(AddString2IntGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd_r(int) const", asFUNCTION(AddInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(uint)", asFUNCTION(AssignUInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(uint)", asFUNCTION(AddAssignUInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string & in, uint)", asFUNCTION(AddString2UIntGeneric), asCALL_GENERIC); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(uint, const string & in)", asFUNCTION(AddUInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(uint)", asFUNCTION(AssignUInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(uint)", asFUNCTION(AddAssignUInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(uint) const", asFUNCTION(AddString2UIntGeneric), asCALL_GENERIC); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd_r(uint) const", asFUNCTION(AddUInt2StringGeneric), asCALL_GENERIC); assert( r >= 0 ); } static string StringFactory(asUINT length, const char *s) @@ -397,6 +406,14 @@ return &str[i]; } +static int StringCmp(const string &a, const string &b) +{ + int cmp = 0; + if( a < b ) cmp = -1; + else if( a > b ) cmp = 1; + return cmp; +} + void RegisterStdString_Native(asIScriptEngine *engine) { int r; @@ -410,17 +427,12 @@ // Register the object operator overloads r = engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); r = engine->RegisterObjectBehaviour("string", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(const string &in)", asMETHODPR(string, operator =, (const string&), string&), asCALL_THISCALL); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(const string &in)", asMETHODPR(string, operator+=, (const string&), string&), asCALL_THISCALL); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(const string &in)", asMETHODPR(string, operator =, (const string&), string&), asCALL_THISCALL); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(const string &in)", asMETHODPR(string, operator+=, (const string&), string&), asCALL_THISCALL); assert( r >= 0 ); - // Register the global operator overloads - r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator==, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator!=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator<=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator>=, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator <, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, "bool f(const string &in, const string &in)", asFUNCTIONPR(operator >, (const string &, const string &), bool), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string &in, const string &in)", asFUNCTIONPR(operator +, (const string &, const string &), string), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "bool opEquals(const string &in) const", asFUNCTIONPR(operator ==, (const string &, const string &), bool), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "int opCmp(const string &in) const", asFUNCTION(StringCmp), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(const string &in) const", asFUNCTIONPR(operator +, (const string &, const string &), string), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); // Register the object methods if( sizeof(size_t) == 4 ) @@ -440,20 +452,20 @@ r = engine->RegisterObjectBehaviour("string", asBEHAVE_INDEX, "const uint8 &f(uint) const", asFUNCTION(StringCharAt), asCALL_CDECL_OBJLAST); assert( r >= 0 ); // Automatic conversion from values - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(double)", asFUNCTION(AssignDoubleToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(double)", asFUNCTION(AddAssignDoubleToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string &in, double)", asFUNCTION(AddStringDouble), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(double, const string &in)", asFUNCTION(AddDoubleString), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(double)", asFUNCTION(AssignDoubleToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(double)", asFUNCTION(AddAssignDoubleToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(double) const", asFUNCTION(AddStringDouble), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd_r(double) const", asFUNCTION(AddDoubleString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(int)", asFUNCTION(AssignIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(int)", asFUNCTION(AddAssignIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string &in, int)", asFUNCTION(AddStringInt), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(int, const string &in)", asFUNCTION(AddIntString), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(int)", asFUNCTION(AssignIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(int)", asFUNCTION(AddAssignIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(int) const", asFUNCTION(AddStringInt), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd_r(int) const", asFUNCTION(AddIntString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string &f(uint)", asFUNCTION(AssignUIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string &f(uint)", asFUNCTION(AddAssignUIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(const string &in, uint)", asFUNCTION(AddStringUInt), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, "string f(uint, const string &in)", asFUNCTION(AddUIntString), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAssign(uint)", asFUNCTION(AssignUIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string &opAddAssign(uint)", asFUNCTION(AddAssignUIntToString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd(uint) const", asFUNCTION(AddStringUInt), asCALL_CDECL_OBJFIRST); assert( r >= 0 ); + r = engine->RegisterObjectMethod("string", "string opAdd_r(uint) const", asFUNCTION(AddUIntString), asCALL_CDECL_OBJLAST); assert( r >= 0 ); } void RegisterStdString(asIScriptEngine * engine) @@ -468,4 +480,4 @@ -#endif // __COMPILE_WITH_ANGELSCRIPT__ + Modified: trunk/src/scripting/vendor/angelscript/scriptstdstring.h =================================================================== --- trunk/src/scripting/vendor/angelscript/scriptstdstring.h 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/vendor/angelscript/scriptstdstring.h 2009-08-16 15:42:42 UTC (rev 106) @@ -3,17 +3,13 @@ // // This function registers the std::string type with AngelScript to be used as the default string type. // -// The string type is registered as a value type, thus may have performance issues if a lot of +// The string type is registered as a value type, thus may have performance issues if a lot of // string operations are performed in the script. However, for relatively few operations, this should // not cause any problem for most applications. // #ifndef SCRIPTSTDSTRING_H -#define SCRIPTSTDSTRING_H - -#include "../../../config.h" - -#ifdef __COMPILE_WITH_ANGELSCRIPT__ +#define SCRIPTSTDSTRING_H #include <angelscript.h> #include <string> @@ -23,7 +19,5 @@ void RegisterStdString(asIScriptEngine *engine); END_AS_NAMESPACE - -#endif // __COMPILE_WITH_ANGELSCRIPT__ #endif Modified: trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp =================================================================== --- trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/vendor/irrlicht/asAabbox3d.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -111,14 +111,10 @@ // Comparison behaviours. ss.str(""); - ss << "bool f(const " << typeName << " &in, const " << typeName << " &in)"; - std::string declComparison = ss.str(); + ss << "bool opEquals(const " << typeName << " &in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), asFUNCTIONPR(equal< aabbox3d<T> >, + (const aabbox3d<T>&, const aabbox3d<T>&), bool), asCALL_CDECL_OBJFIRST); assert(r >= 0); - r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, declComparison.c_str(), asFUNCTIONPR(equal< aabbox3d<T> >, - (const aabbox3d<T>&, const aabbox3d<T>&), bool), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, declComparison.c_str(), asFUNCTIONPR(not_equal< aabbox3d<T> >, - (const aabbox3d<T>&, const aabbox3d<T>&), bool), asCALL_CDECL); assert(r >= 0); - // Bind aabbox3d<T> class functions. ss.str(""); ss << "void addInternalBox(const " << typeName << " &in)"; Modified: trunk/src/scripting/vendor/irrlicht/asDimension2d.cpp =================================================================== --- trunk/src/scripting/vendor/irrlicht/asDimension2d.cpp 2009-08-16 12:31:22 UTC (rev 105) +++ trunk/src/scripting/vendor/irrlicht/asDimension2d.cpp 2009-08-16 15:42:42 UTC (rev 106) @@ -80,59 +80,55 @@ // Calculation behaviours. // Multiply (*) ss.str(""); - ss << typeName << " f(const " << typeName << " &in, const "<< asType << ")"; - r = engine->RegisterGlobalBehaviour(asBEHAVE_MULTIPLY, ss.str().c_str(), - asFUNCTIONPR((multiply< dimension2d<T>, dimension2d<T>, T >), - (const dimension2d<T>&, const T&), dimension2d<T>), asCALL_CDECL); - assert(r >= 0); + ss << typeName << " opMul(const "<< asType << ")"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asFUNCTIONPR((multiply< dimension2d<T>, dimension2d<T>, T >), + (const dimension2d<T>&, const T&), dimension2d<T>), asCALL_CDECL_OBJFIRST); + assert(r >= 0); // Multiply Assign (*=) ss.str(""); - ss << typeName << "& f(const " << asType << ")"; - r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_MUL_ASSIGN, ss.str().c_str(), - asMETHODPR(dimension2d<T>, operator*=, (const T&), - dimension2d<T>&), asCALL_THISCALL); assert(r >= 0); + ss << typeName << "& opMulAssign(const " << asType << ")"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHODPR(dimension2d<T>, operator*=, (const T&), + dimension2d<T>&), asCALL_THISCALL); assert(r >= 0); // Add (+) ss.str(""); - ss << typeName << " f(const " << typeName << " &in, const " << typeName << " &in)"; - r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, ss.str().c_str(), - asFUNCTIONPR((add< dimension2d<T>, dimension2d<T>, dimension2d<T> >), - (const dimension2d<T>&, const dimension2d<T>&), dimension2d<T>), - asCALL_CDECL); assert(r >= 0); + ss << typeName << " opAdd(const " << typeName << " &in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asFUNCTIONPR((add< dimension2d<T>, dimension2d<T>, dimension2d<T> >), + (const dimension2d<T>&, const dimension2d<T>&), dimension2d<T>), + asCALL_CDECL_OBJFIRST); assert(r >= 0); // Add Assign (+=) ss.str(""); - ss << typeName << "& f(const " << typeName << " &in)"; - r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_ADD_ASSIGN, ss.str().c_str(), - asMETHODPR(dimension2d<T>, operator+=, (const dimension2d<T>&), - dimension2d<T>&), asCALL_THISCALL); assert(r >= 0); + ss << typeName << "& opAddAssign(const " << typeName << " &in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHODPR(dimension2d<T>, operator+=, (const dimension2d<T>&), + dimension2d<T>&), asCALL_THISCALL); assert(r >= 0); // Divide (/) ss.str(""); - ss << typeName << " f(const " << typeName << " &in, const " << asType << ")"; - r = engine->RegisterGlobalBehaviour(asBEHAVE_DIVIDE, ss.str().c_str(), - asFUNCTIONPR((divide< dimension2d<T>, dimension2d<T>, T >), - (const dimension2d<T>&, const T&), dimension2d<T>), - ... [truncated message content] |
From: <zcc...@us...> - 2009-08-16 12:31:29
|
Revision: 105 http://sirrf.svn.sourceforge.net/sirrf/?rev=105&view=rev Author: zccdark203 Date: 2009-08-16 12:31:22 +0000 (Sun, 16 Aug 2009) Log Message: ----------- Added documentation for the XML-parsers of the entity class and all standard Sirrf components. Furthermore various minor changes have been applied to improve the XML-parsers. Modified Paths: -------------- trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h 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.h 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.h trunk/src/components/scene/SkyDomeComponent.h trunk/src/components/scene/TerrainComponent.h trunk/src/components/scene/TextBillboardComponent.h trunk/src/components/sound/SoundListenerComponent.h trunk/src/components/sound/SoundSourceComponent.h trunk/src/core/Entity.h trunk/src/core/EntityManager.cpp trunk/src/scripting/components/scene/asParticleSysComponent.cpp Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) @@ -358,7 +358,7 @@ else if(stringw("shadowVolumeMeshSceneNode") == file->getNodeName()) { stringc fileName = file->getAttributeValue(L"fileName"); - stringc zfailmethod = file->getAttributeValue(L"value"); + stringc zfailmethod = file->getAttributeValue(L"zfailmethod"); component->setShadowVolumeSceneNode(fileName.c_str(), (zfailmethod == "true") ? true : false, Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // AnimatedMeshComponent class //! Component wrapper of Irrlicht's IAnimatedMeshSceneNode. +//! +//! <b>XML:</b> +//! \code +//! <AnimatedMeshComponent> +//! <!-- Properties --> +//! </AnimatedMeshComponent> +//! \endcode class AnimatedMeshComponent : public SceneComponent { public: @@ -69,19 +76,49 @@ s32 getStartFrame() const; //! Sets the speed (in frames/s) with which the animation is played. + //! + //! <b>XML:</b> + //! \code + //! <animationSpeed value="" /> + //! \endcode + //! //! @param speed Frames per second played. void setAnimationSpeed(f32 speed); //! Sets the current frame number. + //! + //! <b>XML:</b> + //! \code + //! <currentFrame value="" /> + //! \endcode + //! //! @param frame Number of the frame to let the animation be started from. void setCurrentFrame(f32 frame); //! Sets the frame numbers between which the animation is looped. + //! + //! <b>XML:</b> + //! \code + //! <frameLoop start="" end="" /> + //! \endcode + //! //! @param start Start frame number of the loop. //! @param end End frame number of the loop. void setFrameLoop(s32 start, s32 end); //! Sets looping mode which is on by default. + //! + //! <b>XML:</b> + //! \code + //! <loopMode value="" /> + //! \endcode + //! //! @param value The value of this option. void setLoopMode(bool value); //! Starts a MD2 animation. + //! + //! <b>XML:</b> + //! \code + //! <MD2Animation value="" /> + //! \endcode + //! //! @param animationName Name of the animation which should be played. void setMD2Animation(const std::string &animationName); //! Starts a MD2 animation. @@ -90,6 +127,12 @@ //! @note Not available in AngelScript. void setMD2Animation(EMD2_ANIMATION_TYPE anim); //! Loads and sets a new mesh to display. + //! + //! <b>XML:</b> + //! \code + //! <mesh fileName="" /> + //! \endcode + //! //! fileName Filename of the mesh to load. void setMesh(const std::string &fileName); //! Sets a new mesh to display. @@ -105,6 +148,12 @@ //! @note You must first call setShadowVolumeSceneNode! void setShadowVolumeMesh(IMesh *mesh); //! Loads and sets a new IShadowVolumeSceneNode to the component. + //! + //! <b>XML:</b> + //! \code + //! <shadowVolumeMeshSceneNode fileName="" zfailmethod="" infinity="" /> + //! \endcode + //! //! @param fileName Filename of the mesh to load. //! @param zfailmethod If set to true, the shadow will use the zfail method, if not, //! zpass is used. @@ -120,6 +169,12 @@ void setShadowVolumeSceneNode(IMesh *mesh, bool zfailmethod = true, f32 infinity = 10000.0f); //! Sets the transition time in seconds. + //! + //! <b>XML:</b> + //! \code + //! <transitionTime value="" /> + //! \endcode + //! //! @param time Transition time in seconds. void setTransitionTime(f32 time); Modified: trunk/src/components/scene/BillboardComponent.h =================================================================== --- trunk/src/components/scene/BillboardComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/BillboardComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // BillboardComponent class //! Component wrapper of Irrlicht's IBillboardSceneNode. +//! +//! <b>XML:</b> +//! \code +//! <BillboardComponent> +//! <!-- Properties --> +//! </BillboardComponent> +//! \endcode class BillboardComponent : public SceneComponent { public: @@ -52,13 +59,31 @@ const dimension2df& getSize() const; //! Sets the color of all vertices of the billboard. + //! + //! <b>XML:</b> + //! \code + //! <color overallA="" overallR="" overallG="" overallB="" /> + //! \endcode + //! //! @param overallColor The color to set. void setColor(const SColor &overallColor); //! Sets the color of the top and bottom vertices of the billboard. + //! + //! <b>XML:</b> + //! \code + //! <color topA="" topR="" topG="" topB="" bottomA="" bottomR="" bottomG="" bottomB=""/> + //! \endcode + //! //! @param topColor The color to set the top vertices. //! @param bottomColor The color to set the bottom vertices. void setColor(const SColor &topColor, const SColor &bottomColor); //! Sets the size of the billboard. + //! + //! <b>XML:</b> + //! \code + //! <size width="" height=""/> + //! \endcode + //! //! @param size Size of the billboard. void setSize(const dimension2df &size); Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/CameraComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) @@ -250,7 +250,7 @@ component->setAsMainCamera(); // <aspectRatio> - if(stringw("aspectRatio") == file->getNodeName()) + else if(stringw("aspectRatio") == file->getNodeName()) component->setAspectRatio(file->getAttributeValueAsFloat(L"value")); // <farValue> @@ -281,6 +281,24 @@ file->getAttributeValueAsFloat(L"z") ) ); } + // <FPSMode> + else if(stringw("FPSMode") == file->getNodeName()) + { + component->setFPSMode( file->getAttributeValueAsFloat(L"rotateSpeed"), + file->getAttributeValueAsFloat(L"moveSpeed"), + ( stringc(file->getAttributeValue(L"verticalMovement")) == "true" ) + ? true : false, + file->getAttributeValueAsFloat(L"jumpSpeed")); + } + + // <MayaMode> + else if(stringw("MayaMode") == file->getNodeName()) + { + component->setMayaMode( file->getAttributeValueAsFloat(L"rotateSpeed"), + file->getAttributeValueAsFloat(L"zoomSpeed"), + file->getAttributeValueAsFloat(L"translationSpeed") ); + } + // Derived elements. else SceneComponent::parseBaseXML(file, component); Modified: trunk/src/components/scene/CameraComponent.h =================================================================== --- trunk/src/components/scene/CameraComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/CameraComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // CameraComponent class //! Component wrapper of Irrlicht's ICameraSceneNode. +//! +//! <b>XML:</b> +//! \code +//! <CameraComponent> +//! <!-- Properties --> +//! </CameraComponent> +//! \endcode class CameraComponent : public SceneComponent { public: @@ -66,17 +73,47 @@ bool getIsOrthogonal() const; //! Sets this camera as the main camera. + //! + //! <b>XML:</b> + //! \code + //! <setAsMainCamera /> + //! \endcode + //! void setAsMainCamera(); //! Sets the aspect ratio (default: 4.0f / 3.0f). + //! + //! <b>XML:</b> + //! \code + //! <aspectRatio value="" /> + //! \endcode + //! //! @param aspect New aspect ratio. void setAspectRatio(f32 aspect); //! Sets the value of the far clipping plane (default: 2000.0f). + //! + //! <b>XML:</b> + //! \code + //! <farValue value="" /> + //! \endcode + //! //! @param value New far value. void setFarValue(f32 value); //! Sets the field of view (Default: PI / 2.5f). + //! + //! <b>XML:</b> + //! \code + //! <FOV value="" /> + //! \endcode + //! //! @param value New field of view. void setFOV(f32 value); //! Sets the value of the near clipping plane. (default: 1.0f). + //! + //! <b>XML:</b> + //! \code + //! <nearValue value="" /> + //! \endcode + //! //! @param value New near value. void setNearValue(f32 value); //! Sets the projection matrix of the camera. @@ -87,15 +124,33 @@ //! @param rotation New rotation in degrees. void setRotation(const vector3df &rotation); //! Sets the look at target of the camera. + //! + //! <b>XML:</b> + //! \code + //! <target x="" y="" z=""/> + //! \endcode + //! //! @param position New target. void setTarget(const vector3df &position); //! Sets the up vector of the camera. + //! + //! <b>XML:</b> + //! \code + //! <upVector x="" y="" z="" /> + //! \endcode + //! //! @param position New up vector of the camera. void setUpVector(const vector3df &position); //! Sets the camera to normal mode. void setNormalMode(); //! Sets the camera to FPS mode. + //! + //! <b>XML:</b> + //! \code + //! <FPSMode rotateSpeed="" moveSpeed="" verticalMovement="" jumpSpeed=""/> + //! \endcode + //! //! @param rotateSpeed Speed in degress with which the camera is rotated. //! @param moveSpeed Speed in units per millisecond with which the camera is moved. //! @param verticalMovement Is vertical movement by the camera allowed? @@ -104,6 +159,12 @@ void setFPSMode(f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, bool verticalMovement = false, f32 jumpSpeed = 0.0f); //! Sets the camera to Maya mode. + //! + //! <b>XML:</b> + //! \code + //! <MayaMode rotateSpeed="" zoomSpeed="" translationSpeed=""/> + //! \endcode + //! //! @param rotateSpeed Rotation speed of the camera. //! @param zoomSpeed Zoom speed of the camera. //! @param translationSpeed Translation speed of the camera. Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/ImageComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) @@ -299,7 +299,7 @@ } // <clipRect> - if(stringw("clipRect") == file->getNodeName()) + else if(stringw("clipRect") == file->getNodeName()) { rect<s32> clipRect = rect<s32>( file->getAttributeValueAsInt(L"x1"), file->getAttributeValueAsInt(L"y1"), @@ -310,7 +310,7 @@ } // <color> - if(stringw("color") == file->getNodeName()) + else if(stringw("color") == file->getNodeName()) { component->setColor( SColor(file->getAttributeValueAsInt(L"a"), file->getAttributeValueAsInt(L"r"), @@ -319,21 +319,32 @@ } // <position> - if(stringw("position") == file->getNodeName()) + else if(stringw("position") == file->getNodeName()) { component->setPosition(vector2di(file->getAttributeValueAsInt(L"x"), file->getAttributeValueAsInt(L"y")) ); } + // <sourceRect> + else if(stringw("sourceRect") == file->getNodeName()) + { + rect<s32> sourceRect = rect<s32>( file->getAttributeValueAsInt(L"x1"), + file->getAttributeValueAsInt(L"y1"), + file->getAttributeValueAsInt(L"x2"), + file->getAttributeValueAsInt(L"y2") ); + + component->setSourceRect(sourceRect); + } + // <texture> - if(stringw("texture") == file->getNodeName()) + else if(stringw("texture") == file->getNodeName()) { stringc fileName = file->getAttributeValue(L"fileName"); component->setTexture(fileName.c_str()); } // <useAlphaColor> - if(stringw("useAlphaColor") == file->getNodeName()) + else if(stringw("useAlphaColor") == file->getNodeName()) { stringc value = file->getAttributeValue(L"value"); component->setUseAlphaColor( (value == "true") ? true : false ); Modified: trunk/src/components/scene/ImageComponent.h =================================================================== --- trunk/src/components/scene/ImageComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/ImageComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // ImageComponent class //! Component wrapper for drawing 2d images. +//! +//! <b>XML:</b> +//! \code +//! <ImageComponent> +//! <!-- Properties --> +//! </ImageComponent> +//! \endcode class ImageComponent : public EntityComponent { public: @@ -81,22 +88,58 @@ bool getUseAlphaColor() const; //! Sets the alpha color of the image. + //! + //! <b>XML:</b> + //! \code + //! <alphaColor a="" r="" g="" b="" /> + //! \endcode + //! //! @param color New alpha color of the image. void setAlphaColor(const SColor &color); //! Sets where the image is clipped to. + //! + //! <b>XML:</b> + //! \code + //! <clipRect x1="" y1="" x2="" y2="" /> + //! \endcode + //! //! @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(const rect<s32> &rectangle); //! Sets the color with which the image is drawn. + //! + //! <b>XML:</b> + //! \code + //! <color a="" r="" g="" b="" /> + //! \endcode + //! //! @param color New color. void setColor(const SColor &color); //! Sets the upper left 2d screen position where the image will be drawn. + //! + //! <b>XML:</b> + //! \code + //! <position x="" y="" /> + //! \endcode + //! //! @param position New position. void setPosition(const vector2di &position); //! Sets the source rectangle in the image + //! + //! <b>XML:</b> + //! \code + //! <sourceRect x1="" y1="" x2="" y2="" /> + //! \endcode + //! //! @param rectangle New source rectangle from where the image is retrieved. void setSourceRect(const rect<s32> &rectangle); //! Loads a texture from the given file and sets it as the texture to be drawn. + //! + //! <b>XML:</b> + //! \code + //! <texture fileName="" /> + //! \endcode + //! //! @param fileName Filename of the texture to load. void setTexture(const std::string &fileName); //! Sets the texture which should be drawn. @@ -104,6 +147,12 @@ //! @note Not available in AngelScript. void setTexture(ITexture *texture); //! Sets whether the alpha color should be used. + //! + //! <b>XML:</b> + //! \code + //! <useAlphaColor value="" /> + //! \endcode + //! //! @param value Value to enable or disble this option. void setUseAlphaColor(bool value); Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/LightComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) @@ -121,7 +121,7 @@ // <lightType> else if(stringw("lightType") == file->getNodeName()) { - stringc lightType = file->getAttributeValue(L"lightType"); + stringc lightType = file->getAttributeValue(L"value"); E_LIGHT_TYPE type; #define retrieveLightType(x) \ Modified: trunk/src/components/scene/LightComponent.h =================================================================== --- trunk/src/components/scene/LightComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/LightComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // LightComponent class //! Component wrapper of Irrlicht's ILightSceneNode. +//! +//! <b>XML:</b> +//! \code +//! <LightComponent> +//! <!-- Properties --> +//! </LightComponent> +//! \endcode class LightComponent : public SceneComponent { public: @@ -49,12 +56,30 @@ f32 getRadius() const; //! Sets whether this light casts shadows. + //! + //! <b>XML:</b> + //! \code + //! <castShadow value="" /> + //! \endcode + //! //! @param shadow Value to enable or disable this option. void setCastShadow(bool shadow = true); //! Sets the light type. + //! + //! <b>XML:</b> + //! \code + //! <lightType value="" /> + //! \endcode + //! //! @param type The light type (see: Irrlicht API documentation) void setLightType(E_LIGHT_TYPE type); //! Sets the light's radius of influence. + //! + //! <b>XML:</b> + //! \code + //! <radius value="" /> + //! \endcode + //! //! @param radius The new radius. void setRadius(f32 radius); Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/MeshComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // MeshComponent class //! Component wrapper of Irrlicht's IMeshSceneNode. +//! +//! <b>XML:</b> +//! \code +//! <MeshComponent> +//! <!-- Properties --> +//! </MeshComponent> +//! \endcode class MeshComponent : public SceneComponent { public: @@ -57,6 +64,12 @@ IMesh* getMesh(); //! Loads and sets a new mesh to display. + //! + //! <b>XML:</b> + //! \code + //! <mesh fileName="" /> + //! \endcode + //! //! fileName Filename of the mesh to load. virtual void setMesh(const std::string &fileName); //! Sets a new mesh to display. Modified: trunk/src/components/scene/OctTreeComponent.h =================================================================== --- trunk/src/components/scene/OctTreeComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/OctTreeComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // OctTreeComponent class //! Component wrapper of Irrlicht's SceneManager function addOctTreeSceneNode(...). +//! +//! <b>XML:</b> +//! \code +//! <OctTreeComponent minPolysPerNode=""> +//! <!-- Properties --> +//! </OctTreeComponent> +//! \endcode class OctTreeComponent : public MeshComponent { public: Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) @@ -113,38 +113,6 @@ return mParticleSystemSN->getEmitter(); } -// Sets a particle emitter for the loaded animated mesh component. -void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(const std::string &fileName, - bool useNormalDirection, - const vector3df &direction, - f32 normalDirectionModifier, - bool everyMeshVertex, - u32 minParticlesPerSecond, - u32 maxParticlesPerSecond, - const SColor &minStartColor, - const SColor &maxStartColor, - u32 lifeTimeMin, u32 lifeTimeMax, - s32 maxAngleDegrees, - const dimension2df &minStartSize, - const dimension2df &maxStartSize) -{ - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - IAnimatedMeshSceneNode *node = pSceneMgr->addAnimatedMeshSceneNode(pSceneMgr->getMesh( - fileName.c_str()), 0, pParent->getID()); - if(node) - { - IParticleEmitter *emitter = mParticleSystemSN->createAnimatedMeshSceneNodeEmitter(node, - useNormalDirection, - direction, normalDirectionModifier, -1, everyMeshVertex, - minParticlesPerSecond, maxParticlesPerSecond, minStartColor, - maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees, - minStartSize, maxStartSize); - mParticleSystemSN->setEmitter(emitter); - emitter->drop(); - } -} - // Creates a particle emitter for an animated mesh component. void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(IAnimatedMeshSceneNode *node, bool useNormalDirection, @@ -342,8 +310,8 @@ { case io::EXN_ELEMENT: - // <attractionAffector> - if(stringw("attractionAffector") == file->getNodeName()) + // <AttractionAffector> + if(stringw("AttractionAffector") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df point; @@ -405,8 +373,8 @@ case io::EXN_ELEMENT_END: - // </attractionAffector> - if(stringw("attractionAffector") == file->getNodeName()) + // </AttractionAffector> + if(stringw("AttractionAffector") == file->getNodeName()) doneParsing = true; break; @@ -421,8 +389,8 @@ component->addAttractionAffector(point, speed, attract, affectX, affectY, affectZ); } - // <fadeOutParticleAffector> - else if(stringw("fadeOutParticleAffector") == file->getNodeName()) + // <FadeOutParticleAffector> + else if(stringw("FadeOutParticleAffector") == file->getNodeName()) { // Retrieve required variables from internal loop. SColor targetColor = SColor(0, 0, 0, 0); @@ -452,8 +420,8 @@ case io::EXN_ELEMENT_END: - // </fadeOutParticleAffector> - if(stringw("fadeOutParticleAffector") == file->getNodeName()) + // </FadeOutParticleAffector> + if(stringw("FadeOutParticleAffector") == file->getNodeName()) doneParsing = true; break; @@ -468,8 +436,8 @@ component->addFadeOutParticleAffector(targetColor, timeNeededToFadeOut); } - // <gravityAffector> - else if(stringw("gravityAffector") == file->getNodeName()) + // <GravityAffector> + else if(stringw("GravityAffector") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df gravity = vector3df(0.0f,-0.03f, 0.0f); @@ -498,8 +466,8 @@ case io::EXN_ELEMENT_END: - // </gravityAffector> - if(stringw("gravityAffector") == file->getNodeName()) + // </GravityAffector> + if(stringw("GravityAffector") == file->getNodeName()) doneParsing = true; break; @@ -514,8 +482,8 @@ component->addGravityAffector(gravity, timeForceLost); } - // <rotationAffector> - else if(stringw("rotationAffector") == file->getNodeName()) + // <RotationAffector> + else if(stringw("RotationAffector") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df speed = vector3df(5.0f, 5.0f, 5.0f); @@ -549,8 +517,8 @@ case io::EXN_ELEMENT_END: - // </rotationAffector> - if(stringw("rotationAffector") == file->getNodeName()) + // </RotationAffector> + if(stringw("RotationAffector") == file->getNodeName()) doneParsing = true; break; @@ -565,8 +533,8 @@ component->addRotationAffector(speed, pivotPoint); } - // <scaleParticleAffector> - else if(stringw("scaleParticleAffector") == file->getNodeName()) + // <ScaleParticleAffector> + else if(stringw("ScaleParticleAffector") == file->getNodeName()) { // Retrieve required variables from internal loop. dimension2df scaleTo = dimension2df(1.0f, 1.0f); @@ -590,8 +558,8 @@ case io::EXN_ELEMENT_END: - // </scaleParticleAffector> - if(stringw("scaleParticleAffector") == file->getNodeName()) + // </ScaleParticleAffector> + if(stringw("ScaleParticleAffector") == file->getNodeName()) doneParsing = true; break; @@ -606,8 +574,8 @@ component->addScaleParticleAffector(scaleTo); } - // <animatedMeshSceneNodeEmitter> - else if(stringw("animatedMeshSceneNodeEmitter") == file->getNodeName()) + // <MeshEmitter> + else if(stringw("MeshEmitter") == file->getNodeName()) { // Retrieve required variables from internal loop. std::string fileName; @@ -722,8 +690,8 @@ case io::EXN_ELEMENT_END: - // </animatedMeshSceneNodeEmitter> - if(stringw("animatedMeshSceneNodeEmitter") == file->getNodeName()) + // </MeshEmitter> + if(stringw("MeshEmitter") == file->getNodeName()) doneParsing = true; break; @@ -735,149 +703,14 @@ } // We create the emitter. - component->setAnimatedMeshSceneNodeEmitter(fileName, useNormalDirection, direction, - normalDirectionModifier, everyMeshVertex, minParticlesPerSecond, - maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, - lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize); - } - - // <meshEmitter> - else if(stringw("meshEmitter") == file->getNodeName()) - { - // Retrieve required variables from internal loop. - std::string fileName; - bool useNormalDirection = true; - vector3df direction = vector3df(0.0f, 0.03f, 0.0f); - f32 normalDirectionModifier = 100.0f; - bool everyMeshVertex = false; - u32 minParticlesPerSecond = 5; - u32 maxParticlesPerSecond = 10; - SColor minStartColor = SColor(255, 0, 0, 0); - SColor maxStartColor = SColor(255, 255, 255, 255); - u32 lifeTimeMin = 2000; - u32 lifeTimeMax = 4000; - s32 maxAngleDegrees = 0; - dimension2df minStartSize = dimension2df(5.0f, 5.0f); - dimension2df maxStartSize = dimension2df(5.0f, 5.0f); - - bool doneParsing = false; - - while(file->read() && !doneParsing) - { - switch(file->getNodeType()) - { - case io::EXN_ELEMENT: - - // <fileName> - if(stringw("fileName") == file->getNodeName()) - { - stringc value = file->getAttributeValue(L"value"); - fileName = value.c_str(); - } - - // <useNormalDirection> - else if(stringw("useNormalDirection") == file->getNodeName()) - { - stringc value = file->getAttributeValue(L"value"); - useNormalDirection = (value == "true") ? true : false ; - } - - // <direction> - else if(stringw("direction") == file->getNodeName()) - { - direction = vector3df( file->getAttributeValueAsFloat(L"x"), - file->getAttributeValueAsFloat(L"y"), - file->getAttributeValueAsFloat(L"z") ); - } - - // <normalDirectionModifier> - else if(stringw("normalDirectionModifier") == file->getNodeName()) - normalDirectionModifier = file->getAttributeValueAsFloat(L"value"); - - // <everyMeshVertex> - else if(stringw("everyMeshVertex") == file->getNodeName()) - { - stringc value = file->getAttributeValue(L"value"); - everyMeshVertex = (value == "true") ? true : false ; - } - - // <minParticlesPerSecond> - else if(stringw("minParticlesPerSecond") == file->getNodeName()) - minParticlesPerSecond = file->getAttributeValueAsInt(L"value"); - - // <maxParticlesPerSecond> - else if(stringw("maxParticlesPerSecond") == file->getNodeName()) - maxParticlesPerSecond = file->getAttributeValueAsInt(L"value"); - - // <minStartColor> - else if(stringw("minStartColor") == file->getNodeName()) - { - minStartColor = SColor( file->getAttributeValueAsInt(L"a"), - file->getAttributeValueAsInt(L"r"), - file->getAttributeValueAsInt(L"g"), - file->getAttributeValueAsInt(L"b") ); - } - - // <maxStartColor> - else if(stringw("maxStartColor") == file->getNodeName()) - { - maxStartColor = SColor( file->getAttributeValueAsInt(L"a"), - file->getAttributeValueAsInt(L"r"), - file->getAttributeValueAsInt(L"g"), - file->getAttributeValueAsInt(L"b") ); - } - - // <lifeTimeMin> - else if(stringw("lifeTimeMin") == file->getNodeName()) - lifeTimeMin = file->getAttributeValueAsInt(L"value"); - - // <lifeTimeMin> - else if(stringw("lifeTimeMax") == file->getNodeName()) - lifeTimeMax = file->getAttributeValueAsInt(L"value"); - - // <maxAngleDegrees> - else if(stringw("maxAngleDegrees") == file->getNodeName()) - maxAngleDegrees = file->getAttributeValueAsInt(L"value"); - - // <minStartSize> - else if(stringw("minStartSize") == file->getNodeName()) - { - minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), - file->getAttributeValueAsFloat(L"height")); - } - - // <maxStartSize> - else if(stringw("maxStartSize") == file->getNodeName()) - { - maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), - file->getAttributeValueAsFloat(L"height")); - } - - break; - - case io::EXN_ELEMENT_END: - - // </meshEmitter> - if(stringw("meshEmitter") == file->getNodeName()) - doneParsing = true; - - break; - - default: - - break; - } - } - - // We create the emitter. component->setMeshEmitter(fileName, useNormalDirection, direction, normalDirectionModifier, everyMeshVertex, minParticlesPerSecond, maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize); } - // <boxEmitter> - else if(stringw("boxEmitter") == file->getNodeName()) + // <BoxEmitter> + else if(stringw("BoxEmitter") == file->getNodeName()) { // Retrieve required variables from internal loop. aabbox3df box = aabbox3df(-10, 28,-10, 10, 30, 10); @@ -975,8 +808,8 @@ case io::EXN_ELEMENT_END: - // </boxEmitter> - if(stringw("boxEmitter") == file->getNodeName()) + // </BoxEmitter> + if(stringw("BoxEmitter") == file->getNodeName()) doneParsing = true; break; @@ -993,8 +826,8 @@ lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize); } - // <cylinderEmitter> - else if(stringw("cylinderEmitter") == file->getNodeName()) + // <CylinderEmitter> + else if(stringw("CylinderEmitter") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df center; @@ -1116,8 +949,8 @@ case io::EXN_ELEMENT_END: - // </cylinderEmitter> - if(stringw("cylinderEmitter") == file->getNodeName()) + // </CylinderEmitter> + if(stringw("CylinderEmitter") == file->getNodeName()) doneParsing = true; break; @@ -1135,8 +968,8 @@ minStartSize, maxStartSize); } - // <pointEmitter> - else if(stringw("pointEmitter") == file->getNodeName()) + // <PointEmitter> + else if(stringw("PointEmitter") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df direction = vector3df(0.0f, 0.03f, 0.0f); @@ -1222,8 +1055,8 @@ case io::EXN_ELEMENT_END: - // </pointEmitter> - if(stringw("pointEmitter") == file->getNodeName()) + // </PointEmitter> + if(stringw("PointEmitter") == file->getNodeName()) doneParsing = true; break; @@ -1240,8 +1073,8 @@ maxAngleDegrees, minStartSize, maxStartSize); } - // <ringEmitter> - else if(stringw("ringEmitter") == file->getNodeName()) + // <RingEmitter> + else if(stringw("RingEmitter") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df center; @@ -1346,8 +1179,8 @@ case io::EXN_ELEMENT_END: - // </ringEmitter> - if(stringw("ringEmitter") == file->getNodeName()) + // </RingEmitter> + if(stringw("RingEmitter") == file->getNodeName()) doneParsing = true; break; @@ -1365,8 +1198,8 @@ minStartSize, maxStartSize); } - // <sphereEmitter> - else if(stringw("sphereEmitter") == file->getNodeName()) + // <SphereEmitter> + else if(stringw("SphereEmitter") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df center; @@ -1466,8 +1299,8 @@ case io::EXN_ELEMENT_END: - // </sphereEmitter> - if(stringw("sphereEmitter") == file->getNodeName()) + // </SphereEmitter> + if(stringw("SphereEmitter") == file->getNodeName()) doneParsing = true; break; Modified: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // ParticleSysComponent class //! Component wrapper of Irrlicht's IParticleSystemSceneNode. +//! +//! <b>XML:</b> +//! \code +//! <ParticleSysComponent> +//! <!-- Properties --> +//! </ParticleSysComponent> +//! \endcode class ParticleSysComponent : public SceneComponent { public: @@ -46,6 +53,19 @@ void addAffector(IParticleAffector *affector); //! Adds a point attraction affector. + //! + //! <b>XML:</b> + //! \code + //! <AttractionAffector> + //! <point x="" y="" z="" /> + //! <speed value="" /> + //! <attract value="" /> + //! <affectX value="" /> + //! <affectY value="" /> + //! <affectZ value="" /> + //! </AttractionAffector> + //! \endcode + //! //! @param point Point to attract particles to. //! @param speed Speed in units per second, to attract to the specified point. //! @param attract Whether the particles attract or detract from this point. @@ -56,6 +76,15 @@ bool affectX = true, bool affectY = true, bool affectZ = true); //! Adds a fade out particle affector. + //! + //! <b>XML:</b> + //! \code + //! <FadeOutParticleAffector> + //! <targetColor a="" r="" g="" b="" /> + //! <timeNeededToFadeOut value="" /> + //! </FadeOutParticleAffector> + //! \endcode + //! //! @param targetColor Color where to the color of the particle is changed. //! @param timeNeededToFadeOut How much time in milli seconds should the affector need to //! change the color to the targetColor. @@ -63,6 +92,15 @@ u32 timeNeededToFadeOut = 1000); //! Adds a gravity affector. + //! + //! <b>XML:</b> + //! \code + //! <GravityAffector> + //! <gravity x="" y="" z="" /> + //! <timeForceLost value="" /> + //! </GravityAffector> + //! + //! \endcode //! @param gravity Direction and force of gravity. //! @param timeForceLost Time in milliseconds when the force of the emitter is totally //! lost and the particle does not move any more @@ -70,12 +108,29 @@ u32 timeForceLost = 1000); //! Adds a rotation affector. + //! + //! <b>XML:</b> + //! \code + //! <RotationAffector> + //! <speed x="" y="" z="" /> + //! <pivotPoint x="" y="" z="" /> + //! </RotationAffector> + //! \endcode + //! //! @param speed Rotation in degrees per second. //! @param pivotPoint Point to rotate the particles around. void addRotationAffector(const vector3df &speed = vector3df(5.0f, 5.0f, 5.0f), const vector3df &pivotPoint = vector3df(0.0f, 0.0f, 0.0f)); //! Adds a scale particle affector. + //! + //! <b>XML:</b> + //! \code + //! <ScaleParticleAffector> + //! <scaleTo width="" height="" /> + //! </ScaleParticleAffector> + //! \endcode + //! //! @param scaleTo Multiple of the size which the particle will be scaled to until //! deletion. void addScaleParticleAffector(const dimension2df &scaleTo = dimension2df(1.0f, 1.0f)); @@ -88,43 +143,6 @@ IParticleEmitter* getEmitter(); //! Sets a particle emitter for the loaded animated mesh component. - //! @param fileName Filename of the mesh to load. - //! @param useNormalDirection If true, the direction of each particle created will be the - //! normal of the vertex that it's emitting from. The normal is - //! divided by the normalDirectionModifier parameter, - //! which defaults to 100.0f. - //! @param direction Direction and speed of particle emission. - //! @param normalDirectionModifier If the emitter is using the normal direction then the normal - //! of the vertex that is being emitted from is divided by this - //! number. - //! @param everyMeshVertex If true, the emitter will emit between min/max particles - //! every second, for every vertex in the mesh, if false, it - //! will emit between min/max particles from random vertices - //! in the mesh. - //! @param minParticlesPerSecond Minimal amount of particles emitted per second. - //! @param maxParticlesPerSecond Maximal amount of particles emitted per second. - //! @param minStartColor Minimal initial start color of a particle. - //! @param maxStartColor Maximal initial start color of a particle. - //! @param lifeTimeMin Minimal lifetime of a particle, in milliseconds. - //! @param lifeTimeMax Maximal lifetime of a particle, in milliseconds. - //! @param maxAngleDegrees Maximal angle in degrees, the emitting direction of the - //! particle will differ from the original direction. - //! @param minStartSize Minimal initial start size of a particle. - //! @param maxStartSize Maximal initial start size of a particle. - void setAnimatedMeshSceneNodeEmitter(const std::string &fileName, - bool useNormalDirection = true, - const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - f32 normalDirectionModifier = 100.0f, - bool everyMeshVertex = false, - u32 minParticlesPerSecond = 5, - u32 maxParticlesPerSecond = 10, - const SColor &minStartColor = SColor(255, 0, 0, 0), - const SColor &maxStartColor = SColor(255, 255, 255, 255), - u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, - s32 maxAngleDegrees = 0, - const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), - const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); - //! Sets a particle emitter for the loaded animated mesh component. //! @param node Pointer to the loaded scene node. //! @param useNormalDirection If true, the direction of each particle created will be the //! normal of the vertex that it's emitting from. The normal is @@ -164,6 +182,24 @@ const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); //! Sets a box particle emitter. + //! + //! <b>XML:</b> + //! \code + //! <BoxEmitter> + //! <box minX="" minY="" minZ="" maxX="" maxY="" maxZ="" /> + //! <direction x="" y="" z="" /> + //! <minParticlesPerSecond value="" /> + //! <maxParticlesPerSecond value="" /> + //! <minStartColor a="" r="" g="" b="" /> + //! <maxStartColor a="" r="" g="" b="" /> + //! <lifeTimeMin value="" /> + //! <lifeTimeMax value="" /> + //! <maxAngleDegrees value="" /> + //! <minStartSize width="" height="" /> + //! <maxStartSize width="" height="" /> + //! </BoxEmitter> + //! \endcode + //! //! @param box The box for the emitter. //! @param direction Direction and speed of particle emission. //! @param minParticlesPerSecond Minimal amount of particles emitted per second. @@ -186,6 +222,28 @@ const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); //! Sets a particle emitter for emitting from a cylinder. + //! + //! <b>XML:</b> + //! \code + //! <CylinderEmitter> + //! <center x="" y="" z="" /> + //! <radius value="" /> + //! <normal x="" y="" z="" /> + //! <length value="" /> + //! <outlineOnly value="" /> + //! <direction x="" y="" z="" /> + //! <minParticlesPerSecond value="" /> + //! <maxParticlesPerSecond value="" /> + //! <minStartColor a="" r="" g="" b="" /> + //! <maxStartColor a="" r="" g="" b="" /> + //! <lifeTimeMin value="" /> + //! <lifeTimeMax value="" /> + //! <maxAngleDegrees value="" /> + //! <minStartSize width="" height="" /> + //! <maxStartSize width="" height="" /> + //! </CylinderEmitter> + //! \endcode + //! //! @param center The center of the circle at the base of the cylinder. //! @param radius The thickness of the cylinder //! @param normal Direction of the length of the cylinder @@ -218,6 +276,27 @@ void setEmitter(IParticleEmitter *emitter); //! Sets a particle emitter for the loaded mesh. + //! + //! <b>XML:</b> + //! \code + //! <MeshEmitter> + //! <fileName value="" /> + //! <useNormalDirection value="" /> + //! <direction x="" y="" z="" /> + //! <normalDirectionModifier value="" /> + //! <everyMeshVertex value="" /> + //! <minParticlesPerSecond value="" /> + //! <maxParticlesPerSecond value="" /> + //! <minStartColor a="" r="" g="" b="" /> + //! <maxStartColor a="" r="" g="" b="" /> + //! <lifeTimeMin value="" /> + //! <lifeTimeMax value="" /> + //! <maxAngleDegrees value="" /> + //! <minStartSize width="" height="" /> + //! <maxStartSize width="" height="" /> + //! </MeshEmitter> + //! \endcode + //! //! @param fileName Filename of the mesh to load. //! @param useNormalDirection If true, the direction of each particle created will be the //! normal of the vertex that it's emitting from. The normal is @@ -286,6 +365,23 @@ const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); //! Sets a point particle emitter. + //! + //! <b>XML:</b> + //! \code + //! <PointEmitter> + //! <direction x="" y="" z="" /> + //! <minParticlesPerSecond value="" /> + //! <maxParticlesPerSecond value="" /> + //! <minStartColor a="" r="" g="" b="" /> + //! <maxStartColor a="" r="" g="" b="" /> + //! <lifeTimeMin value="" /> + //! <lifeTimeMax value="" /> + //! <maxAngleDegrees value="" /> + //! <minStartSize width="" height="" /> + //! <maxStartSize width="" height="" /> + //! </PointEmitter> + //! \endcode + //! //! @param direction Direction and speed of particle emission. //! @param minParticlesPerSecond Minimal amount of particles emitted per second. //! @param maxParticlesPerSecond Maximal amount of particles emitted per second. @@ -306,6 +402,26 @@ const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); //! Sets a ring particle emitter. + //! + //! <b>XML:</b> + //! \code + //! <RingEmitter> + //! <center x="" y="" z="" /> + //! <radius value="" /> + //! <ringThickness value="" /> + //! <direction x="" y="" z="" /> + //! <minParticlesPerSecond value="" /> + //! <maxParticlesPerSecond value="" /> + //! <minStartColor a="" r="" g="" b="" /> + //! <maxStartColor a="" r="" g="" b="" /> + //! <lifeTimeMin value="" /> + //! <lifeTimeMax value="" /> + //! <maxAngleDegrees value="" /> + //! <minStartSize width="" height="" /> + //! <maxStartSize width="" height="" /> + //! </RingEmitter> + //! \endcode + //! //! @param center Center of ring. //! @param radius Distance of points from center, points will be rotated //! around the Y axis at a random 360 degrees and will then @@ -332,6 +448,25 @@ const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); //! Sets a sphere particle emitter. + //! + //! <b>XML:</b> + //! \code + //! <SphereEmitter> + //! <center x="" y="" z="" /> + //! <radius value="" /> + //! <direction x="" y="" z="" /> + //! <minParticlesPerSecond value="" /> + //! <maxParticlesPerSecond value="" /> + //! <minStartColor a="" r="" g="" b="" /> + //! <maxStartColor a="" r="" g="" b="" /> + //! <lifeTimeMin value="" /> + //! <lifeTimeMax value="" /> + //! <maxAngleDegrees value="" /> + //! <minStartSize width="" height="" /> + //! <maxStartSize width="" height="" /> + //! </SphereEmitter> + //! \endcode + //! //! @param center Center of the sphere. //! @param radius Radius of the sphere. //! @param direction Direction and speed of particle emission. Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/SceneComponent.cpp 2009-08-16 12:31:22 UTC (rev 105) @@ -488,8 +488,8 @@ // Parses for the base elements of a SceneComponent. void SceneComponent::parseBaseXML(IXMLReader *file, SceneComponent *component) { - // <collisionResponseAnimator> - if(stringw("collisionResponseAnimator") == file->getNodeName()) + // <CollisionResponseAnimator> + if(stringw("CollisionResponseAnimator") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df ellipsoidRadius; @@ -537,8 +537,8 @@ case io::EXN_ELEMENT_END: - // </collisionRespondAnimator> - if(stringw("collisionRespondAnimator") == file->getNodeName()) + // </CollisionRespondAnimator> + if(stringw("CollisionRespondAnimator") == file->getNodeName()) doneParsing = true; break; @@ -554,8 +554,8 @@ ellipsoidTranslation, slidingValue); } - // <flyCircleAnimator> - else if(stringw("flyCircleAnimator") == file->getNodeName()) + // <FlyCircleAnimator> + else if(stringw("FlyCircleAnimator") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df center; @@ -588,7 +588,7 @@ speed = file->getAttributeValueAsFloat(L"value"); // <direction> - if(stringw("direction") == file->getNodeName()) + else if(stringw("direction") == file->getNodeName()) { direction = vector3df( file->getAttributeValueAsFloat(L"x"), file->getAttributeValueAsFloat(L"y"), @@ -599,8 +599,8 @@ case io::EXN_ELEMENT_END: - // </flyCircleAnimator> - if(stringw("flyCircleAnimator") == file->getNodeName()) + // </FlyCircleAnimator> + if(stringw("FlyCircleAnimator") == file->getNodeName()) doneParsing = true; break; @@ -615,8 +615,8 @@ component->addFlyCircleAnimator(center, radius, speed, direction); } - // <flyStraightAnimator> - else if(stringw("flyStraightAnimator") == file->getNodeName()) + // <FlyStraightAnimator> + else if(stringw("FlyStraightAnimator") == file->getNodeName()) { // Retrieve required variables from internal loop. vector3df startPoint; @@ -663,8 +663,8 @@ case io::EXN_ELEMENT_END: - // </flyStraightAnimator> - if(stringw("flyStraightAnimator") == file->getNodeName()) + // </FlyStraightAnimator> + if(stringw("FlyStraightAnimator") == file->getNodeName()) doneParsing = true; break; @@ -720,7 +720,7 @@ // <materialFlag> else if(stringw("materialFlag") == file->getNodeName()) { - stringc materialFlag = file->getAttributeValue(L"materialflag"); + stringc materialFlag = file->getAttributeValue(L"flag"); E_MATERIAL_FLAG flag; #define retrieveMaterialFlag(x) \ Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-08-15 15:10:41 UTC (rev 104) +++ trunk/src/components/scene/SceneComponent.h 2009-08-16 12:31:22 UTC (rev 105) @@ -23,6 +23,13 @@ // SceneComponent class //! Component wrapper of Irrlicht's ISceneNode and base class of various scene components. +//! +//! <b>XML:</b> +//! \code +//! <SceneComponent> +//! <!-- Properties --> +//! </SceneComponent> +//! \endcode class SceneComponent : public EntityComponent { public: @@ -50,6 +57,17 @@ void addAnimator(ISceneNodeAnimator *animator); //! Adds a collision response animator to the component. + //! + //! <b>XML:</b> + //! \code + //! <CollisionResponseAnimator> + //! <ellipsoidRadius x="" y="" z="" /> + //! <gravityPerSecond x="" y="" z="" /> + //! <ellipsoidTranslation x="" y="" z="" /> + //! <slidingValue value="" /> + //! </CollisionResponseAnimator> + //! \endcode + //! //! @param ellipsoidRadius Radius of the ellipsoid with which collision detection and //! response is done. //! @param gravityPerSecond Sets the gravity of the environment, as an acceleration in @@ -66,6 +84,17 @@ f32 slidingValue = 0.0005f); //! Adds a fly circle animator to the component. + //! + //! <b>XML:</b> + //! \code + //! <FlyCircleAnimator> + //! <center x="" y="" z="" /> + //! <radius value="" /> + //! <speed value="" /> + //! <direction x="" y="" z="" /> + //! </FlyCircleAnimator> + //! \endcode + //! //! @param center Center of the circle. //! @param radius Radius of the circle. //! @param speed Specifies the speed of the flight. @@ -75,6 +104,17 @@ f32 speed = 0.001f, const vector3df &direction = vector3df(0, 0, 0)); //! Adds a fly straight animator to the component. + //! + //! <b>XML:</b> + //! \code + //! <FlyStraightAnimator> + //! <startPoint x="" y="" z="" /> + //! <endPoint x="" y="" z="" /> + //! <timeForWay value="" /> + //! <loop value="" /> + //! </FlyStraightAnimator> + //! \endcode + //! //! @param startPoint Start point of the line. //... [truncated message content] |
From: <zcc...@us...> - 2009-08-15 15:10:56
|
Revision: 104 http://sirrf.svn.sourceforge.net/sirrf/?rev=104&view=rev Author: zccdark203 Date: 2009-08-15 15:10:41 +0000 (Sat, 15 Aug 2009) Log Message: ----------- Added the XML-parsers of the remaining scene components. Modified Paths: -------------- trunk/src/components/components.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.h trunk/src/components/scene/ParticleSysComponent.cpp trunk/src/components/scene/ParticleSysComponent.h trunk/src/components/scene/SceneComponent.cpp 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/TextBillboardComponent.cpp trunk/src/components/scene/TextBillboardComponent.h trunk/src/components/sound/SoundListenerComponent.h trunk/src/components/sound/SoundSourceComponent.h Modified: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/components.cpp 2009-08-15 15:10:41 UTC (rev 104) @@ -29,15 +29,15 @@ parsers.push_back(AnimatedMeshComponent::parseXML); parsers.push_back(BillboardComponent::parseXML); - //parsers.push_back(CameraComponent::parseXML); + parsers.push_back(CameraComponent::parseXML); parsers.push_back(ImageComponent::parseXML); - //parsers.push_back(LightComponent::parseXML); + parsers.push_back(LightComponent::parseXML); parsers.push_back(MeshComponent::parseXML); parsers.push_back(OctTreeComponent::parseXML); - //parsers.push_back(ParticleSysComponent::parseXML); + parsers.push_back(ParticleSysComponent::parseXML); parsers.push_back(SceneComponent::parseXML); - //parsers.push_back(SkyBoxComponent::parseXML); - //parsers.push_back(SkyDomeComponent::parseXML); + parsers.push_back(SkyBoxComponent::parseXML); + parsers.push_back(SkyDomeComponent::parseXML); parsers.push_back(TerrainComponent::parseXML); parsers.push_back(TextBillboardComponent::parseXML); Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-15 15:10:41 UTC (rev 104) @@ -131,6 +131,7 @@ //! @note For internal use only! void onShadowVolumeMesh(void *p); + // XML //! Parses for a AnimatedMeshComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) @@ -148,24 +148,24 @@ { if(stringw("") != file->getAttributeValue(L"overallR")) { - component->setColor( SColor( file->getAttributeValueAsInt(L"overallR"), + component->setColor( SColor( file->getAttributeValueAsInt(L"overallA"), + file->getAttributeValueAsInt(L"overallR"), file->getAttributeValueAsInt(L"overallG"), - file->getAttributeValueAsInt(L"overallB"), - file->getAttributeValueAsInt(L"overallA") ) ); + file->getAttributeValueAsInt(L"overallB") ) ); return true; } else { - component->setColor( SColor( file->getAttributeValueAsInt(L"topR"), + component->setColor( SColor( file->getAttributeValueAsInt(L"topA"), + file->getAttributeValueAsInt(L"topR"), file->getAttributeValueAsInt(L"topG"), - file->getAttributeValueAsInt(L"topB"), - file->getAttributeValueAsInt(L"topA") ), - SColor( file->getAttributeValueAsInt(L"bottomR"), + file->getAttributeValueAsInt(L"topB") ), + SColor( file->getAttributeValueAsInt(L"bottomA"), + file->getAttributeValueAsInt(L"bottomR"), file->getAttributeValueAsInt(L"bottomG"), - file->getAttributeValueAsInt(L"bottomB"), - file->getAttributeValueAsInt(L"bottomA") ) ); + file->getAttributeValueAsInt(L"bottomB") ) ); return true; } Modified: trunk/src/components/scene/BillboardComponent.h =================================================================== --- trunk/src/components/scene/BillboardComponent.h 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/BillboardComponent.h 2009-08-15 15:10:41 UTC (rev 104) @@ -66,6 +66,7 @@ //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); + // XML //! Parses for the base elements of a BillboardComponent. //! @note For internal use only! static bool parseBaseXML(IXMLReader *file, BillboardComponent *component); Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/CameraComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) @@ -219,4 +219,90 @@ mCameraAnimator = animMaya; } +// Parses for a CameraComponent. +bool CameraComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + CameraComponent *component = NULL; + + // Are we dealing with a CameraComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("CameraComponent") == file->getNodeName()) + { + // Initialise the component. + component = new CameraComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <isMainCamera> + if(stringw("asMainCamera") == file->getNodeName()) + component->setAsMainCamera(); + + // <aspectRatio> + if(stringw("aspectRatio") == file->getNodeName()) + component->setAspectRatio(file->getAttributeValueAsFloat(L"value")); + + // <farValue> + else if(stringw("farValue") == file->getNodeName()) + component->setFarValue(file->getAttributeValueAsFloat(L"value")); + + // <FOV> + else if(stringw("FOV") == file->getNodeName()) + component->setFOV(file->getAttributeValueAsFloat(L"value")); + + // <farValue> + else if(stringw("nearValue") == file->getNodeName()) + component->setNearValue(file->getAttributeValueAsFloat(L"value")); + + // <target> + else if(stringw("target") == file->getNodeName()) + { + component->setTarget( vector3df(file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ) ); + } + + // <upVector> + else if(stringw("upVector") == file->getNodeName()) + { + component->setUpVector( vector3df(file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ) ); + } + + // Derived elements. + else SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </CameraComponent> + if(stringw("CameraComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/CameraComponent.h =================================================================== --- trunk/src/components/scene/CameraComponent.h 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/CameraComponent.h 2009-08-15 15:10:41 UTC (rev 104) @@ -111,6 +111,11 @@ void setMayaMode(f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, f32 translationSpeed = 1500.0f); + // XML + //! Parses for a CameraComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Members Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/ImageComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) @@ -292,10 +292,10 @@ // <alphaColor> if(stringw("alphaColor") == file->getNodeName()) { - component->setAlphaColor( SColor(file->getAttributeValueAsInt(L"r"), + component->setAlphaColor( SColor(file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), file->getAttributeValueAsInt(L"g"), - file->getAttributeValueAsInt(L"b"), - file->getAttributeValueAsInt(L"a")) ); + file->getAttributeValueAsInt(L"b")) ); } // <clipRect> @@ -312,10 +312,10 @@ // <color> if(stringw("color") == file->getNodeName()) { - component->setColor( SColor(file->getAttributeValueAsInt(L"r"), + component->setColor( SColor(file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), file->getAttributeValueAsInt(L"g"), - file->getAttributeValueAsInt(L"b"), - file->getAttributeValueAsInt(L"a")) ); + file->getAttributeValueAsInt(L"b")) ); } // <position> Modified: trunk/src/components/scene/ImageComponent.h =================================================================== --- trunk/src/components/scene/ImageComponent.h 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/ImageComponent.h 2009-08-15 15:10:41 UTC (rev 104) @@ -121,6 +121,7 @@ //! @note For internal use only! void onTexture(void *p); + // XML //! Parses for a ImageComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/LightComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) @@ -85,4 +85,87 @@ mLightSN->setRadius(radius); } +// Parses for a LightComponent. +bool LightComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + LightComponent *component = NULL; + + // Are we dealing with a LightComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("LightComponent") == file->getNodeName()) + { + // Initialise the component. + component = new LightComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <castShadow> + if(stringw("castShadow") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + component->setCastShadow( (value == "true") ? true : false ); + } + + // <lightType> + else if(stringw("lightType") == file->getNodeName()) + { + stringc lightType = file->getAttributeValue(L"lightType"); + E_LIGHT_TYPE type; + +#define retrieveLightType(x) \ +else if(lightType == #x) \ + type = x + + if(lightType== "") + type = ELT_POINT; // Dummy behaviour. + + retrieveLightType(ELT_POINT); + retrieveLightType(ELT_SPOT); + retrieveLightType(ELT_DIRECTIONAL); + +#undef retrieveLightType + + component->setLightType(type); + } + + // <radius> + else if(stringw("radius") == file->getNodeName()) + component->setRadius(file->getAttributeValueAsFloat(L"value")); + + // Derived elements. + else SceneComponent::parseBaseXML(file, component); + + break; + + case io::EXN_ELEMENT_END: + + // </LightComponent> + if(stringw("LightComponent") == file->getNodeName()) + return true; + + break; + + default: + + break; + } + + } + + // The code should never get here. + return false; +} + // End of File Modified: trunk/src/components/scene/LightComponent.h =================================================================== --- trunk/src/components/scene/LightComponent.h 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/LightComponent.h 2009-08-15 15:10:41 UTC (rev 104) @@ -58,6 +58,11 @@ //! @param radius The new radius. void setRadius(f32 radius); + // XML + //! Parses for a LightComponent. + //! @note For internal use only! + static bool parseXML(IXMLReader *file, Entity *entity); + private: // Members Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/MeshComponent.h 2009-08-15 15:10:41 UTC (rev 104) @@ -69,6 +69,7 @@ //! @note For internal use only! void onMesh(void *p); + // XML //! Parses for a MeshComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-08-13 10:18:28 UTC (rev 103) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-08-15 15:10:41 UTC (rev 104) @@ -316,4 +316,1196 @@ mParticleSystemSN->setParticleSize(size); } +// Parses for a ParticleSYsComponent. +bool ParticleSysComponent::parseXML(IXMLReader *file, Entity *entity) +{ + // Forward declaration. + ParticleSysComponent *component = NULL; + + // Are we dealing with a ParticleSysComponent? + if(file->getNodeType() == io::EXN_ELEMENT) + { + if(stringw("ParticleSysComponent") == file->getNodeName()) + { + // Initialise the component. + component = new ParticleSysComponent(entity); + } + } + + if(component == NULL) + return false; + + // Continue parsing the file. + while(file->read()) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <attractionAffector> + if(stringw("attractionAffector") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df point; + f32 speed = 1.0f; + bool attract = true; + bool affectX = true; + bool affectY = true; + bool affectZ = true; + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <point> + if(stringw("point") == file->getNodeName()) + { + point = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <speed> + else if(stringw("speed") == file->getNodeName()) + speed = file->getAttributeValueAsFloat(L"value"); + + // <attract> + else if(stringw("attract") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + attract = (value == "true") ? true : false ; + } + + // <affectX> + else if(stringw("affectX") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + affectX = (value == "true") ? true : false ; + } + + // <affectY> + else if(stringw("affectY") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + affectY = (value == "true") ? true : false ; + } + + // <affectZ> + else if(stringw("affectZ") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + affectZ = (value == "true") ? true : false ; + } + + break; + + case io::EXN_ELEMENT_END: + + // </attractionAffector> + if(stringw("attractionAffector") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the affector. + component->addAttractionAffector(point, speed, attract, affectX, affectY, affectZ); + } + + // <fadeOutParticleAffector> + else if(stringw("fadeOutParticleAffector") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + SColor targetColor = SColor(0, 0, 0, 0); + u32 timeNeededToFadeOut = 1000; + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <targetColor> + if(stringw("targetColor") == file->getNodeName()) + { + targetColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + else if(stringw("timeNeededToFadeOut") == file->getNodeName()) + timeNeededToFadeOut = file->getAttributeValueAsInt(L"value"); + + break; + + case io::EXN_ELEMENT_END: + + // </fadeOutParticleAffector> + if(stringw("fadeOutParticleAffector") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the affector. + component->addFadeOutParticleAffector(targetColor, timeNeededToFadeOut); + } + + // <gravityAffector> + else if(stringw("gravityAffector") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df gravity = vector3df(0.0f,-0.03f, 0.0f); + u32 timeForceLost = 1000; + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <gravity> + if(stringw("gravity") == file->getNodeName()) + { + gravity = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + else if(stringw("timeForceLost") == file->getNodeName()) + timeForceLost = file->getAttributeValueAsInt(L"value"); + + break; + + case io::EXN_ELEMENT_END: + + // </gravityAffector> + if(stringw("gravityAffector") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the affector. + component->addGravityAffector(gravity, timeForceLost); + } + + // <rotationAffector> + else if(stringw("rotationAffector") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df speed = vector3df(5.0f, 5.0f, 5.0f); + vector3df pivotPoint = vector3df(0.0f, 0.0f, 0.0f); + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <speed> + if(stringw("speed") == file->getNodeName()) + { + speed = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <pivotPoint> + else if(stringw("pivotPoint") == file->getNodeName()) + { + pivotPoint = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + break; + + case io::EXN_ELEMENT_END: + + // </rotationAffector> + if(stringw("rotationAffector") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the affector. + component->addRotationAffector(speed, pivotPoint); + } + + // <scaleParticleAffector> + else if(stringw("scaleParticleAffector") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + dimension2df scaleTo = dimension2df(1.0f, 1.0f); + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <scaleTo> + if(stringw("scaleTo") == file->getNodeName()) + { + scaleTo = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height") ); + } + + break; + + case io::EXN_ELEMENT_END: + + // </scaleParticleAffector> + if(stringw("scaleParticleAffector") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the affector. + component->addScaleParticleAffector(scaleTo); + } + + // <animatedMeshSceneNodeEmitter> + else if(stringw("animatedMeshSceneNodeEmitter") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + std::string fileName; + bool useNormalDirection = true; + vector3df direction = vector3df(0.0f, 0.03f, 0.0f); + f32 normalDirectionModifier = 100.0f; + bool everyMeshVertex = false; + u32 minParticlesPerSecond = 5; + u32 maxParticlesPerSecond = 10; + SColor minStartColor = SColor(255, 0, 0, 0); + SColor maxStartColor = SColor(255, 255, 255, 255); + u32 lifeTimeMin = 2000; + u32 lifeTimeMax = 4000; + s32 maxAngleDegrees = 0; + dimension2df minStartSize = dimension2df(5.0f, 5.0f); + dimension2df maxStartSize = dimension2df(5.0f, 5.0f); + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <fileName> + if(stringw("fileName") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + fileName = value.c_str(); + } + + // <useNormalDirection> + else if(stringw("useNormalDirection") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + useNormalDirection = (value == "true") ? true : false ; + } + + // <direction> + else if(stringw("direction") == file->getNodeName()) + { + direction = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <normalDirectionModifier> + else if(stringw("normalDirectionModifier") == file->getNodeName()) + normalDirectionModifier = file->getAttributeValueAsFloat(L"value"); + + // <everyMeshVertex> + else if(stringw("everyMeshVertex") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + everyMeshVertex = (value == "true") ? true : false ; + } + + // <minParticlesPerSecond> + else if(stringw("minParticlesPerSecond") == file->getNodeName()) + minParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <maxParticlesPerSecond> + else if(stringw("maxParticlesPerSecond") == file->getNodeName()) + maxParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <minStartColor> + else if(stringw("minStartColor") == file->getNodeName()) + { + minStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <maxStartColor> + else if(stringw("maxStartColor") == file->getNodeName()) + { + maxStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <lifeTimeMin> + else if(stringw("lifeTimeMin") == file->getNodeName()) + lifeTimeMin = file->getAttributeValueAsInt(L"value"); + + // <lifeTimeMin> + else if(stringw("lifeTimeMax") == file->getNodeName()) + lifeTimeMax = file->getAttributeValueAsInt(L"value"); + + // <maxAngleDegrees> + else if(stringw("maxAngleDegrees") == file->getNodeName()) + maxAngleDegrees = file->getAttributeValueAsInt(L"value"); + + // <minStartSize> + else if(stringw("minStartSize") == file->getNodeName()) + { + minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + // <maxStartSize> + else if(stringw("maxStartSize") == file->getNodeName()) + { + maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + break; + + case io::EXN_ELEMENT_END: + + // </animatedMeshSceneNodeEmitter> + if(stringw("animatedMeshSceneNodeEmitter") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the emitter. + component->setAnimatedMeshSceneNodeEmitter(fileName, useNormalDirection, direction, + normalDirectionModifier, everyMeshVertex, minParticlesPerSecond, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, + lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize); + } + + // <meshEmitter> + else if(stringw("meshEmitter") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + std::string fileName; + bool useNormalDirection = true; + vector3df direction = vector3df(0.0f, 0.03f, 0.0f); + f32 normalDirectionModifier = 100.0f; + bool everyMeshVertex = false; + u32 minParticlesPerSecond = 5; + u32 maxParticlesPerSecond = 10; + SColor minStartColor = SColor(255, 0, 0, 0); + SColor maxStartColor = SColor(255, 255, 255, 255); + u32 lifeTimeMin = 2000; + u32 lifeTimeMax = 4000; + s32 maxAngleDegrees = 0; + dimension2df minStartSize = dimension2df(5.0f, 5.0f); + dimension2df maxStartSize = dimension2df(5.0f, 5.0f); + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <fileName> + if(stringw("fileName") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + fileName = value.c_str(); + } + + // <useNormalDirection> + else if(stringw("useNormalDirection") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + useNormalDirection = (value == "true") ? true : false ; + } + + // <direction> + else if(stringw("direction") == file->getNodeName()) + { + direction = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <normalDirectionModifier> + else if(stringw("normalDirectionModifier") == file->getNodeName()) + normalDirectionModifier = file->getAttributeValueAsFloat(L"value"); + + // <everyMeshVertex> + else if(stringw("everyMeshVertex") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + everyMeshVertex = (value == "true") ? true : false ; + } + + // <minParticlesPerSecond> + else if(stringw("minParticlesPerSecond") == file->getNodeName()) + minParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <maxParticlesPerSecond> + else if(stringw("maxParticlesPerSecond") == file->getNodeName()) + maxParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <minStartColor> + else if(stringw("minStartColor") == file->getNodeName()) + { + minStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <maxStartColor> + else if(stringw("maxStartColor") == file->getNodeName()) + { + maxStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <lifeTimeMin> + else if(stringw("lifeTimeMin") == file->getNodeName()) + lifeTimeMin = file->getAttributeValueAsInt(L"value"); + + // <lifeTimeMin> + else if(stringw("lifeTimeMax") == file->getNodeName()) + lifeTimeMax = file->getAttributeValueAsInt(L"value"); + + // <maxAngleDegrees> + else if(stringw("maxAngleDegrees") == file->getNodeName()) + maxAngleDegrees = file->getAttributeValueAsInt(L"value"); + + // <minStartSize> + else if(stringw("minStartSize") == file->getNodeName()) + { + minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + // <maxStartSize> + else if(stringw("maxStartSize") == file->getNodeName()) + { + maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + break; + + case io::EXN_ELEMENT_END: + + // </meshEmitter> + if(stringw("meshEmitter") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the emitter. + component->setMeshEmitter(fileName, useNormalDirection, direction, + normalDirectionModifier, everyMeshVertex, minParticlesPerSecond, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, + lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize); + } + + // <boxEmitter> + else if(stringw("boxEmitter") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + aabbox3df box = aabbox3df(-10, 28,-10, 10, 30, 10); + vector3df direction = vector3df(0.0f, 0.03f, 0.0f); + u32 minParticlesPerSecond = 5; + u32 maxParticlesPerSecond = 10; + SColor minStartColor = SColor(255, 0, 0, 0); + SColor maxStartColor = SColor(255, 255, 255, 255); + u32 lifeTimeMin = 2000; + u32 lifeTimeMax = 4000; + s32 maxAngleDegrees = 0; + dimension2df minStartSize = dimension2df(5.0f, 5.0f); + dimension2df maxStartSize = dimension2df(5.0f, 5.0f); + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <box> + if(stringw("scaleTo") == file->getNodeName()) + { + box = aabbox3df( file->getAttributeValueAsFloat(L"minX"), + file->getAttributeValueAsFloat(L"minY"), + file->getAttributeValueAsFloat(L"minZ"), + file->getAttributeValueAsFloat(L"maxX"), + file->getAttributeValueAsFloat(L"maxY"), + file->getAttributeValueAsFloat(L"maxZ") ); + } + + // <direction> + else if(stringw("direction") == file->getNodeName()) + { + direction = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <minParticlesPerSecond> + else if(stringw("minParticlesPerSecond") == file->getNodeName()) + minParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <maxParticlesPerSecond> + else if(stringw("maxParticlesPerSecond") == file->getNodeName()) + maxParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <minStartColor> + else if(stringw("minStartColor") == file->getNodeName()) + { + minStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <maxStartColor> + else if(stringw("maxStartColor") == file->getNodeName()) + { + maxStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <lifeTimeMin> + else if(stringw("lifeTimeMin") == file->getNodeName()) + lifeTimeMin = file->getAttributeValueAsInt(L"value"); + + // <lifeTimeMin> + else if(stringw("lifeTimeMax") == file->getNodeName()) + lifeTimeMax = file->getAttributeValueAsInt(L"value"); + + // <maxAngleDegrees> + else if(stringw("maxAngleDegrees") == file->getNodeName()) + maxAngleDegrees = file->getAttributeValueAsInt(L"value"); + + // <minStartSize> + else if(stringw("minStartSize") == file->getNodeName()) + { + minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + // <maxStartSize> + else if(stringw("maxStartSize") == file->getNodeName()) + { + maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + break; + + case io::EXN_ELEMENT_END: + + // </boxEmitter> + if(stringw("boxEmitter") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the emitter + component->setBoxEmitter(box, direction, minParticlesPerSecond, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, + lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize); + } + + // <cylinderEmitter> + else if(stringw("cylinderEmitter") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df center; + f32 radius; + vector3df normal; + f32 length; + bool outlineOnly = false; + vector3df direction = vector3df(0.0f, 0.03f, 0.0f); + u32 minParticlesPerSecond = 5; + u32 maxParticlesPerSecond = 10; + SColor minStartColor = SColor(255, 0, 0, 0); + SColor maxStartColor = SColor(255, 255, 255, 255); + u32 lifeTimeMin = 2000; + u32 lifeTimeMax = 4000; + s32 maxAngleDegrees = 0; + dimension2df minStartSize = dimension2df(5.0f, 5.0f); + dimension2df maxStartSize = dimension2df(5.0f, 5.0f); + + 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"); + + // <normal> + else if(stringw("normal") == file->getNodeName()) + { + normal = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <length> + else if(stringw("length") == file->getNodeName()) + length = file->getAttributeValueAsFloat(L"value"); + + // <outlineOnly> + else if(stringw("outlineOnly") == file->getNodeName()) + { + stringc value = file->getAttributeValue(L"value"); + outlineOnly = (value == "true") ? true : false ; + } + + // <direction> + else if(stringw("direction") == file->getNodeName()) + { + direction = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <minParticlesPerSecond> + else if(stringw("minParticlesPerSecond") == file->getNodeName()) + minParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <maxParticlesPerSecond> + else if(stringw("maxParticlesPerSecond") == file->getNodeName()) + maxParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <minStartColor> + else if(stringw("minStartColor") == file->getNodeName()) + { + minStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <maxStartColor> + else if(stringw("maxStartColor") == file->getNodeName()) + { + maxStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <lifeTimeMin> + else if(stringw("lifeTimeMin") == file->getNodeName()) + lifeTimeMin = file->getAttributeValueAsInt(L"value"); + + // <lifeTimeMin> + else if(stringw("lifeTimeMax") == file->getNodeName()) + lifeTimeMax = file->getAttributeValueAsInt(L"value"); + + // <maxAngleDegrees> + else if(stringw("maxAngleDegrees") == file->getNodeName()) + maxAngleDegrees = file->getAttributeValueAsInt(L"value"); + + // <minStartSize> + else if(stringw("minStartSize") == file->getNodeName()) + { + minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + // <maxStartSize> + else if(stringw("maxStartSize") == file->getNodeName()) + { + maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + break; + + case io::EXN_ELEMENT_END: + + // </cylinderEmitter> + if(stringw("cylinderEmitter") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the emitter. + component->setCylinderEmitter(center, radius, normal, length, outlineOnly, + direction, minParticlesPerSecond, maxParticlesPerSecond, minStartColor, + maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees, + minStartSize, maxStartSize); + } + + // <pointEmitter> + else if(stringw("pointEmitter") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df direction = vector3df(0.0f, 0.03f, 0.0f); + u32 minParticlesPerSecond = 5; + u32 maxParticlesPerSecond = 10; + SColor minStartColor = SColor(255, 0, 0, 0); + SColor maxStartColor = SColor(255, 255, 255, 255); + u32 lifeTimeMin = 2000; + u32 lifeTimeMax = 4000; + s32 maxAngleDegrees = 0; + dimension2df minStartSize = dimension2df(5.0f, 5.0f); + dimension2df maxStartSize = dimension2df(5.0f, 5.0f); + + bool doneParsing = false; + + while(file->read() && !doneParsing) + { + switch(file->getNodeType()) + { + case io::EXN_ELEMENT: + + // <direction> + if(stringw("direction") == file->getNodeName()) + { + direction = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + // <minParticlesPerSecond> + else if(stringw("minParticlesPerSecond") == file->getNodeName()) + minParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <maxParticlesPerSecond> + else if(stringw("maxParticlesPerSecond") == file->getNodeName()) + maxParticlesPerSecond = file->getAttributeValueAsInt(L"value"); + + // <minStartColor> + else if(stringw("minStartColor") == file->getNodeName()) + { + minStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <maxStartColor> + else if(stringw("maxStartColor") == file->getNodeName()) + { + maxStartColor = SColor( file->getAttributeValueAsInt(L"a"), + file->getAttributeValueAsInt(L"r"), + file->getAttributeValueAsInt(L"g"), + file->getAttributeValueAsInt(L"b") ); + } + + // <lifeTimeMin> + else if(stringw("lifeTimeMin") == file->getNodeName()) + lifeTimeMin = file->getAttributeValueAsInt(L"value"); + + // <lifeTimeMin> + else if(stringw("lifeTimeMax") == file->getNodeName()) + lifeTimeMax = file->getAttributeValueAsInt(L"value"); + + // <maxAngleDegrees> + else if(stringw("maxAngleDegrees") == file->getNodeName()) + maxAngleDegrees = file->getAttributeValueAsInt(L"value"); + + // <minStartSize> + else if(stringw("minStartSize") == file->getNodeName()) + { + minStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + // <maxStartSize> + else if(stringw("maxStartSize") == file->getNodeName()) + { + maxStartSize = dimension2df( file->getAttributeValueAsFloat(L"width"), + file->getAttributeValueAsFloat(L"height")); + } + + break; + + case io::EXN_ELEMENT_END: + + // </pointEmitter> + if(stringw("pointEmitter") == file->getNodeName()) + doneParsing = true; + + break; + + default: + + break; + } + } + + // We create the emitter. + component->setPointEmitter(direction, minParticlesPerSecond, maxParticlesPerSecond, + minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, + maxAngleDegrees, minStartSize, maxStartSize); + } + + // <ringEmitter> + else if(stringw("ringEmitter") == file->getNodeName()) + { + // Retrieve required variables from internal loop. + vector3df center; + f32 radius; + f32 ringThickness; + vector3df direction = vector3df(0.0f, 0.03f, 0.0f); + u32 minParticlesPerSecond = 5; + u32 maxParticlesPerSecond = 10; + SColor minStartColor = SColor(255, 0, 0, 0); + SColor maxStartColor = SColor(255, 255, 255, 255); + u32 lifeTimeMin = 2000; + u32 lifeTimeMax = 4000; + s32 maxAngleDegrees = 0; + dimension2df minStartSize = dimension2df(5.0f, 5.0f); + dimension2df maxStartSize = dimension2df(5.0f, 5.0f); + + 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"); + + // <ringThickness> + else if(stringw("ringThickness") == file->getNodeName()) + ringThickness = file->getAttributeValueAsFloat(L"value"); + + // <direction> + else if(stringw("direction") == file->getNodeName()) + { + direction = vector3df( file->getAttributeValueAsFloat(L"x"), + file->getAttributeValueAsFloat(L"y"), + file->getAttributeValueAsFloat(L"z") ); + } + + ... [truncated message content] |
From: <zcc...@us...> - 2009-08-13 10:18:39
|
Revision: 103 http://sirrf.svn.sourceforge.net/sirrf/?rev=103&view=rev Author: zccdark203 Date: 2009-08-13 10:18:28 +0000 (Thu, 13 Aug 2009) Log Message: ----------- Made some small changes to the way the AssetGroup class handles filenames internally. Modified Paths: -------------- trunk/src/core/AssetGroup.cpp Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-11 10:24:42 UTC (rev 102) +++ trunk/src/core/AssetGroup.cpp 2009-08-13 10:18:28 UTC (rev 103) @@ -154,7 +154,7 @@ for(u32 i = 0; i < fileList->getFileCount(); i++) { // Get file name. - std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + std::string fileName = (fileList->getFileName(i)).c_str(); if(fileName == "..") continue; @@ -259,7 +259,7 @@ for(u32 i = 0; i < fileList->getFileCount(); i++) { // Get file name. - std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + std::string fileName = (fileList->getFileName(i)).c_str(); if(fileName == "..") continue; @@ -358,7 +358,7 @@ for(u32 i = 0; i < fileList->getFileCount(); i++) { // Get file name. - std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + std::string fileName = (fileList->getFileName(i)).c_str(); if(fileName == "..") continue; @@ -460,7 +460,7 @@ for(u32 i = 0; i < fileList->getFileCount(); i++) { // Get file name. - std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + std::string fileName = (fileList->getFileName(i)).c_str(); if(fileName == "..") continue; @@ -563,7 +563,7 @@ for(u32 i = 0; i < fileList->getFileCount(); i++) { // Get file name. - std::string fileName = (fileSystem->getFileBasename(fileList->getFullFileName(i))).c_str(); + std::string fileName = (fileList->getFileName(i)).c_str(); if(fileName == "..") continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-11 10:24:48
|
Revision: 102 http://sirrf.svn.sourceforge.net/sirrf/?rev=102&view=rev Author: zccdark203 Date: 2009-08-11 10:24:42 +0000 (Tue, 11 Aug 2009) Log Message: ----------- Fixed the bug where the onRotationChange event of the Entity class pointed to the parents onPositionChange method. Also, I made some small changes to some event methods. Modified Paths: -------------- trunk/src/components/scene/MeshComponent.h trunk/src/components/scene/SceneComponent.h trunk/src/components/sound/SoundSourceComponent.h trunk/src/core/Entity.cpp Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-08-10 18:12:05 UTC (rev 101) +++ trunk/src/components/scene/MeshComponent.h 2009-08-11 10:24:42 UTC (rev 102) @@ -67,7 +67,7 @@ // Events //! Responds to changes of the mesh attached to this component. //! @note For internal use only! - virtual void onMesh(void *p); + void onMesh(void *p); //! Parses for a MeshComponent. //! @note For internal use only! Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-08-10 18:12:05 UTC (rev 101) +++ trunk/src/components/scene/SceneComponent.h 2009-08-11 10:24:42 UTC (rev 102) @@ -182,7 +182,7 @@ void onUnPause(void *p); //! Responds to changes of a texture attached to this component. //! @note For internal use only! - virtual void onTexture(void *p); + void onTexture(void *p); // XML //! Parses for a SceneComponent. Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-08-10 18:12:05 UTC (rev 101) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-08-11 10:24:42 UTC (rev 102) @@ -116,7 +116,7 @@ void onUnPause(void *p); //! Responds to changes of the sound data attached to this component. //! @note For internal use only! - virtual void onSound(void *p); + void onSound(void *p); //! Parses for a SoundSourceComponent. //! @note For internal use only! Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-08-10 18:12:05 UTC (rev 101) +++ trunk/src/core/Entity.cpp 2009-08-11 10:24:42 UTC (rev 102) @@ -428,7 +428,7 @@ // Register events. pParent->connectEventSignal("onPositionChange", this, &Entity::onPositionChange); - pParent->connectEventSignal("onRotationChange", this, &Entity::onPositionChange); + pParent->connectEventSignal("onRotationChange", this, &Entity::onRotationChange); 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-08-10 18:12:15
|
Revision: 101 http://sirrf.svn.sourceforge.net/sirrf/?rev=101&view=rev Author: zccdark203 Date: 2009-08-10 18:12:05 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Mouse, Key, GUI events emitted by the EventManager now pass the appropriate event structure (SMouseInput, SKeyInput and SGUIEvent) as a parameter. Modified Paths: -------------- trunk/CHANGES trunk/src/core/EventManager.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-10 15:56:42 UTC (rev 100) +++ trunk/CHANGES 2009-08-10 18:12:05 UTC (rev 101) @@ -2,6 +2,10 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Mouse, Key, GUI events emitted by the EventManager now pass the + appropriate event structure (SMouseInput, SKeyInput and SGUIEvent) + as a parameter. + * Added the setAbsolutePosition method to the Entity class. Furthermore the setRotation and setAbsoluteRotation methods have also been added. As a result the rotation parameter has been scrapped from several Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-08-10 15:56:42 UTC (rev 100) +++ trunk/src/core/EventManager.cpp 2009-08-10 18:12:05 UTC (rev 101) @@ -417,7 +417,7 @@ else slotName = "onKeyUp#"; - mEvents["EventManager"][slotName + mKeyMap[event.KeyInput.Key]].emit(0); + mEvents["EventManager"][slotName + mKeyMap[event.KeyInput.Key]].emit((void*)&event.KeyInput); } // Mouse event. @@ -428,36 +428,36 @@ case EMIE_MOUSE_MOVED: // Did the mouse move? mMousePos.X = event.MouseInput.X; mMousePos.Y = event.MouseInput.Y; - mEvents["EventManager"]["onMouseMoved"].emit(0); + mEvents["EventManager"]["onMouseMoved"].emit((void*)&event.MouseInput); break; case EMIE_LMOUSE_PRESSED_DOWN: // Left mouse button was pressed down. - mEvents["EventManager"]["onMouseDown#Left"].emit(0); + mEvents["EventManager"]["onMouseDown#Left"].emit((void*)&event.MouseInput); break; case EMIE_RMOUSE_PRESSED_DOWN: // Right mouse button was pressed down. - mEvents["EventManager"]["onMouseDown#Right"].emit(0); + mEvents["EventManager"]["onMouseDown#Right"].emit((void*)&event.MouseInput); break; case EMIE_MMOUSE_PRESSED_DOWN: // Middle mouse button was pressed down. - mEvents["EventManager"]["onMouseDown#Middle"].emit(0); + mEvents["EventManager"]["onMouseDown#Middle"].emit((void*)&event.MouseInput); break; case EMIE_LMOUSE_LEFT_UP: // Left mouse button was left up. - mEvents["EventManager"]["onMouseUp#Left"].emit(0); + mEvents["EventManager"]["onMouseUp#Left"].emit((void*)&event.MouseInput); break; case EMIE_RMOUSE_LEFT_UP: // Right mouse button was left up. - mEvents["EventManager"]["onMouseUp#Right"].emit(0); + mEvents["EventManager"]["onMouseUp#Right"].emit((void*)&event.MouseInput); break; case EMIE_MMOUSE_LEFT_UP: // Middle mouse button was left up. - mEvents["EventManager"]["onMouseUp#Middle"].emit(0); + mEvents["EventManager"]["onMouseUp#Middle"].emit((void*)&event.MouseInput); break; case EMIE_MOUSE_WHEEL: // The mouse wheel was moved. mMouseWheel = event.MouseInput.Wheel; - mEvents["EventManager"]["onMouseWheel"].emit(0); + mEvents["EventManager"]["onMouseWheel"].emit((void*)&event.MouseInput); break; default: break; @@ -466,7 +466,7 @@ // GUI event. if(event.EventType == EET_GUI_EVENT) - mEvents["EventManager"]["onGUIEvent"].emit((void*)&event); + mEvents["EventManager"]["onGUIEvent"].emit((void*)&event.GUIEvent); return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-10 15:56:55
|
Revision: 100 http://sirrf.svn.sourceforge.net/sirrf/?rev=100&view=rev Author: zccdark203 Date: 2009-08-10 15:56:42 +0000 (Mon, 10 Aug 2009) Log Message: ----------- Added the setAbsolutePosition method to the Entity class. Furthermore the setRotation and setAbsoluteRotation methods have also been added. As a result the rotation parameter has been scrapped from several components. Modified Paths: -------------- trunk/CHANGES trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/BillboardComponent.cpp trunk/src/components/scene/CameraComponent.cpp trunk/src/components/scene/LightComponent.cpp trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/MeshComponent.h trunk/src/components/scene/OctTreeComponent.cpp 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/TerrainComponent.cpp trunk/src/components/scene/TerrainComponent.h trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundListenerComponent.h trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp trunk/src/scripting/components/scene/asMeshComponent.cpp trunk/src/scripting/components/scene/asParticleSysComponent.cpp trunk/src/scripting/components/scene/asTerrainComponent.cpp trunk/src/scripting/components/sound/asSoundListenerComponent.cpp trunk/src/scripting/components/sound/asSoundSourceComponent.cpp trunk/src/scripting/core/asEntity.cpp trunk/src/scripting/sound/asSoundManager.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/CHANGES 2009-08-10 15:56:42 UTC (rev 100) @@ -2,6 +2,11 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Added the setAbsolutePosition method to the Entity class. Furthermore + the setRotation and setAbsoluteRotation methods have also been added. + As a result the rotation parameter has been scrapped from several + components. + * Added the InitState class. The InitState is the first state that will be initialised by the GameManager class. InitState was created in order to separate initial state loading from the GameManager class. Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -28,19 +28,19 @@ // AnimatedMeshComponent constructor. AnimatedMeshComponent::AnimatedMeshComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale) + const vector3df &scale) : SceneComponent(parent, true) { - init(rotation, scale); + init(scale); setMesh(fileName); } // AnimatedMeshComponent constructor. AnimatedMeshComponent::AnimatedMeshComponent(Entity *parent, IAnimatedMesh *mesh, - const vector3df &rotation, const vector3df &scale) + const vector3df &scale) : SceneComponent(parent, true) { - init(rotation, scale); + init(scale); setMesh(mesh); } @@ -52,15 +52,16 @@ } // Common initialisation method. -void AnimatedMeshComponent::init(const vector3df &rotation, const vector3df &scale) +void AnimatedMeshComponent::init(const vector3df &scale) { // 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, pParent->getID(), - pParent->getPosition(), rotation, scale, - true); + pParent->getAbsolutePosition(), + pParent->getAbsoluteRotation(), + scale, true); mSceneNode = mAnimatedMeshSN; mShadowVolumeSN = NULL; Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-08-10 15:56:42 UTC (rev 100) @@ -34,19 +34,15 @@ //! Constructor //! @param parent The parent entity to which the component should be added. //! @param fileName Filename of the mesh to load. - //! @param rotation Initial rotation of the mesh. //! @param scale Initial scale of the mesh. AnimatedMeshComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation = vector3df(0, 0, 0), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); //! Constructor //! @param parent The parent entity to which the component should be added. //! @param mesh Pointer to the loaded animated mesh to be displayed. - //! @param rotation Initial rotation of the mesh. //! @param scale Initial scale of the mesh. //! @note Not available in AngelScript. AnimatedMeshComponent(Entity *parent, IAnimatedMesh *mesh, - const vector3df &rotation = vector3df(0, 0, 0), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); //! Deconstructor ~AnimatedMeshComponent(); @@ -143,8 +139,7 @@ // Private methods. //! Common initialisation method. - void init(const vector3df &rotation = vector3df(0, 0, 0), - const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); + void init(const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); // Members IAnimatedMeshSceneNode *mAnimatedMeshSN; Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -28,8 +28,8 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mBillboardSN = pSceneMgr->addBillboardSceneNode(0, size, parent->getPosition(), parent->getID(), - colorTop, colorBottom); + mBillboardSN = pSceneMgr->addBillboardSceneNode(0, size, parent->getAbsolutePosition(), + parent->getID(), colorTop, colorBottom); mSceneNode = mBillboardSN; // Set-up internal mechanism for collision detection. Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/CameraComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -27,7 +27,8 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mCameraSN = pSceneMgr->addCameraSceneNode(0, parent->getPosition(), lookat, parent->getID()); + mCameraSN = pSceneMgr->addCameraSceneNode(0, parent->getAbsolutePosition(), lookat, + parent->getID()); mSceneNode = mCameraSN; mCameraAnimator = NULL; @@ -155,7 +156,7 @@ // Sets the rotation of the node. void CameraComponent::setRotation(const vector3df &rotation) { - mCameraSN->setRotation(rotation); + mCameraSN->setRotation(pParent->getAbsoluteRotation() + rotation); } // Sets the look at target of the camera. Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/LightComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -27,7 +27,7 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mLightSN = pSceneMgr->addLightSceneNode(0, parent->getPosition(), color, radius, + mLightSN = pSceneMgr->addLightSceneNode(0, parent->getAbsolutePosition(), color, radius, parent->getID()); mSceneNode = mLightSN; Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/MeshComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -27,20 +27,18 @@ } // MeshComponent constructor. -MeshComponent::MeshComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale) +MeshComponent::MeshComponent(Entity *parent, const std::string &fileName, const vector3df &scale) : SceneComponent(parent, true) { - init(rotation, scale); + init(scale); setMesh(fileName); } // MeshComponent constructor. -MeshComponent::MeshComponent(Entity *parent, IMesh *mesh, const vector3df &rotation, - const vector3df &scale) +MeshComponent::MeshComponent(Entity *parent, IMesh *mesh, const vector3df &scale) : SceneComponent(parent, true) { - init(rotation, scale); + init(scale); setMesh(mesh); } @@ -58,14 +56,14 @@ } // Common initialisation method. -void MeshComponent::init(const vector3df &rotation, const vector3df &scale) +void MeshComponent::init(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(0, 0, pParent->getID(), pParent->getPosition(), rotation, - scale, true); + mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, pParent->getID(), pParent->getAbsolutePosition(), + pParent->getAbsoluteRotation(), scale, true); mSceneNode = mMeshSN; // Set-up internal mechanism for collision detection. Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/MeshComponent.h 2009-08-10 15:56:42 UTC (rev 100) @@ -34,19 +34,15 @@ //! Constructor //! @param parent The parent entity to which the component should be added. //! @param fileName Filename of the mesh to load. - //! @param rotation Initial rotation of the mesh. //! @param scale Initial scale of the mesh. MeshComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation = vector3df(0, 0, 0), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); //! Constructor //! @param parent The parent entity to which the component should be added. //! @param mesh Pointer to the loaded animated mesh to be displayed. - //! @param rotation Initial rotation of the mesh. //! @param scale Initial scale of the mesh. //! @note Not available in AngelScript. MeshComponent(Entity *parent, IMesh *mesh, - const vector3df &rotation = vector3df(0, 0, 0), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); //! Deconstructor ~MeshComponent(); @@ -94,8 +90,7 @@ // Private methods. //! Common initialisation method. - void init(const vector3df &rotation = vector3df(0, 0, 0), - const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); + void init(const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); }; #endif Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -65,7 +65,8 @@ // Create the internal scene node. mMeshSN = pSceneMgr->addOctTreeSceneNode((IMesh*)0, 0, pParent->getID(), minPolysPerNode, true); mSceneNode = mMeshSN; - mSceneNode->setPosition(pParent->getPosition()); + mSceneNode->setPosition(pParent->getAbsolutePosition()); + mSceneNode->setRotation(pParent->getAbsoluteRotation()); // Misc. variables. mMinPolysPerNode = minPolysPerNode; Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -20,8 +20,7 @@ // ParticleSysComponent class // ParticleSysComponent constructor (default). -ParticleSysComponent::ParticleSysComponent(Entity *parent, const vector3df &rotation, - const vector3df &scale) +ParticleSysComponent::ParticleSysComponent(Entity *parent, const vector3df &scale) : SceneComponent(parent, true) { // Get pointers to needed sub-systems of the Game Manager. @@ -29,7 +28,8 @@ // Create the s32ernal scene node. mParticleSystemSN = pSceneMgr->addParticleSystemSceneNode(true, 0, parent->getID(), - parent->getPosition(), rotation, + parent->getAbsolutePosition(), + parent->getAbsoluteRotation(), scale); mSceneNode = mParticleSystemSN; Modified: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-08-10 15:56:42 UTC (rev 100) @@ -30,10 +30,8 @@ // Initialisation and deinitialisation //! Constructor (default) //! @param parent The parent entity to which the component should be added. - //! @param rotation Initial rotation of the component. //! @param scale Initial scale of the component. - ParticleSysComponent(Entity *parent, const vector3df &rotation = vector3df(0, 0, 0), - const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); + ParticleSysComponent(Entity *parent, const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); //! Deconstructor ~ParticleSysComponent(); Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/SceneComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -62,6 +62,7 @@ // Register events. pParent->connectEventSignal("onPositionChange", this, &SceneComponent::onPositionChange); + pParent->connectEventSignal("onRotationChange", this, &SceneComponent::onRotationChange); pParent->connectEventSignal("onUpdate", this, &SceneComponent::onUpdate); pParent->connectEventSignal("onPause", this, &SceneComponent::onPause); pParent->connectEventSignal("onUnPause", this, &SceneComponent::onUnPause); @@ -199,7 +200,7 @@ // Gets the relative position of the component. const vector3df SceneComponent::getPosition() const { - return mSceneNode->getPosition() - pParent->getPosition(); + return mSceneNode->getAbsolutePosition() - pParent->getAbsolutePosition(); } // Gets the rotation of the component. @@ -315,13 +316,13 @@ // Sets the relative position of the component. void SceneComponent::setPosition(const vector3df &position) { - mSceneNode->setPosition(pParent->getPosition() + position); + mSceneNode->setPosition(pParent->getAbsolutePosition() + position); } // Sets the rotation of the component. void SceneComponent::setRotation(const vector3df &rotation) { - mSceneNode->setRotation(rotation); + mSceneNode->setRotation(pParent->getAbsoluteRotation() + rotation); } // Sets the relative scale of the component. @@ -347,6 +348,16 @@ } } +// Updates the rotation of the component after its parent has been updated. +void SceneComponent::onRotationChange(void *p) +{ + if(!mEvokedParentChange) + { + vector3df diff = reinterpret_cast<vector3df*>(p)[0]; + mSceneNode->setRotation(mSceneNode->getRotation() + diff); + } +} + // Updates the component if the parent is updated. void SceneComponent::onUpdate(void *p) { @@ -360,9 +371,21 @@ if(diff != vector3df(0)) { mEvokedParentChange = true; - pParent->setPosition(pParent->getPosition() + diff); + pParent->setAbsolutePosition(pParent->getAbsolutePosition() + diff); mEvokedParentChange = false; } + + // We're going to check if an animator has changed the rotation of our scene node. + // If that's the case we'll have to correct the change upstream. + diff = mSceneNode->getRotation() - mLastRot; + mLastRot = mSceneNode->getRotation(); + + if(diff != vector3df(0)) + { + mEvokedParentChange = true; + pParent->setAbsoluteRotation(pParent->getAbsoluteRotation() + diff); + mEvokedParentChange = false; + } } } Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/SceneComponent.h 2009-08-10 15:56:42 UTC (rev 100) @@ -156,7 +156,7 @@ void setPosition(const vector3df &position); //! Sets the rotation of the component. //! @param rotation New rotation of the component in degrees. - void setRotation(const vector3df &rotation); + virtual void setRotation(const vector3df &rotation); //! Sets the relative scale of the component. //! @param scale New scale of the node void setScale(const vector3df &scale); @@ -168,6 +168,9 @@ //! Updates the position of the component after its parent has been updated. //! @note For internal use only! void onPositionChange(void *p); + //! Updates the rotation of the component after its parent has been updated. + //! @note For internal use only! + void onRotationChange(void *p); //! Updates the component if the parent is updated. //! @note For internal use only! void onUpdate(void *p); @@ -208,6 +211,7 @@ // Private members vector3df mLastPos; + vector3df mLastRot; bool mCanAffectParent; bool mEvokedParentChange; Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -28,11 +28,11 @@ // TerrainComponent constructor. TerrainComponent::TerrainComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale, - const SColor &vertexColor, s32 maxLOD, s32 smoothFactor) + const vector3df &scale, const SColor &vertexColor, s32 maxLOD, + s32 smoothFactor) : SceneComponent(parent, true) { - init(rotation, scale, vertexColor, maxLOD, smoothFactor); + init(scale, vertexColor, maxLOD, smoothFactor); loadHeightMap(fileName.c_str(), vertexColor, smoothFactor); } @@ -44,16 +44,17 @@ } // Common initialisation method. -void TerrainComponent::init(const vector3df &rotation, const vector3df &scale, - const SColor &vertexColor, s32 maxLOD, s32 smoothFactor) +void TerrainComponent::init(const vector3df &scale, const SColor &vertexColor, s32 maxLOD, + s32 smoothFactor) { // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. mTerrainSN = pSceneMgr->addTerrainSceneNode(0, 0, pParent->getID(), - pParent->getPosition(), rotation, scale, - vertexColor, maxLOD, ETPS_17, smoothFactor, true); + pParent->getAbsolutePosition(), + pParent->getAbsoluteRotation(), scale, vertexColor, + maxLOD, ETPS_17, smoothFactor, true); mSceneNode = mTerrainSN; // Set-up internal mechanism for collision detection. Modified: trunk/src/components/scene/TerrainComponent.h =================================================================== --- trunk/src/components/scene/TerrainComponent.h 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/TerrainComponent.h 2009-08-10 15:56:42 UTC (rev 100) @@ -34,13 +34,11 @@ //! Constructor //! @param parent The parent entity to which the component should be added. //! @param fileName Filename of the heightmap to load. - //! @param rotation The initial rotation of the component. //! @param scale The initial scale of the component. //! @param vertexColor The default color of all the vertices. //! @param maxLOD The maximum LOD (level of detail) for the component. //! @param smoothFactor The number of times the vertices are smoothed. TerrainComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation = vector3df(0.0f, 0.0f, 0.0f), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f), const SColor &vertexColor = SColor(255, 255, 255, 255), s32 maxLOD = 5, s32 smoothFactor = 0); @@ -96,8 +94,7 @@ // Private methods //! Common initialisation method. - void init(const vector3df &rotation = vector3df(0.0f, 0.0f, 0.0f), - const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f), + void init(const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f), const SColor &vertexColor = SColor(255, 255, 255, 255), s32 maxLOD = 5, s32 smoothFactor = 0); Modified: trunk/src/components/scene/TextBillboardComponent.cpp =================================================================== --- trunk/src/components/scene/TextBillboardComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/scene/TextBillboardComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -65,7 +65,7 @@ // Create internal scene node. mBillboardTextSN = pSceneMgr->addBillboardTextSceneNode(font, text, 0, size, - pParent->getPosition(), + pParent->getAbsolutePosition(), pParent->getID(), colorTop, colorBottom); mBillboardSN = mBillboardTextSN; Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -25,7 +25,8 @@ // SoundListener constructor. SoundListenerComponent::SoundListenerComponent(Entity *parent, bool isMainListener) -: EntityComponent(parent), mPosition(parent->getPosition()), mTarget(vector3df(0, 0, 0)) +: EntityComponent(parent), mPosition(parent->getAbsolutePosition()), + mRotation(parent->getAbsoluteRotation()) { // Is this the new main listener? if(isMainListener) @@ -41,6 +42,7 @@ // Register events. pParent->connectEventSignal("onPositionChange", this, &SoundListenerComponent::onPositionChange); + pParent->connectEventSignal("onRotationChange", this, &SoundListenerComponent::onPositionChange); pParent->connectEventSignal("onPause", this, &SoundListenerComponent::onPause); pParent->connectEventSignal("onUnPause", this, &SoundListenerComponent::onUnPause); } @@ -57,12 +59,6 @@ return mIsMainListener; } -// Gets the target direction of this listener. -const vector3df& SoundListenerComponent::getTarget() const -{ - return mTarget; -} - // Sets whether this listener is the main listener. void SoundListenerComponent::setIsMainListener(bool value) { @@ -72,7 +68,7 @@ mIsMainListener = true; sf::Listener::SetPosition(mPosition.X, mPosition.Y, mPosition.Z); - sf::Listener::SetTarget(mTarget.X, mTarget.Y, mTarget.Z); + sf::Listener::SetTarget(mRotation.X, mRotation.Y, mRotation.Z); } else @@ -84,14 +80,6 @@ } } -// Sets the target direction of this listener. -void SoundListenerComponent::setTarget(const vector3df &target) -{ - mTarget = target; - if(mIsMainListener) - sf::Listener::SetTarget(mTarget.X, mTarget.Y, mTarget.Z); -} - // Events // Updates the position of the component after its parent has been updated. void SoundListenerComponent::onPositionChange(void *p) @@ -101,6 +89,14 @@ sf::Listener::SetPosition(mPosition.X, mPosition.Y, mPosition.Z); } +// Updates the rotation of the component after its parent has been updated. +void SoundListenerComponent::onRotationChange(void *p) +{ + mRotation += reinterpret_cast<vector3df*>(p)[0]; + if(mIsMainListener) + sf::Listener::SetTarget(mRotation.X, mRotation.Y, mRotation.Z); +} + // Pauses the component if the parent is paused. void SoundListenerComponent::onPause(void *p) { @@ -148,18 +144,7 @@ component->setIsMainListener( (value == "true") ? true : false ); } - // <target> - else 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: Modified: trunk/src/components/sound/SoundListenerComponent.h =================================================================== --- trunk/src/components/sound/SoundListenerComponent.h 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/sound/SoundListenerComponent.h 2009-08-10 15:56:42 UTC (rev 100) @@ -39,20 +39,18 @@ // Methods //! Checks if this listener is the main listener. bool getIsMainListener() const; - //! Gets the target direction of this listener. - const vector3df& getTarget() const; //! Sets whether this listener is the main listener. //! @param value Value to enable or disable this option. void setIsMainListener(bool value = true); - //! Sets the target direction of this listener. - //! @param target Position of the point the listener must look at. - void setTarget(const vector3df &target); // Events //! Updates the position of the component after its parent has been updated. //! @note For internal use only! void onPositionChange(void *p); + //! Updates the rotation of the component after its parent has been updated. + //! @note For internal use only! + void onRotationChange(void *p); //! Pauses the component if the parent is paused. //! @note For internal use only! void onPause(void *p); @@ -71,7 +69,7 @@ // Members vector3df mPosition; - vector3df mTarget; + vector3df mRotation; bool mIsMainListener; bool mWasMainListener; // For event handeling Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -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(parent->getPosition()), mVolume(100) + mLoop(false), mMinDistance(1.0f), mPitch(1.0f), mPosition(parent->getAbsolutePosition()), mVolume(100) { // Set misc. variables. mName = "SoundSourceComponent"; Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/core/Entity.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -30,6 +30,7 @@ // Create event slots. createEventSlot("onPositionChange"); + createEventSlot("onRotationChange"); createEventSlot("onUpdate"); createEventSlot("onRender"); createEventSlot("onPause"); @@ -164,12 +165,30 @@ return pParent; } +// Gets the absolute position of the entity. +const vector3df& Entity::getAbsolutePosition() const +{ + return mAbsolutePosition; +} + // Gets the position of the entity. const vector3df& Entity::getPosition() const { return mPosition; } +// Gets the absolute rotation of the entity. +const vector3df& Entity::getAbsoluteRotation() const +{ + return mAbsoluteRotation; +} + +// Gets the rotation of the entity. +const vector3df& Entity::getRotation() const +{ + return mRotation; +} + // Removes all children. void Entity::removeChildren() { @@ -344,19 +363,33 @@ parent->removeChild(this); parent->drop(); + parent->disconnectEventSignal("onPositionChange", this); + parent->disconnectEventSignal("onRotationChange", this); parent->disconnectEventSignal("onUpdate", this); - parent->disconnectEventSignal("onUpdate", this); parent->disconnectEventSignal("onRender", this); parent->disconnectEventSignal("onPause", this); parent->disconnectEventSignal("onUnPause", this); } } +// Sets the absolute position of the entity. +void Entity::setAbsolutePosition(const vector3df &position) +{ + vector3df diff = position - mAbsolutePosition; + + mAbsolutePosition = position; + mPosition += diff; + + emitEvent("onPositionChange", &diff); +} + // Sets the position of the entity. void Entity::setPosition(const vector3df &position) { vector3df diff = position - mPosition; + mPosition = position; + mAbsolutePosition += diff; emitEvent("onPositionChange", &diff); } @@ -386,11 +419,16 @@ pParent = parent; pParent->grab(); - // Inherit position. + // Inherit position and rotation. + setAbsolutePosition(pParent->getAbsolutePosition()); setPosition(pParent->getPosition()); + setAbsoluteRotation(pParent->getAbsoluteRotation()); + setRotation(pParent->getRotation()); + // Register events. pParent->connectEventSignal("onPositionChange", this, &Entity::onPositionChange); + pParent->connectEventSignal("onRotationChange", this, &Entity::onPositionChange); pParent->connectEventSignal("onUpdate", this, &Entity::onUpdate); pParent->connectEventSignal("onRender", this, &Entity::onRender); pParent->connectEventSignal("onPause", this, &Entity::onPause); @@ -402,15 +440,50 @@ return true; } +// Sets the absolute rotation of the entity. +void Entity::setAbsoluteRotation(const vector3df &rotation) +{ + vector3df diff = rotation - mAbsoluteRotation; + + mAbsoluteRotation = rotation; + mRotation += diff; + + emitEvent("onRotationChange", &diff); +} + +// Sets the rotation of the entity. +void Entity::setRotation(const vector3df &rotation) +{ + vector3df diff = rotation - mRotation; + + mRotation = rotation; + mAbsoluteRotation += diff; + + emitEvent("onRotationChange", &diff); +} + // Updates the position of the entity after its parent has been updated. void Entity::onPositionChange(void *p) { vector3df diff = reinterpret_cast<vector3df*>(p)[0]; + + mAbsolutePosition += diff; mPosition += diff; emitEvent("onPositionChange", &diff); } +// Updates the rotation of the entity after its parent has been updated. +void Entity::onRotationChange(void *p) +{ + vector3df diff = reinterpret_cast<vector3df*>(p)[0]; + + mAbsoluteRotation += diff; + mRotation += diff; + + emitEvent("onRotationChange", &diff); +} + // Updates the entity if the parent is updated. void Entity::onUpdate(void *p) { Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/core/Entity.h 2009-08-10 15:56:42 UTC (rev 100) @@ -79,8 +79,14 @@ //! @return Pointer to the parent, NULL if there is no parent. Entity *getParent() const; + //! Gets the absolute position of the entity. + const vector3df& getAbsolutePosition() const; //! Gets the position of the entity. const vector3df& getPosition() const; + //! Gets the absolute rotation of the entity. + const vector3df& getAbsoluteRotation() const; + //! Gets the rotation of the entity. + const vector3df& getRotation() const; //! Removes all children. void removeChildren(); @@ -113,9 +119,18 @@ //! Removes the current parent of this entity. void removeParent(); + //! Sets the absolute position of the entity. + //! @param position New absolute position of the entity. + void setAbsolutePosition(const vector3df &position); //! Sets the position of the entity. //! @param position New position of the entity. void setPosition(const vector3df &position); + //! Sets the absolute rotation of the entity. + //! @param rotation New absolute rotation of the entity. + void setAbsoluteRotation(const vector3df &rotation); + //! Sets the rotation of the entity. + //! @param rotation New rotation of the entity. + void setRotation(const vector3df &rotation); //! Sets the parent of the entity. //! @param parent Parent of the entity. @@ -125,6 +140,9 @@ //! Updates the position of the entity after its parent has been updated. //! @note For internal use only! void onPositionChange(void *p); + //! Updates the rotation of the entity after its parent has been updated. + //! @note For internal use only! + void onRotationChange(void *p); //! Updates the entity if the parent is updated. //! @note For internal use only! void onUpdate(void *p); @@ -151,6 +169,9 @@ std::string mName; vector3df mPosition; + vector3df mRotation; + vector3df mAbsolutePosition; // We store the absolute values too so that we don't have to + vector3df mAbsoluteRotation; // recalculate these values when we need them. bool mIsAddingChild; Modified: trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/components/scene/asAnimatedMeshComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -32,10 +32,9 @@ //! Reference factory for the AnimatedMeshComponent class. AnimatedMeshComponent* createAnimatedMeshComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale) { - return new AnimatedMeshComponent(parent, fileName, rotation, scale); + return new AnimatedMeshComponent(parent, fileName, scale); } //! Binds the AnimatedMeshComponent class to AngelScript. @@ -55,10 +54,9 @@ asFUNCTIONPR(createAnimatedMeshComponent, (Entity*), AnimatedMeshComponent*), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("AnimatedMeshComponent", asBEHAVE_FACTORY, "AnimatedMeshComponent@ f(Entity @+, " \ - "const string &in, const vector3df &in, const vector3df &in)", - asFUNCTIONPR(createAnimatedMeshComponent, (Entity*, const std::string&, - const vector3df&, const vector3df&), AnimatedMeshComponent*), asCALL_CDECL); - assert(r >= 0); + "const string &in, const vector3df &in)", asFUNCTIONPR(createAnimatedMeshComponent, + (Entity*, const std::string&, const vector3df&), AnimatedMeshComponent*), + asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("AnimatedMeshComponent", asBEHAVE_ASSIGNMENT, "AnimatedMeshComponent&" \ " f(const AnimatedMeshComponent &in)", Modified: trunk/src/scripting/components/scene/asMeshComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asMeshComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/components/scene/asMeshComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -29,9 +29,9 @@ //! Reference factory for the MeshComponent class. MeshComponent* createMeshComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale) + const vector3df &scale) { - return new MeshComponent(parent, fileName, rotation, scale); + return new MeshComponent(parent, fileName, scale); } //! Binds the MeshComponent class to AngelScript. @@ -50,8 +50,7 @@ r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_FACTORY, "MeshComponent@ f(Entity @+)", asFUNCTIONPR(createMeshComponent, (Entity*), MeshComponent*), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_FACTORY, "MeshComponent@ f(Entity @+, const string &in, " \ - "const vector3df &in, const vector3df &in)", - asFUNCTIONPR(createMeshComponent, (Entity*, const std::string&, const vector3df&, + "const vector3df &in)", asFUNCTIONPR(createMeshComponent, (Entity*, const std::string&, const vector3df&), MeshComponent*), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_ASSIGNMENT, "MeshComponent& f(const MeshComponent &in)", Modified: trunk/src/scripting/components/scene/asParticleSysComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asParticleSysComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/components/scene/asParticleSysComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -25,10 +25,9 @@ //! Reference factory for the ParticleSysComponent class. -ParticleSysComponent* createParticleSysComponent(Entity *parent, const vector3df &rotation, - const vector3df &scale) +ParticleSysComponent* createParticleSysComponent(Entity *parent, const vector3df &scale) { - return new ParticleSysComponent(parent, rotation, scale); + return new ParticleSysComponent(parent, scale); } //! Binds the ParticleSysComponent class to AngelScript. @@ -45,8 +44,7 @@ // Set SkyboxComponent behaviour. r = engine->RegisterObjectBehaviour("ParticleSysComponent", asBEHAVE_FACTORY, "ParticleSysComponent@ f(Entity @+, " \ - "const vector3df &in, const vector3df &in)", - asFUNCTIONPR(createParticleSysComponent, (Entity*, const vector3df&, + "const vector3df &in)", asFUNCTIONPR(createParticleSysComponent, (Entity*, const vector3df&), ParticleSysComponent*), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("ParticleSysComponent", asBEHAVE_ASSIGNMENT, "ParticleSysComponent& " \ Modified: trunk/src/scripting/components/scene/asTerrainComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asTerrainComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/components/scene/asTerrainComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -32,11 +32,10 @@ //! Reference factory for the TerrainComponent class. TerrainComponent* createTerrainComponent(Entity *parent, const std::string &fileName, - const vector3df &rotation, const vector3df &scale, - const SColor &vertexColor, s32 maxLOD, - s32 smoothFactor) + const vector3df &scale, const SColor &vertexColor, + s32 maxLOD, s32 smoothFactor) { - return new TerrainComponent(parent, fileName, rotation, scale, vertexColor, maxLOD, smoothFactor); + return new TerrainComponent(parent, fileName, scale, vertexColor, maxLOD, smoothFactor); } //! Binds the TerrainComponent class to AngelScript. @@ -56,10 +55,10 @@ asFUNCTIONPR(createTerrainComponent, (Entity*), TerrainComponent*), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("TerrainComponent", asBEHAVE_FACTORY, "TerrainComponent@ f(Entity @+, " \ - "const string &in, const vector3df &in, const vector3df &in," \ - "const SColor &in, s32, s32)", asFUNCTIONPR(createTerrainComponent, - (Entity*, const std::string &, const vector3df &, const vector3df &, - const SColor &, s32, s32), TerrainComponent*), asCALL_CDECL); assert(r >= 0); + "const string &in, const vector3df &in, const SColor &in, s32, s32)", + asFUNCTIONPR(createTerrainComponent, (Entity*, const std::string &, + const vector3df &, const SColor &, s32, s32), TerrainComponent*), + asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("TerrainComponent", asBEHAVE_ASSIGNMENT, "TerrainComponent& " \ "f(const TerrainComponent &in)", Modified: trunk/src/scripting/components/sound/asSoundListenerComponent.cpp =================================================================== --- trunk/src/scripting/components/sound/asSoundListenerComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/components/sound/asSoundListenerComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -61,15 +61,11 @@ // Bind SoundListenerComponent class functions. r = engine->RegisterObjectMethod("SoundListenerComponent", "bool getIsMainListener()", asMETHOD(SoundListenerComponent, getIsMainListener), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("SoundListenerComponent", "const vector3df& getTarget()", - asMETHOD(SoundListenerComponent, getTarget), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("SoundListenerComponent", "void setIsMainListener()", asMETHOD(SoundListenerComponent, setIsMainListener), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("SoundListenerComponent", "void setIsMainListener(bool)", asMETHOD(SoundListenerComponent, setIsMainListener), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("SoundListenerComponent", "void setTarget(const vector3df &in)", - asMETHOD(SoundListenerComponent, setTarget), asCALL_THISCALL); assert(r >= 0); } #endif // __COMPILE_WITH_SFML_AUDIO__ Modified: trunk/src/scripting/components/sound/asSoundSourceComponent.cpp =================================================================== --- trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/components/sound/asSoundSourceComponent.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -59,8 +59,6 @@ // 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/core/asEntity.cpp =================================================================== --- trunk/src/scripting/core/asEntity.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/core/asEntity.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -104,6 +104,15 @@ r = engine->RegisterObjectMethod("Entity", "void setParent(Entity @+)", asMETHOD(Entity, setParent), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("Entity", "void setAbsolutePosition(vector3df &in)", + asMETHOD(Entity, setAbsolutePosition), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void setPosition(vector3df &in)", + asMETHOD(Entity, setPosition), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void setAbsoluteRotation(vector3df &in)", + asMETHOD(Entity, setAbsoluteRotation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void setRotation(vector3df &in)", + asMETHOD(Entity, setRotation), asCALL_THISCALL); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/sound/asSoundManager.cpp =================================================================== --- trunk/src/scripting/sound/asSoundManager.cpp 2009-08-09 19:43:23 UTC (rev 99) +++ trunk/src/scripting/sound/asSoundManager.cpp 2009-08-10 15:56:42 UTC (rev 100) @@ -50,8 +50,6 @@ 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); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-09 19:43:35
|
Revision: 99 http://sirrf.svn.sourceforge.net/sirrf/?rev=99&view=rev Author: zccdark203 Date: 2009-08-09 19:43:23 +0000 (Sun, 09 Aug 2009) Log Message: ----------- Added the InitState class. The InitState is the first state that will be initialised by the GameManager class. InitState was created in order to separate initial state loading from the GameManager class. Additionally the state can be used as a template for other GameState based classes. Modified Paths: -------------- trunk/CHANGES trunk/build/CMake/CMakeLists.txt trunk/build/CodeBlocks/sirrf.cbp trunk/src/core/GameManager.cpp Added Paths: ----------- trunk/src/game/InitState.cpp trunk/src/game/InitState.h Removed Paths: ------------- trunk/src/game/readme.txt Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-08 20:51:55 UTC (rev 98) +++ trunk/CHANGES 2009-08-09 19:43:23 UTC (rev 99) @@ -2,6 +2,12 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Added the InitState class. The InitState is the first state that will + be initialised by the GameManager class. InitState was created in + order to separate initial state loading from the GameManager class. + Additionally the class can be used a template for other GameState + based classes. + * Added the setTextures methods to the SkyBoxComponent class. These methods can be used to set textures after initialisation of the SkyBoxComponent. Modified: trunk/build/CMake/CMakeLists.txt =================================================================== --- trunk/build/CMake/CMakeLists.txt 2009-08-08 20:51:55 UTC (rev 98) +++ trunk/build/CMake/CMakeLists.txt 2009-08-09 19:43:23 UTC (rev 99) @@ -47,7 +47,7 @@ ${SOURCE_DIR}core/ReferenceCounted.cpp # /src/game - # Define here your own source files. + ${SOURCE_DIR}game/InitState.cpp # /src/scripting ${SOURCE_DIR}scripting/Script.cpp Modified: trunk/build/CodeBlocks/sirrf.cbp =================================================================== --- trunk/build/CodeBlocks/sirrf.cbp 2009-08-08 20:51:55 UTC (rev 98) +++ trunk/build/CodeBlocks/sirrf.cbp 2009-08-09 19:43:23 UTC (rev 99) @@ -116,6 +116,8 @@ <Unit filename="../../src/core/ReferenceCounted.cpp" /> <Unit filename="../../src/core/ReferenceCounted.h" /> <Unit filename="../../src/dependencies.h" /> + <Unit filename="../../src/game/InitState.cpp" /> + <Unit filename="../../src/game/InitState.h" /> <Unit filename="../../src/main.cpp" /> <Unit filename="../../src/scripting/Script.cpp" /> <Unit filename="../../src/scripting/Script.h" /> Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-08-08 20:51:55 UTC (rev 98) +++ trunk/src/core/GameManager.cpp 2009-08-09 19:43:23 UTC (rev 99) @@ -18,6 +18,7 @@ // Include files #include "GameManager.h" +#include "../game/InitState.h" #ifdef __COMPILE_WITH_ANGELSCRIPT__ #include "../scripting/core/asGameState.h" // We need the ScriptedGameState class. @@ -83,6 +84,9 @@ pScriptManager = new ScriptManager(); pScriptManager->init(); #endif // __COMPILE_WITH_ANGELSCRIPT__ + + // Change to the init state. + changeState(new InitState()); } // Updates the GameManager. Added: trunk/src/game/InitState.cpp =================================================================== --- trunk/src/game/InitState.cpp (rev 0) +++ trunk/src/game/InitState.cpp 2009-08-09 19:43:23 UTC (rev 99) @@ -0,0 +1,56 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: InitState.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : The InitState class is the first state the GameManager +// initialises. This class was created to separate initial +// state loading from the GameManager code. Additionally you +// can also use the InitState as a template for your custom +// states. +// +// 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 "InitState.h" +#include "../core/GameManager.h" + + +// InitState class +// InitState constructor. +InitState::InitState() +{ +} + +// InitState deconstructor. +InitState::~InitState() +{ +} + +// Initialises the InitState class. +void InitState::init() +{ +} + +// Clears the InitState class. +void InitState::clear() +{ +} + +// Updates the InitState class. +void InitState::update(f32 deltaTime) +{ +} + +// Renders the InitState class. +void InitState::render() +{ +} + +// End of File Added: trunk/src/game/InitState.h =================================================================== --- trunk/src/game/InitState.h (rev 0) +++ trunk/src/game/InitState.h 2009-08-09 19:43:23 UTC (rev 99) @@ -0,0 +1,52 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: InitState.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the InitState 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 +#ifndef __INITSTATE_H__ +#define __INITSTATE_H__ + +// Include files +#include "../dependencies.h" +#include "../core/GameState.h" + + +// InitState class +//! The InitState class is the first state the GameManager initialises. This +//! class was created to separate initial state loading from the GameManager +//! code. Additionally you can also use the InitState as a template for your +//! custom states. +class InitState : public GameState +{ +public: + + // Initialisation, deinitialisation and control... + //! Constructor + InitState(); + //! Deconstructor + ~InitState(); + + //! Initialises the InitState. + void init(); + //! Clears the InitState. + void clear(); + + //! Updates the InitState. + //! @param deltaTime The time that has passed since the last update. + void update(f32 deltaTime); + //! Renders the InitState. + void render(); +}; + +#endif Deleted: trunk/src/game/readme.txt =================================================================== --- trunk/src/game/readme.txt 2009-08-08 20:51:55 UTC (rev 98) +++ trunk/src/game/readme.txt 2009-08-09 19:43:23 UTC (rev 99) @@ -1 +0,0 @@ -Placeholder for states. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-08-08 20:52:04
|
Revision: 98 http://sirrf.svn.sourceforge.net/sirrf/?rev=98&view=rev Author: zccdark203 Date: 2009-08-08 20:51:55 +0000 (Sat, 08 Aug 2009) Log Message: ----------- The SoundSourceComponent can now correctly handle the sound data it receives from an asset group. Of course this component already had support for the AssetGroup class, but the method that provided this feature didn't fit the global way of handeling asset groups and has been removed. The same goes for the SoundManager class. Modified Paths: -------------- trunk/CHANGES trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-07 15:00:20 UTC (rev 97) +++ trunk/CHANGES 2009-08-08 20:51:55 UTC (rev 98) @@ -39,12 +39,9 @@ * 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. * Created the AssetGroup class which represents a collection of assets (meshes, textures, etc). The AssetManager class is responsible for Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-07 15:00:20 UTC (rev 97) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-08 20:51:55 UTC (rev 98) @@ -68,18 +68,38 @@ // Delete the previous data. unloadData(); - // Does the file exist? - if(!fileSystem->existFile(fileName.c_str())) - return false; + // Load the sound. + AssetGroup *assets = pParent->getAssetGroup(); - // Open the given file and load the contents to the buffer. - IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + if(assets != NULL) + { + // Try to retrieve sound from the parent's AssetGroup. + if(assets->getSound(fileName, mBuffer, mBufferSize)) + { + assets->connectEventSignal(std::string("sounds/") + fileName, this, + &SoundSourceComponent::onSound); + mSoundFileName = fileName; + } - mBufferSize = file->getSize(); - mBuffer = new c8[mBufferSize+1]; - file->read(mBuffer, mBufferSize); - file->drop(); + else + return false; + } + else + { + // Does the file exist? + if(!fileSystem->existFile(fileName.c_str())) + return false; + + // Open the given file and load the contents to the buffer. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + mBufferSize = file->getSize(); + mBuffer = new c8[mBufferSize+1]; + file->read(mBuffer, mBufferSize); + file->drop(); + } + // Create SFML's music object. mMusic = new sf::Music(); mMusic->OpenFromMemory(mBuffer, mBufferSize); @@ -116,36 +136,6 @@ 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) { @@ -179,6 +169,14 @@ // Unloads previously loaded data. void SoundSourceComponent::unloadData() { + // Get pointer to the parent's asset group. + AssetGroup *assets = pParent->getAssetGroup(); + + // Disconnect from asset group event if there is one. + /*if(assets != NULL) + assets->disconnectEventSignal(std::string("sounds/") + mSoundFileName, this);*/ + + // Remove sound object. if(mSound != NULL) { delete mSound; @@ -191,7 +189,7 @@ mMusic = NULL; } - if(mBuffer != NULL) + if(assets == NULL && mBuffer != NULL) { delete[] mBuffer; mBuffer = NULL; @@ -420,6 +418,36 @@ play(); } +// Responds to changes of the sound data attached to this component. +void SoundSourceComponent::onSound(void *p) +{ + // Get sound data. + std::pair<c8*, long> *soundData = reinterpret_cast<std::pair<c8*, long>*>(p); + + // Unload previous data. + unloadData(); + + // Set-up new buffer. + mBuffer = soundData->first; + mBufferSize = soundData->second; + + // Set sound. + if(mBufferSize != 0) + { + // Create SFML's music object. + mMusic = new sf::Music(); + mMusic->OpenFromMemory(mBuffer, mBufferSize); + + // 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); + } +} + // Parses for a SoundSourceComponent. bool SoundSourceComponent::parseXML(IXMLReader *file, Entity *entity) { Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-08-07 15:00:20 UTC (rev 97) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-08-08 20:51:55 UTC (rev 98) @@ -21,9 +21,7 @@ #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 @@ -52,10 +50,6 @@ //! @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 @@ -120,6 +114,9 @@ //! Unpauses the component if the parent is unpaused. //! @note For internal use only! void onUnPause(void *p); + //! Responds to changes of the sound data attached to this component. + //! @note For internal use only! + virtual void onSound(void *p); //! Parses for a SoundSourceComponent. //! @note For internal use only! @@ -133,6 +130,7 @@ c8 *mBuffer; long mBufferSize; + std::string mSoundFileName; f32 mAttenuation; bool mLoop; Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-07 15:00:20 UTC (rev 97) +++ trunk/src/core/AssetGroup.cpp 2009-08-08 20:51:55 UTC (rev 98) @@ -638,7 +638,7 @@ #endif // __COMPILE_WITH_ANGELSCRIPT__ #ifdef __COMPILE_WITH_SFML_AUDIO__ -bool AssetGroup::getSound(const std::string &fileName, c8 *buffer, long &length) +bool AssetGroup::getSound(const std::string &fileName, c8 *& buffer, long &length) { std::map<std::string, std::pair<c8*, long> >::iterator it = mSounds.find(fileName); @@ -1184,8 +1184,9 @@ if(!mIsReloading) { std::string slotName = std::string("sounds/") + it->first; + std::pair<c8*, long> emptySound = std::pair<c8*, long>(NULL, 0); - emitEvent(slotName, NULL); + emitEvent(slotName, &emptySound); removeEventSlot(slotName); } @@ -1210,14 +1211,14 @@ for(it = mSounds.begin(); it != mSounds.end(); it++) { // Handle events. + std::string slotName = std::string("sounds/") + it->first; + std::pair<c8*, long> emptySound = std::pair<c8*, long>(NULL, 0); + + emitEvent(slotName, &emptySound); + if(!mIsReloading) - { - std::string slotName = std::string("sounds/") + it->first; + removeEventSlot(slotName); - emitEvent(slotName, NULL); - removeEventSlot(slotName); - } - // Delete the sound. c8 *fBuffer = (it->second).first; delete [] fBuffer; Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-08-07 15:00:20 UTC (rev 97) +++ trunk/src/core/AssetGroup.h 2009-08-08 20:51:55 UTC (rev 98) @@ -71,7 +71,7 @@ //! @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); + bool getSound(const std::string &fileName, c8 *& buffer, long &length); #endif // __COMPILE_WITH_SFML_AUDIO__ //! Gets the texture with the given filename. //! @param fileName Filename of the texture. Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-08-07 15:00:20 UTC (rev 97) +++ trunk/src/sound/SoundManager.cpp 2009-08-08 20:51:55 UTC (rev 98) @@ -132,37 +132,6 @@ 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-08-07 15:00:20 UTC (rev 97) +++ trunk/src/sound/SoundManager.h 2009-08-08 20:51:55 UTC (rev 98) @@ -65,10 +65,6 @@ //! @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-08-07 15:00:29
|
Revision: 97 http://sirrf.svn.sourceforge.net/sirrf/?rev=97&view=rev Author: zccdark203 Date: 2009-08-07 15:00:20 +0000 (Fri, 07 Aug 2009) Log Message: ----------- Added various methods to the AssetGroup class to handle heightmaps. Besides that I've added behaviour for handeling the AssetGroup class to the TerrainComponent class. Modified Paths: -------------- trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/scene/TerrainComponent.h trunk/src/core/AssetGroup.cpp trunk/src/core/AssetGroup.h Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-08-06 17:47:08 UTC (rev 96) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-08-07 15:00:20 UTC (rev 97) @@ -23,19 +23,7 @@ TerrainComponent::TerrainComponent(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. - mTerrainSN = pSceneMgr->addTerrainSceneNode("", 0, parent->getID(), vector3df(0.0f, 0.0f, 0.0f), - vector3df(0.0f, 0.0f, 0.0f), - vector3df(1.0f, 1.0f, 1.0f), - SColor(255, 255, 255, 255), 5, ETPS_17, 0, true); - mSceneNode = mTerrainSN; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTerrainTriangleSelector(mTerrainSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(); } // TerrainComponent constructor. @@ -44,12 +32,27 @@ const SColor &vertexColor, s32 maxLOD, s32 smoothFactor) : SceneComponent(parent, true) { + init(rotation, scale, vertexColor, maxLOD, smoothFactor); + loadHeightMap(fileName.c_str(), vertexColor, smoothFactor); +} + +// TerrainComponent deconstructor. +TerrainComponent::~TerrainComponent() +{ + mTerrainSN->remove(); + mSceneNode = NULL; +} + +// Common initialisation method. +void TerrainComponent::init(const vector3df &rotation, const vector3df &scale, + const SColor &vertexColor, s32 maxLOD, s32 smoothFactor) +{ // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mTerrainSN = pSceneMgr->addTerrainSceneNode(fileName.c_str(), 0, parent->getID(), - parent->getPosition(), rotation, scale, + mTerrainSN = pSceneMgr->addTerrainSceneNode(0, 0, pParent->getID(), + pParent->getPosition(), rotation, scale, vertexColor, maxLOD, ETPS_17, smoothFactor, true); mSceneNode = mTerrainSN; @@ -58,13 +61,6 @@ mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } -// TerrainComponent deconstructor. -TerrainComponent::~TerrainComponent() -{ - mTerrainSN->remove(); - mSceneNode = NULL; -} - // Returns a direct pointer to the ITerrainSceneNode. ITerrainSceneNode* TerrainComponent::getTerrainSceneNode() { @@ -105,12 +101,40 @@ bool TerrainComponent::loadHeightMap(const std::string &fileName, const SColor &vertexColor, s32 smoothFactor) { - IReadFile *file = GameManager::Instance()->getDevice()->getFileSystem()-> - createAndOpenFile(fileName.c_str()); + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + IReadFile *heightMap = 0; - bool result = mTerrainSN->loadHeightMap(file, vertexColor, smoothFactor); - file->drop(); + // Retrieve pointer to the heightmap. + if(assets != NULL) + { + // Unsubscribe from previous asset. + assets->disconnectEventSignal(std::string("heightmaps/") + mHeightMapFileName, this); + // Get heightmap. + heightMap = assets->getHeightMap(fileName); + + if(heightMap) + { + assets->connectEventSignal(std::string("heightmaps/") + fileName, this, + &TerrainComponent::onHeightMap); + mHeightMapFileName = fileName; + } + } + + else + { + heightMap = GameManager::Instance()->getDevice()->getFileSystem() + ->createAndOpenFile(fileName.c_str()); + } + + // Set heightmap. + bool result = mTerrainSN->loadHeightMap(heightMap, vertexColor, smoothFactor); + mVertexColor = vertexColor; + mSmoothFactor = smoothFactor; + + // Clean up + heightMap->drop(); return result; } @@ -120,6 +144,18 @@ mTerrainSN->scaleTexture(scale, scale2); } +// Responds to changes of the heightmap attached to this component. +void TerrainComponent::onHeightMap(void *p) +{ + // Get pointer to the new heightmap. + IReadFile *heightMap = reinterpret_cast<IReadFile*>(p); + + // Set new heightmap. + mTerrainSN->loadHeightMap(heightMap, mVertexColor, mSmoothFactor); + + heightMap->drop(); +} + // Parses for a TerrainComponent. bool TerrainComponent::parseXML(IXMLReader *file, Entity *entity) { Modified: trunk/src/components/scene/TerrainComponent.h =================================================================== --- trunk/src/components/scene/TerrainComponent.h 2009-08-06 17:47:08 UTC (rev 96) +++ trunk/src/components/scene/TerrainComponent.h 2009-08-07 15:00:20 UTC (rev 97) @@ -82,14 +82,31 @@ //! coordinate set by this value. void scaleTexture(f32 scale = 1.0f, f32 scale2 = 0.0f); + // Events + //! Responds to changes of the heightmap attached to this component. + //! @note For internal use only! + void onHeightMap(void *p); + + // XML //! Parses for a TerrainComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); private: - // Members + // Private methods + //! Common initialisation method. + void init(const vector3df &rotation = vector3df(0.0f, 0.0f, 0.0f), + const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f), + const SColor &vertexColor = SColor(255, 255, 255, 255), + s32 maxLOD = 5, s32 smoothFactor = 0); + + // Private members ITerrainSceneNode *mTerrainSN; + + std::string mHeightMapFileName; + SColor mVertexColor; + s32 mSmoothFactor; }; #endif Modified: trunk/src/core/AssetGroup.cpp =================================================================== --- trunk/src/core/AssetGroup.cpp 2009-08-06 17:47:08 UTC (rev 96) +++ trunk/src/core/AssetGroup.cpp 2009-08-07 15:00:20 UTC (rev 97) @@ -72,6 +72,7 @@ // Loads the meshes associated with this asset group. void AssetGroup::loadAssets() { + loadHeightMaps(); loadMeshes(); #ifdef __COMPILE_WITH_ANGELSCRIPT__ loadScripts(); @@ -82,6 +83,118 @@ loadTextures(); } +// Loads the heightmap with the given filename. +bool AssetGroup::loadHeightMap(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 heightmap directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return false; + + if(!fileSystem->changeWorkingDirectoryTo("./heightmaps/")) + return false; + + // Load the heightmap. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + // Store data. + mHeightMaps[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded heightmap: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + { + IReadFile *heightMap = fileSystem->createMemoryReadFile(fBuffer, static_cast<s32>(fSize), + fileName.c_str()); + emitEvent(std::string("heightmaps/") + fileName, heightMap); + } + + else + createEventSlot(std::string("heightmaps/") + fileName); + } + + // Clean up. + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); + + return (file) ? true : false; +} + +// Loads the heightmaps associated with this asset group. +void AssetGroup::loadHeightMaps() +{ + // Retrieve pointers to sub-sytems of the Irrlicht engine. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Change the working directory to the heightmaps directory. + std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); + + if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) + return; + + if(!fileSystem->changeWorkingDirectoryTo("./heightmaps/")) + return; + + // Read the heightmaps. + 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 heightmap. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + if(file) + { + // Retrieve data. + long fSize = file->getSize(); + c8 *fBuffer = new c8[fSize+1]; + memset(fBuffer, 0, fSize+1); + + file->read(fBuffer, fSize); + file->drop(); + + // Store data. + mHeightMaps[fileName] = std::pair<c8*, long>(fBuffer, fSize); + cout << "Loaded heightmap: " << fileName << "\n"; + + // Handle events. + if(mIsReloading) + { + IReadFile *heightMap = fileSystem->createMemoryReadFile(fBuffer, static_cast<s32>(fSize), + fileName.c_str()); + emitEvent(std::string("heightmaps/") + fileName, heightMap); + } + + else + createEventSlot(std::string("heightmaps/") + fileName); + } + } + + // Clean up. + fileList->drop(); + + fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); +} + // Loads the mesh with the given filename. bool AssetGroup::loadMesh(const std::string &fileName) { @@ -286,7 +399,7 @@ // Retrieve pointers to sub-sytems of the Irrlicht engine. IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); - // Change the working directory to the textures directory. + // Change the working directory to the sounds directory. std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) @@ -332,7 +445,7 @@ // Retrieve pointers to sub-sytems of the Irrlicht engine. IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); - // Change the working directory to the textures directory. + // Change the working directory to the sounds directory. std::string workingDir = (fileSystem->getWorkingDirectory()).c_str(); if(!fileSystem->changeWorkingDirectoryTo(mBaseDir.c_str())) @@ -367,7 +480,7 @@ // Store data. mSounds[fileName] = std::pair<c8*, long>(fBuffer, fSize); - cout << "Loaded script: " << fileName << "\n"; + cout << "Loaded sound: " << fileName << "\n"; // Handle events. if(mIsReloading) @@ -482,6 +595,24 @@ fileSystem->changeWorkingDirectoryTo(workingDir.c_str()); } +// Gets the heightmap with the given filename. +IReadFile* AssetGroup::getHeightMap(const std::string &fileName) +{ + std::map<std::string, std::pair<c8*, long> >::iterator it = mHeightMaps.find(fileName); + + if(it != mSounds.end()) + { + c8 *fBuffer = (it->second).first; + s32 fSize = static_cast<s32>((it->second).second); + + IReadFile *file = GameManager::Instance()->getDevice()->getFileSystem() + ->createMemoryReadFile(fBuffer, fSize, fileName.c_str()); + return file; + } + + return NULL; +} + // Gets the mesh with the given filename. IAnimatedMesh* AssetGroup::getMesh(const std::string &fileName) { @@ -557,8 +688,14 @@ std::string assetName = name.substr(pos+1, name.size()-pos); // Reload the asset. - if(assetType == "meshes") + if(assetType == "heightmaps") { + if(reloadHeightMap(assetName)) + return true; + } + + else if(assetType == "meshes") + { if(reloadMesh(assetName)) return true; } @@ -593,6 +730,30 @@ mIsReloading = false; } +// Reloads the heightmap with the given filename. +bool AssetGroup::reloadHeightMap(const std::string &fileName) +{ + mIsReloading = true; + + removeHeightMap(fileName); + bool succeeded = loadHeightMap(fileName); + + mIsReloading = false; + + return succeeded; +} + +// Reloads all heightmaps in this asset group. +void AssetGroup::reloadHeightMaps() +{ + mIsReloading = true; + + removeHeightMaps(); + loadHeightMaps(); + + mIsReloading = false; +} + // Reloads the mesh with the given filename. bool AssetGroup::reloadMesh(const std::string &fileName) { @@ -720,8 +881,14 @@ std::string assetName = name.substr(pos+1, name.size()-pos); // Remove the asset. - if(assetType == "meshes") + if(assetType == "heightmaps") { + if(removeHeightMap(assetName)) + return true; + } + + else if(assetType == "meshes") + { if(removeMesh(assetName)) return true; } @@ -755,6 +922,7 @@ // Removes all assets in this asset group. void AssetGroup::removeAssets() { + removeHeightMaps(); removeMeshes(); #ifdef __COMPILE_WITH_ANGELSCRIPT__ removeScripts(); @@ -765,6 +933,62 @@ removeTextures(); } +// Removes the heightmap with the given name. +bool AssetGroup::removeHeightMap(const std::string &fileName) +{ + // Try to find the given heightmap. + std::map<std::string, std::pair<c8*, long> >::iterator it = mHeightMaps.find(fileName); + + // Did we find the heightmap? + if(it != mHeightMaps.end()) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("heightmaps/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + + // Delete the heightmap. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + mHeightMaps.erase(it); + + return true; + } + + // We didn't find the heightmap. + else return false; +} + +// Removes all heightmaps from this asset group. +void AssetGroup::removeHeightMaps() +{ + // Delete the heightmaps. + std::map<std::string, std::pair<c8*, long> >::iterator it; + + for(it = mHeightMaps.begin(); it != mHeightMaps.end(); it++) + { + // Handle events. + if(!mIsReloading) + { + std::string slotName = std::string("heightmaps/") + it->first; + + emitEvent(slotName, NULL); + removeEventSlot(slotName); + } + + // Delete the heightmap. + c8 *fBuffer = (it->second).first; + delete [] fBuffer; + } + + // Clear the heightmaps map. + mHeightMaps.clear(); +} + // Removes the given mesh. bool AssetGroup::removeMesh(IAnimatedMesh *mesh) { Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-08-06 17:47:08 UTC (rev 96) +++ trunk/src/core/AssetGroup.h 2009-08-07 15:00:20 UTC (rev 97) @@ -53,6 +53,10 @@ //! Gets the base directory of the AssetGroup. const std::string& getBaseDir() const; + //! Gets the heightmap with the given filename. + //! @param fileName Filename of the heightmap. + //! @note Don't forget to drop the file as soon as you're done with it. + IReadFile* getHeightMap(const std::string &fileName); //! Gets the mesh with the given filename. //! @param fileName Filename of the mesh. IAnimatedMesh* getMesh(const std::string &fileName); @@ -79,6 +83,12 @@ //! Reloads all assets in this asset group. void reloadAssets(); + //! Reloads the heightmap with the given filename. + //! @param fileName Filename of the heightmap. + bool reloadHeightMap(const std::string &fileName); + //! Reloads all heightmaps in this asset group. + void reloadHeightMaps(); + //! Reloads the mesh with the given filename. //! @param fileName Filename of the mesh. bool reloadMesh(const std::string &fileName); @@ -113,6 +123,12 @@ //! Removes all assets. void removeAssets(); + //! Removes the given heightmap. + //! @param fileName Filename of the heightmap. + bool removeHeightMap(const std::string &fileName); + //! Removes all heightmaps in this asset group. + void removeHeightMaps(); + //! Removes the given mesh. //! @param mesh Mesh to remove. bool removeMesh(IAnimatedMesh *mesh); @@ -154,6 +170,8 @@ // Private methods void loadAssets(); + bool loadHeightMap(const std::string &fileName); + void loadHeightMaps(); bool loadMesh(const std::string &fileName); void loadMeshes(); #ifdef __COMPILE_WITH_ANGELSCRIPT__ @@ -177,6 +195,7 @@ std::map<std::string, IAnimatedMesh*> mMeshes; std::map<std::string, ITexture*> mTextures; + std::map<std::string, std::pair<c8*, long> > mHeightMaps; #ifdef __COMPILE_WITH_ANGELSCRIPT__ std::map<std::string, Script*> mScripts; #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-08-06 17:47:14
|
Revision: 96 http://sirrf.svn.sourceforge.net/sirrf/?rev=96&view=rev Author: zccdark203 Date: 2009-08-06 17:47:08 +0000 (Thu, 06 Aug 2009) Log Message: ----------- The SkyBoxComponent, SkyDomeComponent and TextBillboardComponent classes have been adjusted to also handle our asset management. I also made two setTextures methods for the SkyBoxComponent class, which can be used the set the textures of the sky box after initialisation. Furthermore I've made various small changes which should improve the framework as a whole. Modified Paths: -------------- trunk/CHANGES 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/TextBillboardComponent.cpp trunk/src/components/scene/TextBillboardComponent.h trunk/src/core/AssetGroup.h trunk/src/core/EntityManager.h trunk/src/scripting/components/scene/asOctTreeComponent.cpp trunk/src/scripting/components/scene/asSkyBoxComponent.cpp trunk/src/scripting/components/scene/asSkyDome.cpp Modified: trunk/CHANGES =================================================================== --- trunk/CHANGES 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/CHANGES 2009-08-06 17:47:08 UTC (rev 96) @@ -2,6 +2,13 @@ Sirrf version 0.2.0 (SVN) - Changes ========================================================================== + * Added the setTextures methods to the SkyBoxComponent class. These + methods can be used to set textures after initialisation of the + SkyBoxComponent. + + * Added additional constructors for OctTreeComponent, SkyBoxComponent + and SkyDomeComponent. + * The OctTreeComponent class now properly inherits from the MeshComponent class. @@ -11,7 +18,7 @@ * Fixed the disconnectEventSignal method in both the EventManager class and the HasEvents class. - * The Entity class now supports post-initialization addition of a + * The Entity class now supports post-initialisation 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 Modified: trunk/src/components/scene/SkyBoxComponent.cpp =================================================================== --- trunk/src/components/scene/SkyBoxComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/components/scene/SkyBoxComponent.cpp 2009-08-06 17:47:08 UTC (rev 96) @@ -20,21 +20,20 @@ // SkyBoxComponent class +// SkyBoxComponent constructor (default). +SkyBoxComponent::SkyBoxComponent(Entity *parent) +: SceneComponent(parent, true) +{ + init(); +} + // SkyBoxComponent constructor. SkyBoxComponent::SkyBoxComponent(Entity *parent, ITexture *top, ITexture *bottom, ITexture *left, ITexture *right, ITexture *front, ITexture *back) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - // Create the internal scene node. - mSceneNode = pSceneMgr->addSkyBoxSceneNode(top, bottom, left, right, front, back, 0, - parent->getID()); - - // Set-up internal mechanism for collision detection. - mTriSelector = NULL; - mMetaSelector = NULL; + init(); + setTextures(top, bottom, left, right, front, back); } // SkyBoxComponent constructor. @@ -43,27 +42,153 @@ const std::string &front, const std::string &back) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IVideoDriver *pDriver = GameManager::Instance()->getDriver(); + init(); + setTextures(top, bottom, left, right, front, back); +} +// SkyBoxComponent deconstructor. +SkyBoxComponent::~SkyBoxComponent() +{ +} + +// Common initialisation method. +void SkyBoxComponent::init() +{ // Create the internal scene node. - mSceneNode = pSceneMgr->addSkyBoxSceneNode(pDriver->getTexture(top.c_str()), - pDriver->getTexture(bottom.c_str()), - pDriver->getTexture(left.c_str()), - pDriver->getTexture(right.c_str()), - pDriver->getTexture(front.c_str()), - pDriver->getTexture(back.c_str()), - 0, parent->getID()); + mSceneNode = GameManager::Instance()->getSceneManager()->addSkyBoxSceneNode(0, 0, 0, 0, 0, 0, 0, + pParent->getID()); // Set-up internal mechanism for collision detection. mTriSelector = NULL; mMetaSelector = NULL; } -// SkyBoxComponent deconstructor. -SkyBoxComponent::~SkyBoxComponent() +// Loads and sets the textures of the sky box. +void SkyBoxComponent::setTextures(const std::string &top, const std::string &bottom, + const std::string &left, const std::string &right, + const std::string &front, const std::string &back, + bool ignoreNull) { + if( (front != "") || !ignoreNull) + setTexture(0, front); + + if( (left != "") || !ignoreNull) + setTexture(1, left); + + if( (back != "") || !ignoreNull) + setTexture(2, back); + + if( (right != "") || !ignoreNull) + setTexture(3, right); + + if( (top != "") || !ignoreNull) + setTexture(4, top); + + if( (bottom != "") || !ignoreNull) + setTexture(5, bottom); } +// Sets the textures of the sky box. +void SkyBoxComponent::setTextures(ITexture *top, ITexture *bottom, ITexture *left, ITexture *right, + ITexture *front, ITexture *back, bool ignoreNull) +{ + if(front || !ignoreNull) + setTexture(0, front); + + if(left || !ignoreNull) + setTexture(1, left); + + if(back || !ignoreNull) + setTexture(2, back); + + if(right || !ignoreNull) + setTexture(3, right); + + if(top || !ignoreNull) + setTexture(4, top); + + if(bottom || !ignoreNull) + setTexture(5, bottom); +} + +// Sets the texture of the appropriate side based on the filename. +void SkyBoxComponent::setTexture(u32 side, const std::string &fileName) +{ + // Check if we got an reasonable side. + if(side >= 6) + return; + + // 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/") + mTextureFileNames[side], this); + + // Get texture. + texture = assets->getTexture(fileName); + + if(texture) + { + assets->connectEventSignal(std::string("textures/") + fileName, this, + &SkyBoxComponent::onTextureSkyBox); + mTextureFileNames[side] = fileName; + } + } + + else + texture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); + + // Set texture. + mSceneNode->getMaterial(side).setTexture(0, texture); +} + +// Sets the texture of the appropriate side. +void SkyBoxComponent::setTexture(u32 side, ITexture *texture) +{ + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + + // Check if we need to unsubscribe from an asset group texture. + if(assets != NULL) + { + assets->disconnectEventSignal(std::string("textures/") + mTextureFileNames[side], this); + mTextureFileNames[side] = ""; + } + + // Set texture. + mSceneNode->getMaterial(side).setTexture(0, texture); +} + +// Responds to changes of a skybox texture attached to this component. +void SkyBoxComponent::onTextureSkyBox(void *p) +{ + // Get texture data. + ITexture *texture = reinterpret_cast<ITexture*>(p); + + // Determine layer. + std::string fileName = (GameManager::Instance()->getDevice()->getFileSystem()-> + getFileBasename(texture->getName())).c_str(); + + u32 side = 6; + + for(u32 i = 0; i < 6; i++) + { + if(mTextureFileNames[i] == fileName) + { + side = i; + break; + } + } + + if(side == 6) + return; + + // Set texture. + mSceneNode->getMaterial(side).setTexture(0, texture); +} + // End of File Modified: trunk/src/components/scene/SkyBoxComponent.h =================================================================== --- trunk/src/components/scene/SkyBoxComponent.h 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/components/scene/SkyBoxComponent.h 2009-08-06 17:47:08 UTC (rev 96) @@ -28,6 +28,9 @@ public: // Initialisation and deinitialisation + //! Constructor (default) + //! @param parent The parent entity to which the component should be added. + SkyBoxComponent(Entity *parent); //! Constructor //! @param parent The parent entity to which the component should be added. //! @param top Texture for the top plane of the box. @@ -52,6 +55,47 @@ const std::string &back); //! Deconstructor ~SkyBoxComponent(); + + // Methods + //! Loads and sets the textures of the sky box. + //! @param top File with the texture for the top plane of the box. + //! @param bottom File with the texture for the bottom plane of the box. + //! @param left File with the texture for the left plane of the box. + //! @param right File with the texture for the right plane of the box. + //! @param front File with the texture for the front plane of the box. + //! @param back File with the texture for the back plane of the box. + //! @param ignoreNull Should a null value be used as a texture? + void setTextures(const std::string &top, const std::string &bottom, const std::string &left, + const std::string &right, const std::string &front, const std::string &back, + bool ignoreNull = true); + + //! Sets the textures of the sky box. + //! @param top Texture for the top plane of the box. + //! @param bottom Texture for the bottom plane of the box. + //! @param left Texture for the left plane of the box. + //! @param right Texture for the right plane of the box. + //! @param front Texture for the front plane of the box. + //! @param back Texture for the back plane of the box. + //! @param ignoreNull Should a null value be used as a texture? + void setTextures(ITexture *top, ITexture *bottom, ITexture *left, ITexture *right, + ITexture *front, ITexture *back, bool ignoreNull = true); + + // Events + //! Responds to changes of a skybox texture attached to this component. + //! @note For internal use only! + void onTextureSkyBox(void *p); + +private: + + //! Common initialisation method. + void init(); + + // Private methods + void setTexture(u32 side, const std::string &fileName); + void setTexture(u32 side, ITexture *texture); + + // Private members + std::string mTextureFileNames[6]; }; #endif Modified: trunk/src/components/scene/SkyDomeComponent.cpp =================================================================== --- trunk/src/components/scene/SkyDomeComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/components/scene/SkyDomeComponent.cpp 2009-08-06 17:47:08 UTC (rev 96) @@ -20,22 +20,21 @@ // SkyDomeComponent class +// SkyDomeComponent constructor (default) +SkyDomeComponent::SkyDomeComponent(Entity *parent, u32 hRes, u32 vRes, f32 texturePerc, + f32 spherePerc, f32 radius) +: SceneComponent(parent, true) +{ + init(hRes, vRes, texturePerc, spherePerc, radius); +} + // SkyDomeComponent constructor. SkyDomeComponent::SkyDomeComponent(Entity *parent, const std::string &fileName, u32 hRes, u32 vRes, f32 texturePerc, f32 spherePerc, f32 radius) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IVideoDriver *pDriver = GameManager::Instance()->getDriver(); - - // Create the internal scene node. - mSceneNode = pSceneMgr->addSkyDomeSceneNode(pDriver->getTexture(fileName.c_str()), hRes, vRes, - texturePerc, spherePerc, radius, 0, parent->getID()); - - // Set-up internal mechanism for collision detection. - mTriSelector = NULL; - mMetaSelector = NULL; + init(hRes, vRes, texturePerc, spherePerc, radius); + setMaterialTexture(0, fileName); } // SkyDomeComponent constructor. @@ -43,21 +42,25 @@ f32 texturePerc, f32 spherePerc, f32 radius) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + init(hRes, vRes, texturePerc, spherePerc, radius); + setMaterialTexture(0, texture); +} +// SkyDomeComponent deconstructor. +SkyDomeComponent::~SkyDomeComponent() +{ +} + +// Common initialisation method. +void SkyDomeComponent::init(u32 hRes, u32 vRes, f32 texturePerc, f32 spherePerc, f32 radius) +{ // Create the internal scene node. - mSceneNode = pSceneMgr->addSkyDomeSceneNode(texture, hRes, vRes, texturePerc, spherePerc, - radius, 0, parent->getID()); + mSceneNode = GameManager::Instance()->getSceneManager()->addSkyDomeSceneNode(0, hRes, + vRes, texturePerc, spherePerc, radius, 0, pParent->getID()); // Set-up internal mechanism for collision detection. mTriSelector = NULL; mMetaSelector = NULL; } -// SkyDomeComponent deconstructor. -SkyDomeComponent::~SkyDomeComponent() -{ -} - // End of File Modified: trunk/src/components/scene/SkyDomeComponent.h =================================================================== --- trunk/src/components/scene/SkyDomeComponent.h 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/components/scene/SkyDomeComponent.h 2009-08-06 17:47:08 UTC (rev 96) @@ -28,6 +28,17 @@ public: // Initialisation and deinitialisation + //! Constructor (default) + //! @param parent The parent entity to which the component should be added. + //! @param hRes Number of vertices of a horizontal layer of the sphere. + //! @param vRes Number of vertices of a vertical layer of the sphere. + //! @param texturePerc How much of the height of the texture is used. Should be + //! between 0 and 1. + //! @param spherePerc How much of the sphere is drawn. Value should be between + //! 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere. + //! @param radius Radius of the skydome. + SkyDomeComponent(Entity *parent, u32 hRes = 16, u32 vRes = 8, f32 texturePerc = 0.9f, + f32 spherePerc = 2.0f, f32 radius = 1000.0f); //! Constructor //! @param parent The parent entity to which the component should be added. //! @param fileName File with the texture to add. @@ -54,6 +65,11 @@ f32 texturePerc = 0.9f, f32 spherePerc = 2.0f, f32 radius = 1000.0f); //! Deconstructor ~SkyDomeComponent(); + +private: + + //! Common initialisation method. + void init(u32 hRes, u32 vRes, f32 texturePerc, f32 spherePerc, f32 radius); }; #endif Modified: trunk/src/components/scene/TextBillboardComponent.cpp =================================================================== --- trunk/src/components/scene/TextBillboardComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/components/scene/TextBillboardComponent.cpp 2009-08-06 17:47:08 UTC (rev 96) @@ -23,20 +23,8 @@ TextBillboardComponent::TextBillboardComponent(Entity *parent) : BillboardComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - - // Create the internal scene node. - mBillboardTextSN = pSceneMgr->addBillboardTextSceneNode(pGUIEnv->getBuiltInFont(), 0, 0, - dimension2df(10.0f, 10.0f), - parent->getPosition(), parent->getID()); - mBillboardSN = mBillboardTextSN; - mSceneNode = mBillboardTextSN; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardTextSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(GameManager::Instance()->getGUIEnvironment()->getBuiltInFont(), 0, + dimension2df(10.0f, 10.0f), SColor(255, 255, 255, 255), SColor(255, 255, 255, 255)); } // TextBillboardComponent constructor. @@ -45,20 +33,8 @@ const SColor &colorTop, const SColor &colorBottom) : BillboardComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - - // Create the internal scene node. - mBillboardTextSN = pSceneMgr->addBillboardTextSceneNode(pGUIEnv->getFont(fontFileName.c_str()), - text, 0, size, parent->getPosition(), - parent->getID(), colorTop, colorBottom); - mBillboardSN = mBillboardTextSN; - mSceneNode = mBillboardTextSN; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardTextSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); + init(GameManager::Instance()->getGUIEnvironment()->getFont(fontFileName.c_str()), + text, size, colorTop, colorBottom); } // TextBillboardComponent constructor. @@ -67,15 +43,30 @@ const SColor &colorTop, const SColor &colorBottom) : BillboardComponent(parent, true) { + core::stringw wBuffer = core::stringw(text.c_str()); + init(GameManager::Instance()->getGUIEnvironment()->getFont(fontFileName.c_str()), + wBuffer.c_str(), size, colorTop, colorBottom); +} + +// TextBillboardComponent deconstructor. +TextBillboardComponent::~TextBillboardComponent() +{ + mBillboardTextSN->remove(); + mBillboardSN = NULL; + mSceneNode = NULL; +} + +// Common initialisation method. +void TextBillboardComponent::init(IGUIFont *font, const wchar_t *text, const dimension2df &size, + const SColor &colorTop, const SColor &colorBottom) +{ // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - // Create the internal scene node. - core::stringw wBuffer = core::stringw(text.c_str()); - mBillboardTextSN = pSceneMgr->addBillboardTextSceneNode(pGUIEnv->getFont(fontFileName.c_str()), - wBuffer.c_str(), 0, size, - parent->getPosition(), parent->getID(), + // Create internal scene node. + mBillboardTextSN = pSceneMgr->addBillboardTextSceneNode(font, text, 0, size, + pParent->getPosition(), + pParent->getID(), colorTop, colorBottom); mBillboardSN = mBillboardTextSN; mSceneNode = mBillboardTextSN; @@ -85,14 +76,6 @@ mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } -// TextBillboardComponent deconstructor. -TextBillboardComponent::~TextBillboardComponent() -{ - mBillboardTextSN->remove(); - mBillboardSN = NULL; - mSceneNode = NULL; -} - // Returns a direct pointer to the IBillboardTextSceneNode. IBillboardTextSceneNode* TextBillboardComponent::getBillboardTextSceneNode() { Modified: trunk/src/components/scene/TextBillboardComponent.h =================================================================== --- trunk/src/components/scene/TextBillboardComponent.h 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/components/scene/TextBillboardComponent.h 2009-08-06 17:47:08 UTC (rev 96) @@ -78,6 +78,10 @@ private: + // Private methods + void init(IGUIFont *font, const wchar_t *text, const dimension2df &size, const SColor &colorTop, + const SColor &colorBottom); + // Members IBillboardTextSceneNode *mBillboardTextSN; }; Modified: trunk/src/core/AssetGroup.h =================================================================== --- trunk/src/core/AssetGroup.h 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/core/AssetGroup.h 2009-08-06 17:47:08 UTC (rev 96) @@ -65,7 +65,7 @@ //! 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. + //! @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__ Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/core/EntityManager.h 2009-08-06 17:47:08 UTC (rev 96) @@ -71,7 +71,7 @@ //! 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 + //! @param assets 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, AssetGroup *assets = NULL, bool grab = true); Modified: trunk/src/scripting/components/scene/asOctTreeComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asOctTreeComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/scripting/components/scene/asOctTreeComponent.cpp 2009-08-06 17:47:08 UTC (rev 96) @@ -26,6 +26,18 @@ //! Reference factory for the OctTreeComponent class. +OctTreeComponent* createOctTreeComponent(Entity *parent) +{ + return new OctTreeComponent(parent); +} + +//! Reference factory for the OctTreeComponent class. +OctTreeComponent* createOctTreeComponent(Entity *parent, s32 minPolysPerNode) +{ + return new OctTreeComponent(parent, minPolysPerNode); +} + +//! Reference factory for the OctTreeComponent class. OctTreeComponent* createOctTreeComponent(Entity *parent, const std::string &fileName, s32 minPolysPerNode) { @@ -45,6 +57,12 @@ bindSceneComponentBase<OctTreeComponent>(engine, "OctTreeComponent"); // Set SkyDomeComponent behaviour. + r = engine->RegisterObjectBehaviour("OctTreeComponent", asBEHAVE_FACTORY, "OctTreeComponent@ f(Entity @+)", + asFUNCTIONPR(createOctTreeComponent, (Entity*), OctTreeComponent*), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("OctTreeComponent", asBEHAVE_FACTORY, "OctTreeComponent@ f(Entity @+, s32)", + asFUNCTIONPR(createOctTreeComponent, (Entity*, s32), OctTreeComponent*), + asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("OctTreeComponent", asBEHAVE_FACTORY, "OctTreeComponent@ f(Entity @+, " \ "const string &in, s32)", asFUNCTIONPR(createOctTreeComponent, (Entity*, const std::string&, Modified: trunk/src/scripting/components/scene/asSkyBoxComponent.cpp =================================================================== --- trunk/src/scripting/components/scene/asSkyBoxComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/scripting/components/scene/asSkyBoxComponent.cpp 2009-08-06 17:47:08 UTC (rev 96) @@ -25,6 +25,12 @@ //! Reference factory for the SkyBoxComponent class. +SkyBoxComponent* createSkyBoxComponent(Entity *parent) +{ + return new SkyBoxComponent(parent); +} + +//! Reference factory for the SkyBoxComponent class. SkyBoxComponent* createSkyBoxComponent(Entity *parent, const std::string &top, const std::string &bottom, const std::string &left, const std::string &right, const std::string &front, @@ -46,6 +52,9 @@ bindSceneComponentBase<SkyBoxComponent>(engine, "SkyBoxComponent"); // Set SkyboxComponent behaviour. + r = engine->RegisterObjectBehaviour("SkyBoxComponent", asBEHAVE_FACTORY, "SkyBoxComponent@ f(Entity @+)", + asFUNCTIONPR(createSkyBoxComponent, (Entity*), SkyBoxComponent*), asCALL_CDECL); + assert(r >= 0); r = engine->RegisterObjectBehaviour("SkyBoxComponent", asBEHAVE_FACTORY, "SkyBoxComponent@ f(Entity @+, " \ "const string &in, const string &in, const string &in, const string &in, " \ "const string &in, const string &in)", @@ -56,6 +65,13 @@ r = engine->RegisterObjectBehaviour("SkyBoxComponent", asBEHAVE_ASSIGNMENT, "SkyBoxComponent& " \ "f(const SkyBoxComponent &in)", asFUNCTION(assignT<SkyBoxComponent>), asCALL_CDECL_OBJFIRST); assert(r >= 0); + + // Bind CameraComponent class functions. + r = engine->RegisterObjectMethod("SkyBoxComponent", "void setTextures(const string &in, const string &in," \ + "const string &in, const string &in, const string &in, const string &in, bool)", + asMETHODPR(SkyBoxComponent, setTextures, (const std::string&, const std::string&, + const std::string&, const std::string&, const std::string&, const std::string&, bool), + void), asCALL_THISCALL); assert(r >= 0); } #endif // __COMPILE_WITH_ANGELSCRIPT__ Modified: trunk/src/scripting/components/scene/asSkyDome.cpp =================================================================== --- trunk/src/scripting/components/scene/asSkyDome.cpp 2009-08-05 19:37:43 UTC (rev 95) +++ trunk/src/scripting/components/scene/asSkyDome.cpp 2009-08-06 17:47:08 UTC (rev 96) @@ -26,6 +26,19 @@ //! Reference factory for the SkyDomeComponent class. +SkyDomeComponent* createSkyDomeComponent(Entity *parent) +{ + return new SkyDomeComponent(parent); +} + +//! Reference factory for the SkyDomeComponent class. +SkyDomeComponent* createSkyDomeComponent(Entity *parent, u32 hRes, u32 vRes, f32 texturePerc, + f32 spherePerc, f32 radius) +{ + return new SkyDomeComponent(parent, hRes, vRes, texturePerc, spherePerc, radius); +} + +//! Reference factory for the SkyDomeComponent class. SkyDomeComponent* createSkyDomeComponent(Entity *parent, const std::string &fileName, u32 hRes, u32 vRes, f32 texturePerc, f32 spherePerc, f32 radius) @@ -46,7 +59,14 @@ bindSceneComponentBase<SkyDomeComponent>(engine, "SkyDomeComponent"); // Set SkyDomeComponent behaviour. + r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+)", + asFUNCTIONPR(createSkyDomeComponent, (Entity*), SkyDomeComponent*), + asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+, " \ + "u32, u32, f32, f32, f32)", + asFUNCTIONPR(createSkyDomeComponent, (Entity*, u32, u32, f32, f32, f32), + SkyDomeComponent*), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("SkyDomeComponent", asBEHAVE_FACTORY, "SkyDomeComponent@ f(Entity @+, " \ "const string &in, u32, u32, f32, f32, f32)", asFUNCTIONPR(createSkyDomeComponent, (Entity*, const std::string&, u32, u32, f32, f32, f32), SkyDomeComponent*), asCALL_CDECL); 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-08-05 19:37:56
|
Revision: 95 http://sirrf.svn.sourceforge.net/sirrf/?rev=95&view=rev Author: zccdark203 Date: 2009-08-05 19:37:43 +0000 (Wed, 05 Aug 2009) Log Message: ----------- Continued with the integration of the AssetGroup class into the entities and their components. This time the SceneComponent class has been adapted. I discovered, though, that mesh reloading will need some work as Irrlicht deletes the materials of a previous mesh by default. Besides that I've made some casting fixes. Modified Paths: -------------- trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/ImageComponent.cpp trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/OctTreeComponent.cpp 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/core/Entity.cpp Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -279,7 +279,7 @@ void AnimatedMeshComponent::onMesh(void *p) { // Get pointer to the new mesh. - IAnimatedMesh *mesh = &reinterpret_cast<IAnimatedMesh*>(p)[0]; + IAnimatedMesh *mesh = reinterpret_cast<IAnimatedMesh*>(p); // Set new mesh. mAnimatedMeshSN->setMesh(mesh); @@ -289,7 +289,7 @@ void AnimatedMeshComponent::onShadowVolumeMesh(void *p) { // Get pointer to the new mesh. - IMesh *mesh = &reinterpret_cast<IMesh*>(p)[0]; + IMesh *mesh = reinterpret_cast<IMesh*>(p); // Set new mesh. mShadowVolumeSN->setShadowMesh(mesh); Modified: trunk/src/components/scene/ImageComponent.cpp =================================================================== --- trunk/src/components/scene/ImageComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/scene/ImageComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -249,7 +249,7 @@ void ImageComponent::onTexture(void *p) { // Get pointer to the new texture. - ITexture *texture = &reinterpret_cast<ITexture*>(p)[0]; + ITexture *texture = reinterpret_cast<ITexture*>(p); // Drop reference to previous texture. if(mTexture) // Technically unneeded, but rather safe than sorry. Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/scene/MeshComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -136,7 +136,7 @@ void MeshComponent::onMesh(void *p) { // Get pointer to the new mesh. - IMesh *mesh = &reinterpret_cast<IMesh*>(p)[0]; + IMesh *mesh = reinterpret_cast<IMesh*>(p); // Set new mesh. mMeshSN->setMesh(mesh); Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -143,7 +143,7 @@ void OctTreeComponent::onMesh(void *p) { // Get pointer to the new mesh. - IMesh *mesh = &reinterpret_cast<IMesh*>(p)[0]; + IMesh *mesh = reinterpret_cast<IMesh*>(p); // Remove previous triangle selector. mLocalMetaSelector->removeTriangleSelector(mOctTreeSelector); Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/scene/SceneComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -23,34 +23,40 @@ SceneComponent::SceneComponent(Entity *parent) : EntityComponent(parent) { + // Common initialisation. + init(); + // Get a pointer to the scene manager. ISceneManager *pScnMgr = GameManager::Instance()->getSceneManager(); - // Initialise the internal scene node. - mSceneNode = pScnMgr->addEmptySceneNode(0, parent->getID()); - mSceneNode->setPosition(parent->getPosition()); - // Set up collision detection for this component. mTriSelector = pScnMgr->createTriangleSelectorFromBoundingBox(mSceneNode); mMetaSelector = pScnMgr->createMetaTriangleSelector(); // Set misc. variables. - mName = "SceneComponent"; mCanAffectParent = false; mEvokedParentChange = false; mLastPos = getPosition(); - - // Register events. - 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) { + init(); +} + +// SceneComponent deconstructor. +SceneComponent::~SceneComponent() +{ + if(mSceneNode != NULL) mSceneNode->remove(); + if(mTriSelector != NULL) mTriSelector->drop(); + if(mMetaSelector != NULL) mMetaSelector->drop(); +} + +// Common initialisation method. +void SceneComponent::init() +{ // Set misc. variables. mName = "SceneComponent"; @@ -61,14 +67,6 @@ pParent->connectEventSignal("onUnPause", this, &SceneComponent::onUnPause); } -// SceneComponent deconstructor. -SceneComponent::~SceneComponent() -{ - if(mSceneNode != NULL) mSceneNode->remove(); - if(mTriSelector != NULL) mTriSelector->drop(); - if(mMetaSelector != NULL) mMetaSelector->drop(); -} - // Returns a direct pointer to the ISceneNode. ISceneNode* SceneComponent::getSceneNode() { @@ -256,14 +254,55 @@ // texture. void SceneComponent::setMaterialTexture(u32 layer, const std::string &fileName) { - ITexture *texture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); - if(texture) - mSceneNode->setMaterialTexture(layer, texture); + // Set up variables. + AssetGroup *assets = pParent->getAssetGroup(); + ITexture *texture = 0; + + // Retrieve pointer to the texture. + if(assets != NULL) + { + // Unsubscribe from previous asset. + std::map<u32, std::string>::iterator it = mTextureFileNames.find(layer); + + if(it != mTextureFileNames.end()) + assets->disconnectEventSignal(std::string("textures/") + it->second, this); + + // Get texture. + texture = assets->getTexture(fileName); + + if(texture) + { + assets->connectEventSignal(std::string("textures/") + fileName, this, + &SceneComponent::onTexture); + mTextureFileNames[layer] = fileName; + } + } + + else + texture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); + + // Set texture. + mSceneNode->setMaterialTexture(layer, texture); } // Sets the texture of the specified layer in all materials of this component to the new texture. void SceneComponent::setMaterialTexture(u32 layer, ITexture *texture) { + // Check if we need to unsubscribe from an asset group texture. + AssetGroup *assets = pParent->getAssetGroup(); + + if(assets != NULL) + { + std::map<u32, std::string>::iterator it = mTextureFileNames.find(layer); + + if(it != mTextureFileNames.end()) + { + assets->disconnectEventSignal(std::string("textures/") + it->second, this); + mTextureFileNames.erase(it); + } + } + + // Set texture. mSceneNode->setMaterialTexture(layer, texture); } @@ -303,7 +342,7 @@ { if(!mEvokedParentChange) { - vector3df diff = static_cast<vector3df*>(p)[0]; + vector3df diff = reinterpret_cast<vector3df*>(p)[0]; mSceneNode->setPosition(mSceneNode->getPosition() + diff); } } @@ -344,6 +383,35 @@ mSceneNode->setVisible(true); } +// Responds to changes of a texture attached to this component. +void SceneComponent::onTexture(void *p) +{ + // Get texture data. + ITexture *texture = reinterpret_cast<ITexture*>(p); + + // Determine layer. + std::string fileName = (GameManager::Instance()->getDevice()->getFileSystem()-> + getFileBasename(texture->getName())).c_str(); + + u32 layer; + + std::map<u32, std::string>::iterator it; + for(it = mTextureFileNames.begin(); it != mTextureFileNames.end(); it++) + { + if(it->second == fileName) + { + layer = it->first; + break; + } + } + + if(it == mTextureFileNames.end()) + return; + + // Set texture. + mSceneNode->setMaterialTexture(layer, texture); +} + // Parses for a SceneComponent. bool SceneComponent::parseXML(IXMLReader *file, Entity *entity) { Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/scene/SceneComponent.h 2009-08-05 19:37:43 UTC (rev 95) @@ -177,7 +177,11 @@ //! Unpauses the component if the parent is paused. //! @note For internal use only! void onUnPause(void *p); + //! Responds to changes of a texture attached to this component. + //! @note For internal use only! + virtual void onTexture(void *p); + // XML //! Parses for a SceneComponent. //! @note For internal use only! static bool parseXML(IXMLReader *file, Entity *entity); @@ -198,12 +202,18 @@ private: + // Private methods. + //! Common initialisation method. + void init(); + // Private members vector3df mLastPos; bool mCanAffectParent; bool mEvokedParentChange; bool mWasVisible; + + std::map<u32, std::string> mTextureFileNames; }; #endif Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -96,7 +96,7 @@ // Updates the position of the component after its parent has been updated. void SoundListenerComponent::onPositionChange(void *p) { - mPosition += static_cast<vector3df*>(p)[0]; + mPosition += reinterpret_cast<vector3df*>(p)[0]; if(mIsMainListener) sf::Listener::SetPosition(mPosition.X, mPosition.Y, mPosition.Z); } Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -397,7 +397,7 @@ // Updates the position of the component after its parent has been updated. void SoundSourceComponent::onPositionChange(void *p) { - mPosition += static_cast<vector3df*>(p)[0]; + mPosition += reinterpret_cast<vector3df*>(p)[0]; if(mSound != NULL) mSound->SetPosition(mPosition.X, mPosition.Y, mPosition.Z); Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-08-05 10:42:35 UTC (rev 94) +++ trunk/src/core/Entity.cpp 2009-08-05 19:37:43 UTC (rev 95) @@ -405,7 +405,7 @@ // Updates the position of the entity after its parent has been updated. void Entity::onPositionChange(void *p) { - vector3df diff = static_cast<vector3df*>(p)[0]; + vector3df diff = reinterpret_cast<vector3df*>(p)[0]; mPosition += diff; emitEvent("onPositionChange", &diff); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |