Ignore:
Timestamp:
07/02/07 04:06:16 (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/FPSPlayer.h

    r2462 r2473  
    55#include "OgreIlluminationManager.h" 
    66#include "NXOgre.h" 
     7#include "GeoLodStripsLibrary.h" 
     8#include "GeoMeshLoader.h" 
    79 
    810using namespace Ogre; 
     
    127129        float getHit(){ if(mCurrentAnimState == PLAYERANIMSTATE_ATTACK) return 20; else return 0;} 
    128130        void addHit(float hit); 
     131        void addPlayerMesh(String meshname, float meshscale, bool rotateModel); 
    129132 
    130133        bool frameStarted(const FrameEvent& evt) 
     
    142145 
    143146        static float MaxHealth; 
     147        static Geometry::GeoMeshLoader* meshLoader; 
     148        static Geometry::Mesh *trollLODMesh; 
     149        Geometry::LodStripsLibrary *lodObject; 
     150        float lastLodLevel; 
    144151}; 
    145152 
  • GTP/trunk/App/Demos/Illum/Ogre/src/Common/src/FPSPlayer.cpp

    r2468 r2473  
    55float TrollCharacter::MaxHealth = 350; 
    66CharacterManager* CharacterManager::mSingleton = 0; 
     7Geometry::GeoMeshLoader* TrollCharacter::meshLoader = 0; 
     8Geometry::Mesh* TrollCharacter::trollLODMesh = 0; 
     9 
     10class CustomIndexData : public Geometry::IndexData 
     11{ 
     12private: 
     13        Ogre::Mesh *targetMesh; 
     14        Ogre::HardwareIndexBufferSharedPtr ibuf; 
     15        Ogre::RenderOperation mRenderOp; 
     16        unsigned long* pIdx; 
     17public: 
     18        CustomIndexData(Ogre::Mesh *ogremesh):Geometry::IndexData(){ 
     19                targetMesh=ogremesh; 
     20                pIdx=NULL; 
     21        } 
     22        virtual ~CustomIndexData(void){} 
     23 
     24        virtual void Begin(unsigned int submeshid, unsigned int indexcount){ 
     25                targetMesh->getSubMesh(submeshid)->_getRenderOperation(mRenderOp,0); 
     26                ibuf = mRenderOp.indexData->indexBuffer; 
     27                mRenderOp.indexData->indexCount = indexcount; 
     28                pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); 
     29        } 
     30        virtual void SetIndex(unsigned int i, unsigned int index){ 
     31                pIdx[i] = index; //lodStripsLib->dataRetrievalInterface->GetIndex(k+offset); 
     32        } 
     33        virtual void End(){ 
     34                ibuf->unlock(); 
     35        } 
     36        virtual void BorrowIndexData(const Geometry::IndexData *){} 
     37}; 
    738 
    839void CharacterManager::levelUP() 
     
    2657                                                                                                                        Vector3(25, 10, 25 - i * 10), false); 
    2758 
    28                         troll->addPlayerMesh("troll.mesh", 0.05, false); 
     59                        troll->addPlayerMesh("trollLOD.mesh", 0.05, false); 
    2960                        troll->addWeaponModel("trollMace.mesh", "RightHand"); 
    3061                        OgreIlluminationManager::getSingleton().initTechniques(troll->getMeshEntity()); 
     
    291322: PlayerCharacter(name, scene, sceneManager, dimensions, startPosition, debug) 
    292323{ 
     324        lastLodLevel = -1.0f; 
    293325        mHealth = MaxHealth; 
    294326} 
     
    363395} 
    364396 
     397void TrollCharacter::addPlayerMesh(String meshname, float meshscale, bool rotateModel) 
     398{ 
     399        if(!meshLoader) 
     400        { 
     401                meshLoader = new Geometry::GeoMeshLoader; 
     402                trollLODMesh = meshLoader->load("../../Media/MORIA/trollLOD.mesh"); 
     403        } 
     404        //clone the mesh 
     405        Mesh* originalMesh = (Mesh*) MeshManager::getSingleton().getByName(meshname).getPointer(); 
     406        if(!originalMesh) 
     407                originalMesh = MeshManager::getSingleton().load("trollLOD.mesh", "GTP_Moria").getPointer(); 
     408        String newMeshName = (meshname + "_CLONE_" + mName); 
     409        Ogre::Mesh *newOgreMesh = originalMesh->clone(newMeshName).getPointer(); 
     410 
     411        mCharacterMeshEntity = mSceneManager->createEntity(mName, newMeshName); 
     412        mCharacterMeshEntity->setCastShadows(true); 
     413        mMeshScale = meshscale; 
     414        mCurrentAnimState = PLAYERANIMSTATE_STAND; 
     415        mCharacterMesh_AnimState = mCharacterMeshEntity->getAnimationState(getAnimStateName(PLAYERANIMSTATE_STAND)); 
     416        mCharacterMesh_AnimState->setEnabled(true); 
     417        mCharacterMesh_AnimState->setLoop(true); 
     418        SceneNode* meshNode = mPlayerNode->createChildSceneNode(mName + "_MeshNode"); 
     419        meshNode->attachObject(mCharacterMeshEntity); 
     420        meshNode->setPosition(0 ,-mPlayerDimensions.y / 2.0, 0); 
     421        meshNode->setScale(meshscale, meshscale, meshscale); 
     422        if(rotateModel) 
     423        meshNode->rotate(Vector3::UNIT_Y, Degree(180.0));        
     424 
     425        if (!meshLoader->GetLodStripsData()) 
     426                OGRE_EXCEPT(1, "LOD info for the trunk not found","TrollCharacter::addPlayerMesh"); 
     427 
     428        lodObject = new Geometry::LodStripsLibrary(meshLoader->GetLodStripsData(), 
     429                                trollLODMesh, 
     430                                new CustomIndexData(this->mCharacterMeshEntity->getMesh().getPointer())); 
     431 
     432         
     433} 
     434 
    365435void PlayerCharacter::addWeaponModel(String meshname, String attachBoneName) 
    366436{ 
     
    460530                q.FromAxes(right,Vector3::UNIT_Y, dir); 
    461531                mPlayerCharacter->setDirection(q); 
    462                  
     532 
     533                float dist_min = 2.0; 
     534                float dist_max = 10.0; 
     535                float lodLevel; 
     536                lodLevel = (float)(dist - dist_min) / (float)(dist_max - dist_min); 
     537                lodLevel = 1.0f - lodLevel; 
     538                 
     539                if (lodLevel < 0.0f) 
     540                        lodLevel = 0.0f; 
     541                if (lodLevel > 1.0f) 
     542                        lodLevel = 1.0f; 
     543                if (fabsf(lastLodLevel-lodLevel)>0.03f ||  
     544                        (lastLodLevel > 0.0f && lodLevel == 0.0f) || 
     545                        (lastLodLevel < 1.0f && lodLevel == 1.0f)) 
     546                { 
     547                        lodObject->GoToLod(lodLevel); 
     548                        lastLodLevel = lodLevel; 
     549                } 
     550 
    463551                if(dist < 1.8) 
    464552                { 
  • GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h

    r2459 r2473  
    391391         
    392392                TrollCharacter* troll = new TrollCharacter("troll1", NXScene, mSceneMgr, Vector3(1.5, 3.0, 1.2), Vector3(15, 10, 15), false); 
    393                 troll->addPlayerMesh("troll.mesh", 0.05, false); 
     393                troll->addPlayerMesh("trollLOD.mesh", 0.05, false); 
    394394                troll->addWeaponModel("trollMace.mesh", "RightHand"); 
    395395 
  • GTP/trunk/App/Demos/Illum/Ogre/src/Moria/scripts/Moria.7.10.vcproj

    r2459 r2473  
    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;&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;" 
     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;;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\include" 
    2424                                PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE" 
    2525                                MinimalRebuild="TRUE" 
     
    3535                        <Tool 
    3636                                Name="VCLinkerTool" 
    37                                 AdditionalDependencies="OgreMain_d.lib IllumModule_Ogre.lib IllumModule.lib NxOgre_d.lib" 
     37                                AdditionalDependencies="OgreMain_d.lib GTGeometry_d.lib IllumModule_Ogre.lib IllumModule.lib NxOgre_d.lib" 
    3838                                OutputFile="$(OutDir)/Moria.exe" 
    39                                 LinkIncremental="2" 
    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;" 
     39                                LinkIncremental="1" 
     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;;&quot;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\build\$(ConfigurationName)&quot;" 
    4141                                IgnoreDefaultLibraryNames="" 
    4242                                GenerateDebugInformation="TRUE" 
     
    8484                                OmitFramePointers="TRUE" 
    8585                                EnableFiberSafeOptimizations="FALSE" 
    86                                 OptimizeForProcessor="2" 
     86                                OptimizeForProcessor="3" 
    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;&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;" 
     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;;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\include" 
    8989                                PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GAMETOOLS_ILLUMINATION_MODULE;GTP_VISIBILITY_MODIFIED_OGRE;NXOGRE" 
    9090                                StringPooling="TRUE" 
     
    102102                        <Tool 
    103103                                Name="VCLinkerTool" 
    104                                 AdditionalDependencies="OgreMain.lib IllumModule_Ogre.lib IllumModule.lib NxOgre.lib" 
     104                                AdditionalDependencies="OgreMain.lib GTGeometry.lib IllumModule_Ogre.lib IllumModule.lib NxOgre.lib" 
    105105                                OutputFile="$(OutDir)/Moria.exe" 
    106106                                LinkIncremental="1" 
    107                                 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;" 
     107                                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;;&quot;..\..\..\..\..\..\..\Lib\Geom\shared\GTGeometry\build\$(ConfigurationName)&quot;" 
     108                                IgnoreAllDefaultLibraries="FALSE" 
     109                                IgnoreDefaultLibraryNames="" 
    108110                                GenerateDebugInformation="FALSE" 
    109111                                SubSystem="2" 
Note: See TracChangeset for help on using the changeset viewer.