Revision: 513
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=513&view=rev
Author: andy_miller
Date: 2007-12-26 06:29:56 -0800 (Wed, 26 Dec 2007)
Log Message:
-----------
nxogre update
Modified Paths:
--------------
trunk/python-ogre/ThirdParty/nxogre/NxOgre.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacterController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacterController.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCloth.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCloth.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreClothRaycaster.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreContainer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreCooking.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreCooking.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreDebugRenderer.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreDebugRenderer.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreError.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreError.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreFluid.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreFluidMesh.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreFluidMesh.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreForceField.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreGlobalFunctions.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreGroup.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreGroup.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreHelpers.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreHelpers.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreJoint.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreJoint.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreJointSet1.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreJointSet2.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreJointSet2.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreLog.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMaterial.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreMaterial.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreParams.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgrePhysXDriver.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgrePhysXDriver.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePose.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgrePose.h
trunk/python-ogre/ThirdParty/nxogre/NxOgrePrerequisites.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreRaycaster.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreRaycaster.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreRemoteDebuggerConnection.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreScene.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreScene.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneBlueprint.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneContactController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneController.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSceneController.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShape.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShape.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeBlueprint.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeBlueprintConvex.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeBlueprintMesh.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeBlueprintPrimitives.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeBlueprintWheel.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeBlueprintWheel.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeConvex.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeConvex.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeMesh.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeMesh.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapePrimitives.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapePrimitives.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeTerrain.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeTerrain.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeWheel.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreShapeWheel.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSimpleShape.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSimpleShape.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreSkeleton.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSoftBody.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreSoftBody.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreStable.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreTesting.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreTrigger.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreUserAllocator.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreUserAllocator.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreUserData.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreUserStream.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreUserStream.h
trunk/python-ogre/ThirdParty/nxogre/NxOgreWorld.cpp
trunk/python-ogre/ThirdParty/nxogre/NxOgreWorld.h
Removed Paths:
-------------
trunk/python-ogre/ThirdParty/nxogre/NxuStream2/
Modified: trunk/python-ogre/ThirdParty/nxogre/NxOgre.h
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/NxOgre.h 2007-12-17 18:04:28 UTC (rev 512)
+++ trunk/python-ogre/ThirdParty/nxogre/NxOgre.h 2007-12-26 14:29:56 UTC (rev 513)
@@ -1,22 +1,67 @@
-//
-// NxOgre a wrapper for the PhysX (formerly Novodex) physics library and the Ogre 3D rendering engine.
-// Copyright (C) 2005 - 2007 Robin Southern and NxOgre.org http://www.nxogre.org
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License, or (at your option) any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-//
+/** @mainpage NxOgre
+@section licence Licence
+<pre>
+NxOgre a wrapper for the PhysX (formerly Novodex) physics library and the Ogre 3D rendering engine.
+Copyright (C) 2005 - 2007 Robin Southern and NxOgre.org http://www.nxogre.org
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+</pre>
+
+@section whatisit What is it?
+NxOgre is a physics connector library between the physics library PhysX and the Ogre 3D rendering system.
+With a help of some short, fast and neat code you can have a quick physics system within your Ogre game
+or engine within a matter of minutes.
+
+@section installing Installing
+@subsection Ogre
+
+The SDK or Source versions will both work with NxOgre. You should have some knowledege with working Ogre.
+If you can make a simple application that can show an Ogre head with a movement camera, you can work with
+NxOgre.
+\n\n
+You will need to create an environmental variable called "OGRE_HOME" pointing to the ogremain directory
+in your Ogre folder. Normally for SDK users this is automatically created by the installer, but it's work
+checking, if you installed Ogre from the source you'll need to create one.
+
+[1] http://www.ogre3d.org/wiki/index.php/Installing_An_SDK \n
+[2] http://www.ogre3d.org/wiki/index.php/Building_From_Source \n
+
+@subsection PhysX
+The PhysX SDK can be downloaded from the Ageia Support Center, a user account is required to download the
+SDK. Once your account has been registered (Accounts are processed by hand, so a wait of 1-2 business days
+is common), download the PhysX SDK and the SystemSoftware.
+\n\n
+Install the SystemSoftware first, then the PhysX SDK. I recommend you install the PhysX SDK in the same
+parent directory as Ogre. Once the installation is completed, create a Environmental variable called
+"<code>PHYSX_DIR</code>" pointing to the PhysX SDK directory.
+\n\n
+[3] http://devsupport.ageia.com/ \n
+
+@subsection NxOgre
+ - Create a "NxOgre" folder, it should be in the parent of your Ogre or nearby
+ - Using Tortoise SVN or another Subversion client checkout the HEAD repositry
+ - Go to the parent directory of Ogre and the PhysX SDK i.e. (c:/dev/)
+ - New Folder, name as NxOgre, and go inside
+ - File, SVN, SVN Checkout
+ - Set the URL to http://latest.nxogre.org/nxogre3/
+ - Click okay
+ - Open up the project and compile.
+
+*/
+
#ifndef __NXOGRE_H__
#define __NXOGRE_H__
@@ -27,23 +72,34 @@
#include "NxOgrePhysXDriver.h"
#include "NxOgreError.h"
#include "NxOgreLog.h"
+#include "NxOgreExtendedTypes.h"
///////////////////////////////////////////
#include "NxOgreActor.h"
#include "NxOgreActorBlueprint.h"
#include "NxOgreBody.h"
+#include "NxOgreContactStream.h"
#include "NxOgreContainer.h"
#include "NxOgreCooking.h"
-#include "NxOgreCharacter.h"
-#include "NxOgreCharacterController.h"
-#include "NxOgreCharacterHitReport.h"
+#if NX_USE_LEGACY_NXCONTROLLER
+# include "NxOgreLegacyCharacter.h"
+# include "NxOgreLegacyCharacterController.h"
+# include "NxOgreLegacyCharacterHitReport.h"
+#else
+# include "NxOgreCharacterSystem.h"
+# include "NxOgreCharacter.h"
+# include "NxOgreCharacterModel.h"
+# include "NxOgreCharacterMovementModel.h"
+#endif
#include "NxOgreCloth.h"
#include "NxOgreClothRaycaster.h"
#include "NxOgreCompound.h"
#include "NxOgreDebugRenderer.h"
#include "NxOgreDominanceGroup.h"
+#include "NxOgreEngine.h"
#include "NxOgreEnumsBlueprint.h"
+#include "NxOgreFileResourceSystem.h"
#include "NxOgreFluid.h"
#include "NxOgreFluidMesh.h"
#include "NxOgreForceField.h"
@@ -51,19 +107,26 @@
#include "NxOgreHelpers.h"
#include "NxOgreJointSet1.h"
#include "NxOgreJointSet2.h"
-#include "NxOgreHelper.h"
#include "NxOgreIntersection.h"
#include "NxOgreMaterial.h"
-#include "NxOgreMotor.h"
+#include "NxOgreMachine.h"
+#include "NxOgreNodeRenderable.h"
+#include "NxOgreResourceManager.h"
+#include "NxOgreOgreResourceSystem.h"
#include "NxOgreParams.h"
#include "NxOgrePose.h"
#include "NxOgreRaycaster.h"
+#include "NxOgreRenderable.h"
+#include "NxOgreRenderableSource.h"
#include "NxOgreRemoteDebuggerConnection.h"
+#include "NxOgreResourceSystem.h"
+#include "NxOgreResourceStreamPtr.h"
#include "NxOgreSerialiser.h"
#include "NxOgreScene.h"
#include "NxOgreSceneBlueprint.h"
#include "NxOgreSceneController.h"
#include "NxOgreSceneContactController.h"
+#include "NxOgreSceneRenderer.h"
#include "NxOgreShape.h"
#include "NxOgreShapeBlueprint.h"
#include "NxOgreShapeBlueprintConvex.h"
@@ -82,9 +145,16 @@
#include "NxOgreStateMachine.h"
#include "NxOgreTesting.h"
#include "NxOgreTrigger.h"
-#include "NxOgreUserStream.h"
+#include "NxOgreMemoryStream.h"
#include "NxOgreUserAllocator.h"
+#include "NxOgreUserData.h"
+#include "NxOgreWheelSet.h"
#include "NxOgreWorld.h"
#include "NxOgreWorldBlueprint.h"
+///////////////////////////////////////////
+
+#include "NxOgreOgreSceneRenderer.h"
+#include "NxOgreOgreNodeRenderable.h"
+
#endif
Modified: trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.cpp 2007-12-17 18:04:28 UTC (rev 512)
+++ trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.cpp 2007-12-26 14:29:56 UTC (rev 513)
@@ -30,44 +30,51 @@
#include "NxOgreContainer.h" // For Getting an ActorGroup
#include "NxOgreActorBlueprint.h" // For Quick Duplication.
+#include "OgreStringConverter.h"
+#include "OgreRoot.h"
+#include "OgreSingleton.h"
+#include "OgreMatrix3.h"
+
namespace NxOgre {
//////////////////////////////////////////////////////////
void ActorParams::setToDefault() {
- mDensity = 0.0f;
- mActorFlags = 0;
- mGroupAsIndex = 0;
- mGroupAsName = "";
+
+ mDensity = 0.0f;
+ mActorFlags = 0;
+ mGroupAsIndex = 0;
+ mGroupAsName = "";
#if NX_SDK_VERSION_NUMBER >= 272
- mDominanceGroupAsIndex = 0;
- mDominanceGroupAsName = "";
+ mDominanceGroupAsIndex = 0;
+ mDominanceGroupAsName = "";
#endif
#if NX_SDK_VERSION_NUMBER >= 260
- mCompartment = NULL;
+ mCompartment = NULL;
#endif
- mMassLocalPose . id();
- mMassSpaceInertia . zero();
- mLinearVelocity . zero();
- mAngularVelocity . zero();
- mWakeUpCounter = 20.0f*0.02f;
- mMass = 10.0f;
- mLinearDamping = 0.0f;
- mAngularDamping = 0.05f;
- mMaxAngularVelocity = -1.0f;
- mBodyFlags = NX_BF_VISUALIZATION;
- mSleepLinearVelocity = -1.0f;
- mSleepAngularVelocity = -1.0f;
- mCCDMotionThreshold = 0.0f;
- mSolverIterationCount = 4;
- mBodyFlags = NX_BF_ENERGY_SLEEP_TEST;
- mSleepEnergyThreshold = -1.0f;
- mSleepDamping = 0.0f;
+ mMassLocalPose . id();
+ mMassSpaceInertia . zero();
+ mLinearVelocity . zero();
+ mAngularVelocity . zero();
+ mWakeUpCounter = 20.0f * 0.02f;
+ mMass = 10.0f;
+ mLinearDamping = 0.0f;
+ mAngularDamping = 0.05f;
+ mMaxAngularVelocity = -1.0f;
+ mBodyFlags = NX_BF_VISUALIZATION;
+ mBodyFlags |= NX_BF_ENERGY_SLEEP_TEST;
+ mSleepLinearVelocity = -1.0f;
+ mSleepAngularVelocity = -1.0f;
+ mCCDMotionThreshold = 0.0f;
+ mSolverIterationCount = 4;
+ mSleepEnergyThreshold = -1.0f;
+ mSleepDamping = 0.0f;
- mNodeScale = Ogre::Vector3(1,1,1);
- mNodeName = "";
- mNodeShadows = true;
+ mNodeScale = Ogre::Vector3(1,1,1);
+ mNodeName = "";
+ mNodeShadows = true;
+ mNodePose . id();
}
@@ -122,6 +129,8 @@
if (Set("node-scale", (*p), mNodeScale)) continue;
if (Set("node-shadows", (*p), mNodeShadows)) continue;
if (Set("node", (*p), mNodeName)) continue;
+ if (Set("node-orientation", (*p), mNodePose.q)) continue;
+ if (Set("node-offset", (*p), mNodePose.v)) continue;
}
@@ -176,11 +185,11 @@
//////////////////////////////////////////////////////////
-Actor::Actor(const NxString& name, Scene* scene, ShapeBlueprint *shape, const Pose& pose, ActorParams params) : mName(name), mOwner(scene) {
+Actor::Actor(const NxString& name, Scene* scene, ShapeBlueprint *shape, const Pose& pose, ActorParams params)
+: mName(name), mOwner(scene) {
if (name.length() == 0) {
mName = NxCreateID(scene->getNbActors(), "Actor");
- mVisualIdentifier = NxString();
}
else {
@@ -190,12 +199,9 @@
if (splitID.size() == 1) {
identifier = name;
- mVisualIdentifier = name;
}
else {
identifier = splitID[0];
- mVisualIdentifier = splitID[1];
- Ogre::StringUtil::trim(mVisualIdentifier);
}
Ogre::StringUtil::trim(identifier);
@@ -310,7 +316,7 @@
bd.wakeUpCounter = params.mWakeUpCounter;
ad.body = &bd;
}
-
+
shape->_bindToActorDescription(this, 0, ad.shapes);
mActor = mOwner->mScene->createActor(ad);
@@ -334,7 +340,7 @@
i++;
}
-#if (OGRE_VERSION_MINOR >= 5)
+#if (OGRE_VERSION_MAJOR >= 1) && (OGRE_VERSION_MINOR >= 5)
mBirthFrame = Ogre::Root::getSingletonPtr()->getNextFrameNumber() - 1;
#else
mBirthFrame = Ogre::Root::getSingletonPtr()->getCurrentFrameNumber();
@@ -352,32 +358,6 @@
//////////////////////////////////////////////////////////
-void Actor::simulate(float dT) {
- shapeSimulate(dT);
-}
-
-//////////////////////////////////////////////////////////
-
-void Actor::render(float) {
- // No.
-}
-
-//////////////////////////////////////////////////////////
-
-void Actor::shapeSimulate(float t) {
- for(Shape* shape = mDynamicCollisionModel.begin();shape = mDynamicCollisionModel.next();)
- shape->simulate(t);
-}
-
-//////////////////////////////////////////////////////////
-
-void Actor::shapeRender(float t) {
- for(Shape* shape = mDynamicCollisionModel.begin();shape = mDynamicCollisionModel.next();)
- shape->render(t);
-}
-
-//////////////////////////////////////////////////////////
-
void Actor::setName(NxString name) {
mOwner->mActors.rename(mName, name);
mName = name;
@@ -385,7 +365,7 @@
//////////////////////////////////////////////////////////
-NxString Actor::getName() {
+NxString Actor::getName() const {
return mName;
}
@@ -423,25 +403,25 @@
//////////////////////////////////////////////////////////
Ogre::Quaternion Actor::getGlobalOrientation() {
- return toQuaternion(mActor->getGlobalOrientationQuat());
+ return NxConvert<Ogre::Quaternion, NxQuat>(mActor->getGlobalOrientationQuat());
}
//////////////////////////////////////////////////////////
void Actor::setGlobalOrientation(const Ogre::Quaternion& quat) {
- mActor->setGlobalOrientation(toNxQuat(quat));
+ mActor->setGlobalOrientation(NxConvert<NxQuat, Ogre::Quaternion>(quat));
}
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getGlobalPosition() {
- return toVector3(mActor->getGlobalPosition());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getGlobalPosition());
}
//////////////////////////////////////////////////////////
void Actor::setGlobalPosition(const Ogre::Vector3& vec) {
- mActor->setGlobalPosition(toNxVec3(vec));
+ mActor->setGlobalPosition(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
@@ -453,13 +433,13 @@
//////////////////////////////////////////////////////////
void Actor::moveGlobalPosition(const Ogre::Vector3& vec) {
- mActor->moveGlobalPosition(toNxVec3(vec));
+ mActor->moveGlobalPosition(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
void Actor::moveGlobalOrientation(const Ogre::Quaternion& quat) {
- mActor->moveGlobalOrientationQuat(toNxQuat(quat));
+ mActor->moveGlobalOrientationQuat(NxConvert<NxQuat, Ogre::Quaternion>(quat));
}
////////////////////////////////////////////////////////
@@ -474,6 +454,7 @@
////////////////////////////////////////////////////////
#if 0
+
const ShapeBlueprint& Actor::createShapeDescription(const ShapeBlueprint& s) {
NxUnderConstruction;
return s;
@@ -512,6 +493,7 @@
NxUnderConstruction;
return NULL;
}
+
#endif
//////////////////////////////////////////////////////////
@@ -571,7 +553,7 @@
//////////////////////////////////////////////////////////
void Actor::setCMassOffsetLocalPosition(const Ogre::Vector3& vec) {
- mActor->setCMassOffsetLocalPosition(toNxVec3(vec));
+ mActor->setCMassOffsetLocalPosition(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
@@ -584,7 +566,6 @@
void Actor::setCMassOffsetLocalOrientation(const Ogre::Matrix3& vec) {
NxUnderConstruction;
-
}
//////////////////////////////////////////////////////////
@@ -596,7 +577,7 @@
//////////////////////////////////////////////////////////
void Actor::setCMassOffsetGlobalPosition(const Ogre::Vector3& vec) {
- mActor->setCMassOffsetGlobalPosition(toNxVec3(vec));
+ mActor->setCMassOffsetGlobalPosition(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
@@ -622,7 +603,7 @@
//////////////////////////////////////////////////////////
void Actor::setCMassGlobalPosition(const Ogre::Vector3& vec) {
- mActor->setCMassGlobalPosition(toNxVec3(vec));
+ mActor->setCMassGlobalPosition(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
@@ -644,13 +625,13 @@
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getCMassLocalPosition() const {
- return toVector3(mActor->getCMassLocalPosition());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getCMassLocalPosition());
}
//////////////////////////////////////////////////////////
Ogre::Quaternion Actor::getCMassLocalOrientation() const {
- return toQuaternion(mActor->getCMassLocalOrientation());
+ return NxConvert<Ogre::Quaternion, NxQuat>(mActor->getCMassLocalOrientation());
}
//////////////////////////////////////////////////////////
@@ -664,7 +645,7 @@
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getCMassGlobalPosition() const {
- return toVector3(mActor->getCMassGlobalPosition());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getCMassGlobalPosition());
}
//////////////////////////////////////////////////////////
@@ -672,7 +653,7 @@
Ogre::Quaternion Actor::getCMassGlobalOrientation() const {
NxQuat quat;
mActor->getCMassGlobalOrientation().toQuat(quat);
- return toQuaternion(quat);
+ return NxConvert<Ogre::Quaternion, NxQuat>(quat);
}
//////////////////////////////////////////////////////////
@@ -692,13 +673,13 @@
void Actor::setMassSpaceInertiaTensor(const Ogre::Vector3& vec) {
- mActor->setMassSpaceInertiaTensor(toNxVec3(vec));
+ mActor->setMassSpaceInertiaTensor(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getMassSpaceInertiaTensor() const {
- return toVector3(mActor->getMassSpaceInertiaTensor());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getMassSpaceInertiaTensor());
}
//////////////////////////////////////////////////////////
@@ -758,26 +739,26 @@
//////////////////////////////////////////////////////////
void Actor::setLinearVelocity(const Ogre::Vector3& vec) {
- mActor->setLinearVelocity(toNxVec3(vec));
+ mActor->setLinearVelocity(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
void Actor::setAngularVelocity(const Ogre::Vector3& vec) {
- mActor->setAngularVelocity(toNxVec3(vec));
+ mActor->setAngularVelocity(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getLinearVelocity() const {
- return toVector3(mActor->getLinearVelocity());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getLinearVelocity());
}
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getAngularVelocity() const {
- return toVector3(mActor->getAngularVelocity());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getAngularVelocity());
}
//////////////////////////////////////////////////////////
@@ -808,73 +789,91 @@
//////////////////////////////////////////////////////////
void Actor::setLinearMomentum(const Ogre::Vector3& vec) {
- mActor->setLinearMomentum(toNxVec3(vec));
+ mActor->setLinearMomentum(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
void Actor::setAngularMomentum(const Ogre::Vector3& vec) {
- mActor->setAngularMomentum(toNxVec3(vec));
+ mActor->setAngularMomentum(NxConvert<NxVec3, Ogre::Vector3>(vec));
}
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getLinearMomentum() const {
- return toVector3(mActor->getLinearMomentum());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getLinearMomentum());
}
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getAngularMomentum() const {
- return toVector3(mActor->getAngularMomentum());
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getAngularMomentum());
}
//////////////////////////////////////////////////////////
void Actor::addForceAtPos(const Ogre::Vector3& force, const Ogre::Vector3& pos, NxForceMode mode, bool wakeup) {
- mActor->addForceAtPos(toNxVec3(force), toNxVec3(pos), mode, wakeup);
+ mActor->addForceAtPos(NxConvert<NxVec3, Ogre::Vector3>(force), NxConvert<NxVec3, Ogre::Vector3>(pos), mode, wakeup);
}
//////////////////////////////////////////////////////////
void Actor::addForceAtLocalPos(const Ogre::Vector3& force, const Ogre::Vector3& pos, NxForceMode mode, bool wakeup) {
- mActor->addForceAtLocalPos(toNxVec3(force), toNxVec3(pos), mode, wakeup);
+ mActor->addForceAtLocalPos(NxConvert<NxVec3, Ogre::Vector3>(force), NxConvert<NxVec3, Ogre::Vector3>(pos), mode, wakeup);
}
//////////////////////////////////////////////////////////
void Actor::addLocalForceAtPos(const Ogre::Vector3& force, const Ogre::Vector3& pos, NxForceMode mode, bool wakeup) {
- mActor->addLocalForceAtPos(toNxVec3(force), toNxVec3(pos), mode, wakeup);
+ mActor->addLocalForceAtPos(NxConvert<NxVec3, Ogre::Vector3>(force), NxConvert<NxVec3, Ogre::Vector3>(pos), mode, wakeup);
}
//////////////////////////////////////////////////////////
void Actor::addLocalForceAtLocalPos(const Ogre::Vector3& force, const Ogre::Vector3& pos, NxForceMode mode, bool wakeup) {
- mActor->addLocalForceAtLocalPos(toNxVec3(force), toNxVec3(pos), mode, wakeup);
+ mActor->addLocalForceAtLocalPos(NxConvert<NxVec3, Ogre::Vector3>(force), NxConvert<NxVec3, Ogre::Vector3>(pos), mode, wakeup);
}
//////////////////////////////////////////////////////////
void Actor::addForce(const Ogre::Vector3& force, NxForceMode mode, bool wakeup) {
- mActor->addForce(toNxVec3(force), mode, wakeup);
+ mActor->addForce(NxConvert<NxVec3, Ogre::Vector3>(force), mode, wakeup);
}
//////////////////////////////////////////////////////////
+void Actor::addForce(const NxVec3& force, NxForceMode mode, bool wakeup) {
+ mActor->addForce(force, mode, wakeup);
+}
+
+//////////////////////////////////////////////////////////
+
+void Actor::addForce(NxReal x, NxReal y, NxReal z, NxForceMode mode, bool wakeup) {
+ mActor->addForce(NxVec3(x,y,z), mode, wakeup);
+}
+
+//////////////////////////////////////////////////////////
+
void Actor::addLocalForce(const Ogre::Vector3& force, NxForceMode mode, bool wakeup) {
- mActor->addLocalForce(toNxVec3(force), mode, wakeup);
+ mActor->addLocalForce(NxConvert<NxVec3, Ogre::Vector3>(force), mode, wakeup);
}
//////////////////////////////////////////////////////////
+void Actor::addTorque(const NxVec3& torque, NxForceMode mode, bool wakeup) {
+ mActor->addTorque(torque, mode, wakeup);
+}
+
+//////////////////////////////////////////////////////////
+
void Actor::addTorque(const Ogre::Vector3& torque, NxForceMode mode, bool wakeup) {
- mActor->addTorque(toNxVec3(torque), mode, wakeup);
+ mActor->addTorque(NxConvert<NxVec3, Ogre::Vector3>(torque), mode, wakeup);
}
//////////////////////////////////////////////////////////
void Actor::addLocalTorque(const Ogre::Vector3& torque, NxForceMode mode, bool wakeup) {
- mActor->addLocalTorque(toNxVec3(torque), mode, wakeup);
+ mActor->addLocalTorque(NxConvert<NxVec3, Ogre::Vector3>(torque), mode, wakeup);
}
//////////////////////////////////////////////////////////
@@ -886,13 +885,13 @@
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getPointVelocity(const Ogre::Vector3& vec) const {
- return toVector3(mActor->getPointVelocity(toNxVec3(vec)));
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getPointVelocity(NxConvert<NxVec3, Ogre::Vector3>(vec)));
}
//////////////////////////////////////////////////////////
Ogre::Vector3 Actor::getLocalPointVelocity(const Ogre::Vector3& vec) const {
- return toVector3(mActor->getLocalPointVelocity(toNxVec3(vec)));
+ return NxConvert<Ogre::Vector3, NxVec3>(mActor->getLocalPointVelocity(NxConvert<NxVec3, Ogre::Vector3>(vec)));
}
//////////////////////////////////////////////////////////
@@ -990,7 +989,7 @@
#if NX_SUPPORT_SWEEP_API
NxU32 Actor::linearSweep(const Ogre::Vector3& motion, NxU32 flags, void* userData, NxU32 nbShapeDescriptions, NxSweepQueryHit* shapes, NxUserEntityReport<NxSweepQueryHit>* callback, const NxSweepCache* sweepCache) {
- return mActor->linearSweep(toNxVec3(motion), flags, userData, nbShapeDescriptions, shapes, callback, sweepCache);
+ return mActor->linearSweep(NxConvert<NxVec3, Ogre::Vector3>(motion), flags, userData, nbShapeDescriptions, shapes, callback, sweepCache);
}
#endif
@@ -1083,6 +1082,12 @@
//////////////////////////////////////////////////////////
+NxActorUserData* Actor::getUserData() {
+ return mNxActorUserData;
+}
+
+//////////////////////////////////////////////////////////
+
StringPairList Actor::saveCustom() {
StringPairList l;
l.insert("ActorType", "Actor");
@@ -1093,6 +1098,7 @@
//////////////////////////////////////////////////////////
void Actor::disable() {
+
mActor->raiseActorFlag(NX_AF_DISABLE_COLLISION);
mActor->raiseActorFlag(NX_AF_DISABLE_RESPONSE);
mActor->raiseActorFlag(NX_AF_FLUID_DISABLE_COLLISION);
@@ -1103,7 +1109,7 @@
mActor->setLinearMomentum(NxVec3(0,0,0));
mActor->setLinearVelocity(NxVec3(0,0,0));
- disableVisualisation();
+// disableVisualisation();
}
//////////////////////////////////////////////////////////
Modified: trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.h
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.h 2007-12-17 18:04:28 UTC (rev 512)
+++ trunk/python-ogre/ThirdParty/nxogre/NxOgreActor.h 2007-12-26 14:29:56 UTC (rev 513)
@@ -23,11 +23,11 @@
#include "NxOgrePrerequisites.h"
#include "NxOgreContainer.h" // For: mCollisionList
#include "NxOgreParams.h"
+#include "NxOgrePose.h"
namespace NxOgre {
- /**
- \page actorparams ActorParams
+ /** \page actorparams ActorParams
String base params are case and space insensitive.
@@ -173,109 +173,180 @@
*/
+
/** ActorParams
- See \ref actorparams for the full string argument documentation.
+ @see \ref actorparams for the full string argument documentation.
*/
class NxExport ActorParams : public Params {
public:
+ /** @brief Class based params.
+ @note Faster, less readable and reusable.
+ @see \ref actorparams
+ @example
+ <code>
+ ActorParams ap;
+ ap.mMass = 10;
+ ap.mGroup = "myGroup";
+ ..., ap, ...
+ </code>
- ActorParams(){setToDefault();}
- ActorParams(const char* p) {process(p);}
- ActorParams(NxString p) {process(p);}
+ */
+ ActorParams() {
+ setToDefault();
+ }
+ /** @brief String based params. "mass: 10, group: myGroup"
+ @note Slower but readable.
+ @params String of params.
+ @see \ref actorparams
+ @example
+ <code>
+ ..., "mass: 10, group: myGroup", ...
+ </code>
+ */
+ ActorParams(const char* p) {
+ process(p);
+ }
+
+ /** @brief String based params. "mass: 10, group: myGroup"
+ @note Slower but readable.
+ @params
+ @see \ref actorparams
+ @example
+ <code>
+ ..., "mass: 10, group: myGroup", ...
+ </code>
+ */
+ ActorParams(NxString p) {
+ process(p);
+ }
+
+ /** @brief Set's the Params to default based on NxActorDesc and NxBodyDesc defaults.
+ */
void setToDefault();
- void parse(Parameters);
+
+ /** @brief Set's the Params based from an NxActorDesc
+ */
void fromNxActorDesc(NxActorDesc&);
+
+ /** @brief Set's the Params based from a NxBodyDesc
+ */
void fromNxBodyDesc(NxBodyDesc&);
////////////////////////////////////////////////////////////////
#if NX_SDK_VERSION_NUMBER >= 260
- /// NxCompartment of the Actor to sit in.
- /// @todo NxOgre-ify
- /// @default NULL
+ /** NxCompartment of the Actor to sit in.
+ @todo NxOgre-ify
+ @default NULL
+ */
NxCompartment* mCompartment;
#endif
- /// Density, mass must be 0 when density is used.
+ /** Density, mass must be 0 when density is used.
+ @default 0
+ @see ActorParams::mMass
+ */
NxReal mDensity;
#if NX_SDK_VERSION_NUMBER >= 272
- /// DominanceGroup (as Name).
- /// @default ""
+ /** @brief DominanceGroup (as Name).
+ @default "" (Resorts to dominance group with identifier "Default")
+ */
NxString mDominanceGroupAsName;
- /// DominanceGroup (as Index)
- /// @default 0
+ /** @brief DominanceGroup (as Index)
+ @default 0
+ */
NxDominanceGroup mDominanceGroupAsIndex;
+
#endif
- /// Flags for the NxActor
- /// @see NxActorFlags
- /// @default 0
+ /** @brief Flags for the NxActor
+ @see NxActorFlags
+ @default 0
+ */
NxU32 mActorFlags;
- /// Group to use as index. GroupAsName must be blank.
- /// @default 0
+ /** @brief Group to use as index. GroupAsName must be blank.
+ @default 0
+ */
NxActorGroup mGroupAsIndex;
- /// Group to use from name. GroupAsIndex must be 0.
- /// @default Blank String
+ /** @brief Group to use from name. GroupAsIndex must be 0.
+ @default Blank String (Resorts to actor group with identifier "Default")
+ */
NxString mGroupAsName;
////////////////////////////////////////////////////////////////
- /// Angular Damping
+ /** @brief Angular Damping
+ */
NxReal mAngularDamping;
- /// Angular Velocity
+ /** @brief Angular Velocity
+ */
NxVec3 mAngularVelocity;
- ///
+ /** @brief CCD Motion Threshold
+ */
NxReal mCCDMotionThreshold;
- ///
+ /** @brief Flags for the Body portion of an Actor, assuming it is dynamic.
+ @see NxBodyDesc
+ */
NxU32 mBodyFlags;
- ///
+ /** @brief Linear Damping of the Actor
+ */
NxReal mLinearDamping;
- ///
+ /** @brief Initial linear velocity of the actor
+ */
NxVec3 mLinearVelocity;
- /// Mass of the Actor. When used, make sure density is zero.
+ /** @brief Mass of the Actor.
+ @note When used, make sure density is zero.
+ @default 10
+ */
NxReal mMass;
- ///
+ /** @brief Mass Local Pose of the body portion of the Actor
+ @default NxMatrix34.id()
+ */
NxMat34 mMassLocalPose;
- ///
+ /** @brief Mass Space Inertia of the body portion of the Actor
+ */
NxVec3 mMassSpaceInertia;
- ///
+ /** @brief Maximum angular velocity of the Actor
+ */
NxReal mMaxAngularVelocity;
- ///
+ /**
+ */
NxReal mSleepAngularVelocity;
- ///
+ /**
+ */
NxReal mSleepDamping;
@@ -307,10 +378,24 @@
/// Set the first Entity of the Visual based Actors to have shadows or not.
bool mNodeShadows;
+ Pose mNodePose;
+ private:
+
+ //! \internal
+ void parse(Parameters);
+
}; // End of ActorParams class
+ /** Actor
+ An Actor is a single unit of matter in the Scene. It is physically represented by a "Collision Model" or a shape. If the actor
+ has some mass then it is known as a Dynamic Actor, capable of scurrying around in the Scene. If the Actor has
+ no mass then it is a static actor which never ever moves.
+
+
+
+ */
class NxExport Actor {
public:
@@ -329,14 +414,13 @@
//////////////////////////////////////////////////////////
+ virtual NxShortHashIdentifier getType() const {return NxHashes_Actor; /* "NxOgre-Actor" */}
+ virtual NxString getStringType() const {return "NxOgre-Actor";}
+
virtual bool hasVisualisation() const {return false;}
- virtual void simulate(float);
- virtual void render(float);
- virtual void shapeSimulate(float);
- virtual void shapeRender(float);
bool isDead() { return (mActor == NULL); }
+
-
/** Duplicate this actor
@param name Name of the new Actor
@@ -359,7 +443,7 @@
//////////////////////////////////////////////////////////
void setName(NxString);
- NxString getName();
+ NxString getName() const;
////////////////////////////////////////////////////////
@@ -473,8 +557,17 @@
void addForceAtLocalPos(const Ogre::Vector3& force, const Ogre::Vector3& pos, NxForceMode mode = NX_FORCE, bool wakeup = true);
void addLocalForceAtPos(const Ogre::Vector3& force, const Ogre::Vector3& pos, NxForceMode mode = NX_FORCE, bool wakeup = true);
void addLocalForceAtLocalPos(const Ogre::Vector3& force, const Ogre::Vector3& pos, NxForceMode mode = NX_FORCE, bool wakeup = true);
+
+
void addForce(const Ogre::Vector3& force, NxForceMode mode = NX_FORCE, bool wakeup = true);
+ void addForce(const NxVec3& force, NxForceMode = NX_FORCE, bool wakeup = true);
+ void addForce(NxReal x, NxReal y, NxReal z, NxForceMode = NX_FORCE, bool wakeup = true);
void addLocalForce(const Ogre::Vector3& force, NxForceMode mode = NX_FORCE, bool wakeup = true);
+
+ void addTorque(NxReal x, NxReal y, NxReal z, NxForceMode mode = NX_FORCE, bool wakeup = true) {
+ addTorque(NxVec3(x,y,z), mode, wakeup);
+ }
+ void addTorque(const NxVec3& torque, NxForceMode mode = NX_FORCE, bool wakeup = true);
void addTorque(const Ogre::Vector3& torque, NxForceMode mode = NX_FORCE, bool wakeup = true);
void addLocalTorque(const Ogre::Vector3& torque, NxForceMode mode = NX_FORCE, bool wakeup = true);
NxReal computeKineticEnergy() const;
@@ -521,6 +614,7 @@
mDynamicCollisionModel;
void* getNxActorUserData();
+ NxActorUserData* getUserData();
/** joinWith
@@ -543,8 +637,6 @@
*/
void disable();
- virtual void disableVisualisation() {}
-
NxU32 getBirthFrame() {return mBirthFrame;}
//////////////////////////////////////////////////////////
@@ -558,9 +650,8 @@
NxActor* mActor;
NxString mName;
NxActorUserData* mNxActorUserData;
- NxString mVisualIdentifier;
NxU32 mBirthFrame;
-
+
private:
Modified: trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.cpp 2007-12-17 18:04:28 UTC (rev 512)
+++ trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.cpp 2007-12-26 14:29:56 UTC (rev 513)
@@ -25,6 +25,13 @@
#include "NxOgreScene.h" // For: Actor::mOwner
#include "NxOgreShapeBlueprint.h"
#include "NxOgreContainer.h"
+#include "NxOgreOgreNodeRenderable.h"
+#include "NxOgreRenderable.h"
+#include "NxOgreRenderableSource.h"
+#include "NxOgreNodeRenderable.h"
+#include "NxOgreSceneRenderer.h"
+#include "NxOgreUserData.h"
+#include "NxOgreHelpers.h"
namespace NxOgre {
@@ -37,11 +44,51 @@
//////////////////////////////////////////////////////////
Body::Body(const NxString& identifier, Scene* scene, ShapeBlueprint *firstShapeDescription, const Pose& pose, ActorParams params)
-: mNode(0), mEntity(0), Actor(identifier, scene, firstShapeDescription, pose, params)
+: Actor(identifier, scene, firstShapeDescription, pose, params)
{
+ NodeRenderableParams visualParams;
+ visualParams.Identifier = identifier;
+ visualParams.IdentifierType = visualParams.IT_CREATE;
+ visualParams.Intent = getStringType();
+
+ std::vector<NxString> splitID = Ogre::StringUtil::split(identifier, ";", 2);
+
+ NxString visualIdentifier;
+
+ if (splitID.size() == 1) {
+ visualIdentifier = identifier;
+ }
+ else {
+ visualIdentifier = splitID[1];
+ }
+
+ Ogre::StringUtil::trim(visualIdentifier);
+
+ if (Ogre::StringUtil::startsWith(visualIdentifier, "(reference)")) {
+ NxString entityName = visualIdentifier.substr(11, entityName.length() - 11);
+ Ogre::StringUtil::trim(entityName);
+ visualParams.GraphicsModel = entityName;
+ visualParams.GraphicsModelType = visualParams.GMT_EXISTING_REFERENCE;
+ }
+ else {
+ visualParams.GraphicsModel = visualIdentifier;
+ visualParams.GraphicsModelType = visualParams.GMT_RESOURCE_IDENTIFIER;
+ }
+
+ setLevelOfDetail(LOD_High);
+ mRenderable = mOwner->getSceneRenderer()->createNodeRenderable(visualParams);
+ mNodeRenderable = static_cast<NodeRenderable*>(mRenderable);
+ mNxActorUserData->RenderPtr = this;
+ mDeltaPose = mLastPose = getGlobalPose();
+
+
+ mOwner->getSceneRenderer()->registerSource(this);
+
+#if 0
+
if (params.mNodeName.length() == 0) {
mNode = mOwner->getSceneManager()->createSceneNode();
}
@@ -77,13 +124,10 @@
NxString entityName = mVisualIdentifier.substr(8, entityName.length() - 8);
Ogre::StringUtil::trim(entityName);
mEntity = mOwner->getSceneManager()->getEntity(entityName);
- mNode->attachObject(mEntity);
-
}
else if (Ogre::StringUtil::endsWith(mVisualIdentifier, ".mesh")) {
mEntity = mOwner->getSceneManager()->createEntity(mName + "-0", mVisualIdentifier);
mEntity->setCastShadows(params.mNodeShadows);
- mNode->attachObject(mEntity);
}
if (mActor->getMass() == 0 && mOwner->getStaticGeometry()) {
@@ -91,6 +135,14 @@
mOwner->getStaticGeometry()->addSceneNode(mNode);
}
+ if (params.mNodePose.isZero() && mEntity && mNode) {
+ mNode->attachObject(mEntity);
+ }
+ else if (mEntity && mNode) {
+ Ogre::SceneNode* childNode = mNode->createChildSceneNode(params.mNodePose.getVector3(), params.mNodePose.getQuaternion());
+ childNode->attachObject(mEntity);
+ }
+
if (params.mNodeScale != Ogre::Vector3(1,1,1)) {
mNode->scale(params.mNodeScale);
}
@@ -100,13 +152,39 @@
mNode->setOrientation(pose);
}
+#endif
+}
+Body::Body(const NxString& identifier, Scene* scene, ShapeBlueprint *firstShapeDescription, const Pose& pose, NodeRenderableParams visualParams, ActorParams params)
+: Actor(identifier, scene, firstShapeDescription, pose, params)
+{
+
+ if (visualParams.Intent.size() == 0)
+ visualParams.Intent = getStringType();
+
+ setLevelOfDetail(LOD_High);
+ setInterpolation(I_Absolute);
+ mLastPoseCount = 0;
+ mRenderable = mOwner->getSceneRenderer()->createNodeRenderable(visualParams);
+ mNodeRenderable = static_cast<NodeRenderable*>(mRenderable);
+ mNxActorUserData->RenderPtr = this;
+
+
+ mOwner->getSceneRenderer()->registerSource(this);
}
//////////////////////////////////////////////////////////
Body::~Body() {
+ mOwner->getSceneRenderer()->unregisterSource(this);
+
+ if (mRenderable) {
+ delete mRenderable;
+ mRenderable = 0;
+ }
+
+#if 0
if (mNode == 0)
return;
@@ -129,26 +207,131 @@
if (mNode)
mOwner->getSceneManager()->destroySceneNode(mNode->getName());
+#endif
}
//////////////////////////////////////////////////////////
-void Body::simulate(float dT) {
- shapeSimulate(dT);
+void Body::__renderSelf() {
+
+ switch (mInterpolation) {
+ case I_Absolute:
+ {
+ mDeltaPose = getGlobalPose();
+ mRenderable->setPose(mDeltaPose);
+ mLastPose = mDeltaPose;
+ }
+ break;
+
+ case I_Linear:
+ {
+ Pose blended_pose = NxInterpolate(mLastPose, getGlobalPose(), mOwner->getLastAlphaValue());
+ mLastPose = getGlobalPose();
+ mRenderable->setPose(blended_pose);
+ }
+ break;
+
+ case I_Linear_x4:
+ {
+ mLastPoseCount++;
+
+ if (mLastPoseCount == 4) {
+
+ mDeltaPose = getGlobalPose();
+
+ if (mDeltaPose.v != mLastPose.v) {
+ mDeltaPose = NxInterpolate(mDeltaPose, mLastPose);
+ mLastPose = getGlobalPose();
+ mLastPoseCount = 0;
+ }
+ else {
+ mLastPoseCount--;
+ mDeltaPose = mLastPose;
+ }
+
+ }
+
+ mRenderable->setPose(mDeltaPose);
+ }
+ break;
+
+ case I_Linear_x8:
+ {
+ mLastPoseCount++;
+
+ if (mLastPoseCount == 8) {
+
+ mDeltaPose = getGlobalPose();
+
+ if (mDeltaPose.v != mLastPose.v) {
+ mDeltaPose = NxInterpolate(mDeltaPose, mLastPose);
+ mLastPose = getGlobalPose();
+ mLastPoseCount = 0;
+ }
+ else {
+ mLastPoseCount--;
+ mDeltaPose = mLastPose;
+ }
+
+ }
+
+ mRenderable->setPose(mDeltaPose);
+ }
+ break;
+ }
+
}
//////////////////////////////////////////////////////////
-void Body::render(float) {
+#if 0
+void Body::renderTo(const Pose& pose) {
+ mNode->setPosition(pose);
+ mNode->setOrientation(pose);
+}
+#endif
+
+//////////////////////////////////////////////////////////
+
+
+/*
+void Body::render(float dT) {
+
#if (NX_UNSTABLE_USE_SCENE_ACTIVE_TRANSFORM == 1)
+#if (NX_UNSTABLE_ACCUMULATOR == 1)
+
+ #define alpha dT
+ assert ( alpha >= 0.0f && alpha <= 1.0f );
+
NxMat34 nm = mActor->getGlobalPose();
+ NxVec3 destPos = nm.t;
+ NxQuat destOri = nm.M;
+
+ NxVec3 renderPos = mPreviousPosition * ( 1.0f - alpha ) + destPos * alpha;
+ NxQuat renderOri;
+ renderOri.slerp( alpha , mPreviousOrientation, destOri );
+
+ mNode->setPosition( NxConvert<Ogre::Vector3, NxVec3>(renderPos) );
+ mNode->setOrientation( NxConvert<Ogre::Quaternion, NxQuat>(renderOri) );
+
+ mPreviousPosition = destPos;
+ mPreviousOrientation = destOri;
+
+ shapeRender(0.0f);
+
+#else
+
+ NxMat34 nm = mActor->getGlobalPose();
NxVec3 nv(nm.t);
NxQuat nq(nm.M);
mNode->setPosition(nv.x, nv.y, nv.z);
mNode->setOrientation(nq.w,nq.x,nq.y,nq.z);
shapeRender(0);
+
+#endif
+
#else
if (mActor && mNode) {
mNode->setPosition(getGlobalPosition());
@@ -156,8 +339,10 @@
shapeRender(dT);
}
#endif
+
}
-
+*/
+#if 0
//////////////////////////////////////////////////////////
void Body::setNode(Ogre::SceneNode* node) {
@@ -314,4 +499,24 @@
//////////////////////////////////////////////////////////
+#endif
+
+
+
+StringPairList Body::saveCustom() {
+
+ // Temp
+ StringPairList l;
+ return l;
+}
+
+//////////////////////////////////////////////////////////
+
+void Body::restoreCustom(StringPairList spl) {
+
+ // TEMP
+}
+
+//////////////////////////////////////////////////////////
+
} //End of NxOgre namespace.
Modified: trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.h
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.h 2007-12-17 18:04:28 UTC (rev 512)
+++ trunk/python-ogre/ThirdParty/nxogre/NxOgreBody.h 2007-12-26 14:29:56 UTC (rev 513)
@@ -22,35 +22,65 @@
#include "NxOgrePrerequisites.h"
#include "NxOgreActor.h" // For: Body inherits Actor
+#include "NxOgrePose.h"
+#include "NxOgreRenderableSource.h"
+#include "NxOgreRenderable.h"
+#include "NxOgreNodeRenderable.h"
namespace NxOgre {
- class NxExport Body : public Actor {
+ class NxExport Body : public Actor, public RenderableSource {
public:
- Body(const NxString& name, Scene*);
- Body(const NxString& name, Scene*, ShapeBlueprint*, const Pose&, ActorParams = ActorParams());
+ Body(const NxString& NameAndOrShorthandVisualIdentifier, Scene*);
+
+ /** @brief Body constructor with limited short-hand visualisation specification.
+ How the body is visualised is built into the identifier.
+
+ - "myBody"
+ No Visualisation
+
+ - "myBody; cow.mesh"
+ Visualisation as "cow.mesh" as the graphics model loading it from
+ the rendersystems resource system.
+ (Default behaviour)
+
+ - "myBody; (reference) cow.mesh"
+ Visualisation as "cow.mesh" from a pre-existing model that has
+ already been loaded and in the scene already.
+ (Moving it from one visualisation node to this one)
+ */
+ Body(const NxString& Identifier, Scene*, ShapeBlueprint*, const Pose&, ActorParams = ActorParams());
+
+ /** Body constructor with full visualisation.
+
+ mSceneMgr->createBody("myBody", new CubeShape(2,2,2), Vector3(0,5,0), "model: cube.1m.mesh, scale: 2 2 2", "mass: 10");
+
+ */
+ Body(const NxString& Identifier, Scene*, ShapeBlueprint*, const Pose&, NodeRenderableParams, ActorParams = ActorParams());
+
+ /** @brief Body destructor. If you hate memory leaks and crashes, use mScene->destroyActor(...);
+ */
+
virtual ~Body();
- virtual bool hasVisualisation() const {return true;}
- Ogre::SceneNode* getNode() {return mNode;}
- Ogre::Entity* getEntity() {return mEntity;}
- void setNode(Ogre::SceneNode*);
- void setEntity(Ogre::Entity*);
- void simulate(float);
- void render(float);
+ NxShortHashIdentifier getType() const {return NxHashes_Body; /* "NxOgre-Example-Body" */}
+ NxString getStringType() const {return "NxOgre-Example-Body";}
+
StringPairList saveCustom();
void restoreCustom(StringPairList);
- void disableVisualisation();
protected:
- Ogre::SceneNode* mNode;
- Ogre::Entity* mEntity;
+ void __renderSelf();
+ NodeRenderable* mNodeRenderable;
+
+
+
};
};
Modified: trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.cpp 2007-12-17 18:04:28 UTC (rev 512)
+++ trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.cpp 2007-12-26 14:29:56 UTC (rev 513)
@@ -19,306 +19,77 @@
#include "NxOgreStable.h"
-#if (NX_USE_CHARACTER_API == 1)
+#if (NX_USE_LEGACY_NXCONTROLLER == 0)
#include "NxOgreCharacter.h"
-#include "NxOgrePose.h" // For: Character position and orientation
-#include "NxOgreCharacterController.h" // For: HitReport and Character creation
-#include "NxOgreScene.h" // For: getNxScene in Scene
-#include "NxOgreHelpers.h" // For: NxVec3 to Vector3 conversion
-#include "NxOgreUserData.h" // For: Actor's UserData
+#include "NxOgreScene.h"
+#include "NxOgreNxActorController.h"
-#include "NxCharacter.h"
-#include "NxBoxController.h"
-#include "NxCapsuleController.h"
+#if (NX_USE_CHARACTER_API == 1)
+# include "NxOgreNxCharacterController.h"
+#endif
namespace NxOgre {
-////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////
-Character::Character(const NxString &name, Scene* scene, CharacterController* cc, Pose p , CharacterParams cp)
-: mName(name), mScene(scene), mCharacterController(cc), mNode(0), mEntity(0) {
-
- mMoveVectorController = mCharacterController;
- mCharacterController->_registerCharacter(mName, this);
- mType = cp.mType;
- mDimensions = cp.mDimensions;
- mUpAxis = cp.mUpAxis;
- mSlopeLimit = cp.mSlopeLimit;
- mStepOffset = cp.mStepOffset;
- mSkinWidth = cp.mSkinWidth;
- mMove_ActiveGroupsMask = cp.mActiveGroupsMask;
- mMove_Sharpness = cp.mSharpness;
- mMove_GroupMask = cp.mGroupMask;
- mNextMovementDirection.zero();
- mDirection.id();
- mMass = 100; /// TEMP.
+void CharacterParams::setToDefault() {
- if (mType == CharacterParams::CT_Box) {
+#if (NX_USE_CHARACTER_API == 1)
+ mControllerType = CT_NXCONTROLLER;
+#else
+ mControllerType = CT_NXACTOR;
+#endif
- NxBoxControllerDesc desc;
- desc.setToDefault();
- desc.position.set(p.v.x,p.v.y,p.v.z); // 0,0,0
- desc.extents.set(mDimensions.x * 0.5f, mDimensions.y * 0.5f, mDimensions.z * 0.5f); // 0.5, 1, 0.5
- desc.upDirection = mUpAxis; // NX_Y
- desc.slopeLimit = mSlopeLimit; // 0.707
- desc.stepOffset = mStepOffset; // 0.5
- desc.skinWidth = mSkinWidth; // 0.1
- desc.callback = mCharacterController;
- desc.userData = this;
-
- mCharacter = mCharacterController->mControllerManager->createController(mScene->getNxScene(), desc);
+ mStepOffset = 0.0f;
+ mSlopeLimit = 0.0f;
+ mUpDirection = NX_AXIS_PLUS_Y;
+ //mGroupMask;
+ mControllerCollisionShape = 0;
- }
- else {
+}
- NxCapsuleControllerDesc desc;
- desc.setToDefault();
- desc.radius = mDimensions.x;
- desc.height = mDimensions.y;
- desc.position.set(p.v.x,p.v.y,p.v.z); // 0,0,0
- desc.upDirection = mUpAxis; // NX_Y
- desc.slopeLimit = mSlopeLimit; // 0.707
- desc.stepOffset = mStepOffset; // 0.5
- desc.skinWidth = mSkinWidth; // 0.1
- desc.callback = mCharacterController;
- desc.userData = this;
+/////////////////////////////////////////////////////////////
- mCharacter = mCharacterController->mControllerManager->createController(mScene->getNxScene(), desc);
-
- }
+Character::Character(NxString identifier, Pose pose, CharacterModel* model, CharacterParams params, CharacterController* character_controller, Scene* scene) {
- if (mCharacter == 0) {
- NxThrow_Error("Character '" + mName + "' could not be created.");
+ if (model == 0) {
+ NxThrow_Error("Character Model pointer is null!");
+ mDead = true;
return;
}
- mNxActorUserData = new NxActorUserData(this, NxActorUserData::T_Character);
- mCharacter->getActor()->setGroup(0);
- mCharacter->getActor()->userData = mNxActorUserData;
- mCharacter->setCollision(true);
-
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-Character::~Character() {
-
- mCharacterController->_unregisterCharacter(mName);
- mCharacterController->mControllerManager->releaseController(*mCharacter);
-
- if (mNode == 0)
+ if (params.mControllerType == CharacterParams::CT_CUSTOM && character_controller == 0) {
+ NxThrow_Error("ControllerType is Custom but pointer is null!");
+ mDead = true;
return;
-
-
- Ogre::SceneNode::ObjectIterator object_it = mNode->getAttachedObjectIterator();
- Ogre::MovableObject *m;
- while(object_it.hasMoreElements()) {
- m = object_it.getNext();
- if (m->getMovableType() == "Entity") {
- mScene->getSceneManager()->destroyEntity((Ogre::Entity*) m);
- }
- else {
- mNode->detachObject(m);
- mScene->getSceneManager()->getRootSceneNode()->attachObject(m);
- }
}
- mNode->detachAllObjects();
- mNode->removeAndDestroyAllChildren();
-
- if (mNode)
- mScene->getSceneManager()->destroySceneNode(mNode->getName());
-
- delete mNxActorUserData;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::simulate(float t) {
-
- NxVec3 moveVector, gravity;
- moveVector.zero();
- mScene->getNxScene()->getGravity(gravity);
-
- // Calculate next movement.
- mMoveVectorController->move(moveVector, mNextMovementDirection, mDirection, gravity, t, this);
-
- // Move it
- mCharacter->move(moveVector, mMove_ActiveGroupsMask, mMove_MinDistance, mCollisionFlags, mMove_Sharpness, &mMove_GroupMask);
-
- // ...And reset.
- mNextMovementDirection.zero();
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::render(float) {
- if (mNode) {
- mNode->setPosition(getGlobalPosition());
- mNode->setOrientation(getGlobalOrientation());
+ mName = identifier;
+
+ if (params.mControllerType == CharacterParams::CT_NXACTOR) {
+ mController = new NxActorController(pose.toMat34(), params.mControllerCollisionShape, scene->getNxScene());
}
-}
+#if (NX_USE_CHARACTER_API == 1)
+ else if (params.mControllerType == CharacterParams::CT_NXCONTROLLER) {
+ mController = new NxCharacterController(pose.toMat34(), params.mControllerCollisionShape, scene->getNxScene());
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::createNode() {
- if (mNode)
- return;
- mNode = mScene->getSceneManager()->getRootSceneNode()->createChildSceneNode(mName, toVector3(NxVec3(mCharacter->getPosition().x,mCharacter->getPosition().y,mCharacter->getPosition().z)));
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::attachMesh(const NxString& meshName) {
-
- createNode();
-
- if (mEntity == 0) {
- mEntity = mScene->getSceneManager()->createEntity(mName, meshName);
- mNode->attachObject(mEntity);
}
+#endif
else {
- Ogre::Entity* entity = mScene->getSceneManager()->createEntity(mName, meshName);
- mNode->attachObject(entity);
+ mController = character_controller;
}
-}
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::attachSkeletonMesh(const NxString&) {
- NxUnderConstruction;
}
-////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////
-void Character::bindToAnimation(Movement, const NxString& AnimationName) {
- NxUnderConstruction;
-}
+Character::~Character() {
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::bindFeet(const NxString& leftBone, const NxString& rightBone) {
- NxUnderConstruction;
}
-////////////////////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////
-void Character::unBindFeet() {
- NxUnderConstruction;
}
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-Ogre::Vector3 Character::getGlobalPosition() {
- return toVector3(NxVec3(mCharacter->getPosition().x, mCharacter->getPosition().y,mCharacter->getPosition().z));
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-Ogre::Quaternion Character::getGlobalOrientation() {
- return toQuaternion(mDirection);
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::setRawNextMovementDirection(const NxVec3& direction) {
- mNextMovementDirection = direction;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::setDirection(const Ogre::Radian &r) {
- mDirection.fromAngleAxis(r.valueAngleUnits(),NxVec3(0,1,0));
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::setDirection(const Ogre::Quaternion &q) {
- mDirection = toNxQuat(q);
- mDirection.x = 0;
- mDirection.z = 0;
-
- mDirection.normalize();
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::addMovement(Direction m) {
-
- if (mUpAxis == NX_Y) {
-
- switch (m) {
- case DR_Forward:
- mNextMovementDirection -= NxVec3Axis[NX_X];
- return;
- break;
-
- case DR_Backward:
- mNextMovementDirection += NxVec3Axis[NX_X];
- return;
- break;
-
- case DR_StepLeft:
- mNextMovementDirection -= NxVec3Axis[NX_Z];
- return;
- break;
-
- case DR_StepRight:
- mNextMovementDirection += NxVec3Axis[NX_Z];
- return;
- break;
-
- case DR_Jump_Up:
- // jump inject code
- mNextMovementDirection.zero();
- // jump timer++
- // pass jump timer onto move bit as well.
- break;
-
- case DR_Ladder_Up:
- mNextMovementDirection += NxVec3Axis[NX_Y];
- return;
- break;
-
- case DR_Ladder_Down:
- mNextMovementDirection -= NxVec3Axis[NX_Y];
- return;
- break;
-
- }
-
- return;
- }
- else if (mUpAxis == NX_X) {
- // TODO
- }
- else if (mUpAxis == NX_Z) {
- // TODO
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::setMovementVectorController(CharacterMovementVectorController* cmvc) {
- mMoveVectorController = cmvc;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void Character::setPosition(const Ogre::Vector3& v) {
- mCharacter->setPosition(toNxExtendedVec3(v));
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-void CharacterMovementVectorController::move(NxVec3 &out, NxVec3 &moveVector, NxQuat &direction, NxVec3 &g, float t, Character*) {
- // TODO: Non NX_Y directions.
- out = ((direction.rot(moveVector) * 1.5) + g) * t;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////////////
-
-} //End of NxOgre namespace.
-
-#endif
+#endif
Modified: trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.h
===================================================================
--- trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.h 2007-12-17 18:04:28 UTC (rev 512)
+++ trunk/python-ogre/ThirdParty/nxogre/NxOgreCharacter.h 2007-12-26 14:29:56 UTC (rev 513)
@@ -19,138 +19,176 @@
#ifndef __NXOGRE_CHARACTER_H__
#define __NXOGRE_CHARACTER_H__
-#if (NX_USE_CHARACTER_API == 1)
#include "NxOgrePrerequisites.h"
-#include "NxOgreContainer.h" // For: mCollisionList
-#include "NxOgreParams.h" // For: CharacterParams
+#if (NX_USE_LEGACY_NXCONTROLLER == 0)
+
+#incl...
[truncated message content] |