Changeset 2388
- Timestamp:
- 05/21/07 12:35:33 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Illum/Ogre/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Illum/Ogre/src/Common/include/SceneSerializer.h
r2186 r2388 1 1 #include "Ogre.h" 2 3 #ifdef NXOGRE 4 #include "NXOgre.h" 5 using namespace NxOgre; 6 #endif 2 7 3 8 using namespace Ogre; … … 22 27 SceneNode* sceneNode; 23 28 std::map<String, String> meshFiles; 24 std::map<String, unsigned int> pathMapResolutions; 29 std::map<String, unsigned int> pathMapResolutions; 30 31 #ifdef NXOGRE 32 std::map<String, String> meshPhysXShapes; 33 std::map<String, String> meshPhysXShapeParams; 34 //float physXMass; 35 //float physXDensity; 36 //bool physXKinematic; 37 //bool physXStatic; 38 Scene* scene; 39 World* world; 40 Body* physXBody; 41 #endif 25 42 }; 26 43 … … 54 71 void parseEntryPoints(String filename); 55 72 73 #ifdef NXOGRE 74 public: 75 void setScene(Scene* scene){mScriptContext.scene = scene;} 76 void setWorld(World* world){mScriptContext.world = world;} 77 78 #endif 79 56 80 }; -
GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/SceneSerializer.cpp
r2367 r2388 1 #include "OgreIlluminationManager.h" 1 2 #include "SceneSerializer.h" 2 #include "OgreIlluminationManager.h"3 3 4 4 void logParseError(const String& error, const SceneScriptContext& context) … … 20 20 } 21 21 22 #ifdef NXOGRE 23 ShapeDescription* createShape(String params) 24 { 25 std::vector<String> parameters = StringUtil::split(params); 26 27 ShapeDescription* s = 0; 28 if(parameters[0] == "cube") 29 s = new CubeShape(StringConverter::parseReal(parameters[1]),//width 30 StringConverter::parseReal(parameters[2]),//height 31 StringConverter::parseReal(parameters[3]));//depth 32 else if(parameters[0] == "sphere") 33 s = new SphereShape(StringConverter::parseReal(parameters[1]));//radius 34 else if(parameters[0] == "capsule") 35 s = new CapsuleShape(StringConverter::parseReal(parameters[1]),//radius 36 StringConverter::parseReal(parameters[2]));//height 37 else if(parameters[0] == "convex_mesh") 38 s = new ConvexShape(parameters[1]);//mesh name 39 else if(parameters[0] == "free_mesh") 40 s = new MeshShape(parameters[1]);//mesh name 41 42 return s; 43 } 44 #endif 45 22 46 bool parseMeshName(String& params, SceneScriptContext& context) 23 47 { … … 27 51 //create the Entity with the given mesh, attach to a scene node 28 52 StringUtil::trim(params); 29 String meshfilename = context.meshFiles[params]; 53 String meshfilename = ""; 54 if(context.meshFiles.count(params) != 0) 55 meshfilename = context.meshFiles[params]; 30 56 context.meshName = params; 57 58 #ifdef NXOGRE 59 if(context.meshPhysXShapes.count(context.meshName) != 0) 60 { 61 ShapeDescription *newShape = createShape(context.meshPhysXShapes[context.meshName]); 62 //LogManager::getSingleton().logMessage("meshname: " + meshfilename); 63 context.physXBody = context.scene->createBody(context.entityName, meshfilename, newShape, Vector3(0,0,0), context.meshPhysXShapeParams[context.meshName]); 64 context.entity = context.physXBody->getEntity(); 65 context.sceneNode = context.physXBody->getNode(); 66 } 67 else 68 { 69 context.entity = context.sceneManager->createEntity(context.entityName, meshfilename); 70 SceneNode* root = context.sceneManager->getRootSceneNode(); 71 context.sceneNode = root->createChildSceneNode(context.entityName); 72 context.sceneNode->attachObject(context.entity); 73 } 74 #else 31 75 context.entity = context.sceneManager->createEntity(context.entityName, meshfilename); 32 76 SceneNode* root = context.sceneManager->getRootSceneNode(); 33 77 context.sceneNode = root->createChildSceneNode(context.entityName); 34 context.sceneNode->attachObject(context.entity); 35 context.entity->setCastShadows(true); 78 context.sceneNode->attachObject(context.entity); 79 #endif 36 80 return false; 37 81 } … … 42 86 logParseError("No clusters given!", context); 43 87 44 //create the Entity with the given mesh, attach to a scene node45 88 std::vector<String> parameters = StringUtil::split(params); 46 89 String subentityname = context.entityName + "_SE_" + parameters[0]; … … 57 100 } 58 101 102 bool parseCastShadows(String& params, SceneScriptContext& context) 103 { 104 context.entity->setCastShadows(StringConverter::parseBool(params)); 105 106 return false; 107 } 108 109 #ifdef NXOGRE 110 bool parsePhysXShape(String& params, SceneScriptContext& context) 111 { 112 context.meshPhysXShapes[context.meshName] = params; 113 114 return false; 115 } 116 117 bool parsePhysXMass(String& params, SceneScriptContext& context) 118 { 119 if(context.meshPhysXShapeParams.count(context.meshName) == 0) 120 context.meshPhysXShapeParams[context.meshName] = ""; 121 122 context.meshPhysXShapeParams[context.meshName] += "mass: " + params + ","; 123 124 return false; 125 } 126 127 bool parsePhysXDensity(String& params, SceneScriptContext& context) 128 { 129 if(context.meshPhysXShapeParams.count(context.meshName) == 0) 130 context.meshPhysXShapeParams[context.meshName] = ""; 131 132 context.meshPhysXShapeParams[context.meshName] += "density: " + params + ","; 133 134 return false; 135 } 136 137 bool parsePhysXKinematic(String& params, SceneScriptContext& context) 138 { 139 if(context.meshPhysXShapeParams.count(context.meshName) == 0) 140 context.meshPhysXShapeParams[context.meshName] = ""; 141 142 context.meshPhysXShapeParams[context.meshName] += "kinematic: " + params + ","; 143 144 return false; 145 } 146 147 bool parsePhysXStatic(String& params, SceneScriptContext& context) 148 { 149 if(context.meshPhysXShapeParams.count(context.meshName) == 0) 150 context.meshPhysXShapeParams[context.meshName] = ""; 151 152 context.meshPhysXShapeParams[context.meshName] += "static: " + params + ","; 153 154 return false; 155 } 156 157 #endif 158 59 159 bool parseTransform(String& params, SceneScriptContext& context) 60 160 { 61 161 Matrix4 transformMatrix = StringConverter::parseMatrix4(params); 62 context.sceneNode->setOrientation(transformMatrix.extractQuaternion());63 162 64 163 Vector4 x(1,0,0,0); … … 68 167 Vector4 z(0,0,1,0); 69 168 z = transformMatrix * z; 169 170 #ifdef NXOGRE 171 if(context.meshPhysXShapes.count(context.meshName) != 0) 172 { 173 context.sceneNode->scale((Vector3(x.x,x.y,x.z)).length(), 174 (Vector3(y.x,y.y,y.z)).length(), 175 (Vector3(z.x,z.y,z.z)).length()); 176 context.physXBody->setGlobalOrientation(transformMatrix.extractQuaternion()); 177 context.physXBody->setGlobalPosition(transformMatrix.getTrans()); 178 } 179 else 180 { 181 context.sceneNode->setOrientation(transformMatrix.extractQuaternion()); 182 context.sceneNode->scale((Vector3(x.x,x.y,x.z)).length(), 183 (Vector3(y.x,y.y,y.z)).length(), 184 (Vector3(z.x,z.y,z.z)).length()); 185 context.sceneNode->translate(transformMatrix.getTrans()); 186 } 187 #else 188 context.sceneNode->setOrientation(transformMatrix.extractQuaternion()); 70 189 context.sceneNode->scale((Vector3(x.x,x.y,x.z)).length(), 71 190 (Vector3(y.x,y.y,y.z)).length(), 72 191 (Vector3(z.x,z.y,z.z)).length()); 73 192 context.sceneNode->translate(transformMatrix.getTrans()); 193 #endif 74 194 75 195 return false; … … 125 245 mEntityAttribParsers.insert(AttribParserList::value_type("subentity", (SCENE_ATTRIBUTE_PARSER)parseClusters)); 126 246 mEntityAttribParsers.insert(AttribParserList::value_type("pathmapfile", (SCENE_ATTRIBUTE_PARSER)parsePRMMapName)); 127 247 mEntityAttribParsers.insert(AttribParserList::value_type("castShadows", (SCENE_ATTRIBUTE_PARSER)parseCastShadows)); 248 249 #ifdef NXOGRE 250 mMeshAttribParsers.insert(AttribParserList::value_type("physXShape", (SCENE_ATTRIBUTE_PARSER)parsePhysXShape)); 251 mMeshAttribParsers.insert(AttribParserList::value_type("physXMass", (SCENE_ATTRIBUTE_PARSER)parsePhysXMass)); 252 mMeshAttribParsers.insert(AttribParserList::value_type("physXDensity", (SCENE_ATTRIBUTE_PARSER)parsePhysXDensity)); 253 mMeshAttribParsers.insert(AttribParserList::value_type("physXKinematic", (SCENE_ATTRIBUTE_PARSER)parsePhysXKinematic)); 254 mMeshAttribParsers.insert(AttribParserList::value_type("physXStatic", (SCENE_ATTRIBUTE_PARSER)parsePhysXStatic)); 255 #endif 128 256 } 129 257 -
GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h
r2377 r2388 24 24 #include "ExampleApplication.h" 25 25 #include "OgreIlluminationManager.h" 26 #include "NXOgre.h" 26 27 #include "SceneSerializer.h" 27 28 28 29 AnimationState* mAnimState; 29 30 bool cullCamera = true; 31 Body *throwSphere = 0; 32 Scene* NXScene = 0; 30 33 31 34 // Listener class for frame updates … … 72 75 bool processUnbufferedKeyInput(const FrameEvent& evt) 73 76 { 74 /*if (mInputDevice->isKeyDown(KC_C)&& mTimeUntilNextToggle <= 0) 75 { 76 cullCamera = ! cullCamera; 77 Root::getSingleton()._getCurrentSceneManager()->setOption("CullCamera", &cullCamera); 78 mTimeUntilNextToggle = 1; 79 }*/ 77 78 if (mInputDevice->isKeyDown(KC_SPACE)) { 79 80 if(throwSphere == 0) 81 { 82 throwSphere = NXScene->createBody("throwSphere", 83 "sphere.mesh", 84 new SphereShape(0.5f), 85 Vector3(0,0,0), 86 "mass: 10"); 87 throwSphere->getNode()->setScale(0.005,0.005,0.005); 88 } 89 //myCube-> 90 throwSphere->setGlobalPosition(mCamera->getPosition()); 91 throwSphere->addForce(mCamera->getDirection()*200); 92 93 } 80 94 return ExampleFrameListener::processUnbufferedKeyInput(evt); 81 95 } … … 170 184 DataStreamPtr inputStream; 171 185 inputStream = ResourceGroupManager::getSingleton().openResource("moria.level"); //towers2.level 186 World* NXWorld = new World("FrameListener: yes, log: html"); 187 NXScene = NXWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes"); 188 s.setScene(NXScene); 189 s.setWorld(NXWorld); 172 190 s.parseScript(inputStream, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 173 191 s.parseEntryPoints("prmEntryPoints.text"); 192 /* 193 Body* b = NXScene->createBody("ize", 194 "sphere.mesh", 195 new SphereShape(0.5f), 196 Vector3(5,0,5), 197 "mass: 10"); 198 b->getNode()->setScale(0.005,0.005,0.005); 199 b->setGlobalPosition(Vector3(5,10,5));*/ 200 174 201 /* 175 202 ParticleSystem* pSys1 = mSceneMgr->createParticleSystem("psys1", "GTP/Moria/Smoke_Large"); -
GTP/trunk/App/Demos/Illum/Ogre/src/Moria/scripts/Moria.7.10.vcproj
r2315 r2388 21 21 Optimization="0" 22 22 ImproveFloatingPointConsistency="TRUE" 23 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include "24 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE "23 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include;"$(NXOGRE_PATH)\include";"$(PHYSX_DIR)\SDKs\Physics\include";"$(PHYSX_DIR)\SDKs\Foundation\include";"$(PHYSX_DIR)\SDKs\Cooking\include";"$(PHYSX_DIR)\SDKs\NxCharacter\include";"$(PHYSX_DIR)\SDKs\PhysXLoader\include"" 24 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE" 25 25 MinimalRebuild="TRUE" 26 26 BasicRuntimeChecks="3" … … 35 35 <Tool 36 36 Name="VCLinkerTool" 37 AdditionalDependencies="OgreMain_d.lib IllumModule_Ogre.lib IllumModule.lib "37 AdditionalDependencies="OgreMain_d.lib IllumModule_Ogre.lib IllumModule.lib NxOgre_d.lib" 38 38 OutputFile="$(OutDir)/Moria.exe" 39 39 LinkIncremental="2" 40 AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Debug;"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Debug "40 AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Debug;"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Debug;"$(NXOGRE_PATH)/lib"" 41 41 IgnoreDefaultLibraryNames="" 42 42 GenerateDebugInformation="TRUE" … … 86 86 OptimizeForProcessor="2" 87 87 OptimizeForWindowsApplication="TRUE" 88 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include "89 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE "88 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\include\RenderingRuns;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderTechniques;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\include\RenderingRuns;..\..\Common\include;"$(NXOGRE_PATH)\include";"$(PHYSX_DIR)\SDKs\Physics\include";"$(PHYSX_DIR)\SDKs\Foundation\include";"$(PHYSX_DIR)\SDKs\Cooking\include";"$(PHYSX_DIR)\SDKs\NxCharacter\include";"$(PHYSX_DIR)\SDKs\PhysXLoader\include"" 89 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE" 90 90 StringPooling="TRUE" 91 91 MinimalRebuild="TRUE" … … 101 101 <Tool 102 102 Name="VCLinkerTool" 103 AdditionalDependencies="OgreMain.lib IllumModule_Ogre.lib IllumModule.lib "103 AdditionalDependencies="OgreMain.lib IllumModule_Ogre.lib IllumModule.lib NxOgre.lib" 104 104 OutputFile="$(OutDir)/Moria.exe" 105 105 LinkIncremental="1" 106 AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Release;"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Release "106 AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Release;"$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)";..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Release;"$(NXOGRE_PATH)\lib"" 107 107 GenerateDebugInformation="FALSE" 108 108 SubSystem="2"
Note: See TracChangeset
for help on using the changeset viewer.