You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
(38) |
Jun
(25) |
Jul
(16) |
Aug
(52) |
Sep
(1) |
Oct
(3) |
Nov
(18) |
Dec
(7) |
---|
From: <zcc...@us...> - 2009-05-31 15:30:23
|
Revision: 44 http://sirrf.svn.sourceforge.net/sirrf/?rev=44&view=rev Author: zccdark203 Date: 2009-05-31 15:30:20 +0000 (Sun, 31 May 2009) Log Message: ----------- I've started with binding all Irrlicht value types which are needed by AngelScript scripts. It turns out that this job is a whole lot bigger than I thought, but it's going well. Modified Paths: -------------- trunk/src/scripting/ScriptManager.cpp Added Paths: ----------- trunk/src/scripting/irrlicht/ trunk/src/scripting/irrlicht/asIrrlicht.cpp trunk/src/scripting/irrlicht/asIrrlicht.h trunk/src/scripting/irrlicht/asVector2d.cpp trunk/src/scripting/irrlicht/asVector2d.h Removed Paths: ------------- trunk/src/scripting/bindIrrlicht.cpp trunk/src/scripting/bindIrrlicht.h Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-05-30 13:16:53 UTC (rev 43) +++ trunk/src/scripting/ScriptManager.cpp 2009-05-31 15:30:20 UTC (rev 44) @@ -16,7 +16,7 @@ // Include files #include "ScriptManager.h" -#include "bindIrrlicht.h" +#include "irrlicht/asIrrlicht.h" #include "../core/GameManager.h" Deleted: trunk/src/scripting/bindIrrlicht.cpp =================================================================== --- trunk/src/scripting/bindIrrlicht.cpp 2009-05-30 13:16:53 UTC (rev 43) +++ trunk/src/scripting/bindIrrlicht.cpp 2009-05-31 15:30:20 UTC (rev 44) @@ -1,413 +0,0 @@ -// ///////////////////////////////////////////////////////////////////////////// -// -// Name: bindIrrlicht.cpp -// Author: Michael Bartsch (ZCCdark203) -// -// Desc : Binds various Irrlicht objects to AngelScript. -// -// License: Copyright (C) 2009 Michael Bartsch -// -// 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 "bindIrrlicht.h" - - -// aabbox3d<T> binding. -template<typename T> -void bindaabbox3d(asIScriptEngine *engine, const char *typeName, const char *asType) -{ - // Forward declarations. - int r; - - // Bind aabbox3d<T> class. - r = engine->RegisterObjectType(typeName, sizeof(aabbox3d<T>), asOBJ_REF); assert(r >= 0); - - // Set aabbox3d<T> behaviour. - - - // Bind aabbox3d<T> class functions. - -} - -// dimension2d<T> binding. -template<typename T> -void bindDimension2d(asIScriptEngine *engine, const char *typeName, const char *asType) -{ - // Forward declarations. - int r; - - // Bind dimension2d<T> class. - r = engine->RegisterObjectType(typeName, sizeof(dimension2d<T>), asOBJ_REF); assert(r >= 0); - - // Set dimension2d<T> behaviour. - - - // Bind dimension2d<T> class functions. - -} - -// CMatrix4<T> binding. -template<typename T> -void bindMatrix4(asIScriptEngine *engine, const char *typeName, const char *asType) -{ - // Forward declarations. - int r; - - // Bind CMatrix4<T> class. - r = engine->RegisterObjectType(typeName, sizeof(CMatrix4<T>), asOBJ_REF); assert(r >= 0); - - // Set CMatrix4<T> behaviour. - - - // Bind CMatrix4<T> class functions. - -} - -// SColor binding. -void bindSColor(asIScriptEngine *engine) -{ - // Forward declarations. - int r; - - // Bind SColor class. - r = engine->RegisterObjectType("SColor", sizeof(SColor), asOBJ_REF); assert(r >= 0); - - // Set SColor behaviour. - - - // Bind SColor class functions. - -} - -// Vector2d<T> binding. -template<typename T> -void bindVector2d(asIScriptEngine *engine, const char *typeName, const char *asType) -{ - // Forward declarations. - int r; - - // Bind Vector3d<T> class. - r = engine->RegisterObjectType(typeName, sizeof(vector2d<T>), asOBJ_REF); assert(r >= 0); - - // Set vector3d<T> behaviour. - - - // Bind vector3d<T> class functions. - -} - -// Vector3d<T> binding. -template<typename T> -void bindVector3d(asIScriptEngine *engine, const char *typeName, const char *asType) -{ - // Forward declarations. - int r; - - // Bind Vector3d<T> class. - r = engine->RegisterObjectType(typeName, sizeof(vector3d<T>), asOBJ_REF); assert(r >= 0); - - // Set vector3d<T> behaviour. - - - // Bind vector3d<T> class functions. - -} - - -// Enumerations -// E_CULLING_TYPE -void bindE_CULLING_TYPE(asIScriptEngine *engine) -{ - // Forward declarations. - int r; - - // Bind E_CULLING_TYPE enumeration. - r = engine->RegisterEnum("E_CULLING_TYPE"); assert(r >= 0); - - // Bind E_CULLING_TYPE enumeration values. - r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_OFF", EAC_OFF); assert(r >= 0); - r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_BOX", EAC_BOX); assert(r >= 0); - r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_FRUSTUM_BOX", EAC_FRUSTUM_BOX); assert(r >= 0); - r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_FRUSTUM_SPHERE", EAC_FRUSTUM_SPHERE); assert(r >= 0); -} - -// EKEY_CODE -void bindEKEY_CODE(asIScriptEngine *engine) -{ - // Forward declarations. - int r; - - // Bind EKEY_CODE enumeration. - r = engine->RegisterEnum("EKEY_CODE"); assert(r >= 0); - - // Bind EKEY_CODE enumeration values. -#define bindEnumValue(x) \ -r = engine->RegisterEnumValue("EKEY_CODE", #x, x); assert(r >= 0) - bindEnumValue(KEY_LBUTTON); - bindEnumValue(KEY_RBUTTON); - bindEnumValue(KEY_CANCEL); - bindEnumValue(KEY_MBUTTON); - bindEnumValue(KEY_XBUTTON1); - bindEnumValue(KEY_XBUTTON2); - bindEnumValue(KEY_BACK); - bindEnumValue(KEY_TAB); - bindEnumValue(KEY_CLEAR); - bindEnumValue(KEY_RETURN); - bindEnumValue(KEY_SHIFT); - bindEnumValue(KEY_CONTROL); - bindEnumValue(KEY_MENU); - bindEnumValue(KEY_PAUSE); - bindEnumValue(KEY_CAPITAL); - bindEnumValue(KEY_KANA); - bindEnumValue(KEY_HANGUEL); - bindEnumValue(KEY_HANGUL); - bindEnumValue(KEY_JUNJA); - bindEnumValue(KEY_FINAL); - bindEnumValue(KEY_HANJA); - bindEnumValue(KEY_KANJI); - bindEnumValue(KEY_ESCAPE); - bindEnumValue(KEY_CONVERT); - bindEnumValue(KEY_NONCONVERT); - bindEnumValue(KEY_ACCEPT); - bindEnumValue(KEY_MODECHANGE); - bindEnumValue(KEY_SPACE); - bindEnumValue(KEY_PRIOR); - bindEnumValue(KEY_NEXT); - bindEnumValue(KEY_END); - bindEnumValue(KEY_HOME); - bindEnumValue(KEY_LEFT); - bindEnumValue(KEY_UP); - bindEnumValue(KEY_RIGHT); - bindEnumValue(KEY_DOWN); - bindEnumValue(KEY_SELECT); - bindEnumValue(KEY_PRINT); - bindEnumValue(KEY_EXECUT); - bindEnumValue(KEY_SNAPSHOT); - bindEnumValue(KEY_INSERT); - bindEnumValue(KEY_DELETE); - bindEnumValue(KEY_HELP); - bindEnumValue(KEY_KEY_0); - bindEnumValue(KEY_KEY_1); - bindEnumValue(KEY_KEY_2); - bindEnumValue(KEY_KEY_3); - bindEnumValue(KEY_KEY_4); - bindEnumValue(KEY_KEY_5); - bindEnumValue(KEY_KEY_6); - bindEnumValue(KEY_KEY_7); - bindEnumValue(KEY_KEY_8); - bindEnumValue(KEY_KEY_9); - bindEnumValue(KEY_KEY_A); - bindEnumValue(KEY_KEY_B); - bindEnumValue(KEY_KEY_C); - bindEnumValue(KEY_KEY_D); - bindEnumValue(KEY_KEY_E); - bindEnumValue(KEY_KEY_F); - bindEnumValue(KEY_KEY_G); - bindEnumValue(KEY_KEY_H); - bindEnumValue(KEY_KEY_I); - bindEnumValue(KEY_KEY_J); - bindEnumValue(KEY_KEY_K); - bindEnumValue(KEY_KEY_L); - bindEnumValue(KEY_KEY_M); - bindEnumValue(KEY_KEY_N); - bindEnumValue(KEY_KEY_O); - bindEnumValue(KEY_KEY_P); - bindEnumValue(KEY_KEY_Q); - bindEnumValue(KEY_KEY_R); - bindEnumValue(KEY_KEY_S); - bindEnumValue(KEY_KEY_T); - bindEnumValue(KEY_KEY_U); - bindEnumValue(KEY_KEY_V); - bindEnumValue(KEY_KEY_W); - bindEnumValue(KEY_KEY_X); - bindEnumValue(KEY_KEY_Y); - bindEnumValue(KEY_KEY_Z); - bindEnumValue(KEY_LWIN); - bindEnumValue(KEY_RWIN); - bindEnumValue(KEY_APPS); - bindEnumValue(KEY_SLEEP); - bindEnumValue(KEY_NUMPAD0); - bindEnumValue(KEY_NUMPAD1); - bindEnumValue(KEY_NUMPAD2); - bindEnumValue(KEY_NUMPAD3); - bindEnumValue(KEY_NUMPAD4); - bindEnumValue(KEY_NUMPAD5); - bindEnumValue(KEY_NUMPAD6); - bindEnumValue(KEY_NUMPAD7); - bindEnumValue(KEY_NUMPAD8); - bindEnumValue(KEY_NUMPAD9); - bindEnumValue(KEY_MULTIPLY); - bindEnumValue(KEY_ADD); - bindEnumValue(KEY_SEPARATOR); - bindEnumValue(KEY_SUBTRACT); - bindEnumValue(KEY_DECIMAL); - bindEnumValue(KEY_DIVIDE); - bindEnumValue(KEY_F1); - bindEnumValue(KEY_F2); - bindEnumValue(KEY_F3); - bindEnumValue(KEY_F4); - bindEnumValue(KEY_F5); - bindEnumValue(KEY_F6); - bindEnumValue(KEY_F7); - bindEnumValue(KEY_F8); - bindEnumValue(KEY_F9); - bindEnumValue(KEY_F10); - bindEnumValue(KEY_F11); - bindEnumValue(KEY_F12); - bindEnumValue(KEY_F13); - bindEnumValue(KEY_F14); - bindEnumValue(KEY_F15); - bindEnumValue(KEY_F16); - bindEnumValue(KEY_F17); - bindEnumValue(KEY_F18); - bindEnumValue(KEY_F19); - bindEnumValue(KEY_F20); - bindEnumValue(KEY_F21); - bindEnumValue(KEY_F22); - bindEnumValue(KEY_F23); - bindEnumValue(KEY_F24); - bindEnumValue(KEY_NUMLOCK); - bindEnumValue(KEY_SCROLL); - bindEnumValue(KEY_LSHIFT); - bindEnumValue(KEY_RSHIFT); - bindEnumValue(KEY_LCONTROL); - bindEnumValue(KEY_RCONTROL); - bindEnumValue(KEY_LMENU); - bindEnumValue(KEY_RMENU); - bindEnumValue(KEY_PLUS); - bindEnumValue(KEY_COMMA); - bindEnumValue(KEY_MINUS); - bindEnumValue(KEY_PERIOD); - bindEnumValue(KEY_ATTN); - bindEnumValue(KEY_CRSEL); - bindEnumValue(KEY_EXSEL); - bindEnumValue(KEY_EREOF); - bindEnumValue(KEY_PLAY); - bindEnumValue(KEY_ZOOM); - bindEnumValue(KEY_PA1); - bindEnumValue(KEY_OEM_CLEAR); -#undef bindEnumValue -} - -// E_LIGHT_TYPE -void bindE_LIGHT_TYPE(asIScriptEngine *engine) -{ - // Forward declarations. - int r; - - // Bind E_LIGHT_TYPE enumeration. - r = engine->RegisterEnum("E_LIGHT_TYPE"); assert(r >= 0); - - // Bind E_LIGHT_TYPE enumeration values. -#define bindEnumValue(x) \ -r = engine->RegisterEnumValue("E_LIGHT_TYPE", #x, x); assert(r >= 0) - bindEnumValue(ELT_POINT); - bindEnumValue(ELT_SPOT); - bindEnumValue(ELT_DIRECTIONAL); -#undef bindEnumValue -} - -// E_MATERIAL_FLAG -void bindE_MATERIAL_FLAG(asIScriptEngine *engine) -{ - // Forward declarations. - int r; - - // Bind E_MATERIAL_FLAG enumeration. - r = engine->RegisterEnum("E_MATERIAL_FLAG"); assert(r >= 0); - - // Bind E_MATERIAL_FLAG enumeration values. -#define bindEnumValue(x) \ -r = engine->RegisterEnumValue("E_MATERIAL_FLAG", #x, x); assert(r >= 0) - bindEnumValue(EMF_WIREFRAME); - bindEnumValue(EMF_POINTCLOUD); - bindEnumValue(EMF_GOURAUD_SHADING); - bindEnumValue(EMF_LIGHTING); - bindEnumValue(EMF_ZBUFFER); - bindEnumValue(EMF_ZWRITE_ENABLE); - bindEnumValue(EMF_BACK_FACE_CULLING); - bindEnumValue(EMF_FRONT_FACE_CULLING); - bindEnumValue(EMF_BILINEAR_FILTER); - bindEnumValue(EMF_TRILINEAR_FILTER); - bindEnumValue(EMF_ANISOTROPIC_FILTER); - bindEnumValue(EMF_FOG_ENABLE); - bindEnumValue(EMF_NORMALIZE_NORMALS); - bindEnumValue(EMF_TEXTURE_WRAP); -#undef bindEnumValue -} - -// E_MATERIAL_TYPE -void bindE_MATERIAL_TYPE(asIScriptEngine *engine) -{ - // Forward declarations. - int r; - - // Bind E_MATERIAL_TYPE enumeration. - r = engine->RegisterEnum("E_MATERIAL_TYPE"); assert(r >= 0); - - // Bind E_MATERIAL_TYPE enumeration values. -#define bindEnumValue(x) \ -r = engine->RegisterEnumValue("E_MATERIAL_TYPE", #x, x); assert(r >= 0) - bindEnumValue(EMT_SOLID); - bindEnumValue(EMT_SOLID_2_LAYER); - bindEnumValue(EMT_LIGHTMAP); - bindEnumValue(EMT_LIGHTMAP_ADD); - bindEnumValue(EMT_LIGHTMAP_M2); - bindEnumValue(EMT_LIGHTMAP_M4); - bindEnumValue(EMT_LIGHTMAP_LIGHTING); - bindEnumValue(EMT_LIGHTMAP_LIGHTING_M2); - bindEnumValue(EMT_LIGHTMAP_LIGHTING_M4); - bindEnumValue(EMT_DETAIL_MAP); - bindEnumValue(EMT_SPHERE_MAP); - bindEnumValue(EMT_REFLECTION_2_LAYER); - bindEnumValue(EMT_TRANSPARENT_ADD_COLOR); - bindEnumValue(EMT_TRANSPARENT_ALPHA_CHANNEL); - bindEnumValue(EMT_TRANSPARENT_ALPHA_CHANNEL_REF); - bindEnumValue(EMT_TRANSPARENT_VERTEX_ALPHA); - bindEnumValue(EMT_TRANSPARENT_REFLECTION_2_LAYER); - bindEnumValue(EMT_NORMAL_MAP_SOLID); - bindEnumValue(EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR); - bindEnumValue(EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA); - bindEnumValue(EMT_PARALLAX_MAP_SOLID); - bindEnumValue(EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR); - bindEnumValue(EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA); - bindEnumValue(EMT_ONETEXTURE_BLEND); -#undef bindEnumValue -} - - -// Irrlicht AngelScript binding -void bindIrrlicht(asIScriptEngine *engine) -{ - // Vector3d<T> - bindaabbox3d<f32>(engine, "aabbox3df", "f32"); - bindaabbox3d<s32>(engine, "aabbox3di", "s32"); - - bindDimension2d<f32>(engine, "dimension2df", "f32"); - bindDimension2d<s32>(engine, "dimension2di", "s32"); - - bindMatrix4<f32>(engine, "matrix4", "f32"); - - bindSColor(engine); - - bindVector2d<f32>(engine, "vector2df", "f32"); - bindVector2d<s32>(engine, "vector2di", "s32"); - - bindVector3d<f32>(engine, "vector3df", "f32"); - bindVector3d<s32>(engine, "vector3di", "s32"); - - // Enumerations - bindE_CULLING_TYPE(engine); - bindEKEY_CODE(engine); - bindE_LIGHT_TYPE(engine); - bindE_MATERIAL_FLAG(engine); - bindE_MATERIAL_TYPE(engine); -} - -// End of File - Deleted: trunk/src/scripting/bindIrrlicht.h =================================================================== --- trunk/src/scripting/bindIrrlicht.h 2009-05-30 13:16:53 UTC (rev 43) +++ trunk/src/scripting/bindIrrlicht.h 2009-05-31 15:30:20 UTC (rev 44) @@ -1,28 +0,0 @@ -// ///////////////////////////////////////////////////////////////////////////// -// -// Name: bindIrrlicht.h -// Author: Michael Bartsch (ZCCdark203) -// -// Desc : Binds various Irrlicht objects to AngelScript. -// -// License: Copyright (C) 2009 Michael Bartsch -// -// 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 __BINDIRRLICHT_H__ -#define __BINDIRRLICHT_H__ - -// Include files -#include "../dependencies.h" - - -// AngelScript binding -extern void bindIrrlicht(asIScriptEngine *engine); - -#endif - - Copied: trunk/src/scripting/irrlicht/asIrrlicht.cpp (from rev 43, trunk/src/scripting/bindIrrlicht.cpp) =================================================================== --- trunk/src/scripting/irrlicht/asIrrlicht.cpp (rev 0) +++ trunk/src/scripting/irrlicht/asIrrlicht.cpp 2009-05-31 15:30:20 UTC (rev 44) @@ -0,0 +1,399 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: bindIrrlicht.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds various Irrlicht objects to AngelScript. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "asIrrlicht.h" +#include "asVector2d.h" + + +// aabbox3d<T> binding. +template<typename T> +void bindaabbox3d(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind aabbox3d<T> class. + r = engine->RegisterObjectType(typeName, sizeof(aabbox3d<T>), asOBJ_REF); assert(r >= 0); + + // Set aabbox3d<T> behaviour. + + + // Bind aabbox3d<T> class functions. + +} + +// dimension2d<T> binding. +template<typename T> +void bindDimension2d(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind dimension2d<T> class. + r = engine->RegisterObjectType(typeName, sizeof(dimension2d<T>), asOBJ_REF); assert(r >= 0); + + // Set dimension2d<T> behaviour. + + + // Bind dimension2d<T> class functions. + +} + +// CMatrix4<T> binding. +template<typename T> +void bindMatrix4(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind CMatrix4<T> class. + r = engine->RegisterObjectType(typeName, sizeof(CMatrix4<T>), asOBJ_REF); assert(r >= 0); + + // Set CMatrix4<T> behaviour. + + + // Bind CMatrix4<T> class functions. + +} + +// SColor binding. +void bindSColor(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SColor class. + r = engine->RegisterObjectType("SColor", sizeof(SColor), asOBJ_REF); assert(r >= 0); + + // Set SColor behaviour. + + + // Bind SColor class functions. + +} + +// Vector3d<T> binding. +template<typename T> +void bindVector3d(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind Vector3d<T> class. + r = engine->RegisterObjectType(typeName, sizeof(vector3d<T>), asOBJ_REF); assert(r >= 0); + + // Set vector3d<T> behaviour. + + + // Bind vector3d<T> class functions. + +} + + +// Enumerations +// E_CULLING_TYPE +void bindE_CULLING_TYPE(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind E_CULLING_TYPE enumeration. + r = engine->RegisterEnum("E_CULLING_TYPE"); assert(r >= 0); + + // Bind E_CULLING_TYPE enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("E_CULLING_TYPE", #x, x); assert(r >= 0) + bindEnumValue(EAC_OFF); + bindEnumValue(EAC_BOX); + bindEnumValue(EAC_FRUSTUM_BOX); + bindEnumValue(EAC_FRUSTUM_SPHERE); +#undef bindEnumValue +} + +// EKEY_CODE +void bindEKEY_CODE(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind EKEY_CODE enumeration. + r = engine->RegisterEnum("EKEY_CODE"); assert(r >= 0); + + // Bind EKEY_CODE enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("EKEY_CODE", #x, x); assert(r >= 0) + bindEnumValue(KEY_LBUTTON); + bindEnumValue(KEY_RBUTTON); + bindEnumValue(KEY_CANCEL); + bindEnumValue(KEY_MBUTTON); + bindEnumValue(KEY_XBUTTON1); + bindEnumValue(KEY_XBUTTON2); + bindEnumValue(KEY_BACK); + bindEnumValue(KEY_TAB); + bindEnumValue(KEY_CLEAR); + bindEnumValue(KEY_RETURN); + bindEnumValue(KEY_SHIFT); + bindEnumValue(KEY_CONTROL); + bindEnumValue(KEY_MENU); + bindEnumValue(KEY_PAUSE); + bindEnumValue(KEY_CAPITAL); + bindEnumValue(KEY_KANA); + bindEnumValue(KEY_HANGUEL); + bindEnumValue(KEY_HANGUL); + bindEnumValue(KEY_JUNJA); + bindEnumValue(KEY_FINAL); + bindEnumValue(KEY_HANJA); + bindEnumValue(KEY_KANJI); + bindEnumValue(KEY_ESCAPE); + bindEnumValue(KEY_CONVERT); + bindEnumValue(KEY_NONCONVERT); + bindEnumValue(KEY_ACCEPT); + bindEnumValue(KEY_MODECHANGE); + bindEnumValue(KEY_SPACE); + bindEnumValue(KEY_PRIOR); + bindEnumValue(KEY_NEXT); + bindEnumValue(KEY_END); + bindEnumValue(KEY_HOME); + bindEnumValue(KEY_LEFT); + bindEnumValue(KEY_UP); + bindEnumValue(KEY_RIGHT); + bindEnumValue(KEY_DOWN); + bindEnumValue(KEY_SELECT); + bindEnumValue(KEY_PRINT); + bindEnumValue(KEY_EXECUT); + bindEnumValue(KEY_SNAPSHOT); + bindEnumValue(KEY_INSERT); + bindEnumValue(KEY_DELETE); + bindEnumValue(KEY_HELP); + bindEnumValue(KEY_KEY_0); + bindEnumValue(KEY_KEY_1); + bindEnumValue(KEY_KEY_2); + bindEnumValue(KEY_KEY_3); + bindEnumValue(KEY_KEY_4); + bindEnumValue(KEY_KEY_5); + bindEnumValue(KEY_KEY_6); + bindEnumValue(KEY_KEY_7); + bindEnumValue(KEY_KEY_8); + bindEnumValue(KEY_KEY_9); + bindEnumValue(KEY_KEY_A); + bindEnumValue(KEY_KEY_B); + bindEnumValue(KEY_KEY_C); + bindEnumValue(KEY_KEY_D); + bindEnumValue(KEY_KEY_E); + bindEnumValue(KEY_KEY_F); + bindEnumValue(KEY_KEY_G); + bindEnumValue(KEY_KEY_H); + bindEnumValue(KEY_KEY_I); + bindEnumValue(KEY_KEY_J); + bindEnumValue(KEY_KEY_K); + bindEnumValue(KEY_KEY_L); + bindEnumValue(KEY_KEY_M); + bindEnumValue(KEY_KEY_N); + bindEnumValue(KEY_KEY_O); + bindEnumValue(KEY_KEY_P); + bindEnumValue(KEY_KEY_Q); + bindEnumValue(KEY_KEY_R); + bindEnumValue(KEY_KEY_S); + bindEnumValue(KEY_KEY_T); + bindEnumValue(KEY_KEY_U); + bindEnumValue(KEY_KEY_V); + bindEnumValue(KEY_KEY_W); + bindEnumValue(KEY_KEY_X); + bindEnumValue(KEY_KEY_Y); + bindEnumValue(KEY_KEY_Z); + bindEnumValue(KEY_LWIN); + bindEnumValue(KEY_RWIN); + bindEnumValue(KEY_APPS); + bindEnumValue(KEY_SLEEP); + bindEnumValue(KEY_NUMPAD0); + bindEnumValue(KEY_NUMPAD1); + bindEnumValue(KEY_NUMPAD2); + bindEnumValue(KEY_NUMPAD3); + bindEnumValue(KEY_NUMPAD4); + bindEnumValue(KEY_NUMPAD5); + bindEnumValue(KEY_NUMPAD6); + bindEnumValue(KEY_NUMPAD7); + bindEnumValue(KEY_NUMPAD8); + bindEnumValue(KEY_NUMPAD9); + bindEnumValue(KEY_MULTIPLY); + bindEnumValue(KEY_ADD); + bindEnumValue(KEY_SEPARATOR); + bindEnumValue(KEY_SUBTRACT); + bindEnumValue(KEY_DECIMAL); + bindEnumValue(KEY_DIVIDE); + bindEnumValue(KEY_F1); + bindEnumValue(KEY_F2); + bindEnumValue(KEY_F3); + bindEnumValue(KEY_F4); + bindEnumValue(KEY_F5); + bindEnumValue(KEY_F6); + bindEnumValue(KEY_F7); + bindEnumValue(KEY_F8); + bindEnumValue(KEY_F9); + bindEnumValue(KEY_F10); + bindEnumValue(KEY_F11); + bindEnumValue(KEY_F12); + bindEnumValue(KEY_F13); + bindEnumValue(KEY_F14); + bindEnumValue(KEY_F15); + bindEnumValue(KEY_F16); + bindEnumValue(KEY_F17); + bindEnumValue(KEY_F18); + bindEnumValue(KEY_F19); + bindEnumValue(KEY_F20); + bindEnumValue(KEY_F21); + bindEnumValue(KEY_F22); + bindEnumValue(KEY_F23); + bindEnumValue(KEY_F24); + bindEnumValue(KEY_NUMLOCK); + bindEnumValue(KEY_SCROLL); + bindEnumValue(KEY_LSHIFT); + bindEnumValue(KEY_RSHIFT); + bindEnumValue(KEY_LCONTROL); + bindEnumValue(KEY_RCONTROL); + bindEnumValue(KEY_LMENU); + bindEnumValue(KEY_RMENU); + bindEnumValue(KEY_PLUS); + bindEnumValue(KEY_COMMA); + bindEnumValue(KEY_MINUS); + bindEnumValue(KEY_PERIOD); + bindEnumValue(KEY_ATTN); + bindEnumValue(KEY_CRSEL); + bindEnumValue(KEY_EXSEL); + bindEnumValue(KEY_EREOF); + bindEnumValue(KEY_PLAY); + bindEnumValue(KEY_ZOOM); + bindEnumValue(KEY_PA1); + bindEnumValue(KEY_OEM_CLEAR); +#undef bindEnumValue +} + +// E_LIGHT_TYPE +void bindE_LIGHT_TYPE(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind E_LIGHT_TYPE enumeration. + r = engine->RegisterEnum("E_LIGHT_TYPE"); assert(r >= 0); + + // Bind E_LIGHT_TYPE enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("E_LIGHT_TYPE", #x, x); assert(r >= 0) + bindEnumValue(ELT_POINT); + bindEnumValue(ELT_SPOT); + bindEnumValue(ELT_DIRECTIONAL); +#undef bindEnumValue +} + +// E_MATERIAL_FLAG +void bindE_MATERIAL_FLAG(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind E_MATERIAL_FLAG enumeration. + r = engine->RegisterEnum("E_MATERIAL_FLAG"); assert(r >= 0); + + // Bind E_MATERIAL_FLAG enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("E_MATERIAL_FLAG", #x, x); assert(r >= 0) + bindEnumValue(EMF_WIREFRAME); + bindEnumValue(EMF_POINTCLOUD); + bindEnumValue(EMF_GOURAUD_SHADING); + bindEnumValue(EMF_LIGHTING); + bindEnumValue(EMF_ZBUFFER); + bindEnumValue(EMF_ZWRITE_ENABLE); + bindEnumValue(EMF_BACK_FACE_CULLING); + bindEnumValue(EMF_FRONT_FACE_CULLING); + bindEnumValue(EMF_BILINEAR_FILTER); + bindEnumValue(EMF_TRILINEAR_FILTER); + bindEnumValue(EMF_ANISOTROPIC_FILTER); + bindEnumValue(EMF_FOG_ENABLE); + bindEnumValue(EMF_NORMALIZE_NORMALS); + bindEnumValue(EMF_TEXTURE_WRAP); +#undef bindEnumValue +} + +// E_MATERIAL_TYPE +void bindE_MATERIAL_TYPE(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind E_MATERIAL_TYPE enumeration. + r = engine->RegisterEnum("E_MATERIAL_TYPE"); assert(r >= 0); + + // Bind E_MATERIAL_TYPE enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("E_MATERIAL_TYPE", #x, x); assert(r >= 0) + bindEnumValue(EMT_SOLID); + bindEnumValue(EMT_SOLID_2_LAYER); + bindEnumValue(EMT_LIGHTMAP); + bindEnumValue(EMT_LIGHTMAP_ADD); + bindEnumValue(EMT_LIGHTMAP_M2); + bindEnumValue(EMT_LIGHTMAP_M4); + bindEnumValue(EMT_LIGHTMAP_LIGHTING); + bindEnumValue(EMT_LIGHTMAP_LIGHTING_M2); + bindEnumValue(EMT_LIGHTMAP_LIGHTING_M4); + bindEnumValue(EMT_DETAIL_MAP); + bindEnumValue(EMT_SPHERE_MAP); + bindEnumValue(EMT_REFLECTION_2_LAYER); + bindEnumValue(EMT_TRANSPARENT_ADD_COLOR); + bindEnumValue(EMT_TRANSPARENT_ALPHA_CHANNEL); + bindEnumValue(EMT_TRANSPARENT_ALPHA_CHANNEL_REF); + bindEnumValue(EMT_TRANSPARENT_VERTEX_ALPHA); + bindEnumValue(EMT_TRANSPARENT_REFLECTION_2_LAYER); + bindEnumValue(EMT_NORMAL_MAP_SOLID); + bindEnumValue(EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR); + bindEnumValue(EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA); + bindEnumValue(EMT_PARALLAX_MAP_SOLID); + bindEnumValue(EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR); + bindEnumValue(EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA); + bindEnumValue(EMT_ONETEXTURE_BLEND); +#undef bindEnumValue +} + + +// Irrlicht AngelScript binding +void bindIrrlicht(asIScriptEngine *engine) +{ + // Vector3d<T> + bindaabbox3d<f32>(engine, "aabbox3df", "f32"); + bindaabbox3d<s32>(engine, "aabbox3di", "s32"); + + bindDimension2d<f32>(engine, "dimension2df", "f32"); + bindDimension2d<s32>(engine, "dimension2di", "s32"); + + bindMatrix4<f32>(engine, "matrix4", "f32"); + + bindSColor(engine); + + bindVector2d(engine); + + bindVector3d<f32>(engine, "vector3df", "f32"); + bindVector3d<s32>(engine, "vector3di", "s32"); + + // Enumerations + bindE_CULLING_TYPE(engine); + bindEKEY_CODE(engine); + bindE_LIGHT_TYPE(engine); + bindE_MATERIAL_FLAG(engine); + bindE_MATERIAL_TYPE(engine); +} + +// End of File + Property changes on: trunk/src/scripting/irrlicht/asIrrlicht.cpp ___________________________________________________________________ Added: svn:mergeinfo + Copied: trunk/src/scripting/irrlicht/asIrrlicht.h (from rev 39, trunk/src/scripting/bindIrrlicht.h) =================================================================== --- trunk/src/scripting/irrlicht/asIrrlicht.h (rev 0) +++ trunk/src/scripting/irrlicht/asIrrlicht.h 2009-05-31 15:30:20 UTC (rev 44) @@ -0,0 +1,28 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: bindIrrlicht.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds various Irrlicht objects to AngelScript. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __BINDIRRLICHT_H__ +#define __BINDIRRLICHT_H__ + +// Include files +#include "../../dependencies.h" + + +// AngelScript binding +extern void bindIrrlicht(asIScriptEngine *engine); + +#endif + + Property changes on: trunk/src/scripting/irrlicht/asIrrlicht.h ___________________________________________________________________ Added: svn:mergeinfo + Added: trunk/src/scripting/irrlicht/asVector2d.cpp =================================================================== --- trunk/src/scripting/irrlicht/asVector2d.cpp (rev 0) +++ trunk/src/scripting/irrlicht/asVector2d.cpp 2009-05-31 15:30:20 UTC (rev 44) @@ -0,0 +1,377 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asVector2d.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the vector2d<T> class from the Irrlicht engine. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "asVector2d.h" + + +// vector2d<T> behaviour functions. +//! An AngelScript wrapper function so that vector2d<T> objects can be +//! constructed within AngelScript. +//! @note For internal use only! +template<typename T> +void constructor(void *memory) +{ + new (memory) vector2d<T>(); +} + +//! An AngelScript wrapper function so that vector2d<T> objects can be +//! constructed within AngelScript. +//! @note For internal use only! +template<typename T> +void constructor(const vector2d<T> &other, void *memory) +{ + new (memory) vector2d<T>(other); +} + +//! An AngelScript wrapper function so that vector2d<T> objects can be +//! constructed within AngelScript. +//! @note For internal use only! +template<typename T> +void constructor(T x, T y, void *memory) +{ + new (memory) vector2d<T>(x, y); +} + +//! An AngelScript wrapper function so that vector2d<T> objects can be +//! deconstructed within AngelScript. +//! @note For internal use only! +template<typename T> +void deconstructor(void *memory) +{ + ((vector2d<T>*)memory)->~vector2d<T>(); +} + +//! An AngelScript wrapper function for the multiply behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> multiply(const vector2d<T> &a, const vector2d<T> &b) +{ + return a * b; +} + +//! An AngelScript wrapper function for the multiply behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> multiply(const vector2d<T> &a, const T &b) +{ + return a * b; +} + +//! An AngelScript wrapper function for the addition behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> add(const vector2d<T> &a, const vector2d<T> &b) +{ + return a + b; +} + +//! An AngelScript wrapper function for the addition behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> add(const vector2d<T> &a, const T &b) +{ + return a + b; +} + +//! An AngelScript wrapper function for the substraction behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> subtract(const vector2d<T> &a, const vector2d<T> &b) +{ + return a - b; +} + +//! An AngelScript wrapper function for the substraction behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> subtract(const vector2d<T> &a, const T &b) +{ + return a - b; +} + +//! An AngelScript wrapper function for the divide behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> divide(const vector2d<T> &a, const vector2d<T> &b) +{ + return a / b; +} + +//! An AngelScript wrapper function for the divide behaviour. +//! @note For internal use only! +template<typename T> +vector2d<T> divide(const vector2d<T> &a, const T &b) +{ + return a / b; +} + +//! An AngelScript wrapper function for the equal behaviour. +//! @note For internal use only! +template<typename T> +bool equal(const vector2d<T> &a, const vector2d<T> &b) +{ + return (a==b); +} + +//! An AngelScript wrapper function for the not-equal behaviour. +//! @note For internal use only! +template<typename T> +bool not_equal(const vector2d<T> &a, const vector2d<T> &b) +{ + return (a!=b); +} + +//! An AngelScript wrapper function for the less-than behaviour. +//! @note For internal use only! +template<typename T> +bool less_than(const vector2d<T> &a, const vector2d<T> &b) +{ + return (a<b); +} + +//! An AngelScript wrapper function for the greater-than behaviour. +//! @note For internal use only! +template<typename T> +bool greater_than(const vector2d<T> &a, const vector2d<T> &b) +{ + return (a>b); +} + +//! An AngelScript wrapper function for the less-or-equal behaviour. +//! @note For internal use only! +template<typename T> +bool l_equal(const vector2d<T> &a, const vector2d<T> &b) +{ + return (a<=b); +} + +//! An AngelScript wrapper function for the greater-or-equal behaviour. +//! @note For internal use only! +template<typename T> +bool g_equal(const vector2d<T> &a, const vector2d<T> &b) +{ + return (a>=b); +} + +//! Binds vector2d<T> as a value type to AngelScript with the given template. +//! @param engine Pointer to the AngelScript engine +//! @param typeName The name of the object within AngelScript; +//! @param asType The AngelScript name of the used template; +template<typename T> +void bindVector2dT(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + std::stringstream ss; + + // Bind Vector2d<T> class. + r = engine->RegisterObjectType(typeName, sizeof(vector2d<T>), asOBJ_VALUE | asOBJ_APP_CLASS_CDA); assert(r >= 0); + + // Set vector2d<T> behaviour. + // Initialisation and deinitialisation + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR(constructor<T>, + (void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0); + + ss.str(""); + ss << "void f(const " << typeName << "&in)"; + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, ss.str().c_str(), asFUNCTIONPR(constructor<T>, + (const vector2d<T>&, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0); + + ss.str(""); + ss << "void f(" << asType << ", " << asType << ")"; + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_CONSTRUCT, ss.str().c_str(), asFUNCTIONPR(constructor<T>, + (T, T, void*), void), asCALL_CDECL_OBJLAST); assert(r >= 0); + + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_DESTRUCT, "void f()", asFUNCTION(deconstructor<T>), + asCALL_CDECL_OBJLAST); assert(r >= 0); + + // Calculation behaviours. + ss.str(""); + ss << typeName << " f(const " << typeName << " &in, const " << typeName << " &in)"; + std::string declActionType = ss.str(); + + ss.str(""); + ss << typeName << " f(const " << typeName << " &in, " << asType << ")"; + std::string declActionValue = ss.str(); + + ss.str(""); + ss << typeName << "& f(const " << typeName << " &in)"; + std::string declAssignType = ss.str(); + + ss.str(""); + ss << typeName << "& f(const " << asType << ")"; + std::string declAssignValue = ss.str(); + + // Assignment + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_ASSIGNMENT, declAssignType.c_str(), + asMETHODPR(vector2d<T>, operator=, (const vector2d<T>&), + vector2d<T>&), asCALL_THISCALL); assert(r >= 0); + + // Multiply (*) + r = engine->RegisterGlobalBehaviour(asBEHAVE_MULTIPLY, declActionType.c_str(), asFUNCTIONPR(multiply<T>, + (const vector2d<T>&, const vector2d<T>&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_MULTIPLY, declActionValue.c_str(), asFUNCTIONPR(multiply<T>, + (const vector2d<T>&, const T&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + + // Multiply Assign (*=) + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_MUL_ASSIGN, declAssignType.c_str(), + asMETHODPR(vector2d<T>, operator*=, (const vector2d<T>&), + vector2d<T>&), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_MUL_ASSIGN, declAssignValue.c_str(), + asMETHODPR(vector2d<T>, operator*=, (const T), vector2d<T>&), + asCALL_THISCALL); assert(r >= 0); + + // Add (+) + r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, declActionType.c_str(), asFUNCTIONPR(add<T>, + (const vector2d<T>&, const vector2d<T>&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_ADD, declActionValue.c_str(), asFUNCTIONPR(add<T>, + (const vector2d<T>&, const T&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + + // Add Assign (+=) + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_ADD_ASSIGN, declAssignType.c_str(), + asMETHODPR(vector2d<T>, operator+=, (const vector2d<T>&), + vector2d<T>&), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_ADD_ASSIGN, declAssignValue.c_str(), + asMETHODPR(vector2d<T>, operator+=, (const T), vector2d<T>&), + asCALL_THISCALL); assert(r >= 0); + + // Subtract (-) + r = engine->RegisterGlobalBehaviour(asBEHAVE_SUBTRACT, declActionType.c_str(), asFUNCTIONPR(subtract<T>, + (const vector2d<T>&, const vector2d<T>&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_SUBTRACT, declActionValue.c_str(), asFUNCTIONPR(subtract<T>, + (const vector2d<T>&, const T&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + + // Subtract Assign (-=) + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_SUB_ASSIGN, declAssignType.c_str(), + asMETHODPR(vector2d<T>, operator-=, (const vector2d<T>&), + vector2d<T>&), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_SUB_ASSIGN, declAssignValue.c_str(), + asMETHODPR(vector2d<T>, operator-=, (const T), vector2d<T>&), + asCALL_THISCALL); assert(r >= 0); + + // Divide (/) + r = engine->RegisterGlobalBehaviour(asBEHAVE_DIVIDE, declActionType.c_str(), asFUNCTIONPR(divide<T>, + (const vector2d<T>&, const vector2d<T>&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_DIVIDE, declActionValue.c_str(), asFUNCTIONPR(divide<T>, + (const vector2d<T>&, const T&), vector2d<T>), + asCALL_CDECL); assert(r >= 0); + + // Divide Assign (/=) + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_DIV_ASSIGN, declAssignType.c_str(), + asMETHODPR(vector2d<T>, operator/=, (const vector2d<T>&), + vector2d<T>&), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour(typeName, asBEHAVE_DIV_ASSIGN, declAssignValue.c_str(), + asMETHODPR(vector2d<T>, operator/=, (const T), vector2d<T>&), + asCALL_THISCALL); assert(r >= 0); + + // Comparison behaviours. + ss.str(""); + ss << "bool f(const " << typeName << " &in, const " << typeName << " &in)"; + std::string declComparison = ss.str(); + + r = engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL, declComparison.c_str(), asFUNCTIONPR(equal<T>, + (const vector2d<T>&, const vector2d<T>&), bool), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_NOTEQUAL, declComparison.c_str(), asFUNCTIONPR(not_equal<T>, + (const vector2d<T>&, const vector2d<T>&), bool), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_LESSTHAN, declComparison.c_str(), asFUNCTIONPR(less_than<T>, + (const vector2d<T>&, const vector2d<T>&), bool), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_GREATERTHAN, declComparison.c_str(), asFUNCTIONPR(greater_than<T>, + (const vector2d<T>&, const vector2d<T>&), bool), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_LEQUAL, declComparison.c_str(), asFUNCTIONPR(l_equal<T>, + (const vector2d<T>&, const vector2d<T>&), bool), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterGlobalBehaviour(asBEHAVE_GEQUAL, declComparison.c_str(), asFUNCTIONPR(g_equal<T>, + (const vector2d<T>&, const vector2d<T>&), bool), asCALL_CDECL); assert(r >= 0); + + // Bind vector2d<T> class functions. + ss.str(""); + ss << asType << " dotProduct(const " << typeName << " &in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, dotProduct), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(typeName, "f64 getAngle()", + asMETHOD(vector2d<T>, getAngle), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(typeName, "f64 getAngleTrig()", + asMETHOD(vector2d<T>, getAngleTrig), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << "f64 getAngleWith(const " << typeName << " &in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, getAngleWith), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << asType << " getDistanceFrom(const " << typeName << " &in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, getDistanceFrom), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << asType << " getDistanceFromSQ(const " << typeName << " &in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, getDistanceFromSQ), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << typeName << " getInterpolated(const " << typeName << " &in, f64)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, getInterpolated), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << typeName << " getInterpolated_quadratic(const " << typeName << " &in, const " << typeName << "&in, f64)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, getInterpolated_quadratic), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << asType << " getLength()"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, getLength), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << asType << " getLengthSQ()"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, getLengthSQ), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << typeName << "& interpolate(const " << typeName << " &in, const " << typeName << "&in, f64)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, interpolate), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << "bool isBetweenPoints(const " << typeName << " &in, const " << typeName << "&in)"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, isBetweenPoints), asCALL_THISCALL); assert(r >= 0); + + ss.str(""); + ss << typeName << "& normalize()"; + r = engine->RegisterObjectMethod(typeName, ss.str().c_str(), + asMETHOD(vector2d<T>, normalize), asCALL_THISCALL); assert(r >= 0); + +} + +//! Binds all needed vector2d<T> objects to AngelScript. +//! @param engine Pointer to the AngelScript engine +void bindVector2d(asIScriptEngine *engine) +{ + bindVector2dT<f32>(engine, "vector2df", "f32"); + bindVector2dT<s32>(engine, "vector2di", "s32"); +} + +// End of File Added: trunk/src/scripting/irrlicht/asVector2d.h =================================================================== --- trunk/src/scripting/irrlicht/asVector2d.h (rev 0) +++ trunk/src/scripting/irrlicht/asVector2d.h 2009-05-31 15:30:20 UTC (rev 44) @@ -0,0 +1,26 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: asVector2d.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds the vector2d<T> class from the Irrlicht engine. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __ASVECTOR2D_INCLUDED__ +#define __ASVECTOR2D_INCLUDED__ + +// Include files +#include "../../dependencies.h" + + +// AngelScript binding +extern void bindVector2d(asIScriptEngine *engine); + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-30 13:17:01
|
Revision: 43 http://sirrf.svn.sourceforge.net/sirrf/?rev=43&view=rev Author: zccdark203 Date: 2009-05-30 13:16:53 +0000 (Sat, 30 May 2009) Log Message: ----------- Integrated Irrlicht's event management into the EventManager class. This class now emits events such as onKeyDown#KEY_KEY_A when input is received. Furthermore it also offers some convenience functions for checking the state of input devices. And on top of that binding of Irrlicht enumerations to AngelScript has been simplified by using macro's. Modified Paths: -------------- trunk/src/core/EventManager.cpp trunk/src/core/EventManager.h trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/scripting/bindIrrlicht.cpp trunk/src/sirrf.depend Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-05-27 20:03:34 UTC (rev 42) +++ trunk/src/core/EventManager.cpp 2009-05-30 13:16:53 UTC (rev 43) @@ -34,6 +34,33 @@ // Initialises the Event Manager. void EventManager::init() { + generateKeyMap(); + + // Create the event group for the Event Manager. This group should take care of core events. + createEventGroup("EventManager"); + std::map<std::string, EventSlot> &eventGroup = mEvents["EventManager"]; + + // Add mouse events. + createEventSlot("EventManager", "onMouseMoved"); + createEventSlot("EventManager", "onMouseDown#Left"); + createEventSlot("EventManager", "onMouseDown#Right"); + createEventSlot("EventManager", "onMouseDown#Middle"); + createEventSlot("EventManager", "onMouseUp#Left"); + createEventSlot("EventManager", "onMouseUp#Right"); + createEventSlot("EventManager", "onMouseUp#Middle"); + createEventSlot("EventManager", "onMouseWheel"); + + // Add event slots to the event group. + std::string strOnKeyDown = "onKeyDown#"; + std::string strOnKeyUp = "onKeyUp#"; + + std::map<EKEY_CODE, std::string>::iterator it; + for(it = mKeyMap.begin(); it != mKeyMap.end(); it++) + { + EventSlot slot1, slot2; + eventGroup[strOnKeyDown + it->second] = slot1; + eventGroup[strOnKeyUp + it->second] = slot2; + } } // Clears the Event Manager. @@ -42,6 +69,156 @@ mEvents.clear(); } +// Generates a string-based keymap, so that keys can be used by the event manager. +void EventManager::generateKeyMap() +{ +#define addToKeyMap(x) mKeyMap[x] = #x + addToKeyMap(KEY_LBUTTON); + addToKeyMap(KEY_RBUTTON); + addToKeyMap(KEY_CANCEL); + addToKeyMap(KEY_MBUTTON); + addToKeyMap(KEY_XBUTTON1); + addToKeyMap(KEY_XBUTTON2); + addToKeyMap(KEY_BACK); + addToKeyMap(KEY_TAB); + addToKeyMap(KEY_CLEAR); + addToKeyMap(KEY_RETURN); + addToKeyMap(KEY_SHIFT); + addToKeyMap(KEY_CONTROL); + addToKeyMap(KEY_MENU); + addToKeyMap(KEY_PAUSE); + addToKeyMap(KEY_CAPITAL); + addToKeyMap(KEY_KANA); + addToKeyMap(KEY_HANGUEL); + addToKeyMap(KEY_HANGUL); + addToKeyMap(KEY_JUNJA); + addToKeyMap(KEY_FINAL); + addToKeyMap(KEY_HANJA); + addToKeyMap(KEY_KANJI); + addToKeyMap(KEY_ESCAPE); + addToKeyMap(KEY_CONVERT); + addToKeyMap(KEY_NONCONVERT); + addToKeyMap(KEY_ACCEPT); + addToKeyMap(KEY_MODECHANGE); + addToKeyMap(KEY_SPACE); + addToKeyMap(KEY_PRIOR); + addToKeyMap(KEY_NEXT); + addToKeyMap(KEY_END); + addToKeyMap(KEY_HOME); + addToKeyMap(KEY_LEFT); + addToKeyMap(KEY_UP); + addToKeyMap(KEY_RIGHT); + addToKeyMap(KEY_DOWN); + addToKeyMap(KEY_SELECT); + addToKeyMap(KEY_PRINT); + addToKeyMap(KEY_EXECUT); + addToKeyMap(KEY_SNAPSHOT); + addToKeyMap(KEY_INSERT); + addToKeyMap(KEY_DELETE); + addToKeyMap(KEY_HELP); + addToKeyMap(KEY_KEY_0); + addToKeyMap(KEY_KEY_1); + addToKeyMap(KEY_KEY_2); + addToKeyMap(KEY_KEY_3); + addToKeyMap(KEY_KEY_4); + addToKeyMap(KEY_KEY_5); + addToKeyMap(KEY_KEY_6); + addToKeyMap(KEY_KEY_7); + addToKeyMap(KEY_KEY_8); + addToKeyMap(KEY_KEY_9); + addToKeyMap(KEY_KEY_A); + addToKeyMap(KEY_KEY_B); + addToKeyMap(KEY_KEY_C); + addToKeyMap(KEY_KEY_D); + addToKeyMap(KEY_KEY_E); + addToKeyMap(KEY_KEY_F); + addToKeyMap(KEY_KEY_G); + addToKeyMap(KEY_KEY_H); + addToKeyMap(KEY_KEY_I); + addToKeyMap(KEY_KEY_J); + addToKeyMap(KEY_KEY_K); + addToKeyMap(KEY_KEY_L); + addToKeyMap(KEY_KEY_M); + addToKeyMap(KEY_KEY_N); + addToKeyMap(KEY_KEY_O); + addToKeyMap(KEY_KEY_P); + addToKeyMap(KEY_KEY_Q); + addToKeyMap(KEY_KEY_R); + addToKeyMap(KEY_KEY_S); + addToKeyMap(KEY_KEY_T); + addToKeyMap(KEY_KEY_U); + addToKeyMap(KEY_KEY_V); + addToKeyMap(KEY_KEY_W); + addToKeyMap(KEY_KEY_X); + addToKeyMap(KEY_KEY_Y); + addToKeyMap(KEY_KEY_Z); + addToKeyMap(KEY_LWIN); + addToKeyMap(KEY_RWIN); + addToKeyMap(KEY_APPS); + addToKeyMap(KEY_SLEEP); + addToKeyMap(KEY_NUMPAD0); + addToKeyMap(KEY_NUMPAD1); + addToKeyMap(KEY_NUMPAD2); + addToKeyMap(KEY_NUMPAD3); + addToKeyMap(KEY_NUMPAD4); + addToKeyMap(KEY_NUMPAD5); + addToKeyMap(KEY_NUMPAD6); + addToKeyMap(KEY_NUMPAD7); + addToKeyMap(KEY_NUMPAD8); + addToKeyMap(KEY_NUMPAD9); + addToKeyMap(KEY_MULTIPLY); + addToKeyMap(KEY_ADD); + addToKeyMap(KEY_SEPARATOR); + addToKeyMap(KEY_SUBTRACT); + addToKeyMap(KEY_DECIMAL); + addToKeyMap(KEY_DIVIDE); + addToKeyMap(KEY_F1); + addToKeyMap(KEY_F2); + addToKeyMap(KEY_F3); + addToKeyMap(KEY_F4); + addToKeyMap(KEY_F5); + addToKeyMap(KEY_F6); + addToKeyMap(KEY_F7); + addToKeyMap(KEY_F8); + addToKeyMap(KEY_F9); + addToKeyMap(KEY_F10); + addToKeyMap(KEY_F11); + addToKeyMap(KEY_F12); + addToKeyMap(KEY_F13); + addToKeyMap(KEY_F14); + addToKeyMap(KEY_F15); + addToKeyMap(KEY_F16); + addToKeyMap(KEY_F17); + addToKeyMap(KEY_F18); + addToKeyMap(KEY_F19); + addToKeyMap(KEY_F20); + addToKeyMap(KEY_F21); + addToKeyMap(KEY_F22); + addToKeyMap(KEY_F23); + addToKeyMap(KEY_F24); + addToKeyMap(KEY_NUMLOCK); + addToKeyMap(KEY_SCROLL); + addToKeyMap(KEY_LSHIFT); + addToKeyMap(KEY_RSHIFT); + addToKeyMap(KEY_LCONTROL); + addToKeyMap(KEY_RCONTROL); + addToKeyMap(KEY_LMENU); + addToKeyMap(KEY_RMENU); + addToKeyMap(KEY_PLUS); + addToKeyMap(KEY_COMMA); + addToKeyMap(KEY_MINUS); + addToKeyMap(KEY_PERIOD); + addToKeyMap(KEY_ATTN); + addToKeyMap(KEY_CRSEL); + addToKeyMap(KEY_EXSEL); + addToKeyMap(KEY_EREOF); + addToKeyMap(KEY_PLAY); + addToKeyMap(KEY_ZOOM); + addToKeyMap(KEY_PA1); + addToKeyMap(KEY_OEM_CLEAR); +#undef addToKeyMap +} + // Angelscript: Increases the reference counter. void EventManager::refAdd() { @@ -121,6 +298,43 @@ return true; } +// Check if the key is down. +bool EventManager::getIsKeyDown(EKEY_CODE keyCode) const +{ + return mKeyState[keyCode]; +} + +// Check if the key is up. +bool EventManager::getIsKeyUp(EKEY_CODE keyCode) const +{ + return !mKeyState[keyCode]; +} + +// Returns the X-coordinate of the mouse position. +s32 EventManager::getMouseX() const +{ + return mMousePos.X; +} + +// Returns the Y-coordinate of the mouse position. +s32 EventManager::getMouseY() const +{ + return mMousePos.Y; +} + +// Returns the position of the mouse as a 2d vector. +const vector2di& EventManager::getMousePos() const +{ + return mMousePos; +} + +// Gets the mouse wheel position. +f32 EventManager::getMouseWheel() const +{ + return mMouseWheel; +} + + // Removes all event groups from the Event Manager. void EventManager::removeAllEventGroups() { @@ -183,7 +397,74 @@ return true; } +// Handles the events sent by the Irrlicht engine. +bool EventManager::OnEvent(const SEvent &event) +{ + // Keyboard event. + if(event.EventType == EET_KEY_INPUT_EVENT) + { + // Store the value in the key map. + mKeyState[event.KeyInput.Key] = event.KeyInput.PressedDown; + // Emit the event. + std::string slotName; + + if(event.KeyInput.PressedDown) + slotName = "onKeyDown#"; + + else slotName = "onKeyUp#"; + + mEvents["EventManager"][slotName + mKeyMap[event.KeyInput.Key]].emit(0); + } + + // Mouse event. + if(event.EventType == EET_MOUSE_INPUT_EVENT) + { + switch(event.MouseInput.Event) + { + case EMIE_MOUSE_MOVED: // Did the mouse move? + mMousePos.X = event.MouseInput.X; + mMousePos.Y = event.MouseInput.Y; + mEvents["EventManager"]["onMouseMoved"].emit(0); + break; + + case EMIE_LMOUSE_PRESSED_DOWN: // Left mouse button was pressed down. + mEvents["EventManager"]["onMouseDown#Left"].emit(0); + break; + + case EMIE_RMOUSE_PRESSED_DOWN: // Right mouse button was pressed down. + mEvents["EventManager"]["onMouseDown#Right"].emit(0); + break; + + case EMIE_MMOUSE_PRESSED_DOWN: // Middle mouse button was pressed down. + mEvents["EventManager"]["onMouseDown#Middle"].emit(0); + break; + + case EMIE_LMOUSE_LEFT_UP: // Left mouse button was left up. + mEvents["EventManager"]["onMouseUp#Left"].emit(0); + break; + + case EMIE_RMOUSE_LEFT_UP: // Right mouse button was left up. + mEvents["EventManager"]["onMouseUp#Right"].emit(0); + break; + + case EMIE_MMOUSE_LEFT_UP: // Middle mouse button was left up. + mEvents["EventManager"]["onMouseUp#Middle"].emit(0); + break; + + case EMIE_MOUSE_WHEEL: // The mouse wheel was moved. + mMouseWheel = event.MouseInput.Wheel; + mEvents["EventManager"]["onMouseWheel"].emit(0); + break; + + default: break; + } + } + + return false; +} + + // EventManager and sigslot::has_slots<> Angelscript binding. void bindEventManager(asIScriptEngine *engine) { @@ -210,6 +491,20 @@ r = engine->RegisterObjectMethod("EventManager", "bool createEventSlot(const string &, const string &)", asMETHOD(EventManager, createEventSlot), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "bool getIsKeyDown(EKEY_CODE)", + asMETHOD(EventManager, getIsKeyDown), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "bool getIsKeyUp(EKEY_CODE)", + asMETHOD(EventManager, getIsKeyDown), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("EventManager", "s32 getMouseX()", + asMETHOD(EventManager, getMouseX), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "s32 getMouseY()", + asMETHOD(EventManager, getMouseY), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "const vector2di& getMousePos()", + asMETHOD(EventManager, getMousePos), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "f32 getMouseWheel()", + asMETHOD(EventManager, getMouseWheel), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EventManager", "void removeAllEventGroups()", asMETHOD(EventManager, removeAllEventGroups), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EventManager", "bool removeAllEventSlots(const string &)", Modified: trunk/src/core/EventManager.h =================================================================== --- trunk/src/core/EventManager.h 2009-05-27 20:03:34 UTC (rev 42) +++ trunk/src/core/EventManager.h 2009-05-30 13:16:53 UTC (rev 43) @@ -24,7 +24,7 @@ // EventManager class -class EventManager +class EventManager : public IEventReceiver { public: @@ -97,16 +97,35 @@ bool emitEvent(const std::string &groupName, const std::string &slotName, void* p = 0); + bool getIsKeyDown(EKEY_CODE keyCode) const; + bool getIsKeyUp(EKEY_CODE keyCode) const; + + s32 getMouseX() const; + s32 getMouseY() const; + const vector2di& getMousePos() const; + f32 getMouseWheel() const; + void removeAllEventGroups(); bool removeAllEventSlots(const std::string &groupName); bool removeEventGroup(const std::string &groupName); bool removeEventSlot(const std::string &groupName, const std::string &slotName); + virtual bool OnEvent(const SEvent &event); + private: + // Private initialisation and deinitialisation + void generateKeyMap(); + // Members std::map<std::string, std::map<std::string, EventSlot> > mEvents; + bool mKeyState[KEY_KEY_CODES_COUNT]; + std::map<EKEY_CODE, std::string> mKeyMap; + + vector2di mMousePos; + f32 mMouseWheel; + }; Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-05-27 20:03:34 UTC (rev 42) +++ trunk/src/core/GameManager.cpp 2009-05-30 13:16:53 UTC (rev 43) @@ -55,18 +55,20 @@ // Initialises the Game Manager. void GameManager::init() { + // Initialise the subsystems of the framework. (stage 1) + pDataStore = new DataStore(); + pEventManager = new EventManager(); + // Initialise the Irrlicht engine. - pDevice = createDevice(EDT_OPENGL, dimension2d<u32>(1024, 768), 32, false, false, false, this); + pDevice = createDevice(EDT_OPENGL, dimension2d<u32>(1024, 768), 32, false, false, false, pEventManager); // Get points to subsystems of the Irrlicht engine. pDriver = pDevice->getVideoDriver(); pSceneManager = pDevice->getSceneManager(); pGUIEnvironment = pDevice->getGUIEnvironment(); - // Initialise subsystems of the framework. - pDataStore = new DataStore(); + // Initialise subsystems of the framework (stage 2); pEntityManager = new EntityManager(); - pEventManager = new EventManager(); pSoundManager = new SoundManager(); pScriptManager = new ScriptManager(); @@ -231,15 +233,7 @@ pDevice->closeDevice(); } -// Handles the events sent by Irrlicht. -bool GameManager::OnEvent(const SEvent& event) -{ - if(!pDriver) - return false; - return false; -} - // GameManager Angelscript binding. void bindGameManager(asIScriptEngine *engine) { Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-05-27 20:03:34 UTC (rev 42) +++ trunk/src/core/GameManager.h 2009-05-30 13:16:53 UTC (rev 43) @@ -33,7 +33,7 @@ // GameManager class -class GameManager : public IEventReceiver +class GameManager { public: @@ -73,7 +73,6 @@ void setIsRunning(bool value); - virtual bool OnEvent(const SEvent &event); private: Modified: trunk/src/scripting/bindIrrlicht.cpp =================================================================== --- trunk/src/scripting/bindIrrlicht.cpp 2009-05-27 20:03:34 UTC (rev 42) +++ trunk/src/scripting/bindIrrlicht.cpp 2009-05-30 13:16:53 UTC (rev 43) @@ -84,8 +84,25 @@ } -// Vector3df<T> binding. +// Vector2d<T> binding. template<typename T> +void bindVector2d(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind Vector3d<T> class. + r = engine->RegisterObjectType(typeName, sizeof(vector2d<T>), asOBJ_REF); assert(r >= 0); + + // Set vector3d<T> behaviour. + + + // Bind vector3d<T> class functions. + +} + +// Vector3d<T> binding. +template<typename T> void bindVector3d(asIScriptEngine *engine, const char *typeName, const char *asType) { // Forward declarations. @@ -119,19 +136,180 @@ r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_FRUSTUM_SPHERE", EAC_FRUSTUM_SPHERE); assert(r >= 0); } +// EKEY_CODE +void bindEKEY_CODE(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind EKEY_CODE enumeration. + r = engine->RegisterEnum("EKEY_CODE"); assert(r >= 0); + + // Bind EKEY_CODE enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("EKEY_CODE", #x, x); assert(r >= 0) + bindEnumValue(KEY_LBUTTON); + bindEnumValue(KEY_RBUTTON); + bindEnumValue(KEY_CANCEL); + bindEnumValue(KEY_MBUTTON); + bindEnumValue(KEY_XBUTTON1); + bindEnumValue(KEY_XBUTTON2); + bindEnumValue(KEY_BACK); + bindEnumValue(KEY_TAB); + bindEnumValue(KEY_CLEAR); + bindEnumValue(KEY_RETURN); + bindEnumValue(KEY_SHIFT); + bindEnumValue(KEY_CONTROL); + bindEnumValue(KEY_MENU); + bindEnumValue(KEY_PAUSE); + bindEnumValue(KEY_CAPITAL); + bindEnumValue(KEY_KANA); + bindEnumValue(KEY_HANGUEL); + bindEnumValue(KEY_HANGUL); + bindEnumValue(KEY_JUNJA); + bindEnumValue(KEY_FINAL); + bindEnumValue(KEY_HANJA); + bindEnumValue(KEY_KANJI); + bindEnumValue(KEY_ESCAPE); + bindEnumValue(KEY_CONVERT); + bindEnumValue(KEY_NONCONVERT); + bindEnumValue(KEY_ACCEPT); + bindEnumValue(KEY_MODECHANGE); + bindEnumValue(KEY_SPACE); + bindEnumValue(KEY_PRIOR); + bindEnumValue(KEY_NEXT); + bindEnumValue(KEY_END); + bindEnumValue(KEY_HOME); + bindEnumValue(KEY_LEFT); + bindEnumValue(KEY_UP); + bindEnumValue(KEY_RIGHT); + bindEnumValue(KEY_DOWN); + bindEnumValue(KEY_SELECT); + bindEnumValue(KEY_PRINT); + bindEnumValue(KEY_EXECUT); + bindEnumValue(KEY_SNAPSHOT); + bindEnumValue(KEY_INSERT); + bindEnumValue(KEY_DELETE); + bindEnumValue(KEY_HELP); + bindEnumValue(KEY_KEY_0); + bindEnumValue(KEY_KEY_1); + bindEnumValue(KEY_KEY_2); + bindEnumValue(KEY_KEY_3); + bindEnumValue(KEY_KEY_4); + bindEnumValue(KEY_KEY_5); + bindEnumValue(KEY_KEY_6); + bindEnumValue(KEY_KEY_7); + bindEnumValue(KEY_KEY_8); + bindEnumValue(KEY_KEY_9); + bindEnumValue(KEY_KEY_A); + bindEnumValue(KEY_KEY_B); + bindEnumValue(KEY_KEY_C); + bindEnumValue(KEY_KEY_D); + bindEnumValue(KEY_KEY_E); + bindEnumValue(KEY_KEY_F); + bindEnumValue(KEY_KEY_G); + bindEnumValue(KEY_KEY_H); + bindEnumValue(KEY_KEY_I); + bindEnumValue(KEY_KEY_J); + bindEnumValue(KEY_KEY_K); + bindEnumValue(KEY_KEY_L); + bindEnumValue(KEY_KEY_M); + bindEnumValue(KEY_KEY_N); + bindEnumValue(KEY_KEY_O); + bindEnumValue(KEY_KEY_P); + bindEnumValue(KEY_KEY_Q); + bindEnumValue(KEY_KEY_R); + bindEnumValue(KEY_KEY_S); + bindEnumValue(KEY_KEY_T); + bindEnumValue(KEY_KEY_U); + bindEnumValue(KEY_KEY_V); + bindEnumValue(KEY_KEY_W); + bindEnumValue(KEY_KEY_X); + bindEnumValue(KEY_KEY_Y); + bindEnumValue(KEY_KEY_Z); + bindEnumValue(KEY_LWIN); + bindEnumValue(KEY_RWIN); + bindEnumValue(KEY_APPS); + bindEnumValue(KEY_SLEEP); + bindEnumValue(KEY_NUMPAD0); + bindEnumValue(KEY_NUMPAD1); + bindEnumValue(KEY_NUMPAD2); + bindEnumValue(KEY_NUMPAD3); + bindEnumValue(KEY_NUMPAD4); + bindEnumValue(KEY_NUMPAD5); + bindEnumValue(KEY_NUMPAD6); + bindEnumValue(KEY_NUMPAD7); + bindEnumValue(KEY_NUMPAD8); + bindEnumValue(KEY_NUMPAD9); + bindEnumValue(KEY_MULTIPLY); + bindEnumValue(KEY_ADD); + bindEnumValue(KEY_SEPARATOR); + bindEnumValue(KEY_SUBTRACT); + bindEnumValue(KEY_DECIMAL); + bindEnumValue(KEY_DIVIDE); + bindEnumValue(KEY_F1); + bindEnumValue(KEY_F2); + bindEnumValue(KEY_F3); + bindEnumValue(KEY_F4); + bindEnumValue(KEY_F5); + bindEnumValue(KEY_F6); + bindEnumValue(KEY_F7); + bindEnumValue(KEY_F8); + bindEnumValue(KEY_F9); + bindEnumValue(KEY_F10); + bindEnumValue(KEY_F11); + bindEnumValue(KEY_F12); + bindEnumValue(KEY_F13); + bindEnumValue(KEY_F14); + bindEnumValue(KEY_F15); + bindEnumValue(KEY_F16); + bindEnumValue(KEY_F17); + bindEnumValue(KEY_F18); + bindEnumValue(KEY_F19); + bindEnumValue(KEY_F20); + bindEnumValue(KEY_F21); + bindEnumValue(KEY_F22); + bindEnumValue(KEY_F23); + bindEnumValue(KEY_F24); + bindEnumValue(KEY_NUMLOCK); + bindEnumValue(KEY_SCROLL); + bindEnumValue(KEY_LSHIFT); + bindEnumValue(KEY_RSHIFT); + bindEnumValue(KEY_LCONTROL); + bindEnumValue(KEY_RCONTROL); + bindEnumValue(KEY_LMENU); + bindEnumValue(KEY_RMENU); + bindEnumValue(KEY_PLUS); + bindEnumValue(KEY_COMMA); + bindEnumValue(KEY_MINUS); + bindEnumValue(KEY_PERIOD); + bindEnumValue(KEY_ATTN); + bindEnumValue(KEY_CRSEL); + bindEnumValue(KEY_EXSEL); + bindEnumValue(KEY_EREOF); + bindEnumValue(KEY_PLAY); + bindEnumValue(KEY_ZOOM); + bindEnumValue(KEY_PA1); + bindEnumValue(KEY_OEM_CLEAR); +#undef bindEnumValue +} + // E_LIGHT_TYPE void bindE_LIGHT_TYPE(asIScriptEngine *engine) { // Forward declarations. int r; - // Bind E_CULLING_TYPE enumeration. + // Bind E_LIGHT_TYPE enumeration. r = engine->RegisterEnum("E_LIGHT_TYPE"); assert(r >= 0); - // Bind E_CULLING_TYPE enumeration values. - r = engine->RegisterEnumValue("E_LIGHT_TYPE", "ELT_POINT", ELT_POINT); assert(r >= 0); - r = engine->RegisterEnumValue("E_LIGHT_TYPE", "ELT_SPOT", ELT_SPOT); assert(r >= 0); - r = engine->RegisterEnumValue("E_LIGHT_TYPE", "ELT_DIRECTIONAL", ELT_DIRECTIONAL); assert(r >= 0); + // Bind E_LIGHT_TYPE enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("E_LIGHT_TYPE", #x, x); assert(r >= 0) + bindEnumValue(ELT_POINT); + bindEnumValue(ELT_SPOT); + bindEnumValue(ELT_DIRECTIONAL); +#undef bindEnumValue } // E_MATERIAL_FLAG @@ -143,21 +321,24 @@ // Bind E_MATERIAL_FLAG enumeration. r = engine->RegisterEnum("E_MATERIAL_FLAG"); assert(r >= 0); - // Bind E_CULLING_TYPE enumeration values. - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_WIREFRAME", EMF_WIREFRAME); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_POINTCLOUD", EMF_POINTCLOUD); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_GOURAUD_SHADING", EMF_GOURAUD_SHADING); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_LIGHTING", EMF_LIGHTING); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_ZBUFFER", EMF_ZBUFFER); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_ZWRITE_ENABLE", EMF_ZWRITE_ENABLE); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_BACK_FACE_CULLING", EMF_BACK_FACE_CULLING); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_FRONT_FACE_CULLING", EMF_FRONT_FACE_CULLING); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_BILINEAR_FILTER", EMF_BILINEAR_FILTER); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_TRILINEAR_FILTER", EMF_TRILINEAR_FILTER); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_ANISOTROPIC_FILTER", EMF_ANISOTROPIC_FILTER); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_FOG_ENABLE", EMF_FOG_ENABLE); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_NORMALIZE_NORMALS", EMF_NORMALIZE_NORMALS); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_TEXTURE_WRAP", EMF_TEXTURE_WRAP); + // Bind E_MATERIAL_FLAG enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("E_MATERIAL_FLAG", #x, x); assert(r >= 0) + bindEnumValue(EMF_WIREFRAME); + bindEnumValue(EMF_POINTCLOUD); + bindEnumValue(EMF_GOURAUD_SHADING); + bindEnumValue(EMF_LIGHTING); + bindEnumValue(EMF_ZBUFFER); + bindEnumValue(EMF_ZWRITE_ENABLE); + bindEnumValue(EMF_BACK_FACE_CULLING); + bindEnumValue(EMF_FRONT_FACE_CULLING); + bindEnumValue(EMF_BILINEAR_FILTER); + bindEnumValue(EMF_TRILINEAR_FILTER); + bindEnumValue(EMF_ANISOTROPIC_FILTER); + bindEnumValue(EMF_FOG_ENABLE); + bindEnumValue(EMF_NORMALIZE_NORMALS); + bindEnumValue(EMF_TEXTURE_WRAP); +#undef bindEnumValue } // E_MATERIAL_TYPE @@ -166,34 +347,37 @@ // Forward declarations. int r; - // Bind E_MATERIAL_FLAG enumeration. + // Bind E_MATERIAL_TYPE enumeration. r = engine->RegisterEnum("E_MATERIAL_TYPE"); assert(r >= 0); - // Bind E_CULLING_TYPE enumeration values. - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_SOLID", EMT_SOLID); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_SOLID_2_LAYER", EMT_SOLID_2_LAYER); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP", EMT_LIGHTMAP); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_ADD", EMT_LIGHTMAP_ADD); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_M2", EMT_LIGHTMAP_M2); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_M4", EMT_LIGHTMAP_M4); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_LIGHTING", EMT_LIGHTMAP_LIGHTING); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_LIGHTING_M2", EMT_LIGHTMAP_LIGHTING_M2); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_LIGHTING_M4", EMT_LIGHTMAP_LIGHTING_M4); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_DETAIL_MAP", EMT_DETAIL_MAP); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_SPHERE_MAP", EMT_SPHERE_MAP); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_REFLECTION_2_LAYER", EMT_REFLECTION_2_LAYER); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_ADD_COLOR", EMT_TRANSPARENT_ADD_COLOR); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_ALPHA_CHANNEL", EMT_TRANSPARENT_ALPHA_CHANNEL); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_ALPHA_CHANNEL_REF", EMT_TRANSPARENT_ALPHA_CHANNEL_REF); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_VERTEX_ALPHA", EMT_TRANSPARENT_VERTEX_ALPHA); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_REFLECTION_2_LAYER", EMT_TRANSPARENT_REFLECTION_2_LAYER); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_NORMAL_MAP_SOLID", EMT_NORMAL_MAP_SOLID); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR", EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA", EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_PARALLAX_MAP_SOLID", EMT_PARALLAX_MAP_SOLID); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR", EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA", EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA); assert(r >= 0); - r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_ONETEXTURE_BLEND", EMT_ONETEXTURE_BLEND); assert(r >= 0); + // Bind E_MATERIAL_TYPE enumeration values. +#define bindEnumValue(x) \ +r = engine->RegisterEnumValue("E_MATERIAL_TYPE", #x, x); assert(r >= 0) + bindEnumValue(EMT_SOLID); + bindEnumValue(EMT_SOLID_2_LAYER); + bindEnumValue(EMT_LIGHTMAP); + bindEnumValue(EMT_LIGHTMAP_ADD); + bindEnumValue(EMT_LIGHTMAP_M2); + bindEnumValue(EMT_LIGHTMAP_M4); + bindEnumValue(EMT_LIGHTMAP_LIGHTING); + bindEnumValue(EMT_LIGHTMAP_LIGHTING_M2); + bindEnumValue(EMT_LIGHTMAP_LIGHTING_M4); + bindEnumValue(EMT_DETAIL_MAP); + bindEnumValue(EMT_SPHERE_MAP); + bindEnumValue(EMT_REFLECTION_2_LAYER); + bindEnumValue(EMT_TRANSPARENT_ADD_COLOR); + bindEnumValue(EMT_TRANSPARENT_ALPHA_CHANNEL); + bindEnumValue(EMT_TRANSPARENT_ALPHA_CHANNEL_REF); + bindEnumValue(EMT_TRANSPARENT_VERTEX_ALPHA); + bindEnumValue(EMT_TRANSPARENT_REFLECTION_2_LAYER); + bindEnumValue(EMT_NORMAL_MAP_SOLID); + bindEnumValue(EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR); + bindEnumValue(EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA); + bindEnumValue(EMT_PARALLAX_MAP_SOLID); + bindEnumValue(EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR); + bindEnumValue(EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA); + bindEnumValue(EMT_ONETEXTURE_BLEND); +#undef bindEnumValue } @@ -211,11 +395,15 @@ bindSColor(engine); + bindVector2d<f32>(engine, "vector2df", "f32"); + bindVector2d<s32>(engine, "vector2di", "s32"); + bindVector3d<f32>(engine, "vector3df", "f32"); bindVector3d<s32>(engine, "vector3di", "s32"); // Enumerations bindE_CULLING_TYPE(engine); + bindEKEY_CODE(engine); bindE_LIGHT_TYPE(engine); bindE_MATERIAL_FLAG(engine); bindE_MATERIAL_TYPE(engine); Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-27 20:03:34 UTC (rev 42) +++ trunk/src/sirrf.depend 2009-05-30 13:16:53 UTC (rev 43) @@ -1043,11 +1043,11 @@ "../dependencies.h" "Entity.h" -1243451609 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1243683215 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" "../components/components.h" -1243271926 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h +1243683226 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" "GameState.h" "DataStore.h" @@ -1076,10 +1076,10 @@ 1240939945 source:/home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.cpp -1243451609 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp +1243687542 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp "EventManager.h" -1243271884 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h +1243687542 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h "../dependencies.h" 1240941730 /home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.h @@ -1179,7 +1179,7 @@ "../../dependencies.h" "SceneComponent.h" -1243451135 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp +1243454092 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp "AnimatedMeshComponent.h" "../../core/GameManager.h" @@ -1187,7 +1187,7 @@ "../../dependencies.h" "SceneComponent.h" -1243453049 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp +1243453618 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp "CameraComponent.h" "../../core/GameManager.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-27 20:04:04
|
Revision: 42 http://sirrf.svn.sourceforge.net/sirrf/?rev=42&view=rev Author: zccdark203 Date: 2009-05-27 20:03:34 +0000 (Wed, 27 May 2009) Log Message: ----------- Added AngelScript bindings to all existing scene components. I've also made some typedefs within AngelScript so that the Irrlicht naming convention of base variables (int = s32, etc) can be used. At the same time I've also made various small improvements to the framework as a whole. Modified Paths: -------------- trunk/src/components/components.cpp trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/BillboardComponent.cpp trunk/src/components/scene/BillboardComponent.h trunk/src/components/scene/CameraComponent.cpp trunk/src/components/scene/CameraComponent.h trunk/src/components/scene/LightComponent.cpp trunk/src/components/scene/LightComponent.h trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/MeshComponent.h trunk/src/components/scene/OctTreeComponent.cpp trunk/src/components/scene/OctTreeComponent.h trunk/src/components/scene/ParticleSysComponent.cpp trunk/src/components/scene/ParticleSysComponent.h trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/components/scene/SkyBoxComponent.cpp trunk/src/components/scene/SkyBoxComponent.h trunk/src/components/scene/SkyDomeComponent.cpp trunk/src/components/scene/SkyDomeComponent.h trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/scene/TerrainComponent.h trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/components/scene/TextBillboardComponent.h trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/core/DataStack.cpp trunk/src/core/DataStack.h trunk/src/core/DataStore.cpp trunk/src/core/Entity.cpp trunk/src/core/EntityComponent.h trunk/src/core/EntityManager.cpp trunk/src/scripting/Script.cpp trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/bindIrrlicht.cpp trunk/src/sirrf.depend trunk/src/sirrf.layout trunk/src/sound/SoundManager.cpp Modified: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/components.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -23,6 +23,18 @@ // Scene bindSceneComponent(engine); + bindAnimatedMeshComponent(engine); + bindBillboardComponent(engine); + bindCameraComponent(engine); + bindLightComponent(engine); + bindMeshComponent(engine); + bindOctTreeComponent(engine); + bindParticleSysComponent(engine); + bindSkyBoxComponent(engine); + bindSkyDomeComponent(engine); + bindTerrainComponent(engine); + bindTextBillboardComponent(engine); + // Sound bindSoundListenerComponent(engine); bindSoundSourceComponent(engine); Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -82,6 +82,20 @@ mSceneNode = NULL; } +// AngelScript: Will be used to instanciate objects of this class. +AnimatedMeshComponent* AnimatedMeshComponent::refFactory(Entity *parent) +{ + return new AnimatedMeshComponent(parent); +} + +// AngelScript: Will be used to instanciate objects of this class. +AnimatedMeshComponent* AnimatedMeshComponent::refFactory(Entity *parent, const std::string &fileName, + const vector3df &rotation, + const vector3df &scale) +{ + return new AnimatedMeshComponent(parent, fileName, rotation, scale); +} + // Gets a direct pointer to the IAnimatedMeshSceneNode. IAnimatedMeshSceneNode* AnimatedMeshComponent::getAnimatedMeshSceneNode() { @@ -89,7 +103,7 @@ } // Returns the current end frame number. -int AnimatedMeshComponent::getEndFrame() const +s32 AnimatedMeshComponent::getEndFrame() const { return mAnimatedMeshSN->getEndFrame(); } @@ -101,7 +115,7 @@ } // Returns the current displayed frame number. -int AnimatedMeshComponent::getFrame() const +s32 AnimatedMeshComponent::getFrame() const { return mAnimatedMeshSN->getFrameNr(); } @@ -119,7 +133,7 @@ } // Returns the current start frame number. -int AnimatedMeshComponent::getStartFrame() const +s32 AnimatedMeshComponent::getStartFrame() const { return mAnimatedMeshSN->getStartFrame(); } @@ -203,4 +217,59 @@ mAnimatedMeshSN->setTransitionTime(time); } + +// AnimatedMeshComponent Angelscript binding. +void bindAnimatedMeshComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind AnimatedMeshComponent class. + r = engine->RegisterObjectType("AnimatedMeshComponent", sizeof(AnimatedMeshComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<AnimatedMeshComponent>(engine, "AnimatedMeshComponent"); + + // Set SkyDomeComponent behaviour. + r = engine->RegisterObjectBehaviour("AnimatedMeshComponent", asBEHAVE_FACTORY, "AnimatedMeshComponent@ f(Entity @)", + asFUNCTIONPR(AnimatedMeshComponent::refFactory, (Entity*), AnimatedMeshComponent*), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("AnimatedMeshComponent", asBEHAVE_FACTORY, "AnimatedMeshComponent@ f(Entity @, " \ + "const string &, const vector3df &in, const vector3df &in)", + asFUNCTIONPR(AnimatedMeshComponent::refFactory, (Entity*, const std::string&, + const vector3df&, const vector3df&), AnimatedMeshComponent*), asCALL_CDECL); + assert(r >= 0); + + // Bind AnimatedMeshComponent class functions. + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void animate()", + asMETHOD(AnimatedMeshComponent, animate), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "s32 getEndFrame()", + asMETHOD(AnimatedMeshComponent, getEndFrame), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "s32 getFrame()", + asMETHOD(AnimatedMeshComponent, getFrame), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "s32 getStartFrame()", + asMETHOD(AnimatedMeshComponent, getStartFrame), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setAnimationSpeed(f32)", + asMETHOD(AnimatedMeshComponent, setAnimationSpeed), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setCurrentFrame(s32)", + asMETHOD(AnimatedMeshComponent, setCurrentFrame), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setFrameLoop(s32, s32)", + asMETHOD(AnimatedMeshComponent, setFrameLoop), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setLoopMode(bool)", + asMETHOD(AnimatedMeshComponent, setLoopMode), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setMD2Animation(const string &)", + asMETHODPR(AnimatedMeshComponent, setMD2Animation, (const std::string&), void), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setMesh(const string &)", + asMETHODPR(AnimatedMeshComponent, setMesh, (const std::string&), void), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setShadowVolumeSceneNode(const string &fileName, " \ + "bool, f32)", asMETHODPR(AnimatedMeshComponent, setShadowVolumeSceneNode, + (const std::string&, bool, f32), void), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("AnimatedMeshComponent", "void setTransitionTime(f32)", + asMETHOD(AnimatedMeshComponent, setTransitionTime), asCALL_THISCALL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -36,16 +36,21 @@ const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); ~AnimatedMeshComponent(); + // AngelScript binding + static AnimatedMeshComponent* refFactory(Entity *parent); + static AnimatedMeshComponent* refFactory(Entity *parent, const std::string &fileName, + const vector3df &rotation, const vector3df &scale); + // Methods IAnimatedMeshSceneNode* getAnimatedMeshSceneNode(); void animate(); - int getEndFrame() const; - int getFrame() const; + s32 getEndFrame() const; + s32 getFrame() const; IMesh* getMesh(); IShadowVolumeSceneNode* getShadowVolumeSceneNode(); - int getStartFrame() const; + s32 getStartFrame() const; void setAnimationSpeed(f32 speed); void setCurrentFrame(s32 frame); @@ -68,4 +73,8 @@ IShadowVolumeSceneNode *mShadowVolumeSN; }; + +// AnimatedMeshComponent Angelscript binding. +extern void bindAnimatedMeshComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -20,23 +20,6 @@ // BillboardComponent class // BillboardComponent constructor (default). -BillboardComponent::BillboardComponent(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. - mBillboardSN = pSceneMgr->addBillboardSceneNode(0, dimension2df(10.0f, 10.0f), - parent->getPosition(), parent->getID()); - mSceneNode = mBillboardSN; - - // Set-up internal mechanism for collision detection. - mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardSN); - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); -} - -// BillboardComponent constructor. BillboardComponent::BillboardComponent(Entity *parent, const dimension2df &size, const SColor &colorTop, const SColor &colorBottom) : SceneComponent(parent, true) @@ -60,6 +43,19 @@ { } +// AngelScript: Will be used to instanciate objects of this class. +BillboardComponent* BillboardComponent::refFactory(Entity *parent) +{ + return new BillboardComponent(parent); +} + +// AngelScript: Will be used to instanciate objects of this class. +BillboardComponent* BillboardComponent::refFactory(Entity *parent, const dimension2df &size, + const SColor &colorTop, const SColor &colorBottom) +{ + return new BillboardComponent(parent, size, colorTop, colorBottom); +} + // BillboardComponent deconstructor. BillboardComponent::~BillboardComponent() { @@ -106,4 +102,28 @@ mBillboardSN->setSize(size); } + +// BillboardComponent Angelscript binding. +void bindBillboardComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind BillboardComponent class. + r = engine->RegisterObjectType("BillboardComponent", sizeof(BillboardComponent), asOBJ_REF); assert(r >= 0); + + // Bind base functions. + bindBillboardComponentBase<BillboardComponent>(engine, "BillboardComponent"); + + // Set BillboardComponent behaviour. + r = engine->RegisterObjectBehaviour("BillboardComponent", asBEHAVE_FACTORY, "BillboardComponent@ f(Entity @)", + asFUNCTIONPR(BillboardComponent::refFactory, (Entity*), BillboardComponent*), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("BillboardComponent", asBEHAVE_FACTORY, "BillboardComponent@ f(Entity @, " \ + "const dimension2df &in, const SColor &in, const SColor &in)", + asFUNCTIONPR(BillboardComponent::refFactory, (Entity*, const dimension2df&, + const SColor&, const SColor&), BillboardComponent*), + asCALL_CDECL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/BillboardComponent.h =================================================================== --- trunk/src/components/scene/BillboardComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/BillboardComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -27,12 +27,16 @@ public: // Initialisation and deinitialisation - BillboardComponent(Entity *parent); BillboardComponent(Entity *parent, const dimension2df &size = dimension2df(10.0f, 10.0f), const SColor &colorTop = SColor(255, 255, 255, 255), const SColor &colorBottom = SColor(255, 255, 255, 255)); ~BillboardComponent(); + // AngelScript binding + static BillboardComponent* refFactory(Entity *parent); + static BillboardComponent* refFactory(Entity *parent, const dimension2df &size, + const SColor &colorTop, const SColor &colorBottom); + // Methods IBillboardSceneNode* getBillboardSceneNode(); @@ -52,4 +56,39 @@ IBillboardSceneNode *mBillboardSN; }; + +// BillboardComponent Angelscript binding. +extern void bindBillboardComponent(asIScriptEngine *engine); + + +template<typename T> +void bindBillboardComponentBase(asIScriptEngine *engine, const char *type) +{ + // Forward declaration. + int r; + std::string sType = type; + + // Bind inherited functions. + bindSceneComponentBase<BillboardComponent>(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 ); + + // Bind common class functions. + r = engine->RegisterObjectMethod(type, "void getColor(SColor &in, SColor &in)", + asMETHOD(T, getColor), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "const dimension2df& getSize()", + asMETHOD(T, getSize), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "void setColor(const SColor &in)", + asMETHODPR(T, setColor, (const SColor&), void), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setColor(const SColor &in, const SColor &in)", + asMETHODPR(T, setColor, (const SColor&, const SColor&), void), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setSize(const dimension2df &in)", + asMETHOD(T, setSize), asCALL_THISCALL); assert(r >= 0); +} + #endif Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/CameraComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -44,6 +44,18 @@ mSceneNode = NULL; } +// AngelScript: Will be used to instanciate objects of this class. +CameraComponent* CameraComponent::refFactory(Entity *parent) +{ + return new CameraComponent(parent); +} + +// AngelScript: Will be used to instanciate objects of this class. +CameraComponent* CameraComponent::refFactory(Entity *parent, const vector3df &lookat) +{ + return new CameraComponent(parent, lookat); +} + // Gets a direct pointer to the ICameraSceneNode. ICameraSceneNode* CameraComponent::getCameraSceneNode() { @@ -63,25 +75,25 @@ } // Gets the aspect ratio of the camera. -float CameraComponent::getAspectRatio() const +f32 CameraComponent::getAspectRatio() const { return mCameraSN->getAspectRatio(); } // Gets the value of the far plane of the camera. -float CameraComponent::getFarValue() const +f32 CameraComponent::getFarValue() const { return mCameraSN->getFarValue(); } // Gets the field of view of the camera. -float CameraComponent::getFOV() const +f32 CameraComponent::getFOV() const { return mCameraSN->getFOV(); } // Gets the value of the near plane of the camera. -float CameraComponent::getNearValue() const +f32 CameraComponent::getNearValue() const { return mCameraSN->getNearValue(); } @@ -218,4 +230,77 @@ mCameraAnimator = animMaya; } + +// CameraComponent Angelscript binding. +void bindCameraComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind CameraComponent class. + r = engine->RegisterObjectType("CameraComponent", sizeof(CameraComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<CameraComponent>(engine, "CameraComponent"); + + // Set CameraComponent behaviour. + r = engine->RegisterObjectBehaviour("CameraComponent", asBEHAVE_FACTORY, "CameraComponent@ f(Entity @)", + asFUNCTIONPR(CameraComponent::refFactory, (Entity*), CameraComponent*), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("CameraComponent", asBEHAVE_FACTORY, "CameraComponent@ f(Entity @, " \ + "const vector3df &in)", asFUNCTIONPR(CameraComponent::refFactory, + (Entity*, const vector3df&), CameraComponent*), asCALL_CDECL); assert(r >= 0); + + // Bind CameraComponent class functions. + r = engine->RegisterObjectMethod("CameraComponent", "void bindTargetAndRotation(bool)", + asMETHOD(CameraComponent, bindTargetAndRotation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "bool getTargetAndRotationBinding()", + asMETHOD(CameraComponent, getTargetAndRotationBinding), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("CameraComponent", "f32 getAspectRatio()", + asMETHOD(CameraComponent, getAspectRatio), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "f32 getFarValue()", + asMETHOD(CameraComponent, getFarValue), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "f32 getFOV()", + asMETHOD(CameraComponent, getFOV), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "f32 getNearValue()", + asMETHOD(CameraComponent, getNearValue), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "const matrix4& getProjectionMatrix()", + asMETHOD(CameraComponent, getProjectionMatrix), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "const vector3df& getTarget()", + asMETHOD(CameraComponent, getTarget), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "const vector3df& getUpVector()", + asMETHOD(CameraComponent, getUpVector), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "const matrix4& getViewMatrix()", + asMETHOD(CameraComponent, getViewMatrix), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "bool getIsOrthogonal()", + asMETHOD(CameraComponent, getIsOrthogonal), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("CameraComponent", "void setAsMainCamera()", + asMETHOD(CameraComponent, setAsMainCamera), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setAspectRatio(f32)", + asMETHOD(CameraComponent, setAspectRatio), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setFarValue(f32)", + asMETHOD(CameraComponent, setFarValue), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setFOV(f32)", + asMETHOD(CameraComponent, setFOV), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setNearValue(f32)", + asMETHOD(CameraComponent, setNearValue), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setProjectionMatrix(const matrix4 &in, bool)", + asMETHOD(CameraComponent, setProjectionMatrix), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setRotation(const vector3df &in)", + asMETHOD(CameraComponent, setRotation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setTarget(const vector3df &in)", + asMETHOD(CameraComponent, setTarget), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setUpVector(const vector3df &in)", + asMETHOD(CameraComponent, setUpVector), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("CameraComponent", "void setNormalMode()", + asMETHOD(CameraComponent, setNormalMode), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setFPSMode(f32, f32, bool, f32)", + asMETHOD(CameraComponent, setFPSMode), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("CameraComponent", "void setMayaMode(f32, f32, f32)", + asMETHOD(CameraComponent, setMayaMode), asCALL_THISCALL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/CameraComponent.h =================================================================== --- trunk/src/components/scene/CameraComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/CameraComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -30,21 +30,25 @@ CameraComponent(Entity *parent, const vector3df &lookat = vector3df(0, 0, 100)); ~CameraComponent(); + // AngelScript binding + static CameraComponent* refFactory(Entity *parent); + static CameraComponent* refFactory(Entity *parent, const vector3df &lookat); + // Methods ICameraSceneNode* getCameraSceneNode(); void bindTargetAndRotation(bool bound); bool getTargetAndRotationBinding() const; - float getAspectRatio() const; - float getFarValue() const; - float getFOV() const; - float getNearValue() const; + f32 getAspectRatio() const; + f32 getFarValue() const; + f32 getFOV() const; + f32 getNearValue() const; const matrix4& getProjectionMatrix() const; const vector3df& getTarget() const; const vector3df& getUpVector() const; - const matrix4& getViewMatrix()const; - bool getIsOrthogonal()const; + const matrix4& getViewMatrix() const; + bool getIsOrthogonal() const; void setAsMainCamera(); void setAspectRatio(f32 aspect); @@ -69,5 +73,9 @@ ISceneNodeAnimator *mCameraAnimator; }; + +// CameraComponent Angelscript binding. +extern void bindCameraComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/LightComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -19,24 +19,7 @@ // LightComponent class -// LightComponent constructor (default). -LightComponent::LightComponent(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. - mLightSN = pSceneMgr->addLightSceneNode(0, parent->getPosition(), SColorf(1.0f, 1.0f, 1.0f), - 100.0f, parent->getID()); - mSceneNode = mLightSN; - - // Set-up internal mechanism for collision detection. - mTriSelector = NULL; - mMetaSelector = pSceneMgr->createMetaTriangleSelector(); -} - -// LightComponent constructor. +// LightComponent constructor. (default) LightComponent::LightComponent(Entity *parent, const SColorf &color, f32 radius) : SceneComponent(parent, true) { @@ -60,6 +43,18 @@ mSceneNode = NULL; } +// AngelScript: Will be used to instanciate objects of this class. +LightComponent* LightComponent::refFactory(Entity *parent) +{ + return new LightComponent(parent); +} + +// AngelScript: Will be used to instanciate objects of this class. +LightComponent* LightComponent::refFactory(Entity *parent, const SColor &color, f32 radius) +{ + return new LightComponent(parent, color, radius); +} + // Gets a direct pointer to the ILightSceneNode. ILightSceneNode* LightComponent::getLightSceneNode() { @@ -79,7 +74,7 @@ } // Gets the light's radius of influence. -float LightComponent::getRadius() const +f32 LightComponent::getRadius() const { return mLightSN->getRadius(); } @@ -102,4 +97,42 @@ mLightSN->setRadius(radius); } + +// LightComponent Angelscript binding. +void bindLightComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind LightComponent class. + r = engine->RegisterObjectType("LightComponent", sizeof(LightComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<LightComponent>(engine, "LightComponent"); + + // Set LightComponent behaviour. + r = engine->RegisterObjectBehaviour("LightComponent", asBEHAVE_FACTORY, "LightComponent@ f(Entity @)", + asFUNCTIONPR(LightComponent::refFactory, (Entity*), LightComponent*), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("LightComponent", asBEHAVE_FACTORY, "LightComponent@ f(Entity @, " \ + "const SColor&in, f32)",asFUNCTIONPR(LightComponent::refFactory, + (Entity*, const SColor &color, f32), LightComponent*), asCALL_CDECL); + assert(r >= 0); + + // Bind LightComponent class functions. + r = engine->RegisterObjectMethod("LightComponent", "bool getCastShadow()", + asMETHOD(LightComponent, getCastShadow), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("LightComponent", "E_LIGHT_TYPE getLightType()", + asMETHOD(LightComponent, getLightType), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("LightComponent", "f32 getRadius()", + asMETHOD(LightComponent, getRadius), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("LightComponent", "void setCastShadow(bool)", + asMETHOD(LightComponent, setCastShadow), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("LightComponent", "void setLightType(E_LIGHT_TYPE)", + asMETHOD(LightComponent, setLightType), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("LightComponent", "void setRadius(f32)", + asMETHOD(LightComponent, setRadius), asCALL_THISCALL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/LightComponent.h =================================================================== --- trunk/src/components/scene/LightComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/LightComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -27,17 +27,20 @@ public: // Initialisation and deinitialisation - LightComponent(Entity *parent); LightComponent(Entity *parent, const SColorf &color = SColorf(1.0f, 1.0f, 1.0f), f32 radius = 100.0f); ~LightComponent(); + // AngelScript binding + static LightComponent* refFactory(Entity *parent); + static LightComponent* refFactory(Entity *parent, const SColor &color, f32 radius); + // Methods ILightSceneNode* getLightSceneNode(); bool getCastShadow() const; E_LIGHT_TYPE getLightType() const; - float getRadius() const; + f32 getRadius() const; void setCastShadow(bool shadow = true); void setLightType(E_LIGHT_TYPE type); @@ -49,4 +52,8 @@ ILightSceneNode *mLightSN; }; + +// LightComponent Angelscript binding. +extern void bindLightComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/MeshComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -80,6 +80,19 @@ mSceneNode = NULL; } +// AngelScript: Will be used to instanciate objects of this class. +MeshComponent* MeshComponent::refFactory(Entity *parent) +{ + return new MeshComponent(parent); +} + +// AngelScript: Will be used to instanciate objects of this class. +MeshComponent* MeshComponent::refFactory(Entity *parent, const std::string &fileName, + const vector3df &rotation, const vector3df &scale) +{ + return new MeshComponent(parent, fileName, rotation, scale); +} + // Gets a direct pointer to the IMeshSceneNode. IMeshSceneNode* MeshComponent::getMeshSceneNode() { @@ -106,4 +119,30 @@ mMeshSN->setMesh(mesh); } + +// MeshComponent Angelscript binding. +void bindMeshComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind MeshComponent class. + r = engine->RegisterObjectType("MeshComponent", sizeof(MeshComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<MeshComponent>(engine, "MeshComponent"); + + // Set MeshComponent behaviour. + r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_FACTORY, "MeshComponent@ f(Entity @)", + asFUNCTIONPR(MeshComponent::refFactory, (Entity*), MeshComponent*), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("MeshComponent", asBEHAVE_FACTORY, "MeshComponent@ f(Entity @, const string&, " \ + "const vector3df &in, const vector3df &in)", + asFUNCTIONPR(MeshComponent::refFactory, (Entity*, const std::string&, const vector3df&, + const vector3df&), MeshComponent*), asCALL_CDECL); assert(r >= 0); + + // Bind MeshComponent class functions. + r = engine->RegisterObjectMethod("MeshComponent", "void setMesh(const string&)", + asMETHODPR(MeshComponent, setMesh, (const std::string&), void), asCALL_THISCALL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/MeshComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -36,6 +36,11 @@ const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); ~MeshComponent(); + // AngelScript binding + static MeshComponent* refFactory(Entity *parent); + static MeshComponent* refFactory(Entity *parent, const std::string &fileName, + const vector3df &rotation, const vector3df &scale); + // Methods IMeshSceneNode* getMeshSceneNode(); @@ -50,5 +55,9 @@ IMeshSceneNode *mMeshSN; }; + +// MeshComponent Angelscript binding. +extern void bindMeshComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -74,4 +74,31 @@ { } +// AngelScript: Will be used to instanciate objects of this class. +OctTreeComponent* OctTreeComponent::refFactory(Entity *parent, const std::string &fileName, + s32 minPolysPerNode) +{ + return new OctTreeComponent(parent, fileName, minPolysPerNode); +} + + +// OctTreeComponent Angelscript binding. +void bindOctTreeComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SkyDomeComponent class. + r = engine->RegisterObjectType("OctTreeComponent", sizeof(OctTreeComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<OctTreeComponent>(engine, "OctTreeComponent"); + + // Set SkyDomeComponent behaviour. + r = engine->RegisterObjectBehaviour("OctTreeComponent", asBEHAVE_FACTORY, "OctTreeComponent@ f(Entity @, " \ + "const string &, s32)", + asFUNCTIONPR(OctTreeComponent::refFactory, (Entity*, const std::string&, + s32), OctTreeComponent*), asCALL_CDECL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/OctTreeComponent.h =================================================================== --- trunk/src/components/scene/OctTreeComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/OctTreeComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -31,6 +31,14 @@ OctTreeComponent(Entity *parent, IMesh *mesh, s32 minPolysPerNode = 256); OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, s32 minPolysPerNode = 512); ~OctTreeComponent(); + + // AngelScript binding + static OctTreeComponent* refFactory(Entity *parent, const std::string &fileName, + s32 minPolysPerNode); }; + +// OctTreeComponent Angelscript binding. +extern void bindOctTreeComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -45,6 +45,13 @@ mSceneNode = NULL; } +// AngelScript: Will be used to instanciate objects of this class. +ParticleSysComponent* ParticleSysComponent::refFactory(Entity *parent, const vector3df &rotation, + const vector3df &scale) +{ + return new ParticleSysComponent(parent, rotation, scale); +} + // Gets a direct pos32er to the IParticleSystemSceneNode. IParticleSystemSceneNode* ParticleSysComponent::getParticleSystemSceneNode() { @@ -315,4 +322,81 @@ mParticleSystemSN->setParticleSize(size); } + +// ParticleSysComponent Angelscript binding. +void bindParticleSysComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind ParticleSysComponent class. + r = engine->RegisterObjectType("ParticleSysComponent", sizeof(ParticleSysComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<ParticleSysComponent>(engine, "ParticleSysComponent"); + + // Set SkyboxComponent behaviour. + r = engine->RegisterObjectBehaviour("ParticleSysComponent", asBEHAVE_FACTORY, "ParticleSysComponent@ f(Entity @, " \ + "const vector3df &in, const vector3df &in)", + asFUNCTIONPR(ParticleSysComponent::refFactory, (Entity*, const vector3df&, + const vector3df&), ParticleSysComponent*), asCALL_CDECL); assert(r >= 0); + + // Bind ParticleSysComponent class methods. + r = engine->RegisterObjectMethod("ParticleSysComponent", "void addAttractionAffector(const vector3df &in, f32, " \ + "bool, bool, bool, bool)", asMETHOD(ParticleSysComponent, addAttractionAffector), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void addFadeOutParticleAffector(const SColor &in, u32)", + asMETHOD(ParticleSysComponent, addFadeOutParticleAffector), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void addGravityAffector(const vector3df &in, u32)", + asMETHOD(ParticleSysComponent, addGravityAffector), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void addRotationAffector(const vector3df &in, const vector3df &in)", + asMETHOD(ParticleSysComponent, addRotationAffector), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void addScaleParticleAffector(const dimension2df &in)", + asMETHOD(ParticleSysComponent, addScaleParticleAffector), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void removeAffectors()", + asMETHOD(ParticleSysComponent, removeAffectors), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setAnimatedMeshSceneNodeEmitter(const string &, " \ + "bool, const vector3df &in, f32, bool, u32, u32, const SColor &in, " \ + "const SColor &in, u32, u32, s32, const dimension2df &in, const dimension2df &in)", + asMETHODPR(ParticleSysComponent, setAnimatedMeshSceneNodeEmitter, + (const std::string&, bool, const vector3df&, f32, bool, u32, u32, + const SColor&, const SColor&, u32, u32, s32,const dimension2df&, + const dimension2df &), void), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setBoxEmitter(const aabbox3df &in, const vector3df &in, " \ + "u32, u32, const SColor &in, const SColor &in, u32, u32, s32, " \ + "const dimension2df &in, const dimension2df &in)", + asMETHOD(ParticleSysComponent, setBoxEmitter), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setCylinderEmitter(const vector3df &in, f32, " \ + "const vector3df &in, f32, bool, const vector3df &in, u32, u32, " \ + "const SColor &in, const SColor &in, u32, u32, s32, const dimension2df &in, " \ + "const dimension2df &in)", asMETHOD(ParticleSysComponent, setCylinderEmitter), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setMeshEmitter(const string&, bool, " \ + "const vector3df &in, f32, bool, u32, u32, const SColor &in, const SColor &in, " \ + "u32, u32, s32, const dimension2df &in, const dimension2df &in)", + asMETHODPR(ParticleSysComponent, setMeshEmitter, (const std::string&, bool, + const vector3df&, f32, bool, u32, u32, const SColor&, const SColor&, u32, u32, s32, + const dimension2df&, const dimension2df&), void), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setPointEmitter(const vector3df &in, u32, u32, " \ + "const SColor &in, const SColor &in, u32, u32, s32, const dimension2df &in, " \ + "const dimension2df &in)", asMETHOD(ParticleSysComponent, setPointEmitter), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setRingEmitter(const vector3df &in, f32, f32, " \ + "const vector3df &in, u32, u32, const SColor &in, const SColor &in, " \ + "u32, u32, s32, const dimension2df &in, const dimension2df &in)", + asMETHOD(ParticleSysComponent, setRingEmitter), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setSphereEmitter(const vector3df &in, f32, " \ + "const vector3df &in, u32, u32, const SColor &in, const SColor &in, " \ + "u32, u32, s32, const dimension2df &in, const dimension2df &in)", + asMETHOD(ParticleSysComponent, setSphereEmitter), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setParticlesAreGlobal()", + asMETHOD(ParticleSysComponent, setParticlesAreGlobal), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setParticlesAreGlobal(bool)", + asMETHOD(ParticleSysComponent, setParticlesAreGlobal), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleSysComponent", "void setParticleSize(const dimension2df &in)", + asMETHOD(ParticleSysComponent, setParticleSize), asCALL_THISCALL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -31,6 +31,10 @@ const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); ~ParticleSysComponent(); + // AngelScript binding + static ParticleSysComponent* refFactory(Entity *parent, const vector3df &rotation, + const vector3df &scale); + // Methods IParticleSystemSceneNode* getParticleSystemSceneNode(); @@ -156,4 +160,8 @@ IParticleSystemSceneNode *mParticleSystemSN; }; + +// ParticleSysComponent Angelscript binding. +extern void bindParticleSysComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -305,20 +305,16 @@ // Forward declarations. int r; - // Bind SceneListenerComponent class. + // Bind SceneComponent class. r = engine->RegisterObjectType("SceneComponent", sizeof(SceneComponent), asOBJ_REF); assert(r >= 0); // Bind base functions. bindSceneComponentBase<SceneComponent>(engine, "SceneComponent"); - // Set SoundListenerComponent behaviour. - r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "SceneComponent@ f(EntityComponent @)", - asFUNCTION((asRefCast<EntityComponent,SceneComponent>)), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f(SceneComponent @)", - asFUNCTION((asRefCast<SceneComponent,EntityComponent>)), asCALL_CDECL); assert( r >= 0 ); - + // Set SceneComponent behaviour. r = engine->RegisterObjectBehaviour("SceneComponent", asBEHAVE_FACTORY, "SceneComponent@ f(Entity @)", - asFUNCTION(SceneComponent::refFactory), asCALL_CDECL); assert(r >= 0); + asFUNCTIONPR(SceneComponent::refFactory, (Entity*), SceneComponent*), + asCALL_CDECL); assert(r >= 0); } // End of File Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/SceneComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -103,19 +103,26 @@ { // Forward declaration. int r; + std::string sType = type; // Bind inherited functions. 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 ); + // Bind common class functions. r = engine->RegisterObjectMethod(type, "void addCollisionResponseAnimator(const vector3df &in, " \ - "const vector3df &in, const vector3df &in, float)", + "const vector3df &in, const vector3df &in, f32)", asMETHOD(T, addCollisionResponseAnimator), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod(type, "void addFlyCircleAnimator(const vector3df &in, float, " \ - "float, const vector3df &in)", + r = engine->RegisterObjectMethod(type, "void addFlyCircleAnimator(const vector3df &in, f32, " \ + "f32, const vector3df &in)", asMETHOD(T, addFlyCircleAnimator), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "void addFlyStraightAnimator(const vector3df &in, " \ - "const vector3df &in, uint, bool)", + "const vector3df &in, u32, bool)", asMETHOD(T, addFlyStraightAnimator), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "void addToMetaSelector(Entity@)", @@ -128,8 +135,8 @@ r = engine->RegisterObjectMethod(type, "E_CULLING_TYPE getAutomaticCulling()", asMETHOD(T, getAutomaticCulling), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "const aabbox3df& getBoundingBox()", - asMETHOD(T, getBoundingBox), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod(type, "uint getMaterialCount()", + asMETHODPR(T, getBoundingBox, (void), const aabbox3df&), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "u32 getMaterialCount()", asMETHOD(T, getMaterialCount), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "const matrix4& getRelativeTransformation()", asMETHOD(T, getRelativeTransformation), asCALL_THISCALL); assert(r >= 0); @@ -147,11 +154,11 @@ asMETHOD(T, setAbsolutePosition), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "void setAutomaticCulling(E_CULLING_TYPE)", asMETHOD(T, setAutomaticCulling), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod(type, "void setDebugDataVisible(int state)", + r = engine->RegisterObjectMethod(type, "void setDebugDataVisible(s32 state)", asMETHOD(T, setDebugDataVisible), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "void setMaterialFlag(E_MATERIAL_FLAG, bool)", asMETHOD(T, setMaterialFlag), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod(type, "void setMaterialTexture(uint, const string &)", + r = engine->RegisterObjectMethod(type, "void setMaterialTexture(u32, const string &)", asMETHODPR(T, setMaterialTexture, (u32 layer, const std::string &fileName), void), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "void setMaterialType(E_MATERIAL_TYPE)", Modified: trunk/src/components/scene/SkyBoxComponent.cpp =================================================================== --- trunk/src/components/scene/SkyBoxComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/SkyBoxComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -66,4 +66,34 @@ { } +// AngelScript: Will be used to instanciate objects of this class. +SkyBoxComponent* SkyBoxComponent::refFactory(Entity *parent, const std::string &top, + const std::string &bottom, const std::string &left, + const std::string &right, const std::string &front, + const std::string &back) +{ + return new SkyBoxComponent(parent, top, bottom, left, right, front, back); +} + + +// SkyBoxComponent Angelscript binding. +void bindSkyBoxComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SkyBoxComponent class. + r = engine->RegisterObjectType("SkyBoxComponent", sizeof(SkyBoxComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<SkyBoxComponent>(engine, "SkyBoxComponent"); + + // Set SkyboxComponent behaviour. + r = engine->RegisterObjectBehaviour("SkyBoxComponent", asBEHAVE_FACTORY, "SkyBoxComponent@ f(Entity @, " \ + "const string &, const string &, const string &, const string &, " \ + "const string &, const string &)", + asFUNCTIONPR(SkyBoxComponent::refFactory, (Entity*, const std::string&, + const std::string&, const std::string&, const std::string&, const std::string&, + const std::string&), SkyBoxComponent*), asCALL_CDECL); assert(r >= 0); +} // End of File Modified: trunk/src/components/scene/SkyBoxComponent.h =================================================================== --- trunk/src/components/scene/SkyBoxComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/SkyBoxComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -33,6 +33,16 @@ const std::string &left, const std::string &right, const std::string &front, const std::string &back); ~SkyBoxComponent(); + + // AngelScript binding + static SkyBoxComponent* refFactory(Entity *parent, const std::string &top, + const std::string &bottom, const std::string &left, + const std::string &right, const std::string &front, + const std::string &back); }; + +// SkyBoxComponent Angelscript binding. +extern void bindSkyBoxComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/SkyDomeComponent.cpp =================================================================== --- trunk/src/components/scene/SkyDomeComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/SkyDomeComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -60,4 +60,32 @@ { } +// AngelScript: Will be used to instanciate objects of this class. +SkyDomeComponent* SkyDomeComponent::refFactory(Entity *parent, const std::string &fileName, + u32 hRes, u32 vRes, f32 texturePerc, f32 spherePerc, + f32 radius) +{ + return new SkyDomeComponent(parent, fileName, hRes, vRes, texturePerc, spherePerc, radius); +} + + +// SkyDomeComponent Angelscript binding. +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 @, " \ + "const string &, u32, u32, f32, f32, f32)", + asFUNCTIONPR(SkyDomeComponent::refFactory, (Entity*, const std::string&, + u32, u32, f32, f32, f32), SkyDomeComponent*), asCALL_CDECL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/SkyDomeComponent.h =================================================================== --- trunk/src/components/scene/SkyDomeComponent.h 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/SkyDomeComponent.h 2009-05-27 20:03:34 UTC (rev 42) @@ -13,8 +13,8 @@ // // ///////////////////////////////////////////////////////////////////////////// -#ifndef __SKYBOXCOMPONENT_H__ -#define __SKYBOXCOMPONENT_H__ +#ifndef __SKYDOMECOMPONENT_H__ +#define __SKYDOMECOMPONENT_H__ // Include files #include "../../dependencies.h" @@ -32,6 +32,14 @@ SkyDomeComponent(Entity *parent, ITexture *texture, u32 hRes = 16, u32 vRes = 8, f32 texturePerc = 0.9f, f32 spherePerc = 2.0f, f32 radius = 1000.0f); ~SkyDomeComponent(); + + // AngelScript binding + static SkyDomeComponent* refFactory(Entity *parent, const std::string &fileName, u32 hRes, + u32 vRes, f32 texturePerc, f32 spherePerc, f32 radius); }; + +// SkyDomeComponent Angelscript binding. +extern void bindSkyDomeComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-05-27 20:03:34 UTC (rev 42) @@ -65,18 +65,27 @@ mSceneNode = NULL; } +// AngelScript: Will be used to instanciate objects of this class. +TerrainComponent* TerrainComponent::refFactory(Entity *parent) +{ + return new TerrainComponent(parent); +} + +// AngelScript: Will be used to instanciate objects of this class. +TerrainComponent* TerrainComponent::refFactory(Entity *parent, const std::string &fileName, + const vector3df &rotation, const vector3df &scale, + const SColor &vertexColor, s32 maxLOD, + s32 smoothFactor) +{ + return new TerrainComponent(parent, fileName, rotation, scale, vertexColor, maxLOD, smoothFactor); +} + // Gets a direct pointer to the ITerrainSceneNode. ITerrainSceneNode* TerrainComponent::getTerrainSceneNode() { return mTerrainSN; } -// Gets the bounding box of the terrain. -const aabbox3df& TerrainComponent::getBoundingBox() const -{ - return mTerrainSN->getBoundingBox(); -} - // Gets the bounding box of a patch. const aabbox3df& TerrainComponent::getBoundingBox(s32 patchX, s32 patchZ) const { @@ -84,7 +93,7 @@ } // Gets the height of a point of the terrain. -float TerrainComponent::getHeight(f32 x, f32 y) +f32 TerrainComponent::getHeight(f32 x, f32 y) { return mTerrainSN->getHeight(x, y); } @@ -120,4 +129,41 @@ mTerrainSN->scaleTexture(scale, scale2); } + +// TerrainComponent Angelscript binding. +void bindTerrainComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind TerrainComponent class. + r = engine->RegisterObjectType("TerrainComponent", sizeof(TerrainComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindSceneComponentBase<TerrainComponent>(engine, "TerrainComponent"); + + // Set TerrainComponent behaviour. + r = engine->RegisterObjectBehaviour("TerrainComponent", asBEHAVE_FACTORY, "TerrainComponent@ f(Entity @)", + asFUNCTIONPR(TerrainComponent::refFactory, (Entity*), TerrainComponent*), + asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("TerrainComponent", asBEHAVE_FACTORY, "TerrainComponent@ f(Entity @, " \ + "const string &, const vector3df &in, const vector3df &in," \ + "const SColor &in, s32, s32)", asFUNCTIONPR(TerrainComponent::refFactory, + (Entity*, const std::string &, const vector3df &, const vector3df &, + const SColor &, s32, s32), TerrainComponent*), asCALL_CDECL); assert(r >= 0); + + // Bind TerrainComponent class functions. + r = engine->RegisterObjectMethod("TerrainComponent", "const aabbox3df& getBoundingBox(s32, s32)", + asMETHODPR(TerrainComponent, getBoundingBox, (s32, s32), const aabbox3df&), + asCALL_THISCALL);... [truncated message content] |
From: <zcc...@us...> - 2009-05-27 14:22:38
|
Revision: 41 http://sirrf.svn.sourceforge.net/sirrf/?rev=41&view=rev Author: zccdark203 Date: 2009-05-27 13:42:37 +0000 (Wed, 27 May 2009) Log Message: ----------- The first update of today is a small one: it only adds the full AngelScript binding of the SceneComponent class. Modified Paths: -------------- trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/scripting/bindIrrlicht.cpp trunk/src/sirrf.depend Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-25 20:33:10 UTC (rev 40) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-27 13:42:37 UTC (rev 41) @@ -67,6 +67,13 @@ if(mMetaSelector != NULL) mMetaSelector->drop(); } +// AngelScript: Will be used to instanciate objects of this class. +SceneComponent* SceneComponent::refFactory(Entity* parent) +{ + return new SceneComponent(parent); +} + + // Gets a direct pointer to the ISceneNode. ISceneNode* SceneComponent::getSceneNode() { @@ -301,9 +308,6 @@ // Bind SceneListenerComponent class. r = engine->RegisterObjectType("SceneComponent", sizeof(SceneComponent), asOBJ_REF); assert(r >= 0); - // Bind inherited functions. - bindEntityComponentBase<SceneComponent>(engine, "SceneComponent"); - // Bind base functions. bindSceneComponentBase<SceneComponent>(engine, "SceneComponent"); @@ -313,8 +317,8 @@ r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f(SceneComponent @)", asFUNCTION((asRefCast<SceneComponent,EntityComponent>)), asCALL_CDECL); assert( r >= 0 ); - //r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @)", - // asFUNCTION(SoundListenerComponent::refFactory), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("SceneComponent", asBEHAVE_FACTORY, "SceneComponent@ f(Entity @)", + asFUNCTION(SceneComponent::refFactory), asCALL_CDECL); assert(r >= 0); } // End of File Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-25 20:33:10 UTC (rev 40) +++ trunk/src/components/scene/SceneComponent.h 2009-05-27 13:42:37 UTC (rev 41) @@ -30,6 +30,9 @@ SceneComponent(Entity *parent); ~SceneComponent(); + // AngelScript binding + static SceneComponent* refFactory(Entity *parent); + // Methods ISceneNode* getSceneNode(); IMetaTriangleSelector* getMetaSelector() const; @@ -101,6 +104,9 @@ // Forward declaration. int r; + // Bind inherited functions. + bindEntityComponentBase<SceneComponent>(engine, type); + // Bind common class functions. r = engine->RegisterObjectMethod(type, "void addCollisionResponseAnimator(const vector3df &in, " \ "const vector3df &in, const vector3df &in, float)", @@ -121,12 +127,12 @@ asMETHOD(T, getAbsolutePosition), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "E_CULLING_TYPE getAutomaticCulling()", asMETHOD(T, getAutomaticCulling), asCALL_THISCALL); assert(r >= 0); - //r = engine->RegisterObjectMethod(type, "const aabbox3df& getBoundingBox()", - // asMETHOD(T, getBoundingBox), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "const aabbox3df& getBoundingBox()", + asMETHOD(T, getBoundingBox), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "uint getMaterialCount()", asMETHOD(T, getMaterialCount), asCALL_THISCALL); assert(r >= 0); - //r = engine->RegisterObjectMethod(type, "matrix4 getRelativeTransformation()", - // asMETHOD(T, getRelativeTransformation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "const matrix4& getRelativeTransformation()", + asMETHOD(T, getRelativeTransformation), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "const vector3df& getPosition()", asMETHOD(T, getPosition), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod(type, "const vector3df& getRotation()", Modified: trunk/src/scripting/bindIrrlicht.cpp =================================================================== --- trunk/src/scripting/bindIrrlicht.cpp 2009-05-25 20:33:10 UTC (rev 40) +++ trunk/src/scripting/bindIrrlicht.cpp 2009-05-27 13:42:37 UTC (rev 41) @@ -17,6 +17,40 @@ #include "bindIrrlicht.h" +// aabbox3d<T> binding. +template<typename T> +void bindaabbox3d(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind aabbox3d<T> class. + r = engine->RegisterObjectType(typeName, sizeof(aabbox3d<T>), asOBJ_REF); assert(r >= 0); + + // Set aabbox3d<T> behaviour. + + + // Bind aabbox3d<T> class functions. + +} + +// CMatrix4<T> binding. +template<typename T> +void bindMatrix4(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind CMatrix4<T> class. + r = engine->RegisterObjectType(typeName, sizeof(CMatrix4<T>), asOBJ_REF); assert(r >= 0); + + // Set CMatrix4<T> behaviour. + + + // Bind CMatrix4<T> class functions. + +} + // Vector3df<T> binding. template<typename T> void bindVector3d(asIScriptEngine *engine, const char *typeName, const char *asType) @@ -119,6 +153,11 @@ void bindIrrlicht(asIScriptEngine *engine) { // Vector3d<T> + bindaabbox3d<f32>(engine, "aabbox3df", "float"); + bindaabbox3d<s32>(engine, "aabbox3di", "int"); + + bindMatrix4<f32>(engine, "matrix4", "float"); + bindVector3d<f32>(engine, "vector3df", "float"); bindVector3d<s32>(engine, "vector3di", "int"); Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-25 20:33:10 UTC (rev 40) +++ trunk/src/sirrf.depend 2009-05-27 13:42:37 UTC (rev 41) @@ -1124,11 +1124,11 @@ "scriptstring.h" <string.h> -1243280771 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp +1243431307 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" "../../core/GameManager.h" -1243283285 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h +1243431581 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -2366,6 +2366,6 @@ 1243269810 /home/michael/Programming/Projects/sirrf/src/scripting/bindIrrlicht.h "../dependencies.h" -1243270286 source:/home/michael/Programming/Projects/sirrf/src/scripting/bindIrrlicht.cpp +1243431366 source:/home/michael/Programming/Projects/sirrf/src/scripting/bindIrrlicht.cpp "bindIrrlicht.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-25 20:33:26
|
Revision: 40 http://sirrf.svn.sourceforge.net/sirrf/?rev=40&view=rev Author: zccdark203 Date: 2009-05-25 20:33:10 +0000 (Mon, 25 May 2009) Log Message: ----------- Just added the binding for the SceneComponent class. It's still incomplete, though, as some functions require Irrlicht core variables (which will have to be bound first). Furthermore I've removed code which was actually unneeded. Modified Paths: -------------- trunk/src/components/components.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/EntityComponent.cpp trunk/src/core/EntityComponent.h trunk/src/scripting/bindIrrlicht.cpp trunk/src/sirrf.depend trunk/src/sirrf.layout Modified: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/components/components.cpp 2009-05-25 20:33:10 UTC (rev 40) @@ -21,6 +21,7 @@ void bindComponents(asIScriptEngine *engine) { // Scene + bindSceneComponent(engine); // Sound bindSoundListenerComponent(engine); Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-25 20:33:10 UTC (rev 40) @@ -173,7 +173,7 @@ } // Gets the automatic culling state. -bool SceneComponent::getAutomaticCulling() const +E_CULLING_TYPE SceneComponent::getAutomaticCulling() const { return mSceneNode->getAutomaticCulling(); } @@ -214,12 +214,6 @@ return mSceneNode->getScale(); } -// Returns type of the component. -ESCENE_NODE_TYPE SceneComponent::getType() const -{ - return mSceneNode->getType(); -} - // Removes all animators from this component. void SceneComponent::removeAnimators() { @@ -297,4 +291,30 @@ mSceneNode->setPosition(mSceneNode->getPosition() + vec); } + +// SceneComponent Angelscript binding. +void bindSceneComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SceneListenerComponent class. + r = engine->RegisterObjectType("SceneComponent", sizeof(SceneComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindEntityComponentBase<SceneComponent>(engine, "SceneComponent"); + + // Bind base functions. + bindSceneComponentBase<SceneComponent>(engine, "SceneComponent"); + + // Set SoundListenerComponent behaviour. + r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "SceneComponent@ f(EntityComponent @)", + asFUNCTION((asRefCast<EntityComponent,SceneComponent>)), asCALL_CDECL); assert( r >= 0 ); + r = engine->RegisterGlobalBehaviour(asBEHAVE_IMPLICIT_REF_CAST, "EntityComponent@ f(SceneComponent @)", + asFUNCTION((asRefCast<SceneComponent,EntityComponent>)), asCALL_CDECL); assert( r >= 0 ); + + //r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @)", + // asFUNCTION(SoundListenerComponent::refFactory), asCALL_CDECL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/components/scene/SceneComponent.h 2009-05-25 20:33:10 UTC (rev 40) @@ -53,14 +53,13 @@ void addToMetaSelector(ITriangleSelector *selector); vector3df getAbsolutePosition() const; - bool getAutomaticCulling() const; + E_CULLING_TYPE getAutomaticCulling() const; const aabbox3df& getBoundingBox() const; u32 getMaterialCount() const; matrix4 getRelativeTransformation() const; const vector3df getPosition() const; const vector3df& getRotation() const; const vector3df& getScale() const; - ESCENE_NODE_TYPE getType() const; void removeAnimators(); @@ -91,4 +90,72 @@ private: }; + +// SceneComponent Angelscript binding. +extern void bindSceneComponent(asIScriptEngine *engine); + + +template<typename T> +void bindSceneComponentBase(asIScriptEngine *engine, const char *type) +{ + // Forward declaration. + int r; + + // Bind common class functions. + r = engine->RegisterObjectMethod(type, "void addCollisionResponseAnimator(const vector3df &in, " \ + "const vector3df &in, const vector3df &in, float)", + asMETHOD(T, addCollisionResponseAnimator), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void addFlyCircleAnimator(const vector3df &in, float, " \ + "float, const vector3df &in)", + asMETHOD(T, addFlyCircleAnimator), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void addFlyStraightAnimator(const vector3df &in, " \ + "const vector3df &in, uint, bool)", + asMETHOD(T, addFlyStraightAnimator), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "void addToMetaSelector(Entity@)", + asMETHODPR(T, addToMetaSelector, (Entity*), void), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void addToMetaSelector(SceneComponent@)", + asMETHODPR(T, addToMetaSelector, (SceneComponent*), void), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "const vector3df& getAbsolutePosition()", + asMETHOD(T, getAbsolutePosition), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "E_CULLING_TYPE getAutomaticCulling()", + asMETHOD(T, getAutomaticCulling), asCALL_THISCALL); assert(r >= 0); + //r = engine->RegisterObjectMethod(type, "const aabbox3df& getBoundingBox()", + // asMETHOD(T, getBoundingBox), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "uint getMaterialCount()", + asMETHOD(T, getMaterialCount), asCALL_THISCALL); assert(r >= 0); + //r = engine->RegisterObjectMethod(type, "matrix4 getRelativeTransformation()", + // asMETHOD(T, getRelativeTransformation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "const vector3df& getPosition()", + asMETHOD(T, getPosition), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "const vector3df& getRotation()", + asMETHOD(T, getRotation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "const vector3df& getScale()", + asMETHOD(T, getScale), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "void removeAnimators()", + asMETHOD(T, removeAnimators), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "void setAbsolutePosition(const vector3df &in)", + asMETHOD(T, setAbsolutePosition), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setAutomaticCulling(E_CULLING_TYPE)", + asMETHOD(T, setAutomaticCulling), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setDebugDataVisible(int state)", + asMETHOD(T, setDebugDataVisible), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setMaterialFlag(E_MATERIAL_FLAG, bool)", + asMETHOD(T, setMaterialFlag), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setMaterialTexture(uint, const string &)", + asMETHODPR(T, setMaterialTexture, (u32 layer, const std::string &fileName), void), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setMaterialType(E_MATERIAL_TYPE)", + asMETHOD(T, setMaterialType), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setPosition(const vector3df &in)", + asMETHOD(T, setPosition), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setRotation(const vector3df &in)", + asMETHOD(T, setRotation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "void setScale(const vector3df &in)", + asMETHOD(T, setScale), asCALL_THISCALL); assert(r >= 0); +} + #endif Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-05-25 20:33:10 UTC (rev 40) @@ -119,7 +119,7 @@ r = engine->RegisterObjectType("SoundListenerComponent", sizeof(SoundListenerComponent), asOBJ_REF); assert(r >= 0); // Bind inherited functions. - bindEntityComponentChild<SoundListenerComponent>(engine, "SoundListenerComponent"); + bindEntityComponentBase<SoundListenerComponent>(engine, "SoundListenerComponent"); // Set SoundListenerComponent behaviour. r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "SoundListenerComponent@ f(EntityComponent @)", Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-25 20:33:10 UTC (rev 40) @@ -378,7 +378,7 @@ r = engine->RegisterObjectType("SoundSourceComponent", sizeof(SoundSourceComponent), asOBJ_REF); assert(r >= 0); // Bind inherited functions. - bindEntityComponentChild<SoundSourceComponent>(engine, "SoundSourceComponent"); + bindEntityComponentBase<SoundSourceComponent>(engine, "SoundSourceComponent"); // Set SoundSourceComponent behaviour. r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "SoundSourceComponent@ f(EntityComponent @)", Modified: trunk/src/core/EntityComponent.cpp =================================================================== --- trunk/src/core/EntityComponent.cpp 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/core/EntityComponent.cpp 2009-05-25 20:33:10 UTC (rev 40) @@ -107,25 +107,12 @@ r = engine->RegisterObjectType("EntityComponent", sizeof(EntityComponent), asOBJ_REF); r = engine->RegisterObjectType("Entity", sizeof(Entity), asOBJ_REF); + // Get EntityComponent base functions. + bindEntityComponentBase<EntityComponent>(engine, "EntityComponent"); + // Set EntityComponent behaviour. r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_FACTORY, "EntityComponent@ f(Entity @)", asFUNCTION(EntityComponent::refFactory), asCALL_CDECL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_ADDREF, "void f()", - asMETHOD(EntityComponent, refAdd), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_RELEASE, "void f()", - asMETHOD(EntityComponent, refRelease), asCALL_THISCALL); assert(r >= 0); - - // Bind EntityComponent class functions. - r = engine->RegisterObjectMethod("EntityComponent", "uint getID()", - asMETHOD(EntityComponent, getID), asCALL_THISCALL); assert(r >= 0); - - r = engine->RegisterObjectMethod("EntityComponent", "void setName(const string &)", - asMETHOD(EntityComponent, setName), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityComponent", "const string& getName()", - asMETHOD(EntityComponent, getName), asCALL_THISCALL); assert(r >= 0); - - r = engine->RegisterObjectMethod("EntityComponent", "Entity@ getParent()", - asMETHOD(EntityComponent, getParent), asCALL_THISCALL); assert(r >= 0); } // End of File Modified: trunk/src/core/EntityComponent.h =================================================================== --- trunk/src/core/EntityComponent.h 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/core/EntityComponent.h 2009-05-25 20:33:10 UTC (rev 40) @@ -68,7 +68,7 @@ extern void bindEntityComponent(asIScriptEngine *engine); template<typename T> -void bindEntityComponentChild(asIScriptEngine *engine, const char *type) +void bindEntityComponentBase(asIScriptEngine *engine, const char *type) { // Forward declaration. int r; Modified: trunk/src/scripting/bindIrrlicht.cpp =================================================================== --- trunk/src/scripting/bindIrrlicht.cpp 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/scripting/bindIrrlicht.cpp 2009-05-25 20:33:10 UTC (rev 40) @@ -35,12 +35,97 @@ } +// Enumerations +// E_CULLING_TYPE +void bindE_CULLING_TYPE(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind E_CULLING_TYPE enumeration. + r = engine->RegisterEnum("E_CULLING_TYPE"); assert(r >= 0); + + // Bind E_CULLING_TYPE enumeration values. + r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_OFF", EAC_OFF); assert(r >= 0); + r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_BOX", EAC_BOX); assert(r >= 0); + r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_FRUSTUM_BOX", EAC_FRUSTUM_BOX); assert(r >= 0); + r = engine->RegisterEnumValue("E_CULLING_TYPE", "EAC_FRUSTUM_SPHERE", EAC_FRUSTUM_SPHERE); assert(r >= 0); +} + +// E_MATERIAL_FLAG +void bindE_MATERIAL_FLAG(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind E_MATERIAL_FLAG enumeration. + r = engine->RegisterEnum("E_MATERIAL_FLAG"); assert(r >= 0); + + // Bind E_CULLING_TYPE enumeration values. + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_WIREFRAME", EMF_WIREFRAME); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_POINTCLOUD", EMF_POINTCLOUD); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_GOURAUD_SHADING", EMF_GOURAUD_SHADING); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_LIGHTING", EMF_LIGHTING); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_ZBUFFER", EMF_ZBUFFER); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_ZWRITE_ENABLE", EMF_ZWRITE_ENABLE); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_BACK_FACE_CULLING", EMF_BACK_FACE_CULLING); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_FRONT_FACE_CULLING", EMF_FRONT_FACE_CULLING); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_BILINEAR_FILTER", EMF_BILINEAR_FILTER); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_TRILINEAR_FILTER", EMF_TRILINEAR_FILTER); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_ANISOTROPIC_FILTER", EMF_ANISOTROPIC_FILTER); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_FOG_ENABLE", EMF_FOG_ENABLE); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_NORMALIZE_NORMALS", EMF_NORMALIZE_NORMALS); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_FLAG", "EMF_TEXTURE_WRAP", EMF_TEXTURE_WRAP); +} + +// E_MATERIAL_TYPE +void bindE_MATERIAL_TYPE(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind E_MATERIAL_FLAG enumeration. + r = engine->RegisterEnum("E_MATERIAL_TYPE"); assert(r >= 0); + + // Bind E_CULLING_TYPE enumeration values. + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_SOLID", EMT_SOLID); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_SOLID_2_LAYER", EMT_SOLID_2_LAYER); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP", EMT_LIGHTMAP); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_ADD", EMT_LIGHTMAP_ADD); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_M2", EMT_LIGHTMAP_M2); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_M4", EMT_LIGHTMAP_M4); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_LIGHTING", EMT_LIGHTMAP_LIGHTING); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_LIGHTING_M2", EMT_LIGHTMAP_LIGHTING_M2); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_LIGHTMAP_LIGHTING_M4", EMT_LIGHTMAP_LIGHTING_M4); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_DETAIL_MAP", EMT_DETAIL_MAP); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_SPHERE_MAP", EMT_SPHERE_MAP); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_REFLECTION_2_LAYER", EMT_REFLECTION_2_LAYER); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_ADD_COLOR", EMT_TRANSPARENT_ADD_COLOR); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_ALPHA_CHANNEL", EMT_TRANSPARENT_ALPHA_CHANNEL); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_ALPHA_CHANNEL_REF", EMT_TRANSPARENT_ALPHA_CHANNEL_REF); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_VERTEX_ALPHA", EMT_TRANSPARENT_VERTEX_ALPHA); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_TRANSPARENT_REFLECTION_2_LAYER", EMT_TRANSPARENT_REFLECTION_2_LAYER); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_NORMAL_MAP_SOLID", EMT_NORMAL_MAP_SOLID); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR", EMT_NORMAL_MAP_TRANSPARENT_ADD_COLOR); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA", EMT_NORMAL_MAP_TRANSPARENT_VERTEX_ALPHA); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_PARALLAX_MAP_SOLID", EMT_PARALLAX_MAP_SOLID); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR", EMT_PARALLAX_MAP_TRANSPARENT_ADD_COLOR); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA", EMT_PARALLAX_MAP_TRANSPARENT_VERTEX_ALPHA); assert(r >= 0); + r = engine->RegisterEnumValue("E_MATERIAL_TYPE", "EMT_ONETEXTURE_BLEND", EMT_ONETEXTURE_BLEND); assert(r >= 0); +} + + // Irrlicht AngelScript binding void bindIrrlicht(asIScriptEngine *engine) { // Vector3d<T> bindVector3d<f32>(engine, "vector3df", "float"); bindVector3d<s32>(engine, "vector3di", "int"); + + // Enumerations + bindE_CULLING_TYPE(engine); + bindE_MATERIAL_FLAG(engine); + bindE_MATERIAL_TYPE(engine); } // End of File Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/sirrf.depend 2009-05-25 20:33:10 UTC (rev 40) @@ -1027,11 +1027,11 @@ "../dependencies.h" "EntityComponent.h" -1243271750 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h +1243278085 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h "../dependencies.h" "Entity.h" -1243271684 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp +1243278246 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" 1243271819 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp @@ -1124,11 +1124,11 @@ "scriptstring.h" <string.h> -1242569214 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp +1243280771 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" "../../core/GameManager.h" -1242569214 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h +1243283285 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -1388,7 +1388,7 @@ <SFML/System/Thread.hpp> <vector> -1243272710 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp +1243278117 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp "SoundListenerComponent.h" "../../core/GameManager.h" @@ -2322,7 +2322,7 @@ "matrix4.h" "IVideoDriver.h" -1243272756 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp +1243278126 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp "SoundSourceComponent.h" "../../core/GameManager.h" @@ -2352,7 +2352,7 @@ "sound/SoundListenerComponent.h" "sound/SoundSourceComponent.h" -1243270609 source:/home/michael/Programming/Projects/sirrf/src/components/components.cpp +1243277891 source:/home/michael/Programming/Projects/sirrf/src/components/components.cpp "components.h" 1242996572 source:/home/michael/Programming/Projects/sirrf/src/scripting/Script.cpp Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-25 17:43:27 UTC (rev 39) +++ trunk/src/sirrf.layout 2009-05-25 20:33:10 UTC (rev 40) @@ -2,7 +2,7 @@ <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> <File name="components/components.cpp" open="0" top="0" tabpos="0"> - <Cursor position="662" topLine="0" /> + <Cursor position="46" topLine="0" /> </File> <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="5"> <Cursor position="6902" topLine="51" /> @@ -47,10 +47,10 @@ <Cursor position="5205" topLine="0" /> </File> <File name="components/scene/SceneComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="4873" topLine="115" /> + <Cursor position="7833" topLine="220" /> </File> - <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="2553" topLine="25" /> + <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="3"> + <Cursor position="6181" topLine="108" /> </File> <File name="components/scene/SkyBoxComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="196" topLine="0" /> @@ -77,64 +77,64 @@ <Cursor position="0" topLine="11" /> </File> <File name="components/sound/SoundListenerComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1749" topLine="20" /> + <Cursor position="3595" topLine="106" /> </File> <File name="components/sound/SoundListenerComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1035" topLine="12" /> + <Cursor position="1568" topLine="19" /> </File> <File name="components/sound/SoundSourceComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3866" topLine="168" /> + <Cursor position="8901" topLine="393" /> </File> <File name="components/sound/SoundSourceComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1118" topLine="16" /> + <Cursor position="1149" topLine="23" /> </File> - <File name="core/DataStack.cpp" open="1" top="1" tabpos="1"> - <Cursor position="5760" topLine="225" /> + <File name="core/DataStack.cpp" open="0" top="0" tabpos="1"> + <Cursor position="7075" topLine="225" /> </File> <File name="core/DataStack.h" open="0" top="0" tabpos="1"> - <Cursor position="1097" topLine="14" /> + <Cursor position="2798" topLine="80" /> </File> <File name="core/DataStore.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1907" topLine="54" /> + <Cursor position="6954" topLine="198" /> </File> <File name="core/DataStore.h" open="0" top="0" tabpos="0"> - <Cursor position="990" topLine="18" /> + <Cursor position="1436" topLine="22" /> </File> <File name="core/Entity.cpp" open="0" top="0" tabpos="3"> - <Cursor position="1479" topLine="0" /> + <Cursor position="9870" topLine="400" /> </File> <File name="core/Entity.h" open="0" top="0" tabpos="4"> - <Cursor position="950" topLine="13" /> + <Cursor position="2227" topLine="52" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2460" topLine="0" /> + <Cursor position="2465" topLine="75" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1560" topLine="23" /> + <Cursor position="1562" topLine="51" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1112" topLine="18" /> + <Cursor position="7240" topLine="192" /> </File> <File name="core/EntityManager.h" open="0" top="0" tabpos="0"> - <Cursor position="974" topLine="20" /> + <Cursor position="974" topLine="24" /> </File> <File name="core/EventManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="6002" topLine="0" /> + <Cursor position="4859" topLine="180" /> </File> <File name="core/EventManager.h" open="0" top="0" tabpos="0"> - <Cursor position="1006" topLine="3" /> + <Cursor position="3193" topLine="72" /> </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="2037" topLine="43" /> + <Cursor position="8260" topLine="246" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> - <Cursor position="1072" topLine="27" /> + <Cursor position="2368" topLine="59" /> </File> <File name="core/GameState.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1619" topLine="38" /> + <Cursor position="1619" topLine="42" /> </File> <File name="core/GameState.h" open="0" top="0" tabpos="0"> - <Cursor position="1017" topLine="4" /> + <Cursor position="1063" topLine="4" /> </File> <File name="dependencies.h" open="0" top="0" tabpos="0"> <Cursor position="0" topLine="15" /> @@ -149,15 +149,21 @@ <Cursor position="1075" topLine="15" /> </File> <File name="scripting/ScriptManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="5334" topLine="196" /> + <Cursor position="757" topLine="0" /> </File> <File name="scripting/ScriptManager.h" open="0" top="0" tabpos="1"> - <Cursor position="1616" topLine="23" /> + <Cursor position="2104" topLine="42" /> </File> + <File name="scripting/bindIrrlicht.cpp" open="0" top="0" tabpos="1"> + <Cursor position="7063" topLine="42" /> + </File> + <File name="scripting/bindIrrlicht.h" open="0" top="0" tabpos="2"> + <Cursor position="763" topLine="0" /> + </File> <File name="sound/SoundManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="4563" topLine="0" /> + <Cursor position="5773" topLine="144" /> </File> <File name="sound/SoundManager.h" open="0" top="0" tabpos="2"> - <Cursor position="949" topLine="12" /> + <Cursor position="1315" topLine="15" /> </File> </CodeBlocks_layout_file> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-25 17:43:37
|
Revision: 39 http://sirrf.svn.sourceforge.net/sirrf/?rev=39&view=rev Author: zccdark203 Date: 2009-05-25 17:43:27 +0000 (Mon, 25 May 2009) Log Message: ----------- The sound components have been succesfully exposed to AngelScript. Besides that I've also started with exposing some Irrlicht structures to AngelScript, but that's a WIP (so don't rely on it). Furthermore I've cleaned up all the binding code for AngelScript. Modified Paths: -------------- trunk/src/components/components.cpp trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundListenerComponent.h trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h trunk/src/core/DataStack.cpp trunk/src/core/DataStack.h trunk/src/core/DataStore.cpp trunk/src/core/DataStore.h trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityComponent.cpp trunk/src/core/EntityComponent.h trunk/src/core/EntityManager.cpp trunk/src/core/EventManager.cpp trunk/src/core/EventManager.h trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/core/GameState.h trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/ScriptManager.h trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Added Paths: ----------- trunk/src/scripting/bindIrrlicht.cpp trunk/src/scripting/bindIrrlicht.h Modified: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/components/components.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -20,6 +20,11 @@ // AngelScript binding void bindComponents(asIScriptEngine *engine) { + // Scene + + // Sound + bindSoundListenerComponent(engine); + bindSoundSourceComponent(engine); } // End of File Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -52,6 +52,12 @@ setIsMainListener(false); } +// AngelScript: Will be used to instanciate objects of this class. +SoundListenerComponent* SoundListenerComponent::refFactory(Entity *parent, bool isMainListener) +{ + return new SoundListenerComponent(parent, isMainListener); +} + // Checks if this listener is the main listener. bool SoundListenerComponent::getIsMainListener() const { @@ -102,4 +108,42 @@ sf::Listener::SetPosition(mPosition.X, mPosition.Y, mPosition.Z); } + +// SoundListenerComponent Angelscript binding. +void bindSoundListenerComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SoundListenerComponent class. + r = engine->RegisterObjectType("SoundListenerComponent", sizeof(SoundListenerComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindEntityComponentChild<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("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @)", + asFUNCTION(SoundListenerComponent::refFactory), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("SoundListenerComponent", asBEHAVE_FACTORY, "SoundListenerComponent@ f(Entity @, bool)", + asFUNCTION(SoundListenerComponent::refFactory), asCALL_CDECL); assert(r >= 0); + + // 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); +} + // End of File Modified: trunk/src/components/sound/SoundListenerComponent.h =================================================================== --- trunk/src/components/sound/SoundListenerComponent.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/components/sound/SoundListenerComponent.h 2009-05-25 17:43:27 UTC (rev 39) @@ -30,6 +30,9 @@ SoundListenerComponent(Entity *parent, bool isMainListener = true); ~SoundListenerComponent(); + // AngelScript binding + static SoundListenerComponent* refFactory(Entity *parent, bool isMainListener = true); + // Methods bool getIsMainListener() const; const vector3df& getTarget() const; @@ -52,4 +55,8 @@ bool mIsMainListener; }; + +// SoundListenerComponent Angelscript binding. +extern void bindSoundListenerComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -48,6 +48,12 @@ delete[] mBuffer; } +// AngelScript: Will be used to instanciate objects of this class. +SoundSourceComponent* SoundSourceComponent::refFactory(Entity *parent) +{ + return new SoundSourceComponent(parent); +} + // Gets a direct pointer to SFML's sf::Sound object. sf::Sound* SoundSourceComponent::getSound() { @@ -361,4 +367,70 @@ mMusic->SetPosition(mPosition.X, mPosition.Y, mPosition.Z); } + +// SoundSourceComponent Angelscript binding. +void bindSoundSourceComponent(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SoundSourceComponent class. + r = engine->RegisterObjectType("SoundSourceComponent", sizeof(SoundSourceComponent), asOBJ_REF); assert(r >= 0); + + // Bind inherited functions. + bindEntityComponentChild<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("SoundSourceComponent", asBEHAVE_FACTORY, "SoundSourceComponent@ f(Entity @)", + asFUNCTION(SoundSourceComponent::refFactory), asCALL_CDECL); assert(r >= 0); + + // Bind SoundSourceComponent class functions. + r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadMusic(const string &)", + asMETHOD(SoundSourceComponent, loadMusic), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "bool loadSoundBuffer(const string &)", + asMETHOD(SoundSourceComponent, loadSoundBuffer), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SoundSourceComponent", "void play()", + asMETHOD(SoundSourceComponent, play), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "void pause()", + asMETHOD(SoundSourceComponent, play), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "void stop()", + asMETHOD(SoundSourceComponent, play), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SoundSourceComponent", "float getAttenuation()", + asMETHOD(SoundSourceComponent, getAttenuation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "bool getIsPlaying()", + asMETHOD(SoundSourceComponent, getIsPlaying), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "bool getIsPaused()", + asMETHOD(SoundSourceComponent, getIsPaused), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "bool getIsStopped()", + asMETHOD(SoundSourceComponent, getIsStopped), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "float getMinDistance()", + asMETHOD(SoundSourceComponent, getMinDistance), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "float getOffset()", + asMETHOD(SoundSourceComponent, getOffset), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "float getPitch()", + asMETHOD(SoundSourceComponent, getPitch), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "float getVolume()", + asMETHOD(SoundSourceComponent, getVolume), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SoundSourceComponent", "void setAttenuation(float)", + asMETHOD(SoundSourceComponent, setAttenuation), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "void setLoop(bool)", + asMETHOD(SoundSourceComponent, setLoop), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "void setMinDistance(float)", + asMETHOD(SoundSourceComponent, setMinDistance), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "void setOffset(float)", + asMETHOD(SoundSourceComponent, setOffset), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "void setPitch(float)", + asMETHOD(SoundSourceComponent, setPitch), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundSourceComponent", "void setVolume(float)", + asMETHOD(SoundSourceComponent, setVolume), asCALL_THISCALL); assert(r >= 0); +} + // End of File Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-05-25 17:43:27 UTC (rev 39) @@ -30,6 +30,9 @@ SoundSourceComponent(Entity *parent); ~SoundSourceComponent(); + // AngelScript binding + static SoundSourceComponent* refFactory(Entity *parent); + // Methods sf::Sound* getSound(); sf::Music* getMusic(); @@ -79,5 +82,9 @@ }; + +// SoundSourceComponent Angelscript binding. +extern void bindSoundSourceComponent(asIScriptEngine *engine); + #endif Modified: trunk/src/core/DataStack.cpp =================================================================== --- trunk/src/core/DataStack.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/DataStack.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -236,7 +236,7 @@ r = engine->RegisterObjectType("DataStack", sizeof(DataStack), asOBJ_REF); assert(r >= 0); // Set DataStack behaviour. - r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_FACTORY, "DataStack@ f(const string &name)", + r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_FACTORY, "DataStack@ f(const string &)", asFUNCTION(DataStack::refFactory), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_ADDREF, "void f()", asMETHOD(DataStack, refAdd), asCALL_THISCALL); assert(r >= 0); @@ -256,13 +256,13 @@ r = engine->RegisterObjectMethod("DataStack", "void removeAll()", asMETHOD(DataStack, removeAll), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStack", "bool removeVar(const string &name)", + r = engine->RegisterObjectMethod("DataStack", "bool removeVar(const string &)", asMETHOD(DataStack, removeVar), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStack", "bool save(const string &fileName)", + r = engine->RegisterObjectMethod("DataStack", "bool save(const string &)", asMETHOD(DataStack, save), asCALL_THISCALL);assert(r >= 0); - r = engine->RegisterObjectMethod("DataStack", "bool load(const string &fileName)", + r = engine->RegisterObjectMethod("DataStack", "bool load(const string &)", asMETHOD(DataStack, load), asCALL_THISCALL);assert(r >= 0); } Modified: trunk/src/core/DataStack.h =================================================================== --- trunk/src/core/DataStack.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/DataStack.h 2009-05-25 17:43:27 UTC (rev 39) @@ -117,6 +117,7 @@ std::map<std::string, std::string> mVars; }; + // DataStack Angelscript binding. extern void bindDataStack(asIScriptEngine *engine); Modified: trunk/src/core/DataStore.cpp =================================================================== --- trunk/src/core/DataStore.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/DataStore.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -213,27 +213,27 @@ r = engine->RegisterObjectMethod("DataStore", "void clear()", asMETHOD(DataStore, clear), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "bool addDataStack(DataStack @stack)", + r = engine->RegisterObjectMethod("DataStore", "bool addDataStack(DataStack @)", asMETHOD(DataStore, addDataStack), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "DataStack@ createDataStack(const string &name)", + r = engine->RegisterObjectMethod("DataStore", "DataStack@ createDataStack(const string &)", asMETHOD(DataStore, createDataStack), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "DataStack@ getDataStack(const uint id)", + r = engine->RegisterObjectMethod("DataStore", "DataStack@ getDataStack(const uint)", asMETHODPR(DataStore, getDataStack, (const u32), DataStack*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "DataStack@ getDataStack(const string &name)", + r = engine->RegisterObjectMethod("DataStore", "DataStack@ getDataStack(const string &)", asMETHODPR(DataStore, getDataStack, (const std::string &), DataStack*), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("DataStore", "void removeAll()", asMETHOD(DataStore, removeAll), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "bool removeDataStack(DataStack @stack)", + r = engine->RegisterObjectMethod("DataStore", "bool removeDataStack(DataStack @)", asMETHODPR(DataStore, removeDataStack, (DataStack*), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "bool removeDataStack(const uint id)", + r = engine->RegisterObjectMethod("DataStore", "bool removeDataStack(const uint)", asMETHODPR(DataStore, removeDataStack, (const u32), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("DataStore", "bool removeDataStack(const string &name)", + r = engine->RegisterObjectMethod("DataStore", "bool removeDataStack(const string &)", asMETHODPR(DataStore, removeDataStack, (const std::string &), bool), asCALL_THISCALL); assert(r >= 0); } Modified: trunk/src/core/DataStore.h =================================================================== --- trunk/src/core/DataStore.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/DataStore.h 2009-05-25 17:43:27 UTC (rev 39) @@ -59,6 +59,7 @@ }; + // DataStore Angelscript binding. extern void bindDataStore(asIScriptEngine *engine); Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/Entity.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -395,7 +395,7 @@ r = engine->RegisterObjectType("EntityComponent", sizeof(EntityComponent), asOBJ_REF); // Set Entity behaviour. - r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_FACTORY, "Entity@ f(const string &name)", + r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_FACTORY, "Entity@ f(const string &)", asFUNCTION(Entity::refFactory), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_ADDREF, "void f()", asMETHOD(Entity, refAdd), asCALL_THISCALL); assert(r >= 0); @@ -411,16 +411,16 @@ r = engine->RegisterObjectMethod("Entity", "bool addComponent()", asMETHOD(Entity, addComponent), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "Entity@ getChild(const uint id)", + r = engine->RegisterObjectMethod("Entity", "Entity@ getChild(const uint)", asMETHODPR(Entity, getChild, (const u32), Entity*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "Entity@ getChild(const string &name)", + r = engine->RegisterObjectMethod("Entity", "Entity@ getChild(const string &)", asMETHODPR(Entity, getChild, (const std::string &), Entity*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "EntityComponent@ getComponent(const uint id)", + r = engine->RegisterObjectMethod("Entity", "EntityComponent@ getComponent(const uint)", asMETHODPR(Entity, getComponent, (const u32), EntityComponent*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "EntityComponent@ getComponent(const string &name)", + r = engine->RegisterObjectMethod("Entity", "EntityComponent@ getComponent(const string &)", asMETHODPR(Entity, getComponent, (const std::string &), EntityComponent*), asCALL_THISCALL); assert(r >= 0); @@ -429,22 +429,22 @@ r = engine->RegisterObjectMethod("Entity", "void removeAll()", asMETHOD(Entity, removeAll), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "bool removeChild(Entity @entity)", + r = engine->RegisterObjectMethod("Entity", "bool removeChild(Entity @)", asMETHODPR(Entity, removeChild, (Entity*), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "bool removeChild(const uint id)", + r = engine->RegisterObjectMethod("Entity", "bool removeChild(const uint)", asMETHODPR(Entity, removeChild, (const u32), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "bool removeChild(const string &name)", + r = engine->RegisterObjectMethod("Entity", "bool removeChild(const string &)", asMETHODPR(Entity, removeChild, (const std::string&), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "bool removeComponent(EntityComponent @component)", + r = engine->RegisterObjectMethod("Entity", "bool removeComponent(EntityComponent @)", asMETHODPR(Entity, removeComponent, (EntityComponent*), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "bool removeComponent(const uint id)", + r = engine->RegisterObjectMethod("Entity", "bool removeComponent(const uint)", asMETHODPR(Entity, removeComponent, (const u32), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "bool removeComponent(const string &name)", + r = engine->RegisterObjectMethod("Entity", "bool removeComponent(const string &)", asMETHODPR(Entity, removeComponent, (const std::string&), bool), asCALL_THISCALL); assert(r >= 0); } Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/Entity.h 2009-05-25 17:43:27 UTC (rev 39) @@ -89,6 +89,7 @@ vector<EntityComponent*> mComponents; }; + // Entity Angelscript binding. extern void bindEntity(asIScriptEngine *engine); Modified: trunk/src/core/EntityComponent.cpp =================================================================== --- trunk/src/core/EntityComponent.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/EntityComponent.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -108,7 +108,7 @@ r = engine->RegisterObjectType("Entity", sizeof(Entity), asOBJ_REF); // Set EntityComponent behaviour. - r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_FACTORY, "EntityComponent@ f(Entity @parent)", + r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_FACTORY, "EntityComponent@ f(Entity @)", asFUNCTION(EntityComponent::refFactory), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_ADDREF, "void f()", asMETHOD(EntityComponent, refAdd), asCALL_THISCALL); assert(r >= 0); @@ -119,7 +119,7 @@ r = engine->RegisterObjectMethod("EntityComponent", "uint getID()", asMETHOD(EntityComponent, getID), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityComponent", "void setName(const string &name)", + r = engine->RegisterObjectMethod("EntityComponent", "void setName(const string &)", asMETHOD(EntityComponent, setName), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityComponent", "const string& getName()", asMETHOD(EntityComponent, getName), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/core/EntityComponent.h =================================================================== --- trunk/src/core/EntityComponent.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/EntityComponent.h 2009-05-25 17:43:27 UTC (rev 39) @@ -63,7 +63,32 @@ s32 mRefCount; }; + // EntityComponent Angelscript binding. extern void bindEntityComponent(asIScriptEngine *engine); +template<typename T> +void bindEntityComponentChild(asIScriptEngine *engine, const char *type) +{ + // Forward declaration. + int r; + + // Set common behaviour. + r = engine->RegisterObjectBehaviour(type, asBEHAVE_ADDREF, "void f()", + asMETHOD(T, refAdd), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour(type, asBEHAVE_RELEASE, "void f()", + asMETHOD(T, refRelease), asCALL_THISCALL); assert(r >= 0); + + // Bind common class functions. + r = engine->RegisterObjectMethod(type, "uint getID()", + asMETHOD(T, getID), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "void setName(const string &)", + asMETHOD(T, setName), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod(type, "const string& getName()", + asMETHOD(T, getName), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod(type, "Entity@ getParent()", + asMETHOD(T, getParent), asCALL_THISCALL); assert(r >= 0); +} #endif Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/EntityManager.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -212,29 +212,29 @@ r = engine->RegisterObjectMethod("EntityManager", "void clear()", asMETHOD(EntityManager, clear), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "bool addEntity(Entity @entity)", + r = engine->RegisterObjectMethod("EntityManager", "bool addEntity(Entity @)", asMETHOD(EntityManager, addEntity), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &name)", + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &)", asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &name, Entity @parent)", + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &, Entity @)", asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const int id)", + r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const int)", asMETHODPR(EntityManager, getEntity, (const u32), Entity*), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const string &name)", + r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const string &)", asMETHODPR(EntityManager, getEntity, (const std::string &), Entity*), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "void removeAll()", asMETHOD(EntityManager, removeAll), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(Entity @entity)", + r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(Entity @)", asMETHODPR(EntityManager, removeEntity, (Entity*), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(const int id)", + r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(const int)", asMETHODPR(EntityManager, removeEntity, (const u32), bool), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(const string &name)", + r = engine->RegisterObjectMethod("EntityManager", "bool removeEntity(const string &)", asMETHODPR(EntityManager, removeEntity, (const std::string &), bool), asCALL_THISCALL); assert(r >= 0); } Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/EventManager.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -185,33 +185,11 @@ // EventManager and sigslot::has_slots<> Angelscript binding. -void construct_ss_has_slots(void *p) -{ - new(p) sigslot::has_slots<>(); -} - - -void deconstruct_ss_has_slots(sigslot::has_slots<> *p) -{ - p->~has_slots(); -} - void bindEventManager(asIScriptEngine *engine) { // Forward declarations. int r; - // Bind sigslot::has_slots<> class. - r = engine->RegisterObjectType("ss_has_slots", sizeof(sigslot::has_slots<>), asOBJ_VALUE | asOBJ_APP_CLASS_CDA); assert(r >= 0); - - r = engine->RegisterObjectBehaviour("ss_has_slots", asBEHAVE_CONSTRUCT, "void f()", - asFUNCTION(construct_ss_has_slots), asCALL_CDECL_OBJLAST); assert(r >= 0); - r = engine->RegisterObjectBehaviour("ss_has_slots", asBEHAVE_DESTRUCT, "void f()", - asFUNCTION(deconstruct_ss_has_slots), asCALL_CDECL_OBJLAST); assert(r >= 0); - - r = engine->RegisterObjectMethod("ss_has_slots", "void disconnect_all()", - asMETHOD(sigslot::has_slots<>, disconnect_all), asCALL_THISCALL); assert(r >= 0); - // Bind EventManager class. r = engine->RegisterObjectType("EventManager", sizeof(EventManager), asOBJ_REF); assert(r >= 0); @@ -227,20 +205,18 @@ r = engine->RegisterObjectMethod("EventManager", "void clear()", asMETHOD(EventManager, clear), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EventManager", "bool createEventGroup(const string &groupName)", + r = engine->RegisterObjectMethod("EventManager", "bool createEventGroup(const string &)", asMETHOD(EventManager, createEventGroup), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EventManager", "bool createEventSlot(const string &groupName, " \ - "const string &slotName)", + r = engine->RegisterObjectMethod("EventManager", "bool createEventSlot(const string &, const string &)", asMETHOD(EventManager, createEventSlot), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EventManager", "void removeAllEventGroups()", asMETHOD(EventManager, removeAllEventGroups), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EventManager", "bool removeAllEventSlots(const string &groupName)", + r = engine->RegisterObjectMethod("EventManager", "bool removeAllEventSlots(const string &)", asMETHOD(EventManager, removeAllEventSlots), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EventManager", "bool removeEventGroup(const string &groupName)", + r = engine->RegisterObjectMethod("EventManager", "bool removeEventGroup(const string &)", asMETHOD(EventManager, removeEventGroup), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("EventManager", "bool removeEventSlot(const string &groupName, " \ - "const string &slotName)", + r = engine->RegisterObjectMethod("EventManager", "bool removeEventSlot(const string &, const string &)", asMETHOD(EventManager, removeEventSlot), asCALL_THISCALL); assert(r >= 0); } Modified: trunk/src/core/EventManager.h =================================================================== --- trunk/src/core/EventManager.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/EventManager.h 2009-05-25 17:43:27 UTC (rev 39) @@ -109,6 +109,7 @@ }; + // EventManager and sigslot::has_slots<> Angelscript binding. extern void bindEventManager(asIScriptEngine *engine); Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/GameManager.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -261,10 +261,10 @@ r = engine->RegisterGlobalFunction("GameManager& getGameManager()", asFUNCTION(GameManager::Instance), asCALL_CDECL); assert( r >= 0 ); - r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @state)", + r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @)", asMETHODPR(GameManager, changeState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "void pushState(GameState @state)", + r = engine->RegisterObjectMethod("GameManager", "void pushState(GameState @)", asMETHODPR(GameManager, pushState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void popState()", @@ -282,7 +282,7 @@ r = engine->RegisterObjectMethod("GameManager", "bool getIsRunning()", asMETHOD(GameManager, getIsRunning), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "void setIsRunning(bool value)", + r = engine->RegisterObjectMethod("GameManager", "void setIsRunning(bool)", asMETHOD(GameManager, setIsRunning), asCALL_THISCALL); assert(r >= 0); } Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/GameManager.h 2009-05-25 17:43:27 UTC (rev 39) @@ -96,6 +96,7 @@ }; + // GameManager Angelscript binding. extern void bindGameManager(asIScriptEngine *engine); Modified: trunk/src/core/GameState.h =================================================================== --- trunk/src/core/GameState.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/core/GameState.h 2009-05-25 17:43:27 UTC (rev 39) @@ -41,6 +41,7 @@ void refRelease(); }; + // GameState Angelscript binding. extern void bindGameState(asIScriptEngine *engine); Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/scripting/ScriptManager.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -16,6 +16,7 @@ // Include files #include "ScriptManager.h" +#include "bindIrrlicht.h" #include "../core/GameManager.h" @@ -41,6 +42,9 @@ RegisterScriptString(pEngine); pEngine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); + // Register Irrlicht. + bindIrrlicht(pEngine); + // Register classes and functions. bindGameState(pEngine); bindEntity(pEngine); Modified: trunk/src/scripting/ScriptManager.h =================================================================== --- trunk/src/scripting/ScriptManager.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/scripting/ScriptManager.h 2009-05-25 17:43:27 UTC (rev 39) @@ -63,4 +63,23 @@ // AngelScript functions extern void MessageCallback(const asSMessageInfo *msg, void *param); +// Global function for AngelScript's ref casting. +// Author: Andreas Jönsson (AngelScript's author) +template<typename A, typename B> +B* asRefCast(A* a) +{ + // If the handle already is a null handle, then just return the null handle + if( !a ) return 0; + + // Now try to dynamically cast the pointer to the wanted type + B* b = dynamic_cast<B*>(a); + if( b == 0 ) + { + // Since the cast couldn't be made, we need to release the handle we received + a->refRelease(); + } + return b; +} + + #endif Added: trunk/src/scripting/bindIrrlicht.cpp =================================================================== --- trunk/src/scripting/bindIrrlicht.cpp (rev 0) +++ trunk/src/scripting/bindIrrlicht.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -0,0 +1,47 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: bindIrrlicht.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds various Irrlicht objects to AngelScript. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "bindIrrlicht.h" + + +// Vector3df<T> binding. +template<typename T> +void bindVector3d(asIScriptEngine *engine, const char *typeName, const char *asType) +{ + // Forward declarations. + int r; + + // Bind Vector3d<T> class. + r = engine->RegisterObjectType(typeName, sizeof(vector3d<T>), asOBJ_REF); assert(r >= 0); + + // Set vector3d<T> behaviour. + + + // Bind vector3d<T> class functions. + +} + + +// Irrlicht AngelScript binding +void bindIrrlicht(asIScriptEngine *engine) +{ + // Vector3d<T> + bindVector3d<f32>(engine, "vector3df", "float"); + bindVector3d<s32>(engine, "vector3di", "int"); +} + +// End of File + Added: trunk/src/scripting/bindIrrlicht.h =================================================================== --- trunk/src/scripting/bindIrrlicht.h (rev 0) +++ trunk/src/scripting/bindIrrlicht.h 2009-05-25 17:43:27 UTC (rev 39) @@ -0,0 +1,28 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: bindIrrlicht.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Binds various Irrlicht objects to AngelScript. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __BINDIRRLICHT_H__ +#define __BINDIRRLICHT_H__ + +// Include files +#include "../dependencies.h" + + +// AngelScript binding +extern void bindIrrlicht(asIScriptEngine *engine); + +#endif + + Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/sirrf.cbp 2009-05-25 17:43:27 UTC (rev 39) @@ -108,6 +108,8 @@ <Unit filename="scripting/Script.h" /> <Unit filename="scripting/ScriptManager.cpp" /> <Unit filename="scripting/ScriptManager.h" /> + <Unit filename="scripting/bindIrrlicht.cpp" /> + <Unit filename="scripting/bindIrrlicht.h" /> <Unit filename="scripting/scriptstring.cpp" /> <Unit filename="scripting/scriptstring.h" /> <Unit filename="scripting/scriptstring_utils.cpp" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/sirrf.depend 2009-05-25 17:43:27 UTC (rev 39) @@ -989,11 +989,11 @@ <assert.h> "scriptstring.h" -1243004646 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp +1243271458 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp "DataStack.h" "GameManager.h" -1242570871 /home/michael/Programming/Projects/sirrf/src/core/DataStack.h +1243271612 /home/michael/Programming/Projects/sirrf/src/core/DataStack.h "../dependencies.h" "DataStore.h" @@ -1012,29 +1012,29 @@ <SFML/System.hpp> <SFML/Audio.hpp> -1243004416 /home/michael/Programming/Projects/sirrf/src/core/DataStore.h +1243271618 /home/michael/Programming/Projects/sirrf/src/core/DataStore.h "../dependencies.h" "DataStack.h" -1243004577 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp +1243271501 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" -1243004664 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp +1243271659 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp "Entity.h" "GameManager.h" -1242570582 /home/michael/Programming/Projects/sirrf/src/core/Entity.h +1243271665 /home/michael/Programming/Projects/sirrf/src/core/Entity.h "../dependencies.h" "EntityComponent.h" -1242844453 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h +1243271750 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h "../dependencies.h" "Entity.h" -1243004691 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp +1243271684 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" -1243004603 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp +1243271819 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp "EntityManager.h" "GameManager.h" @@ -1042,11 +1042,11 @@ "../dependencies.h" "Entity.h" -1243005457 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1243271919 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" "../components/components.h" -1243005433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h +1243271926 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" "GameState.h" "DataStore.h" @@ -1056,7 +1056,7 @@ "../scripting/ScriptManager.h" "../components/components.h" -1243006017 /home/michael/Programming/Projects/sirrf/src/core/GameState.h +1243271961 /home/michael/Programming/Projects/sirrf/src/core/GameState.h "GameManager.h" 1241010330 /home/michael/Programming/Projects/sirrf/src/core/ScriptManager.h @@ -1075,10 +1075,10 @@ 1240939945 source:/home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.cpp -1243004860 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp +1243271950 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp "EventManager.h" -1243004790 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h +1243271884 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h "../dependencies.h" 1240941730 /home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.h @@ -1096,7 +1096,7 @@ <windows.h> <pthread.h> -1243004124 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h +1243272609 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h "../dependencies.h" "scriptstring.h" "Script.h" @@ -1105,8 +1105,9 @@ <angelscript.h> <string> -1243005889 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp +1243269833 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp "ScriptManager.h" + "bindIrrlicht.h" "../core/GameManager.h" 1228771288 /home/michael/Programming/Projects/sirrf/src/scripting/scriptstring.h @@ -1247,11 +1248,11 @@ 1216759683 /usr/local/include//AL/alc.h -1243004975 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp +1243271979 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp "SoundManager.h" "../core/GameManager.h" -1243004900 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h +1243271983 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h "../dependencies.h" 1242308358 /usr/local/include//SFML/System.hpp @@ -1387,11 +1388,11 @@ <SFML/System/Thread.hpp> <vector> -1242845303 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp +1243272710 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp "SoundListenerComponent.h" "../../core/GameManager.h" -1242845296 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.h +1243269077 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -2321,11 +2322,11 @@ "matrix4.h" "IVideoDriver.h" -1242842908 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp +1243272756 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp "SoundSourceComponent.h" "../../core/GameManager.h" -1242842334 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.h +1243271340 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -2351,7 +2352,7 @@ "sound/SoundListenerComponent.h" "sound/SoundSourceComponent.h" -1242845081 source:/home/michael/Programming/Projects/sirrf/src/components/components.cpp +1243270609 source:/home/michael/Programming/Projects/sirrf/src/components/components.cpp "components.h" 1242996572 source:/home/michael/Programming/Projects/sirrf/src/scripting/Script.cpp @@ -2362,3 +2363,9 @@ "../dependencies.h" "ScriptManager.h" +1243269810 /home/michael/Programming/Projects/sirrf/src/scripting/bindIrrlicht.h + "../dependencies.h" + +1243270286 source:/home/michael/Programming/Projects/sirrf/src/scripting/bindIrrlicht.cpp + "bindIrrlicht.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/sirrf.layout 2009-05-25 17:43:27 UTC (rev 39) @@ -88,8 +88,8 @@ <File name="components/sound/SoundSourceComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1118" topLine="16" /> </File> - <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> - <Cursor position="5171" topLine="225" /> + <File name="core/DataStack.cpp" open="1" top="1" tabpos="1"> + <Cursor position="5760" topLine="225" /> </File> <File name="core/DataStack.h" open="0" top="0" tabpos="1"> <Cursor position="1097" topLine="14" /> @@ -143,13 +143,13 @@ <Cursor position="1727" topLine="8" /> </File> <File name="scripting/Script.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2283" topLine="101" /> + <Cursor position="2283" topLine="8" /> </File> <File name="scripting/Script.h" open="0" top="0" tabpos="0"> <Cursor position="1075" topLine="15" /> </File> <File name="scripting/ScriptManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="1298" topLine="22" /> + <Cursor position="5334" topLine="196" /> </File> <File name="scripting/ScriptManager.h" open="0" top="0" tabpos="1"> <Cursor position="1616" topLine="23" /> Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/sound/SoundManager.cpp 2009-05-25 17:43:27 UTC (rev 39) @@ -172,15 +172,15 @@ r = engine->RegisterObjectMethod("SoundManager", "float getGlobalVolume()", asMETHOD(SoundManager, getGlobalVolume), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("SoundManager", "bool loadSoundBuffer(const string &fileName)", + r = engine->RegisterObjectMethod("SoundManager", "bool loadSoundBuffer(const string &)", asMETHOD(SoundManager, loadSoundBuffer), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("SoundManager", "void removeAll()", asMETHOD(SoundManager, removeAll), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("SoundManager", "bool removeSoundBuffer(const string &fileName)", + r = engine->RegisterObjectMethod("SoundManager", "bool removeSoundBuffer(const string &)", asMETHOD(SoundManager, removeSoundBuffer), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("SoundManager", "void setGlobalVolume(float volume)", + r = engine->RegisterObjectMethod("SoundManager", "void setGlobalVolume(float)", asMETHOD(SoundManager, setGlobalVolume), asCALL_THISCALL); assert(r >= 0); } Modified: trunk/src/sound/SoundManager.h =================================================================== --- trunk/src/sound/SoundManager.h 2009-05-22 16:27:16 UTC (rev 38) +++ trunk/src/sound/SoundManager.h 2009-05-25 17:43:27 UTC (rev 39) @@ -53,6 +53,7 @@ }; + // SoundManager Angelscript binding. extern void bindSoundManager(asIScriptEngine *engine); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-22 16:27:24
|
Revision: 38 http://sirrf.svn.sourceforge.net/sirrf/?rev=38&view=rev Author: zccdark203 Date: 2009-05-22 16:27:16 +0000 (Fri, 22 May 2009) Log Message: ----------- All exposed classes can now be used within AngelScript through both handles (@) and references (&). I've already tested it and there shouldn't be any bugs, but confirmation would be appreciated. Unfortunately, there is also a bit of bad news. Apparently, its currently impossible to derive from application registered classes in AngelScript. That while I wanted to use exactly that for scripted GameStates and EntityComponents. There are different ways to get the same functionality, but I would prefer an AngelScript solution. I think I'll have to contact the developers of AngelScript, because according to the website there is some way to implement derivation from application registered classes. Modified Paths: -------------- trunk/src/core/DataStack.cpp trunk/src/core/DataStore.cpp trunk/src/core/DataStore.h trunk/src/core/Entity.cpp trunk/src/core/EntityComponent.cpp trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h trunk/src/core/EventManager.cpp trunk/src/core/EventManager.h trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/core/GameState.cpp trunk/src/core/GameState.h trunk/src/scripting/ScriptManager.cpp trunk/src/sirrf.depend trunk/src/sirrf.layout trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Modified: trunk/src/core/DataStack.cpp =================================================================== --- trunk/src/core/DataStack.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/DataStack.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -235,7 +235,7 @@ // Bind DataStack class. r = engine->RegisterObjectType("DataStack", sizeof(DataStack), asOBJ_REF); assert(r >= 0); - // Bind DataStack class functions. + // Set DataStack behaviour. r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_FACTORY, "DataStack@ f(const string &name)", asFUNCTION(DataStack::refFactory), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_ADDREF, "void f()", @@ -243,6 +243,7 @@ r = engine->RegisterObjectBehaviour("DataStack", asBEHAVE_RELEASE, "void f()", asMETHOD(DataStack, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind DataStack class functions. r = engine->RegisterObjectMethod("DataStack", "void init()", asMETHOD(DataStack, init), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("DataStack", "void clear()", Modified: trunk/src/core/DataStore.cpp =================================================================== --- trunk/src/core/DataStore.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/DataStore.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -42,6 +42,18 @@ removeAll(); } +// Angelscript: Increases the reference counter. +void DataStore::refAdd() +{ + // Dummy function. +} + +// Angelscript: Decreases the reference counter. +void DataStore::refRelease() +{ + // Dummy function. +} + // Adds the given Data Stack to the Data Store. bool DataStore::addDataStack(DataStack *stack) { @@ -68,6 +80,7 @@ // Create the Data Stack and add it to the vector. DataStack *stack = new DataStack(name); + stack->refAdd(); mStacks.push_back(stack); return stack; @@ -186,8 +199,14 @@ int r; // Bind DataStore class. - r = engine->RegisterObjectType("DataStore", sizeof(DataStore), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); + r = engine->RegisterObjectType("DataStore", sizeof(DataStore), asOBJ_REF); assert(r >= 0); + // Set DataStore behaviour. + r = engine->RegisterObjectBehaviour("DataStore", asBEHAVE_ADDREF, "void f()", + asMETHOD(DataStore, refAdd), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("DataStore", asBEHAVE_RELEASE, "void f()", + asMETHOD(DataStore, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind DataStore class functions. r = engine->RegisterObjectMethod("DataStore", "void init()", asMETHOD(DataStore, init), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/core/DataStore.h =================================================================== --- trunk/src/core/DataStore.h 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/DataStore.h 2009-05-22 16:27:16 UTC (rev 38) @@ -36,6 +36,10 @@ void init(); void clear(); + // AngelScript binding + void refAdd(); + void refRelease(); + // Methods bool addDataStack(DataStack *stack); DataStack* createDataStack(const std::string &name); Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/Entity.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -394,7 +394,7 @@ r = engine->RegisterObjectType("Entity", sizeof(Entity), asOBJ_REF); r = engine->RegisterObjectType("EntityComponent", sizeof(EntityComponent), asOBJ_REF); - // Bind Entity class functions. + // Set Entity behaviour. r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_FACTORY, "Entity@ f(const string &name)", asFUNCTION(Entity::refFactory), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_ADDREF, "void f()", @@ -402,6 +402,7 @@ r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_RELEASE, "void f()", asMETHOD(Entity, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind Entity class functions. r = engine->RegisterObjectMethod("Entity", "uint getID()", asMETHOD(Entity, getID), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "const string& getName()", Modified: trunk/src/core/EntityComponent.cpp =================================================================== --- trunk/src/core/EntityComponent.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/EntityComponent.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -107,7 +107,7 @@ r = engine->RegisterObjectType("EntityComponent", sizeof(EntityComponent), asOBJ_REF); r = engine->RegisterObjectType("Entity", sizeof(Entity), asOBJ_REF); - // Bind GameManager class functions. + // Set EntityComponent behaviour. r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_FACTORY, "EntityComponent@ f(Entity @parent)", asFUNCTION(EntityComponent::refFactory), asCALL_CDECL); assert(r >= 0); r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_ADDREF, "void f()", @@ -115,6 +115,7 @@ r = engine->RegisterObjectBehaviour("EntityComponent", asBEHAVE_RELEASE, "void f()", asMETHOD(EntityComponent, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind EntityComponent class functions. r = engine->RegisterObjectMethod("EntityComponent", "uint getID()", asMETHOD(EntityComponent, getID), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/EntityManager.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -16,6 +16,7 @@ // Include files #include "EntityManager.h" +#include "GameManager.h" // EntityManager class @@ -43,6 +44,18 @@ removeAll(); } +// Angelscript: Increases the reference counter. +void EntityManager::refAdd() +{ + // Dummy function. +} + +// Angelscript: Decreases the reference counter. +void EntityManager::refRelease() +{ + // Dummy function. +} + // Adds an entity to the Entity Manager. bool EntityManager::addEntity(Entity *entity) { @@ -185,8 +198,14 @@ int r; // Bind EntityManager class. - r = engine->RegisterObjectType("EntityManager", sizeof(EntityManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); + r = engine->RegisterObjectType("EntityManager", sizeof(EntityManager), asOBJ_REF); assert(r >= 0); + // Set EntityManager behaviour. + r = engine->RegisterObjectBehaviour("EntityManager", asBEHAVE_ADDREF, "void f()", + asMETHOD(EntityManager, refAdd), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("EntityManager", asBEHAVE_RELEASE, "void f()", + asMETHOD(EntityManager, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind EntityManager class functions. r = engine->RegisterObjectMethod("EntityManager", "void init()", asMETHOD(EntityManager, init), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/EntityManager.h 2009-05-22 16:27:16 UTC (rev 38) @@ -38,6 +38,10 @@ void init(); void clear(); + // AngelScript binding + void refAdd(); + void refRelease(); + // Methods bool addEntity(Entity *entity); Entity* createEntity(const std::string &name, Entity *parent = NULL); Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/EventManager.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -42,6 +42,18 @@ mEvents.clear(); } +// Angelscript: Increases the reference counter. +void EventManager::refAdd() +{ + // Dummy function. +} + +// Angelscript: Decreases the reference counter. +void EventManager::refRelease() +{ + // Dummy function. +} + // Creates a new event group, a collection of events. bool EventManager::createEventGroup(const std::string &groupName) { @@ -201,8 +213,14 @@ asMETHOD(sigslot::has_slots<>, disconnect_all), asCALL_THISCALL); assert(r >= 0); // Bind EventManager class. - r = engine->RegisterObjectType("EventManager", sizeof(EventManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); + r = engine->RegisterObjectType("EventManager", sizeof(EventManager), asOBJ_REF); assert(r >= 0); + // Set EventManager behaviour. + r = engine->RegisterObjectBehaviour("EventManager", asBEHAVE_ADDREF, "void f()", + asMETHOD(EventManager, refAdd), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("EventManager", asBEHAVE_RELEASE, "void f()", + asMETHOD(EventManager, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind EventManager class functions. r = engine->RegisterObjectMethod("EventManager", "void init()", asMETHOD(EventManager, init), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/core/EventManager.h =================================================================== --- trunk/src/core/EventManager.h 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/EventManager.h 2009-05-22 16:27:16 UTC (rev 38) @@ -35,6 +35,10 @@ void init(); void clear(); + // AngelScript binding + void refAdd(); + void refRelease(); + // Methods bool createEventGroup(const std::string &groupName); bool createEventSlot(const std::string &groupName, const std::string &slotName); Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/GameManager.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -105,6 +105,24 @@ pDevice->drop(); } +// AngelScript: Will be used to instanciate objects of this class. +GameManager* GameManager::refFactory() +{ + return GameManager::Instance(); +} + +// Angelscript: Increases the reference counter. +void GameManager::refAdd() +{ + // Dummy function. +} + +// Angelscript: Decreases the reference counter. +void GameManager::refRelease() +{ + // Dummy function. +} + // Close the current state and change to the given state. void GameManager::changeState(GameState *state) { @@ -119,24 +137,6 @@ } } -// Close the current state and load the given state. -void GameManager::changeState(const std::string &fileName) -{ - // Clear the current state. - popState(); - - // Determine the base state. - GameState *state = NULL; - //state = loadState(fileName); - - // Initialise the state. - if(state != NULL) - { - mGameStates.push_back(state); - state->init(); - } -} - // Pause the current state and change to the given state. void GameManager::pushState(GameState *state) { @@ -151,24 +151,6 @@ } } -// Pauses the current state and change to a new state. -void GameManager::pushState(const std::string &fileName) -{ - // Pause the current state. - //mGameStates.back()->pause(); - - // Determine the base state. - GameState *state = NULL; - //state = loadState(fileName); - - // Initialise the state. - if(state != NULL) - { - mGameStates.push_back(state); - state->init(); - } -} - // Close the current state and resume the previous state. void GameManager::popState() { @@ -265,34 +247,36 @@ int r; // Bind GameManager class. - r = engine->RegisterObjectType("GameManager", sizeof(GameManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); + r = engine->RegisterObjectType("GameManager", sizeof(GameManager), asOBJ_REF); assert(r >= 0); + // Set GameManager behaviour. + r = engine->RegisterObjectBehaviour("GameManager", asBEHAVE_FACTORY, "GameManager@ f()", + asFUNCTION(GameManager::refFactory), asCALL_CDECL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("GameManager", asBEHAVE_ADDREF, "void f()", + asMETHOD(GameManager, refAdd), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("GameManager", asBEHAVE_RELEASE, "void f()", + asMETHOD(GameManager, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind GameManager class functions. r = engine->RegisterGlobalFunction("GameManager& getGameManager()", asFUNCTION(GameManager::Instance), asCALL_CDECL); assert( r >= 0 ); - /*r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @state)", + r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @state)", asMETHODPR(GameManager, changeState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "void changeState(const string &fileName)", - asMETHODPR(GameManager, changeState, (const std::string&), void), - asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void pushState(GameState @state)", asMETHODPR(GameManager, pushState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "void pushState(const string &fileName)", - asMETHODPR(GameManager, pushState, (const std::string&), void), - asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void popState()", - asMETHOD(GameManager, popState), asCALL_THISCALL); assert(r >= 0);*/ + asMETHOD(GameManager, popState), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "DataStore& getDataStore()", + r = engine->RegisterObjectMethod("GameManager", "DataStore@ getDataStore()", asMETHOD(GameManager, getDataStore), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "EntityManager& getEntityManager()", + r = engine->RegisterObjectMethod("GameManager", "EntityManager@ getEntityManager()", asMETHOD(GameManager, getEntityManager), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "EventManager& getEventManager()", + r = engine->RegisterObjectMethod("GameManager", "EventManager@ getEventManager()", asMETHOD(GameManager, getEventManager), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "SoundManager& getSoundManager()", + r = engine->RegisterObjectMethod("GameManager", "SoundManager@ getSoundManager()", asMETHOD(GameManager, getSoundManager), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "bool getIsRunning()", Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/GameManager.h 2009-05-22 16:27:16 UTC (rev 38) @@ -37,6 +37,7 @@ { public: + // Initialisation, deinitialisation and control... GameManager(); ~GameManager(); @@ -47,10 +48,14 @@ void update(); void clear(); + // AngelScript binding + static GameManager* refFactory(); + void refAdd(); + void refRelease(); + + // Public methods void changeState(GameState *state); - void changeState(const std::string &fileName); void pushState(GameState *state); - void pushState(const std::string &fileName); void popState(); IrrlichtDevice* getDevice(); Modified: trunk/src/core/GameState.cpp =================================================================== --- trunk/src/core/GameState.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/GameState.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -47,7 +47,18 @@ { } +// Angelscript: Increases the reference counter. +void GameState::refAdd() +{ + // Dummy function. +} +// Angelscript: Decreases the reference counter. +void GameState::refRelease() +{ + // Dummy function. +} + // GameState Angelscript binding. void bindGameState(asIScriptEngine *engine) { @@ -57,6 +68,12 @@ // Bind GameState class. r = engine->RegisterObjectType("GameState", sizeof(GameState), asOBJ_REF); assert(r >= 0); + // Set GameState behaviour. + r = engine->RegisterObjectBehaviour("GameState", asBEHAVE_ADDREF, "void f()", + asMETHOD(GameState, refAdd), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("GameState", asBEHAVE_RELEASE, "void f()", + asMETHOD(GameState, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind GameState class functions. r = engine->RegisterObjectMethod("GameState", "void init()", asMETHOD(GameState, init), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/core/GameState.h =================================================================== --- trunk/src/core/GameState.h 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/core/GameState.h 2009-05-22 16:27:16 UTC (rev 38) @@ -28,12 +28,17 @@ { public: + // Initialisation, deinitialisation and control... GameState(); virtual ~GameState(); virtual void init(); virtual void update(); virtual void clear(); + + // AngelScript binding + void refAdd(); + void refRelease(); }; // GameState Angelscript binding. Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/scripting/ScriptManager.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -42,7 +42,7 @@ pEngine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); // Register classes and functions. - //bindGameState(pEngine); + bindGameState(pEngine); bindEntity(pEngine); bindEntityComponent(pEngine); bindComponents(pEngine); @@ -236,5 +236,4 @@ printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message); } - // End of File Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/sirrf.depend 2009-05-22 16:27:16 UTC (rev 38) @@ -989,7 +989,7 @@ <assert.h> "scriptstring.h" -1242998367 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp +1243004646 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp "DataStack.h" "GameManager.h" @@ -1012,14 +1012,14 @@ <SFML/System.hpp> <SFML/Audio.hpp> -1242570720 /home/michael/Programming/Projects/sirrf/src/core/DataStore.h +1243004416 /home/michael/Programming/Projects/sirrf/src/core/DataStore.h "../dependencies.h" "DataStack.h" -1242998012 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp +1243004577 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" -1242570624 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp +1243004664 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp "Entity.h" "GameManager.h" @@ -1031,21 +1031,22 @@ "../dependencies.h" "Entity.h" -1242844458 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp +1243004691 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" -1242998701 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp +1243004603 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp "EntityManager.h" + "GameManager.h" -1242570228 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h +1243004384 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h "../dependencies.h" "Entity.h" -1242998525 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1243005457 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" "../components/components.h" -1242995189 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h +1243005433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" "GameState.h" "DataStore.h" @@ -1055,14 +1056,14 @@ "../scripting/ScriptManager.h" "../components/components.h" -1241010257 /home/michael/Programming/Projects/sirrf/src/core/GameState.h +1243006017 /home/michael/Programming/Projects/sirrf/src/core/GameState.h "GameManager.h" 1241010330 /home/michael/Programming/Projects/sirrf/src/core/ScriptManager.h "../dependencies.h" "../angelscript/add_on/scriptstring/scriptstring.h" -1241206653 source:/home/michael/Programming/Projects/sirrf/src/core/GameState.cpp +1243006017 source:/home/michael/Programming/Projects/sirrf/src/core/GameState.cpp "GameState.h" 1241017939 source:/home/michael/Programming/Projects/sirrf/src/core/ScriptManager.cpp @@ -1074,10 +1075,10 @@ 1240939945 source:/home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.cpp -1242998050 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp +1243004860 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp "EventManager.h" -1241450474 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h +1243004790 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h "../dependencies.h" 1240941730 /home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.h @@ -1095,7 +1096,7 @@ <windows.h> <pthread.h> -1242936652 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h +1243004124 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h "../dependencies.h" "scriptstring.h" "Script.h" @@ -1104,7 +1105,7 @@ <angelscript.h> <string> -1242998145 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp +1243005889 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp "ScriptManager.h" "../core/GameManager.h" @@ -1246,11 +1247,11 @@ 1216759683 /usr/local/include//AL/alc.h -1242997995 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp +1243004975 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp "SoundManager.h" "../core/GameManager.h" -1242843356 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h +1243004900 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h "../dependencies.h" 1242308358 /usr/local/include//SFML/System.hpp Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/sirrf.layout 2009-05-22 16:27:16 UTC (rev 38) @@ -89,69 +89,75 @@ <Cursor position="1118" topLine="16" /> </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> - <Cursor position="980" topLine="0" /> + <Cursor position="5171" topLine="225" /> </File> <File name="core/DataStack.h" open="0" top="0" tabpos="1"> <Cursor position="1097" topLine="14" /> </File> <File name="core/DataStore.cpp" open="0" top="0" tabpos="0"> - <Cursor position="290" topLine="0" /> + <Cursor position="1907" topLine="54" /> </File> <File name="core/DataStore.h" open="0" top="0" tabpos="0"> - <Cursor position="1234" topLine="18" /> + <Cursor position="990" topLine="18" /> </File> <File name="core/Entity.cpp" open="0" top="0" tabpos="3"> - <Cursor position="632" topLine="0" /> + <Cursor position="1479" topLine="0" /> </File> <File name="core/Entity.h" open="0" top="0" tabpos="4"> - <Cursor position="1091" topLine="28" /> + <Cursor position="950" topLine="13" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3849" topLine="6" /> + <Cursor position="2460" topLine="0" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1560" topLine="23" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2566" topLine="97" /> + <Cursor position="1112" topLine="18" /> </File> <File name="core/EntityManager.h" open="0" top="0" tabpos="0"> - <Cursor position="1402" topLine="20" /> + <Cursor position="974" topLine="20" /> </File> <File name="core/EventManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="193" topLine="0" /> + <Cursor position="6002" topLine="0" /> </File> + <File name="core/EventManager.h" open="0" top="0" tabpos="0"> + <Cursor position="1006" topLine="3" /> + </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="1910" topLine="43" /> + <Cursor position="2037" topLine="43" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> - <Cursor position="928" topLine="0" /> + <Cursor position="1072" topLine="27" /> </File> <File name="core/GameState.cpp" open="0" top="0" tabpos="0"> - <Cursor position="190" topLine="0" /> + <Cursor position="1619" topLine="38" /> </File> + <File name="core/GameState.h" open="0" top="0" tabpos="0"> + <Cursor position="1017" topLine="4" /> + </File> <File name="dependencies.h" open="0" top="0" tabpos="0"> <Cursor position="0" topLine="15" /> </File> <File name="main.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1645" topLine="0" /> + <Cursor position="1727" topLine="8" /> </File> <File name="scripting/Script.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3422" topLine="93" /> + <Cursor position="2283" topLine="101" /> </File> <File name="scripting/Script.h" open="0" top="0" tabpos="0"> <Cursor position="1075" topLine="15" /> </File> <File name="scripting/ScriptManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="3209" topLine="80" /> + <Cursor position="1298" topLine="22" /> </File> <File name="scripting/ScriptManager.h" open="0" top="0" tabpos="1"> - <Cursor position="1184" topLine="10" /> + <Cursor position="1616" topLine="23" /> </File> <File name="sound/SoundManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="2397" topLine="57" /> + <Cursor position="4563" topLine="0" /> </File> <File name="sound/SoundManager.h" open="0" top="0" tabpos="2"> - <Cursor position="1245" topLine="12" /> + <Cursor position="949" topLine="12" /> </File> </CodeBlocks_layout_file> Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/sound/SoundManager.cpp 2009-05-22 16:27:16 UTC (rev 38) @@ -43,6 +43,18 @@ removeAll(); } +// Angelscript: Increases the reference counter. +void SoundManager::refAdd() +{ + // Dummy function. +} + +// Angelscript: Decreases the reference counter. +void SoundManager::refRelease() +{ + // Dummy function. +} + // Gets the current global volume of all sounds. f32 SoundManager::getGlobalVolume() const { @@ -143,8 +155,14 @@ int r; // Bind SoundManager class. - r = engine->RegisterObjectType("SoundManager", sizeof(SoundManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); + r = engine->RegisterObjectType("SoundManager", sizeof(SoundManager), asOBJ_REF); assert(r >= 0); + // Set SoundManager behaviour. + r = engine->RegisterObjectBehaviour("SoundManager", asBEHAVE_ADDREF, "void f()", + asMETHOD(SoundManager, refAdd), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectBehaviour("SoundManager", asBEHAVE_RELEASE, "void f()", + asMETHOD(SoundManager, refRelease), asCALL_THISCALL); assert(r >= 0); + // Bind SoundManager class functions. r = engine->RegisterObjectMethod("SoundManager", "void init()", asMETHOD(SoundManager, init), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/sound/SoundManager.h =================================================================== --- trunk/src/sound/SoundManager.h 2009-05-22 13:36:32 UTC (rev 37) +++ trunk/src/sound/SoundManager.h 2009-05-22 16:27:16 UTC (rev 38) @@ -32,6 +32,10 @@ void init(); void clear(); + // AngelScript binding + void refAdd(); + void refRelease(); + // Methods f32 getGlobalVolume() const; sf::SoundBuffer* getSoundBuffer(const std::string &fileName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-22 14:14:42
|
Revision: 37 http://sirrf.svn.sourceforge.net/sirrf/?rev=37&view=rev Author: zccdark203 Date: 2009-05-22 13:36:32 +0000 (Fri, 22 May 2009) Log Message: ----------- The first batch of classes that have been exposed in the right way to AngelScript. I might decide to drop the asOBJ_NOHANDLE flag though, because this prevents EntityManager, etc from having those useful handles. Modified Paths: -------------- trunk/src/core/DataStore.cpp trunk/src/core/EntityManager.cpp trunk/src/core/EventManager.cpp trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/scripting/Script.cpp trunk/src/scripting/ScriptManager.cpp trunk/src/sirrf.depend trunk/src/sound/SoundManager.cpp Modified: trunk/src/core/DataStore.cpp =================================================================== --- trunk/src/core/DataStore.cpp 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/core/DataStore.cpp 2009-05-22 13:36:32 UTC (rev 37) @@ -186,7 +186,7 @@ int r; // Bind DataStore class. - r = engine->RegisterObjectType("DataStore", sizeof(DataStore), asOBJ_REF); assert(r >= 0); + r = engine->RegisterObjectType("DataStore", sizeof(DataStore), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); // Bind DataStore class functions. r = engine->RegisterObjectMethod("DataStore", "void init()", Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/core/EntityManager.cpp 2009-05-22 13:36:32 UTC (rev 37) @@ -69,6 +69,7 @@ // Add the entity. Entity *entity = new Entity(name, parent); + entity->refAdd(); mEntities.push_back(entity); return entity; } @@ -184,7 +185,7 @@ int r; // Bind EntityManager class. - r = engine->RegisterObjectType("EntityManager", sizeof(EntityManager), asOBJ_REF); assert(r >= 0); + r = engine->RegisterObjectType("EntityManager", sizeof(EntityManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); // Bind EntityManager class functions. r = engine->RegisterObjectMethod("EntityManager", "void init()", @@ -196,6 +197,8 @@ asMETHOD(EntityManager, addEntity), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &name)", asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("EntityManager", "Entity@ createEntity(const string &name, Entity @parent)", + asMETHOD(EntityManager, createEntity), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("EntityManager", "Entity@ getEntity(const int id)", asMETHODPR(EntityManager, getEntity, (const u32), Entity*), Modified: trunk/src/core/EventManager.cpp =================================================================== --- trunk/src/core/EventManager.cpp 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/core/EventManager.cpp 2009-05-22 13:36:32 UTC (rev 37) @@ -201,7 +201,7 @@ asMETHOD(sigslot::has_slots<>, disconnect_all), asCALL_THISCALL); assert(r >= 0); // Bind EventManager class. - r = engine->RegisterObjectType("EventManager", sizeof(EventManager), asOBJ_REF); assert(r >= 0); + r = engine->RegisterObjectType("EventManager", sizeof(EventManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); // Bind EventManager class functions. r = engine->RegisterObjectMethod("EventManager", "void init()", Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/core/GameManager.cpp 2009-05-22 13:36:32 UTC (rev 37) @@ -44,6 +44,14 @@ return pInstance; } +GameManager& GameManager::Reference() +{ + if(pInstance == 0) + pInstance = new GameManager(); + + return *pInstance; +} + // Initialises the Game Manager. void GameManager::init() { @@ -257,10 +265,13 @@ int r; // Bind GameManager class. - r = engine->RegisterObjectType("GameManager", sizeof(GameManager), asOBJ_REF); assert(r >= 0); + r = engine->RegisterObjectType("GameManager", sizeof(GameManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); // Bind GameManager class functions. - r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @state)", + r = engine->RegisterGlobalFunction("GameManager& getGameManager()", asFUNCTION(GameManager::Instance), + asCALL_CDECL); assert( r >= 0 ); + + /*r = engine->RegisterObjectMethod("GameManager", "void changeState(GameState @state)", asMETHODPR(GameManager, changeState, (GameState*), void), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void changeState(const string &fileName)", @@ -273,15 +284,15 @@ asMETHODPR(GameManager, pushState, (const std::string&), void), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "void popState()", - asMETHOD(GameManager, popState), asCALL_THISCALL); assert(r >= 0); + asMETHOD(GameManager, popState), asCALL_THISCALL); assert(r >= 0);*/ - r = engine->RegisterObjectMethod("GameManager", "DataStore@ getDataStore()", + r = engine->RegisterObjectMethod("GameManager", "DataStore& getDataStore()", asMETHOD(GameManager, getDataStore), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "EntityManager@ getEntityManager()", + r = engine->RegisterObjectMethod("GameManager", "EntityManager& getEntityManager()", asMETHOD(GameManager, getEntityManager), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "EventManager@ getEventManager()", + r = engine->RegisterObjectMethod("GameManager", "EventManager& getEventManager()", asMETHOD(GameManager, getEventManager), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("GameManager", "SoundManager@ getSoundManager()", + r = engine->RegisterObjectMethod("GameManager", "SoundManager& getSoundManager()", asMETHOD(GameManager, getSoundManager), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "bool getIsRunning()", Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/core/GameManager.h 2009-05-22 13:36:32 UTC (rev 37) @@ -41,6 +41,7 @@ ~GameManager(); static GameManager* Instance(); + static GameManager& Reference(); void init(); void update(); Modified: trunk/src/scripting/Script.cpp =================================================================== --- trunk/src/scripting/Script.cpp 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/scripting/Script.cpp 2009-05-22 13:36:32 UTC (rev 37) @@ -71,7 +71,7 @@ bool Script::initScript(const std::string &args) { // Do we have a module? - if(mModule != NULL) + if(mModule == NULL) return false; // Get the ID of the main function. Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/scripting/ScriptManager.cpp 2009-05-22 13:36:32 UTC (rev 37) @@ -42,7 +42,7 @@ pEngine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); // Register classes and functions. - bindGameState(pEngine); + //bindGameState(pEngine); bindEntity(pEngine); bindEntityComponent(pEngine); bindComponents(pEngine); Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/sirrf.depend 2009-05-22 13:36:32 UTC (rev 37) @@ -989,7 +989,7 @@ <assert.h> "scriptstring.h" -1242846547 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp +1242998367 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp "DataStack.h" "GameManager.h" @@ -1016,7 +1016,7 @@ "../dependencies.h" "DataStack.h" -1242846515 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp +1242998012 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" 1242570624 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp @@ -1034,18 +1034,18 @@ 1242844458 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" -1242843474 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp +1242998701 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp "EntityManager.h" 1242570228 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h "../dependencies.h" "Entity.h" -1242936521 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242998525 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" "../components/components.h" -1242934406 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h +1242995189 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" "GameState.h" "DataStore.h" @@ -1069,12 +1069,12 @@ "ScriptManager.h" "GameManager.h" -1241449240 source:/home/michael/Programming/Projects/sirrf/src/main.cpp +1242995529 source:/home/michael/Programming/Projects/sirrf/src/main.cpp "core/GameManager.h" 1240939945 source:/home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.cpp -1242233674 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp +1242998050 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp "EventManager.h" 1241450474 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h @@ -1104,7 +1104,7 @@ <angelscript.h> <string> -1242936652 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp +1242998145 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp "ScriptManager.h" "../core/GameManager.h" @@ -1246,7 +1246,7 @@ 1216759683 /usr/local/include//AL/alc.h -1242936719 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp +1242997995 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp "SoundManager.h" "../core/GameManager.h" @@ -2353,7 +2353,7 @@ 1242845081 source:/home/michael/Programming/Projects/sirrf/src/components/components.cpp "components.h" -1242935951 source:/home/michael/Programming/Projects/sirrf/src/scripting/Script.cpp +1242996572 source:/home/michael/Programming/Projects/sirrf/src/scripting/Script.cpp "Script.h" "../core/GameManager.h" Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-05-21 20:24:05 UTC (rev 36) +++ trunk/src/sound/SoundManager.cpp 2009-05-22 13:36:32 UTC (rev 37) @@ -143,7 +143,7 @@ int r; // Bind SoundManager class. - r = engine->RegisterObjectType("SoundManager", sizeof(SoundManager), asOBJ_REF); assert(r >= 0); + r = engine->RegisterObjectType("SoundManager", sizeof(SoundManager), asOBJ_REF | asOBJ_NOHANDLE); assert(r >= 0); // Bind SoundManager class functions. r = engine->RegisterObjectMethod("SoundManager", "void init()", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-21 20:24:19
|
Revision: 36 http://sirrf.svn.sourceforge.net/sirrf/?rev=36&view=rev Author: zccdark203 Date: 2009-05-21 20:24:05 +0000 (Thu, 21 May 2009) Log Message: ----------- AngelScript can now be loaded via the ScriptManager class and the Script class. In the current implementation scripts must be loaded with Script::loadScript(...). After that the script should be initiliased with Script::initScript(...), which calls the main-function in the script. I figured out that end-users probably have no interest in calling directly functions from scripts. Furthermore this approach is much more easier technically as well. All that remains now is fixing all those classes that AngelScript is complaining about. That should be the next objective. By the way, for those who're tracking this project, today Laconia has been added to Sirrf's SF.net page. It should give even more actual information about Sirrf. Modified Paths: -------------- trunk/src/core/DataStack.cpp trunk/src/core/DataStore.cpp trunk/src/core/GameManager.h trunk/src/scripting/ScriptManager.cpp trunk/src/scripting/ScriptManager.h trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout trunk/src/sound/SoundManager.cpp Added Paths: ----------- trunk/src/scripting/Script.cpp trunk/src/scripting/Script.h Modified: trunk/src/core/DataStack.cpp =================================================================== --- trunk/src/core/DataStack.cpp 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/core/DataStack.cpp 2009-05-21 20:24:05 UTC (rev 36) @@ -3,7 +3,10 @@ // Name: DataStack.cpp // Author: Michael Bartsch (ZCCdark203) // -// Desc : +// Desc : DataStacks provide an interface for storing (and removing) +// variables that can be accessed from anywhere within the +// framework. Furthermore it's also possible to save these +// variables into files. // // License: Copyright (C) 2009 Michael Bartsch // Modified: trunk/src/core/DataStore.cpp =================================================================== --- trunk/src/core/DataStore.cpp 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/core/DataStore.cpp 2009-05-21 20:24:05 UTC (rev 36) @@ -3,7 +3,8 @@ // Name: DataStore.cpp // Author: Michael Bartsch (ZCCdark203) // -// Desc : +// Desc : The DataStore class manages the DataStacks that are being +// used by the framework. // // License: Copyright (C) 2009 Michael Bartsch // Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/core/GameManager.h 2009-05-21 20:24:05 UTC (rev 36) @@ -25,6 +25,7 @@ #include "EventManager.h" #include "../sound/SoundManager.h" #include "../scripting/ScriptManager.h" +#include "../components/components.h" // Forward declarations class GameState; Added: trunk/src/scripting/Script.cpp =================================================================== --- trunk/src/scripting/Script.cpp (rev 0) +++ trunk/src/scripting/Script.cpp 2009-05-21 20:24:05 UTC (rev 36) @@ -0,0 +1,159 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: Script.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : The Script class is technically a wrapper for every +// AngelScript file that is loaded by the framework. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "Script.h" +#include "../core/GameManager.h" + + +// Script class +// Static variables. +u32 Script::mIDCount = 0; + +// Constructor of the Script class. +Script::Script(const std::string &name) +: mName(name), mModule(NULL) +{ + mID = mIDCount++; + + // Get a pointer to the Script Manager. + ScriptManager *scriptMgr = GameManager::Instance()->getScriptManager(); + + // Create a script context. + mContext = scriptMgr->getEngine()->CreateContext(); +} + +// Deconstructor of the Script class. +Script::~Script() +{ + // Get a pointer to the Script Manager. + ScriptManager *scriptMgr = GameManager::Instance()->getScriptManager(); + + // Clean up. + if(mModule != NULL) + scriptMgr->getEngine()->DiscardModule(mName.c_str()); + + mContext->Release(); +} + +// Gets the ID of this script. +unsigned int Script::getID() const +{ + return mID; +} + +// Gets the name of this script. +const std::string& Script::getName() const +{ + return mName; +} + +// Gets the AngelScript module associated with this Script object. +asIScriptModule* Script::getModule() const +{ + return mModule; +} + +// Initialises the script by calling the "main" function. +bool Script::initScript(const std::string &args) +{ + // Do we have a module? + if(mModule != NULL) + return false; + + // Get the ID of the main function. + int functionID = mModule->GetFunctionIdByDecl("void main(const string &args)"); + + if(functionID == asERROR || functionID == asMULTIPLE_FUNCTIONS || functionID == asNO_FUNCTION) + return false; + + // Prepare the function. + mContext->Prepare(functionID); + + std::string arguments = args; + mContext->SetArgAddress(0, &arguments); + + // Execute the function. + int r = mContext->Execute(); + if(r == asEXECUTION_FINISHED) + { + return true; + } + + else return false; +} + +// Loads a script file and builds it. +bool Script::loadScript(const std::string &fileName) +{ + // Get pointers to sub-systems of the Game Manager and Irrlicht. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + ScriptManager *scriptMgr = GameManager::Instance()->getScriptManager(); + + // Reset previous data. + if(mModule != NULL) + { + scriptMgr->getEngine()->DiscardModule(mName.c_str()); + mModule = NULL; + } + + // Does the file exist? + if(!fileSystem->existFile(fileName.c_str())) + return false; + + // Create the module. + mModule = scriptMgr->getEngine()->GetModule(mName.c_str(), asGM_ALWAYS_CREATE); + + // Open the given file and load the contents to the buffer. + IReadFile *file = fileSystem->createAndOpenFile(fileName.c_str()); + + long bufferSize = file->getSize(); + c8 * buffer = new c8[bufferSize+1]; + memset(buffer, 0, bufferSize+1); + + file->read(buffer, bufferSize); + file->drop(); + + // Add a script section to the earlier created module. + mModule->AddScriptSection("main", buffer); + + // Build the script. + int r = mModule->Build(); + if(r < 0) + return false; + + // Clean up. + delete[] buffer; + + return true; +} + +// Unloads the loaded script. +bool Script::unloadScript() +{ + ScriptManager *scriptMgr = GameManager::Instance()->getScriptManager(); + + if(mModule != NULL) + { + scriptMgr->getEngine()->DiscardModule(mName.c_str()); + mModule = NULL; + return true; + } + + return false; +} + +// End of File Added: trunk/src/scripting/Script.h =================================================================== --- trunk/src/scripting/Script.h (rev 0) +++ trunk/src/scripting/Script.h 2009-05-21 20:24:05 UTC (rev 36) @@ -0,0 +1,61 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: Script.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the Script class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __SCRIPT_INCLUDED__ +#define __SCRIPT_INCLUDED__ + +// Include files +#include "../dependencies.h" +#include "ScriptManager.h" + +// Forward declarations. +class ScriptManager; + + +// Script class +class Script +{ +public: + + Script(const std::string &name); + ~Script(); + + // Methods + u32 getID() const; + const std::string& getName() const; + + asIScriptContext* getContext() const; + asIScriptModule* getModule() const; + + bool initScript(const std::string &args = ""); + bool loadScript(const std::string &fileName); + bool unloadScript(); + +private: + + // Static members + static u32 mIDCount; + + // Private members + u32 mID; + std::string mName; + + asIScriptModule *mModule; + asIScriptContext *mContext; + +}; + +#endif + Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/scripting/ScriptManager.cpp 2009-05-21 20:24:05 UTC (rev 36) @@ -17,7 +17,6 @@ // Include files #include "ScriptManager.h" #include "../core/GameManager.h" -#include "../components/components.h" // ScriptManager class @@ -38,7 +37,9 @@ { // Initialise the AngelScript engine. pEngine = asCreateScriptEngine(ANGELSCRIPT_VERSION); + RegisterScriptString(pEngine); + pEngine->SetMessageCallback(asFUNCTION(MessageCallback), 0, asCALL_CDECL); // Register classes and functions. bindGameState(pEngine); @@ -56,8 +57,184 @@ // Clears the Script Manager. void ScriptManager::clear() { + // Remove scripts. + removeAll(); + // Deinitialise the AngelScript engine. pEngine->Release(); } +// Gets the AngelScript engine. +asIScriptEngine* ScriptManager::getEngine() const +{ + return pEngine; +} + +// Adds an script to the Entity Manager. +bool ScriptManager::addScript(Script *script) +{ + // Did we get a valid pointer? + if(script == NULL) + return false; + + // Look if a script with given name doesn't already exist. + if(getScript(script->getName())) + return false; + + // Add the script. + mScripts.push_back(script); + + return true; +} + +// Creates an script with the given name and adds it to the Script Manager. +Script* ScriptManager::createScript(const std::string &name) +{ + // Look if a script with given name doesn't already exist. + if(getScript(name)) + return NULL; + + // Add the script. + Script *script = new Script(name); + mScripts.push_back(script); + return script; +} + +// Creates an script with the given name and adds it to the Script Manager. +Script* ScriptManager::createScriptFromFile(const std::string &fileName) +{ + // Get pointer to the File System of Irrlicht. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Retrieve base name. + std::string fileBase = (fileSystem->getFileBasename(fileName.c_str())).c_str(); + + // Look if a script with given name doesn't already exist. + if(getScript(fileBase)) + return NULL; + + // Add the script. + Script *script = new Script(fileBase); + script->loadScript(fileName); + mScripts.push_back(script); + return script; +} + +// Gets the script with the given ID. +Script* ScriptManager::getScript(const u32 id) +{ + for(u32 i = 0; i < mScripts.size(); i++) + { + if(mScripts[i]->getID() == id) + return mScripts[i]; + } + + return NULL; +} + +// Gets the script with the given name. +Script* ScriptManager::getScript(const std::string &name) +{ + for(u32 i = 0; i < mScripts.size(); i++) + { + if(mScripts[i]->getName() == name) + return mScripts[i]; + } + + return NULL; +} + +// Removes all scripts. +void ScriptManager::removeAll() +{ + for(u32 i = 0; i < mScripts.size(); i++) + delete mScripts[i]; + + mScripts.clear(); +} + +// Removes the given script. +bool ScriptManager::removeScript(Script *script) +{ + // Did we get a valid pointer? + if(script == NULL) + return false; + + // Try to remove the script. + vector<Script*>::iterator it; + + for(it = mScripts.begin(); it < mScripts.end(); it++) + { + Script *scr = *it; + + if(scr == script) + { + delete scr; + mScripts.erase(it); + return true; + } + } + + // We couldn't find the script and thus couldn't remove it. + return false; +} + +// Removes the script with the given ID. +bool ScriptManager::removeScript(const u32 id) +{ + // Try to remove the script. + vector<Script*>::iterator it; + + for(it = mScripts.begin(); it < mScripts.end(); it++) + { + Script *scr = *it; + + if(scr->getID() == id) + { + delete scr; + mScripts.erase(it); + return true; + } + } + + // We couldn't find the script and thus couldn't remove it. + return false; +} + +// Removes the script with the given name. +bool ScriptManager::removeScript(const std::string &name) +{ + // Try to remove the script. + vector<Script*>::iterator it; + + for(it = mScripts.begin(); it < mScripts.end(); it++) + { + Script *scr = *it; + + if(scr->getName() == name) + { + delete scr; + mScripts.erase(it); + return true; + } + } + + // We couldn't find the script and thus couldn't remove it. + return false; +} + + +// AngelScript functions +// Implement a simple message callback function +void MessageCallback(const asSMessageInfo *msg, void *param) +{ + const char *type = "ERR "; + if(msg->type == asMSGTYPE_WARNING) + type = "WARN"; + else if(msg->type == asMSGTYPE_INFORMATION) + type = "INFO"; + printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message); +} + + // End of File Modified: trunk/src/scripting/ScriptManager.h =================================================================== --- trunk/src/scripting/ScriptManager.h 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/scripting/ScriptManager.h 2009-05-21 20:24:05 UTC (rev 36) @@ -20,7 +20,12 @@ #include "../dependencies.h" #include "scriptstring.h" // Standard Angelscript add-on. +#include "Script.h" +// Forward declarations. +class Script; + + // ScriptManager class class ScriptManager { @@ -32,9 +37,30 @@ void init(); void clear(); + // Methods + asIScriptEngine* getEngine() const; + + bool addScript(Script *script); + Script* createScript(const std::string &name); + Script* createScriptFromFile(const std::string &fileName); + + Script* getScript(const u32 id); + Script* getScript(const std::string &name); + + void removeAll(); + bool removeScript(Script *script); + bool removeScript(const u32 id); + bool removeScript(const std::string &name); + private: + // Private members asIScriptEngine *pEngine; + + std::vector<Script*> mScripts; }; +// AngelScript functions +extern void MessageCallback(const asSMessageInfo *msg, void *param); + #endif Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/sirrf.cbp 2009-05-21 20:24:05 UTC (rev 36) @@ -104,6 +104,8 @@ <Unit filename="core/GameState.h" /> <Unit filename="dependencies.h" /> <Unit filename="main.cpp" /> + <Unit filename="scripting/Script.cpp" /> + <Unit filename="scripting/Script.h" /> <Unit filename="scripting/ScriptManager.cpp" /> <Unit filename="scripting/ScriptManager.h" /> <Unit filename="scripting/scriptstring.cpp" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/sirrf.depend 2009-05-21 20:24:05 UTC (rev 36) @@ -989,7 +989,7 @@ <assert.h> "scriptstring.h" -1242570871 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp +1242846547 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp "DataStack.h" "GameManager.h" @@ -1016,7 +1016,7 @@ "../dependencies.h" "DataStack.h" -1242570720 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp +1242846515 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" 1242570624 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp @@ -1041,11 +1041,11 @@ "../dependencies.h" "Entity.h" -1242845230 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242936521 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" "../components/components.h" -1242308603 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h +1242934406 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" "GameState.h" "DataStore.h" @@ -1053,6 +1053,7 @@ "EventManager.h" "../sound/SoundManager.h" "../scripting/ScriptManager.h" + "../components/components.h" 1241010257 /home/michael/Programming/Projects/sirrf/src/core/GameState.h "GameManager.h" @@ -1094,18 +1095,18 @@ <windows.h> <pthread.h> -1242049253 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h +1242936652 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h "../dependencies.h" "scriptstring.h" + "Script.h" 1228771288 /home/michael/Programming/Projects/sirrf/src/vendor/angelscript/add_on/scriptstring/scriptstring.h <angelscript.h> <string> -1242845172 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp +1242936652 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp "ScriptManager.h" "../core/GameManager.h" - "../components/components.h" 1228771288 /home/michael/Programming/Projects/sirrf/src/scripting/scriptstring.h <angelscript.h> @@ -1245,7 +1246,7 @@ 1216759683 /usr/local/include//AL/alc.h -1242843655 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp +1242936719 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp "SoundManager.h" "../core/GameManager.h" @@ -1385,7 +1386,7 @@ <SFML/System/Thread.hpp> <vector> -1242844932 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp +1242845303 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp "SoundListenerComponent.h" "../../core/GameManager.h" @@ -2352,3 +2353,11 @@ 1242845081 source:/home/michael/Programming/Projects/sirrf/src/components/components.cpp "components.h" +1242935951 source:/home/michael/Programming/Projects/sirrf/src/scripting/Script.cpp + "Script.h" + "../core/GameManager.h" + +1242936783 /home/michael/Programming/Projects/sirrf/src/scripting/Script.h + "../dependencies.h" + "ScriptManager.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/sirrf.layout 2009-05-21 20:24:05 UTC (rev 36) @@ -35,7 +35,7 @@ <Cursor position="1475" topLine="9" /> </File> <File name="components/scene/OctTreeComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2701" topLine="32" /> + <Cursor position="197" topLine="0" /> </File> <File name="components/scene/OctTreeComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1115" topLine="0" /> @@ -53,13 +53,13 @@ <Cursor position="2553" topLine="25" /> </File> <File name="components/scene/SkyBoxComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1024" topLine="0" /> + <Cursor position="196" topLine="0" /> </File> <File name="components/scene/SkyBoxComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1036" topLine="0" /> </File> <File name="components/scene/SkyDomeComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1778" topLine="20" /> + <Cursor position="197" topLine="0" /> </File> <File name="components/scene/SkyDomeComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1223" topLine="0" /> @@ -89,46 +89,46 @@ <Cursor position="1118" topLine="16" /> </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1494" topLine="222" /> + <Cursor position="980" topLine="0" /> </File> <File name="core/DataStack.h" open="0" top="0" tabpos="1"> <Cursor position="1097" topLine="14" /> </File> <File name="core/DataStore.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3490" topLine="142" /> + <Cursor position="290" topLine="0" /> </File> <File name="core/DataStore.h" open="0" top="0" tabpos="0"> <Cursor position="1234" topLine="18" /> </File> <File name="core/Entity.cpp" open="0" top="0" tabpos="3"> - <Cursor position="657" topLine="0" /> + <Cursor position="632" topLine="0" /> </File> <File name="core/Entity.h" open="0" top="0" tabpos="4"> - <Cursor position="1098" topLine="49" /> + <Cursor position="1091" topLine="28" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3849" topLine="87" /> + <Cursor position="3849" topLine="6" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1560" topLine="26" /> + <Cursor position="1560" topLine="23" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3989" topLine="172" /> + <Cursor position="2566" topLine="97" /> </File> <File name="core/EntityManager.h" open="0" top="0" tabpos="0"> <Cursor position="1402" topLine="20" /> </File> <File name="core/EventManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="4881" topLine="154" /> + <Cursor position="193" topLine="0" /> </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="7817" topLine="0" /> + <Cursor position="1910" topLine="43" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> - <Cursor position="2271" topLine="0" /> + <Cursor position="928" topLine="0" /> </File> <File name="core/GameState.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1420" topLine="4" /> + <Cursor position="190" topLine="0" /> </File> <File name="dependencies.h" open="0" top="0" tabpos="0"> <Cursor position="0" topLine="15" /> @@ -136,14 +136,20 @@ <File name="main.cpp" open="0" top="0" tabpos="0"> <Cursor position="1645" topLine="0" /> </File> + <File name="scripting/Script.cpp" open="0" top="0" tabpos="0"> + <Cursor position="3422" topLine="93" /> + </File> + <File name="scripting/Script.h" open="0" top="0" tabpos="0"> + <Cursor position="1075" topLine="15" /> + </File> <File name="scripting/ScriptManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="802" topLine="12" /> + <Cursor position="3209" topLine="80" /> </File> <File name="scripting/ScriptManager.h" open="0" top="0" tabpos="1"> - <Cursor position="740" topLine="0" /> + <Cursor position="1184" topLine="10" /> </File> <File name="sound/SoundManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="5114" topLine="124" /> + <Cursor position="2397" topLine="57" /> </File> <File name="sound/SoundManager.h" open="0" top="0" tabpos="2"> <Cursor position="1245" topLine="12" /> Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-05-20 18:55:49 UTC (rev 35) +++ trunk/src/sound/SoundManager.cpp 2009-05-21 20:24:05 UTC (rev 36) @@ -82,6 +82,8 @@ long bufferSize = file->getSize(); c8 * buffer = new c8[bufferSize+1]; + memset(buffer, 0, bufferSize+1); + file->read(buffer, bufferSize); file->drop(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-20 18:55:59
|
Revision: 35 http://sirrf.svn.sourceforge.net/sirrf/?rev=35&view=rev Author: zccdark203 Date: 2009-05-20 18:55:49 +0000 (Wed, 20 May 2009) Log Message: ----------- SoundSourceComponent is now able to use SFML's sf::SoundBuffer. These buffers are in turn managed by the SoundManager. But please remember to only use sf::SoundBuffer for small sounds. I tested it with a .ogg file of about 6 Mb and I saw RAM-consumption jump to 110 Mb. For these kind of files it's better to use SoundSourceComponent::loadMusic. \n\n Besides that the SoundManager class has been exposed to AngelScript. I decided to postpone exposing SoundSourceComponent and SoundListenerComponent till I figure out how to deal with binding them efficiently, which I find quite important. Modified Paths: -------------- trunk/src/components/components.h trunk/src/components/sound/SoundListenerComponent.h trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h trunk/src/core/EntityManager.cpp trunk/src/core/GameManager.cpp trunk/src/scripting/ScriptManager.cpp trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Added Paths: ----------- trunk/src/components/components.cpp Added: trunk/src/components/components.cpp =================================================================== --- trunk/src/components/components.cpp (rev 0) +++ trunk/src/components/components.cpp 2009-05-20 18:55:49 UTC (rev 35) @@ -0,0 +1,25 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: components.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Control functions for derived EntityComponent classes. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// This program is free software: you can redistribute it +// and/or modify it under the terms of the zlib/libpng License. +// See main.cpp for conditions of distribution and use. +// +// ///////////////////////////////////////////////////////////////////////////// + +// Include files +#include "components.h" + + +// AngelScript binding +void bindComponents(asIScriptEngine *engine) +{ +} + +// End of File Modified: trunk/src/components/components.h =================================================================== --- trunk/src/components/components.h 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/components/components.h 2009-05-20 18:55:49 UTC (rev 35) @@ -16,6 +16,7 @@ #ifndef __COMPONENTS_H__ #define __COMPONENTS_H__ +// Include files // Scene #include "scene/SceneComponent.h" #include "scene/AnimatedMeshComponent.h" @@ -34,5 +35,9 @@ #include "sound/SoundListenerComponent.h" #include "sound/SoundSourceComponent.h" + +// AngelScript binding +extern void bindComponents(asIScriptEngine *engine); + #endif Modified: trunk/src/components/sound/SoundListenerComponent.h =================================================================== --- trunk/src/components/sound/SoundListenerComponent.h 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/components/sound/SoundListenerComponent.h 2009-05-20 18:55:49 UTC (rev 35) @@ -53,4 +53,3 @@ }; #endif - Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-20 18:55:49 UTC (rev 35) @@ -93,7 +93,7 @@ file->drop(); // Create SFML's music object. - mMusic= new sf::Music(); + mMusic = new sf::Music(); mMusic->OpenFromMemory(mBuffer, mBufferSize); // Initialize variables. @@ -107,6 +107,53 @@ return true; } +// Loads the sound data from a sound buffer. +bool SoundSourceComponent::loadSoundBuffer(const std::string &bufferName) +{ + // Delete the previous data. + if(mSound != NULL) + { + delete mSound; + mSound = NULL; + } + + if(mMusic != NULL) + { + delete mMusic; + mMusic = NULL; + } + + if(mBuffer != NULL) + { + delete[] mBuffer; + mBuffer = NULL; + mBufferSize = 0; + } + + // Set new data. + mSound = new sf::Sound(); + + sf::SoundBuffer *soundBuffer = GameManager::Instance()->getSoundManager()->getSoundBuffer(bufferName); + if(soundBuffer == NULL) + { + delete mSound; + mSound = NULL; + return false; + } + + mSound->SetBuffer(*soundBuffer); + std::cout << mSound->GetBuffer()->GetDuration() << "\n"; + + mSound->SetAttenuation(mAttenuation); + mSound->SetLoop(mLoop); + mSound->SetMinDistance(mMinDistance); + mSound->SetPitch(mPitch); + mSound->SetPosition(mPosition.X, mPosition.Y, mPosition.Z); + mSound->SetVolume(mVolume); + + return true; +} + // Plays the associated sound. void SoundSourceComponent::play() { Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-05-20 18:55:49 UTC (rev 35) @@ -35,7 +35,7 @@ sf::Music* getMusic(); bool loadMusic(const std::string &fileName); - void loadSoundBuffer(const std::string &bufferName); + bool loadSoundBuffer(const std::string &bufferName); void play(); void pause(); Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/core/EntityManager.cpp 2009-05-20 18:55:49 UTC (rev 35) @@ -176,6 +176,7 @@ return false; } + // EntityManager Angelscript binding. void bindEntityManager(asIScriptEngine *engine) { Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/core/GameManager.cpp 2009-05-20 18:55:49 UTC (rev 35) @@ -18,8 +18,8 @@ // Include files #include "GameManager.h" +#include "../components/components.h" - // GameManager class // Constructor of the GameManager class. GameManager::GameManager() @@ -279,6 +279,10 @@ asMETHOD(GameManager, getDataStore), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "EntityManager@ getEntityManager()", asMETHOD(GameManager, getEntityManager), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("GameManager", "EventManager@ getEventManager()", + asMETHOD(GameManager, getEventManager), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("GameManager", "SoundManager@ getSoundManager()", + asMETHOD(GameManager, getSoundManager), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("GameManager", "bool getIsRunning()", asMETHOD(GameManager, getIsRunning), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/scripting/ScriptManager.cpp =================================================================== --- trunk/src/scripting/ScriptManager.cpp 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/scripting/ScriptManager.cpp 2009-05-20 18:55:49 UTC (rev 35) @@ -17,6 +17,7 @@ // Include files #include "ScriptManager.h" #include "../core/GameManager.h" +#include "../components/components.h" // ScriptManager class @@ -43,10 +44,12 @@ bindGameState(pEngine); bindEntity(pEngine); bindEntityComponent(pEngine); + bindComponents(pEngine); bindEntityManager(pEngine); bindEventManager(pEngine); bindDataStack(pEngine); bindDataStore(pEngine); + bindSoundManager(pEngine); bindGameManager(pEngine); } Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/sirrf.cbp 2009-05-20 18:55:49 UTC (rev 35) @@ -56,6 +56,7 @@ <Add option="-Wall" /> <Add directory="vendor" /> </Compiler> + <Unit filename="components/components.cpp" /> <Unit filename="components/components.h" /> <Unit filename="components/scene/AnimatedMeshComponent.cpp" /> <Unit filename="components/scene/AnimatedMeshComponent.h" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/sirrf.depend 2009-05-20 18:55:49 UTC (rev 35) @@ -1027,21 +1027,21 @@ "../dependencies.h" "EntityComponent.h" -1242570430 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h +1242844453 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h "../dependencies.h" "Entity.h" -1242570351 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp +1242844458 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" -1242570289 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp +1242843474 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp "EntityManager.h" 1242570228 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h "../dependencies.h" "Entity.h" -1242763596 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242845230 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" "../components/components.h" @@ -1102,9 +1102,10 @@ <angelscript.h> <string> -1242049235 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp +1242845172 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp "ScriptManager.h" "../core/GameManager.h" + "../components/components.h" 1228771288 /home/michael/Programming/Projects/sirrf/src/scripting/scriptstring.h <angelscript.h> @@ -1244,10 +1245,11 @@ 1216759683 /usr/local/include//AL/alc.h -1242569994 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp +1242843655 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp "SoundManager.h" + "../core/GameManager.h" -1242569980 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h +1242843356 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h "../dependencies.h" 1242308358 /usr/local/include//SFML/System.hpp @@ -1383,11 +1385,11 @@ <SFML/System/Thread.hpp> <vector> -1242764227 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp +1242844932 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp "SoundListenerComponent.h" "../../core/GameManager.h" -1242412327 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.h +1242845296 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -2317,11 +2319,11 @@ "matrix4.h" "IVideoDriver.h" -1242764287 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp +1242842908 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp "SoundSourceComponent.h" "../../core/GameManager.h" -1242764287 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.h +1242842334 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -2331,7 +2333,7 @@ 1242564474 /home/michael/Programming/Projects/sirrf/src/sound/SoundStream.h "../dependencies.h" -1242570986 /home/michael/Programming/Projects/sirrf/src/components/components.h +1242845012 /home/michael/Programming/Projects/sirrf/src/components/components.h "scene/SceneComponent.h" "scene/AnimatedMeshComponent.h" "scene/BillboardComponent.h" @@ -2347,3 +2349,6 @@ "sound/SoundListenerComponent.h" "sound/SoundSourceComponent.h" +1242845081 source:/home/michael/Programming/Projects/sirrf/src/components/components.cpp + "components.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/sirrf.layout 2009-05-20 18:55:49 UTC (rev 35) @@ -1,14 +1,14 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> - <File name="components/components.h" open="0" top="0" tabpos="0"> - <Cursor position="1185" topLine="0" /> + <File name="components/components.cpp" open="0" top="0" tabpos="0"> + <Cursor position="662" topLine="0" /> </File> <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="5"> <Cursor position="6902" topLine="51" /> </File> <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="6"> - <Cursor position="2349" topLine="16" /> + <Cursor position="2349" topLine="19" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1983" topLine="0" /> @@ -77,25 +77,25 @@ <Cursor position="0" topLine="11" /> </File> <File name="components/sound/SoundListenerComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2702" topLine="62" /> + <Cursor position="1749" topLine="20" /> </File> <File name="components/sound/SoundListenerComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1224" topLine="12" /> + <Cursor position="1035" topLine="12" /> </File> <File name="components/sound/SoundSourceComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="7244" topLine="0" /> + <Cursor position="3866" topLine="168" /> </File> <File name="components/sound/SoundSourceComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1742" topLine="22" /> + <Cursor position="1118" topLine="16" /> </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1494" topLine="0" /> + <Cursor position="1494" topLine="222" /> </File> <File name="core/DataStack.h" open="0" top="0" tabpos="1"> <Cursor position="1097" topLine="14" /> </File> <File name="core/DataStore.cpp" open="0" top="0" tabpos="0"> - <Cursor position="6063" topLine="178" /> + <Cursor position="3490" topLine="142" /> </File> <File name="core/DataStore.h" open="0" top="0" tabpos="0"> <Cursor position="1234" topLine="18" /> @@ -107,48 +107,45 @@ <Cursor position="1098" topLine="49" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="658" topLine="0" /> + <Cursor position="3849" topLine="87" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1400" topLine="26" /> + <Cursor position="1560" topLine="26" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="6192" topLine="175" /> + <Cursor position="3989" topLine="172" /> </File> <File name="core/EntityManager.h" open="0" top="0" tabpos="0"> - <Cursor position="1131" topLine="20" /> + <Cursor position="1402" topLine="20" /> </File> <File name="core/EventManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="4881" topLine="186" /> + <Cursor position="4881" topLine="154" /> </File> - <File name="core/EventManager.h" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="68" /> - </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="860" topLine="27" /> + <Cursor position="7817" topLine="0" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> - <Cursor position="891" topLine="14" /> + <Cursor position="2271" topLine="0" /> </File> <File name="core/GameState.cpp" open="0" top="0" tabpos="0"> <Cursor position="1420" topLine="4" /> </File> <File name="dependencies.h" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="13" /> + <Cursor position="0" topLine="15" /> </File> <File name="main.cpp" open="0" top="0" tabpos="0"> <Cursor position="1645" topLine="0" /> </File> <File name="scripting/ScriptManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="1151" topLine="17" /> + <Cursor position="802" topLine="12" /> </File> <File name="scripting/ScriptManager.h" open="0" top="0" tabpos="1"> <Cursor position="740" topLine="0" /> </File> <File name="sound/SoundManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="1251" topLine="13" /> + <Cursor position="5114" topLine="124" /> </File> <File name="sound/SoundManager.h" open="0" top="0" tabpos="2"> - <Cursor position="957" topLine="0" /> + <Cursor position="1245" topLine="12" /> </File> </CodeBlocks_layout_file> Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/sound/SoundManager.cpp 2009-05-20 18:55:49 UTC (rev 35) @@ -16,6 +16,7 @@ // Include files #include "SoundManager.h" +#include "../core/GameManager.h" // SoundManager class @@ -39,6 +40,7 @@ // Clears the Sound Manager. void SoundManager::clear() { + removeAll(); } // Gets the current global volume of all sounds. @@ -47,10 +49,119 @@ return sf::Listener::GetGlobalVolume(); } +// Gets the sound buffer with the given filename. +sf::SoundBuffer* SoundManager::getSoundBuffer(const std::string &fileName) +{ + std::map<std::string, sf::SoundBuffer*>::iterator it = mSoundBuffers.find(fileName); + + if(it != mSoundBuffers.end()) + return it->second; + + return NULL; +} + +// Creates a sound buffer from the given file. +bool SoundManager::loadSoundBuffer(const std::string &fileName) +{ + // Get pointer to the File System of Irrlicht. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Has the sound buffer already been loaded? + std::string fileBase = (fileSystem->getFileBasename(fileName.c_str())).c_str(); + + std::map<std::string, sf::SoundBuffer*>::iterator it = mSoundBuffers.find(fileBase); + if(it != mSoundBuffers.end()) + return false; + + // 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()); + + long bufferSize = file->getSize(); + c8 * buffer = new c8[bufferSize+1]; + file->read(buffer, bufferSize); + file->drop(); + + // Create the sound buffer and add it to the map. + sf::SoundBuffer *soundBuffer = new sf::SoundBuffer(); + soundBuffer->LoadFromMemory(buffer, bufferSize); + + mSoundBuffers[fileBase] = soundBuffer; + + // Clean up. + delete[] buffer; + + return true; +} + +// Removes all sound buffers. +void SoundManager::removeAll() +{ + std::map<std::string, sf::SoundBuffer*>::iterator it; + for(it = mSoundBuffers.begin(); it != mSoundBuffers.end(); it++) + delete it->second; + + mSoundBuffers.clear(); +} + +// Removes the sound buffer with the given filename. +bool SoundManager::removeSoundBuffer(const std::string &fileName) +{ + // Try to remove the sound buffer. + std::map<std::string, sf::SoundBuffer*>::iterator it = mSoundBuffers.find(fileName); + + if(it != mSoundBuffers.end()) + { + sf::SoundBuffer *soundBuffer = it->second; + + delete soundBuffer; + mSoundBuffers.erase(it); + + return true; + } + + // We couldn't find the sound buffer and thus couldn't remove it. + return false; +} + // Sets the global volume of all sounds. void SoundManager::setGlobalVolume(f32 volume) { sf::Listener::SetGlobalVolume(volume); } + +// SoundManager Angelscript binding. +void bindSoundManager(asIScriptEngine *engine) +{ + // Forward declarations. + int r; + + // Bind SoundManager class. + r = engine->RegisterObjectType("SoundManager", sizeof(SoundManager), asOBJ_REF); assert(r >= 0); + + // Bind SoundManager class functions. + r = engine->RegisterObjectMethod("SoundManager", "void init()", + asMETHOD(SoundManager, init), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundManager", "void clear()", + asMETHOD(SoundManager, clear), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SoundManager", "float getGlobalVolume()", + asMETHOD(SoundManager, getGlobalVolume), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SoundManager", "bool loadSoundBuffer(const string &fileName)", + asMETHOD(SoundManager, loadSoundBuffer), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SoundManager", "void removeAll()", + asMETHOD(SoundManager, removeAll), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("SoundManager", "bool removeSoundBuffer(const string &fileName)", + asMETHOD(SoundManager, removeSoundBuffer), asCALL_THISCALL); assert(r >= 0); + + r = engine->RegisterObjectMethod("SoundManager", "void setGlobalVolume(float volume)", + asMETHOD(SoundManager, setGlobalVolume), asCALL_THISCALL); assert(r >= 0); +} + // End of File. Modified: trunk/src/sound/SoundManager.h =================================================================== --- trunk/src/sound/SoundManager.h 2009-05-19 20:30:00 UTC (rev 34) +++ trunk/src/sound/SoundManager.h 2009-05-20 18:55:49 UTC (rev 35) @@ -34,10 +34,22 @@ // Methods f32 getGlobalVolume() const; + sf::SoundBuffer* getSoundBuffer(const std::string &fileName); + + bool loadSoundBuffer(const std::string &fileName); + + void removeAll(); + bool removeSoundBuffer(const std::string &fileName); + void setGlobalVolume(f32 volume); private: + std::map<std::string, sf::SoundBuffer*> mSoundBuffers; + }; +// SoundManager Angelscript binding. +extern void bindSoundManager(asIScriptEngine *engine); + #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-19 20:30:13
|
Revision: 34 http://sirrf.svn.sourceforge.net/sirrf/?rev=34&view=rev Author: zccdark203 Date: 2009-05-19 20:30:00 +0000 (Tue, 19 May 2009) Log Message: ----------- Implemented most parts of the SoundSourceComponent class. I only need to add support for SFML's sound buffers, which will also require some changes to the SoundManager. Furthermore I've concluded that both SoundListenerComponent and SoundSourceComponent are already exposable to AngelScript. So expect that too next time. Modified Paths: -------------- trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout Removed Paths: ------------- trunk/src/sound/SoundStream.cpp trunk/src/sound/SoundStream.h Modified: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-05-19 20:30:00 UTC (rev 34) @@ -39,7 +39,7 @@ } // Set misc. variables. - mName = "SceneComponent"; + mName = "SoundListenerComponent"; // Register events. pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", Modified: trunk/src/components/sound/SoundSourceComponent.cpp =================================================================== --- trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/components/sound/SoundSourceComponent.cpp 2009-05-19 20:30:00 UTC (rev 34) @@ -21,13 +21,297 @@ // SoundSourceComponent class // SoundSource constructor. SoundSourceComponent::SoundSourceComponent(Entity *parent) -: EntityComponent(parent) +: EntityComponent(parent), mSound(NULL), mMusic(NULL), mBuffer(NULL), mAttenuation(1.0f), + mLoop(false), mMinDistance(1.0f), mPitch(1.0f), mPosition(vector3df(0, 0, 0)), mVolume(100) { + // Get a pointer to sub-systems of the Game Manager. + EventManager *pEventMgr = GameManager::Instance()->getEventManager(); + + // Set misc. variables. + mName = "SoundSourceComponent"; + + // Register events. + pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", + this, &SoundSourceComponent::onPositionChange); } // SoundSourceComponent deconstructor. SoundSourceComponent::~SoundSourceComponent() { + if(mSound != NULL) + delete mSound; + + if(mMusic != NULL) + delete mMusic; + + if(mBuffer != NULL) + delete[] mBuffer; } +// Gets a direct pointer to SFML's sf::Sound object. +sf::Sound* SoundSourceComponent::getSound() +{ + return mSound; +} + +// Loads the sound data as a music (streaming) object. +bool SoundSourceComponent::loadMusic(const std::string &fileName) +{ + // Get pointer to the File System of Irrlicht. + IFileSystem *fileSystem = GameManager::Instance()->getDevice()->getFileSystem(); + + // Delete the previous data. + if(mSound != NULL) + { + delete mSound; + mSound = NULL; + } + + if(mMusic != NULL) + { + delete mMusic; + mMusic = NULL; + } + + if(mBuffer != NULL) + { + delete[] mBuffer; + mBuffer = NULL; + mBufferSize = 0; + } + + // 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); + + // 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; +} + +// Plays the associated sound. +void SoundSourceComponent::play() +{ + if(mSound != NULL) + mSound->Play(); + + else if(mMusic != NULL) + mMusic->Play(); +} + +// Pauses the associated sound. +void SoundSourceComponent::pause() +{ + if(mSound != NULL) + mSound->Pause(); + + else if(mMusic != NULL) + mMusic->Pause(); +} + +// Stops the associated sound. +void SoundSourceComponent::stop() +{ + if(mSound != NULL) + mSound->Stop(); + + else if(mMusic != NULL) + mMusic->Stop(); +} + +// Gets the attenuation of the sound. +f32 SoundSourceComponent::getAttenuation() const +{ + return mAttenuation; +} + +// Returns whether the sound is paused. +bool SoundSourceComponent::getIsPaused() const +{ + if(mSound != NULL) + { + if(mSound->GetStatus() == sf::Sound::Paused) + return true; + } + + else if(mMusic != NULL) + { + if(mMusic->GetStatus() == sf::Sound::Paused) + return true; + } + + return false; +} + +// Returns whether the sound is playing. +bool SoundSourceComponent::getIsPlaying() const +{ + if(mSound != NULL) + { + if(mSound->GetStatus() == sf::Sound::Playing) + return true; + } + + else if(mMusic != NULL) + { + if(mMusic->GetStatus() == sf::Sound::Playing) + return true; + } + + return false; +} + +// Returns whether the sound has been stopped. +bool SoundSourceComponent::getIsStopped() const +{ + if(mSound != NULL) + { + if(mSound->GetStatus() == sf::Sound::Stopped) + return true; + } + + else if(mMusic != NULL) + { + if(mMusic->GetStatus() == sf::Sound::Stopped) + return true; + } + + return false; +} + +// Gets the loop state of the sound. +bool SoundSourceComponent::getLoop() const +{ + return mLoop; +} + +// Gets the minimum distance. +f32 SoundSourceComponent::getMinDistance() const +{ + return mMinDistance; +} + +// Gets the current playing position of the sound. +// NOTE: Only works for sound! +f32 SoundSourceComponent::getOffset() const +{ + if(mSound != NULL) + return mSound->GetPlayingOffset(); + + return 0.0f; +} + +// Gets the pitch of the sound. +f32 SoundSourceComponent::getPitch() const +{ + return mPitch; +} + +// Gets the volume of the sound. +f32 SoundSourceComponent::getVolume() const +{ + return mVolume; +} + +// Sets the attenuation factor - the higher the attenuation, the more the sound +// will be attenuated with distance from listener. +void SoundSourceComponent::setAttenuation(f32 attenuation) +{ + if(mSound != NULL) + mSound->SetAttenuation(attenuation); + + else if(mMusic != NULL) + mMusic->SetAttenuation(attenuation); + + mAttenuation = attenuation; +} + +// Sets the sound loop state. +void SoundSourceComponent::setLoop(bool value) +{ + if(mSound != NULL) + mSound->SetLoop(value); + + else if(mMusic != NULL) + mMusic->SetLoop(value); + + mLoop = value; +} + +// Sets the minimum distance - closer than this distance, the listener will hear +// the sound at its maximum volume. +void SoundSourceComponent::setMinDistance(f32 minDistance) +{ + if(mSound != NULL) + mSound->SetMinDistance(minDistance); + + else if(mMusic != NULL) + mMusic->SetMinDistance(minDistance); + + mMinDistance = minDistance; +} + +// Sets the current playing position of the sound. +// NOTE: Only works for sound! +void SoundSourceComponent::setOffset(f32 offset) +{ + if(mSound != NULL) + mSound->SetPlayingOffset(offset); +} + +// Sets the sound pitch. +void SoundSourceComponent::setPitch(f32 pitch) +{ + if(mSound != NULL) + mSound->SetPitch(pitch); + + else if(mMusic != NULL) + mMusic->SetPitch(pitch); + + mPitch = pitch; +} + +// Sets the sound volume. +void SoundSourceComponent::setVolume(f32 volume) +{ + if(mSound != NULL) + mSound->SetVolume(volume); + + else if(mMusic != NULL) + mMusic->SetVolume(volume); + + mVolume = volume; +} + +// Events +// Updates the position of the component after its parent has been updated. +void SoundSourceComponent::onPositionChange(void *p) +{ + mPosition += static_cast<vector3df*>(p)[0]; + + if(mSound != NULL) + mSound->SetPosition(mPosition.X, mPosition.Y, mPosition.Z); + + else if(mMusic != NULL) + mMusic->SetPosition(mPosition.X, mPosition.Y, mPosition.Z); +} + // End of File Modified: trunk/src/components/sound/SoundSourceComponent.h =================================================================== --- trunk/src/components/sound/SoundSourceComponent.h 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/components/sound/SoundSourceComponent.h 2009-05-19 20:30:00 UTC (rev 34) @@ -31,28 +31,52 @@ ~SoundSourceComponent(); // Methods + sf::Sound* getSound(); + sf::Music* getMusic(); + + bool loadMusic(const std::string &fileName); + void loadSoundBuffer(const std::string &bufferName); + void play(); void pause(); void stop(); - void setAttenuation(f32 attenuation); - void setLoop(bool value); - void setMinDistance(f32 minDistance); - void setOffset(f32 offset); - void setPitch(f32 pitch); - void setVolume(f32 volume); - f32 getAttenuation() const; bool getIsPaused() const; bool getIsPlaying() const; bool getIsStopped() const; bool getLoop() const; f32 getMinDistance() const; + f32 getOffset() const; f32 getPitch() const; f32 getVolume() const; + void setAttenuation(f32 attenuation); + void setLoop(bool value); + void setMinDistance(f32 minDistance); + void setOffset(f32 offset); + void setPitch(f32 pitch); + void setVolume(f32 volume); + + // Events + void onPositionChange(void *p); + private: + // Members + sf::Sound *mSound; + sf::Music *mMusic; + + c8 *mBuffer; + long mBufferSize; + + f32 mAttenuation; + bool mLoop; + f32 mMinDistance; + f32 mPitch; + vector3df mPosition; + f32 mVolume; + }; #endif Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/sirrf.cbp 2009-05-19 20:30:00 UTC (rev 34) @@ -110,8 +110,6 @@ <Unit filename="scripting/scriptstring_utils.cpp" /> <Unit filename="sound/SoundManager.cpp" /> <Unit filename="sound/SoundManager.h" /> - <Unit filename="sound/SoundStream.cpp" /> - <Unit filename="sound/SoundStream.h" /> <Extensions> <code_completion /> <envvars /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/sirrf.depend 2009-05-19 20:30:00 UTC (rev 34) @@ -1041,8 +1041,9 @@ "../dependencies.h" "Entity.h" -1242571000 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242763596 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" + "../components/components.h" 1242308603 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" @@ -1382,7 +1383,7 @@ <SFML/System/Thread.hpp> <vector> -1242412608 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp +1242764227 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp "SoundListenerComponent.h" "../../core/GameManager.h" @@ -2316,11 +2317,11 @@ "matrix4.h" "IVideoDriver.h" -1242565440 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp +1242764287 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.cpp "SoundSourceComponent.h" "../../core/GameManager.h" -1242566125 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.h +1242764287 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundSourceComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -2330,3 +2331,19 @@ 1242564474 /home/michael/Programming/Projects/sirrf/src/sound/SoundStream.h "../dependencies.h" +1242570986 /home/michael/Programming/Projects/sirrf/src/components/components.h + "scene/SceneComponent.h" + "scene/AnimatedMeshComponent.h" + "scene/BillboardComponent.h" + "scene/CameraComponent.h" + "scene/LightComponent.h" + "scene/MeshComponent.h" + "scene/OctTreeComponent.h" + "scene/ParticleSysComponent.h" + "scene/SkyBoxComponent.h" + "scene/SkyDomeComponent.h" + "scene/TerrainComponent.h" + "scene/TextBillboardComponent.h" + "sound/SoundListenerComponent.h" + "sound/SoundSourceComponent.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/sirrf.layout 2009-05-19 20:30:00 UTC (rev 34) @@ -1,125 +1,140 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> + <File name="components/components.h" open="0" top="0" tabpos="0"> + <Cursor position="1185" topLine="0" /> + </File> <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="5"> - <Cursor position="6959" topLine="0" /> + <Cursor position="6902" topLine="51" /> </File> <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="6"> - <Cursor position="2365" topLine="25" /> + <Cursor position="2349" topLine="16" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1258" topLine="33" /> + <Cursor position="1983" topLine="0" /> </File> <File name="components/scene/BillboardComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1296" topLine="11" /> + <Cursor position="1296" topLine="0" /> </File> <File name="components/scene/CameraComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1210" topLine="9" /> + <Cursor position="5654" topLine="178" /> </File> <File name="components/scene/CameraComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1119" topLine="24" /> + <Cursor position="2145" topLine="29" /> </File> <File name="components/scene/LightComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1925" topLine="18" /> + <Cursor position="2917" topLine="62" /> </File> <File name="components/scene/LightComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1072" topLine="8" /> + <Cursor position="1323" topLine="8" /> </File> <File name="components/scene/MeshComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2968" topLine="37" /> + <Cursor position="2763" topLine="66" /> </File> <File name="components/scene/MeshComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1475" topLine="9" /> </File> <File name="components/scene/OctTreeComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="950" topLine="19" /> + <Cursor position="2701" topLine="32" /> </File> <File name="components/scene/OctTreeComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1176" topLine="0" /> + <Cursor position="1115" topLine="0" /> </File> <File name="components/scene/ParticleSysComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="1576" topLine="9" /> + <Cursor position="13414" topLine="241" /> </File> <File name="components/scene/ParticleSysComponent.h" open="0" top="0" tabpos="2"> - <Cursor position="2007" topLine="31" /> + <Cursor position="5205" topLine="0" /> </File> <File name="components/scene/SceneComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="4151" topLine="3" /> + <Cursor position="4873" topLine="115" /> </File> <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1662" topLine="24" /> + <Cursor position="2553" topLine="25" /> </File> <File name="components/scene/SkyBoxComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1945" topLine="26" /> + <Cursor position="1024" topLine="0" /> </File> <File name="components/scene/SkyBoxComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1036" topLine="0" /> </File> <File name="components/scene/SkyDomeComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1283" topLine="20" /> + <Cursor position="1778" topLine="20" /> </File> <File name="components/scene/SkyDomeComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1065" topLine="0" /> + <Cursor position="1223" topLine="0" /> </File> <File name="components/scene/TerrainComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2118" topLine="2" /> + <Cursor position="4106" topLine="80" /> </File> <File name="components/scene/TerrainComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="661" topLine="12" /> + <Cursor position="1779" topLine="16" /> </File> <File name="components/scene/TextBillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1477" topLine="24" /> + <Cursor position="3998" topLine="75" /> </File> <File name="components/scene/TextBillboardComponent.h" open="0" top="0" tabpos="2"> <Cursor position="0" topLine="11" /> </File> + <File name="components/sound/SoundListenerComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="2702" topLine="62" /> + </File> + <File name="components/sound/SoundListenerComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="1224" topLine="12" /> + </File> + <File name="components/sound/SoundSourceComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="7244" topLine="0" /> + </File> + <File name="components/sound/SoundSourceComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="1742" topLine="22" /> + </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> - <Cursor position="5904" topLine="0" /> + <Cursor position="1494" topLine="0" /> </File> - <File name="core/DataStack.h" open="1" top="1" tabpos="1"> - <Cursor position="2589" topLine="66" /> + <File name="core/DataStack.h" open="0" top="0" tabpos="1"> + <Cursor position="1097" topLine="14" /> </File> <File name="core/DataStore.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3007" topLine="0" /> + <Cursor position="6063" topLine="178" /> </File> <File name="core/DataStore.h" open="0" top="0" tabpos="0"> - <Cursor position="1253" topLine="18" /> + <Cursor position="1234" topLine="18" /> </File> <File name="core/Entity.cpp" open="0" top="0" tabpos="3"> - <Cursor position="4693" topLine="12" /> + <Cursor position="657" topLine="0" /> </File> <File name="core/Entity.h" open="0" top="0" tabpos="4"> - <Cursor position="822" topLine="26" /> + <Cursor position="1098" topLine="49" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1041" topLine="75" /> + <Cursor position="658" topLine="0" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1269" topLine="23" /> + <Cursor position="1400" topLine="26" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="4763" topLine="175" /> + <Cursor position="6192" topLine="175" /> </File> <File name="core/EntityManager.h" open="0" top="0" tabpos="0"> - <Cursor position="989" topLine="19" /> + <Cursor position="1131" topLine="20" /> </File> <File name="core/EventManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="3" /> + <Cursor position="4881" topLine="186" /> </File> <File name="core/EventManager.h" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="41" /> + <Cursor position="0" topLine="68" /> </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="2"> - <Cursor position="963" topLine="0" /> + <Cursor position="860" topLine="27" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> - <Cursor position="891" topLine="8" /> + <Cursor position="891" topLine="14" /> </File> <File name="core/GameState.cpp" open="0" top="0" tabpos="0"> <Cursor position="1420" topLine="4" /> </File> <File name="dependencies.h" open="0" top="0" tabpos="0"> - <Cursor position="1015" topLine="13" /> + <Cursor position="0" topLine="13" /> </File> <File name="main.cpp" open="0" top="0" tabpos="0"> <Cursor position="1645" topLine="0" /> @@ -131,9 +146,9 @@ <Cursor position="740" topLine="0" /> </File> <File name="sound/SoundManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="1125" topLine="7" /> + <Cursor position="1251" topLine="13" /> </File> <File name="sound/SoundManager.h" open="0" top="0" tabpos="2"> - <Cursor position="906" topLine="0" /> + <Cursor position="957" topLine="0" /> </File> </CodeBlocks_layout_file> Deleted: trunk/src/sound/SoundStream.cpp =================================================================== --- trunk/src/sound/SoundStream.cpp 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/sound/SoundStream.cpp 2009-05-19 20:30:00 UTC (rev 34) @@ -1,44 +0,0 @@ -// ///////////////////////////////////////////////////////////////////////////// -// -// Name: SoundStream.cpp -// Author: Michael Bartsch (ZCCdark203) -// -// Desc : Sirrf's custom sound stream using Irrlicht's file system -// as backend. -// -// License: Copyright (C) 2009 Michael Bartsch -// -// 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 "SoundStream.h" - - -// SoundStream class -// SoundStream constructor. -SoundStream::SoundStream(size_t bufferSize) -{ -} - -// SoundStream deconstructor. -SoundStream::~SoundStream() -{ -} - -bool SoundStream::open(const std::string &fileName) -{ -} - -bool SoundStream::OnStart() -{ -} - -bool SoundStream::OnGetData(sf::SoundStream::Chunk &data) -{ -} - -// End of File. Deleted: trunk/src/sound/SoundStream.h =================================================================== --- trunk/src/sound/SoundStream.h 2009-05-17 14:47:40 UTC (rev 33) +++ trunk/src/sound/SoundStream.h 2009-05-19 20:30:00 UTC (rev 34) @@ -1,43 +0,0 @@ -// ///////////////////////////////////////////////////////////////////////////// -// -// Name: SoundStream.h -// Author: Michael Bartsch (ZCCdark203) -// -// Desc : Declaration of the SoundStream class. -// -// License: Copyright (C) 2009 Michael Bartsch -// -// 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 __SOUNDSTREAM_H__ -#define __SOUNDSTREAM_H__ - -// Include files -#include "../dependencies.h" - - -// SoundStream class -class SoundStream : public sf::SoundStream -{ -public: - - // Initialisation and deinitialisation - SoundStream(size_t bufferSize = 44100); - ~SoundStream(); - - // Methods - bool open(const std::string &fileName); - -private: - - // Private methods - virtual bool OnStart(); - virtual bool OnGetData(sf::SoundStream::Chunk &data); - -}; - -#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-17 14:47:49
|
Revision: 33 http://sirrf.svn.sourceforge.net/sirrf/?rev=33&view=rev Author: zccdark203 Date: 2009-05-17 14:47:40 +0000 (Sun, 17 May 2009) Log Message: ----------- In previous revisions I used C++'s naming convention for standard variables (int, float, etc.). With this revision Sirrf has switched to Irrlicht's naming convention. Not only should this make Sirrf more accessible to regular Irrlicht users, but it should also gaurantee bit-consitency. On top of that Sirrf has switched to Irrlicht SVN 2329 in order to prepare for Irrlicht's new File System. And to finish this commit, I've also added two sound related classes, but those are not finished yet. Modified Paths: -------------- 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/CameraComponent.h trunk/src/components/scene/LightComponent.cpp trunk/src/components/scene/LightComponent.h trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/OctTreeComponent.cpp trunk/src/components/scene/OctTreeComponent.h trunk/src/components/scene/ParticleSysComponent.cpp trunk/src/components/scene/ParticleSysComponent.h trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/components/scene/SkyDomeComponent.cpp trunk/src/components/scene/SkyDomeComponent.h trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/scene/TerrainComponent.h trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/core/DataStack.cpp trunk/src/core/DataStack.h trunk/src/core/DataStore.cpp trunk/src/core/DataStore.h trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityComponent.cpp trunk/src/core/EntityComponent.h trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h trunk/src/core/GameManager.cpp trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Added Paths: ----------- trunk/src/components/components.h trunk/src/components/sound/SoundSourceComponent.cpp trunk/src/components/sound/SoundSourceComponent.h trunk/src/sound/SoundStream.cpp trunk/src/sound/SoundStream.h Added: trunk/src/components/components.h =================================================================== --- trunk/src/components/components.h (rev 0) +++ trunk/src/components/components.h 2009-05-17 14:47:40 UTC (rev 33) @@ -0,0 +1,38 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: components.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Header file with all components. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __COMPONENTS_H__ +#define __COMPONENTS_H__ + +// Scene +#include "scene/SceneComponent.h" +#include "scene/AnimatedMeshComponent.h" +#include "scene/BillboardComponent.h" +#include "scene/CameraComponent.h" +#include "scene/LightComponent.h" +#include "scene/MeshComponent.h" +#include "scene/OctTreeComponent.h" +#include "scene/ParticleSysComponent.h" +#include "scene/SkyBoxComponent.h" +#include "scene/SkyDomeComponent.h" +#include "scene/TerrainComponent.h" +#include "scene/TextBillboardComponent.h" + +// Sound +#include "sound/SoundListenerComponent.h" +#include "sound/SoundSourceComponent.h" + +#endif + Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -27,8 +27,8 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(0, 0, parent->getID(), vector3df(0, 0, 0), - vector3df(0, 0, 0), + mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(0, 0, parent->getID(), + parent->getPosition(), vector3df(0, 0, 0), vector3df(1.0f, 1.0f, 1.0f), true); mSceneNode = mAnimatedMeshSN; mShadowVolumeSN = NULL; @@ -48,7 +48,7 @@ // Create the internal scene node. mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(pSceneMgr->getMesh(fileName.c_str()), 0, - parent->getID(), vector3df(0, 0, 0), + parent->getID(), parent->getPosition(), rotation, scale, true); mSceneNode = mAnimatedMeshSN; mShadowVolumeSN = NULL; @@ -66,7 +66,7 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(mesh, 0, parent->getID(), - vector3df(0, 0, 0), rotation, scale, + parent->getPosition(), rotation, scale, true); mSceneNode = mAnimatedMeshSN; @@ -125,19 +125,19 @@ } // Sets the speed (in frames/s) with which the animation is played. -void AnimatedMeshComponent::setAnimationSpeed(float speed) +void AnimatedMeshComponent::setAnimationSpeed(f32 speed) { mAnimatedMeshSN->setAnimationSpeed(speed); } // Sets the current frame number. -void AnimatedMeshComponent::setCurrentFrame(int frame) +void AnimatedMeshComponent::setCurrentFrame(s32 frame) { mAnimatedMeshSN->setCurrentFrame(frame); } // Sets the frame numbers between the animation is looped. -void AnimatedMeshComponent::setFrameLoop(int start, int end) +void AnimatedMeshComponent::setFrameLoop(s32 start, s32 end) { mAnimatedMeshSN->setFrameLoop(start, end); } @@ -176,7 +176,7 @@ // Loads and sets a new shadow volume scene node to the component. void AnimatedMeshComponent::setShadowVolumeSceneNode(const std::string &fileName, bool zfailmethod, - float infinity) + f32 infinity) { if(!mShadowVolumeSN) { @@ -188,7 +188,7 @@ } // Adds a new shadow volume scene node to the component. -void AnimatedMeshComponent::setShadowVolumeSceneNode(IMesh *mesh, bool zfailmethod, float infinity) +void AnimatedMeshComponent::setShadowVolumeSceneNode(IMesh *mesh, bool zfailmethod, f32 infinity) { if(!mShadowVolumeSN) { @@ -198,7 +198,7 @@ } // Sets the transition time in seconds. -void AnimatedMeshComponent::setTransitionTime(float time) +void AnimatedMeshComponent::setTransitionTime(f32 time) { mAnimatedMeshSN->setTransitionTime(time); } Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-17 14:47:40 UTC (rev 33) @@ -47,19 +47,19 @@ IShadowVolumeSceneNode* getShadowVolumeSceneNode(); int getStartFrame() const; - void setAnimationSpeed(float speed); - void setCurrentFrame(int frame); - void setFrameLoop(int start, int end); + void setAnimationSpeed(f32 speed); + void setCurrentFrame(s32 frame); + void setFrameLoop(s32 start, s32 end); void setLoopMode(bool value); void setMD2Animation(const std::string &animationName); void setMD2Animation(EMD2_ANIMATION_TYPE anim); void setMesh(const std::string &fileName); void setMesh(IAnimatedMesh *mesh); void setShadowVolumeSceneNode(const std::string &fileName, bool zfailmethod = true, - float infinity = 10000.0f); + f32 infinity = 10000.0f); void setShadowVolumeSceneNode(IMesh *mesh, bool zfailmethod = true, - float infinity = 10000.0f); - void setTransitionTime(float time); + f32 infinity = 10000.0f); + void setTransitionTime(f32 time); private: Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -28,7 +28,7 @@ // Create the internal scene node. mBillboardSN = pSceneMgr->addBillboardSceneNode(0, dimension2df(10.0f, 10.0f), - vector3df(0, 0, 0), parent->getID()); + parent->getPosition(), parent->getID()); mSceneNode = mBillboardSN; // Set-up internal mechanism for collision detection. @@ -45,7 +45,7 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mBillboardSN = pSceneMgr->addBillboardSceneNode(0, size, vector3df(0, 0, 0), parent->getID(), + mBillboardSN = pSceneMgr->addBillboardSceneNode(0, size, parent->getPosition(), parent->getID(), colorTop, colorBottom); mSceneNode = mBillboardSN; Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/CameraComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -27,7 +27,7 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mCameraSN = pSceneMgr->addCameraSceneNode(0, vector3df(0, 0, 0), lookat, parent->getID()); + mCameraSN = pSceneMgr->addCameraSceneNode(0, parent->getPosition(), lookat, parent->getID()); mSceneNode = mCameraSN; mCameraAnimator = NULL; @@ -123,25 +123,25 @@ } // Sets the aspect ratio (default: 4.0f / 3.0f). -void CameraComponent::setAspectRatio(float aspect) +void CameraComponent::setAspectRatio(f32 aspect) { mCameraSN->setAspectRatio(aspect); } // Sets the value of the far clipping plane (default: 2000.0f). -void CameraComponent::setFarValue(float value) +void CameraComponent::setFarValue(f32 value) { mCameraSN->setFarValue(value); } // Sets the field of view (Default: PI / 2.5f). -void CameraComponent::setFOV(float value) +void CameraComponent::setFOV(f32 value) { mCameraSN->setFOV(value); } // Sets the value of the near clipping plane. (default: 1.0f). -void CameraComponent::setNearValue(float value) +void CameraComponent::setNearValue(f32 value) { mCameraSN->setNearValue(value); } @@ -178,8 +178,8 @@ } // Sets the camera to FPS mode. -void CameraComponent::setFPSMode(float rotateSpeed, float moveSpeed, bool verticalMovement, - float jumpSpeed) +void CameraComponent::setFPSMode(f32 rotateSpeed, f32 moveSpeed, bool verticalMovement, + f32 jumpSpeed) { // Remove previous camera animator. if(mCameraAnimator) @@ -199,7 +199,7 @@ } // Sets the camera to Maya mode. -void CameraComponent::setMayaMode(float rotateSpeed, float zoomSpeed, float translationSpeed) +void CameraComponent::setMayaMode(f32 rotateSpeed, f32 zoomSpeed, f32 translationSpeed) { // Remove previous camera animator. if(mCameraAnimator) Modified: trunk/src/components/scene/CameraComponent.h =================================================================== --- trunk/src/components/scene/CameraComponent.h 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/CameraComponent.h 2009-05-17 14:47:40 UTC (rev 33) @@ -47,20 +47,20 @@ bool getIsOrthogonal()const; void setAsMainCamera(); - void setAspectRatio(float aspect); - void setFarValue(float value); - void setFOV(float value); - void setNearValue(float value); + void setAspectRatio(f32 aspect); + void setFarValue(f32 value); + void setFOV(f32 value); + void setNearValue(f32 value); void setProjectionMatrix(const matrix4 &projection, bool isOrthogonal = false); void setRotation(const vector3df &rotation); void setTarget(const vector3df &position); void setUpVector(const vector3df &position); void setNormalMode(); - void setFPSMode(float rotateSpeed = 100.0f, float moveSpeed = 0.5f, - bool verticalMovement = false, float jumpSpeed = 0.0f); - void setMayaMode(float rotateSpeed = -1500.0f, float zoomSpeed = 200.0f, - float translationSpeed = 1500.0f); + void setFPSMode(f32 rotateSpeed = 100.0f, f32 moveSpeed = 0.5f, bool verticalMovement = false, + f32 jumpSpeed = 0.0f); + void setMayaMode(f32 rotateSpeed = -1500.0f, f32 zoomSpeed = 200.0f, + f32 translationSpeed = 1500.0f); private: Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/LightComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -27,7 +27,7 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mLightSN = pSceneMgr->addLightSceneNode(0, vector3df(0, 0, 0), SColorf(1.0f, 1.0f, 1.0f), + mLightSN = pSceneMgr->addLightSceneNode(0, parent->getPosition(), SColorf(1.0f, 1.0f, 1.0f), 100.0f, parent->getID()); mSceneNode = mLightSN; @@ -37,14 +37,15 @@ } // LightComponent constructor. -LightComponent::LightComponent(Entity *parent, const SColorf &color, float radius) +LightComponent::LightComponent(Entity *parent, const SColorf &color, f32 radius) : SceneComponent(parent, true) { // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mLightSN = pSceneMgr->addLightSceneNode(0, vector3df(0, 0, 0), color, radius, parent->getID()); + mLightSN = pSceneMgr->addLightSceneNode(0, parent->getPosition(), color, radius, + parent->getID()); mSceneNode = mLightSN; // Set-up internal mechanism for collision detection. @@ -96,7 +97,7 @@ } // Sets the light's radius of influence. -void LightComponent::setRadius(float radius) +void LightComponent::setRadius(f32 radius) { mLightSN->setRadius(radius); } Modified: trunk/src/components/scene/LightComponent.h =================================================================== --- trunk/src/components/scene/LightComponent.h 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/LightComponent.h 2009-05-17 14:47:40 UTC (rev 33) @@ -29,7 +29,7 @@ // Initialisation and deinitialisation LightComponent(Entity *parent); LightComponent(Entity *parent, const SColorf &color = SColorf(1.0f, 1.0f, 1.0f), - float radius = 100.0f); + f32 radius = 100.0f); ~LightComponent(); // Methods @@ -41,7 +41,7 @@ void setCastShadow(bool shadow = true); void setLightType(E_LIGHT_TYPE type); - void setRadius(float radius); + void setRadius(f32 radius); private: Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/MeshComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -27,7 +27,7 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, parent->getID(), vector3df(0, 30, -40), + mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, parent->getID(), parent->getPosition(), vector3df(0, 0, 0), vector3df(1.0f, 1.0f, 1.0f), true); mSceneNode = mMeshSN; @@ -46,7 +46,7 @@ // Create the internal scene node. mMeshSN = pSceneMgr->addMeshSceneNode(pSceneMgr->getMesh(fileName.c_str()), 0, - parent->getID(), vector3df(0, 0, 0), rotation, scale, + parent->getID(), parent->getPosition(), rotation, scale, true); mSceneNode = mMeshSN; @@ -64,7 +64,7 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); // Create the internal scene node. - mMeshSN = pSceneMgr->addMeshSceneNode(mesh, 0, parent->getID(), vector3df(0, 0, 0), rotation, + mMeshSN = pSceneMgr->addMeshSceneNode(mesh, 0, parent->getID(), parent->getPosition(), rotation, scale, true); mSceneNode = mMeshSN; Modified: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -21,7 +21,7 @@ // OctTreeComponent class // OctTreeComponent constructor. -OctTreeComponent::OctTreeComponent(Entity *parent, const std::string &fileName, int minPolysPerNode) +OctTreeComponent::OctTreeComponent(Entity *parent, const std::string &fileName, s32 minPolysPerNode) : SceneComponent(parent, true) { // Get pointers to needed sub-systems of the Game Manager. @@ -30,6 +30,7 @@ // Create the internal scene node. IMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); + mSceneNode->setPosition(parent->getPosition()); // Set-up internal mechanism for collision detection. mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); @@ -37,7 +38,7 @@ } // OctTreeComponent constructor. -OctTreeComponent::OctTreeComponent(Entity *parent, IMesh *mesh, int minPolysPerNode) +OctTreeComponent::OctTreeComponent(Entity *parent, IMesh *mesh, s32 minPolysPerNode) : SceneComponent(parent, true) { // Get pointers to needed sub-systems of the Game Manager. @@ -45,6 +46,7 @@ // Create the internal scene node. mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); + mSceneNode->setPosition(parent->getPosition()); // Set-up internal mechanism for collision detection. mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); @@ -52,7 +54,7 @@ } // OctTreeComponent constructor. -OctTreeComponent::OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, int minPolysPerNode) +OctTreeComponent::OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, s32 minPolysPerNode) : SceneComponent(parent, true) { // Get pointers to needed sub-systems of the Game Manager. @@ -60,6 +62,7 @@ // Create the internal scene node. mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); + mSceneNode->setPosition(parent->getPosition()); // Set-up internal mechanism for collision detection. mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); Modified: trunk/src/components/scene/OctTreeComponent.h =================================================================== --- trunk/src/components/scene/OctTreeComponent.h 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/OctTreeComponent.h 2009-05-17 14:47:40 UTC (rev 33) @@ -27,9 +27,9 @@ public: // Initialisation and deinitialisation - OctTreeComponent(Entity *parent, const std::string &fileName, int minPolysPerNode = 256); - OctTreeComponent(Entity *parent, IMesh *mesh, int minPolysPerNode = 256); - OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, int minPolysPerNode = 512); + OctTreeComponent(Entity *parent, const std::string &fileName, s32 minPolysPerNode = 256); + OctTreeComponent(Entity *parent, IMesh *mesh, s32 minPolysPerNode = 256); + OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, s32 minPolysPerNode = 512); ~OctTreeComponent(); }; Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -24,16 +24,16 @@ const vector3df &scale) : SceneComponent(parent, true) { - // Get pointers to needed sub-systems of the Game Manager. + // Get pos32ers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - // Create the internal scene node. + // Create the s32ernal scene node. mParticleSystemSN = pSceneMgr->addParticleSystemSceneNode(true, 0, parent->getID(), - vector3df(0, 0, 0), rotation, + parent->getPosition(), rotation, scale); mSceneNode = mParticleSystemSN; - // Set-up internal mechanism for collision detection. + // Set-up s32ernal mechanism for collision detection. mTriSelector = NULL; mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } @@ -45,7 +45,7 @@ mSceneNode = NULL; } -// Gets a direct pointer to the IParticleSystemSceneNode. +// Gets a direct pos32er to the IParticleSystemSceneNode. IParticleSystemSceneNode* ParticleSysComponent::getParticleSystemSceneNode() { return mParticleSystemSN; @@ -57,11 +57,11 @@ mParticleSystemSN->addAffector(affector); } -// Adds a point attraction affector. -void ParticleSysComponent::addAttractionAffector(const vector3df &point, float speed, bool attract, +// Adds a pos32 attraction affector. +void ParticleSysComponent::addAttractionAffector(const vector3df &pos32, f32 speed, bool attract, bool affectX, bool affectY, bool affectZ) { - IParticleAffector *affector = mParticleSystemSN->createAttractionAffector(point, speed, attract, + IParticleAffector *affector = mParticleSystemSN->createAttractionAffector(pos32, speed, attract, affectX, affectY, affectZ); mParticleSystemSN->addAffector(affector); affector->drop(); @@ -69,7 +69,7 @@ // Adds a fade out particle affector. void ParticleSysComponent::addFadeOutParticleAffector(const SColor &targetColor, - unsigned int timeNeededToFadeOut) + u32 timeNeededToFadeOut) { IParticleAffector *affector = mParticleSystemSN->createFadeOutParticleAffector(targetColor, timeNeededToFadeOut); @@ -78,7 +78,7 @@ } // Adds a gravity affector. -void ParticleSysComponent::addGravityAffector(const vector3df &gravity, unsigned int timeForceLost) +void ParticleSysComponent::addGravityAffector(const vector3df &gravity, u32 timeForceLost) { IParticleAffector *affector = mParticleSystemSN->createGravityAffector(gravity, timeForceLost); mParticleSystemSN->addAffector(affector); @@ -86,9 +86,9 @@ } // Adds a rotation affector. -void ParticleSysComponent::addRotationAffector(const vector3df &speed, const vector3df &pivotPoint) +void ParticleSysComponent::addRotationAffector(const vector3df &speed, const vector3df &pivotPos32) { - IParticleAffector *affector = mParticleSystemSN->createRotationAffector(speed, pivotPoint); + IParticleAffector *affector = mParticleSystemSN->createRotationAffector(speed, pivotPos32); mParticleSystemSN->addAffector(affector); affector->drop(); } @@ -117,15 +117,14 @@ void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(const std::string &fileName, bool useNormalDirection, const vector3df &direction, - float normalDirectionModifier, + f32 normalDirectionModifier, bool everyMeshVertex, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, + u32 minParticlesPerSecond, + u32 maxParticlesPerSecond, const SColor &minStartColor, const SColor &maxStartColor, - unsigned int lifeTimeMin, - unsigned int lifeTimeMax, - int maxAngleDegrees, + u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees, const dimension2df &minStartSize, const dimension2df &maxStartSize) { @@ -150,15 +149,14 @@ void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(IAnimatedMeshSceneNode *node, bool useNormalDirection, const vector3df &direction, - float normalDirectionModifier, + f32 normalDirectionModifier, bool everyMeshVertex, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, + u32 minParticlesPerSecond, + u32 maxParticlesPerSecond, const SColor &minStartColor, const SColor &maxStartColor, - unsigned int lifeTimeMin, - unsigned int lifeTimeMax, - int maxAngleDegrees, + u32 lifeTimeMin, u32 lifeTimeMax, + s32 maxAngleDegrees, const dimension2df &minStartSize, const dimension2df &maxStartSize) { @@ -172,14 +170,10 @@ } // Sets a box particle emitter. -void ParticleSysComponent::setBoxEmitter(const aabbox3df &box, - const vector3df &direction, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, - const SColor &minStartColor, - const SColor &maxStartColor, - unsigned int lifeTimeMin, unsigned int lifeTimeMax, - int maxAngleDegrees, +void ParticleSysComponent::setBoxEmitter(const aabbox3df &box, const vector3df &direction, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, + const SColor &minStartColor, const SColor &maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, const dimension2df &minStartSize, const dimension2df &maxStartSize) { @@ -192,16 +186,14 @@ } // Sets a particle emitter for emitting from a cylinder. -void ParticleSysComponent::setCylinderEmitter(const vector3df ¢er, float radius, - const vector3df &normal, float length, - bool outlineOnly, - const vector3df &direction, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, +void ParticleSysComponent::setCylinderEmitter(const vector3df ¢er, f32 radius, + const vector3df &normal, f32 length, + bool outlineOnly, const vector3df &direction, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, const SColor &minStartColor, const SColor &maxStartColor, - unsigned int lifeTimeMin, unsigned int lifeTimeMax, - int maxAngleDegrees, const dimension2df &minStartSize, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, + const dimension2df &minStartSize, const dimension2df &maxStartSize) { IParticleEmitter *emitter = mParticleSystemSN->createCylinderEmitter(center, radius, normal, @@ -219,14 +211,11 @@ } void ParticleSysComponent::setMeshEmitter(const std::string &fileName, bool useNormalDirection, - const vector3df &direction, - float normalDirectionModifier, bool everyMeshVertex, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, - const SColor &minStartColor, - const SColor &maxStartColor, - unsigned int lifeTimeMin, unsigned int lifeTimeMax, - int maxAngleDegrees, + 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) { @@ -247,13 +236,10 @@ // Sets a particle emitter a mesh. void ParticleSysComponent::setMeshEmitter(IMesh *mesh, bool useNormalDirection, const vector3df &direction, - float normalDirectionModifier, bool everyMeshVertex, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, - const SColor &minStartColor, - const SColor &maxStartColor, - unsigned int lifeTimeMin, unsigned int lifeTimeMax, - int maxAngleDegrees, + 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) { @@ -268,12 +254,9 @@ // Sets a point particle emitter. void ParticleSysComponent::setPointEmitter(const vector3df &direction, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, - const SColor &minStartColor, - const SColor &maxStartColor, - unsigned int lifeTimeMin, unsigned int lifeTimeMax, - int maxAngleDegrees, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, + const SColor &minStartColor, const SColor &maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, const dimension2df &minStartSize, const dimension2df &maxStartSize) { @@ -286,14 +269,11 @@ } // Sets a ring particle emitter. -void ParticleSysComponent::setRingEmitter(const vector3df ¢er, float radius, - float ringThickness, const vector3df &direction, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, - const SColor &minStartColor, - const SColor &maxStartColor, - unsigned int lifeTimeMin, unsigned int lifeTimeMax, - int maxAngleDegrees, +void ParticleSysComponent::setRingEmitter(const vector3df ¢er, f32 radius, + f32 ringThickness, const vector3df &direction, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, + const SColor &minStartColor, const SColor &maxStartColor, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, const dimension2df &minStartSize, const dimension2df &maxStartSize) { @@ -306,14 +286,12 @@ } // Sets a sphere particle emitter. -void ParticleSysComponent::setSphereEmitter(const vector3df ¢er, float radius, +void ParticleSysComponent::setSphereEmitter(const vector3df ¢er, f32 radius, const vector3df &direction, - unsigned int minParticlesPerSecond, - unsigned int maxParticlesPerSecond, + u32 minParticlesPerSecond, u32 maxParticlesPerSecond, const SColor &minStartColor, const SColor &maxStartColor, - unsigned int lifeTimeMin, unsigned int lifeTimeMax, - int maxAngleDegrees, + u32 lifeTimeMin, u32 lifeTimeMax, s32 maxAngleDegrees, const dimension2df &minStartSize, const dimension2df &maxStartSize) { Modified: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-05-17 14:47:40 UTC (rev 33) @@ -36,14 +36,14 @@ void addAffector(IParticleAffector *affector); - void addAttractionAffector(const vector3df &point, float speed = 1.0f, bool attract = true, + void addAttractionAffector(const vector3df &point, f32 speed = 1.0f, bool attract = true, bool affectX = true, bool affectY = true, bool affectZ = true); void addFadeOutParticleAffector(const SColor &targetColor = SColor(0, 0, 0, 0), - unsigned int timeNeededToFadeOut = 1000); + u32 timeNeededToFadeOut = 1000); void addGravityAffector(const vector3df &gravity = vector3df(0.0f,-0.03f, 0.0f), - unsigned int timeForceLost = 1000); + u32 timeForceLost = 1000); void addRotationAffector(const vector3df &speed = vector3df(5.0f, 5.0f, 5.0f), const vector3df &pivotPoint = vector3df(0.0f, 0.0f, 0.0f)); @@ -57,52 +57,46 @@ void setAnimatedMeshSceneNodeEmitter(const std::string &fileName, bool useNormalDirection = true, const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - float normalDirectionModifier = 100.0f, + f32 normalDirectionModifier = 100.0f, bool everyMeshVertex = false, - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + u32 minParticlesPerSecond = 5, + u32 maxParticlesPerSecond = 10, const SColor &minStartColor = SColor(255, 0, 0, 0), const SColor &maxStartColor = SColor(255, 255, 255, 255), - unsigned int lifeTimeMin = 2000, - unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); void setAnimatedMeshSceneNodeEmitter(IAnimatedMeshSceneNode *node, bool useNormalDirection = true, const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - float normalDirectionModifier = 100.0f, + f32 normalDirectionModifier = 100.0f, bool everyMeshVertex = false, - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + u32 minParticlesPerSecond = 5, + u32 maxParticlesPerSecond = 10, const SColor &minStartColor = SColor(255, 0, 0, 0), const SColor &maxStartColor = SColor(255, 255, 255, 255), - unsigned int lifeTimeMin = 2000, - unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); void setBoxEmitter(const aabbox3df &box = aabbox3df(-10, 28,-10, 10, 30, 10), const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, const SColor &minStartColor = SColor(255, 0, 0, 0), const SColor &maxStartColor = SColor(255, 255, 255, 255), - unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); - void setCylinderEmitter(const vector3df ¢er, float radius, const vector3df &normal, - float length, bool outlineOnly = false, + void setCylinderEmitter(const vector3df ¢er, f32 radius, const vector3df &normal, + f32 length, bool outlineOnly = false, const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, const SColor &minStartColor = SColor(255, 0, 0, 0), const SColor &maxStartColor = SColor(255, 255, 255, 255), - unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); @@ -110,56 +104,46 @@ void setMeshEmitter(const std::string &fileName, bool useNormalDirection = true, const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - float normalDirectionModifier = 100.0f, bool everyMeshVertex = false, - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + 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), - unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); void setMeshEmitter(IMesh *mesh, bool useNormalDirection = true, const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - float normalDirectionModifier = 100.0f, bool everyMeshVertex = false, - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + 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), - unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); void setPointEmitter(const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, const SColor &minStartColor = SColor(255, 0, 0, 0), const SColor &maxStartColor = SColor(255, 255, 255, 255), - unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); - void setRingEmitter(const vector3df ¢er, float radius, float ringThickness, + void setRingEmitter(const vector3df ¢er, f32 radius, f32 ringThickness, const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, const SColor &minStartColor = SColor(255, 0, 0, 0), const SColor &maxStartColor = SColor(255, 255, 255, 255), - unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); - void setSphereEmitter(const vector3df ¢er, float radius, + void setSphereEmitter(const vector3df ¢er, f32 radius, const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), - unsigned int minParticlesPerSecond = 5, - unsigned int maxParticlesPerSecond = 10, + u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10, const SColor &minStartColor = SColor(255, 0, 0, 0), const SColor &maxStartColor = SColor(255, 255, 255, 255), - unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, - int maxAngleDegrees = 0, + 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)); Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -29,6 +29,7 @@ // 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); @@ -94,7 +95,7 @@ void SceneComponent::addCollisionResponseAnimator(const vector3df &ellipsoidRadius, const vector3df &gravityPerSecond, const vector3df &ellipsoidTranslation, - float slidingValue) + f32 slidingValue) { ISceneNodeAnimator *anim = GameManager::Instance()->getSceneManager()-> createCollisionResponseAnimator(mMetaSelector, mSceneNode, @@ -106,7 +107,7 @@ } // Adds a fly circle animator to the component. -void SceneComponent::addFlyCircleAnimator(const vector3df ¢er, float radius, float speed, +void SceneComponent::addFlyCircleAnimator(const vector3df ¢er, f32 radius, f32 speed, const vector3df &direction) { ISceneNodeAnimator *anim = GameManager::Instance()->getSceneManager()-> @@ -118,7 +119,7 @@ // Adds a fly straight animator to the component. void SceneComponent::addFlyStraightAnimator(const vector3df &startPoint, const vector3df &endPoint, - unsigned int timeForWay, bool loop) + u32 timeForWay, bool loop) { ISceneNodeAnimator *anim = GameManager::Instance()->getSceneManager()-> createFlyStraightAnimator(startPoint, endPoint, timeForWay, loop); @@ -184,7 +185,7 @@ } // Get amount of materials used by this component. -unsigned int SceneComponent::getMaterialCount() const +u32 SceneComponent::getMaterialCount() const { return mSceneNode->getMaterialCount(); } @@ -238,7 +239,7 @@ } // Sets if debug data like bounding boxes should be drawn. -void SceneComponent::setDebugDataVisible(int state) +void SceneComponent::setDebugDataVisible(s32 state) { mSceneNode->setDebugDataVisible(state); } @@ -251,7 +252,7 @@ // Loads and sets the texture of the specified layer in all materials of this component to the new // texture. -void SceneComponent::setMaterialTexture(unsigned int layer, const std::string &fileName) +void SceneComponent::setMaterialTexture(u32 layer, const std::string &fileName) { ITexture *texture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); if(texture) @@ -259,7 +260,7 @@ } // Sets the texture of the specified layer in all materials of this component to the new texture. -void SceneComponent::setMaterialTexture(unsigned int layer, ITexture *texture) +void SceneComponent::setMaterialTexture(u32 layer, ITexture *texture) { mSceneNode->setMaterialTexture(layer, texture); } Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/SceneComponent.h 2009-05-17 14:47:40 UTC (rev 33) @@ -40,13 +40,13 @@ void addCollisionResponseAnimator(const vector3df &ellipsoidRadius = vector3df(30, 60, 30), const vector3df &gravityPerSecond = vector3df(0, -10, 0), const vector3df &ellipsoidTranslation = vector3df(0, 0, 0), - float slidingValue = 0.0005f); + f32 slidingValue = 0.0005f); - void addFlyCircleAnimator(const vector3df ¢er = vector3df(0, 0, 0), float radius = 100, - float speed = 0.001f, const vector3df &direction = vector3df(0, 0, 0)); + void addFlyCircleAnimator(const vector3df ¢er = vector3df(0, 0, 0), f32 radius = 100, + f32 speed = 0.001f, const vector3df &direction = vector3df(0, 0, 0)); void addFlyStraightAnimator(const vector3df &startPoint, const vector3df &endPoint, - unsigned int timeForWay, bool loop = false); + u32 timeForWay, bool loop = false); void addToMetaSelector(Entity *entity); void addToMetaSelector(SceneComponent *component); @@ -55,7 +55,7 @@ vector3df getAbsolutePosition() const; bool getAutomaticCulling() const; const aabbox3df& getBoundingBox() const; - unsigned int getMaterialCount() const; + u32 getMaterialCount() const; matrix4 getRelativeTransformation() const; const vector3df getPosition() const; const vector3df& getRotation() const; @@ -66,10 +66,10 @@ void setAbsolutePosition(const vector3df &position); void setAutomaticCulling(E_CULLING_TYPE state); - void setDebugDataVisible(int state); + void setDebugDataVisible(s32 state); void setMaterialFlag(E_MATERIAL_FLAG flag, bool value); - void setMaterialTexture(unsigned int layer, const std::string &fileName); - void setMaterialTexture(unsigned int layer, ITexture *texture); + void setMaterialTexture(u32 layer, const std::string &fileName); + void setMaterialTexture(u32 layer, ITexture *texture); void setMaterialType(E_MATERIAL_TYPE type); void setPosition(const vector3df &position); void setRotation(const vector3df &rotation); Modified: trunk/src/components/scene/SkyDomeComponent.cpp =================================================================== --- trunk/src/components/scene/SkyDomeComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/SkyDomeComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -21,8 +21,8 @@ // SkyDomeComponent class // SkyDomeComponent constructor. -SkyDomeComponent::SkyDomeComponent(Entity *parent, const std::string &fileName, unsigned int hRes, - unsigned int vRes, float texturePerc, float spherePerc) +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. @@ -31,7 +31,7 @@ // Create the internal scene node. mSceneNode = pSceneMgr->addSkyDomeSceneNode(pDriver->getTexture(fileName.c_str()), hRes, vRes, - texturePerc, spherePerc, 0, parent->getID()); + texturePerc, spherePerc, radius, 0, parent->getID()); // Set-up internal mechanism for collision detection. mTriSelector = NULL; @@ -39,16 +39,16 @@ } // SkyDomeComponent constructor. -SkyDomeComponent::SkyDomeComponent(Entity *parent, ITexture *texture, unsigned int hRes, - unsigned int vRes, float texturePerc, float spherePerc) +SkyDomeComponent::SkyDomeComponent(Entity *parent, ITexture *texture, 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(); // Create the internal scene node. - mSceneNode = pSceneMgr->addSkyDomeSceneNode(texture, hRes, vRes, texturePerc, spherePerc, 0, - parent->getID()); + mSceneNode = pSceneMgr->addSkyDomeSceneNode(texture, hRes, vRes, texturePerc, spherePerc, + radius, 0, parent->getID()); // Set-up internal mechanism for collision detection. mTriSelector = NULL; Modified: trunk/src/components/scene/SkyDomeComponent.h =================================================================== --- trunk/src/components/scene/SkyDomeComponent.h 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/SkyDomeComponent.h 2009-05-17 14:47:40 UTC (rev 33) @@ -27,10 +27,10 @@ public: // Initialisation and deinitialisation - SkyDomeComponent(Entity *parent, const std::string &fileName, unsigned int hRes = 16, - unsigned int vRes = 8, float texturePerc = 0.9f, float spherePerc = 2.0f); - SkyDomeComponent(Entity *parent, ITexture *texture, unsigned int hRes = 16, - unsigned int vRes = 8, float texturePerc = 0.9f, float spherePerc = 2.0f); + SkyDomeComponent(Entity *parent, const std::string &fileName, u32 hRes = 16, u32 vRes = 8, + f32 texturePerc = 0.9f, f32 spherePerc = 2.0f, f32 radius = 1000.0f); + SkyDomeComponent(Entity *parent, ITexture *texture, u32 hRes = 16, u32 vRes = 8, + f32 texturePerc = 0.9f, f32 spherePerc = 2.0f, f32 radius = 1000.0f); ~SkyDomeComponent(); }; Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-05-17 14:47:40 UTC (rev 33) @@ -41,7 +41,7 @@ // TerrainComponent constructor. TerrainComponent::TerrainComponent(Entity *parent, const std::string &fileName, const vector3df &rotation, const vector3df &scale, - const SColor &vertexColor, int maxLOD, int smoothFactor) + const SColor &vertexColor, s32 maxLOD, s32 smoothFactor) : SceneComponent(parent, true) { // Get pointers to needed sub-systems of the Game Manager. @@ -49,7 +49,7 @@ // Create the internal scene node. mTerrainSN = pSceneMgr->addTerrainSceneNode(fileName.c_str(), 0, parent->getID(), - vector3df(0.0f, 0.0f, 0.0f), rotation, scale, + parent->getPosition(), rotation, scale, vertexColor, maxLOD, ETPS_17, smoothFactor, true); mSceneNode = mTerrainSN; @@ -78,13 +78,13 @@ } // Gets the bounding box of a patch. -const aabbox3df& TerrainComponent::getBoundingBox(int patchX, int patchZ) const +const aabbox3df& TerrainComponent::getBoundingBox(s32 patchX, s32 patchZ) const { return mTerrainSN->getBoundingBox(patchX, patchZ); } // Gets the height of a point of the terrain. -float TerrainComponent::getHeight(float x, float y) +float TerrainComponent::getHeight(f32 x, f32 y) { return mTerrainSN->getHeight(x, y); } @@ -103,7 +103,7 @@ // Loads the data from a heightMapFile. bool TerrainComponent::loadHeightMap(const std::string &fileName, const SColor &vertexColor, - int smoothFactor) + s... [truncated message content] |
From: <zcc...@us...> - 2009-05-15 18:42:46
|
Revision: 32 http://sirrf.svn.sourceforge.net/sirrf/?rev=32&view=rev Author: zccdark203 Date: 2009-05-15 18:42:44 +0000 (Fri, 15 May 2009) Log Message: ----------- Created the SoundListenerComponent and added some global sound control functions to the SoundManager. That concludes the wrapping of SFML's sf::Listener. Modified Paths: -------------- trunk/src/core/GameManager.cpp trunk/src/dependencies.h trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Added Paths: ----------- trunk/src/components/sound/ trunk/src/components/sound/SoundListenerComponent.cpp trunk/src/components/sound/SoundListenerComponent.h Added: trunk/src/components/sound/SoundListenerComponent.cpp =================================================================== --- trunk/src/components/sound/SoundListenerComponent.cpp (rev 0) +++ trunk/src/components/sound/SoundListenerComponent.cpp 2009-05-15 18:42:44 UTC (rev 32) @@ -0,0 +1,105 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SoundListenerComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Component wrapper of SFML's sf::Listener. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "SoundListenerComponent.h" +#include "../../core/GameManager.h" + + +// SoundListenerComponent class +// Static variables. +SoundListenerComponent* SoundListenerComponent::mMainListener = 0; + +// SoundListener constructor. +SoundListenerComponent::SoundListenerComponent(Entity *parent, bool isMainListener) +: EntityComponent(parent), mPosition(vector3df(0, 0, 0)), mTarget(vector3df(0, 0, 0)) +{ + // Get a pointer to sub-systems of the Game Manager. + EventManager *pEventMgr = GameManager::Instance()->getEventManager(); + + // Is this the new main listener? + if(isMainListener) + { + if(mMainListener) + mMainListener->setIsMainListener(false); + + setIsMainListener(true); + } + + // Set misc. variables. + mName = "SceneComponent"; + + // Register events. + pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", + this, &SoundListenerComponent::onPositionChange); +} + +// SoundListenerComponent deconstructor. +SoundListenerComponent::~SoundListenerComponent() +{ + setIsMainListener(false); +} + +// Checks if this listener is the main listener. +bool SoundListenerComponent::getIsMainListener() const +{ + 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) +{ + if(value) + { + mMainListener = this; + mIsMainListener = true; + + sf::Listener::SetPosition(mPosition.X, mPosition.Y, mPosition.Z); + sf::Listener::SetTarget(mTarget.X, mTarget.Y, mTarget.Z); + } + + else + { + if(mIsMainListener) + mMainListener = 0; + + mIsMainListener = false; + } +} + +// 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) +{ + mPosition += static_cast<vector3df*>(p)[0]; + if(mIsMainListener) + sf::Listener::SetPosition(mPosition.X, mPosition.Y, mPosition.Z); +} + +// End of File Added: trunk/src/components/sound/SoundListenerComponent.h =================================================================== --- trunk/src/components/sound/SoundListenerComponent.h (rev 0) +++ trunk/src/components/sound/SoundListenerComponent.h 2009-05-15 18:42:44 UTC (rev 32) @@ -0,0 +1,56 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SoundListenerComponent.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the SoundListenerComponent class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __SOUNDLISTENERCOMPONENT_H__ +#define __SOUNDLISTENERCOMPONENT_H__ + +// Include files +#include "../../dependencies.h" +#include "../../core/EntityComponent.h" + + +// SoundListenerComponent class +class SoundListenerComponent : public EntityComponent +{ +public: + + // Initialisation and deinitialisation + SoundListenerComponent(Entity *parent, bool isMainListener = true); + ~SoundListenerComponent(); + + // Methods + bool getIsMainListener() const; + const vector3df& getTarget() const; + + void setIsMainListener(bool value = true); + void setTarget(const vector3df &target); + + // Events + void onPositionChange(void *p); + +private: + + // Static Members + static SoundListenerComponent *mMainListener; + + // Members + vector3df mPosition; + vector3df mTarget; + + bool mIsMainListener; +}; + +#endif + Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-05-14 14:43:23 UTC (rev 31) +++ trunk/src/core/GameManager.cpp 2009-05-15 18:42:44 UTC (rev 32) @@ -59,7 +59,7 @@ pDataStore = new DataStore(); pEntityManager = new EntityManager(); pEventManager = new EventManager(); - //pSoundManager = new SoundManager(); + pSoundManager = new SoundManager(); pScriptManager = new ScriptManager(); //changeState("menu", ""); Modified: trunk/src/dependencies.h =================================================================== --- trunk/src/dependencies.h 2009-05-14 14:43:23 UTC (rev 31) +++ trunk/src/dependencies.h 2009-05-15 18:42:44 UTC (rev 32) @@ -40,6 +40,7 @@ // SFML #include <SFML/System.hpp> +#include <SFML/Audio.hpp> // Namespaces Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-14 14:43:23 UTC (rev 31) +++ trunk/src/sirrf.cbp 2009-05-15 18:42:44 UTC (rev 32) @@ -21,7 +21,7 @@ <Add option="-lXxf86vm" /> <Add option="-lXext" /> <Add option="-lX11" /> - <Add option="-lsfml-system" /> + <Add option="-lsfml-system -lsfml-audio" /> <Add library="libIrrlicht.a" /> <Add library="libangelscript.a" /> <Add directory="/usr/lib/" /> @@ -44,7 +44,7 @@ <Add option="-lXxf86vm" /> <Add option="-lXext" /> <Add option="-lX11" /> - <Add option="-lsfml-system" /> + <Add option="-lsfml-system -lsfml-audio" /> <Add library="libIrrlicht.a" /> <Add library="libangelscript.a" /> <Add directory="/usr/lib/" /> @@ -80,6 +80,8 @@ <Unit filename="components/scene/TerrainComponent.h" /> <Unit filename="components/scene/TextBillboardComponent.cpp" /> <Unit filename="components/scene/TextBillboardComponent.h" /> + <Unit filename="components/sound/SoundListenerComponent.cpp" /> + <Unit filename="components/sound/SoundListenerComponent.h" /> <Unit filename="core/DataStack.cpp" /> <Unit filename="core/DataStack.h" /> <Unit filename="core/DataStore.cpp" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-14 14:43:23 UTC (rev 31) +++ trunk/src/sirrf.depend 2009-05-15 18:42:44 UTC (rev 32) @@ -997,7 +997,7 @@ "../dependencies.h" "DataStore.h" -1242308067 /home/michael/Programming/Projects/sirrf/src/dependencies.h +1242411405 /home/michael/Programming/Projects/sirrf/src/dependencies.h <assert.h> <fstream> <iostream> @@ -1010,6 +1010,7 @@ <angelscript.h> <sigslot/sigslot.h> <SFML/System.hpp> + <SFML/Audio.hpp> 1241784354 /home/michael/Programming/Projects/sirrf/src/core/DataStore.h "../dependencies.h" @@ -1245,7 +1246,7 @@ 1242308067 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp "SoundManager.h" -1242308141 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h +1242412796 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h "../dependencies.h" 1242308358 /usr/local/include//SFML/System.hpp @@ -1324,3 +1325,68 @@ 1242308358 /usr/local/include//SFML/System/Vector3.inl +1242308358 /usr/local/include//SFML/Audio.hpp + <SFML/System.hpp> + <SFML/Audio/Listener.hpp> + <SFML/Audio/Music.hpp> + <SFML/Audio/Sound.hpp> + <SFML/Audio/SoundBuffer.hpp> + <SFML/Audio/SoundBufferRecorder.hpp> + <SFML/Audio/SoundRecorder.hpp> + <SFML/Audio/SoundStream.hpp> + +1242308358 /usr/local/include//SFML/Audio/Listener.hpp + <SFML/Config.hpp> + <SFML/System/Vector3.hpp> + +1242308358 /usr/local/include//SFML/Audio/Music.hpp + <SFML/Audio/SoundStream.hpp> + <string> + <vector> + +1242308358 /usr/local/include//SFML/Audio/SoundStream.hpp + <SFML/Audio/Sound.hpp> + <SFML/System/Thread.hpp> + <cstdlib> + +1242308358 /usr/local/include//SFML/Audio/Sound.hpp + <SFML/System/Resource.hpp> + <SFML/System/Vector3.hpp> + <SFML/Audio/AudioResource.hpp> + <cstdlib> + +1242308358 /usr/local/include//SFML/System/Resource.hpp + <set> + <SFML/System/Resource.inl> + <SFML/System/ResourcePtr.inl> + +1242308358 /usr/local/include//SFML/System/Resource.inl + +1242308358 /usr/local/include//SFML/System/ResourcePtr.inl + +1242308358 /usr/local/include//SFML/Audio/AudioResource.hpp + <SFML/Config.hpp> + +1242308358 /usr/local/include//SFML/Audio/SoundBuffer.hpp + <SFML/System/Resource.hpp> + <SFML/Audio/AudioResource.hpp> + <string> + <vector> + +1242308358 /usr/local/include//SFML/Audio/SoundBufferRecorder.hpp + <SFML/Audio/SoundBuffer.hpp> + <SFML/Audio/SoundRecorder.hpp> + <vector> + +1242308358 /usr/local/include//SFML/Audio/SoundRecorder.hpp + <SFML/System/Thread.hpp> + <vector> + +1242412608 source:/home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.cpp + "SoundListenerComponent.h" + "../../core/GameManager.h" + +1242412327 /home/michael/Programming/Projects/sirrf/src/components/sound/SoundListenerComponent.h + "../../dependencies.h" + "../../core/EntityComponent.h" + Modified: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp 2009-05-14 14:43:23 UTC (rev 31) +++ trunk/src/sound/SoundManager.cpp 2009-05-15 18:42:44 UTC (rev 32) @@ -34,13 +34,6 @@ // Initialises the Sound Manager. void SoundManager::init() { - sf::Clock Clock; - while (Clock.GetElapsedTime() < 5.f) - { - std::cout << Clock.GetElapsedTime() << std::endl; - sf::Sleep(0.5f); - } - } // Clears the Sound Manager. @@ -48,4 +41,16 @@ { } +// Gets the current global volume of all sounds. +float SoundManager::getGlobalVolume() const +{ + return sf::Listener::GetGlobalVolume(); +} + +// Sets the global volume of all sounds. +void SoundManager::setGlobalVolume(float volume) +{ + sf::Listener::SetGlobalVolume(volume); +} + // End of File. Modified: trunk/src/sound/SoundManager.h =================================================================== --- trunk/src/sound/SoundManager.h 2009-05-14 14:43:23 UTC (rev 31) +++ trunk/src/sound/SoundManager.h 2009-05-15 18:42:44 UTC (rev 32) @@ -33,6 +33,8 @@ void clear(); // Methods + float getGlobalVolume() const; + void setGlobalVolume(float volume); private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-14 14:43:32
|
Revision: 31 http://sirrf.svn.sourceforge.net/sirrf/?rev=31&view=rev Author: zccdark203 Date: 2009-05-14 14:43:23 +0000 (Thu, 14 May 2009) Log Message: ----------- Changed how entities and their components are initialized. In previous implementations I relied on 'delete this' during construction, but this is quite unsafe and thus has been changed. Also, I've added the first pieces of SFML integration. Modified Paths: -------------- trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityComponent.cpp trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h trunk/src/core/GameManager.cpp trunk/src/core/GameManager.h trunk/src/dependencies.h trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout Added Paths: ----------- trunk/src/sound/ trunk/src/sound/SoundManager.cpp trunk/src/sound/SoundManager.h Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/core/Entity.cpp 2009-05-14 14:43:23 UTC (rev 31) @@ -24,13 +24,21 @@ // Entity constructor. Entity::Entity(const std::string &name, Entity *parent) -: mRefCount(1), pParent(parent), mName(name), mPosition(0, 0, 0) +: mRefCount(1), mName(name), mPosition(0, 0, 0) { mID = mIDCount++; - // Add to the Entity Manager. - GameManager::Instance()->getEntityManager()->addEntity(this); + // Add to its parent. + if(parent != NULL) + { + if(parent->addChild(this)) + pParent = parent; + else pParent = NULL; + } + + else pParent = NULL; + // Register events. EventManager *pEventMgr = GameManager::Instance()->getEventManager(); @@ -65,7 +73,19 @@ void Entity::refRelease() { if(--mRefCount == 0) - GameManager::Instance()->getEntityManager()->removeEntity(this); + { + if(pParent != NULL) + { + if(!pParent->removeChild(this)) + { + if(!GameManager::Instance()->getEntityManager()->removeEntity(this)) + delete this; + } + } + + else if(!GameManager::Instance()->getEntityManager()->removeEntity(this)) + delete this; + } } // Gets the ID of this entity. @@ -179,7 +199,10 @@ { // Children. for(unsigned int i = 0; i < mChildren.size(); i++) - GameManager::Instance()->getEntityManager()->removeEntity(mChildren[i]); + { + if(!GameManager::Instance()->getEntityManager()->removeEntity(mChildren[i])) + delete mChildren[i]; + } mChildren.clear(); @@ -206,7 +229,9 @@ if(ent == entity) { - GameManager::Instance()->getEntityManager()->removeEntity(ent); + if(!GameManager::Instance()->getEntityManager()->removeEntity(ent)) + delete ent; + mChildren.erase(it); return true; } @@ -228,7 +253,9 @@ if(ent->getID() == id) { - GameManager::Instance()->getEntityManager()->removeEntity(ent); + if(!GameManager::Instance()->getEntityManager()->removeEntity(ent)) + delete ent; + mChildren.erase(it); return true; } @@ -250,7 +277,9 @@ if(ent->getName() == name) { - GameManager::Instance()->getEntityManager()->removeEntity(ent); + if(!GameManager::Instance()->getEntityManager()->removeEntity(ent)) + delete ent; + mChildren.erase(it); return true; } @@ -378,9 +407,7 @@ r = engine->RegisterObjectMethod("Entity", "const string& getName()", asMETHOD(Entity, getName), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "void addChild(Entity @entity)", - asMETHOD(Entity, addChild), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "void addComponent(EntityComponent @component)", + r = engine->RegisterObjectMethod("Entity", "bool addComponent()", asMETHOD(Entity, addComponent), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "Entity@ getChild(const uint id)", Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/core/Entity.h 2009-05-14 14:43:23 UTC (rev 31) @@ -42,7 +42,6 @@ unsigned int getID() const; const std::string& getName() const; - bool addChild(Entity *entity); bool addComponent(EntityComponent *component); Entity* getChild(const unsigned int id); @@ -69,6 +68,9 @@ private: + // Private methods + bool addChild(Entity *entity); + // Static members static unsigned int mIDCount; Modified: trunk/src/core/EntityComponent.cpp =================================================================== --- trunk/src/core/EntityComponent.cpp 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/core/EntityComponent.cpp 2009-05-14 14:43:23 UTC (rev 31) @@ -23,16 +23,21 @@ // EntityComponent constructor. EntityComponent::EntityComponent(Entity *parent) -: pParent(parent), mRefCount(1) +: mRefCount(1) { // Get new unique ID. mID = mIDCount++; // Check if we got a valid pointer. - if(parent == NULL) - delete this; + if(parent != NULL) + { + if(parent->addComponent(this)) + pParent = parent; - else parent->addComponent(this); + else pParent = NULL; + } + + else pParent = NULL; } // EntityComponent deconstructor. @@ -56,7 +61,15 @@ void EntityComponent::refRelease() { if(--mRefCount == 0) - pParent->removeComponent(this); + { + if(pParent != NULL) + { + if(!pParent->removeComponent(this)) + delete this; + } + + else delete this; + } } // Gets the ID of the component. Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/core/EntityManager.cpp 2009-05-14 14:43:23 UTC (rev 31) @@ -69,6 +69,7 @@ // Add the entity. Entity *entity = new Entity(name, parent); + mEntities.push_back(entity); return entity; } Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/core/EntityManager.h 2009-05-14 14:43:23 UTC (rev 31) @@ -27,6 +27,8 @@ // EntityManager class class EntityManager { + friend class Entity; + public: // Initialisation and deinitialisation @@ -50,6 +52,7 @@ private: + // Private members vector<Entity*> mEntities; }; Modified: trunk/src/core/GameManager.cpp =================================================================== --- trunk/src/core/GameManager.cpp 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/core/GameManager.cpp 2009-05-14 14:43:23 UTC (rev 31) @@ -59,6 +59,7 @@ pDataStore = new DataStore(); pEntityManager = new EntityManager(); pEventManager = new EventManager(); + //pSoundManager = new SoundManager(); pScriptManager = new ScriptManager(); //changeState("menu", ""); @@ -87,6 +88,7 @@ // Clean up subsystems of the framework. delete pScriptManager; + delete pSoundManager; delete pEventManager; delete pEntityManager; delete pDataStore; @@ -207,7 +209,7 @@ return pEntityManager; } -// Returns a pointr to the Entity Manager. +// Returns a pointer to the Entity Manager. EventManager* GameManager::getEventManager() { return pEventManager; @@ -219,6 +221,12 @@ return pScriptManager; } +// Returns a pointer to the Sound Manager. +SoundManager* GameManager::getSoundManager() +{ + return pSoundManager; +} + // Returns whether the Irrlicht device is running. bool GameManager::getIsRunning() const { Modified: trunk/src/core/GameManager.h =================================================================== --- trunk/src/core/GameManager.h 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/core/GameManager.h 2009-05-14 14:43:23 UTC (rev 31) @@ -23,7 +23,7 @@ #include "DataStore.h" #include "EntityManager.h" #include "EventManager.h" - +#include "../sound/SoundManager.h" #include "../scripting/ScriptManager.h" // Forward declarations @@ -60,6 +60,7 @@ EntityManager* getEntityManager(); ScriptManager* getScriptManager(); EventManager* getEventManager(); + SoundManager* getSoundManager(); bool getIsRunning() const; @@ -84,6 +85,7 @@ EntityManager *pEntityManager; EventManager *pEventManager; ScriptManager *pScriptManager; + SoundManager *pSoundManager; }; Modified: trunk/src/dependencies.h =================================================================== --- trunk/src/dependencies.h 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/dependencies.h 2009-05-14 14:43:23 UTC (rev 31) @@ -38,7 +38,10 @@ // Sigslot #include <sigslot/sigslot.h> +// SFML +#include <SFML/System.hpp> + // Namespaces // C++ STD using namespace std; Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/sirrf.cbp 2009-05-14 14:43:23 UTC (rev 31) @@ -17,7 +17,11 @@ <Add directory="/usr/local/include/irrlicht-1.5/" /> </Compiler> <Linker> - <Add option="-lGL -lXxf86vm -lXext -lX11" /> + <Add option="-lGL" /> + <Add option="-lXxf86vm" /> + <Add option="-lXext" /> + <Add option="-lX11" /> + <Add option="-lsfml-system" /> <Add library="libIrrlicht.a" /> <Add library="libangelscript.a" /> <Add directory="/usr/lib/" /> @@ -36,7 +40,11 @@ </Compiler> <Linker> <Add option="-s" /> - <Add option="-lGL -lXxf86vm -lXext -lX11" /> + <Add option="-lGL" /> + <Add option="-lXxf86vm" /> + <Add option="-lXext" /> + <Add option="-lX11" /> + <Add option="-lsfml-system" /> <Add library="libIrrlicht.a" /> <Add library="libangelscript.a" /> <Add directory="/usr/lib/" /> @@ -95,6 +103,8 @@ <Unit filename="scripting/scriptstring.cpp" /> <Unit filename="scripting/scriptstring.h" /> <Unit filename="scripting/scriptstring_utils.cpp" /> + <Unit filename="sound/SoundManager.cpp" /> + <Unit filename="sound/SoundManager.h" /> <Extensions> <code_completion /> <envvars /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/sirrf.depend 2009-05-14 14:43:23 UTC (rev 31) @@ -997,7 +997,7 @@ "../dependencies.h" "DataStore.h" -1241035920 /home/michael/Programming/Projects/sirrf/src/dependencies.h +1242308067 /home/michael/Programming/Projects/sirrf/src/dependencies.h <assert.h> <fstream> <iostream> @@ -1009,6 +1009,7 @@ <irrlicht.h> <angelscript.h> <sigslot/sigslot.h> + <SFML/System.hpp> 1241784354 /home/michael/Programming/Projects/sirrf/src/core/DataStore.h "../dependencies.h" @@ -1017,11 +1018,11 @@ 1241784354 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" -1242236804 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp +1242311870 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp "Entity.h" "GameManager.h" -1242236673 /home/michael/Programming/Projects/sirrf/src/core/Entity.h +1242310199 /home/michael/Programming/Projects/sirrf/src/core/Entity.h "../dependencies.h" "EntityComponent.h" @@ -1029,25 +1030,26 @@ "../dependencies.h" "Entity.h" -1241786410 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp +1242311455 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" -1242237467 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp +1242311555 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp "EntityManager.h" -1242237467 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h +1242310487 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h "../dependencies.h" "Entity.h" -1242234537 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242311666 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" -1241782433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h +1242308603 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" "GameState.h" "DataStore.h" "EntityManager.h" "EventManager.h" + "../sound/SoundManager.h" "../scripting/ScriptManager.h" 1241010257 /home/michael/Programming/Projects/sirrf/src/core/GameState.h @@ -1236,3 +1238,89 @@ "../../dependencies.h" "SceneComponent.h" +1202520678 /usr/local/include//AL/al.h + +1216759683 /usr/local/include//AL/alc.h + +1242308067 source:/home/michael/Programming/Projects/sirrf/src/sound/SoundManager.cpp + "SoundManager.h" + +1242308141 /home/michael/Programming/Projects/sirrf/src/sound/SoundManager.h + "../dependencies.h" + +1242308358 /usr/local/include//SFML/System.hpp + <SFML/Config.hpp> + <SFML/System/Clock.hpp> + <SFML/System/Lock.hpp> + <SFML/System/Mutex.hpp> + <SFML/System/Randomizer.hpp> + <SFML/System/Sleep.hpp> + <SFML/System/Thread.hpp> + <SFML/System/Unicode.hpp> + <SFML/System/Vector2.hpp> + <SFML/System/Vector3.hpp> + +1242308358 /usr/local/include//SFML/Config.hpp + <climits> + +1242308358 /usr/local/include//SFML/System/Clock.hpp + <SFML/Config.hpp> + +1242308358 /usr/local/include//SFML/System/Lock.hpp + <SFML/System/NonCopyable.hpp> + +1242308358 /usr/local/include//SFML/System/NonCopyable.hpp + <SFML/Config.hpp> + +1242308358 /usr/local/include//SFML/System/Mutex.hpp + <SFML/Config.hpp> + <SFML/System/Win32/Mutex.hpp> + <SFML/System/Unix/Mutex.hpp> + +1242308358 /usr/local/include//SFML/System/Win32/Mutex.hpp + <SFML/System/NonCopyable.hpp> + <windows.h> + +1242308358 /usr/local/include//SFML/System/Unix/Mutex.hpp + <SFML/System/NonCopyable.hpp> + <pthread.h> + +1242308358 /usr/local/include//SFML/System/Randomizer.hpp + <SFML/Config.hpp> + +1242308358 /usr/local/include//SFML/System/Sleep.hpp + <SFML/Config.hpp> + +1242308358 /usr/local/include//SFML/System/Thread.hpp + <SFML/Config.hpp> + <SFML/System/Win32/Thread.hpp> + <SFML/System/Unix/Thread.hpp> + +1242308358 /usr/local/include//SFML/System/Win32/Thread.hpp + <SFML/System/NonCopyable.hpp> + <windows.h> + +1242308358 /usr/local/include//SFML/System/Unix/Thread.hpp + <SFML/System/NonCopyable.hpp> + <pthread.h> + +1242308358 /usr/local/include//SFML/System/Unicode.hpp + <SFML/Config.hpp> + <iterator> + <locale> + <string> + <stdlib.h> + <SFML/System/Unicode.inl> + +1242308358 /usr/local/include//SFML/System/Unicode.inl + +1242308358 /usr/local/include//SFML/System/Vector2.hpp + <SFML/System/Vector2.inl> + +1242308358 /usr/local/include//SFML/System/Vector2.inl + +1242308358 /usr/local/include//SFML/System/Vector3.hpp + <SFML/System/Vector3.inl> + +1242308358 /usr/local/include//SFML/System/Vector3.inl + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-13 18:23:51 UTC (rev 30) +++ trunk/src/sirrf.layout 2009-05-14 14:43:23 UTC (rev 31) @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> - <File name="components/scene/AnimatedMeshComponent.cpp" open="1" top="0" tabpos="5"> - <Cursor position="1706" topLine="20" /> + <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="5"> + <Cursor position="6959" topLine="0" /> </File> - <File name="components/scene/AnimatedMeshComponent.h" open="1" top="1" tabpos="6"> - <Cursor position="2415" topLine="25" /> + <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="6"> + <Cursor position="2365" topLine="25" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1258" topLine="33" /> @@ -43,11 +43,11 @@ <File name="components/scene/ParticleSysComponent.h" open="0" top="0" tabpos="2"> <Cursor position="2007" topLine="31" /> </File> - <File name="components/scene/SceneComponent.cpp" open="1" top="0" tabpos="1"> - <Cursor position="1606" topLine="18" /> + <File name="components/scene/SceneComponent.cpp" open="0" top="0" tabpos="1"> + <Cursor position="4151" topLine="3" /> </File> <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1591" topLine="32" /> + <Cursor position="1662" topLine="24" /> </File> <File name="components/scene/SkyBoxComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1945" topLine="26" /> @@ -74,10 +74,10 @@ <Cursor position="0" topLine="11" /> </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> - <Cursor position="5904" topLine="222" /> + <Cursor position="5904" topLine="16" /> </File> <File name="core/DataStack.h" open="0" top="0" tabpos="0"> - <Cursor position="2589" topLine="75" /> + <Cursor position="2589" topLine="24" /> </File> <File name="core/DataStore.cpp" open="0" top="0" tabpos="0"> <Cursor position="3007" topLine="178" /> @@ -85,39 +85,42 @@ <File name="core/DataStore.h" open="0" top="0" tabpos="0"> <Cursor position="1253" topLine="18" /> </File> - <File name="core/Entity.cpp" open="1" top="0" tabpos="3"> - <Cursor position="11503" topLine="377" /> + <File name="core/Entity.cpp" open="0" top="0" tabpos="3"> + <Cursor position="4693" topLine="15" /> </File> - <File name="core/Entity.h" open="1" top="0" tabpos="4"> - <Cursor position="1993" topLine="29" /> + <File name="core/Entity.h" open="0" top="0" tabpos="4"> + <Cursor position="822" topLine="26" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1192" topLine="9" /> + <Cursor position="1041" topLine="11" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1269" topLine="17" /> + <Cursor position="1269" topLine="23" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="4303" topLine="164" /> + <Cursor position="4763" topLine="173" /> </File> <File name="core/EntityManager.h" open="0" top="0" tabpos="0"> - <Cursor position="770" topLine="15" /> + <Cursor position="989" topLine="19" /> </File> <File name="core/EventManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1209" topLine="21" /> + <Cursor position="0" topLine="3" /> </File> <File name="core/EventManager.h" open="0" top="0" tabpos="0"> - <Cursor position="707" topLine="59" /> + <Cursor position="0" topLine="41" /> </File> - <File name="core/GameManager.cpp" open="1" top="0" tabpos="2"> - <Cursor position="2313" topLine="52" /> + <File name="core/GameManager.cpp" open="0" top="0" tabpos="2"> + <Cursor position="860" topLine="12" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> - <Cursor position="1901" topLine="30" /> + <Cursor position="891" topLine="8" /> </File> <File name="core/GameState.cpp" open="0" top="0" tabpos="0"> <Cursor position="1420" topLine="4" /> </File> + <File name="dependencies.h" open="0" top="0" tabpos="0"> + <Cursor position="1015" topLine="13" /> + </File> <File name="main.cpp" open="0" top="0" tabpos="0"> <Cursor position="1645" topLine="0" /> </File> @@ -127,4 +130,10 @@ <File name="scripting/ScriptManager.h" open="0" top="0" tabpos="1"> <Cursor position="740" topLine="0" /> </File> + <File name="sound/SoundManager.cpp" open="0" top="0" tabpos="1"> + <Cursor position="1125" topLine="7" /> + </File> + <File name="sound/SoundManager.h" open="0" top="0" tabpos="2"> + <Cursor position="906" topLine="0" /> + </File> </CodeBlocks_layout_file> Added: trunk/src/sound/SoundManager.cpp =================================================================== --- trunk/src/sound/SoundManager.cpp (rev 0) +++ trunk/src/sound/SoundManager.cpp 2009-05-14 14:43:23 UTC (rev 31) @@ -0,0 +1,51 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SoundManager.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : The Sound Manager is the central interface point to all +// sound related functions of this program. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "SoundManager.h" + + +// SoundManager class +// SoundManager constructor. +SoundManager::SoundManager() +{ + init(); +} + +// SoundManager deconstructor. +SoundManager::~SoundManager() +{ + clear(); +} + +// Initialises the Sound Manager. +void SoundManager::init() +{ + sf::Clock Clock; + while (Clock.GetElapsedTime() < 5.f) + { + std::cout << Clock.GetElapsedTime() << std::endl; + sf::Sleep(0.5f); + } + +} + +// Clears the Sound Manager. +void SoundManager::clear() +{ +} + +// End of File. Added: trunk/src/sound/SoundManager.h =================================================================== --- trunk/src/sound/SoundManager.h (rev 0) +++ trunk/src/sound/SoundManager.h 2009-05-14 14:43:23 UTC (rev 31) @@ -0,0 +1,41 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SoundManager.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the SoundManager class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __SOUNDMANAGER_H__ +#define __SOUNDMANAGER_H__ + +// Include files +#include "../dependencies.h" + + +// SoundManager class +class SoundManager +{ +public: + + // Initialisation and deinitialisation + SoundManager(); + ~SoundManager(); + + void init(); + void clear(); + + // Methods + +private: + +}; + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-13 18:24:00
|
Revision: 30 http://sirrf.svn.sourceforge.net/sirrf/?rev=30&view=rev Author: zccdark203 Date: 2009-05-13 18:23:51 +0000 (Wed, 13 May 2009) Log Message: ----------- Finished the initial implementation of the scene components. In a later phase I'll probably come back to these components as they will have to been binded into AngelScript. And they might require some small additions in order to work properly with multiple running states. Modified Paths: -------------- trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/sirrf.depend Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-13 18:00:30 UTC (rev 29) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-13 18:23:51 UTC (rev 30) @@ -84,6 +84,49 @@ return mTriSelector; } +// Adds an scene node animator to the component. +void SceneComponent::addAnimator(ISceneNodeAnimator *animator) +{ + mSceneNode->addAnimator(animator); +} + +// Adds a collision response animator to the component. +void SceneComponent::addCollisionResponseAnimator(const vector3df &ellipsoidRadius, + const vector3df &gravityPerSecond, + const vector3df &ellipsoidTranslation, + float slidingValue) +{ + ISceneNodeAnimator *anim = GameManager::Instance()->getSceneManager()-> + createCollisionResponseAnimator(mMetaSelector, mSceneNode, + ellipsoidRadius, gravityPerSecond, ellipsoidTranslation, + slidingValue); + + mSceneNode->addAnimator(anim); + anim->drop(); +} + +// Adds a fly circle animator to the component. +void SceneComponent::addFlyCircleAnimator(const vector3df ¢er, float radius, float speed, + const vector3df &direction) +{ + ISceneNodeAnimator *anim = GameManager::Instance()->getSceneManager()-> + createFlyCircleAnimator(center, radius, speed, direction); + + mSceneNode->addAnimator(anim); + anim->drop(); +} + +// Adds a fly straight animator to the component. +void SceneComponent::addFlyStraightAnimator(const vector3df &startPoint, const vector3df &endPoint, + unsigned int timeForWay, bool loop) +{ + ISceneNodeAnimator *anim = GameManager::Instance()->getSceneManager()-> + createFlyStraightAnimator(startPoint, endPoint, timeForWay, loop); + + mSceneNode->addAnimator(anim); + anim->drop(); +} + // Searches for a SceneComponent within the given entity and if found adds the triangle selector of // that component to the meta selector of this component. void SceneComponent::addToMetaSelector(Entity *entity) Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-13 18:00:30 UTC (rev 29) +++ trunk/src/components/scene/SceneComponent.h 2009-05-13 18:23:51 UTC (rev 30) @@ -35,6 +35,19 @@ IMetaTriangleSelector* getMetaSelector() const; ITriangleSelector* getTriangleSelector() const; + void addAnimator(ISceneNodeAnimator *animator); + + void addCollisionResponseAnimator(const vector3df &ellipsoidRadius = vector3df(30, 60, 30), + const vector3df &gravityPerSecond = vector3df(0, -10, 0), + const vector3df &ellipsoidTranslation = vector3df(0, 0, 0), + float slidingValue = 0.0005f); + + void addFlyCircleAnimator(const vector3df ¢er = vector3df(0, 0, 0), float radius = 100, + float speed = 0.001f, const vector3df &direction = vector3df(0, 0, 0)); + + void addFlyStraightAnimator(const vector3df &startPoint, const vector3df &endPoint, + unsigned int timeForWay, bool loop = false); + void addToMetaSelector(Entity *entity); void addToMetaSelector(SceneComponent *component); void addToMetaSelector(ITriangleSelector *selector); Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-13 18:00:30 UTC (rev 29) +++ trunk/src/sirrf.depend 2009-05-13 18:23:51 UTC (rev 30) @@ -1032,7 +1032,7 @@ 1241786410 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" -1242236673 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp +1242237467 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp "EntityManager.h" 1242237467 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h @@ -1116,11 +1116,11 @@ "scriptstring.h" <string.h> -1242236840 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp +1242238812 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" "../../core/GameManager.h" -1242236839 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h +1242238591 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h "../../dependencies.h" "../../core/EntityComponent.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-13 18:00:37
|
Revision: 29 http://sirrf.svn.sourceforge.net/sirrf/?rev=29&view=rev Author: zccdark203 Date: 2009-05-13 18:00:30 +0000 (Wed, 13 May 2009) Log Message: ----------- Revised the way how Entities are created within Sirrf. I've also made some changes to the removeChild functions of EntityComponent. Modified Paths: -------------- trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/core/EntityManager.cpp trunk/src/core/EntityManager.h trunk/src/sirrf.depend Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-13 17:29:19 UTC (rev 28) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-13 18:00:30 UTC (rev 29) @@ -153,7 +153,7 @@ } // Gets the relative position of the component. -const vector3df& SceneComponent::getPosition() const +const vector3df SceneComponent::getPosition() const { return mSceneNode->getPosition() - pParent->getPosition(); } Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-13 17:29:19 UTC (rev 28) +++ trunk/src/components/scene/SceneComponent.h 2009-05-13 18:00:30 UTC (rev 29) @@ -44,7 +44,7 @@ const aabbox3df& getBoundingBox() const; unsigned int getMaterialCount() const; matrix4 getRelativeTransformation() const; - const vector3df& getPosition() const; + const vector3df getPosition() const; const vector3df& getRotation() const; const vector3df& getScale() const; ESCENE_NODE_TYPE getType() const; Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-05-13 17:29:19 UTC (rev 28) +++ trunk/src/core/Entity.cpp 2009-05-13 18:00:30 UTC (rev 29) @@ -28,18 +28,9 @@ { mID = mIDCount++; - init(); -} + // Add to the Entity Manager. + GameManager::Instance()->getEntityManager()->addEntity(this); -// Entity deconstructor. -Entity::~Entity() -{ - clear(); -} - -// Initialises the entity. -void Entity::init() -{ // Register events. EventManager *pEventMgr = GameManager::Instance()->getEventManager(); @@ -48,8 +39,8 @@ pEventMgr->createEventSlot(groupName, "onPositionChange"); } -// Clears the entity. -void Entity::clear() +// Entity deconstructor. +Entity::~Entity() { // Remove all components. removeAll(); @@ -188,7 +179,7 @@ { // Children. for(unsigned int i = 0; i < mChildren.size(); i++) - delete mChildren[i]; + GameManager::Instance()->getEntityManager()->removeEntity(mChildren[i]); mChildren.clear(); @@ -215,7 +206,7 @@ if(ent == entity) { - delete ent; + GameManager::Instance()->getEntityManager()->removeEntity(ent); mChildren.erase(it); return true; } @@ -237,7 +228,7 @@ if(ent->getID() == id) { - delete ent; + GameManager::Instance()->getEntityManager()->removeEntity(ent); mChildren.erase(it); return true; } @@ -259,7 +250,7 @@ if(ent->getName() == name) { - delete ent; + GameManager::Instance()->getEntityManager()->removeEntity(ent); mChildren.erase(it); return true; } @@ -382,11 +373,6 @@ r = engine->RegisterObjectBehaviour("Entity", asBEHAVE_RELEASE, "void f()", asMETHOD(Entity, refRelease), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "void init()", - asMETHOD(Entity, init), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "void clear()", - asMETHOD(Entity, clear), asCALL_THISCALL); assert(r >= 0); - r = engine->RegisterObjectMethod("Entity", "uint getID()", asMETHOD(Entity, getID), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "const string& getName()", Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-05-13 17:29:19 UTC (rev 28) +++ trunk/src/core/Entity.h 2009-05-13 18:00:30 UTC (rev 29) @@ -33,9 +33,6 @@ Entity(const std::string &name, Entity *parent = NULL); ~Entity(); - void init(); - void clear(); - // AngelScript binding static Entity* refFactory(const std::string &name); void refAdd(); Modified: trunk/src/core/EntityManager.cpp =================================================================== --- trunk/src/core/EntityManager.cpp 2009-05-13 17:29:19 UTC (rev 28) +++ trunk/src/core/EntityManager.cpp 2009-05-13 18:00:30 UTC (rev 29) @@ -61,16 +61,14 @@ } // Creates an entity with the given name and adds it to the Entity Manager. -Entity* EntityManager::createEntity(const std::string &name) +Entity* EntityManager::createEntity(const std::string &name, Entity *parent) { // Look if a entity with given name doesn't already exist. if(getEntity(name)) return NULL; // Add the entity. - Entity *entity = new Entity(name); - mEntities.push_back(entity); - + Entity *entity = new Entity(name, parent); return entity; } Modified: trunk/src/core/EntityManager.h =================================================================== --- trunk/src/core/EntityManager.h 2009-05-13 17:29:19 UTC (rev 28) +++ trunk/src/core/EntityManager.h 2009-05-13 18:00:30 UTC (rev 29) @@ -38,7 +38,7 @@ // Methods bool addEntity(Entity *entity); - Entity* createEntity(const std::string &name); + Entity* createEntity(const std::string &name, Entity *parent = NULL); Entity* getEntity(const unsigned int id); Entity* getEntity(const std::string &name); Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-13 17:29:19 UTC (rev 28) +++ trunk/src/sirrf.depend 2009-05-13 18:00:30 UTC (rev 29) @@ -1017,11 +1017,11 @@ 1241784354 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" -1242233632 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp +1242236804 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp "Entity.h" "GameManager.h" -1242228980 /home/michael/Programming/Projects/sirrf/src/core/Entity.h +1242236673 /home/michael/Programming/Projects/sirrf/src/core/Entity.h "../dependencies.h" "EntityComponent.h" @@ -1032,18 +1032,15 @@ 1241786410 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" -1241206746 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp +1242236673 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp "EntityManager.h" -1241450469 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h +1242237467 /home/michael/Programming/Projects/sirrf/src/core/EntityManager.h "../dependencies.h" "Entity.h" -1242233990 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242234537 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" - "../components/scene/AnimatedMeshComponent.h" - "../components/scene/CameraComponent.h" - "../components/scene/SkyDomeComponent.h" 1241782433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" @@ -1119,11 +1116,11 @@ "scriptstring.h" <string.h> -1242233923 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp +1242236840 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" "../../core/GameManager.h" -1242233095 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h +1242236839 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h "../../dependencies.h" "../../core/EntityComponent.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-13 17:29:28
|
Revision: 28 http://sirrf.svn.sourceforge.net/sirrf/?rev=28&view=rev Author: zccdark203 Date: 2009-05-13 17:29:19 +0000 (Wed, 13 May 2009) Log Message: ----------- Implemented the positioning system for Entities and EntityComponents. Modified Paths: -------------- trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/core/Entity.cpp trunk/src/core/Entity.h trunk/src/sirrf.depend trunk/src/sirrf.layout Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-13 17:29:19 UTC (rev 28) @@ -25,6 +25,7 @@ { // Get a pointer to the scene manager. ISceneManager *pScnMgr = GameManager::Instance()->getSceneManager(); + EventManager *pEventMgr = GameManager::Instance()->getEventManager(); // Initialise the internal scene node. mSceneNode = pScnMgr->addEmptySceneNode(0, parent->getID()); @@ -35,13 +36,26 @@ // Set misc. variables. mName = "SceneComponent"; + + // Register events. + pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", + this, &SceneComponent::onPositionChange); + } // SceneComponent constructor (derivatives). SceneComponent::SceneComponent(Entity *parent, bool isDerived) : EntityComponent(parent) { + // Get a pointer to the scene manager. + EventManager *pEventMgr = GameManager::Instance()->getEventManager(); + + // Set misc. variables. mName = "SceneComponent"; + + // Register events. + pEventMgr->connectEventSignal(std::string("ent#") + parent->getName(), "onPositionChange", + this, &SceneComponent::onPositionChange); } // SceneComponent deconstructor. @@ -141,7 +155,7 @@ // Gets the relative position of the component. const vector3df& SceneComponent::getPosition() const { - return mSceneNode->getPosition(); + return mSceneNode->getPosition() - pParent->getPosition(); } // Gets the rotation of the component. @@ -171,6 +185,7 @@ // Sets the absolute position of the component. void SceneComponent::setAbsolutePosition(const vector3df &position) { + mSceneNode->setPosition(position); } // Enables or disables automatic culling based on the bounding box. @@ -215,7 +230,7 @@ // Sets the relative position of the component. void SceneComponent::setPosition(const vector3df &position) { - mSceneNode->setPosition(position); + mSceneNode->setPosition(pParent->getPosition() + position); } // Sets the rotation of the component. @@ -230,4 +245,12 @@ mSceneNode->setScale(scale); } +// Events +// Updates the position of the component after its parent has been updated. +void SceneComponent::onPositionChange(void *p) +{ + vector3df vec = static_cast<vector3df*>(p)[0]; + mSceneNode->setPosition(mSceneNode->getPosition() + vec); +} + // End of File Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-11 21:28:06 UTC (rev 27) +++ trunk/src/components/scene/SceneComponent.h 2009-05-13 17:29:19 UTC (rev 28) @@ -62,6 +62,9 @@ void setRotation(const vector3df &rotation); void setScale(const vector3df &scale); + // Events + void onPositionChange(void *p); + protected: // Initialisation Modified: trunk/src/core/Entity.cpp =================================================================== --- trunk/src/core/Entity.cpp 2009-05-11 21:28:06 UTC (rev 27) +++ trunk/src/core/Entity.cpp 2009-05-13 17:29:19 UTC (rev 28) @@ -23,8 +23,8 @@ unsigned int Entity::mIDCount = 0; // Entity constructor. -Entity::Entity(const std::string &name) -: mRefCount(1), mName(name) +Entity::Entity(const std::string &name, Entity *parent) +: mRefCount(1), pParent(parent), mName(name), mPosition(0, 0, 0) { mID = mIDCount++; @@ -40,6 +40,12 @@ // Initialises the entity. void Entity::init() { + // Register events. + EventManager *pEventMgr = GameManager::Instance()->getEventManager(); + + std::string groupName = "ent#" + mName; + pEventMgr->createEventGroup(groupName); + pEventMgr->createEventSlot(groupName, "onPositionChange"); } // Clears the entity. @@ -47,6 +53,9 @@ { // Remove all components. removeAll(); + + // Remove events. + GameManager::Instance()->getEventManager()->removeEventGroup(std::string("ent#") + mName); } // AngelScript: Will be used to instanciate objects of this class. @@ -80,6 +89,23 @@ return mName; } +// Adds a child to the entity. +bool Entity::addChild(Entity *entity) +{ + // Did we get a pointer to a entity? + if(entity == NULL) + return false; + + // Check if a entity of the given type doesn't already exist. + if(getChild(entity->getName())) + return false; + + // Add new component. + mChildren.push_back(entity); + + return true; +} + // Adds a component to the entity. bool Entity::addComponent(EntityComponent *component) { @@ -97,6 +123,30 @@ return true; } +// Gets the child with the given ID from this entity. +Entity* Entity::getChild(const unsigned int id) +{ + for(unsigned int i = 0; i < mChildren.size(); i++) + { + if(mChildren[i]->getID() == id) + return mChildren[i]; + } + + return NULL; +} + +// Gets the child with the given name from this entity. +Entity* Entity::getChild(const std::string &name) +{ + for(unsigned int i = 0; i < mChildren.size(); i++) + { + if(mChildren[i]->getName() == name) + return mChildren[i]; + } + + return NULL; +} + // Gets the component with the given ID from this entity. EntityComponent* Entity::getComponent(const unsigned int id) { @@ -121,15 +171,104 @@ return NULL; } -// Removes all components. +// Gets the parent of this entity. +Entity* Entity::getParent() const +{ + return pParent; +} + +// Gets the position of the entity. +const vector3df& Entity::getPosition() const +{ + return mPosition; +} + +// Removes all children and components. void Entity::removeAll() { + // Children. + for(unsigned int i = 0; i < mChildren.size(); i++) + delete mChildren[i]; + + mChildren.clear(); + + // Components. for(unsigned int i = 0; i < mComponents.size(); i++) delete mComponents[i]; mComponents.clear(); } +// Removes the given child. +bool Entity::removeChild(Entity *entity) +{ + // Did we get a valid pointer? + if(entity == NULL) + return false; + + // Try to remove the entity. + vector<Entity*>::iterator it; + + for(it = mChildren.begin(); it < mChildren.end(); it++) + { + Entity *ent = *it; + + if(ent == entity) + { + delete ent; + mChildren.erase(it); + return true; + } + } + + // We couldn't find the entity and thus couldn't remove it. + return false; +} + +// Removes the child with the given ID. +bool Entity::removeChild(const unsigned int id) +{ + // Try to remove the entity. + vector<Entity*>::iterator it; + + for(it = mChildren.begin(); it < mChildren.end(); it++) + { + Entity *ent = *it; + + if(ent->getID() == id) + { + delete ent; + mChildren.erase(it); + return true; + } + } + + // We couldn't find the entity and thus couldn't remove it. + return false; +} + +// Removes the child with the given name. +bool Entity::removeChild(const std::string &name) +{ + // Try to remove the entity. + vector<Entity*>::iterator it; + + for(it = mChildren.begin(); it < mChildren.end(); it++) + { + Entity *ent = *it; + + if(ent->getName() == name) + { + delete ent; + mChildren.erase(it); + return true; + } + } + + // We couldn't find the entity and thus couldn't remove it. + return false; +} + // Removes the given component. bool Entity::removeComponent(EntityComponent *component) { @@ -137,7 +276,7 @@ if(component == NULL) return false; - // Try to remove the entity. + // Try to remove the component. vector<EntityComponent*>::iterator it; for(it = mComponents.begin(); it < mComponents.end(); it++) @@ -159,7 +298,7 @@ // Removes the component with the given ID. bool Entity::removeComponent(const unsigned int id) { - // Try to remove the entity. + // Try to remove the component. vector<EntityComponent*>::iterator it; for(it = mComponents.begin(); it < mComponents.end(); it++) @@ -181,7 +320,7 @@ // Removes the component with the given name. bool Entity::removeComponent(const std::string &name) { - // Try to remove the entity. + // Try to remove the component. vector<EntityComponent*>::iterator it; for(it = mComponents.begin(); it < mComponents.end(); it++) @@ -200,7 +339,31 @@ return false; } +// Sets the position of the entity. +void Entity::setPosition(const vector3df &position) +{ + // Determine difference. + vector3df diff = position - mPosition; + // Set position. + mPosition = position; + + // Set position for children, components and misc. subscribers. + for(unsigned int i = 0; i < mChildren.size(); i++) + mChildren[i]->onPositionChange(diff); + + GameManager::Instance()->getEventManager()->emitEvent(std::string("ent#") + mName, + "onPositionChange", &diff); +} + +// Changes the position of the entity if its parent has changed its position. +// NOTE: This is a semi-event function; it's called directly by its parent. +void Entity::onPositionChange(const vector3df &diff) +{ + mPosition += diff; +} + + // Entity Angelscript binding. void bindEntity(asIScriptEngine *engine) { @@ -229,9 +392,17 @@ r = engine->RegisterObjectMethod("Entity", "const string& getName()", asMETHOD(Entity, getName), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void addChild(Entity @entity)", + asMETHOD(Entity, addChild), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "void addComponent(EntityComponent @component)", asMETHOD(Entity, addComponent), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "Entity@ getChild(const uint id)", + asMETHODPR(Entity, getChild, (const unsigned int), Entity*), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "Entity@ getChild(const string &name)", + asMETHODPR(Entity, getChild, (const std::string &), Entity*), + asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "EntityComponent@ getComponent(const uint id)", asMETHODPR(Entity, getComponent, (const unsigned int), EntityComponent*), asCALL_THISCALL); assert(r >= 0); @@ -239,8 +410,20 @@ asMETHODPR(Entity, getComponent, (const std::string &), EntityComponent*), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "Entity@ getParent()", + asMETHOD(Entity, getParent), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "void removeAll()", asMETHOD(Entity, removeAll), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "bool removeChild(Entity @entity)", + asMETHODPR(Entity, removeChild, (Entity*), bool), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "bool removeChild(const uint id)", + asMETHODPR(Entity, removeChild, (const unsigned int), bool), + asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Entity", "bool removeChild(const string &name)", + asMETHODPR(Entity, removeChild, (const std::string&), bool), + asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("Entity", "bool removeComponent(EntityComponent @component)", asMETHODPR(Entity, removeComponent, (EntityComponent*), bool), asCALL_THISCALL); assert(r >= 0); Modified: trunk/src/core/Entity.h =================================================================== --- trunk/src/core/Entity.h 2009-05-11 21:28:06 UTC (rev 27) +++ trunk/src/core/Entity.h 2009-05-13 17:29:19 UTC (rev 28) @@ -30,7 +30,7 @@ public: // Initialisation and deinitialisation - Entity(const std::string &name); + Entity(const std::string &name, Entity *parent = NULL); ~Entity(); void init(); @@ -45,16 +45,31 @@ unsigned int getID() const; const std::string& getName() const; - bool addComponent(EntityComponent* component); + bool addChild(Entity *entity); + bool addComponent(EntityComponent *component); + Entity* getChild(const unsigned int id); + Entity* getChild(const std::string &name); EntityComponent* getComponent(const unsigned int id); EntityComponent* getComponent(const std::string &name); + Entity *getParent() const; + + const vector3df& getPosition() const; + void removeAll(); + bool removeChild(Entity *entity); + bool removeChild(const unsigned int id); + bool removeChild(const std::string &name); bool removeComponent(EntityComponent *component); bool removeComponent(const unsigned int id); bool removeComponent(const std::string &name); + void setPosition(const vector3df &position); + + // Events + void onPositionChange(const vector3df &diff); + private: // Static members @@ -64,9 +79,14 @@ int mRefCount; // Normal members + Entity *pParent; + unsigned int mID; std::string mName; + vector3df mPosition; + + vector<Entity*> mChildren; vector<EntityComponent*> mComponents; }; Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-11 21:28:06 UTC (rev 27) +++ trunk/src/sirrf.depend 2009-05-13 17:29:19 UTC (rev 28) @@ -1017,11 +1017,11 @@ 1241784354 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" -1241786392 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp +1242233632 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp "Entity.h" "GameManager.h" -1241205828 /home/michael/Programming/Projects/sirrf/src/core/Entity.h +1242228980 /home/michael/Programming/Projects/sirrf/src/core/Entity.h "../dependencies.h" "EntityComponent.h" @@ -1039,10 +1039,11 @@ "../dependencies.h" "Entity.h" -1242073177 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242233990 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" "../components/scene/AnimatedMeshComponent.h" "../components/scene/CameraComponent.h" + "../components/scene/SkyDomeComponent.h" 1241782433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" @@ -1071,7 +1072,7 @@ 1240939945 source:/home/michael/Programming/Projects/sirrf/src/core/EventSubscriber.cpp -1241111981 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp +1242233674 source:/home/michael/Programming/Projects/sirrf/src/core/EventManager.cpp "EventManager.h" 1241450474 /home/michael/Programming/Projects/sirrf/src/core/EventManager.h @@ -1118,11 +1119,11 @@ "scriptstring.h" <string.h> -1242076632 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp +1242233923 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" "../../core/GameManager.h" -1242072340 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h +1242233095 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h "../../dependencies.h" "../../core/EntityComponent.h" @@ -1172,11 +1173,11 @@ "../../dependencies.h" "SceneComponent.h" -1242073200 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp +1242233094 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp "AnimatedMeshComponent.h" "../../core/GameManager.h" -1241877528 /home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.h +1242233061 /home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.h "../../dependencies.h" "SceneComponent.h" Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-11 21:28:06 UTC (rev 27) +++ trunk/src/sirrf.layout 2009-05-13 17:29:19 UTC (rev 28) @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> - <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="3498" topLine="3" /> + <File name="components/scene/AnimatedMeshComponent.cpp" open="1" top="0" tabpos="5"> + <Cursor position="1706" topLine="20" /> </File> - <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1577" topLine="25" /> + <File name="components/scene/AnimatedMeshComponent.h" open="1" top="1" tabpos="6"> + <Cursor position="2415" topLine="25" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1258" topLine="33" /> @@ -43,8 +43,8 @@ <File name="components/scene/ParticleSysComponent.h" open="0" top="0" tabpos="2"> <Cursor position="2007" topLine="31" /> </File> - <File name="components/scene/SceneComponent.cpp" open="1" top="1" tabpos="1"> - <Cursor position="1606" topLine="6" /> + <File name="components/scene/SceneComponent.cpp" open="1" top="0" tabpos="1"> + <Cursor position="1606" topLine="18" /> </File> <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1591" topLine="32" /> @@ -85,14 +85,14 @@ <File name="core/DataStore.h" open="0" top="0" tabpos="0"> <Cursor position="1253" topLine="18" /> </File> - <File name="core/Entity.cpp" open="0" top="0" tabpos="3"> - <Cursor position="5686" topLine="200" /> + <File name="core/Entity.cpp" open="1" top="0" tabpos="3"> + <Cursor position="11503" topLine="377" /> </File> - <File name="core/Entity.h" open="0" top="0" tabpos="0"> - <Cursor position="1592" topLine="24" /> + <File name="core/Entity.h" open="1" top="0" tabpos="4"> + <Cursor position="1993" topLine="29" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1192" topLine="24" /> + <Cursor position="1192" topLine="9" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1269" topLine="17" /> @@ -104,13 +104,13 @@ <Cursor position="770" topLine="15" /> </File> <File name="core/EventManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="171" /> + <Cursor position="1209" topLine="21" /> </File> <File name="core/EventManager.h" open="0" top="0" tabpos="0"> - <Cursor position="707" topLine="27" /> + <Cursor position="707" topLine="59" /> </File> - <File name="core/GameManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="1014" topLine="0" /> + <File name="core/GameManager.cpp" open="1" top="0" tabpos="2"> + <Cursor position="2313" topLine="52" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> <Cursor position="1901" topLine="30" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-11 21:28:28
|
Revision: 27 http://sirrf.svn.sourceforge.net/sirrf/?rev=27&view=rev Author: zccdark203 Date: 2009-05-11 21:28:06 +0000 (Mon, 11 May 2009) Log Message: ----------- Added ITriangleSelectors and IMetaTriangleSelectors to the Scene Components. This will be needed for collision detection later on. Furthermore I've remove TextComponent from the project as the same functionality can be achieved through TextBillboardComponent. But I've also added three new components: OctTreeComponent, SkyDomeComponent and SkyBoxComponent. The implementation of SceneComponent is still incomplete, though. Affectors will be added the next time. Modified Paths: -------------- trunk/src/components/scene/AnimatedMeshComponent.cpp 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/ParticleSysComponent.cpp trunk/src/components/scene/SceneComponent.cpp trunk/src/components/scene/SceneComponent.h trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout Added Paths: ----------- trunk/src/components/scene/OctTreeComponent.cpp trunk/src/components/scene/OctTreeComponent.h trunk/src/components/scene/SkyBoxComponent.cpp trunk/src/components/scene/SkyBoxComponent.h trunk/src/components/scene/SkyDomeComponent.cpp trunk/src/components/scene/SkyDomeComponent.h Removed Paths: ------------- trunk/src/components/scene/TextComponent.cpp trunk/src/components/scene/TextComponent.h Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,13 +23,19 @@ AnimatedMeshComponent::AnimatedMeshComponent(Entity *parent) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(0, 0, parent->getID(), vector3df(0, 0, 0), vector3df(0, 0, 0), vector3df(1.0f, 1.0f, 1.0f), true); mSceneNode = mAnimatedMeshSN; mShadowVolumeSN = NULL; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mAnimatedMeshSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // AnimatedMeshComponent constructor. @@ -37,13 +43,19 @@ const vector3df &rotation, const vector3df &scale) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mAnimatedMeshSN = pSceneMgr->addAnimatedMeshSceneNode(pSceneMgr->getMesh(fileName.c_str()), 0, parent->getID(), vector3df(0, 0, 0), rotation, scale, true); mSceneNode = mAnimatedMeshSN; mShadowVolumeSN = NULL; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mAnimatedMeshSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // AnimatedMeshComponent constructor. @@ -57,6 +69,10 @@ vector3df(0, 0, 0), rotation, scale, true); mSceneNode = mAnimatedMeshSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mAnimatedMeshSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // AnimatedMeshComponent deconstructor. Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,11 +23,17 @@ BillboardComponent::BillboardComponent(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. mBillboardSN = pSceneMgr->addBillboardSceneNode(0, dimension2df(10.0f, 10.0f), vector3df(0, 0, 0), parent->getID()); mSceneNode = mBillboardSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // BillboardComponent constructor. @@ -35,11 +41,17 @@ const SColor &colorTop, const SColor &colorBottom) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mBillboardSN = pSceneMgr->addBillboardSceneNode(0, size, vector3df(0, 0, 0), parent->getID(), colorTop, colorBottom); mSceneNode = mBillboardSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // BillboardComponent constructor (derivatives). Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/CameraComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,12 +23,18 @@ CameraComponent::CameraComponent(Entity *parent, const vector3df &lookat) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mCameraSN = pSceneMgr->addCameraSceneNode(0, vector3df(0, 0, 0), lookat, parent->getID()); mSceneNode = mCameraSN; mCameraAnimator = NULL; + + // Set-up internal mechanism for collision detection. + mTriSelector = NULL; + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // CameraComponent deconstructor. @@ -207,6 +213,7 @@ animMaya->setRotateSpeed(rotateSpeed); animMaya->setMoveSpeed(translationSpeed); animMaya->setZoomSpeed(zoomSpeed); + animMaya->drop(); mCameraAnimator = animMaya; } Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/LightComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,21 +23,33 @@ LightComponent::LightComponent(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. mLightSN = pSceneMgr->addLightSceneNode(0, vector3df(0, 0, 0), SColorf(1.0f, 1.0f, 1.0f), 100.0f, parent->getID()); mSceneNode = mLightSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = NULL; + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // LightComponent constructor. LightComponent::LightComponent(Entity *parent, const SColorf &color, float radius) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mLightSN = pSceneMgr->addLightSceneNode(0, vector3df(0, 0, 0), color, radius, parent->getID()); mSceneNode = mLightSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = NULL; + mMetaSelector = NULL; } // LightComponent deconstructor. Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/MeshComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,11 +23,17 @@ MeshComponent::MeshComponent(Entity *parent) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, parent->getID(), vector3df(0, 30, -40), vector3df(0, 0, 0), vector3df(1.0f, 1.0f, 1.0f), true); mSceneNode = mMeshSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mMeshSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // MeshComponent constructor. @@ -35,12 +41,18 @@ const vector3df &rotation, const vector3df &scale) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mMeshSN = pSceneMgr->addMeshSceneNode(pSceneMgr->getMesh(fileName.c_str()), 0, parent->getID(), vector3df(0, 0, 0), rotation, scale, true); mSceneNode = mMeshSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mMeshSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // MeshComponent constructor. @@ -48,11 +60,17 @@ const vector3df &scale) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mMeshSN = pSceneMgr->addMeshSceneNode(mesh, 0, parent->getID(), vector3df(0, 0, 0), rotation, scale, true); mSceneNode = mMeshSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mMeshSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // MeshComponent deconstructor. Added: trunk/src/components/scene/OctTreeComponent.cpp =================================================================== --- trunk/src/components/scene/OctTreeComponent.cpp (rev 0) +++ trunk/src/components/scene/OctTreeComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -0,0 +1,74 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: OctTreeComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Component wrapper of Irrlicht's SceneManager function +// addOctTreeSceneNode(...). +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "OctTreeComponent.h" +#include "../../core/GameManager.h" + + +// OctTreeComponent class +// OctTreeComponent constructor. +OctTreeComponent::OctTreeComponent(Entity *parent, const std::string &fileName, int minPolysPerNode) +: SceneComponent(parent, true) +{ + // Get pointers to needed sub-systems of the Game Manager. + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + // Create the internal scene node. + IMesh *mesh = pSceneMgr->getMesh(fileName.c_str()); + mSceneNode = pSceneMgr->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); +} + +// OctTreeComponent constructor. +OctTreeComponent::OctTreeComponent(Entity *parent, IMesh *mesh, int minPolysPerNode) +: 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->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); +} + +// OctTreeComponent constructor. +OctTreeComponent::OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, int minPolysPerNode) +: 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->addOctTreeSceneNode(mesh, 0, parent->getID(), minPolysPerNode, true); + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createOctTreeTriangleSelector(mesh, mSceneNode); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); +} + +// OctTreeComponent deconstructor. +OctTreeComponent::~OctTreeComponent() +{ +} + +// End of File Added: trunk/src/components/scene/OctTreeComponent.h =================================================================== --- trunk/src/components/scene/OctTreeComponent.h (rev 0) +++ trunk/src/components/scene/OctTreeComponent.h 2009-05-11 21:28:06 UTC (rev 27) @@ -0,0 +1,36 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: OctTreeComponent.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the OctTreeComponent class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __OCTTREECOMPONENT_H__ +#define __OCTTREECOMPONENT_H__ + +// Include files +#include "../../dependencies.h" +#include "SceneComponent.h" + + +// OctTreeComponent class +class OctTreeComponent : public SceneComponent +{ +public: + + // Initialisation and deinitialisation + OctTreeComponent(Entity *parent, const std::string &fileName, int minPolysPerNode = 256); + OctTreeComponent(Entity *parent, IMesh *mesh, int minPolysPerNode = 256); + OctTreeComponent(Entity *parent, IAnimatedMesh *mesh, int minPolysPerNode = 512); + ~OctTreeComponent(); +}; + +#endif Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -24,12 +24,18 @@ const vector3df &scale) : SceneComponent(parent, true) { + // Get pointers to needed sub-systems of the Game Manager. ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + // Create the internal scene node. mParticleSystemSN = pSceneMgr->addParticleSystemSceneNode(true, 0, parent->getID(), vector3df(0, 0, 0), rotation, scale); mSceneNode = mParticleSystemSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = NULL; + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // ParticleSysComponent deconstructor. Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,19 +23,33 @@ SceneComponent::SceneComponent(Entity *parent) : EntityComponent(parent) { + // Get a pointer to the scene manager. + ISceneManager *pScnMgr = GameManager::Instance()->getSceneManager(); + + // Initialise the internal scene node. + mSceneNode = pScnMgr->addEmptySceneNode(0, parent->getID()); + + // Set up collision detection for this component. + mTriSelector = pScnMgr->createTriangleSelectorFromBoundingBox(mSceneNode); + mMetaSelector =pScnMgr->createMetaTriangleSelector(); + + // Set misc. variables. + mName = "SceneComponent"; } // SceneComponent constructor (derivatives). SceneComponent::SceneComponent(Entity *parent, bool isDerived) : EntityComponent(parent) { + mName = "SceneComponent"; } // SceneComponent deconstructor. SceneComponent::~SceneComponent() { - if(mSceneNode != NULL) - mSceneNode->remove(); + if(mSceneNode != NULL) mSceneNode->remove(); + if(mTriSelector != NULL) mTriSelector->drop(); + if(mMetaSelector != NULL) mMetaSelector->drop(); } // Gets a direct pointer to the ISceneNode. @@ -44,6 +58,56 @@ return mSceneNode; } +// Gets the internal meta selector. (for internal use) +IMetaTriangleSelector* SceneComponent::getMetaSelector() const +{ + return mMetaSelector; +} + +// Gets the internal triangle selector. (for use by external entities) +ITriangleSelector* SceneComponent::getTriangleSelector() const +{ + return mTriSelector; +} + +// Searches for a SceneComponent within the given entity and if found adds the triangle selector of +// that component to the meta selector of this component. +void SceneComponent::addToMetaSelector(Entity *entity) +{ + if(entity != NULL && mMetaSelector != NULL) + { + SceneComponent *component = static_cast<SceneComponent*>(entity-> + getComponent("SceneComponent")); + + if(component != NULL) + { + ITriangleSelector *selector = component->getTriangleSelector(); + + if(selector != NULL) + mMetaSelector->addTriangleSelector(selector); + } + } +} + +// Adds the triangle selector of the given component to the meta selector of this component. +void SceneComponent::addToMetaSelector(SceneComponent *component) +{ + if(component != NULL && mMetaSelector != NULL) + { + ITriangleSelector *selector = component->getTriangleSelector(); + + if(selector != NULL) + mMetaSelector->addTriangleSelector(selector); + } +} + +// Adds the given triangle selector to the meta selector of this component. +void SceneComponent::addToMetaSelector(ITriangleSelector *selector) +{ + if(selector != NULL && mMetaSelector != NULL) + mMetaSelector->addTriangleSelector(selector); +} + // Gets the abolute position of the component. vector3df SceneComponent::getAbsolutePosition() const { Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/SceneComponent.h 2009-05-11 21:28:06 UTC (rev 27) @@ -32,7 +32,13 @@ // Methods ISceneNode* getSceneNode(); + IMetaTriangleSelector* getMetaSelector() const; + ITriangleSelector* getTriangleSelector() const; + void addToMetaSelector(Entity *entity); + void addToMetaSelector(SceneComponent *component); + void addToMetaSelector(ITriangleSelector *selector); + vector3df getAbsolutePosition() const; bool getAutomaticCulling() const; const aabbox3df& getBoundingBox() const; @@ -63,6 +69,8 @@ // Members ISceneNode *mSceneNode; + IMetaTriangleSelector *mMetaSelector; + ITriangleSelector *mTriSelector; private: }; Added: trunk/src/components/scene/SkyBoxComponent.cpp =================================================================== --- trunk/src/components/scene/SkyBoxComponent.cpp (rev 0) +++ trunk/src/components/scene/SkyBoxComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -0,0 +1,69 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SkyBoxComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Component wrapper of Irrlicht's SceneManager function +// addSkyBoxSceneNode(...). +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "SkyBoxComponent.h" +#include "../../core/GameManager.h" + + +// SkyBoxComponent class +// 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; +} + +// SkyBoxComponent constructor. +SkyBoxComponent::SkyBoxComponent(Entity *parent, const std::string &top, const std::string &bottom, + const std::string &left, const std::string &right, + const std::string &front, const std::string &back) +: 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->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()); + + // Set-up internal mechanism for collision detection. + mTriSelector = NULL; + mMetaSelector = NULL; +} + +// SkyBoxComponent deconstructor. +SkyBoxComponent::~SkyBoxComponent() +{ +} + +// End of File Added: trunk/src/components/scene/SkyBoxComponent.h =================================================================== --- trunk/src/components/scene/SkyBoxComponent.h (rev 0) +++ trunk/src/components/scene/SkyBoxComponent.h 2009-05-11 21:28:06 UTC (rev 27) @@ -0,0 +1,38 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SkyBoxComponent.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the SkyBoxComponent class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __SKYBOXCOMPONENT_H__ +#define __SKYBOXCOMPONENT_H__ + +// Include files +#include "../../dependencies.h" +#include "SceneComponent.h" + + +// SkyBoxComponent class +class SkyBoxComponent : public SceneComponent +{ +public: + + // Initialisation and deinitialisation + SkyBoxComponent(Entity *parent, ITexture *top, ITexture *bottom, ITexture *left, + ITexture *right, ITexture *front, ITexture *back); + SkyBoxComponent(Entity *parent, const std::string &top, const std::string &bottom, + const std::string &left, const std::string &right, const std::string &front, + const std::string &back); + ~SkyBoxComponent(); +}; + +#endif Added: trunk/src/components/scene/SkyDomeComponent.cpp =================================================================== --- trunk/src/components/scene/SkyDomeComponent.cpp (rev 0) +++ trunk/src/components/scene/SkyDomeComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -0,0 +1,63 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SkyDomeComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Component wrapper of Irrlicht's SceneManager function +// addSkyDomeSceneNode(...). +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "SkyDomeComponent.h" +#include "../../core/GameManager.h" + + +// SkyDomeComponent class +// SkyDomeComponent constructor. +SkyDomeComponent::SkyDomeComponent(Entity *parent, const std::string &fileName, unsigned int hRes, + unsigned int vRes, float texturePerc, float spherePerc) +: 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, 0, parent->getID()); + + // Set-up internal mechanism for collision detection. + mTriSelector = NULL; + mMetaSelector = NULL; +} + +// SkyDomeComponent constructor. +SkyDomeComponent::SkyDomeComponent(Entity *parent, ITexture *texture, unsigned int hRes, + unsigned int vRes, float texturePerc, float spherePerc) +: 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->addSkyDomeSceneNode(texture, hRes, vRes, texturePerc, spherePerc, 0, + parent->getID()); + + // Set-up internal mechanism for collision detection. + mTriSelector = NULL; + mMetaSelector = NULL; +} + +// SkyDomeComponent deconstructor. +SkyDomeComponent::~SkyDomeComponent() +{ +} + +// End of File Added: trunk/src/components/scene/SkyDomeComponent.h =================================================================== --- trunk/src/components/scene/SkyDomeComponent.h (rev 0) +++ trunk/src/components/scene/SkyDomeComponent.h 2009-05-11 21:28:06 UTC (rev 27) @@ -0,0 +1,37 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: SkyDomeComponent.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the SkyDomeComponent class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __SKYBOXCOMPONENT_H__ +#define __SKYBOXCOMPONENT_H__ + +// Include files +#include "../../dependencies.h" +#include "SceneComponent.h" + + +// SkyDomeComponent class +class SkyDomeComponent : public SceneComponent +{ +public: + + // Initialisation and deinitialisation + SkyDomeComponent(Entity *parent, const std::string &fileName, unsigned int hRes = 16, + unsigned int vRes = 8, float texturePerc = 0.9f, float spherePerc = 2.0f); + SkyDomeComponent(Entity *parent, ITexture *texture, unsigned int hRes = 16, + unsigned int vRes = 8, float texturePerc = 0.9f, float spherePerc = 2.0f); + ~SkyDomeComponent(); +}; + +#endif Modified: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,13 +23,19 @@ 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(); } // TerrainComponent constructor. @@ -38,12 +44,18 @@ const SColor &vertexColor, int maxLOD, int smoothFactor) : 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(fileName.c_str(), 0, parent->getID(), vector3df(0.0f, 0.0f, 0.0f), rotation, scale, vertexColor, maxLOD, ETPS_17, smoothFactor, true); mSceneNode = mTerrainSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTerrainTriangleSelector(mTerrainSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // TerrainComponent deconstructor. Modified: trunk/src/components/scene/TextBillboardComponent.cpp =================================================================== --- trunk/src/components/scene/TextBillboardComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/TextBillboardComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -23,14 +23,20 @@ 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), vector3df(0, 0, 0), parent->getID()); mBillboardSN = mBillboardTextSN; mSceneNode = mBillboardTextSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardTextSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // TextBillboardComponent constructor. @@ -39,14 +45,20 @@ 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, vector3df(0,0,0), parent->getID(), colorTop, colorBottom); mBillboardSN = mBillboardTextSN; mSceneNode = mBillboardTextSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardTextSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // TextBillboardComponent constructor. @@ -55,9 +67,11 @@ 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. wchar_t wchartBuffer[text.length()+1]; mbstowcs(wchartBuffer, text.c_str(), text.length()+1); @@ -66,6 +80,10 @@ parent->getID(), colorTop, colorBottom); mBillboardSN = mBillboardTextSN; mSceneNode = mBillboardTextSN; + + // Set-up internal mechanism for collision detection. + mTriSelector = pSceneMgr->createTriangleSelectorFromBoundingBox(mBillboardTextSN); + mMetaSelector = pSceneMgr->createMetaTriangleSelector(); } // TextBillboardComponent deconstructor. Deleted: trunk/src/components/scene/TextComponent.cpp =================================================================== --- trunk/src/components/scene/TextComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/TextComponent.cpp 2009-05-11 21:28:06 UTC (rev 27) @@ -1,97 +0,0 @@ -// ///////////////////////////////////////////////////////////////////////////// -// -// Name: TextComponent.cpp -// Author: Michael Bartsch (ZCCdark203) -// -// Desc : Component wrapper of Irrlicht's ITextSceneNode. -// -// License: Copyright (C) 2009 Michael Bartsch -// -// 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 "TextComponent.h" -#include "../../core/GameManager.h" - - -// TextComponent class -// TextComponent constructor (default). -TextComponent::TextComponent(Entity *parent) -: SceneComponent(parent, true) -{ - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - - mTextSN = pSceneMgr->addTextSceneNode(pGUIEnv->getBuiltInFont(), 0, SColor(100, 255, 255, 255), - 0, vector3df(0, 0, 0), parent->getID()); - mSceneNode = mTextSN; -} - -// TextComponent constructor. -TextComponent::TextComponent(Entity *parent, const std::string fontFilename, const wchar_t *text, - const SColor &color) -: SceneComponent(parent, true) -{ - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - - mTextSN = pSceneMgr->addTextSceneNode(pGUIEnv->getFont(fontFilename.c_str()), text, color, 0, - vector3df(0,0,0), parent->getID()); - mSceneNode = mTextSN; -} - -// TextComponent constructor. -TextComponent::TextComponent(Entity *parent, const std::string fontFilename, - const std::string &text, const SColor &color) -: SceneComponent(parent, true) -{ - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - - wchar_t wchartBuffer[text.length()+1]; - mbstowcs(wchartBuffer, text.c_str(), text.length()+1); - - mTextSN = pSceneMgr->addTextSceneNode(pGUIEnv->getFont(fontFilename.c_str()), wchartBuffer, - color, 0, vector3df(0,0,0), parent->getID()); - mSceneNode = mTextSN; -} - -// TextComponent deconstructor. -TextComponent::~TextComponent() -{ - mTextSN->remove(); - mSceneNode = NULL; -} - -// Gets a direct pointer to the ITextSceneNode. -ITextSceneNode* TextComponent::getTextSceneNode() -{ - return mTextSN; -} - -// Sets the text string. -void TextComponent::setText(const std::string &text) -{ - wchar_t wchartBuffer[text.length()+1]; - mbstowcs(wchartBuffer, text.c_str(), text.length()+1); - - mTextSN->setText(wchartBuffer); -} - -// Sets the text string. -void TextComponent::setText(const wchar_t *text) -{ - mTextSN->setText(text); -} - -// Sets the color of the text. -void TextComponent::setTextColor(const SColor &color) -{ - mTextSN->setTextColor(color); -} - -// End of File Deleted: trunk/src/components/scene/TextComponent.h =================================================================== --- trunk/src/components/scene/TextComponent.h 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/components/scene/TextComponent.h 2009-05-11 21:28:06 UTC (rev 27) @@ -1,51 +0,0 @@ -// ///////////////////////////////////////////////////////////////////////////// -// -// Name: TextComponent.h -// Author: Michael Bartsch (ZCCdark203) -// -// Desc : Declaration of the TextComponent class. -// -// License: Copyright (C) 2009 Michael Bartsch -// -// 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 __TEXTCOMPONENT_H__ -#define __TEXTCOMPONENT_H__ - -// Include files -#include "../../dependencies.h" -#include "SceneComponent.h" - - -// TextComponent class -class TextComponent : public SceneComponent -{ -public: - - // Initialisation and deinitialisation - TextComponent(Entity *parent); - TextComponent(Entity *parent, const std::string fontFilename, const wchar_t *text, - const SColor &color = SColor(100, 255, 255, 255)); - TextComponent(Entity *parent, const std::string fontFilename, const std::string &text, - const SColor &color = SColor(100, 255, 255, 255)); - ~TextComponent(); - - // Methods - ITextSceneNode* getTextSceneNode(); - - void setText(const std::string &text); - void setText(const wchar_t *text); - void setTextColor(const SColor &color); - -private: - - // Members - ITextSceneNode *mTextSN; -}; - -#endif - Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/sirrf.cbp 2009-05-11 21:28:06 UTC (rev 27) @@ -58,16 +58,20 @@ <Unit filename="components/scene/LightComponent.h" /> <Unit filename="components/scene/MeshComponent.cpp" /> <Unit filename="components/scene/MeshComponent.h" /> + <Unit filename="components/scene/OctTreeComponent.cpp" /> + <Unit filename="components/scene/OctTreeComponent.h" /> <Unit filename="components/scene/ParticleSysComponent.cpp" /> <Unit filename="components/scene/ParticleSysComponent.h" /> <Unit filename="components/scene/SceneComponent.cpp" /> <Unit filename="components/scene/SceneComponent.h" /> + <Unit filename="components/scene/SkyBoxComponent.cpp" /> + <Unit filename="components/scene/SkyBoxComponent.h" /> + <Unit filename="components/scene/SkyDomeComponent.cpp" /> + <Unit filename="components/scene/SkyDomeComponent.h" /> <Unit filename="components/scene/TerrainComponent.cpp" /> <Unit filename="components/scene/TerrainComponent.h" /> <Unit filename="components/scene/TextBillboardComponent.cpp" /> <Unit filename="components/scene/TextBillboardComponent.h" /> - <Unit filename="components/scene/TextComponent.cpp" /> - <Unit filename="components/scene/TextComponent.h" /> <Unit filename="core/DataStack.cpp" /> <Unit filename="core/DataStack.h" /> <Unit filename="core/DataStore.cpp" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/sirrf.depend 2009-05-11 21:28:06 UTC (rev 27) @@ -1039,8 +1039,10 @@ "../dependencies.h" "Entity.h" -1241892856 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1242073177 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" + "../components/scene/AnimatedMeshComponent.h" + "../components/scene/CameraComponent.h" 1241782433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" @@ -1116,15 +1118,15 @@ "scriptstring.h" <string.h> -1242052952 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp +1242076632 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" "../../core/GameManager.h" -1242052952 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h +1242072340 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h "../../dependencies.h" "../../core/EntityComponent.h" -1242053058 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp +1242073310 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp "BillboardComponent.h" "../../core/GameManager.h" @@ -1132,7 +1134,7 @@ "../../dependencies.h" "SceneComponent.h" -1241890653 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.cpp +1242074217 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.cpp "TextBillboardComponent.h" "../../core/GameManager.h" @@ -1148,7 +1150,7 @@ "../../dependencies.h" "SceneComponent.h" -1242053075 source:/home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.cpp +1242073882 source:/home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.cpp "MeshComponent.h" "../../core/GameManager.h" @@ -1162,7 +1164,7 @@ 1241639151 source:/home/michael/Programming/Projects/sirrf/src/core/support.cpp "support.h" -1241890509 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp +1242076586 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp "LightComponent.h" "../../core/GameManager.h" @@ -1170,7 +1172,7 @@ "../../dependencies.h" "SceneComponent.h" -1241877529 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp +1242073200 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp "AnimatedMeshComponent.h" "../../core/GameManager.h" @@ -1178,7 +1180,7 @@ "../../dependencies.h" "SceneComponent.h" -1242053021 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp +1242073675 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp "CameraComponent.h" "../../core/GameManager.h" @@ -1186,7 +1188,7 @@ "../../dependencies.h" "SceneComponent.h" -1241877128 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TerrainComponent.cpp +1242074083 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TerrainComponent.cpp "TerrainComponent.h" "../../core/GameManager.h" @@ -1194,7 +1196,7 @@ "../../dependencies.h" "SceneComponent.h" -1242052951 source:/home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.cpp +1242073978 source:/home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.cpp "ParticleSysComponent.h" "../../core/GameManager.h" @@ -1212,3 +1214,27 @@ "scriptstdstring.h" <string.h> +1242075226 source:/home/michael/Programming/Projects/sirrf/src/components/scene/OctTreeComponent.cpp + "OctTreeComponent.h" + "../../core/GameManager.h" + +1242075620 /home/michael/Programming/Projects/sirrf/src/components/scene/OctTreeComponent.h + "../../dependencies.h" + "SceneComponent.h" + +1242076485 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SkyDomeComponent.cpp + "SkyDomeComponent.h" + "../../core/GameManager.h" + +1242076412 /home/michael/Programming/Projects/sirrf/src/components/scene/SkyDomeComponent.h + "../../dependencies.h" + "SceneComponent.h" + +1242076138 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SkyBoxComponent.cpp + "SkyBoxComponent.h" + "../../core/GameManager.h" + +1242076138 /home/michael/Programming/Projects/sirrf/src/components/scene/SkyBoxComponent.h + "../../dependencies.h" + "SceneComponent.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-11 15:18:08 UTC (rev 26) +++ trunk/src/sirrf.layout 2009-05-11 21:28:06 UTC (rev 27) @@ -2,65 +2,77 @@ <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="3649" topLine="12" /> + <Cursor position="3498" topLine="3" /> </File> <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1577" topLine="25" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1121" topLine="0" /> + <Cursor position="1258" topLine="33" /> </File> <File name="components/scene/BillboardComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1296" topLine="11" /> </File> <File name="components/scene/CameraComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2963" topLine="6" /> + <Cursor position="1210" topLine="9" /> </File> <File name="components/scene/CameraComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1119" topLine="24" /> </File> <File name="components/scene/LightComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1067" topLine="6" /> + <Cursor position="1925" topLine="18" /> </File> <File name="components/scene/LightComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1072" topLine="8" /> </File> <File name="components/scene/MeshComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1000" topLine="0" /> + <Cursor position="2968" topLine="37" /> </File> <File name="components/scene/MeshComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1475" topLine="9" /> </File> + <File name="components/scene/OctTreeComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="950" topLine="19" /> + </File> + <File name="components/scene/OctTreeComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="1176" topLine="0" /> + </File> <File name="components/scene/ParticleSysComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="800" topLine="285" /> + <Cursor position="1576" topLine="9" /> </File> <File name="components/scene/ParticleSysComponent.h" open="0" top="0" tabpos="2"> - <Cursor position="947" topLine="20" /> + <Cursor position="2007" topLine="31" /> </File> - <File name="components/scene/SceneComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1183" topLine="3" /> + <File name="components/scene/SceneComponent.cpp" open="1" top="1" tabpos="1"> + <Cursor position="1606" topLine="6" /> </File> <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="957" topLine="4" /> + <Cursor position="1591" topLine="32" /> </File> + <File name="components/scene/SkyBoxComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="1945" topLine="26" /> + </File> + <File name="components/scene/SkyBoxComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="1036" topLine="0" /> + </File> + <File name="components/scene/SkyDomeComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="1283" topLine="20" /> + </File> + <File name="components/scene/SkyDomeComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="1065" topLine="0" /> + </File> <File name="components/scene/TerrainComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1354" topLine="5" /> + <Cursor position="2118" topLine="2" /> </File> <File name="components/scene/TerrainComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="661" topLine="0" /> + <Cursor position="661" topLine="12" /> </File> <File name="components/scene/TextBillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1337" topLine="13" /> + <Cursor position="1477" topLine="24" /> </File> <File name="components/scene/TextBillboardComponent.h" open="0" top="0" tabpos="2"> - <Cursor position="1874" topLine="11" /> + <Cursor position="0" topLine="11" /> </File> - <File name="components/scene/TextComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1173" topLine="8" /> - </File> - <File name="components/scene/TextComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="8" /> - </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> <Cursor position="5904" topLine="222" /> </File> @@ -73,17 +85,17 @@ <File name="core/DataStore.h" open="0" top="0" tabpos="0"> <Cursor position="1253" topLine="18" /> </File> - <File name="core/Entity.cpp" open="1" top="0" tabpos="3"> + <File name="core/Entity.cpp" open="0" top="0" tabpos="3"> <Cursor position="5686" topLine="200" /> </File> <File name="core/Entity.h" open="0" top="0" tabpos="0"> <Cursor position="1592" topLine="24" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2995" topLine="74" /> + <Cursor position="1192" topLine="24" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1466" topLine="26" /> + <Cursor position="1269" topLine="17" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> <Cursor position="4303" topLine="164" /> @@ -98,7 +110,7 @@ <Cursor position="707" topLine="27" /> </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="860" topLine="9" /> + <Cursor position="1014" topLine="0" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> <Cursor position="1901" topLine="30" /> @@ -109,10 +121,10 @@ <File name="main.cpp" open="0" top="0" tabpos="0"> <Cursor position="1645" topLine="0" /> </File> - <File name="scripting/ScriptManager.cpp" open="1" top="0" tabpos="2"> + <File name="scripting/ScriptManager.cpp" open="0" top="0" tabpos="2"> <Cursor position="1151" topLine="17" /> </File> - <File name="scripting/ScriptManager.h" open="1" top="1" tabpos="1"> + <File name="scripting/ScriptManager.h" open="0" top="0" tabpos="1"> <Cursor position="740" topLine="0" /> </File> </CodeBlocks_layout_file> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-11 15:18:19
|
Revision: 26 http://sirrf.svn.sourceforge.net/sirrf/?rev=26&view=rev Author: zccdark203 Date: 2009-05-11 15:18:08 +0000 (Mon, 11 May 2009) Log Message: ----------- Added a preliminary implementation of SceneComponent, a wrapper for Irrlicht's ISceneNode and base for various components. Furthermore, I added removeAffectors() to ParticleSysComponent. And I made some documentation changes. Modified Paths: -------------- trunk/src/components/scene/BillboardComponent.cpp trunk/src/components/scene/CameraComponent.cpp trunk/src/components/scene/MeshComponent.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/core/EntityComponent.h trunk/src/sirrf.depend Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) @@ -58,7 +58,7 @@ } } -// Returns a pointer to the billboard scene node. +// Gets a direct pointer to the IBillboardSceneNode. IBillboardSceneNode* BillboardComponent::getBillboardSceneNode() { return mBillboardSN; Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/components/scene/CameraComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) @@ -44,13 +44,13 @@ return mCameraSN; } -// Binds the camera scene node's rotation to its target position and vice vera, or unbinds them. +// Binds the camera component's rotation to its target position and vice vera, or unbinds them. void CameraComponent::bindTargetAndRotation(bool bound) { mCameraSN->bindTargetAndRotation(bound); } -// Queries if the camera scene node's rotation and its target position are bound together. +// Queries if the camera component's rotation and its target position are bound together. bool CameraComponent::getTargetAndRotationBinding() const { return mCameraSN->getTargetAndRotationBinding(); Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/components/scene/MeshComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) @@ -62,7 +62,7 @@ mSceneNode = NULL; } -// Returns a pointer to the mesh scene node. +// Gets a direct pointer to the IMeshSceneNode. IMeshSceneNode* MeshComponent::getMeshSceneNode() { return mMeshSN; Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) @@ -95,13 +95,19 @@ affector->drop(); } +// Removes all affectors. +void ParticleSysComponent::removeAffectors() +{ + mParticleSystemSN->removeAllAffectors(); +} + // Gets the particle emitter, which creates the particles. IParticleEmitter* ParticleSysComponent::getEmitter() { return mParticleSystemSN->getEmitter(); } -// Sets a particle emitter for the loaded animated mesh scene node. +// Sets a particle emitter for the loaded animated mesh component. void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(const std::string &fileName, bool useNormalDirection, const vector3df &direction, @@ -134,7 +140,7 @@ } } -// Creates a particle emitter for an animated mesh scene node. +// Creates a particle emitter for an animated mesh component. void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(IAnimatedMeshSceneNode *node, bool useNormalDirection, const vector3df &direction, Modified: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-05-11 15:18:08 UTC (rev 26) @@ -50,6 +50,8 @@ void addScaleParticleAffector(const dimension2df &scaleTo = dimension2df(1.0f, 1.0f)); + void removeAffectors(); + IParticleEmitter* getEmitter(); void setAnimatedMeshSceneNodeEmitter(const std::string &fileName, Modified: trunk/src/components/scene/SceneComponent.cpp =================================================================== --- trunk/src/components/scene/SceneComponent.cpp 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/components/scene/SceneComponent.cpp 2009-05-11 15:18:08 UTC (rev 26) @@ -15,6 +15,7 @@ // Include files #include "SceneComponent.h" +#include "../../core/GameManager.h" // SceneComponent class @@ -43,4 +44,126 @@ return mSceneNode; } +// Gets the abolute position of the component. +vector3df SceneComponent::getAbsolutePosition() const +{ + return mSceneNode->getAbsolutePosition(); +} + +// Gets the automatic culling state. +bool SceneComponent::getAutomaticCulling() const +{ + return mSceneNode->getAutomaticCulling(); +} + +// Get the axis aligned, not transformed bounding box of this component. +const aabbox3df& SceneComponent::getBoundingBox() const +{ + return mSceneNode->getBoundingBox(); +} + +// Get amount of materials used by this component. +unsigned int SceneComponent::getMaterialCount() const +{ + return mSceneNode->getMaterialCount(); +} + +// Returns the relative transformation of the component. +matrix4 SceneComponent::getRelativeTransformation() const +{ + return mSceneNode->getRelativeTransformation(); +} + +// Gets the relative position of the component. +const vector3df& SceneComponent::getPosition() const +{ + return mSceneNode->getPosition(); +} + +// Gets the rotation of the component. +const vector3df& SceneComponent::getRotation() const +{ + return mSceneNode->getRotation(); +} + +// Gets the relative scale of the component. +const vector3df& SceneComponent::getScale() const +{ + return mSceneNode->getScale(); +} + +// Returns type of the component. +ESCENE_NODE_TYPE SceneComponent::getType() const +{ + return mSceneNode->getType(); +} + +// Removes all animators from this component. +void SceneComponent::removeAnimators() +{ + mSceneNode->removeAnimators(); +} + +// Sets the absolute position of the component. +void SceneComponent::setAbsolutePosition(const vector3df &position) +{ +} + +// Enables or disables automatic culling based on the bounding box. +void SceneComponent::setAutomaticCulling(E_CULLING_TYPE state) +{ + mSceneNode->setAutomaticCulling(state); +} + +// Sets if debug data like bounding boxes should be drawn. +void SceneComponent::setDebugDataVisible(int state) +{ + mSceneNode->setDebugDataVisible(state); +} + +// Sets a material flag to a new value. +void SceneComponent::setMaterialFlag(E_MATERIAL_FLAG flag, bool value) +{ + mSceneNode->setMaterialFlag(flag, value); +} + +// Loads and sets the texture of the specified layer in all materials of this component to the new +// texture. +void SceneComponent::setMaterialTexture(unsigned int layer, const std::string &fileName) +{ + ITexture *texture = GameManager::Instance()->getDriver()->getTexture(fileName.c_str()); + if(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(unsigned int layer, ITexture *texture) +{ + mSceneNode->setMaterialTexture(layer, texture); +} + +// Sets the material type of all materials in this component to a new material type. +void SceneComponent::setMaterialType(E_MATERIAL_TYPE type) +{ + mSceneNode->setMaterialType(type); +} + +// Sets the relative position of the component. +void SceneComponent::setPosition(const vector3df &position) +{ + mSceneNode->setPosition(position); +} + +// Sets the rotation of the component. +void SceneComponent::setRotation(const vector3df &rotation) +{ + mSceneNode->setRotation(rotation); +} + +// Sets the relative scale of the component. +void SceneComponent::setScale(const vector3df &scale) +{ + mSceneNode->setScale(scale); +} + // End of File Modified: trunk/src/components/scene/SceneComponent.h =================================================================== --- trunk/src/components/scene/SceneComponent.h 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/components/scene/SceneComponent.h 2009-05-11 15:18:08 UTC (rev 26) @@ -33,6 +33,29 @@ // Methods ISceneNode* getSceneNode(); + vector3df getAbsolutePosition() const; + bool getAutomaticCulling() const; + const aabbox3df& getBoundingBox() const; + unsigned int getMaterialCount() const; + matrix4 getRelativeTransformation() const; + const vector3df& getPosition() const; + const vector3df& getRotation() const; + const vector3df& getScale() const; + ESCENE_NODE_TYPE getType() const; + + void removeAnimators(); + + void setAbsolutePosition(const vector3df &position); + void setAutomaticCulling(E_CULLING_TYPE state); + void setDebugDataVisible(int state); + void setMaterialFlag(E_MATERIAL_FLAG flag, bool value); + void setMaterialTexture(unsigned int layer, const std::string &fileName); + void setMaterialTexture(unsigned int layer, ITexture *texture); + void setMaterialType(E_MATERIAL_TYPE type); + void setPosition(const vector3df &position); + void setRotation(const vector3df &rotation); + void setScale(const vector3df &scale); + protected: // Initialisation Modified: trunk/src/core/EntityComponent.h =================================================================== --- trunk/src/core/EntityComponent.h 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/core/EntityComponent.h 2009-05-11 15:18:08 UTC (rev 26) @@ -41,11 +41,11 @@ // Methods unsigned int getID() const; - void setName(const std::string &name); const std::string& getName() const; - const Entity* getParent(); + void setName(const std::string &name); + protected: // Normal members Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-11 13:44:58 UTC (rev 25) +++ trunk/src/sirrf.depend 2009-05-11 15:18:08 UTC (rev 26) @@ -1025,7 +1025,7 @@ "../dependencies.h" "EntityComponent.h" -1241784947 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h +1242054464 /home/michael/Programming/Projects/sirrf/src/core/EntityComponent.h "../dependencies.h" "Entity.h" @@ -1116,14 +1116,15 @@ "scriptstring.h" <string.h> -1241704111 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp +1242052952 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" + "../../core/GameManager.h" -1241704036 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h +1242052952 /home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.h "../../dependencies.h" "../../core/EntityComponent.h" -1241890438 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp +1242053058 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp "BillboardComponent.h" "../../core/GameManager.h" @@ -1147,7 +1148,7 @@ "../../dependencies.h" "SceneComponent.h" -1241809517 source:/home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.cpp +1242053075 source:/home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.cpp "MeshComponent.h" "../../core/GameManager.h" @@ -1177,7 +1178,7 @@ "../../dependencies.h" "SceneComponent.h" -1241877765 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp +1242053021 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp "CameraComponent.h" "../../core/GameManager.h" @@ -1193,11 +1194,11 @@ "../../dependencies.h" "SceneComponent.h" -1241892541 source:/home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.cpp +1242052951 source:/home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.cpp "ParticleSysComponent.h" "../../core/GameManager.h" -1241892541 /home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.h +1242052951 /home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.h "../../dependencies.h" "SceneComponent.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-11 13:55:04
|
Revision: 25 http://sirrf.svn.sourceforge.net/sirrf/?rev=25&view=rev Author: zccdark203 Date: 2009-05-11 13:44:58 +0000 (Mon, 11 May 2009) Log Message: ----------- Updated to AngelScript 2.16.1 Modified Paths: -------------- trunk/src/scripting/scriptstring_utils.cpp trunk/src/sirrf.depend trunk/src/sirrf.layout Modified: trunk/src/scripting/scriptstring_utils.cpp =================================================================== --- trunk/src/scripting/scriptstring_utils.cpp 2009-05-09 18:15:34 UTC (rev 24) +++ trunk/src/scripting/scriptstring_utils.cpp 2009-05-11 13:44:58 UTC (rev 25) @@ -1,5 +1,6 @@ #include <assert.h> #include "scriptstring.h" +#include <string.h> // strstr Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-09 18:15:34 UTC (rev 24) +++ trunk/src/sirrf.depend 2009-05-11 13:44:58 UTC (rev 25) @@ -8,7 +8,7 @@ <angelscript.h> <string> -1239217492 /usr/local/include//angelscript.h +1242048002 /usr/local/include//angelscript.h <stddef.h> 1237737822 source:/home/michael/Programming/Projects/game/src/angelscript/add_on/scriptstring/scriptstring_utils.cpp @@ -1039,7 +1039,7 @@ "../dependencies.h" "Entity.h" -1241811704 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1241892856 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" 1241782433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h @@ -1090,7 +1090,7 @@ <windows.h> <pthread.h> -1241035941 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h +1242049253 /home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.h "../dependencies.h" "scriptstring.h" @@ -1098,7 +1098,7 @@ <angelscript.h> <string> -1241112252 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp +1242049235 source:/home/michael/Programming/Projects/sirrf/src/scripting/ScriptManager.cpp "ScriptManager.h" "../core/GameManager.h" @@ -1111,9 +1111,10 @@ <string.h> "scriptstring.h" -1237737822 source:/home/michael/Programming/Projects/sirrf/src/scripting/scriptstring_utils.cpp +1241866946 source:/home/michael/Programming/Projects/sirrf/src/scripting/scriptstring_utils.cpp <assert.h> "scriptstring.h" + <string.h> 1241704111 source:/home/michael/Programming/Projects/sirrf/src/components/scene/SceneComponent.cpp "SceneComponent.h" @@ -1200,3 +1201,13 @@ "../../dependencies.h" "SceneComponent.h" +1236000368 /home/michael/Programming/Projects/sirrf/src/scripting/scriptstdstring.h + <angelscript.h> + <string> + +1241866940 source:/home/michael/Programming/Projects/sirrf/src/scripting/scriptstdstring.cpp + <assert.h> + <sstream> + "scriptstdstring.h" + <string.h> + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-09 18:15:34 UTC (rev 24) +++ trunk/src/sirrf.layout 2009-05-11 13:44:58 UTC (rev 25) @@ -2,13 +2,13 @@ <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="3649" topLine="8" /> + <Cursor position="3649" topLine="12" /> </File> <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1577" topLine="25" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2882" topLine="0" /> + <Cursor position="1121" topLine="0" /> </File> <File name="components/scene/BillboardComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1296" topLine="11" /> @@ -20,7 +20,7 @@ <Cursor position="1119" topLine="24" /> </File> <File name="components/scene/LightComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1927" topLine="30" /> + <Cursor position="1067" topLine="6" /> </File> <File name="components/scene/LightComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1072" topLine="8" /> @@ -31,11 +31,11 @@ <File name="components/scene/MeshComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1475" topLine="9" /> </File> - <File name="components/scene/ParticleSysComponent.cpp" open="1" top="1" tabpos="1"> - <Cursor position="7385" topLine="0" /> + <File name="components/scene/ParticleSysComponent.cpp" open="0" top="0" tabpos="1"> + <Cursor position="800" topLine="285" /> </File> - <File name="components/scene/ParticleSysComponent.h" open="1" top="0" tabpos="2"> - <Cursor position="1054" topLine="0" /> + <File name="components/scene/ParticleSysComponent.h" open="0" top="0" tabpos="2"> + <Cursor position="947" topLine="20" /> </File> <File name="components/scene/SceneComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1183" topLine="3" /> @@ -50,11 +50,14 @@ <Cursor position="661" topLine="0" /> </File> <File name="components/scene/TextBillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3902" topLine="61" /> + <Cursor position="1337" topLine="13" /> </File> <File name="components/scene/TextBillboardComponent.h" open="0" top="0" tabpos="2"> <Cursor position="1874" topLine="11" /> </File> + <File name="components/scene/TextComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="1173" topLine="8" /> + </File> <File name="components/scene/TextComponent.h" open="0" top="0" tabpos="0"> <Cursor position="0" topLine="8" /> </File> @@ -70,8 +73,8 @@ <File name="core/DataStore.h" open="0" top="0" tabpos="0"> <Cursor position="1253" topLine="18" /> </File> - <File name="core/Entity.cpp" open="0" top="0" tabpos="0"> - <Cursor position="5686" topLine="212" /> + <File name="core/Entity.cpp" open="1" top="0" tabpos="3"> + <Cursor position="5686" topLine="200" /> </File> <File name="core/Entity.h" open="0" top="0" tabpos="0"> <Cursor position="1592" topLine="24" /> @@ -95,7 +98,7 @@ <Cursor position="707" topLine="27" /> </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="860" topLine="3" /> + <Cursor position="860" topLine="9" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> <Cursor position="1901" topLine="30" /> @@ -106,7 +109,10 @@ <File name="main.cpp" open="0" top="0" tabpos="0"> <Cursor position="1645" topLine="0" /> </File> - <File name="scripting/ScriptManager.cpp" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="17" /> + <File name="scripting/ScriptManager.cpp" open="1" top="0" tabpos="2"> + <Cursor position="1151" topLine="17" /> </File> + <File name="scripting/ScriptManager.h" open="1" top="1" tabpos="1"> + <Cursor position="740" topLine="0" /> + </File> </CodeBlocks_layout_file> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-09 18:15:35
|
Revision: 24 http://sirrf.svn.sourceforge.net/sirrf/?rev=24&view=rev Author: zccdark203 Date: 2009-05-09 18:15:34 +0000 (Sat, 09 May 2009) Log Message: ----------- Finished the implementation of ParticleSysComponent. Modified Paths: -------------- trunk/src/components/scene/ParticleSysComponent.cpp trunk/src/components/scene/ParticleSysComponent.h trunk/src/sirrf.depend Modified: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-09 17:41:43 UTC (rev 23) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-09 18:15:34 UTC (rev 24) @@ -20,17 +20,6 @@ // ParticleSysComponent class // ParticleSysComponent constructor (default). -ParticleSysComponent::ParticleSysComponent(Entity *parent) -: SceneComponent(parent, true) -{ - ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - - mParticleSystemSN = pSceneMgr->addParticleSystemSceneNode(true, 0, parent->getID(), - vector3df(0, 0, 0)); - mSceneNode = mParticleSystemSN; -} - -// ParticleSysComponent constructor. ParticleSysComponent::ParticleSysComponent(Entity *parent, const vector3df &rotation, const vector3df &scale) : SceneComponent(parent, true) @@ -56,6 +45,57 @@ return mParticleSystemSN; } +// Adds a new particle effector to the particle system. +void ParticleSysComponent::addAffector(IParticleAffector *affector) +{ + mParticleSystemSN->addAffector(affector); +} + +// Adds a point attraction affector. +void ParticleSysComponent::addAttractionAffector(const vector3df &point, float speed, bool attract, + bool affectX, bool affectY, bool affectZ) +{ + IParticleAffector *affector = mParticleSystemSN->createAttractionAffector(point, speed, attract, + affectX, affectY, affectZ); + mParticleSystemSN->addAffector(affector); + affector->drop(); +} + +// Adds a fade out particle affector. +void ParticleSysComponent::addFadeOutParticleAffector(const SColor &targetColor, + unsigned int timeNeededToFadeOut) +{ + IParticleAffector *affector = mParticleSystemSN->createFadeOutParticleAffector(targetColor, + timeNeededToFadeOut); + mParticleSystemSN->addAffector(affector); + affector->drop(); +} + +// Adds a gravity affector. +void ParticleSysComponent::addGravityAffector(const vector3df &gravity, unsigned int timeForceLost) +{ + IParticleAffector *affector = mParticleSystemSN->createGravityAffector(gravity, timeForceLost); + mParticleSystemSN->addAffector(affector); + affector->drop(); +} + +// Adds a rotation affector. +void ParticleSysComponent::addRotationAffector(const vector3df &speed, const vector3df &pivotPoint) +{ + IParticleAffector *affector = mParticleSystemSN->createRotationAffector(speed, pivotPoint); + mParticleSystemSN->addAffector(affector); + affector->drop(); +} + +// Adds a scale particle affector. +void ParticleSysComponent::addScaleParticleAffector(const dimension2df &scaleTo) +{ + IParticleAffector *affector = mParticleSystemSN->createScaleParticleAffector(scaleTo); + mParticleSystemSN->addAffector(affector); + affector->drop(); +} + +// Gets the particle emitter, which creates the particles. IParticleEmitter* ParticleSysComponent::getEmitter() { return mParticleSystemSN->getEmitter(); @@ -273,4 +313,16 @@ emitter->drop(); } +// Sets if the particles should be global. +void ParticleSysComponent::setParticlesAreGlobal(bool value) +{ + mParticleSystemSN->setParticlesAreGlobal(value); +} + +// Sets the size of all particles. +void ParticleSysComponent::setParticleSize(const dimension2df &size) +{ + mParticleSystemSN->setParticleSize(size); +} + // End of File Modified: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h 2009-05-09 17:41:43 UTC (rev 23) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-05-09 18:15:34 UTC (rev 24) @@ -27,7 +27,6 @@ public: // Initialisation and deinitialisation - ParticleSysComponent(Entity *parent); ParticleSysComponent(Entity *parent, const vector3df &rotation = vector3df(0, 0, 0), const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); ~ParticleSysComponent(); @@ -35,6 +34,22 @@ // Methods IParticleSystemSceneNode* getParticleSystemSceneNode(); + void addAffector(IParticleAffector *affector); + + void addAttractionAffector(const vector3df &point, float speed = 1.0f, bool attract = true, + bool affectX = true, bool affectY = true, bool affectZ = true); + + void addFadeOutParticleAffector(const SColor &targetColor = SColor(0, 0, 0, 0), + unsigned int timeNeededToFadeOut = 1000); + + void addGravityAffector(const vector3df &gravity = vector3df(0.0f,-0.03f, 0.0f), + unsigned int timeForceLost = 1000); + + void addRotationAffector(const vector3df &speed = vector3df(5.0f, 5.0f, 5.0f), + const vector3df &pivotPoint = vector3df(0.0f, 0.0f, 0.0f)); + + void addScaleParticleAffector(const dimension2df &scaleTo = dimension2df(1.0f, 1.0f)); + IParticleEmitter* getEmitter(); void setAnimatedMeshSceneNodeEmitter(const std::string &fileName, @@ -146,6 +161,9 @@ const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + void setParticlesAreGlobal(bool value = true); + void setParticleSize(const dimension2df &size = dimension2df(5.0f, 5.0f)); + private: // Members Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-09 17:41:43 UTC (rev 23) +++ trunk/src/sirrf.depend 2009-05-09 18:15:34 UTC (rev 24) @@ -1138,7 +1138,7 @@ "../../dependencies.h" "BillboardComponent.h" -1241878343 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.cpp +1241890726 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.cpp "TextComponent.h" "../../core/GameManager.h" @@ -1192,11 +1192,11 @@ "../../dependencies.h" "SceneComponent.h" -1241890548 source:/home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.cpp +1241892541 source:/home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.cpp "ParticleSysComponent.h" "../../core/GameManager.h" -1241890326 /home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.h +1241892541 /home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.h "../../dependencies.h" "SceneComponent.h" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-09 17:41:51
|
Revision: 23 http://sirrf.svn.sourceforge.net/sirrf/?rev=23&view=rev Author: zccdark203 Date: 2009-05-09 17:41:43 +0000 (Sat, 09 May 2009) Log Message: ----------- Added a preliminary implementation of ParticleSysComponent, a wrapper class for Irrlicht's IParticleSystemSceneNode. In its current state it's unable to set affector, but other functionalities already work. Furthermore I've changed the initialization of some other components. Modified Paths: -------------- trunk/src/components/scene/BillboardComponent.cpp trunk/src/components/scene/LightComponent.cpp trunk/src/components/scene/TerrainComponent.h trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/components/scene/TextComponent.cpp trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout Added Paths: ----------- trunk/src/components/scene/ParticleSysComponent.cpp trunk/src/components/scene/ParticleSysComponent.h Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-05-09 17:41:43 UTC (rev 23) @@ -25,7 +25,8 @@ { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - mBillboardSN = pSceneMgr->addBillboardSceneNode(); + mBillboardSN = pSceneMgr->addBillboardSceneNode(0, dimension2df(10.0f, 10.0f), + vector3df(0, 0, 0), parent->getID()); mSceneNode = mBillboardSN; } Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/components/scene/LightComponent.cpp 2009-05-09 17:41:43 UTC (rev 23) @@ -25,7 +25,8 @@ { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - mLightSN = pSceneMgr->addLightSceneNode(); + mLightSN = pSceneMgr->addLightSceneNode(0, vector3df(0, 0, 0), SColorf(1.0f, 1.0f, 1.0f), + 100.0f, parent->getID()); mSceneNode = mLightSN; } Added: trunk/src/components/scene/ParticleSysComponent.cpp =================================================================== --- trunk/src/components/scene/ParticleSysComponent.cpp (rev 0) +++ trunk/src/components/scene/ParticleSysComponent.cpp 2009-05-09 17:41:43 UTC (rev 23) @@ -0,0 +1,276 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: ParticleSysComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Component wrapper of Irrlicht's IParticleSystemSceneNode. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "ParticleSysComponent.h" +#include "../../core/GameManager.h" + + +// ParticleSysComponent class +// ParticleSysComponent constructor (default). +ParticleSysComponent::ParticleSysComponent(Entity *parent) +: SceneComponent(parent, true) +{ + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + mParticleSystemSN = pSceneMgr->addParticleSystemSceneNode(true, 0, parent->getID(), + vector3df(0, 0, 0)); + mSceneNode = mParticleSystemSN; +} + +// ParticleSysComponent constructor. +ParticleSysComponent::ParticleSysComponent(Entity *parent, const vector3df &rotation, + const vector3df &scale) +: SceneComponent(parent, true) +{ + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + mParticleSystemSN = pSceneMgr->addParticleSystemSceneNode(true, 0, parent->getID(), + vector3df(0, 0, 0), rotation, + scale); + mSceneNode = mParticleSystemSN; +} + +// ParticleSysComponent deconstructor. +ParticleSysComponent::~ParticleSysComponent() +{ + mParticleSystemSN->remove(); + mSceneNode = NULL; +} + +// Gets a direct pointer to the IParticleSystemSceneNode. +IParticleSystemSceneNode* ParticleSysComponent::getParticleSystemSceneNode() +{ + return mParticleSystemSN; +} + +IParticleEmitter* ParticleSysComponent::getEmitter() +{ + return mParticleSystemSN->getEmitter(); +} + +// Sets a particle emitter for the loaded animated mesh scene node. +void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(const std::string &fileName, + bool useNormalDirection, + const vector3df &direction, + float normalDirectionModifier, + bool everyMeshVertex, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, + unsigned int lifeTimeMax, + int 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 scene node. +void ParticleSysComponent::setAnimatedMeshSceneNodeEmitter(IAnimatedMeshSceneNode *node, + bool useNormalDirection, + const vector3df &direction, + float normalDirectionModifier, + bool everyMeshVertex, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, + unsigned int lifeTimeMax, + int maxAngleDegrees, + const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IParticleEmitter *emitter = mParticleSystemSN->createAnimatedMeshSceneNodeEmitter(node, + useNormalDirection, direction, normalDirectionModifier, -1, + everyMeshVertex, minParticlesPerSecond, maxParticlesPerSecond, + minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, + maxAngleDegrees, minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); +} + +// Sets a box particle emitter. +void ParticleSysComponent::setBoxEmitter(const aabbox3df &box, + const vector3df &direction, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, unsigned int lifeTimeMax, + int maxAngleDegrees, + const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IParticleEmitter *emitter = mParticleSystemSN->createBoxEmitter(box, direction, + minParticlesPerSecond, maxParticlesPerSecond, minStartColor, + maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees, + minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); +} + +// Sets a particle emitter for emitting from a cylinder. +void ParticleSysComponent::setCylinderEmitter(const vector3df ¢er, float radius, + const vector3df &normal, float length, + bool outlineOnly, + const vector3df &direction, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, unsigned int lifeTimeMax, + int maxAngleDegrees, const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IParticleEmitter *emitter = mParticleSystemSN->createCylinderEmitter(center, radius, normal, + length, outlineOnly, direction, minParticlesPerSecond, + maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, + lifeTimeMax, maxAngleDegrees, minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); +} + +// Sets the particle emitter, which creates the particles. +void ParticleSysComponent::setEmitter(IParticleEmitter *emitter) +{ + mParticleSystemSN->setEmitter(emitter); +} + +void ParticleSysComponent::setMeshEmitter(const std::string &fileName, bool useNormalDirection, + const vector3df &direction, + float normalDirectionModifier, bool everyMeshVertex, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, unsigned int lifeTimeMax, + int maxAngleDegrees, + const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IMesh *mesh = GameManager::Instance()->getSceneManager()->getMesh(fileName.c_str()); + + if(mesh) + { + IParticleEmitter *emitter = mParticleSystemSN->createMeshEmitter(mesh, useNormalDirection, + direction, normalDirectionModifier, -1, everyMeshVertex, + minParticlesPerSecond, maxParticlesPerSecond, + minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, + maxAngleDegrees, minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); + } +} + +// Sets a particle emitter a mesh. +void ParticleSysComponent::setMeshEmitter(IMesh *mesh, bool useNormalDirection, + const vector3df &direction, + float normalDirectionModifier, bool everyMeshVertex, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, unsigned int lifeTimeMax, + int maxAngleDegrees, + const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IParticleEmitter *emitter = mParticleSystemSN->createMeshEmitter(mesh, useNormalDirection, + direction, normalDirectionModifier, -1, everyMeshVertex, + minParticlesPerSecond, maxParticlesPerSecond, + minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, + maxAngleDegrees, minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); +} + +// Sets a point particle emitter. +void ParticleSysComponent::setPointEmitter(const vector3df &direction, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, unsigned int lifeTimeMax, + int maxAngleDegrees, + const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IParticleEmitter *emitter = mParticleSystemSN->createPointEmitter(direction, + minParticlesPerSecond, maxParticlesPerSecond, minStartColor, + maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees, + minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); +} + +// Sets a ring particle emitter. +void ParticleSysComponent::setRingEmitter(const vector3df ¢er, float radius, + float ringThickness, const vector3df &direction, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, unsigned int lifeTimeMax, + int maxAngleDegrees, + const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IParticleEmitter *emitter = mParticleSystemSN->createRingEmitter(center, radius, ringThickness, + direction, minParticlesPerSecond, maxParticlesPerSecond, + minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, + maxAngleDegrees, minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); +} + +// Sets a sphere particle emitter. +void ParticleSysComponent::setSphereEmitter(const vector3df ¢er, float radius, + const vector3df &direction, + unsigned int minParticlesPerSecond, + unsigned int maxParticlesPerSecond, + const SColor &minStartColor, + const SColor &maxStartColor, + unsigned int lifeTimeMin, unsigned int lifeTimeMax, + int maxAngleDegrees, + const dimension2df &minStartSize, + const dimension2df &maxStartSize) +{ + IParticleEmitter *emitter = mParticleSystemSN->createSphereEmitter(center, radius, direction, + minParticlesPerSecond, maxParticlesPerSecond, minStartColor, + maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees, + minStartSize, maxStartSize); + mParticleSystemSN->setEmitter(emitter); + emitter->drop(); +} + +// End of File Added: trunk/src/components/scene/ParticleSysComponent.h =================================================================== --- trunk/src/components/scene/ParticleSysComponent.h (rev 0) +++ trunk/src/components/scene/ParticleSysComponent.h 2009-05-09 17:41:43 UTC (rev 23) @@ -0,0 +1,155 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: ParticleSysComponent.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the ParticleSysComponent class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __PARTICLESYSCOMPONENT_H__ +#define __PARTICLESYSCOMPONENT_H__ + +// Include files +#include "../../dependencies.h" +#include "SceneComponent.h" + + +// ParticleSysComponent class +class ParticleSysComponent : public SceneComponent +{ +public: + + // Initialisation and deinitialisation + ParticleSysComponent(Entity *parent); + ParticleSysComponent(Entity *parent, const vector3df &rotation = vector3df(0, 0, 0), + const vector3df &scale = vector3df(1.0f, 1.0f, 1.0f)); + ~ParticleSysComponent(); + + // Methods + IParticleSystemSceneNode* getParticleSystemSceneNode(); + + IParticleEmitter* getEmitter(); + + void setAnimatedMeshSceneNodeEmitter(const std::string &fileName, + bool useNormalDirection = true, + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + float normalDirectionModifier = 100.0f, + bool everyMeshVertex = false, + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, + unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + void setAnimatedMeshSceneNodeEmitter(IAnimatedMeshSceneNode *node, + bool useNormalDirection = true, + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + float normalDirectionModifier = 100.0f, + bool everyMeshVertex = false, + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, + unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + + void setBoxEmitter(const aabbox3df &box = aabbox3df(-10, 28,-10, 10, 30, 10), + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + + void setCylinderEmitter(const vector3df ¢er, float radius, const vector3df &normal, + float length, bool outlineOnly = false, + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + + void setEmitter(IParticleEmitter *emitter); + + void setMeshEmitter(const std::string &fileName, bool useNormalDirection = true, + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + float normalDirectionModifier = 100.0f, bool everyMeshVertex = false, + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + void setMeshEmitter(IMesh *mesh, bool useNormalDirection = true, + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + float normalDirectionModifier = 100.0f, bool everyMeshVertex = false, + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + + void setPointEmitter(const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + + void setRingEmitter(const vector3df ¢er, float radius, float ringThickness, + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + + void setSphereEmitter(const vector3df ¢er, float radius, + const vector3df &direction = vector3df(0.0f, 0.03f, 0.0f), + unsigned int minParticlesPerSecond = 5, + unsigned int maxParticlesPerSecond = 10, + const SColor &minStartColor = SColor(255, 0, 0, 0), + const SColor &maxStartColor = SColor(255, 255, 255, 255), + unsigned int lifeTimeMin = 2000, unsigned int lifeTimeMax = 4000, + int maxAngleDegrees = 0, + const dimension2df &minStartSize = dimension2df(5.0f, 5.0f), + const dimension2df &maxStartSize = dimension2df(5.0f, 5.0f)); + +private: + + // Members + IParticleSystemSceneNode *mParticleSystemSN; +}; + +#endif Modified: trunk/src/components/scene/TerrainComponent.h =================================================================== --- trunk/src/components/scene/TerrainComponent.h 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/components/scene/TerrainComponent.h 2009-05-09 17:41:43 UTC (rev 23) @@ -13,8 +13,8 @@ // // ///////////////////////////////////////////////////////////////////////////// -#ifndef __TEXTCOMPONENT_H__ -#define __TEXTCOMPONENT_H__ +#ifndef __TERRAINCOMPONENT_H__ +#define __TERRAINCOMPONENT_H__ // Include files #include "../../dependencies.h" Modified: trunk/src/components/scene/TextBillboardComponent.cpp =================================================================== --- trunk/src/components/scene/TextBillboardComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/components/scene/TextBillboardComponent.cpp 2009-05-09 17:41:43 UTC (rev 23) @@ -26,7 +26,9 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - mBillboardTextSN = pSceneMgr->addBillboardTextSceneNode(pGUIEnv->getBuiltInFont(), 0); + mBillboardTextSN = pSceneMgr->addBillboardTextSceneNode(pGUIEnv->getBuiltInFont(), 0, 0, + dimension2df(10.0f, 10.0f), + vector3df(0, 0, 0), parent->getID()); mBillboardSN = mBillboardTextSN; mSceneNode = mBillboardTextSN; } Modified: trunk/src/components/scene/TextComponent.cpp =================================================================== --- trunk/src/components/scene/TextComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/components/scene/TextComponent.cpp 2009-05-09 17:41:43 UTC (rev 23) @@ -26,7 +26,8 @@ ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); IGUIEnvironment *pGUIEnv = GameManager::Instance()->getGUIEnvironment(); - mTextSN = pSceneMgr->addTextSceneNode(pGUIEnv->getBuiltInFont(), 0); + mTextSN = pSceneMgr->addTextSceneNode(pGUIEnv->getBuiltInFont(), 0, SColor(100, 255, 255, 255), + 0, vector3df(0, 0, 0), parent->getID()); mSceneNode = mTextSN; } Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/sirrf.cbp 2009-05-09 17:41:43 UTC (rev 23) @@ -58,6 +58,8 @@ <Unit filename="components/scene/LightComponent.h" /> <Unit filename="components/scene/MeshComponent.cpp" /> <Unit filename="components/scene/MeshComponent.h" /> + <Unit filename="components/scene/ParticleSysComponent.cpp" /> + <Unit filename="components/scene/ParticleSysComponent.h" /> <Unit filename="components/scene/SceneComponent.cpp" /> <Unit filename="components/scene/SceneComponent.h" /> <Unit filename="components/scene/TerrainComponent.cpp" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/sirrf.depend 2009-05-09 17:41:43 UTC (rev 23) @@ -1122,7 +1122,7 @@ "../../dependencies.h" "../../core/EntityComponent.h" -1241877641 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp +1241890438 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp "BillboardComponent.h" "../../core/GameManager.h" @@ -1130,7 +1130,7 @@ "../../dependencies.h" "SceneComponent.h" -1241877966 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.cpp +1241890653 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.cpp "TextBillboardComponent.h" "../../core/GameManager.h" @@ -1160,7 +1160,7 @@ 1241639151 source:/home/michael/Programming/Projects/sirrf/src/core/support.cpp "support.h" -1241877831 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp +1241890509 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp "LightComponent.h" "../../core/GameManager.h" @@ -1188,7 +1188,15 @@ "TerrainComponent.h" "../../core/GameManager.h" -1241877128 /home/michael/Programming/Projects/sirrf/src/components/scene/TerrainComponent.h +1241882006 /home/michael/Programming/Projects/sirrf/src/components/scene/TerrainComponent.h "../../dependencies.h" "SceneComponent.h" +1241890548 source:/home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.cpp + "ParticleSysComponent.h" + "../../core/GameManager.h" + +1241890326 /home/michael/Programming/Projects/sirrf/src/components/scene/ParticleSysComponent.h + "../../dependencies.h" + "SceneComponent.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-09 14:21:58 UTC (rev 22) +++ trunk/src/sirrf.layout 2009-05-09 17:41:43 UTC (rev 23) @@ -2,50 +2,59 @@ <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="1"> - <Cursor position="5966" topLine="21" /> + <Cursor position="3649" topLine="8" /> </File> <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1710" topLine="0" /> + <Cursor position="1577" topLine="25" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1548" topLine="18" /> + <Cursor position="2882" topLine="0" /> </File> <File name="components/scene/BillboardComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1208" topLine="11" /> + <Cursor position="1296" topLine="11" /> </File> <File name="components/scene/CameraComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3106" topLine="84" /> + <Cursor position="2963" topLine="6" /> </File> <File name="components/scene/CameraComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1243" topLine="30" /> + <Cursor position="1119" topLine="24" /> </File> <File name="components/scene/LightComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1590" topLine="15" /> + <Cursor position="1927" topLine="30" /> </File> <File name="components/scene/LightComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="9" /> + <Cursor position="1072" topLine="8" /> </File> <File name="components/scene/MeshComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1000" topLine="0" /> </File> <File name="components/scene/MeshComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1430" topLine="9" /> + <Cursor position="1475" topLine="9" /> </File> + <File name="components/scene/ParticleSysComponent.cpp" open="1" top="1" tabpos="1"> + <Cursor position="7385" topLine="0" /> + </File> + <File name="components/scene/ParticleSysComponent.h" open="1" top="0" tabpos="2"> + <Cursor position="1054" topLine="0" /> + </File> <File name="components/scene/SceneComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1183" topLine="3" /> </File> <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="0"> <Cursor position="957" topLine="4" /> </File> + <File name="components/scene/TerrainComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="1354" topLine="5" /> + </File> + <File name="components/scene/TerrainComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="661" topLine="0" /> + </File> <File name="components/scene/TextBillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3618" topLine="0" /> + <Cursor position="3902" topLine="61" /> </File> <File name="components/scene/TextBillboardComponent.h" open="0" top="0" tabpos="2"> - <Cursor position="1563" topLine="9" /> + <Cursor position="1874" topLine="11" /> </File> - <File name="components/scene/TextComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2553" topLine="0" /> - </File> <File name="components/scene/TextComponent.h" open="0" top="0" tabpos="0"> <Cursor position="0" topLine="8" /> </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-09 14:22:04
|
Revision: 22 http://sirrf.svn.sourceforge.net/sirrf/?rev=22&view=rev Author: zccdark203 Date: 2009-05-09 14:21:58 +0000 (Sat, 09 May 2009) Log Message: ----------- Added TerrainComponent and reviewed previously commited components. Modified Paths: -------------- trunk/src/components/scene/AnimatedMeshComponent.cpp trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/BillboardComponent.cpp trunk/src/components/scene/BillboardComponent.h trunk/src/components/scene/CameraComponent.cpp trunk/src/components/scene/CameraComponent.h trunk/src/components/scene/LightComponent.cpp trunk/src/components/scene/LightComponent.h trunk/src/components/scene/TextBillboardComponent.cpp trunk/src/components/scene/TextBillboardComponent.h trunk/src/components/scene/TextComponent.cpp trunk/src/components/scene/TextComponent.h trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout Added Paths: ----------- trunk/src/components/scene/TerrainComponent.cpp trunk/src/components/scene/TerrainComponent.h Modified: trunk/src/components/scene/AnimatedMeshComponent.cpp =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/AnimatedMeshComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) @@ -73,7 +73,7 @@ } // Returns the current end frame number. -int AnimatedMeshComponent::getEndFrame() +int AnimatedMeshComponent::getEndFrame() const { return mAnimatedMeshSN->getEndFrame(); } @@ -85,7 +85,7 @@ } // Returns the current displayed frame number. -int AnimatedMeshComponent::getFrame() +int AnimatedMeshComponent::getFrame() const { return mAnimatedMeshSN->getFrameNr(); } @@ -103,7 +103,7 @@ } // Returns the current start frame number. -int AnimatedMeshComponent::getStartFrame() +int AnimatedMeshComponent::getStartFrame() const { return mAnimatedMeshSN->getStartFrame(); } Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-09 14:21:58 UTC (rev 22) @@ -41,11 +41,11 @@ void animate(); - int getEndFrame(); - int getFrame(); + int getEndFrame() const; + int getFrame() const; IMesh* getMesh(); IShadowVolumeSceneNode* getShadowVolumeSceneNode(); - int getStartFrame(); + int getStartFrame() const; void setAnimationSpeed(float speed); void setCurrentFrame(int frame); Modified: trunk/src/components/scene/BillboardComponent.cpp =================================================================== --- trunk/src/components/scene/BillboardComponent.cpp 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/BillboardComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) @@ -30,8 +30,8 @@ } // BillboardComponent constructor. -BillboardComponent::BillboardComponent(Entity *parent, const dimension2df &size, SColor colorTop, - SColor colorBottom) +BillboardComponent::BillboardComponent(Entity *parent, const dimension2df &size, + const SColor &colorTop, const SColor &colorBottom) : SceneComponent(parent, true) { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); @@ -63,6 +63,18 @@ return mBillboardSN; } +// Gets the color of the top and bottom vertices of the billboard. +void BillboardComponent::getColor(SColor &topColor, SColor &bottomColor) const +{ + mBillboardSN->getColor(topColor, bottomColor); +} + +// Returns the size of the billboard. +const dimension2df& BillboardComponent::getSize() const +{ + return mBillboardSN->getSize(); +} + // Set the color of all vertices of the billboard. void BillboardComponent::setColor(const SColor &overallColor) { @@ -81,16 +93,4 @@ mBillboardSN->setSize(size); } -// Gets the color of the top and bottom vertices of the billboard. -void BillboardComponent::getColor(SColor &topColor, SColor &bottomColor) const -{ - mBillboardSN->getColor(topColor, bottomColor); -} - -// Returns the size of the billboard. -const dimension2df& BillboardComponent::getSize() const -{ - return mBillboardSN->getSize(); -} - // End of File Modified: trunk/src/components/scene/BillboardComponent.h =================================================================== --- trunk/src/components/scene/BillboardComponent.h 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/BillboardComponent.h 2009-05-09 14:21:58 UTC (rev 22) @@ -29,7 +29,8 @@ // Initialisation and deinitialisation BillboardComponent(Entity *parent); BillboardComponent(Entity *parent, const dimension2df &size = dimension2df(10.0f, 10.0f), - SColor colorTop = 0xFFFFFFFF, SColor colorBottom = 0xFFFFFFFF); + const SColor &colorTop = SColor(255, 255, 255, 255), + const SColor &colorBottom = SColor(255, 255, 255, 255)); ~BillboardComponent(); // Methods Modified: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/CameraComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) @@ -51,61 +51,61 @@ } // Queries if the camera scene node's rotation and its target position are bound together. -bool CameraComponent::getTargetAndRotationBinding() +bool CameraComponent::getTargetAndRotationBinding() const { return mCameraSN->getTargetAndRotationBinding(); } // Gets the aspect ratio of the camera. -float CameraComponent::getAspectRatio() +float CameraComponent::getAspectRatio() const { return mCameraSN->getAspectRatio(); } // Gets the value of the far plane of the camera. -float CameraComponent::getFarValue() +float CameraComponent::getFarValue() const { return mCameraSN->getFarValue(); } // Gets the field of view of the camera. -float CameraComponent::getFOV() +float CameraComponent::getFOV() const { return mCameraSN->getFOV(); } // Gets the value of the near plane of the camera. -float CameraComponent::getNearValue() +float CameraComponent::getNearValue() const { return mCameraSN->getNearValue(); } // Gets the current projection matrix of the camera. -const matrix4& CameraComponent::getProjectionMatrix() +const matrix4& CameraComponent::getProjectionMatrix() const { return mCameraSN->getProjectionMatrix(); } // Gets the current look at target of the camera. -const vector3df& CameraComponent::getTarget() +const vector3df& CameraComponent::getTarget() const { return mCameraSN->getTarget(); } // Gets the up vector of the camera. -const vector3df& CameraComponent::getUpVector() +const vector3df& CameraComponent::getUpVector() const { return mCameraSN->getUpVector(); } // Gets the current view matrix of the camera. -const matrix4& CameraComponent::getViewMatrix() +const matrix4& CameraComponent::getViewMatrix() const { return mCameraSN->getViewMatrix(); } // Checks if the camera is orthogonal. -bool CameraComponent::getIsOrthogonal() +bool CameraComponent::getIsOrthogonal() const { return mCameraSN->isOrthogonal(); } Modified: trunk/src/components/scene/CameraComponent.h =================================================================== --- trunk/src/components/scene/CameraComponent.h 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/CameraComponent.h 2009-05-09 14:21:58 UTC (rev 22) @@ -34,17 +34,17 @@ ICameraSceneNode* getCameraSceneNode(); void bindTargetAndRotation(bool bound); - bool getTargetAndRotationBinding(); + bool getTargetAndRotationBinding() const; - float getAspectRatio(); - float getFarValue(); - float getFOV(); - float getNearValue(); - const matrix4& getProjectionMatrix(); - const vector3df& getTarget(); - const vector3df& getUpVector(); - const matrix4& getViewMatrix(); - bool getIsOrthogonal(); + float getAspectRatio() const; + float getFarValue() const; + float getFOV() const; + float getNearValue() const; + const matrix4& getProjectionMatrix() const; + const vector3df& getTarget() const; + const vector3df& getUpVector() const; + const matrix4& getViewMatrix()const; + bool getIsOrthogonal()const; void setAsMainCamera(); void setAspectRatio(float aspect); Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/LightComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) @@ -30,7 +30,7 @@ } // LightComponent constructor. -LightComponent::LightComponent(Entity *parent, SColorf color, float radius) +LightComponent::LightComponent(Entity *parent, const SColorf &color, float radius) : SceneComponent(parent, true) { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); @@ -53,19 +53,19 @@ } // Returns whether this light casts shadows. -bool LightComponent::getCastShadow() +bool LightComponent::getCastShadow() const { return mLightSN->getCastShadow(); } // Gets the light type. -E_LIGHT_TYPE LightComponent::getLightType() +E_LIGHT_TYPE LightComponent::getLightType() const { return mLightSN->getLightType(); } // Gets the light's radius of influence. -float LightComponent::getRadius() +float LightComponent::getRadius() const { return mLightSN->getRadius(); } Modified: trunk/src/components/scene/LightComponent.h =================================================================== --- trunk/src/components/scene/LightComponent.h 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/LightComponent.h 2009-05-09 14:21:58 UTC (rev 22) @@ -28,16 +28,16 @@ // Initialisation and deinitialisation LightComponent(Entity *parent); - LightComponent(Entity *parent, SColorf color = SColorf(1.0f, 1.0f, 1.0f), + LightComponent(Entity *parent, const SColorf &color = SColorf(1.0f, 1.0f, 1.0f), float radius = 100.0f); ~LightComponent(); // Methods ILightSceneNode* getLightSceneNode(); - bool getCastShadow(); - E_LIGHT_TYPE getLightType(); - float getRadius(); + bool getCastShadow() const; + E_LIGHT_TYPE getLightType() const; + float getRadius() const; void setCastShadow(bool shadow = true); void setLightType(E_LIGHT_TYPE type); Added: trunk/src/components/scene/TerrainComponent.cpp =================================================================== --- trunk/src/components/scene/TerrainComponent.cpp (rev 0) +++ trunk/src/components/scene/TerrainComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) @@ -0,0 +1,111 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: TerrainComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Component wrapper of Irrlicht's ITerrainSceneNode. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "TerrainComponent.h" +#include "../../core/GameManager.h" + + +// TerrainComponent class +// TerrainComponent constructor (default). +TerrainComponent::TerrainComponent(Entity *parent) +: SceneComponent(parent, true) +{ + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + 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; +} + +// TerrainComponent constructor. +TerrainComponent::TerrainComponent(Entity *parent, const std::string &fileName, + const vector3df &rotation, const vector3df &scale, + const SColor &vertexColor, int maxLOD, int smoothFactor) +: SceneComponent(parent, true) +{ + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + mTerrainSN = pSceneMgr->addTerrainSceneNode(fileName.c_str(), 0, parent->getID(), + vector3df(0.0f, 0.0f, 0.0f), rotation, scale, + vertexColor, maxLOD, ETPS_17, smoothFactor, true); + mSceneNode = mTerrainSN; +} + +// TerrainComponent deconstructor. +TerrainComponent::~TerrainComponent() +{ + mTerrainSN->remove(); + mSceneNode = NULL; +} + +// Gets a direct pointer to the ITerrainSceneNode. +ITerrainSceneNode* TerrainComponent::getTerrainSceneNode() +{ + return mTerrainSN; +} + +// Gets the bounding box of the terrain. +const aabbox3df& TerrainComponent::getBoundingBox() const +{ + return mTerrainSN->getBoundingBox(); +} + +// Gets the bounding box of a patch. +const aabbox3df& TerrainComponent::getBoundingBox(int patchX, int patchZ) const +{ + return mTerrainSN->getBoundingBox(patchX, patchZ); +} + +// Gets the height of a point of the terrain. +float TerrainComponent::getHeight(float x, float y) +{ + return mTerrainSN->getHeight(x, y); +} + +// Gets pointer to the mesh. +IMesh* TerrainComponent::getMesh() +{ + return mTerrainSN->getMesh(); +} + +// Gets center of terrain. +const vector3df& TerrainComponent::getTerrainCenter() const +{ + return mTerrainSN->getTerrainCenter(); +} + +// Loads the data from a heightMapFile. +bool TerrainComponent::loadHeightMap(const std::string &fileName, const SColor &vertexColor, + int smoothFactor) +{ + IReadFile *file = GameManager::Instance()->getDevice()->getFileSystem()-> + createAndOpenFile(fileName.c_str()); + + bool result = mTerrainSN->loadHeightMap(file, vertexColor, smoothFactor); + file->drop(); + + return result; +} + +// Scales the base texture. +void TerrainComponent::scaleTexture(float scale, float scale2) +{ + mTerrainSN->scaleTexture(scale, scale2); +} + +// End of File Added: trunk/src/components/scene/TerrainComponent.h =================================================================== --- trunk/src/components/scene/TerrainComponent.h (rev 0) +++ trunk/src/components/scene/TerrainComponent.h 2009-05-09 14:21:58 UTC (rev 22) @@ -0,0 +1,59 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: TerrainComponent.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the TerrainComponent class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __TEXTCOMPONENT_H__ +#define __TEXTCOMPONENT_H__ + +// Include files +#include "../../dependencies.h" +#include "SceneComponent.h" + + +// TerrainComponent class +class TerrainComponent : public SceneComponent +{ +public: + + // Initialisation and deinitialisation + TerrainComponent(Entity *parent); + 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), int maxLOD = 5, + int smoothFactor = 0); + ~TerrainComponent(); + + // Methods + ITerrainSceneNode* getTerrainSceneNode(); + + const aabbox3df& getBoundingBox() const; + const aabbox3df& getBoundingBox(int patchX, int patchZ) const; + float getHeight(float x, float y); + IMesh* getMesh(); + const vector3df& getTerrainCenter() const; + + bool loadHeightMap(const std::string &fileName, const SColor &vertexColor = + SColor(255, 255, 255, 255), int smoothFactor = 0); + + void scaleTexture(float scale = 1.0f, float scale2 = 0.0f); + + +private: + + // Members + ITerrainSceneNode *mTerrainSN; +}; + +#endif Modified: trunk/src/components/scene/TextBillboardComponent.cpp =================================================================== --- trunk/src/components/scene/TextBillboardComponent.cpp 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/TextBillboardComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) @@ -34,7 +34,7 @@ // TextBillboardComponent constructor. TextBillboardComponent::TextBillboardComponent(Entity *parent, const std::string fontFilename, const wchar_t *text, const dimension2df &size, - SColor colorTop, SColor colorBottom) + const SColor &colorTop, const SColor &colorBottom) : BillboardComponent(parent, true) { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); @@ -50,7 +50,7 @@ // TextBillboardComponent constructor. TextBillboardComponent::TextBillboardComponent(Entity *parent, const std::string fontFilename, const std::string &text, const dimension2df &size, - SColor colorTop, SColor colorBottom) + const SColor &colorTop, const SColor &colorBottom) : BillboardComponent(parent, true) { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); @@ -96,7 +96,7 @@ } // Sets the color of the text. -void TextBillboardComponent::setTextColor(SColor &color) +void TextBillboardComponent::setTextColor(const SColor &color) { mBillboardTextSN->setTextColor(color); } Modified: trunk/src/components/scene/TextBillboardComponent.h =================================================================== --- trunk/src/components/scene/TextBillboardComponent.h 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/TextBillboardComponent.h 2009-05-09 14:21:58 UTC (rev 22) @@ -30,10 +30,12 @@ TextBillboardComponent(Entity *parent); TextBillboardComponent(Entity *parent, const std::string fontFilename, const wchar_t *text, const dimension2df &size = dimension2df(10.0f, 10.0f), - SColor colorTop = 0xFFFFFFFF, SColor colorBottom = 0xFFFFFFFF); + const SColor &colorTop = SColor(255, 255, 255, 255), + const SColor &colorBottom = SColor(255, 255, 255, 255)); TextBillboardComponent(Entity *parent, const std::string fontFilename, const std::string &text, const dimension2df &size = dimension2df(10.0f, 10.0f), - SColor colorTop = 0xFFFFFFFF, SColor colorBottom = 0xFFFFFFFF); + const SColor &colorTop = SColor(255, 255, 255, 255), + const SColor &colorBottom = SColor(255, 255, 255, 255)); ~TextBillboardComponent(); // Methods @@ -41,7 +43,7 @@ void setText(const std::string &text); void setText(const wchar_t *text); - void setTextColor(SColor &color); + void setTextColor(const SColor &color); private: Modified: trunk/src/components/scene/TextComponent.cpp =================================================================== --- trunk/src/components/scene/TextComponent.cpp 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/TextComponent.cpp 2009-05-09 14:21:58 UTC (rev 22) @@ -32,7 +32,7 @@ // TextComponent constructor. TextComponent::TextComponent(Entity *parent, const std::string fontFilename, const wchar_t *text, - SColor color) + const SColor &color) : SceneComponent(parent, true) { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); @@ -45,7 +45,7 @@ // TextComponent constructor. TextComponent::TextComponent(Entity *parent, const std::string fontFilename, - const std::string &text, SColor color) + const std::string &text, const SColor &color) : SceneComponent(parent, true) { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); @@ -88,7 +88,7 @@ } // Sets the color of the text. -void TextComponent::setTextColor(SColor &color) +void TextComponent::setTextColor(const SColor &color) { mTextSN->setTextColor(color); } Modified: trunk/src/components/scene/TextComponent.h =================================================================== --- trunk/src/components/scene/TextComponent.h 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/components/scene/TextComponent.h 2009-05-09 14:21:58 UTC (rev 22) @@ -29,9 +29,9 @@ // Initialisation and deinitialisation TextComponent(Entity *parent); TextComponent(Entity *parent, const std::string fontFilename, const wchar_t *text, - SColor color = SColor(100, 255, 255, 255)); + const SColor &color = SColor(100, 255, 255, 255)); TextComponent(Entity *parent, const std::string fontFilename, const std::string &text, - SColor color = SColor(100, 255, 255, 255)); + const SColor &color = SColor(100, 255, 255, 255)); ~TextComponent(); // Methods @@ -39,7 +39,7 @@ void setText(const std::string &text); void setText(const wchar_t *text); - void setTextColor(SColor &color); + void setTextColor(const SColor &color); private: Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/sirrf.cbp 2009-05-09 14:21:58 UTC (rev 22) @@ -60,6 +60,8 @@ <Unit filename="components/scene/MeshComponent.h" /> <Unit filename="components/scene/SceneComponent.cpp" /> <Unit filename="components/scene/SceneComponent.h" /> + <Unit filename="components/scene/TerrainComponent.cpp" /> + <Unit filename="components/scene/TerrainComponent.h" /> <Unit filename="components/scene/TextBillboardComponent.cpp" /> <Unit filename="components/scene/TextBillboardComponent.h" /> <Unit filename="components/scene/TextComponent.cpp" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/sirrf.depend 2009-05-09 14:21:58 UTC (rev 22) @@ -1039,10 +1039,8 @@ "../dependencies.h" "Entity.h" -1241811192 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1241811704 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" - "../components/scene/CameraComponent.h" - "../components/scene/AnimatedMeshComponent.h" 1241782433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" @@ -1124,27 +1122,27 @@ "../../dependencies.h" "../../core/EntityComponent.h" -1241624983 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp +1241877641 source:/home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.cpp "BillboardComponent.h" "../../core/GameManager.h" -1241704016 /home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.h +1241878517 /home/michael/Programming/Projects/sirrf/src/components/scene/BillboardComponent.h "../../dependencies.h" "SceneComponent.h" -1241639972 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.cpp +1241877966 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.cpp "TextBillboardComponent.h" "../../core/GameManager.h" -1241625045 /home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.h +1241877966 /home/michael/Programming/Projects/sirrf/src/components/scene/TextBillboardComponent.h "../../dependencies.h" "BillboardComponent.h" -1241804074 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.cpp +1241878343 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.cpp "TextComponent.h" "../../core/GameManager.h" -1241704067 /home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.h +1241878343 /home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.h "../../dependencies.h" "SceneComponent.h" @@ -1152,7 +1150,7 @@ "MeshComponent.h" "../../core/GameManager.h" -1241783055 /home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.h +1241874442 /home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.h "../../dependencies.h" "SceneComponent.h" @@ -1162,27 +1160,35 @@ 1241639151 source:/home/michael/Programming/Projects/sirrf/src/core/support.cpp "support.h" -1241804068 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp +1241877831 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp "LightComponent.h" "../../core/GameManager.h" -1241703952 /home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.h +1241877831 /home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.h "../../dependencies.h" "SceneComponent.h" -1241786189 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp +1241877529 source:/home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.cpp "AnimatedMeshComponent.h" "../../core/GameManager.h" -1241785924 /home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.h +1241877528 /home/michael/Programming/Projects/sirrf/src/components/scene/AnimatedMeshComponent.h "../../dependencies.h" "SceneComponent.h" -1241811159 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp +1241877765 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp "CameraComponent.h" "../../core/GameManager.h" -1241811159 /home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.h +1241877765 /home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.h "../../dependencies.h" "SceneComponent.h" +1241877128 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TerrainComponent.cpp + "TerrainComponent.h" + "../../core/GameManager.h" + +1241877128 /home/michael/Programming/Projects/sirrf/src/components/scene/TerrainComponent.h + "../../dependencies.h" + "SceneComponent.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-09 13:09:25 UTC (rev 21) +++ trunk/src/sirrf.layout 2009-05-09 14:21:58 UTC (rev 22) @@ -1,26 +1,32 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> - <File name="components/scene/AnimatedMeshComponent.cpp" open="1" top="1" tabpos="1"> + <File name="components/scene/AnimatedMeshComponent.cpp" open="0" top="0" tabpos="1"> <Cursor position="5966" topLine="21" /> </File> <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1710" topLine="21" /> + <Cursor position="1710" topLine="0" /> </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1548" topLine="15" /> + <Cursor position="1548" topLine="18" /> </File> <File name="components/scene/BillboardComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1208" topLine="11" /> </File> + <File name="components/scene/CameraComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="3106" topLine="84" /> + </File> + <File name="components/scene/CameraComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="1243" topLine="30" /> + </File> <File name="components/scene/LightComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="48" /> + <Cursor position="1590" topLine="15" /> </File> <File name="components/scene/LightComponent.h" open="0" top="0" tabpos="0"> <Cursor position="0" topLine="9" /> </File> <File name="components/scene/MeshComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2722" topLine="0" /> + <Cursor position="1000" topLine="0" /> </File> <File name="components/scene/MeshComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1430" topLine="9" /> @@ -32,16 +38,16 @@ <Cursor position="957" topLine="4" /> </File> <File name="components/scene/TextBillboardComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="3618" topLine="61" /> + <Cursor position="3618" topLine="0" /> </File> <File name="components/scene/TextBillboardComponent.h" open="0" top="0" tabpos="2"> <Cursor position="1563" topLine="9" /> </File> <File name="components/scene/TextComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="32" /> + <Cursor position="2553" topLine="0" /> </File> <File name="components/scene/TextComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1411" topLine="8" /> + <Cursor position="0" topLine="8" /> </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> <Cursor position="5904" topLine="222" /> @@ -80,7 +86,7 @@ <Cursor position="707" topLine="27" /> </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="860" topLine="0" /> + <Cursor position="860" topLine="3" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> <Cursor position="1901" topLine="30" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-09 13:09:30
|
Revision: 21 http://sirrf.svn.sourceforge.net/sirrf/?rev=21&view=rev Author: zccdark203 Date: 2009-05-09 13:09:25 +0000 (Sat, 09 May 2009) Log Message: ----------- Several minor changes to the way data of components is handled internally. Modified Paths: -------------- trunk/src/components/scene/AnimatedMeshComponent.h trunk/src/components/scene/LightComponent.h trunk/src/components/scene/MeshComponent.h trunk/src/components/scene/TextBillboardComponent.h trunk/src/components/scene/TextComponent.h Modified: trunk/src/components/scene/AnimatedMeshComponent.h =================================================================== --- trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-08 19:43:56 UTC (rev 20) +++ trunk/src/components/scene/AnimatedMeshComponent.h 2009-05-09 13:09:25 UTC (rev 21) @@ -61,7 +61,7 @@ float infinity = 10000.0f); void setTransitionTime(float time); -protected: +private: // Members IAnimatedMeshSceneNode *mAnimatedMeshSN; Modified: trunk/src/components/scene/LightComponent.h =================================================================== --- trunk/src/components/scene/LightComponent.h 2009-05-08 19:43:56 UTC (rev 20) +++ trunk/src/components/scene/LightComponent.h 2009-05-09 13:09:25 UTC (rev 21) @@ -43,7 +43,7 @@ void setLightType(E_LIGHT_TYPE type); void setRadius(float radius); -protected: +private: // Members ILightSceneNode *mLightSN; Modified: trunk/src/components/scene/MeshComponent.h =================================================================== --- trunk/src/components/scene/MeshComponent.h 2009-05-08 19:43:56 UTC (rev 20) +++ trunk/src/components/scene/MeshComponent.h 2009-05-09 13:09:25 UTC (rev 21) @@ -44,7 +44,7 @@ void setMesh(const std::string &fileName); void setMesh(IMesh *mesh); -protected: +private: // Members IMeshSceneNode *mMeshSN; Modified: trunk/src/components/scene/TextBillboardComponent.h =================================================================== --- trunk/src/components/scene/TextBillboardComponent.h 2009-05-08 19:43:56 UTC (rev 20) +++ trunk/src/components/scene/TextBillboardComponent.h 2009-05-09 13:09:25 UTC (rev 21) @@ -43,7 +43,7 @@ void setText(const wchar_t *text); void setTextColor(SColor &color); -protected: +private: // Members IBillboardTextSceneNode *mBillboardTextSN; Modified: trunk/src/components/scene/TextComponent.h =================================================================== --- trunk/src/components/scene/TextComponent.h 2009-05-08 19:43:56 UTC (rev 20) +++ trunk/src/components/scene/TextComponent.h 2009-05-09 13:09:25 UTC (rev 21) @@ -41,7 +41,7 @@ void setText(const wchar_t *text); void setTextColor(SColor &color); -protected: +private: // Members ITextSceneNode *mTextSN; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <zcc...@us...> - 2009-05-08 19:44:01
|
Revision: 20 http://sirrf.svn.sourceforge.net/sirrf/?rev=20&view=rev Author: zccdark203 Date: 2009-05-08 19:43:56 +0000 (Fri, 08 May 2009) Log Message: ----------- Added CameraComponent. Modified Paths: -------------- trunk/src/components/scene/LightComponent.cpp trunk/src/components/scene/MeshComponent.cpp trunk/src/components/scene/TextComponent.cpp trunk/src/sirrf.cbp trunk/src/sirrf.depend trunk/src/sirrf.layout Added Paths: ----------- trunk/src/components/scene/CameraComponent.cpp trunk/src/components/scene/CameraComponent.h Added: trunk/src/components/scene/CameraComponent.cpp =================================================================== --- trunk/src/components/scene/CameraComponent.cpp (rev 0) +++ trunk/src/components/scene/CameraComponent.cpp 2009-05-08 19:43:56 UTC (rev 20) @@ -0,0 +1,214 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: CameraComponent.cpp +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Component wrapper of Irrlicht's ICameraSceneNode. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 "CameraComponent.h" +#include "../../core/GameManager.h" + + +// CameraComponent class +// CameraComponent constructor (default). +CameraComponent::CameraComponent(Entity *parent, const vector3df &lookat) +: SceneComponent(parent, true) +{ + ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); + + mCameraSN = pSceneMgr->addCameraSceneNode(0, vector3df(0, 0, 0), lookat, parent->getID()); + mSceneNode = mCameraSN; + + mCameraAnimator = NULL; +} + +// CameraComponent deconstructor. +CameraComponent::~CameraComponent() +{ + mCameraSN->remove(); + mSceneNode = NULL; +} + +// Gets a direct pointer to the ICameraSceneNode. +ICameraSceneNode* CameraComponent::getCameraSceneNode() +{ + return mCameraSN; +} + +// Binds the camera scene node's rotation to its target position and vice vera, or unbinds them. +void CameraComponent::bindTargetAndRotation(bool bound) +{ + mCameraSN->bindTargetAndRotation(bound); +} + +// Queries if the camera scene node's rotation and its target position are bound together. +bool CameraComponent::getTargetAndRotationBinding() +{ + return mCameraSN->getTargetAndRotationBinding(); +} + +// Gets the aspect ratio of the camera. +float CameraComponent::getAspectRatio() +{ + return mCameraSN->getAspectRatio(); +} + +// Gets the value of the far plane of the camera. +float CameraComponent::getFarValue() +{ + return mCameraSN->getFarValue(); +} + +// Gets the field of view of the camera. +float CameraComponent::getFOV() +{ + return mCameraSN->getFOV(); +} + +// Gets the value of the near plane of the camera. +float CameraComponent::getNearValue() +{ + return mCameraSN->getNearValue(); +} + +// Gets the current projection matrix of the camera. +const matrix4& CameraComponent::getProjectionMatrix() +{ + return mCameraSN->getProjectionMatrix(); +} + +// Gets the current look at target of the camera. +const vector3df& CameraComponent::getTarget() +{ + return mCameraSN->getTarget(); +} + +// Gets the up vector of the camera. +const vector3df& CameraComponent::getUpVector() +{ + return mCameraSN->getUpVector(); +} + +// Gets the current view matrix of the camera. +const matrix4& CameraComponent::getViewMatrix() +{ + return mCameraSN->getViewMatrix(); +} + +// Checks if the camera is orthogonal. +bool CameraComponent::getIsOrthogonal() +{ + return mCameraSN->isOrthogonal(); +} + +// Sets this camera as the main camera. +void CameraComponent::setAsMainCamera() +{ + GameManager::Instance()->getSceneManager()->setActiveCamera(mCameraSN); +} + +// Sets the aspect ratio (default: 4.0f / 3.0f). +void CameraComponent::setAspectRatio(float aspect) +{ + mCameraSN->setAspectRatio(aspect); +} + +// Sets the value of the far clipping plane (default: 2000.0f). +void CameraComponent::setFarValue(float value) +{ + mCameraSN->setFarValue(value); +} + +// Sets the field of view (Default: PI / 2.5f). +void CameraComponent::setFOV(float value) +{ + mCameraSN->setFOV(value); +} + +// Sets the value of the near clipping plane. (default: 1.0f). +void CameraComponent::setNearValue(float value) +{ + mCameraSN->setNearValue(value); +} + +// Sets the projection matrix of the camera. +void CameraComponent::setProjectionMatrix(const matrix4 &projection, bool isOrthogonal) +{ + mCameraSN->setProjectionMatrix(projection, isOrthogonal); +} + +// Sets the rotation of the node. +void CameraComponent::setRotation(const vector3df &rotation) +{ + mCameraSN->setRotation(rotation); +} + +// Sets the look at target of the camera. +void CameraComponent::setTarget(const vector3df &position) +{ + mCameraSN->setTarget(position); +} + +// Sets the up vector of the camera. +void CameraComponent::setUpVector(const vector3df &position) +{ + mCameraSN->setUpVector(position); +} + +// Sets the camera to normal mode. +void CameraComponent::setNormalMode() +{ + if(mCameraAnimator) + mCameraSN->removeAnimator(mCameraAnimator); +} + +// Sets the camera to FPS mode. +void CameraComponent::setFPSMode(float rotateSpeed, float moveSpeed, bool verticalMovement, + float jumpSpeed) +{ + // Remove previous camera animator. + if(mCameraAnimator) + mCameraSN->removeAnimator(mCameraAnimator); + + // Add FPS camera animator. + ISceneNodeAnimatorCameraFPS *animFPS = (ISceneNodeAnimatorCameraFPS*)GameManager::Instance()-> + getSceneManager()->getDefaultSceneNodeAnimatorFactory()-> + createSceneNodeAnimator("cameraFPS", mCameraSN); + + animFPS->setRotateSpeed(rotateSpeed); + animFPS->setMoveSpeed(moveSpeed); + animFPS->setVerticalMovement(verticalMovement); + animFPS->drop(); + + mCameraAnimator = animFPS; +} + +// Sets the camera to Maya mode. +void CameraComponent::setMayaMode(float rotateSpeed, float zoomSpeed, float translationSpeed) +{ + // Remove previous camera animator. + if(mCameraAnimator) + mCameraSN->removeAnimator(mCameraAnimator); + + // Add Maya camera animator. + ISceneNodeAnimatorCameraMaya *animMaya = (ISceneNodeAnimatorCameraMaya*)GameManager::Instance()-> + getSceneManager()->getDefaultSceneNodeAnimatorFactory()-> + createSceneNodeAnimator("cameraMaya", mCameraSN); + + animMaya->setRotateSpeed(rotateSpeed); + animMaya->setMoveSpeed(translationSpeed); + animMaya->setZoomSpeed(zoomSpeed); + + mCameraAnimator = animMaya; +} + +// End of File Added: trunk/src/components/scene/CameraComponent.h =================================================================== --- trunk/src/components/scene/CameraComponent.h (rev 0) +++ trunk/src/components/scene/CameraComponent.h 2009-05-08 19:43:56 UTC (rev 20) @@ -0,0 +1,73 @@ +// ///////////////////////////////////////////////////////////////////////////// +// +// Name: CameraComponent.h +// Author: Michael Bartsch (ZCCdark203) +// +// Desc : Declaration of the CameraComponent class. +// +// License: Copyright (C) 2009 Michael Bartsch +// +// 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 __CAMERACOMPONENT_H__ +#define __CAMERACOMPONENT_H__ + +// Include files +#include "../../dependencies.h" +#include "SceneComponent.h" + + +// CameraComponent class +class CameraComponent : public SceneComponent +{ +public: + + // Initialisation and deinitialisation + CameraComponent(Entity *parent, const vector3df &lookat = vector3df(0, 0, 100)); + ~CameraComponent(); + + // Methods + ICameraSceneNode* getCameraSceneNode(); + + void bindTargetAndRotation(bool bound); + bool getTargetAndRotationBinding(); + + float getAspectRatio(); + float getFarValue(); + float getFOV(); + float getNearValue(); + const matrix4& getProjectionMatrix(); + const vector3df& getTarget(); + const vector3df& getUpVector(); + const matrix4& getViewMatrix(); + bool getIsOrthogonal(); + + void setAsMainCamera(); + void setAspectRatio(float aspect); + void setFarValue(float value); + void setFOV(float value); + void setNearValue(float value); + void setProjectionMatrix(const matrix4 &projection, bool isOrthogonal = false); + void setRotation(const vector3df &rotation); + void setTarget(const vector3df &position); + void setUpVector(const vector3df &position); + + void setNormalMode(); + void setFPSMode(float rotateSpeed = 100.0f, float moveSpeed = 0.5f, + bool verticalMovement = false, float jumpSpeed = 0.0f); + void setMayaMode(float rotateSpeed = -1500.0f, float zoomSpeed = 200.0f, + float translationSpeed = 1500.0f); + +private: + + // Members + ICameraSceneNode *mCameraSN; + ISceneNodeAnimator *mCameraAnimator; +}; + +#endif + Modified: trunk/src/components/scene/LightComponent.cpp =================================================================== --- trunk/src/components/scene/LightComponent.cpp 2009-05-08 12:43:04 UTC (rev 19) +++ trunk/src/components/scene/LightComponent.cpp 2009-05-08 19:43:56 UTC (rev 20) @@ -48,9 +48,9 @@ // Gets a direct pointer to the ILightSceneNode. ILightSceneNode* LightComponent::getLightSceneNode() - { - return mLightSN; - } +{ + return mLightSN; +} // Returns whether this light casts shadows. bool LightComponent::getCastShadow() Modified: trunk/src/components/scene/MeshComponent.cpp =================================================================== --- trunk/src/components/scene/MeshComponent.cpp 2009-05-08 12:43:04 UTC (rev 19) +++ trunk/src/components/scene/MeshComponent.cpp 2009-05-08 19:43:56 UTC (rev 20) @@ -25,7 +25,7 @@ { ISceneManager *pSceneMgr = GameManager::Instance()->getSceneManager(); - mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, parent->getID(), vector3df(0, 0, 0), + mMeshSN = pSceneMgr->addMeshSceneNode(0, 0, parent->getID(), vector3df(0, 30, -40), vector3df(0, 0, 0), vector3df(1.0f, 1.0f, 1.0f), true); mSceneNode = mMeshSN; } Modified: trunk/src/components/scene/TextComponent.cpp =================================================================== --- trunk/src/components/scene/TextComponent.cpp 2009-05-08 12:43:04 UTC (rev 19) +++ trunk/src/components/scene/TextComponent.cpp 2009-05-08 19:43:56 UTC (rev 20) @@ -68,9 +68,9 @@ // Gets a direct pointer to the ITextSceneNode. ITextSceneNode* TextComponent::getTextSceneNode() - { - return mTextSN; - } +{ + return mTextSN; +} // Sets the text string. void TextComponent::setText(const std::string &text) Modified: trunk/src/sirrf.cbp =================================================================== --- trunk/src/sirrf.cbp 2009-05-08 12:43:04 UTC (rev 19) +++ trunk/src/sirrf.cbp 2009-05-08 19:43:56 UTC (rev 20) @@ -52,6 +52,8 @@ <Unit filename="components/scene/AnimatedMeshComponent.h" /> <Unit filename="components/scene/BillboardComponent.cpp" /> <Unit filename="components/scene/BillboardComponent.h" /> + <Unit filename="components/scene/CameraComponent.cpp" /> + <Unit filename="components/scene/CameraComponent.h" /> <Unit filename="components/scene/LightComponent.cpp" /> <Unit filename="components/scene/LightComponent.h" /> <Unit filename="components/scene/MeshComponent.cpp" /> Modified: trunk/src/sirrf.depend =================================================================== --- trunk/src/sirrf.depend 2009-05-08 12:43:04 UTC (rev 19) +++ trunk/src/sirrf.depend 2009-05-08 19:43:56 UTC (rev 20) @@ -989,7 +989,7 @@ <assert.h> "scriptstring.h" -1241782432 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp +1241786428 source:/home/michael/Programming/Projects/sirrf/src/core/DataStack.cpp "DataStack.h" "GameManager.h" @@ -1017,7 +1017,7 @@ 1241784354 source:/home/michael/Programming/Projects/sirrf/src/core/DataStore.cpp "DataStore.h" -1241205947 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp +1241786392 source:/home/michael/Programming/Projects/sirrf/src/core/Entity.cpp "Entity.h" "GameManager.h" @@ -1029,7 +1029,7 @@ "../dependencies.h" "Entity.h" -1241784995 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp +1241786410 source:/home/michael/Programming/Projects/sirrf/src/core/EntityComponent.cpp "EntityComponent.h" 1241206746 source:/home/michael/Programming/Projects/sirrf/src/core/EntityManager.cpp @@ -1039,8 +1039,10 @@ "../dependencies.h" "Entity.h" -1241786269 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp +1241811192 source:/home/michael/Programming/Projects/sirrf/src/core/GameManager.cpp "GameManager.h" + "../components/scene/CameraComponent.h" + "../components/scene/AnimatedMeshComponent.h" 1241782433 /home/michael/Programming/Projects/sirrf/src/core/GameManager.h "../dependencies.h" @@ -1138,7 +1140,7 @@ "../../dependencies.h" "BillboardComponent.h" -1241639942 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.cpp +1241804074 source:/home/michael/Programming/Projects/sirrf/src/components/scene/TextComponent.cpp "TextComponent.h" "../../core/GameManager.h" @@ -1146,7 +1148,7 @@ "../../dependencies.h" "SceneComponent.h" -1241783089 source:/home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.cpp +1241809517 source:/home/michael/Programming/Projects/sirrf/src/components/scene/MeshComponent.cpp "MeshComponent.h" "../../core/GameManager.h" @@ -1160,7 +1162,7 @@ 1241639151 source:/home/michael/Programming/Projects/sirrf/src/core/support.cpp "support.h" -1241703965 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp +1241804068 source:/home/michael/Programming/Projects/sirrf/src/components/scene/LightComponent.cpp "LightComponent.h" "../../core/GameManager.h" @@ -1176,3 +1178,11 @@ "../../dependencies.h" "SceneComponent.h" +1241811159 source:/home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.cpp + "CameraComponent.h" + "../../core/GameManager.h" + +1241811159 /home/michael/Programming/Projects/sirrf/src/components/scene/CameraComponent.h + "../../dependencies.h" + "SceneComponent.h" + Modified: trunk/src/sirrf.layout =================================================================== --- trunk/src/sirrf.layout 2009-05-08 12:43:04 UTC (rev 19) +++ trunk/src/sirrf.layout 2009-05-08 19:43:56 UTC (rev 20) @@ -1,26 +1,35 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="linux-release" /> + <File name="components/scene/AnimatedMeshComponent.cpp" open="1" top="1" tabpos="1"> + <Cursor position="5966" topLine="21" /> + </File> + <File name="components/scene/AnimatedMeshComponent.h" open="0" top="0" tabpos="0"> + <Cursor position="1710" topLine="21" /> + </File> <File name="components/scene/BillboardComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1548" topLine="15" /> </File> <File name="components/scene/BillboardComponent.h" open="0" top="0" tabpos="0"> <Cursor position="1208" topLine="11" /> </File> + <File name="components/scene/LightComponent.cpp" open="0" top="0" tabpos="0"> + <Cursor position="0" topLine="48" /> + </File> <File name="components/scene/LightComponent.h" open="0" top="0" tabpos="0"> <Cursor position="0" topLine="9" /> </File> <File name="components/scene/MeshComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="2875" topLine="0" /> + <Cursor position="2722" topLine="0" /> </File> <File name="components/scene/MeshComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="1475" topLine="9" /> + <Cursor position="1430" topLine="9" /> </File> <File name="components/scene/SceneComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="1183" topLine="3" /> </File> <File name="components/scene/SceneComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="957" topLine="1" /> + <Cursor position="957" topLine="4" /> </File> <File name="components/scene/TextBillboardComponent.cpp" open="0" top="0" tabpos="0"> <Cursor position="3618" topLine="61" /> @@ -29,31 +38,34 @@ <Cursor position="1563" topLine="9" /> </File> <File name="components/scene/TextComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="0" topLine="44" /> + <Cursor position="0" topLine="32" /> </File> <File name="components/scene/TextComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="788" topLine="8" /> + <Cursor position="1411" topLine="8" /> </File> <File name="core/DataStack.cpp" open="0" top="0" tabpos="0"> - <Cursor position="4770" topLine="129" /> + <Cursor position="5904" topLine="222" /> </File> <File name="core/DataStack.h" open="0" top="0" tabpos="0"> - <Cursor position="2705" topLine="69" /> + <Cursor position="2589" topLine="75" /> </File> <File name="core/DataStore.cpp" open="0" top="0" tabpos="0"> - <Cursor position="4544" topLine="178" /> + <Cursor position="3007" topLine="178" /> </File> + <File name="core/DataStore.h" open="0" top="0" tabpos="0"> + <Cursor position="1253" topLine="18" /> + </File> <File name="core/Entity.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1027" topLine="114" /> + <Cursor position="5686" topLine="212" /> </File> <File name="core/Entity.h" open="0" top="0" tabpos="0"> <Cursor position="1592" topLine="24" /> </File> <File name="core/EntityComponent.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1062" topLine="3" /> + <Cursor position="2995" topLine="74" /> </File> <File name="core/EntityComponent.h" open="0" top="0" tabpos="0"> - <Cursor position="980" topLine="9" /> + <Cursor position="1466" topLine="26" /> </File> <File name="core/EntityManager.cpp" open="0" top="0" tabpos="0"> <Cursor position="4303" topLine="164" /> @@ -68,10 +80,10 @@ <Cursor position="707" topLine="27" /> </File> <File name="core/GameManager.cpp" open="0" top="0" tabpos="1"> - <Cursor position="2026" topLine="45" /> + <Cursor position="860" topLine="0" /> </File> <File name="core/GameManager.h" open="0" top="0" tabpos="0"> - <Cursor position="1072" topLine="50" /> + <Cursor position="1901" topLine="30" /> </File> <File name="core/GameState.cpp" open="0" top="0" tabpos="0"> <Cursor position="1420" topLine="4" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |