Changeset 2388


Ignore:
Timestamp:
05/21/07 12:35:33 (17 years ago)
Author:
szirmay
Message:
 
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  
    11#include "Ogre.h" 
     2 
     3#ifdef NXOGRE 
     4#include "NXOgre.h" 
     5using namespace NxOgre; 
     6#endif 
    27 
    38using namespace Ogre; 
     
    2227        SceneNode* sceneNode; 
    2328        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 
    2542}; 
    2643 
     
    5471        void parseEntryPoints(String filename); 
    5572 
     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 
    5680}; 
  • GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/SceneSerializer.cpp

    r2367 r2388  
     1#include "OgreIlluminationManager.h" 
    12#include "SceneSerializer.h" 
    2 #include "OgreIlluminationManager.h" 
    33 
    44void logParseError(const String& error, const SceneScriptContext& context) 
     
    2020} 
    2121 
     22#ifdef NXOGRE 
     23ShapeDescription* 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 
    2246bool parseMeshName(String& params, SceneScriptContext& context) 
    2347{ 
     
    2751        //create the Entity with the given mesh, attach to a scene node 
    2852        StringUtil::trim(params); 
    29         String meshfilename = context.meshFiles[params]; 
     53        String meshfilename = ""; 
     54        if(context.meshFiles.count(params) != 0) 
     55                meshfilename = context.meshFiles[params]; 
    3056        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 
    3175        context.entity = context.sceneManager->createEntity(context.entityName, meshfilename); 
    3276        SceneNode* root = context.sceneManager->getRootSceneNode(); 
    3377        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   
    3680    return false; 
    3781} 
     
    4286                logParseError("No clusters given!", context); 
    4387 
    44         //create the Entity with the given mesh, attach to a scene node 
    4588        std::vector<String> parameters = StringUtil::split(params); 
    4689        String subentityname = context.entityName + "_SE_" + parameters[0]; 
     
    57100} 
    58101 
     102bool parseCastShadows(String& params, SceneScriptContext& context) 
     103{ 
     104        context.entity->setCastShadows(StringConverter::parseBool(params)); 
     105 
     106        return false; 
     107} 
     108 
     109#ifdef NXOGRE 
     110bool parsePhysXShape(String& params, SceneScriptContext& context) 
     111{ 
     112        context.meshPhysXShapes[context.meshName] = params; 
     113 
     114        return false; 
     115} 
     116 
     117bool 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 
     127bool 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 
     137bool 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 
     147bool 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 
    59159bool parseTransform(String& params, SceneScriptContext& context) 
    60160{ 
    61161        Matrix4 transformMatrix = StringConverter::parseMatrix4(params); 
    62         context.sceneNode->setOrientation(transformMatrix.extractQuaternion()); 
    63162         
    64163        Vector4 x(1,0,0,0); 
     
    68167        Vector4 z(0,0,1,0); 
    69168        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()); 
    70189        context.sceneNode->scale((Vector3(x.x,x.y,x.z)).length(), 
    71190                                                                (Vector3(y.x,y.y,y.z)).length(), 
    72191                                                                (Vector3(z.x,z.y,z.z)).length()); 
    73192        context.sceneNode->translate(transformMatrix.getTrans()); 
     193#endif 
    74194         
    75195        return false; 
     
    125245        mEntityAttribParsers.insert(AttribParserList::value_type("subentity", (SCENE_ATTRIBUTE_PARSER)parseClusters)); 
    126246        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 
    128256} 
    129257 
  • GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h

    r2377 r2388  
    2424#include "ExampleApplication.h" 
    2525#include "OgreIlluminationManager.h" 
     26#include "NXOgre.h" 
    2627#include "SceneSerializer.h" 
    2728 
    2829AnimationState* mAnimState; 
    2930bool cullCamera = true; 
     31Body *throwSphere = 0; 
     32Scene* NXScene = 0; 
    3033 
    3134// Listener class for frame updates 
     
    7275        bool processUnbufferedKeyInput(const FrameEvent& evt) 
    7376    { 
    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                } 
    8094                return ExampleFrameListener::processUnbufferedKeyInput(evt); 
    8195        } 
     
    170184                DataStreamPtr inputStream;                               
    171185                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); 
    172190                s.parseScript(inputStream, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
    173191                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 
    174201/* 
    175202           ParticleSystem* pSys1 = mSceneMgr->createParticleSystem("psys1", "GTP/Moria/Smoke_Large"); 
  • GTP/trunk/App/Demos/Illum/Ogre/src/Moria/scripts/Moria.7.10.vcproj

    r2315 r2388  
    2121                                Optimization="0" 
    2222                                ImproveFloatingPointConsistency="TRUE" 
    23                                 AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\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;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\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;&quot;$(NXOGRE_PATH)\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Physics\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Foundation\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Cooking\include&quot;;&quot;$(PHYSX_DIR)\SDKs\NxCharacter\include&quot;;&quot;$(PHYSX_DIR)\SDKs\PhysXLoader\include&quot;" 
     24                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE" 
    2525                                MinimalRebuild="TRUE" 
    2626                                BasicRuntimeChecks="3" 
     
    3535                        <Tool 
    3636                                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" 
    3838                                OutputFile="$(OutDir)/Moria.exe" 
    3939                                LinkIncremental="2" 
    40                                 AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Debug;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Debug" 
     40                                AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Debug;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Debug;&quot;$(NXOGRE_PATH)/lib&quot;" 
    4141                                IgnoreDefaultLibraryNames="" 
    4242                                GenerateDebugInformation="TRUE" 
     
    8686                                OptimizeForProcessor="2" 
    8787                                OptimizeForWindowsApplication="TRUE" 
    88                                 AdditionalIncludeDirectories="..\include;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\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;&quot;$(OGRE_PATH)\Samples\Common\include&quot;;&quot;$(OGRE_PATH)\OgreMain\include&quot;;..\..\..\..\..\..\..\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;&quot;$(NXOGRE_PATH)\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Physics\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Foundation\include&quot;;&quot;$(PHYSX_DIR)\SDKs\Cooking\include&quot;;&quot;$(PHYSX_DIR)\SDKs\NxCharacter\include&quot;;&quot;$(PHYSX_DIR)\SDKs\PhysXLoader\include&quot;" 
     89                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE" 
    9090                                StringPooling="TRUE" 
    9191                                MinimalRebuild="TRUE" 
     
    101101                        <Tool 
    102102                                Name="VCLinkerTool" 
    103                                 AdditionalDependencies="OgreMain.lib IllumModule_Ogre.lib IllumModule.lib" 
     103                                AdditionalDependencies="OgreMain.lib IllumModule_Ogre.lib IllumModule.lib NxOgre.lib" 
    104104                                OutputFile="$(OutDir)/Moria.exe" 
    105105                                LinkIncremental="1" 
    106                                 AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Release" 
     106                                AdditionalLibraryDirectories="..\..\..\..\..\..\..\Lib\Illum\IllumModule\OgreIllumModule\bin\Release;&quot;$(OGRE_PATH)\OgreMain\lib\$(ConfigurationName)&quot;;..\..\..\..\..\..\..\Lib\Illum\IllumModule\IllumModule\bin\Release;&quot;$(NXOGRE_PATH)\lib&quot;" 
    107107                                GenerateDebugInformation="FALSE" 
    108108                                SubSystem="2" 
Note: See TracChangeset for help on using the changeset viewer.