From: <ku...@us...> - 2008-05-13 15:43:52
|
Revision: 2440 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2440&view=rev Author: kuranes Date: 2008-05-13 08:14:37 -0700 (Tue, 13 May 2008) Log Message: ----------- - linux patch - ragdoll ongoing work - terrain demo file Modified Paths: -------------- trunk/ogrebullet/Collisions/include/Shapes/OgreBulletCollisionsGImpactShape.h trunk/ogrebullet/Collisions/include/Utils/OgreBulletCollisionsMeshToShapeConverter.h trunk/ogrebullet/Demos/Dynamics_Demos/scripts/VC8/Ogre_Bullet_Dynamics_Demos_SDK.vcproj trunk/ogrebullet/Demos/src/OgreBulletListener.cpp trunk/ogrebullet/Dynamics/include/OgreBulletDynamics.h trunk/ogrebullet/Dynamics/include/OgreBulletDynamicsPreRequisites.h trunk/ogrebullet/Dynamics/scripts/VC8/OgreBulletDynamics_SDK.vcproj trunk/ogrebullet/OgreBullet_SDK.suo Added Paths: ----------- trunk/ogrebullet/Collisions/Makefile.am trunk/ogrebullet/Collisions/include/Debug/Makefile.am trunk/ogrebullet/Collisions/include/Makefile.am trunk/ogrebullet/Collisions/include/Shapes/Makefile.am trunk/ogrebullet/Collisions/include/Utils/Makefile.am trunk/ogrebullet/Collisions/src/Makefile.am trunk/ogrebullet/Demos/Dynamics_Demos/include/Ragdoll_Demo.h trunk/ogrebullet/Demos/Dynamics_Demos/include/Terrain_Demo.h trunk/ogrebullet/Demos/Dynamics_Demos/src/Ragdoll_Demo.cpp trunk/ogrebullet/Demos/Dynamics_Demos/src/Terrain_Demo.cpp trunk/ogrebullet/Dynamics/Makefile.am trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am trunk/ogrebullet/Dynamics/include/Makefile.am trunk/ogrebullet/Dynamics/include/Prefab/ trunk/ogrebullet/Dynamics/include/Prefab/Makefile.am trunk/ogrebullet/Dynamics/include/Prefab/OgreBulletDynamicsRagDoll.h trunk/ogrebullet/Dynamics/src/Makefile.am trunk/ogrebullet/Dynamics/src/Prefab/ trunk/ogrebullet/Dynamics/src/Prefab/OgreBulletDynamicsRagDoll.cpp trunk/ogrebullet/Makefile.am trunk/ogrebullet/OgreBullet.pc.in trunk/ogrebullet/autogen.sh trunk/ogrebullet/configure.ac Added: trunk/ogrebullet/Collisions/Makefile.am =================================================================== --- trunk/ogrebullet/Collisions/Makefile.am (rev 0) +++ trunk/ogrebullet/Collisions/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,2 @@ +SUBDIRS = include src + Added: trunk/ogrebullet/Collisions/include/Debug/Makefile.am =================================================================== --- trunk/ogrebullet/Collisions/include/Debug/Makefile.am (rev 0) +++ trunk/ogrebullet/Collisions/include/Debug/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,8 @@ +ogrebulletcoldebugincludedir = $(includedir)/OgreBullet/Collisions/Debug + +ogrebulletcoldebuginclude_HEADERS = \ + OgreBulletCollisionsDebugContact.h \ + OgreBulletCollisionsDebugDrawer.h \ + OgreBulletCollisionsDebugLines.h \ + OgreBulletCollisionsDebugShape.h + Added: trunk/ogrebullet/Collisions/include/Makefile.am =================================================================== --- trunk/ogrebullet/Collisions/include/Makefile.am (rev 0) +++ trunk/ogrebullet/Collisions/include/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,13 @@ +ogrebulletcolincludedir = $(includedir)/OgreBullet/Collisions + +SUBDIRS = Debug Shapes Utils + +ogrebulletcolinclude_HEADERS = \ + OgreBulletCollisions.h \ + OgreBulletCollisionsObject.h \ + OgreBulletCollisionsObjectState.h \ + OgreBulletCollisionsPreRequisites.h \ + OgreBulletCollisionsRay.h \ + OgreBulletCollisionsShape.h \ + OgreBulletCollisionsWorld.h + Added: trunk/ogrebullet/Collisions/include/Shapes/Makefile.am =================================================================== --- trunk/ogrebullet/Collisions/include/Shapes/Makefile.am (rev 0) +++ trunk/ogrebullet/Collisions/include/Shapes/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,18 @@ +ogrebulletcolshapesincludedir = $(includedir)/OgreBullet/Collisions/Shapes + +ogrebulletcolshapesinclude_HEADERS = \ + OgreBulletCollisionsBoxShape.h \ + OgreBulletCollisionsCapsuleShape.h \ + OgreBulletCollisionsCompoundShape.h \ + OgreBulletCollisionsConeShape.h \ + OgreBulletCollisionsConvexHullShape.h \ + OgreBulletCollisionsCylinderShape.h \ + OgreBulletCollisionsGImpactShape.h \ + OgreBulletCollisionsMinkowskiSumShape.h \ + OgreBulletCollisionsMultiSphereShape.h \ + OgreBulletCollisionsSphereShape.h \ + OgreBulletCollisionsStaticPlaneShape.h \ + OgreBulletCollisionsTerrainShape.h \ + OgreBulletCollisionsTriangleShape.h \ + OgreBulletCollisionsTrimeshShape.h + Modified: trunk/ogrebullet/Collisions/include/Shapes/OgreBulletCollisionsGImpactShape.h =================================================================== --- trunk/ogrebullet/Collisions/include/Shapes/OgreBulletCollisionsGImpactShape.h 2008-05-13 14:47:20 UTC (rev 2439) +++ trunk/ogrebullet/Collisions/include/Shapes/OgreBulletCollisionsGImpactShape.h 2008-05-13 15:14:37 UTC (rev 2440) @@ -35,7 +35,11 @@ namespace OgreBulletCollisions { +#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 class __declspec( dllexport ) GImpactConcaveShape : public CollisionShape +#else + class GImpactConcaveShape : public CollisionShape +#endif { public: GImpactConcaveShape(Ogre::Vector3 *_vertices, unsigned int _vertex_count, unsigned int *_indices, unsigned int_index_count); Added: trunk/ogrebullet/Collisions/include/Utils/Makefile.am =================================================================== --- trunk/ogrebullet/Collisions/include/Utils/Makefile.am (rev 0) +++ trunk/ogrebullet/Collisions/include/Utils/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,6 @@ +ogrebulletcolutilsincludedir = $(includedir)/OgreBullet/Collisions/Utils + +ogrebulletcolutilsinclude_HEADERS = \ + OgreBulletCollisionsMeshToShapeConverter.h \ + OgreBulletConverter.h + Modified: trunk/ogrebullet/Collisions/include/Utils/OgreBulletCollisionsMeshToShapeConverter.h =================================================================== --- trunk/ogrebullet/Collisions/include/Utils/OgreBulletCollisionsMeshToShapeConverter.h 2008-05-13 14:47:20 UTC (rev 2439) +++ trunk/ogrebullet/Collisions/include/Utils/OgreBulletCollisionsMeshToShapeConverter.h 2008-05-13 15:14:37 UTC (rev 2440) @@ -111,15 +111,15 @@ void addEntity(Ogre::Entity *entity,const Ogre::Matrix4 &transform = Ogre::Matrix4::IDENTITY); void addMesh(const Ogre::MeshPtr &mesh, const Ogre::Matrix4 &transform); - BoxCollisionShape* AnimatedMeshToShapeConverter::createAlignedBox(unsigned char bone, + BoxCollisionShape* createAlignedBox(unsigned char bone, const Ogre::Vector3 &bonePosition, const Ogre::Quaternion &boneOrientation); - BoxCollisionShape* AnimatedMeshToShapeConverter::createOrientedBox(unsigned char bone, + BoxCollisionShape* createOrientedBox(unsigned char bone, const Ogre::Vector3 &bonePosition, const Ogre::Quaternion &boneOrientation); - CapsuleCollisionShape* AnimatedMeshToShapeConverter::createOrientedCapsuleCollisionShape(unsigned char bone, + CapsuleCollisionShape* createOrientedCapsuleCollisionShape(unsigned char bone, const Ogre::Vector3 &bonePosition, const Ogre::Quaternion &boneOrientation); Added: trunk/ogrebullet/Collisions/src/Makefile.am =================================================================== --- trunk/ogrebullet/Collisions/src/Makefile.am (rev 0) +++ trunk/ogrebullet/Collisions/src/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,37 @@ +INCLUDES = \ + ${OGRE_CFLAGS} \ + ${bullet_CFLAGS} \ + -I../include + +lib_LTLIBRARIES = libOgreBulletCol.la + +libOgreBulletCol_la_SOURCES = \ + OgreBulletCollisionsObject.cpp \ + OgreBulletCollisionsObjectState.cpp \ + OgreBulletCollisionsPrecompiled.cpp \ + OgreBulletCollisionsRay.cpp \ + OgreBulletCollisionsShape.cpp \ + OgreBulletCollisionsWorld.cpp \ + Debug/OgreBulletCollisionsDebugContact.cpp \ + Debug/OgreBulletCollisionsDebugDrawer.cpp \ + Debug/OgreBulletCollisionsDebugLines.cpp \ + Debug/OgreBulletCollisionsDebugShape.cpp \ + Shapes/OgreBulletCollisionsBoxShape.cpp \ + Shapes/OgreBulletCollisionsCapsuleShape.cpp \ + Shapes/OgreBulletCollisionsCompoundShape.cpp \ + Shapes/OgreBulletCollisionsConeShape.cpp \ + Shapes/OgreBulletCollisionsConvexHullShape.cpp \ + Shapes/OgreBulletCollisionsCylinderShape.cpp \ + Shapes/OgreBulletCollisionsGImpactShape.cpp \ + Shapes/OgreBulletCollisionsMinkowskiSumShape.cpp \ + Shapes/OgreBulletCollisionsMultiSphereShape.cpp \ + Shapes/OgreBulletCollisionsSphereShape.cpp \ + Shapes/OgreBulletCollisionsStaticPlaneShape.cpp \ + Shapes/OgreBulletCollisionsTriangleShape.cpp \ + Shapes/OgreBulletCollisionsTrimeshShape.cpp \ + Utils/OgreBulletCollisionsMeshToShapeConverter.cpp + +libOgreBulletCol_la_LIBADD = \ + $(OGRE_LIBS) \ + $(bullet_LIBS) + Added: trunk/ogrebullet/Demos/Dynamics_Demos/include/Ragdoll_Demo.h =================================================================== --- trunk/ogrebullet/Demos/Dynamics_Demos/include/Ragdoll_Demo.h (rev 0) +++ trunk/ogrebullet/Demos/Dynamics_Demos/include/Ragdoll_Demo.h 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,45 @@ +/*************************************************************************** + +This source file is part of OGREBULLET +(Object-oriented Graphics Rendering Engine Bullet Wrapper) +For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 + +Copyright (c) 2007 tua...@gm... (Use it Freely, even Statically, but have to contribute any changes) + + + +This source file is not LGPL, it's public source code that you can reuse. +-----------------------------------------------------------------------------*/ +#ifndef _OGREBULLET_Ragdoll_Demo__H +#define _OGREBULLET_Ragdoll_Demo__H + +#include "OgreBulletDynamics.h" +#include "OgreBulletListener.h" + +// ------------------------------------------------------------------------- +class Ragdoll_Demo : public OgreBulletListener +{ +public: + + Ragdoll_Demo() : OgreBulletListener() + { + mName = "Ragdoll Demo"; + }; + virtual ~Ragdoll_Demo(){}; + + void init(Ogre::Root *root, Ogre::RenderWindow *win, OgreBulletApplication *application); + + void keyPressed(BULLET_KEY_CODE key); + + void shootToKill(); + + void button0Pressed(); + + bool frameStarted(Ogre::Real elapsedTime); + bool frameEnded(Ogre::Real elapsedTime); + + }; + + +#endif //_OGREBULLET_Constraints_Demo__H + Added: trunk/ogrebullet/Demos/Dynamics_Demos/include/Terrain_Demo.h =================================================================== --- trunk/ogrebullet/Demos/Dynamics_Demos/include/Terrain_Demo.h (rev 0) +++ trunk/ogrebullet/Demos/Dynamics_Demos/include/Terrain_Demo.h 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,72 @@ +/*************************************************************************** + +This source file is part of OGREBULLET +(Object-oriented Graphics Rendering Engine Bullet Wrapper) +For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 + +Copyright (c) 2007 tua...@gm... (Use it Freely, even Statically, but have to contribute any changes) + + + +This source file is not LGPL, it's public source code that you can reuse. +-----------------------------------------------------------------------------*/ +#ifndef _OGREBULLET_Terrain_Demo__H +#define _OGREBULLET_Terrain_Demo__H + +#include "OgreBulletDynamics.h" +#include "OgreBulletListener.h" + +// ------------------------------------------------------------------------- +class Terrain_Demo : public OgreBulletListener +{ +public: + +Terrain_Demo() : OgreBulletListener() + { + mName = "Terrain Test Scene"; + }; + virtual ~Terrain_Demo(){}; + + + void init(Ogre::Root *root, Ogre::RenderWindow *win, OgreBulletApplication *application); + + void keyPressed(BULLET_KEY_CODE key); + void keyReleased(BULLET_KEY_CODE key); + + bool frameStarted(Ogre::Real elapsedTime); + +private: + + + + OgreBulletCollisions::HeightmapCollisionShape *mTerrainShape; + + + OgreBulletDynamics::WheeledRigidBody *mCarChassis; + OgreBulletDynamics::VehicleTuning *mTuning; + OgreBulletDynamics::VehicleRayCaster *mVehicleRayCaster; + OgreBulletDynamics::RaycastVehicle *mVehicle; + + Ogre::Entity *mChassis; + Ogre::Entity *mWheels[4]; + Ogre::SceneNode *mWheelNodes[4]; + + + int mWheelsEngine[4]; + int mWheelsEngineCount; + int mWheelsSteerable[4]; + int mWheelsSteerableCount; + + float mEngineForce; + float mSteering; + + int mWheelEngineStyle; + int mWheelSteeringStyle; + + + bool mSteeringLeft; + bool mSteeringRight; +}; + + +#endif //_OGREBULLET_Vehicles_Demo__H Modified: trunk/ogrebullet/Demos/Dynamics_Demos/scripts/VC8/Ogre_Bullet_Dynamics_Demos_SDK.vcproj =================================================================== --- trunk/ogrebullet/Demos/Dynamics_Demos/scripts/VC8/Ogre_Bullet_Dynamics_Demos_SDK.vcproj 2008-05-13 14:47:20 UTC (rev 2439) +++ trunk/ogrebullet/Demos/Dynamics_Demos/scripts/VC8/Ogre_Bullet_Dynamics_Demos_SDK.vcproj 2008-05-13 15:14:37 UTC (rev 2440) @@ -1,324 +1,324 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="8,00" - Name="Dynamics_Demos" - ProjectGUID="{96F6C2AA-6145-435B-B6F1-77AB7026BB29}" - Keyword="Win32Proj" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="..\..\bin\$(ConfigurationName)" - IntermediateDirectory="..\..\obj\$(ConfigurationName)" - ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories=""$(BULLET_HOME)\src";"$(BULLET_HOME)\Extras\GIMPACT\include";..\include;..\..\include;..\..\..\include;..\..\..\..\include;..\..\..\..\Collisions\include;..\..\..\..\Dynamics\include;"$(OGRE_HOME)\include";"$(OGRE_HOME)\Samples\include"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" - MinimalRebuild="false" - BasicRuntimeChecks="3" - SmallerTypeCheck="false" - RuntimeLibrary="3" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="false" - FloatingPointModel="2" - UsePrecompiledHeader="0" - WarningLevel="3" - Detect64BitPortabilityProblems="true" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="OgreMain_d.lib OIS_d.lib OgreBulletCollisions_d.lib OgreBulletDynamics_d.lib libbulletcollision_d.lib libbulletdynamics_d.lib libbulletmath_d.lib libGIMPACT_d.lib" - OutputFile="$(OutDir)/OgreBulletDemos.exe" - LinkIncremental="2" - AdditionalLibraryDirectories=""..\..\..\..\lib\$(ConfigurationName)";"$(OGRE_HOME)\lib\";"$(BULLET_HOME)\out\$(ConfigurationName)8\libs"" - IgnoreAllDefaultLibraries="false" - IgnoreDefaultLibraryNames="" - GenerateDebugInformation="true" - ProgramDatabaseFile="$(OutDir)/OgreOdeDemo_Blender.pdb" - SubSystem="2" - OptimizeForWindows98="1" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - CommandLine="copy $(TargetPath) $(OGRE_HOME)\bin\$(ConfigurationName)" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="..\..\bin\$(ConfigurationName)" - IntermediateDirectory="..\..\obj\$(ConfigurationName)" - ConfigurationType="1" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - FavorSizeOrSpeed="1" - WholeProgramOptimization="true" - AdditionalIncludeDirectories=""$(BULLET_HOME)\src";"$(BULLET_HOME)\Extras\GIMPACT\include";..\include;..\..\include;..\..\..\include;..\..\..\..\include;..\..\..\..\Collisions\include;..\..\..\..\Dynamics\include;"$(OGRE_HOME)\include";"$(OGRE_HOME)\Samples\include"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_PRECOMP" - StringPooling="true" - MinimalRebuild="true" - BasicRuntimeChecks="0" - SmallerTypeCheck="false" - RuntimeLibrary="2" - BufferSecurityCheck="false" - EnableFunctionLevelLinking="true" - FloatingPointModel="2" - UsePrecompiledHeader="0" - WarningLevel="3" - Detect64BitPortabilityProblems="true" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="OgreMain.lib OIS.lib OgreBulletCollisions.lib OgreBulletDynamics.lib libbulletcollision.lib libbulletdynamics.lib libbulletmath.lib libGIMPACT.lib" - OutputFile="$(OutDir)/OgreBulletDemos.exe" - LinkIncremental="1" - AdditionalLibraryDirectories=""..\..\..\..\lib\$(ConfigurationName)";"$(OGRE_HOME)\lib\";"$(BULLET_HOME)\out\$(ConfigurationName)8\libs"" - GenerateDebugInformation="true" - SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - OptimizeForWindows98="1" - LinkTimeCodeGeneration="1" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - CommandLine="copy $(TargetPath) $(OGRE_HOME)\bin\$(ConfigurationName)" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" - > - <File - RelativePath="..\..\src\Constraints_Demo.cpp" - > - </File> - <File - RelativePath="..\..\src\main.cpp" - > - </File> - <File - RelativePath="..\..\src\Primitives_Demo.cpp" - > - </File> - <File - RelativePath="..\..\src\Ragdoll_Demo.cpp" - > - </File> - <File - RelativePath="..\..\src\Terrain_Demo.cpp" - > - </File> - <File - RelativePath="..\..\src\TriMesh_Demo.cpp" - > - </File> - <File - RelativePath="..\..\src\Vehicle_Demo.cpp" - > - </File> - <Filter - Name="Common" - > - <File - RelativePath="..\..\..\src\BetaGUI.cpp" - > - </File> - <File - RelativePath="..\..\..\src\OgreBulletApplication.cpp" - > - </File> - <File - RelativePath="..\..\..\src\OgreBulletGuiListener.cpp" - > - </File> - <File - RelativePath="..\..\..\src\OgreBulletInputListener.cpp" - > - </File> - <File - RelativePath="..\..\..\src\OgreBulletListener.cpp" - > - </File> - </Filter> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl;inc;xsd" - UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" - > - <File - RelativePath="..\..\include\Constraints_Demo.h" - > - </File> - <File - RelativePath="..\..\include\Primitives_Demo.h" - > - </File> - <File - RelativePath="..\..\include\Ragdoll_Demo.h" - > - </File> - <File - RelativePath="..\..\include\Terrain_Demo.h" - > - </File> - <File - RelativePath="..\..\include\TriMesh_Demo.h" - > - </File> - <File - RelativePath="..\..\include\Vehicle_Demo.h" - > - </File> - <Filter - Name="Common" - > - <File - RelativePath="..\..\..\include\BetaGUI.h" - > - </File> - <File - RelativePath="..\..\..\include\OgreBulletApplication.h" - > - </File> - <File - RelativePath="..\..\..\include\OgreBulletGuiListener.h" - > - </File> - <File - RelativePath="..\..\..\include\OgreBulletInputListener.h" - > - </File> - <File - RelativePath="..\..\..\include\OgreBulletListener.h" - > - </File> - </Filter> - </Filter> - <Filter - Name="Resource Files" - Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" - UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" - > - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="Dynamics_Demos" + ProjectGUID="{96F6C2AA-6145-435B-B6F1-77AB7026BB29}" + Keyword="Win32Proj" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="$(OGRE_HOME)\bin\$(ConfigurationName)" + IntermediateDirectory="..\..\obj\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories=""$(BULLET_HOME)\src";"$(BULLET_HOME)\Extras\GIMPACT\include";..\include;..\..\include;..\..\..\include;..\..\..\..\include;..\..\..\..\Collisions\include;..\..\..\..\Dynamics\include;"$(OGRE_HOME)\include";"$(OGRE_HOME)\Samples\include"" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + MinimalRebuild="false" + BasicRuntimeChecks="3" + SmallerTypeCheck="false" + RuntimeLibrary="3" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="false" + FloatingPointModel="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="OgreMain_d.lib OIS_d.lib OgreBulletCollisions_d.lib OgreBulletDynamics_d.lib libbulletcollision_d.lib libbulletdynamics_d.lib libbulletmath_d.lib libGIMPACT_d.lib" + OutputFile="$(OutDir)/OgreBulletDemos.exe" + LinkIncremental="2" + AdditionalLibraryDirectories=""..\..\..\..\lib\$(ConfigurationName)";"$(OGRE_HOME)\lib\";"$(BULLET_HOME)\out\$(ConfigurationName)8\libs"" + IgnoreAllDefaultLibraries="false" + IgnoreDefaultLibraryNames="" + GenerateDebugInformation="true" + ProgramDatabaseFile="$(OutDir)/OgreOdeDemo_Blender.pdb" + SubSystem="2" + OptimizeForWindows98="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + CommandLine="" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="$(OGRE_HOME)\bin\$(ConfigurationName)" + IntermediateDirectory="..\..\obj\$(ConfigurationName)" + ConfigurationType="1" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="1" + FavorSizeOrSpeed="1" + WholeProgramOptimization="true" + AdditionalIncludeDirectories=""$(BULLET_HOME)\src";"$(BULLET_HOME)\Extras\GIMPACT\include";..\include;..\..\include;..\..\..\include;..\..\..\..\include;..\..\..\..\Collisions\include;..\..\..\..\Dynamics\include;"$(OGRE_HOME)\include";"$(OGRE_HOME)\Samples\include"" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_PRECOMP" + StringPooling="true" + MinimalRebuild="true" + BasicRuntimeChecks="0" + SmallerTypeCheck="false" + RuntimeLibrary="2" + BufferSecurityCheck="false" + EnableFunctionLevelLinking="true" + FloatingPointModel="2" + UsePrecompiledHeader="0" + WarningLevel="3" + Detect64BitPortabilityProblems="true" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="OgreMain.lib OIS.lib OgreBulletCollisions.lib OgreBulletDynamics.lib libbulletcollision.lib libbulletdynamics.lib libbulletmath.lib libGIMPACT.lib" + OutputFile="$(OutDir)/OgreBulletDemos.exe" + LinkIncremental="1" + AdditionalLibraryDirectories=""..\..\..\..\lib\$(ConfigurationName)";"$(OGRE_HOME)\lib\";"$(BULLET_HOME)\out\$(ConfigurationName)8\libs"" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + OptimizeForWindows98="1" + LinkTimeCodeGeneration="1" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + CommandLine="" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath="..\..\src\Constraints_Demo.cpp" + > + </File> + <File + RelativePath="..\..\src\main.cpp" + > + </File> + <File + RelativePath="..\..\src\Primitives_Demo.cpp" + > + </File> + <File + RelativePath="..\..\src\Ragdoll_Demo.cpp" + > + </File> + <File + RelativePath="..\..\src\Terrain_Demo.cpp" + > + </File> + <File + RelativePath="..\..\src\TriMesh_Demo.cpp" + > + </File> + <File + RelativePath="..\..\src\Vehicle_Demo.cpp" + > + </File> + <Filter + Name="Common" + > + <File + RelativePath="..\..\..\src\BetaGUI.cpp" + > + </File> + <File + RelativePath="..\..\..\src\OgreBulletApplication.cpp" + > + </File> + <File + RelativePath="..\..\..\src\OgreBulletGuiListener.cpp" + > + </File> + <File + RelativePath="..\..\..\src\OgreBulletInputListener.cpp" + > + </File> + <File + RelativePath="..\..\..\src\OgreBulletListener.cpp" + > + </File> + </Filter> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath="..\..\include\Constraints_Demo.h" + > + </File> + <File + RelativePath="..\..\include\Primitives_Demo.h" + > + </File> + <File + RelativePath="..\..\include\Ragdoll_Demo.h" + > + </File> + <File + RelativePath="..\..\include\Terrain_Demo.h" + > + </File> + <File + RelativePath="..\..\include\TriMesh_Demo.h" + > + </File> + <File + RelativePath="..\..\include\Vehicle_Demo.h" + > + </File> + <Filter + Name="Common" + > + <File + RelativePath="..\..\..\include\BetaGUI.h" + > + </File> + <File + RelativePath="..\..\..\include\OgreBulletApplication.h" + > + </File> + <File + RelativePath="..\..\..\include\OgreBulletGuiListener.h" + > + </File> + <File + RelativePath="..\..\..\include\OgreBulletInputListener.h" + > + </File> + <File + RelativePath="..\..\..\include\OgreBulletListener.h" + > + </File> + </Filter> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: trunk/ogrebullet/Demos/Dynamics_Demos/src/Ragdoll_Demo.cpp =================================================================== --- trunk/ogrebullet/Demos/Dynamics_Demos/src/Ragdoll_Demo.cpp (rev 0) +++ trunk/ogrebullet/Demos/Dynamics_Demos/src/Ragdoll_Demo.cpp 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,321 @@ +/*************************************************************************** + +This source file is part of OGREBULLET +(Object-oriented Graphics Rendering Engine Bullet Wrapper) +For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 + +Copyright (c) 2007 tua...@gm... (Use it Freely, even Statically, but have to contribute any changes) + + + +This source file is not LGPL, it's public source code that you can reuse. +-----------------------------------------------------------------------------*/ +#include "Ragdoll_Demo.h" + +#include "OgreBulletDynamicsWorld.h" +#include "OgreBulletDynamicsRigidBody.h" +#include "Debug/OgreBulletCollisionsDebugDrawer.h" + +#if !(OGRE_VERSION < ((1 << 16) | (3 << 8) | 0)) +using namespace OIS; +#endif + +using namespace Ogre; +using namespace OgreBulletCollisions; +using namespace OgreBulletDynamics; + +// ------------------------------------------------------------------------- +const String ragdollMeshNames[] = { + "zombie_small.mesh", + "zombie_small.mesh", + "ninja.mesh", + "robot.mesh", + "GingerBreadMan.mesh" +}; +const String ragdollAnimation [] = { + "Walk1", + "Walk1", + "Walk", + "Walk", + "Walk1" +}; +size_t sSelectedMesh = 1; + +#ifdef _DEBUG +const size_t sMaxRagdoll = 10; +#else //_DEBUG +const size_t sMaxRagdoll = 30; +#endif //_DEBUG +// ------------------------------------------------------------------------- +const Vector3 CameraStart = Vector3(0,-9,1); +// ------------------------------------------------------------------------- + +typedef std::list<Entity *> RagDollList; + +struct ragDollData +{ + OgreBulletDynamics::RagDoll *ragdoll; + size_t sSelectedMesh; + Ogre::Real timeSinceBirth; + Ogre::Real timeSincePhysical; +}; + +// ------------------------------------------------------------------------- +RagDollList myRagDolls; + +Real _animation_speed; + +Entity *_gun; +SceneNode *_gun_node; + +Overlay* _over; + +Real _shot_time; + +Real _last_ragdoll; +int _ragdoll_count; +// ------------------------------------------------------------------------- + +// ------------------------------------------------------------------------- +void Ragdoll_Demo::init(Ogre::Root *root, Ogre::RenderWindow *win, OgreBulletApplication *application) +{ + mHelpKeys.clear(); + mHelpKeys.push_back (BASIC_HELP_INFO0); + mHelpKeys.push_back (BASIC_HELP_INFO1); + mHelpKeys.push_back (BASIC_HELP_INFO2); + mHelpKeys.push_back (BASIC_HELP_INFO3); + mHelpKeys.push_back (BASIC_HELP_INFO4); + mHelpKeys.push_back (BASIC_HELP_INFO5); + mHelpKeys.push_back (BASIC_HELP_INFO6); + // ------------------------ + // Start OgreScene + mSceneMgr = root->createSceneManager(ST_GENERIC); + + mCamera = mSceneMgr->createCamera("Cam"); + //mCamera->setFOVy(Degree(90)); + mCamera->setNearClipDistance(0.1); + mCamera->setFarClipDistance(100); + Viewport *vp = win->addViewport(mCamera); + vp->setBackgroundColour(ColourValue(0,0,0)); + // Alter the camera aspect ratio to match the viewport + mCamera->setAspectRatio( + Real(vp->getActualWidth()) / Real(vp->getActualHeight())); + mCamera->setPosition(CameraStart); + mCamera->rotate(Vector3(1,0,0), Degree(90)); + mCamera->setFixedYawAxis(true, Vector3::UNIT_Z); + + OgreBulletListener::init(root, win, application); + + // ------------------------ + // add lights + setBasicLight(); + + // ------------------------ + // Add the Gui + setPhysicGUI(); + // ------------------------ + // Start Bullet + initWorld(); + + // ------------------------ + // Add the ground + addGround(); +} +// ------------------------------------------------------------------------- +void Ragdoll_Demo::keyPressed(BULLET_KEY_CODE key) +{ + const float trowDist = 2.0f; + switch(key) + { + case KC_X: + shootToKill(); + break; + } + OgreBulletListener::throwDynamicObject (key); + OgreBulletListener::dropDynamicObject (key); + + return OgreBulletListener::keyPressed (key); +} +// ------------------------------------------------------------------------- +void Ragdoll_Demo::button0Pressed() +{ + shootToKill(); +} +// ------------------------------------------------------------------------- +bool Ragdoll_Demo::frameStarted(Ogre::Real elapsedTime) +{ + _last_ragdoll += elapsedTime; + + +#ifdef _RAGDOLL_FINISHED + _gun_node->setOrientation(mCamera->getOrientation()); + _gun_node->setPosition(mCamera->getPosition() + (mCamera->getOrientation() * Ogre::Vector3(0.3,-0.15,-1.1))); + + for ( RagDollList::iterator iRag = myRagDolls.begin(); + iRag != myRagDolls.end(); + ++iRag) + { + ragDollData *b = any_cast<ragDollData *> ((*iRag)->getUserAny()); + if (b && b->ragdoll) + { + if (b->ragdoll->isActive()) + { + + b->timeSincePhysical += time; + b->ragdoll->update(); + } + } + else + { + (*iRag)->getAnimationState(ragdollAnimation[b->sSelectedMesh])->addTime(time * _animation_speed); + + (*iRag)->getParentNode ()->translate( + (*iRag)->getParentNode ()->getOrientation() * (Vector3::UNIT_Z * time * 2.5)); + + } + } +#endif + + return OgreBulletListener::frameStarted(elapsedTime);; +} +// ------------------------------------------------------------------------- +bool Ragdoll_Demo::frameEnded(Ogre::Real elapsedTime) +{ +#ifdef _RAGDOLL_FINISHED + _shot_time -= time; + + + for ( RagDollList::iterator i = myRagDolls.begin(); + i != myRagDolls.end(); ) + { + + ragDollData *b = any_cast<ragDollData *> ((*i)->getUserAny()); + + if (b) + { + b->timeSinceBirth += time; + + // turn to stone to improve fps, + // better way to do that would be to tweak + // simulation parameters to be less jitty. + // better auto sleep + if (b->ragdoll + && b->ragdoll->isActive() + && b->timeSincePhysical > 5.0) + { + b->ragdoll->setSleep(); + } + + + if ( b->timeSinceBirth > sMaxRagdoll) + { + delete b->ragdoll; + delete b; + + (static_cast<SceneNode*> ((*i)->getParentNode ()->getParent()))->removeAndDestroyChild( + (*i)->getParentNode ()->getName ()); + mSceneMgr->destroyMovableObject((*i)->getName(), (*i)->getMovableType()); + + i = myRagDolls.erase(i); + } + else + { + ++i; + } + } + else + { + ++i; + } + } + if (_last_ragdoll > 5.0 && + myRagDolls.size() < static_cast<size_t>(sMaxRagdoll)) + createRagDoll(); +#endif + return OgreBulletListener::frameEnded(elapsedTime);; +} + +// ------------------------------------------------------------------------- +void Ragdoll_Demo::shootToKill() +{ +#ifdef _RAGDOLL_FINISHED + if (_shot_time <= 0.0) + { + + Ray pickRay = mCamera->getCameraToViewportRay(0.5, 0.5); + + _shot_time = 0.2; + + mRayQuery->setRay (pickRay); + const RaySceneQueryResult& result = mRayQuery->execute(); + if (!result.empty()) + { + RaySceneQueryResult::const_iterator i = result.begin(); + + //mRayQuery->setSortByDistance (true, 1);//only one hit + + //myBulletRayRay->setDefinition(pickRay.getOrigin(), pickRay.getDirection()); + //myBulletRayRay->enable (); + + while((i != result.end())) + { + + _last_ragdoll = 5.0; + + Entity *e = i->movable; + ragDollData * const b = any_cast<ragDollData *> (e->getUserAny()); + + // uncomment to see nice debug mesh of animated mesh + //#define _DEBUG_ZOMBIE_TRIMESH +#ifdef _DEBUG_TRIMESH + // ray cast could be tested against that instead of ragdoll. + // depending on complexity of mesh could be simpler + OgreBulletListener::AnimatedMeshToShapeConverter meshconverter(e, e->getParentNode ()->_getFullTransform()); + //_geoms.push_back(meshconverter.createStaticTriangleMesh(_world, _space)); +#else //_DEBUG_TRIMESH + bool wasPhysical = b && b->ragdoll && b->ragdoll->isCollisionEnabled(); + if (!wasPhysical) + { + e->getAnimationState(ragdollAnimation[b->sSelectedMesh])->setEnabled(false); + + + // Create the ragdoll + b->ragdoll->collisionEnable(true); + //e->setSelfCollisions(true); + + } + + + OgreBulletDynamics::RigidBody *hit_body; + Ogre::Vector3 hit_point; + + bool is_hit = false; + if (e->pickRagdoll(myBulletRay, hit_body, hit_point)) + { + if (hit_body) + { + hit_body->addForceAt(pickRay.getDirection() * 250000, hit_point); + is_hit = true; + ragDollData *b = any_cast<ragDollData *> (e->getUserAny()); + b->timeSincePhysical = 0.0f; + } + } + + if (!is_hit&& !wasPhysical) + { + ragDollData *b = any_cast<ragDollData *> (e->getUserAny()); + if (b && b->ragdoll) + b->ragdoll->collisionEnable(false); + + e->getAnimationState(ragdollAnimation[b->sSelectedMesh])->setEnabled(true); + } +#endif //_TESTTRIMESH + + ++i; + } // if results. + } + //myBulletRay->disable (); + } + +#endif +} \ No newline at end of file Added: trunk/ogrebullet/Demos/Dynamics_Demos/src/Terrain_Demo.cpp =================================================================== --- trunk/ogrebullet/Demos/Dynamics_Demos/src/Terrain_Demo.cpp (rev 0) +++ trunk/ogrebullet/Demos/Dynamics_Demos/src/Terrain_Demo.cpp 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,574 @@ +/*************************************************************************** + +This source file is part of OGREBULLET +(Object-oriented Graphics Rendering Engine Bullet Wrapper) +For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 + +Copyright (c) 2007 tua...@gm... (Use it Freely, even Statically, but have to contribute any changes) + + + +This source file is not LGPL, it's public source code that you can reuse. +-----------------------------------------------------------------------------*/ +#include "Terrain_Demo.h" + +#include "Shapes/OgreBulletCollisionsTerrainShape.h" +#include "Shapes/OgreBulletCollisionsBoxShape.h" +#include "Shapes/OgreBulletCollisionsCompoundShape.h" + +#include "OgreBulletDynamicsWorld.h" +#include "OgreBulletDynamicsRigidBody.h" +#include "Debug/OgreBulletCollisionsDebugDrawer.h" + +#include "Constraints/OgreBulletDynamicsRaycastVehicle.h" + +#if !(OGRE_VERSION < ((1 << 16) | (3 << 8) | 0)) +using namespace OIS; +#endif + +using namespace Ogre; +using namespace OgreBulletCollisions; +using namespace OgreBulletDynamics; + + + +///btRaycastVehicle is the interface for the constraint that implements the raycast vehicle +///notice that for higher-quality slow-moving vehicles, another approach might be better +///implementing explicit hinged-wheel constraints with cylinder collision, rather then raycasts + + static float gMaxEngineForce = 3000.f; + + static float gSteeringIncrement = 0.04f; + static float gSteeringClamp = 0.8f; + + static float gWheelRadius = 0.5f; + static float gWheelWidth = 0.4f; + + static float gWheelFriction = 1e30f;//1000;//1e30f; + static float gSuspensionStiffness = 20.f; + static float gSuspensionDamping = 2.3f; + static float gSuspensionCompression = 4.4f; + + static float gRollInfluence = + //0.1f; + 1.0f; + static float gSuspensionRestLength = 0.6; + static float gMaxSuspensionTravelCm = 500.0; + static float gFrictionSlip = 10.5; + + static const Vector3 CameraStart = Vector3(0, 25, 0); + // ------------------------------------------------------------------------- + static const Vector3 CarPosition = Vector3(15, 3,-15); + + static const float terrain_height = 45; + static const Vector3 terrain_Shift = Vector3(750, terrain_height, 750); + + +#define CUBE_HALF_EXTENTS 1 + +// ------------------------------------------------------------------------- +void Terrain_Demo::init(Ogre::Root *root, Ogre::RenderWindow *win, OgreBulletApplication *application) +{ + + mCameraMove = 1; + + + mHelpKeys.clear(); + mHelpKeys.push_back (BASIC_HELP_INFO0); + mHelpKeys.push_back (BASIC_HELP_INFO1); + mHelpKeys.push_back (BASIC_HELP_INFO2); + mHelpKeys.push_back (BASIC_HELP_INFO3); + mHelpKeys.push_back (BASIC_HELP_INFO4); + mHelpKeys.push_back (BASIC_HELP_INFO5); + mHelpKeys.push_back (BASIC_HELP_INFO6); + mHelpKeys.push_back ("Use Arrow Key to move Car."); + +// reset + for (int i = 0; i < 4; i++) + { + mWheelsEngine[i] = 0; + mWheelsSteerable[i] = 0; + } + mWheelsEngineCount = 2; + mWheelsEngine[0] = 0; + mWheelsEngine[1] = 1; + mWheelsEngine[2] = 2; + mWheelsEngine[3] = 3; + + mWheelsSteerableCount = 2; + mWheelsSteerable[0] = 0; + mWheelsSteerable[1] = 1; + //mWheelsSteerable[2] = 2; + //mWheelsSteerable[3] = 3; + + mWheelEngineStyle = 0; + mWheelSteeringStyle = 0; + + mSteeringLeft = false; + mSteeringRight = false; + + mEngineForce = 0; + mSteering = 0; + + // ------------------------ + // Start OgreScene + mSceneMgr = root->createSceneManager( "TerrainSceneManager", "BulletTerrain"); + + mCamera = mSceneMgr->createCamera("Cam"); + //mCamera->setFOVy(Degree(90)); + mCamera->setNearClipDistance(0.1); + mCamera->setFarClipDistance(100); + Viewport *vp = win->addViewport(mCamera); + vp->setBackgroundColour(ColourValue(0,0,0)); + // Alter the camera aspect ratio to match the viewport + mCamera->setAspectRatio( + Real(vp->getActualWidth()) / Real(vp->getActualHeight())); + mCamera->setPosition(CameraStart + terrain_Shift); + mCamera->lookAt(CarPosition + terrain_Shift); + + + // Create a terrain + std::string terrain_cfg("terrain.cfg"); + mSceneMgr->setWorldGeometry(terrain_cfg); + + OgreBulletListener::init(root, win, application); + + // ------------------------ + // add lights + setBasicLight(); + + // ------------------------ + // Add the Gui + setPhysicGUI(); + // ------------------------ + // Start Bullet + initWorld(); + + // ------------------------ + // Add the ground + + // 0.1, 0.8 + //addStaticPlane(0.3, 0.8); + + { + int page_size; + Vector3 terrainScale; + String terrainfileName; + + { + Ogre::ConfigFile config; + Ogre::String val; + + config.loadFromResourceSystem(terrain_cfg, ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME, "=", true); + + val = config.getSetting( "PageSize" ); + assert( !val.empty() ); + page_size = atoi( val.c_str() ); + + val = config.getSetting( "PageWorldX" ); + assert( !val.empty() ); + terrainScale.x = atof( val.c_str() ) / page_size; + + val = config.getSetting( "MaxHeight" ); + assert( !val.empty() ); + terrainScale.y = atof( val.c_str() ); + + val = config.getSetting( "PageWorldZ" ); + assert( !val.empty() ); + terrainScale.z = atof( val.c_str() ) / page_size; + + val = config.getSetting( "Heightmap.image" ); + assert( !val.empty() ); + terrainfileName = val; + } + + + float *heights = new float [page_size*page_size]; + { + Ogre::Image terrainHeightMap; + terrainHeightMap.load(terrainfileName, ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME); + + const uchar * const __restrict imagedata = terrainHeightMap.getData(); + for (int src_pos = 0; src_pos < page_size*page_size; src_pos += 1) + { + heights[src_pos] = (((float)(imagedata[src_pos])) / 255); + } + } + + mTerrainShape = new HeightmapCollisionShape ( + page_size, + page_size, + terrainScale, + heights, + true); + + RigidBody *defaultTerrainBody = new RigidBody( + "Terrain", + mWorld); + + const float terrainBodyRestitution = 0.1f; + const float terrainBodyFriction = 0.8f; + + Ogre::Vector3 terrainShiftPos(page_size, 0.0, page_size); + //Ogre::Vector3 terrainShiftPos(terrainScale.x, 0.0, terrainScale.z); + terrainShiftPos *= terrainScale; + terrainShiftPos /= 2; + + Ogre::SceneNode* pTerrainNode = mSceneMgr->getRootSceneNode ()->createChildSceneNode (); + defaultTerrainBody->setStaticShape (pTerrainNode, mTerrainShape, terrainBodyRestitution, terrainBodyFriction, terrainShiftPos); + + mBodies.push_back(defaultTerrainBody); + mShapes.push_back(mTerrainShape); + } + + + + + // create obstacle in front of car + addCube("obstacle", Vector3(13, -5.25, -5) + terrain_Shift , Quaternion(Radian(Degree(22.5)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(15, -5.25, -5) + terrain_Shift , Quaternion(Radian(Degree(22.5)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(17, -5.25, -5) + terrain_Shift , Quaternion(Radian(Degree(22.5)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + + addCube("obstacle", Vector3(13, -5.25, -10) + terrain_Shift , Quaternion(Radian(Degree(-22.5)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(15, -5.25, -10) + terrain_Shift , Quaternion(Radian(Degree(-22.5)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(17, -5.25, -10) + terrain_Shift , Quaternion(Radian(Degree(-22.5)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + + // create obstacle a bit aside + addCube("obstacle", Vector3(-2, 0, -5) + terrain_Shift , Quaternion(Radian(Degree(45.0)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(0, 0, -5) + terrain_Shift , Quaternion(Radian(Degree(45.0)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(2, 0, -5) + terrain_Shift , Quaternion(Radian(Degree(45.0)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + + addCube("obstacle", Vector3(-2, 0, -10) + terrain_Shift , Quaternion(Radian(Degree(-45.0)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(0, 0, -10) + terrain_Shift , Quaternion(Radian(Degree(-45.0)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(2, 0, -10) + terrain_Shift , Quaternion(Radian(Degree(-45.0)), Vector3::UNIT_X), Vector3(1, 1, 1), 0.3, 0.8, 0); + + // create obstacle just for fun + addCube("obstacle", Vector3(25, -10, -25) + terrain_Shift , Quaternion(Radian(Degree(45.0)), Vector3::UNIT_Z), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(25, -10, -27) + terrain_Shift , Quaternion(Radian(Degree(45.0)), Vector3::UNIT_Z), Vector3(1, 1, 1), 0.3, 0.8, 0); + addCube("obstacle", Vector3(25, -10, -29) + terrain_Shift , Quaternion(Radian(Degree(45.0)), Vector3::UNIT_Z), Vector3(1, 1, 1), 0.3, 0.8, 0); + + + + + /// create vehicle + { + const Vector3 chassisShift(0, 1.0, 0); + float connectionHeight = 0.7f; + + mChassis = mSceneMgr->createEntity( + "chassis" + StringConverter::toString(mNumEntitiesInstanced++), + "chassis.mesh"); + + SceneNode *node = mSceneMgr->getRootSceneNode ()->createChildSceneNode (); + + SceneNode *chassisnode = node->createChildSceneNode (); + chassisnode->attachObject (mChassis); + chassisnode->setPosition (chassisShift); + + + mChassis->setQueryFlags (GEOMETRY_QUERY_MASK); +#if (OGRE_VERSION < ((1 << 16) | (5 << 8) | 0)) // only applicable before shoggoth (1.5.0) + mChassis->setNormaliseNormals(true); +#endif + mChassis->setCastShadows(true); + + + + CompoundCollisionShape* compound = new CompoundCollisionShape(); + + BoxCollisionShape* chassisShape = new BoxCollisionShape(Vector3(1.f,0.75f,2.1f)); + compound->addChildShape(chassisShape, chassisShift); + + mCarChassis = new WheeledRigidBody("carChassis", mWorld); + + mCarChassis->setShape (node, + compound, + 0.6, //restitution + 0.6, //friction + 800, //bodyMass + CarPosition + terrain_Shift , + Quaternion::IDENTITY); + mCarChassis->setDamping(0.2, 0.2); + + mCarChassis->disableDeactivation (); + mTuning = new VehicleTuning( + gSuspensionStiffness, + gSuspensionCompression, + gSuspensionDamping, + gMaxSuspensionTravelCm, + gFrictionSlip); + + mVehicleRayCaster = new VehicleRayCaster(mWorld); + mVehicle = new RaycastVehicle(mCarChassis, mTuning, mVehicleRayCaster); + + { + int rightIndex = 0; + int upIndex = 1; + int forwardIndex = 2; + + mVehicle->setCoordinateSystem(rightIndex, upIndex, forwardIndex); + + Vector3 wheelDirectionCS0(0,-1,0); + Vector3 wheelAxleCS(-1,0,0); + + for (size_t i = 0; i < 4; i++) + { + mWheels[i] = mSceneMgr->createEntity( + "wheel" + StringConverter::toString(mNumEntitiesInstanced++), + "wheel.mesh"); + + mWheels[i]->setQueryFlags (GEOMETRY_QUERY_MASK); +#if (OGRE_VERSION < ((1 << 16) | (5 << 8) | 0)) // only applicable before shoggoth (1.5.0) + mWheels[i]->setNormaliseNormals(true); +#endif + mWheels[i]->setCastShadows(true); + + mWheelNodes[i] = mSceneMgr->getRootSceneNode ()->createChildSceneNode (); + mWheelNodes[i]->attachObject (mWheels[i]); + + } + + { + bool isFrontWheel = true; + + Vector3 connectionPointCS0 ( + CUBE_HALF_EXTENTS-(0.3*gWheelWidth), + connectionHeight, + 2*CUBE_HALF_EXTENTS-gWheelRadius); + + + mVehicle->addWheel( + mWheelNodes[0], + connectionPointCS0, + wheelDirectionCS0, + wheelAxleCS, + gSuspensionRestLength, + gWheelRadius, + isFrontWheel, gWheelFriction, gRollInfluence); + + connectionPointCS0 = Vector3( + -CUBE_HALF_EXTENTS+(0.3*gWheelWidth), + connectionHeight, + 2*CUBE_HALF_EXTENTS-gWheelRadius); + + + mVehicle->addWheel( + mWheelNodes[1], + connectionPointCS0, + wheelDirectionCS0, + wheelAxleCS, + gSuspensionRestLength, + gWheelRadius, + isFrontWheel, gWheelFriction, gRollInfluence); + + + connectionPointCS0 = Vector3( + -CUBE_HALF_EXTENTS+(0.3*gWheelWidth), + connectionHeight, + -2*CUBE_HALF_EXTENTS+gWheelRadius); + + isFrontWheel = false; + mVehicle->addWheel( + mWheelNodes[2], + connectionPointCS0, + wheelDirectionCS0, + wheelAxleCS, + gSuspensionRestLength, + gWheelRadius, + isFrontWheel, gWheelFriction, gRollInfluence); + + connectionPointCS0 = Vector3( + CUBE_HALF_EXTENTS-(0.3*gWheelWidth), + connectionHeight, + -2*CUBE_HALF_EXTENTS+gWheelRadius); + + mVehicle->addWheel( + mWheelNodes[3], + connectionPointCS0, + wheelDirectionCS0, + wheelAxleCS, + gSuspensionRestLength, + gWheelRadius, + isFrontWheel, gWheelFriction, gRollInfluence); + + //mVehicle->setWheelsAttached(); + + } + + } + } + +} +// ------------------------------------------------------------------------- +void Terrain_Demo::keyPressed(BULLET_KEY_CODE key) +{ + OgreBulletListener::throwDynamicObject (key); + OgreBulletListener::dropDynamicObject (key); + + bool wheel_engine_style_change = false; + bool wheel_steering_style_change = false; + + switch(key) + { + + case KC_PGUP: + wheel_engine_style_change = true; + mWheelEngineStyle = (mWheelEngineStyle + 1) % 3; + break; + case KC_PGDOWN: + wheel_engine_style_change = true; + mWheelEngineStyle = (mWheelEngineStyle - 1) % 3; + break; + case KC_HOME: + wheel_steering_style_change = true; + mWheelSteeringStyle = (mWheelSteeringStyle + 1) % 3; + break; + case KC_END: + wheel_steering_style_change = true; + mWheelSteeringStyle = (mWheelSteeringStyle - 1) % 3;; + break; + + case KC_LEFT: + mSteeringLeft = true; + break; + case KC_RIGHT: + mSteeringRight = true; + break; + case KC_DOWN: + mEngineForce = -gMaxEngineForce; + break; + case KC_UP: + mEngineForce = gMaxEngineForce; + break; + default: + break; + + } + + if (wheel_engine_style_change) + { + for (int i = 0; i < 4; i++) + mWheelsEngine[i] = 0; + + if (mWheelEngineStyle < 0) + mWheelEngineStyle = 2; + + switch (mWheelEngineStyle) + { + case 0://front + mWheelsSteerableCount = 2; + mWheelsSteerable[0] = 0; + mWheelsSteerable[1] = 1; + break; + case 1://back + mWheelsSteerableCount = 2; + mWheelsSteerable[0] = 2; + mWheelsSteerable[1] = 3; + break; + case 2://4x4 + mWheelsSteerableCount = 4; + mWheelsSteerable[0] = 0; + mWheelsSteerable[1] = 1; + mWheelsSteerable[2] = 2; + mWheelsSteerable[3] = 3; + break; + default: + assert(0); + break; + } + } + + if (wheel_steering_style_change) + { + for (int i = 0; i < 4; i++) + mWheelsSteerable[i] = 0; + + if (mWheelSteeringStyle < 0) + mWheelSteeringStyle = 2; + + switch (mWheelSteeringStyle) + { + case 0://front + mWheelsEngineCount = 2; + mWheelsEngine[0] = 0; + mWheelsEngine[1] = 1; + break; + case 1://back + mWheelsEngineCount = 2; + mWheelsEngine[0] = 2; + mWheelsEngine[1] = 3; + break; + case 2://4x4 + mWheelsEngineCount = 4; + mWheelsEngine[0] = 0; + mWheelsEngine[1] = 1; + mWheelsEngine[2] = 2; + mWheelsEngine[3] = 3; + break; + default: + assert(0); + break; + } + } + + return OgreBulletListener::keyPressed (key); +} +// ------------------------------------------------------------------------- +void Terrain_Demo::keyReleased(BULLET_KEY_CODE key) +{ + switch(key) + { + + case KC_LEFT: + mSteeringLeft = false; + break; + case KC_RIGHT: + mSteeringRight = false; + break; + case KC_DOWN: + mEngineForce = 0; + break; + case KC_UP: + mEngineForce = 0; + break; + default: + break; + + } + return OgreBulletListener::keyReleased (key); +} +// ------------------------------------------------------------------------- +bool Terrain_Demo::frameStarted(Real elapsedTime) +{ + + // apply engine Force on relevant wheels + for (int i = mWheelsEngine[0]; i < mWheelsEngineCount; i++) + { + mVehicle->applyEngineForce (mEngineForce, mWheelsEngine[i]); + } + + if (mSteeringLeft) + { + mSteering += gSteeringIncrement; + if (mSteering > gSteeringClamp) + mSteering = gSteeringClamp; + } + else if (mSteeringRight) + { + mSteering -= gSteeringIncrement; + if (mSteering < -gSteeringClamp) + mSteering = -gSteeringClamp; + } + + // apply Steering on relevant wheels + for (int i = mWheelsSteerable[0]; i < mWheelsSteerableCount; i++) + { + if (i < 2) + mVehicle->setSteeringValue (mSteering, mWheelsSteerable[i]); + else + mVehicle->setSteeringValue (-mSteering, mWheelsSteerable[i]); + } + + return OgreBulletListener::frameStarted(elapsedTime); +} +// ------------------------------------------------------------------------- \ No newline at end of file Modified: trunk/ogrebullet/Demos/src/OgreBulletListener.cpp =================================================================== (Binary files differ) Added: trunk/ogrebullet/Dynamics/Makefile.am =================================================================== --- trunk/ogrebullet/Dynamics/Makefile.am (rev 0) +++ trunk/ogrebullet/Dynamics/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,2 @@ +SUBDIRS = include src + Added: trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am =================================================================== --- trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am (rev 0) +++ trunk/ogrebullet/Dynamics/include/Constraints/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,9 @@ +ogrebulletdynconstraintsincludedir = $(includedir)/OgreBullet/Dynamics/Constraints + +ogrebulletdynconstraintsinclude_HEADERS = \ + OgreBulletDynamics6DofConstraint.h \ + OgreBulletDynamicsConeTwistConstraint.h \ + OgreBulletDynamicsHingeConstraint.h \ + OgreBulletDynamicsPoint2pointConstraint.h \ + OgreBulletDynamicsRaycastVehicle.h + Added: trunk/ogrebullet/Dynamics/include/Makefile.am =================================================================== --- trunk/ogrebullet/Dynamics/include/Makefile.am (rev 0) +++ trunk/ogrebullet/Dynamics/include/Makefile.am 2008-05-13 15:14:37 UTC (rev 2440) @@ -0,0 +1,12 @@ +ogrebulletdynincludedir = $(includedir)/OgreBullet/Dynamics + +SUBDIRS = Constraints Prefab + +ogrebulletdyninclude_HEADERS = \ + OgreBulletDynamicsConstraint.h \ + OgreBulletDynamics.h \ + OgreBulletDynamicsObjectState.h \ + OgreBulletDynamicsPreRequisites.h \ + OgreBulletDynamicsRigidBody.h \ + OgreBulletDynamicsWorld.h + Modified: trunk/ogrebullet/Dynamics/include/OgreBulletDynamics.h =================================================================== --- trunk/ogrebullet/Dynamics/include/OgreBulletDynamics.h 2008-05-13 14:47:20 UTC (rev 2439) +++ trunk/ogrebullet/Dynamics/include/OgreBulletDynamics.h 2008-05-13 15:14:37 UTC (rev 2440) @@ -1,49 +1,50 @@ -/*************************************************************************** - -This source file is part of OGREBULLET -(Object-oriented Graphics Rendering Engine Bullet Wrapper) -For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 - -Copyright (c) 2007 tua...@gm... (Use it Freely... [truncated message content] |