From: <kal...@us...> - 2010-01-01 17:46:56
|
Revision: 2776 http://ogreaddons.svn.sourceforge.net/ogreaddons/?rev=2776&view=rev Author: kallaspriit Date: 2010-01-01 17:46:46 +0000 (Fri, 01 Jan 2010) Log Message: ----------- Updated custom joints demo and started raycast car implementation, by Julio. Modified Paths: -------------- branches/ogrenewt/newton20/OgreNewt.sln branches/ogrenewt/newton20/OgreNewt.suo branches/ogrenewt/newton20/OgreNewt.vcproj branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonApplication.cpp branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonFrameListener.cpp branches/ogrenewt/newton20/demos/Demo03_CollisionCallbacks/OgreNewtonApplication.cpp branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonApplication.cpp branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.cpp branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.h branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/SimpleVehicle.cpp branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/SimpleVehicle.h branches/ogrenewt/newton20/demos/Demo07_CustomJoints/Demo07_CustomJoints.vcproj branches/ogrenewt/newton20/demos/Demo07_CustomJoints/OgreNewtonApplication.cpp branches/ogrenewt/newton20/demos/Demo09_PlayerController/OgreNewtonApplication.cpp branches/ogrenewt/newton20/inc/OgreNewt.h branches/ogrenewt/newton20/inc/OgreNewt_BasicJoints.h branches/ogrenewt/newton20/inc/OgreNewt_Joint.h branches/ogrenewt/newton20/inc/OgreNewt_PlayerController.h branches/ogrenewt/newton20/inc/OgreNewt_RayCast.h branches/ogrenewt/newton20/inc/OgreNewt_Vehicle.h branches/ogrenewt/newton20/inc/OgreNewt_World.h branches/ogrenewt/newton20/src/OgreNewt_BasicFrameListener.cpp branches/ogrenewt/newton20/src/OgreNewt_BasicJoints.cpp branches/ogrenewt/newton20/src/OgreNewt_Body.cpp branches/ogrenewt/newton20/src/OgreNewt_ConvexCast.cpp branches/ogrenewt/newton20/src/OgreNewt_Joint.cpp branches/ogrenewt/newton20/src/OgreNewt_PlayerController.cpp branches/ogrenewt/newton20/src/OgreNewt_RayCast.cpp branches/ogrenewt/newton20/src/OgreNewt_Vehicle.cpp branches/ogrenewt/newton20/src/OgreNewt_World.cpp Added Paths: ----------- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj.Julio-PC.Julio.user branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Ogre.log branches/ogrenewt/newton20/demos/Demo07_CustomJoints/MyCustomMotorizedHinge.cpp branches/ogrenewt/newton20/demos/Demo07_CustomJoints/MyCustomMotorizedHinge.h branches/ogrenewt/newton20/demos/MinimalOgreNewtApplication/media/primitives/box.material branches/ogrenewt/newton20/demos/media/materials/scripts/castle.material branches/ogrenewt/newton20/demos/media/materials/scripts/f1Body.material branches/ogrenewt/newton20/demos/media/materials/scripts/f1Body.skl branches/ogrenewt/newton20/demos/media/materials/scripts/f1Tire.material branches/ogrenewt/newton20/demos/media/materials/scripts/jeepBody.material branches/ogrenewt/newton20/demos/media/materials/scripts/jeepBody.skl branches/ogrenewt/newton20/demos/media/materials/scripts/jeepTire.material branches/ogrenewt/newton20/demos/media/materials/scripts/playground.material branches/ogrenewt/newton20/demos/media/materials/scripts/track.material branches/ogrenewt/newton20/demos/media/models/f1Body.mesh branches/ogrenewt/newton20/demos/media/models/f1Tire.mesh branches/ogrenewt/newton20/demos/media/models/jeepBody.mesh branches/ogrenewt/newton20/demos/media/models/jeepTire.mesh branches/ogrenewt/newton20/demos/media/models/track.mesh branches/ogrenewt/newton20/demos/media/primitives/textures/Asphalt1.tga branches/ogrenewt/newton20/demos/media/primitives/textures/cabrio_tex.tga branches/ogrenewt/newton20/demos/media/primitives/textures/ferrari_body_tex.tga branches/ogrenewt/newton20/demos/media/primitives/textures/ferrari_tire_tex.tga branches/ogrenewt/newton20/demos/media/primitives/textures/lav_tire.tga branches/ogrenewt/newton20/inc/OgreNewt_RayCastVehicle.h branches/ogrenewt/newton20/src/OgreNewt_RayCastVehicle.cpp Removed Paths: ------------- branches/ogrenewt/newton20/demos/media/primitives/castle.material branches/ogrenewt/newton20/demos/media/primitives/playground.material Modified: branches/ogrenewt/newton20/OgreNewt.sln =================================================================== --- branches/ogrenewt/newton20/OgreNewt.sln 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/OgreNewt.sln 2010-01-01 17:46:46 UTC (rev 2776) @@ -42,6 +42,11 @@ {C28C7710-76B1-4FFD-A85A-9AEFDA25EE64} = {C28C7710-76B1-4FFD-A85A-9AEFDA25EE64} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Demo05_SimpleVehicle", "demos\Demo05_SimpleVehicle\Demo05_SimpleVehicle.vcproj", "{0F61AA2F-57FC-409F-B697-E2300FF26473}" + ProjectSection(ProjectDependencies) = postProject + {C28C7710-76B1-4FFD-A85A-9AEFDA25EE64} = {C28C7710-76B1-4FFD-A85A-9AEFDA25EE64} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -104,6 +109,12 @@ {44F65D14-7093-4B8F-BE0F-95D5D31CFBBC}.Release|Win32.ActiveCfg = Release|Win32 {44F65D14-7093-4B8F-BE0F-95D5D31CFBBC}.Release|Win32.Build.0 = Release|Win32 {44F65D14-7093-4B8F-BE0F-95D5D31CFBBC}.Release|x64.ActiveCfg = Release|Win32 + {0F61AA2F-57FC-409F-B697-E2300FF26473}.Debug|Win32.ActiveCfg = Debug|Win32 + {0F61AA2F-57FC-409F-B697-E2300FF26473}.Debug|Win32.Build.0 = Debug|Win32 + {0F61AA2F-57FC-409F-B697-E2300FF26473}.Debug|x64.ActiveCfg = Debug|Win32 + {0F61AA2F-57FC-409F-B697-E2300FF26473}.Release|Win32.ActiveCfg = Release|Win32 + {0F61AA2F-57FC-409F-B697-E2300FF26473}.Release|Win32.Build.0 = Release|Win32 + {0F61AA2F-57FC-409F-B697-E2300FF26473}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: branches/ogrenewt/newton20/OgreNewt.suo =================================================================== (Binary files differ) Modified: branches/ogrenewt/newton20/OgreNewt.vcproj =================================================================== --- branches/ogrenewt/newton20/OgreNewt.vcproj 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/OgreNewt.vcproj 2010-01-01 17:46:46 UTC (rev 2776) @@ -289,6 +289,10 @@ > </File> <File + RelativePath=".\src\OgreNewt_RayCastVehicle.cpp" + > + </File> + <File RelativePath=".\src\OgreNewt_Stdafx.cpp" > <FileConfiguration @@ -397,6 +401,10 @@ > </File> <File + RelativePath=".\inc\OgreNewt_RayCastVehicle.h" + > + </File> + <File RelativePath=".\inc\OgreNewt_Stdafx.h" > </File> Modified: branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonApplication.cpp =================================================================== --- branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonApplication.cpp 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonApplication.cpp 2010-01-01 17:46:46 UTC (rev 2776) @@ -52,7 +52,7 @@ box1node->setScale( size ); // box1->setNormaliseNormals(true); - OgreNewt::ConvexCollisionPtr col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Box( m_World, size, 0 )); + OgreNewt::ConvexCollisionPtr col (new OgreNewt::CollisionPrimitives::Box( m_World, size, 0 )); OgreNewt::Body* bod = new OgreNewt::Body( m_World, col ); Modified: branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonFrameListener.cpp =================================================================== --- branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonFrameListener.cpp 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/demos/Demo02_Joints/OgreNewtonFrameListener.cpp 2010-01-01 17:46:46 UTC (rev 2776) @@ -97,7 +97,8 @@ ent->setMaterialName( "Simple/dirt01" ); // ent->setNormaliseNormals(true); - OgreNewt::ConvexCollisionPtr col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Ellipsoid( m_World, Ogre::Vector3(0.5f, 0.5f, 0.5f), 0 )); +// OgreNewt::ConvexCollisionPtr col = OgreNewt::ConvexCollisionPtr(new OgreNewt::CollisionPrimitives::Ellipsoid( m_World, Ogre::Vector3(0.5f, 0.5f, 0.5f), 0 )); + OgreNewt::ConvexCollisionPtr col (new OgreNewt::CollisionPrimitives::Ellipsoid( m_World, Ogre::Vector3(0.5f, 0.5f, 0.5f), 0 )); OgreNewt::Body* body = new OgreNewt::Body( m_World, col ); #ifdef OGRENEWT_NO_COLLISION_SHAREDPTR Modified: branches/ogrenewt/newton20/demos/Demo03_CollisionCallbacks/OgreNewtonApplication.cpp =================================================================== --- branches/ogrenewt/newton20/demos/Demo03_CollisionCallbacks/OgreNewtonApplication.cpp 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/demos/Demo03_CollisionCallbacks/OgreNewtonApplication.cpp 2010-01-01 17:46:46 UTC (rev 2776) @@ -1,132 +1,137 @@ -/* - OgreNewt library - connecting Ogre and Newton! - - Demo03_CollisionCallbacks - the material system in Newton is extremely powerful. by assigning - materials to bodies, you can define all kinds of specific behavior when objects collide. you can use - material callbacks to create hot spots, or make sound effects, or spawn particles, etc. this example - uses a conveyor belt as an example. look at the conveyorMatCallback to see how it's implemented. -*/ -#include "OgreNewtonApplication.h" -#include "OgreNewtonFrameListener.h" - -#include <OgreNewt.h> -#include <OgreNewt_BasicFrameListener.h> - - - -OgreNewtonApplication::OgreNewtonApplication(void) -{ - m_World = new OgreNewt::World(); - -} - -OgreNewtonApplication::~OgreNewtonApplication(void) -{ - std::vector<ConveyorBelt*>::iterator it; - for (it=mBelts.begin(); it!=mBelts.end(); it++) - { - ConveyorBelt* belt = (*it); - delete belt; - } - - delete m_World; -} - - - -void OgreNewtonApplication::createScene() -{ - - // sky box. - mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); - - // shadows on. - mSceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_MODULATIVE ); - - createMaterials(); - - // lets make a few conveyor belt objects. - ConveyorBelt* belt = new ConveyorBelt(); - Ogre::String name("ConveyorBelt1"); - Ogre::Vector3 size(15,0.3,3); - Ogre::Vector3 dir(1,0,0); - Ogre::Real speed(2.0); - Ogre::Vector3 pos(0,2,0); - Ogre::Quaternion orient(Ogre::Quaternion::IDENTITY); - belt->init( name, mSceneMgr, m_World, size, dir, speed, pos, orient, mMatConveyor, BT_CONVEYOR ); - mBelts.push_back( belt ); - - - belt = new ConveyorBelt(); - name = Ogre::String("ConveyorBelt2"); - size = Ogre::Vector3(23,0.3,4); - dir = Ogre::Vector3(-1,0,0); - speed = Ogre::Real(6.0); - pos = Ogre::Vector3(3,-1,0); - orient = Ogre::Quaternion(Ogre::Quaternion::IDENTITY); - belt->init( name, mSceneMgr, m_World, size, dir, speed, pos, orient, mMatConveyor, BT_CONVEYOR ); - mBelts.push_back( belt ); - - - // floor object! - Entity* floor; - SceneNode* floornode; -// floor = mSceneMgr->createEntity("Floor", "simple_terrain.mesh" ); - floor = mSceneMgr->createEntity("Floor", "playground.mesh" ); - floornode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "FloorNode" ); - floornode->attachObject( floor ); -// floor->setMaterialName( "Simple/BeachStones" ); - - floor->setCastShadows( false ); - - //Ogre::Vector3 siz(100.0, 10.0, 100.0); - OgreNewt::CollisionPtr col = OgreNewt::CollisionPtr(new OgreNewt::CollisionPrimitives::TreeCollision( m_World, floor, true, 0 )); - OgreNewt::Body* bod = new OgreNewt::Body( m_World, col ); - -#ifdef OGRENEWT_NO_COLLISION_SHAREDPTR - delete col; -#endif - - //floornode->setScale( siz ); - bod->attachNode( floornode ); - bod->setPositionOrientation( Ogre::Vector3(0.0,-10.0,0.0), Ogre::Quaternion::IDENTITY ); - - - // position camera - mCamera->setPosition(0.0, 2.0, 0.0); - - //make a light - Ogre::Light* light; - - light = mSceneMgr->createLight( "Light1" ); - light->setType( Ogre::Light::LT_POINT ); - light->setPosition( Ogre::Vector3(0.0, 100.0, 100.0) ); - - - -} - -void OgreNewtonApplication::createMaterials() -{ - mMatDefault = m_World->getDefaultMaterialID(); - mMatConveyor = new OgreNewt::MaterialID( m_World ); - - mMatPairDefaultConveyor = new OgreNewt::MaterialPair( m_World, mMatDefault, mMatConveyor ); - mConveyorCallback = new ConveyorMatCallback( BT_CONVEYOR ); - mMatPairDefaultConveyor->setContactCallback( mConveyorCallback ); - mMatPairDefaultConveyor->setDefaultSoftness( 0.8 ); - mMatPairDefaultConveyor->setDefaultElasticity( 0.05 ); - mMatPairDefaultConveyor->setDefaultFriction( 0.9, 0.8 ); - -} - - -void OgreNewtonApplication::createFrameListener() -{ - mNewtonListener = new OgreNewt::BasicFrameListener( mWindow, m_World, 100 ); - mRoot->addFrameListener(mNewtonListener); - - mFrameListener = new OgreNewtonFrameListener( mWindow, mCamera, mSceneMgr, m_World); - mRoot->addFrameListener(mFrameListener); -} - +/* + OgreNewt library - connecting Ogre and Newton! + + Demo03_CollisionCallbacks - the material system in Newton is extremely powerful. by assigning + materials to bodies, you can define all kinds of specific behavior when objects collide. you can use + material callbacks to create hot spots, or make sound effects, or spawn particles, etc. this example + uses a conveyor belt as an example. look at the conveyorMatCallback to see how it's implemented. +*/ +#include "OgreNewtonApplication.h" +#include "OgreNewtonFrameListener.h" + +#include <OgreNewt.h> +#include <OgreNewt_BasicFrameListener.h> + + + +OgreNewtonApplication::OgreNewtonApplication(void) +{ + m_World = new OgreNewt::World(); + +} + +OgreNewtonApplication::~OgreNewtonApplication(void) +{ + std::vector<ConveyorBelt*>::iterator it; + for (it=mBelts.begin(); it!=mBelts.end(); it++) + { + ConveyorBelt* belt = (*it); + delete belt; + } + + delete m_World; +} + + + +void OgreNewtonApplication::createScene() +{ + + // sky box. + mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); + + // shadows on. + mSceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_MODULATIVE ); + + createMaterials(); + + // lets make a few conveyor belt objects. + ConveyorBelt* belt = new ConveyorBelt(); + Ogre::String name("ConveyorBelt1"); + Ogre::Vector3 size(15,0.3,3); + Ogre::Vector3 dir(1,0,0); + Ogre::Real speed(2.0); + Ogre::Vector3 pos(0,2,0); + Ogre::Quaternion orient(Ogre::Quaternion::IDENTITY); + belt->init( name, mSceneMgr, m_World, size, dir, speed, pos, orient, mMatConveyor, BT_CONVEYOR ); + mBelts.push_back( belt ); + + + belt = new ConveyorBelt(); + name = Ogre::String("ConveyorBelt2"); + size = Ogre::Vector3(23,0.3,4); + dir = Ogre::Vector3(-1,0,0); + speed = Ogre::Real(6.0); + pos = Ogre::Vector3(3,-1,0); + orient = Ogre::Quaternion(Ogre::Quaternion::IDENTITY); + belt->init( name, mSceneMgr, m_World, size, dir, speed, pos, orient, mMatConveyor, BT_CONVEYOR ); + mBelts.push_back( belt ); + + + // floor object! + Entity* floor; + SceneNode* floornode; +// floor = mSceneMgr->createEntity("Floor", "simple_terrain.mesh" ); + floor = mSceneMgr->createEntity("Floor", "playground.mesh" ); + floornode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "FloorNode" ); + floornode->attachObject( floor ); +// floor->setMaterialName( "Simple/BeachStones" ); + + floor->setCastShadows( false ); + + //Ogre::Vector3 siz(100.0, 10.0, 100.0); + OgreNewt::CollisionPtr col = OgreNewt::CollisionPtr(new OgreNewt::CollisionPrimitives::TreeCollision( m_World, floor, true, 0 )); + OgreNewt::Body* bod = new OgreNewt::Body( m_World, col ); + +#ifdef OGRENEWT_NO_COLLISION_SHAREDPTR + delete col; +#endif + + //floornode->setScale( siz ); + bod->attachNode( floornode ); + bod->setPositionOrientation( Ogre::Vector3(0.0,-10.0,0.0), Ogre::Quaternion::IDENTITY ); + + + // position camera + mCamera->setPosition(0.0, 2.0, 0.0); + + // set the near and far clip plane + mCamera->setNearClipDistance(0.2f); + mCamera->setFarClipDistance(1000.0f); + + + //make a light + Ogre::Light* light; + + light = mSceneMgr->createLight( "Light1" ); + light->setType( Ogre::Light::LT_POINT ); + light->setPosition( Ogre::Vector3(0.0, 100.0, 100.0) ); + + + +} + +void OgreNewtonApplication::createMaterials() +{ + mMatDefault = m_World->getDefaultMaterialID(); + mMatConveyor = new OgreNewt::MaterialID( m_World ); + + mMatPairDefaultConveyor = new OgreNewt::MaterialPair( m_World, mMatDefault, mMatConveyor ); + mConveyorCallback = new ConveyorMatCallback( BT_CONVEYOR ); + mMatPairDefaultConveyor->setContactCallback( mConveyorCallback ); + mMatPairDefaultConveyor->setDefaultSoftness( 0.8 ); + mMatPairDefaultConveyor->setDefaultElasticity( 0.05 ); + mMatPairDefaultConveyor->setDefaultFriction( 0.9, 0.8 ); + +} + + +void OgreNewtonApplication::createFrameListener() +{ + mNewtonListener = new OgreNewt::BasicFrameListener( mWindow, m_World, 100 ); + mRoot->addFrameListener(mNewtonListener); + + mFrameListener = new OgreNewtonFrameListener( mWindow, mCamera, mSceneMgr, m_World); + mRoot->addFrameListener(mFrameListener); +} + Added: branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj =================================================================== --- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj (rev 0) +++ branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj 2010-01-01 17:46:46 UTC (rev 2776) @@ -0,0 +1,223 @@ +<?xml version="1.0" encoding="windows-1257"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="9.00" + Name="Demo05_SimpleVehicle" + ProjectGUID="{0F61AA2F-57FC-409F-B697-E2300FF26473}" + RootNamespace="Demo09_PlayerController" + Keyword="Win32Proj" + TargetFrameworkVersion="196613" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory="..\bin\$(ConfigurationName)" + IntermediateDirectory="..\obj\$(ConfigurationName)\$(ProjectName)" + ConfigurationType="1" + CharacterSet="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + AdditionalIncludeDirectories=""$(NEWTON_HOME)\sdk";"$(BOOST_HOME)\";"$(OGRE_HOME)\OgreMain\include";"$(OGRE_HOME)\include";"$(OGRE_HOME)\Samples\Common\CEGUIRenderer\include";"$(OGRE_HOME)\Samples\Common\include";"$(OGRE_HOME)\samples\include";"$(OGRE_HOME)\Dependencies\include";"$(OGRE_HOME)\Dependencies\include\ois";"$(OGRE_HOME)\Dependencies\include\CEGUI";"$(OGRE_HOME)\include\OIS";..\..\inc;." + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="newton.lib OgreMain_d.lib OIS_d.lib OgreGUIRenderer_d.lib CEGUIBase_d.lib OgreNewt_d.lib" + LinkIncremental="1" + AdditionalLibraryDirectories="..\..\lib;"$(OGRE_HOME)\lib";"$(OGRE_HOME)\Dependencies\lib\Debug";"$(NEWTON_HOME)\sdk\x32\dll_vs9"" + GenerateDebugInformation="true" + SubSystem="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory="..\bin\$(ConfigurationName)" + IntermediateDirectory="..\obj\$(ConfigurationName)\$(ProjectName)" + ConfigurationType="1" + CharacterSet="1" + WholeProgramOptimization="1" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + EnableIntrinsicFunctions="true" + AdditionalIncludeDirectories=""$(NEWTON_HOME)\sdk";"$(BOOST_HOME)\";"$(OGRE_HOME)\OgreMain\include";"$(OGRE_HOME)\include";"$(OGRE_HOME)\Samples\Common\CEGUIRenderer\include";"$(OGRE_HOME)\Samples\Common\include";"$(OGRE_HOME)\samples\include";"$(OGRE_HOME)\Dependencies\include";"$(OGRE_HOME)\Dependencies\include\ois";"$(OGRE_HOME)\Dependencies\include\CEGUI";"$(OGRE_HOME)\include\OIS";..\..\inc;." + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS" + RuntimeLibrary="2" + EnableFunctionLevelLinking="true" + UsePrecompiledHeader="0" + WarningLevel="3" + DebugInformationFormat="3" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="newton.lib OgreMain.lib OIS.lib OgreGUIRenderer.lib CEGUIBase.lib OgreNewt.lib" + LinkIncremental="1" + AdditionalLibraryDirectories="..\..\lib;"$(OGRE_HOME)\lib";"$(OGRE_HOME)\Dependencies\lib\Release";"$(NEWTON_HOME)\sdk\x32\dll_vs9"" + GenerateDebugInformation="true" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + <File + RelativePath=".\demo05.cpp" + > + </File> + <File + RelativePath=".\OgreNewtonApplication.cpp" + > + </File> + <File + RelativePath=".\OgreNewtonFrameListener.cpp" + > + </File> + <File + RelativePath=".\SimpleVehicle.cpp" + > + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl;inc;xsd" + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + <File + RelativePath=".\OgreNewtonApplication.h" + > + </File> + <File + RelativePath=".\OgreNewtonFrameListener.h" + > + </File> + <File + RelativePath=".\SimpleVehicle.h" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> Added: branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj.Julio-PC.Julio.user =================================================================== --- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj.Julio-PC.Julio.user (rev 0) +++ branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Demo05_SimpleVehicle.vcproj.Julio-PC.Julio.user 2010-01-01 17:46:46 UTC (rev 2776) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="windows-1257"?> +<VisualStudioUserFile + ProjectType="Visual C++" + Version="9.00" + ShowAllFiles="false" + > + <Configurations> + <Configuration + Name="Debug|Win32" + > + <DebugSettings + Command="$(TargetPath)" + WorkingDirectory="$(TargetDir)" + CommandArguments="" + Attach="false" + DebuggerType="3" + Remote="1" + RemoteMachine="JULIO-PC" + RemoteCommand="" + HttpUrl="" + PDBPath="" + SQLDebugging="" + Environment="" + EnvironmentMerge="true" + DebuggerFlavor="0" + MPIRunCommand="" + MPIRunArguments="" + MPIRunWorkingDirectory="" + ApplicationCommand="" + ApplicationArguments="" + ShimCommand="" + MPIAcceptMode="" + MPIAcceptFilter="" + /> + </Configuration> + <Configuration + Name="Release|Win32" + > + <DebugSettings + Command="$(TargetPath)" + WorkingDirectory="$(TargetDir)" + CommandArguments="" + Attach="false" + DebuggerType="3" + Remote="1" + RemoteMachine="JULIO-PC" + RemoteCommand="" + HttpUrl="" + PDBPath="" + SQLDebugging="" + Environment="" + EnvironmentMerge="true" + DebuggerFlavor="0" + MPIRunCommand="" + MPIRunArguments="" + MPIRunWorkingDirectory="" + ApplicationCommand="" + ApplicationArguments="" + ShimCommand="" + MPIAcceptMode="" + MPIAcceptFilter="" + /> + </Configuration> + </Configurations> +</VisualStudioUserFile> Added: branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Ogre.log =================================================================== --- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Ogre.log (rev 0) +++ branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/Ogre.log 2010-01-01 17:46:46 UTC (rev 2776) @@ -0,0 +1,31 @@ +12:29:39: Creating resource group General +12:29:39: Creating resource group Internal +12:29:39: Creating resource group Autodetect +12:29:39: SceneManagerFactory for type 'DefaultSceneManager' registered. +12:29:39: Registering ResourceManager for type Material +12:29:39: Registering ResourceManager for type Mesh +12:29:39: Registering ResourceManager for type Skeleton +12:29:39: MovableObjectFactory for type 'ParticleSystem' registered. +12:29:39: OverlayElementFactory for type Panel registered. +12:29:39: OverlayElementFactory for type BorderPanel registered. +12:29:39: OverlayElementFactory for type TextArea registered. +12:29:39: Registering ResourceManager for type Font +12:29:39: ArchiveFactory for archive type FileSystem registered. +12:29:39: ArchiveFactory for archive type Zip registered. +12:29:39: FreeImage version: 3.10.0 +12:29:39: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details +12:29:39: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi,exr,j2k,j2c,jp2 +12:29:39: DDS codec registering +12:29:39: Registering ResourceManager for type HighLevelGpuProgram +12:29:39: Registering ResourceManager for type Compositor +12:29:39: MovableObjectFactory for type 'Entity' registered. +12:29:39: MovableObjectFactory for type 'Light' registered. +12:29:39: MovableObjectFactory for type 'BillboardSet' registered. +12:29:39: MovableObjectFactory for type 'ManualObject' registered. +12:29:39: MovableObjectFactory for type 'BillboardChain' registered. +12:29:39: MovableObjectFactory for type 'RibbonTrail' registered. +12:29:39: OGRE EXCEPTION(6:FileNotFoundException): 'plugins.cfg' file not found! in ConfigFile::load at c:\ogre\ogremain\src\ogreconfigfile.cpp (line 84) +12:29:39: plugins.cfg not found, automatic plugin loading disabled. +12:29:39: *-*-* OGRE Initialising +12:29:39: *-*-* Version 1.6.4 (Shoggoth) +12:29:39: OGRE EXCEPTION(6:FileNotFoundException): 'resources.cfg' file not found! in ConfigFile::load at c:\ogre\ogremain\src\ogreconfigfile.cpp (line 84) Modified: branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonApplication.cpp =================================================================== --- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonApplication.cpp 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonApplication.cpp 2010-01-01 17:46:46 UTC (rev 2776) @@ -1,91 +1,192 @@ -/* - OgreNewt library - connecting Ogre and Newton! - - Demo05_SimpleVehicle - how to use the vehicle classes to make a simple vehicle in OgreNewt. -*/ - -#include "OgreNewtonApplication.h" -#include "OgreNewtonFrameListener.h" - -#include <OgreNewt.h> -#include <OgreNewt_BasicFrameListener.h> - - -OgreNewtonApplication::OgreNewtonApplication(void) -{ - // create OgreNewt world. - m_World = new OgreNewt::World(); - -} - -OgreNewtonApplication::~OgreNewtonApplication(void) -{ - // destroy world. - delete m_World; -} - - - -void OgreNewtonApplication::createScene() -{ - // sky box. - mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); - - // shadows on! - mSceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_ADDITIVE ); - - - // floor object! this time we'll scale it slightly to make it more vehicle-friendly :P - Ogre::Vector3 size(2.0,0.5,2.0); - Entity* floor; - SceneNode* floornode; - floor = mSceneMgr->createEntity("Floor", "simple_terrain.mesh" ); - floornode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "FloorNode" ); - floornode->attachObject( floor ); - floor->setMaterialName( "Simple/BeachStones" ); - floornode->setScale(size); - - floor->setCastShadows( false ); - - //Ogre::Vector3 siz(100.0, 10.0, 100.0); - OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::TreeCollision( m_World, floornode, false, 0 ); - OgreNewt::Body* bod = new OgreNewt::Body( m_World, col ); - delete col; - - bod->attachNode( floornode ); - bod->setPositionOrientation( Ogre::Vector3(0.0,-2.0,0.0), Ogre::Quaternion::IDENTITY ); - - - - // here's where we make the simple vehicle. everything is taken care of in the constuctor. - mCar = new SimpleVehicle( mSceneMgr, m_World, Ogre::Vector3(0,-0.5,0), Ogre::Quaternion(Ogre::Quaternion::IDENTITY) ); - - - - // position camera - msnCam = mSceneMgr->getRootSceneNode()->createChildSceneNode(); - msnCam->attachObject( mCamera ); - mCamera->setPosition(0.0, 0.0, 0.0); - msnCam->setPosition( 0.0, 1.0, 20.0); - - //make a light - Ogre::Light* light; - - light = mSceneMgr->createLight( "Light1" ); - light->setType( Ogre::Light::LT_POINT ); - light->setPosition( Ogre::Vector3(0.0, 100.0, 100.0) ); - - - -} - - -void OgreNewtonApplication::createFrameListener() -{ - mFrameListener = new OgreNewtonFrameListener( mWindow, mCamera, mSceneMgr, m_World, msnCam, mCar ); - mRoot->addFrameListener(mFrameListener); - - mNewtonListener = new OgreNewt::BasicFrameListener( mWindow, m_World, 60 ); - mRoot->addFrameListener(mNewtonListener); -} - +/* + OgreNewt library - connecting Ogre and Newton! + + Demo05_SimpleVehicle - how to use the vehicle classes to make a simple vehicle in OgreNewt. +*/ + +#include "OgreNewtonApplication.h" +#include "OgreNewtonFrameListener.h" + +#include <OgreNewt.h> +#include <OgreNewt_BasicFrameListener.h> + + +OgreNewtonApplication::OgreNewtonApplication(void) +{ + // create OgreNewt world. + m_World = new OgreNewt::World(); + +} + +OgreNewtonApplication::~OgreNewtonApplication(void) +{ + // destroy world. + delete m_World; +} + + +static SimpleVehicle::CAR_CONFIG raceCar = +{ + "f1Body.mesh", + + // FL_TIRE + {"f1Tire.mesh", {-0.743107f, -0.023629f, -1.279540f}, {0.70710552f, 0.0f, 0.70710552f, 0.0f}}, + + // FR_TIRE + {"f1Tire.mesh", { 0.741849f, -0.023629f, -1.279540,}, {0.70710552f, 0.0f, -0.70710552f, 0.0f}}, + + // RR_tire + {"f1Tire.mesh", { 0.725642f, -0.023618f, 1.717240f}, {0.70710552f, 0.0f, -0.70710552f, 0.0f}}, + + // RL_tire + {"f1Tire.mesh", {-0.725644f, -0.023618f, 1.717240f}, {0.70710552f, 0.0f, 0.70710552f, 0.0f}}, +}; + + + +static SimpleVehicle::CAR_CONFIG Jeep = +{ + "jeepBody.mesh", + + // FL_TIRE + {"jeepTire.mesh", {-0.625456f, -0.296697f, -1.235474f}, {0.70710552f, 0.0f, 0.70710552f, 0.0f}}, + + // FR_TIRE + {"jeepTire.mesh", { 0.625456f, -0.296697f, -1.235474f}, {0.70710552f, 0.0f, 0.70710552f, 0.0f}}, + + // RR_tire + {"jeepTire.mesh", { 0.625456f, -0.296697f, 0.818093f}, {0.70710552f, 0.0f, 0.70710552f, 0.0f}}, + + // RL_tire + {"jeepTire.mesh", {-0.625456f, -0.296697f, 0.818093f}, {0.70710552f, 0.0f, 0.70710552f, 0.0f}}, +}; + +class CarPlacementRaycast: public OgreNewt::BasicRaycast +{ + public: + CarPlacementRaycast(OgreNewt::Body* car, Ogre::Vector3& location) + :OgreNewt::BasicRaycast () + { + // ignore go as if will no do the user filter correctly + Ogre::Vector3 start (location); + Ogre::Vector3 end (location); + + start.y += 100.0f; + end.y -= 100.0f; + + // re-cast the ray this time filtering the car body + m_myBody = car; + go (car->getWorld(), start, end, true); + + OgreNewt::BasicRaycast::BasicRaycastInfo info = getFirstHit(); + m_elevation = 0.5f + start.y + (end.y - start.y) * info.mDistance; + } + + // skip the car body + virtual bool userPreFilterCallback( OgreNewt::Body* body ) + { + // ray form casting hi own body + return (body != m_myBody); + } + + Ogre::Real m_elevation; + OgreNewt::Body* m_myBody; + +}; + + +void OgreNewtonApplication::createScene() +{ + // sky box. + mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox"); + + // shadows on! + mSceneMgr->setShadowTechnique( Ogre::SHADOWTYPE_STENCIL_ADDITIVE ); + + + // floor object! this time we'll scale it slightly to make it more vehicle-friendly :P + Ogre::Vector3 size(2.0,0.5,2.0); + Entity* floor; + SceneNode* floornode; + const char *levelName = "track.mesh"; +// const char *levelName = "simple_terrain.mesh"; + + floor = mSceneMgr->createEntity("Floor", levelName ); + floornode = mSceneMgr->getRootSceneNode()->createChildSceneNode( "FloorNode" ); + floornode->attachObject( floor ); +// floor->setMaterialName( "Simple/BeachStones" ); + floornode->setScale(size); + floor->setCastShadows( false ); + + char serializeCollisionName[256]; + strcpy (serializeCollisionName, levelName); + strtok (serializeCollisionName, "."); + strcat (serializeCollisionName, ".col"); + + FILE* file = fopen (serializeCollisionName, "rb"); + if (!file) { + // serialize the mesh so that next time loads faster + OgreNewt::CollisionSerializer saveLevelCollision; + OgreNewt::CollisionPtr tmpSphape = OgreNewt::CollisionPtr(new OgreNewt::CollisionPrimitives::TreeCollision( m_World, floor, true, 0 )); + saveLevelCollision.exportCollision(tmpSphape, serializeCollisionName); + file = fopen (serializeCollisionName, "rb"); + } + + // load level collision from serialized file + FileHandleDataStream streamFile (file); + OgreNewt::CollisionSerializer loadLevelCollision; + OgreNewt::CollisionPtr col = loadLevelCollision.importCollision(streamFile, m_World); + fclose (file); + OgreNewt::Body* bod = new OgreNewt::Body( m_World, OgreNewt::CollisionPtr(col)); + bod->attachNode( floornode ); +// bod->setPositionOrientation( Ogre::Vector3(0.0,-2.0,0.0), Ogre::Quaternion::IDENTITY ); + + + + // here's where we make the simple vehicle. everything is taken care of in the constructor. + mCar = SimpleVehicle::create (&raceCar, mSceneMgr, m_World); +// mCar = SimpleVehicle::create (&Jeep, mSceneMgr, m_World); + + // position the car above the ground; + Ogre::Vector3 location (0.0f, 0.0f, 0.0); + CarPlacementRaycast castRay (mCar->getBody0(), location); + location.y = castRay.m_elevation + 0.5f; + mCar->getBody0()->setPositionOrientation (location, Ogre::Quaternion(Ogre::Quaternion::IDENTITY)); + + + // position camera +// msnCam = mSceneMgr->getRootSceneNode()->createChildSceneNode(); +// msnCam->attachObject( mCamera ); + + location.y += 0.0f; + location.z += 10.0f; + mCamera->setPosition(location); +// msnCam->setPosition( 0.0, 1.0, 20.0); + + // set the near and far clip plane + mCamera->setNearClipDistance(0.2f); + mCamera->setFarClipDistance(1000.0f); + + + //make a light + Ogre::Light* light; + + light = mSceneMgr->createLight( "Light1" ); + light->setType( Ogre::Light::LT_POINT ); + light->setPosition( Ogre::Vector3(0.0, 100.0, 100.0) ); + + + +} + + +void OgreNewtonApplication::createFrameListener() +{ +// mFrameListener = new OgreNewtonFrameListener( mWindow, mCamera, mSceneMgr, m_World, msnCam, mCar ); + mFrameListener = new OgreNewtonFrameListener( mWindow, mCamera, mSceneMgr, m_World); + mRoot->addFrameListener(mFrameListener); + + mNewtonListener = new OgreNewt::BasicFrameListener( mWindow, m_World, 100 ); + mRoot->addFrameListener(mNewtonListener); +} + Modified: branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.cpp =================================================================== --- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.cpp 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.cpp 2010-01-01 17:46:46 UTC (rev 2776) @@ -1,157 +1,160 @@ -#include "OgreNewtonFrameListener.h" - - -OgreNewtonFrameListener::OgreNewtonFrameListener(RenderWindow* win, Camera* cam, SceneManager* mgr, OgreNewt::World* W, SimpleVehicle* car) : - ExampleFrameListener(win,cam) -{ - m_World = W; - mSceneMgr = mgr; - - mCar = car; - - timer = 0.0f; - OgreNewt::Debugger &debug(m_World->getDebugger()); - debug.init(mgr); -} - -OgreNewtonFrameListener::~OgreNewtonFrameListener(void) -{ -} - -bool OgreNewtonFrameListener::frameStarted(const FrameEvent &evt) -{ - Vector3 trans, strafe, vec; - Quaternion quat; - - quat = mCamera->getOrientation(); - - vec = Vector3(0.0,0.0,-0.5); - trans = quat * vec; - - vec = Vector3(0.5,0.0,0.0); - strafe = quat * vec; - - mKeyboard->capture(); - mMouse->capture(); - - mCamera->pitch( Degree(mMouse->getMouseState().Y.rel * -0.5) ); - mCamera->setFixedYawAxis(true); - mCamera->yaw( Degree(mMouse->getMouseState().X.rel * -0.5) ); - - if (mKeyboard->isKeyDown(OIS::KC_UP)) - mCamera->moveRelative(trans); - - if (mKeyboard->isKeyDown(OIS::KC_DOWN)) - mCamera->moveRelative(trans * -1.0); - - if (mKeyboard->isKeyDown(OIS::KC_LEFT)) - mCamera->moveRelative(strafe * -1.0); - - if (mKeyboard->isKeyDown(OIS::KC_RIGHT)) - mCamera->moveRelative(strafe); - - - if (mKeyboard->isKeyDown(OIS::KC_SPACE)) - { - if (timer <= 0.0) - { - Ogre::Vector3 dir, vec; - Ogre::Quaternion camorient = mCamera->getDerivedOrientation(); - vec = Ogre::Vector3(0,0,-1); - - dir = camorient * vec; - - Entity* ent; - SceneNode* node; - Ogre::String name; - Ogre::Vector3 pos = mCamera->getDerivedPosition(); - - name = "Body "+Ogre::StringConverter::toString( count++ ); - - ent = mSceneMgr->createEntity( name, "ellipsoid.mesh" ); - node = mSceneMgr->getRootSceneNode()->createChildSceneNode( name ); - node->attachObject( ent ); - - ent->setMaterialName( "Simple/dirt01" ); - - OgreNewt::Collision* col = new OgreNewt::CollisionPrimitives::Ellipsoid( m_World, Ogre::Vector3(1,1,1), 0 ); - OgreNewt::Body* body = new OgreNewt::Body( m_World, col ); - - Ogre::Vector3 inertia = OgreNewt::MomentOfInertia::CalcSphereSolid( 10.0, 1.0 ); - body->setMassMatrix( 10.0, inertia ); - body->attachToNode( node ); - body->setStandardForceCallback(); - body->setPositionOrientation( pos, camorient ); - body->setVelocity( (dir * 50.0) ); - - timer = 0.2; - } - } - - timer -= evt.timeSinceLastFrame; - - // --------------------------------------------------------- - // -- VEHICLE CONTORLS - // --------------------------------------------------------- - Ogre::Real torque = 0.0; - Ogre::Degree steering(0.0); - - if (mKeyboard->isKeyDown(OIS::KC_W)) - torque += 600.0; - - if (mKeyboard->isKeyDown(OIS::KC_S)) - torque -= 600.0; - - if (mKeyboard->isKeyDown(OIS::KC_A)) - steering += Ogre::Degree(30); - - if (mKeyboard->isKeyDown(OIS::KC_D)) - steering -= Ogre::Degree(30); - - //update the vehicle! - mCar->setTorqueSteering( torque, steering ); - - if ((mKeyboard->isKeyDown(OIS::KC_R)) && (!mR)) - { - mR = true; - // rebuild the vehicle - if (mCar) - { - delete mCar; - mCar = new SimpleVehicle( mSceneMgr, m_World, Ogre::Vector3(0,Ogre::Math::UnitRandom() * 10.0,0), Ogre::Quaternion(Ogre::Quaternion::IDENTITY) ); - } - } - if (!mKeyboard->isKeyDown( OIS::KC_R )) { mR = false; } - - - OgreNewt::Debugger& debug(m_World->getDebugger()); - if (mKeyboard->isKeyDown(OIS::KC_F3)) - { - debug.showDebugInformation(); - debug.startRaycastRecording(); - debug.clearRaycastsRecorded(); - } - else - { - debug.hideDebugInformation(); - debug.clearRaycastsRecorded(); - debug.stopRaycastRecording(); - } - - - - if (mKeyboard->isKeyDown(OIS::KC_T)) - m_World->setThreadCount( m_World->getThreadCount() % 2 + 1); - - - if (mKeyboard->isKeyDown(OIS::KC_ESCAPE)) - { - if (mCar) - delete mCar; - - return false; - } - - return true; -} - +#include "OgreNewtonFrameListener.h" + + +//OgreNewtonFrameListener::OgreNewtonFrameListener(RenderWindow* win, Camera* cam, SceneManager* mgr, OgreNewt::World* W, SimpleVehicle* car) : +OgreNewtonFrameListener::OgreNewtonFrameListener(RenderWindow* win, Camera* cam, SceneManager* mgr, OgreNewt::World* W) : + ExampleFrameListener(win,cam) +{ + m_World = W; + mSceneMgr = mgr; + +// mCar = car; + + timer = 0.0f; + OgreNewt::Debugger &debug(m_World->getDebugger()); + debug.init(mgr); +} + +OgreNewtonFrameListener::~OgreNewtonFrameListener(void) +{ +} + +bool OgreNewtonFrameListener::frameStarted(const FrameEvent &evt) +{ + Vector3 trans, strafe, vec; + Quaternion quat; + + quat = mCamera->getOrientation(); + + vec = Vector3(0.0,0.0,-0.5); + trans = quat * vec; + + vec = Vector3(0.5,0.0,0.0); + strafe = quat * vec; + + mKeyboard->capture(); + mMouse->capture(); + + mCamera->pitch( Degree(mMouse->getMouseState().Y.rel * -0.5) ); + mCamera->setFixedYawAxis(true); + mCamera->yaw( Degree(mMouse->getMouseState().X.rel * -0.5) ); + + if (mKeyboard->isKeyDown(OIS::KC_UP)) + mCamera->moveRelative(trans); + + if (mKeyboard->isKeyDown(OIS::KC_DOWN)) + mCamera->moveRelative(trans * -1.0); + + if (mKeyboard->isKeyDown(OIS::KC_LEFT)) + mCamera->moveRelative(strafe * -1.0); + + if (mKeyboard->isKeyDown(OIS::KC_RIGHT)) + mCamera->moveRelative(strafe); + + + if (mKeyboard->isKeyDown(OIS::KC_SPACE)) + { + if (timer <= 0.0) + { + Ogre::Vector3 dir, vec; + Ogre::Quaternion camorient = mCamera->getDerivedOrientation(); + vec = Ogre::Vector3(0,0,-1); + + dir = camorient * vec; + + Entity* ent; + SceneNode* node; + Ogre::String name; + Ogre::Vector3 pos = mCamera->getDerivedPosition(); + + name = "Body "+Ogre::StringConverter::toString( count++ ); + + ent = mSceneMgr->createEntity( name, "ellipsoid.mesh" ); + node = mSceneMgr->getRootSceneNode()->createChildSceneNode( name ); + node->attachObject( ent ); + + ent->setMaterialName( "Simple/dirt01" ); + +// OgreNewt::CollisionPtr col = new OgreNewt::CollisionPrimitives::Ellipsoid( m_World, Ogre::Vector3(1,1,1), 0 ); + OgreNewt::ConvexCollisionPtr col (new OgreNewt::CollisionPrimitives::Ellipsoid( m_World, Ogre::Vector3(0.5f, 0.5f, 0.5f), 0 )); + OgreNewt::Body* body = new OgreNewt::Body( m_World, col ); + + Ogre::Vector3 inertia, offset; + col->calculateInertialMatrix(inertia, offset); + body->setMassMatrix (1.0, 1.0*inertia ); + body->setCenterOfMass(offset); + body->attachNode( node ); + body->setStandardForceCallback(); + body->setPositionOrientation( pos, camorient ); + body->setVelocity( (dir * 50.0) ); + + timer = 0.2; + } + } + + timer -= evt.timeSinceLastFrame; + + // --------------------------------------------------------- + // -- VEHICLE CONTORLS + // --------------------------------------------------------- + Ogre::Real torque = 0.0; + Ogre::Degree steering(0.0); + + if (mKeyboard->isKeyDown(OIS::KC_W)) + torque += 600.0; + + if (mKeyboard->isKeyDown(OIS::KC_S)) + torque -= 600.0; + + if (mKeyboard->isKeyDown(OIS::KC_A)) + steering += Ogre::Degree(30); + + if (mKeyboard->isKeyDown(OIS::KC_D)) + steering -= Ogre::Degree(30); + + //update the vehicle! +// mCar->setTorqueSteering( torque, steering ); + + if ((mKeyboard->isKeyDown(OIS::KC_R)) && (!mR)) + { +// mR = true; +// // rebuild the vehicle +// if (mCar) +// { +// delete mCar; +// mCar = new SimpleVehicle( mSceneMgr, m_World, Ogre::Vector3(0,Ogre::Math::UnitRandom() * 10.0,0), Ogre::Quaternion(Ogre::Quaternion::IDENTITY) ); +// } + } + if (!mKeyboard->isKeyDown( OIS::KC_R )) { mR = false; } + + + OgreNewt::Debugger& debug(m_World->getDebugger()); + if (mKeyboard->isKeyDown(OIS::KC_F3)) + { + debug.showDebugInformation(); + debug.startRaycastRecording(); + debug.clearRaycastsRecorded(); + } + else + { + debug.hideDebugInformation(); + debug.clearRaycastsRecorded(); + debug.stopRaycastRecording(); + } + + + + if (mKeyboard->isKeyDown(OIS::KC_T)) + m_World->setThreadCount( m_World->getThreadCount() % 2 + 1); + + + if (mKeyboard->isKeyDown(OIS::KC_ESCAPE)) + { +// if (mCar) +// delete mCar; + return false; + } + + return true; +} + Modified: branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.h =================================================================== --- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.h 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/OgreNewtonFrameListener.h 2010-01-01 17:46:46 UTC (rev 2776) @@ -15,10 +15,11 @@ float timer; bool mR; - SimpleVehicle* mCar; +// SimpleVehicle* mCar; public: - OgreNewtonFrameListener(RenderWindow* win, Camera* cam, SceneManager* mgr, OgreNewt::World* W, SimpleVehicle* car); +// OgreNewtonFrameListener(RenderWindow* win, Camera* cam, SceneManager* mgr, OgreNewt::World* W, SimpleVehicle* car); + OgreNewtonFrameListener(RenderWindow* win, Camera* cam, SceneManager* mgr, OgreNewt::World* W); ~OgreNewtonFrameListener(void); bool frameStarted(const FrameEvent &evt); Modified: branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/SimpleVehicle.cpp =================================================================== --- branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/SimpleVehicle.cpp 2009-12-30 15:20:22 UTC (rev 2775) +++ branches/ogrenewt/newton20/demos/Demo05_SimpleVehicle/SimpleVehicle.cpp 2010-01-01 17:46:46 UTC (rev 2776) @@ -1,186 +1,290 @@ -#include "SimpleVehicle.h" - -int SimpleVehicle::mEntityCount = 5; - -// SimpleVehicle constructor. this creates and sets up the entire vehicle! -SimpleVehicle::SimpleVehicle(Ogre::SceneManager* mgr, OgreNewt::World* world, Ogre::Vector3& position, Ogre::Quaternion& orient) : OgreNewt::Vehicle() -{ - // save the scene manager - mSceneMgr = mgr; - mWorld = world; - - - // first thing we need to do is create the rigid body for the main chassis. - Ogre::Vector3 size(5,1.2,2); - OgreNewt::Body* bod = makeSimpleBox(size, position, orient); - - //now that we have defined the chassis, we can call the "init()" function. this is a helper function that - // simply sets up some internal wiring of the vehicle class that makes eveything work :) it also calls the virtual - // function "setup" to finish building the vehicle. - // you pass this function the body to be used as the main chassis, and the up direction of the world (for suspension purposes). - init( bod, Ogre::Vector3(0,1,0) ); - - // the above function calls our "setup" function, which takes care of the rest of the vehicle setup. - -} - - -// virtual function - setup(). this actually builds the tires, etc. -void SimpleVehicle::setup() -{ - // okay, we have the main chassis all setup. let's do a few things to it: - m_chassis->setStandardForceCallback(); - // we don't want the vehicle to freeze, because we'll be unable to control it. - m_chassis->setAutoFreeze(0); - - - // okay, let's add tires! - // all offsets here are in local space of the vehicle. - Ogre::Vector3 offset(1.8,-1.6,0.87); - - int tireNum = 0; - for (int x=-1;x<=1;x+=2) - { - for (int z=-1;z<=1;z+=2) - { - - // okay, let's create the tire itself. we'll use the OgreNewt::Vehicle::Tire class for this. most of the - // parameters are self-explanatory... try changing some of them to see what happens. - Ogre::Quaternion tireorient = Ogre::Quaternion(Ogre::Degree(0), Ogre::Vector3::UNIT_Y); - Ogre::Vector3 tirepos = offset * Ogre::Vector3(x,0.5f,z); - Ogre::Vector3 pin(0,0,x); - Ogre::Real mass = 15.0; - Ogre::Real width = 0.3; - Ogre::Real radius = 0.5; - Ogre::Real susShock = 30.0; - Ogre::Real susSpring = 200.0; - Ogre::Real susLength = 1.2; - bool steering; - - - // first, load the visual mesh that represents the tire. - Ogre::Entity* ent = mSceneMgr->createEntity("Tire"+Ogre::StringConverter::toString(mEntityCount++), "wheel.mesh"); - // make a scene node for the tire. - Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(); - node->attachObject( ent ); - node->setScale( Ogre::Vector3(radius, radius, width) ); - - if (x > 0) - steering = true; - else - steering = false; - - // create the actual tire! - SimpleTire* tire = new SimpleTire(this, tireorient, tirepos, pin, mass, width, radius, - susShock, susSpring, susLength, 0, steering); - - // attach the tire to the node. - tire->attachToNode( node ); - - } - } - -} - - -SimpleVehicle::SimpleTire::~SimpleTire() -{ - // destroy entity, and scene node. - Ogre::Entity* ent = (Ogre::Entity*)m_node->getAttachedObject(static_cast<unsigned short>(0)); - m_node->detachAllObjects(); - m_node->getCreator()->destroyEntity( ent ); - m_node->getParentSceneNode()->removeAndDestroyChild( m_node->getName() ); -} - -SimpleVehicle::~SimpleVehicle(void) -{ - std::vector< SimpleTire* > toDelete; - - // delete tire objects. - for (SimpleTire* tire = (SimpleTire*)getFirstTire(); tire; tire=(SimpleTire*)getNextTire(tire)) - { - toDelete.push_back( tire ); - } - - while (!toDelete.empty()) - { - SimpleTire* tire = toDelete.back(); - delete tire; - toDelete.pop_back(); - } - - // finally, destroy entity and node from chassis. - Ogre::Entity* ent = (Ogre::Entity*)((Ogre::SceneNode*)m_chassis->getOgreNode())->getAttachedObject(static_cast<unsigned short>(0)); - ((Ogre::SceneNode*)m_chassis->getOgreNode())->detachAllObjects(); - ((Ogre::SceneNode*)m_chassis->getOgreNode())->getCreator()->destroyEntity( ent ); - ((Ogre::SceneNode*)m_chassis->getOgreNode())->getParentSceneNode()->removeAndDestroyChild( m_chassis->getOgreNode()->getName() ); - - destroy(); -} - - - -// This is the important callback, which is the meat of controlling the vehicle. -void SimpleVehicle::userCallback() -{ - - // foop through wheels, adding torque and steering, and updating their positions. - for (SimpleTire* tire = (SimpleTire*)getFirstTire(); tire; tire=(SimpleTire*)getNextTire(tire)) - { - // set the torque and steering! non-steering tires get the torque. - - // is this a steering tire? - if (tire->mSteeringTire) - tire->setSteeringAngle( mSteering ); - else - tire->setTorque( mTorque ); - - // finally, this command updates the location of the visual mesh. - tire->updateNode(); - } - -} - - - - - - - -OgreNewt::Body* SimpleVehicle::makeSimpleBox( Ogre::Vector3& size, Ogre::Vector3& pos, Ogre::Quaternion& orient ) -{ - Ogre::Entity* box1; - Ogre::SceneNode* box1node; - - box1 = mSceneMgr->createEntity( "Entity"+Ogre::StringConverter::toString(mEntityCount++), "box.mesh" ); - box1node = mSceneMgr->getRootSceneNode()->createChildSceneNode(); - box1node->attachObject( box1 ); - box1node->setScale( size ); - - OgreNewt::ConvexCollision* col = new OgreNewt::CollisionPrimitives::Box( mWorld, size ); - OgreNewt::Body* bod = new OgreNewt::Body( mWorld, col ); - - - // base mass on the size of the object. - Ogre::Real mass = size.x * size.y * size.z * 100.0; - // calculate the inertia based on box formula and mass - Ogre::Vector3 inertia, offset; - col->calculateInertialMatrix(inertia, offset); - - delete col; - - - bod->attachNode( box1node ); - bod->setMassMatrix( mass, mass*inertia ); - bod->setCenterOfMass(offset); - bod->setStandardForceCallback(); - - box1->setMaterialName( "Simple/BumpyMetal" ); - box1->setNormaliseNormals(true); - - - bod->setPositionOrientation( pos, orient ); - - return bod; -} - +#include "SimpleVehicle.h" + + + + + +int SimpleVehicle::mEntityCount = 0; + +SimpleVehicle* SimpleVehicle::create (CAR_CONFIG* config, Ogre::SceneManager* mgr, OgreNewt::World* world) +{ + SimpleVehicle* car; + Ogre::Entity* carEnt; + OgreNewt::Body* carBody; + Ogre::SceneNode* parentNode; + + // create the main car body + carEnt = mgr->createEntity( "CarEntity" + Ogre::StringConverter::toString(mEntityCount++), config->m_name); + parentNode = mgr->getRootSceneNode()->createChildSceneNode(); + parentNode->attachObject (carEnt); + + + OgreNewt::ConvexCollisionPtr col (new OgreNewt::CollisionPrimitives::ConvexHull (world, carEnt, 0)); + carBody = new OgreNewt::Body (world, col); + + // base mass on the size of the object. + Ogre::Real mass = 100.0f; + // calculate the inertia based on box formula and mass + Ogre::Vector3 inertia, offset; + col->calculateInertialMatrix(inertia, offset); + + carBody->attachNode (parentNode); + carBody->setMassMatrix (mass, mass*inertia); + carBody->setCenterOfMass (offset); + carBody->setStandardForceCallback(); + + // create the car joint; + car = new SimpleVehicle (carBody, 4); + + + // create and attach all tires + CAR_CONFIG::TIRE* tireGeo = &config->front_right; + for (int i = 0; i < 4; i ++) { + Ogre::Entity* tireEnt; + Ogre::SceneNode* tireNode; + tireEnt = mgr->createEntity( "CarEntity" + Ogre::StringConverter::toString(mEntityCount++), tireGeo[i].meshName); + Ogre::Vector3 posit (tireGeo[i].m_posit[0], tireGeo[i].m_posit[1], tireGeo[i].m_posit[2]); + Ogre::Quaternion rotation (tireGeo[i].m_rotation[0], tireGeo[i].m_rotation[1], tireGeo[i].m_rotation[2], tireGeo[i].m_rotation[3]); + tireNode = (Ogre::SceneNode*) parentNode->createChild (posit, rotation ); + tireNode->attachObject (tireEnt); + } + + + return car; +} + +// SimpleVehicle constructor. this creates and sets up the entire vehicle! +SimpleVehicle::SimpleVehicle(OgreNewt::Body* carBody, int maxTiresCount) + :RayCastVehicle(carBody, maxTiresCount) +{ + + // save the scene manager +// mSceneMgr = mgr; +// mWorld = world; + + + // first thing we need to do is create the rigid body for the main chassis. +// Ogre::Vector3 size(5,1.2,2); +// OgreNewt::Body* bod = makeSimpleBox(size, position, orient); +// OgreNewt::Body* bod = makeBody (carMesh, mgr); + +/* + //now that we have defined the chassis, we can call the "init()" function. this is a helper function that + // simply sets up some internal wiring of the vehicle class that makes eveything work :) it also calls the virtual + // function "setup" to finish building the vehicle. + // you pass this function the body to be used as the main chassis, and the up direction of the world (for suspension purposes). + init( bod, Ogre::Vector3(0,1,0) ); + + // the above function calls our "setup" function, which takes care of the rest of the vehicle setup. +*/ +} + +SimpleVehicle::~SimpleVehicle(void) +{ +/* + std::vector< SimpleTire* > toDelete; + + // delete tire objects. + for (SimpleTire* tire = (SimpleTire*)getFirstTire(); tire; tire=(SimpleTire*)getNextTire(tire)) + { + toDelete.push_back( tire ); + } + + while (!toDelete.empty()) + { + SimpleTire* tire = toDelete.back(); + delete tire; + toDelete.pop_back(); + } + + // finally, destroy entity and node from chassis. + Ogre::Entity* ent = (Ogre::Entity*)((Ogre::SceneNode*)m_chassis->getOgreNode())->getAttachedObject(static_cast<unsigned short>(0)); + ((Ogre::SceneNode*)m_chassis->getOgreNode())->detachAllObjects(); + ((Ogre::SceneNode*)m_chassis->getOgreNode())->getCreator()->destroyEntity( ent ); + ((Ogre::SceneNode*)m_chassis->getOgreNode())->getParentSceneNode()->removeAndDestroyChild( m_chassis->getOgreNode()->getName() ); + + destroy(); +*/ +} + +/* +OgreNewt::Body* SimpleVehicle::makeBody (const char* carMesh, Ogre::SceneManager* mgr) const +{ + Ogre::Entity* box1; + Ogre::SceneNode* box1node; + + box1 = mgr->createEntity( "CarEntity"+Ogre::StringConverter::toString(mEntityCount++), carMesh); + box1node = mgr->getRootSceneNode()->createChildSceneNode(); + box1node->attachObject (box1); + +Ogre::Vector3 pos(mEntityCount * 3, 0, 0); +box1node->setPosition(pos); +// box1node->setScale( size ); + + OgreNewt::ConvexCollision* col = new OgreNewt::CollisionPrimitives::Box( mWorld, size ); + OgreNewt::Body* bod = new OgreNewt::Body( mWorld, col ); + + // base mass on the size of the object. + Ogre::Real mass = size.x * size.y * size.z * 100.0; + // calculate the inertia based on box formula and mass + Ogre::Vector3 inertia, offset; + col->calculateInertialMatrix(inertia, offset); + + delete col; + + + bod->attachNode( box1node ); + bod->setMassMatrix( mass, mass*inertia ); + bod->setCenterOfMass(offset); + bod->setStandardForceCallback(); + + box1->setMaterialName( "Simple/BumpyMetal" ); + box1->setNormaliseNormals(true); + + + bod->setPositionOrientation( pos, orient ); + + return bod; + + return NULL; +} +*/ + + +#if 0 + +// virtual function - setup(). this actually builds the tires, etc. +void SimpleVehicle::setup() +{ + // okay, we have the main chassis all setup. let's do a few things to it: + m_chassis->setStandardForceCallback(); + // we don't want the vehicle to freeze, because we'll be unable to control it. + m_chassis->setAutoFreeze(0); + + + // okay, let's add tires! + // all offsets here are in local space of the vehicle. + Ogre::Vector3 offset(1.8,-1.6,0.87); + + int tireNum = 0; + for (int x=-1;x<=1;x+=2) + { + for (int z=-1;z<=1;z+=2) + { + + // okay, let's create the tire itself. we'll use the OgreNewt::Vehicle::Tire class for this. most of the + // parameters are self-explanatory... try changing some of them to see what happens. + Ogre::Quaternion tireorient = Ogre::Quaternion(Ogre::Degree(0), Ogre::Vector3::UNIT_Y); + Ogre::Vector3 tirepos = offset * Ogre::Vector3(x,0.5f,z); + Ogre::Vector3 pin(0,0,x); + Ogre::Real mass = 15.0; + Ogre::Real width = 0.3; + Ogre::Real radius = 0.5; + Ogre::Real susShock = 30.0; + Ogre::Real susSpring = 200.0; + Ogre::Real susLength = 1.2; + bool steering; + + + // first, load the visual mesh that represents the tire. + Ogre::Entity* ent = mSceneMgr->createEntity("Tire"+Ogre::StringConverter::toString(mEntityCount++), "wheel.mesh"); + // make a scene node for the tire. + Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode(); + node->attachObject( ent ); + node->setScale( Ogre::Vector3(radius, radius, width) ); + + if (x > 0) + steering = true; + else + steering = false; + + // create the actual tire! + SimpleTire* tire = new SimpleTire(this, tireorient, tirepos, pin, mass, width, radius, + susShock, susSpring, susLength, 0, steering); + + // attach the tire to the node. + tire->attachToNode( node ); + + } + } + +} + + +SimpleVehicle::SimpleTire::~SimpleTire() +{ + // destroy entity, and scene node. + Ogre::Entity* ent = (Ogre::Entity*)m_node->getAttachedObject(static_cast<unsigned short>(0)); + m_node->detachAllObjects(); + m_node->getCreator()->destroyEntity( ent ); + m_node->getParentSceneNode()->removeAndDestroyChild( m_node->getName() ); +} + + + + +// This is the important callback, which is the meat of controlling the vehicle. +void SimpleVehicle::userCallback() +{ + + // foop through wheels, adding torque and steering, and updating their positions. + for (SimpleTire* tire = (SimpleTire*)getFirstTire(); tire; tire=(SimpleTire*)getNextTire(tire)) + { + // set the torque and steering! non-steering tires get the torque. + + // is this a steering tire? + if (tire->mSteeringTire) + tire->setSteeringAngle( mSteering ); + else + tire->setTorque( mTorque ); + + // finally, this command updates the location of the visual mesh. + tire->updateNode(); + } + +} + + ... [truncated message content] |