Grom
14-03-2007 12:01:49
for vehicles, is it better to load the tires as separate meshes so that they can rotate independently of the body? Or is there some better method of mesh's (perhaps with bones or sub-meshes) that I don't know about.
Grom
14-03-2007 12:01:49
betajaen
14-03-2007 12:06:40
luis
14-03-2007 15:06:05
Grom
14-03-2007 19:05:44
betajaen
14-03-2007 19:26:39
Grom
15-03-2007 13:44:45
I can provide the wheel mesh if you need a reference of the correct wheel orientation when modelling
betajaen
15-03-2007 13:48:19
betajaen
15-03-2007 14:08:50
/*
#####################################################################
# #
# NxOgre Tutorial 702 : Suspension and Torque #
# #
# #
# Written by Robin Southern #
# #
#####################################################################
Preamble:
If you don't know the difference between a SceneManager and a Scene-
Node you should start with the Ogre tutorials at the Wiki[1]. As
these tutorials tend to push the Ogre code aside and deal more with
nxOgre.
[1] http://www.ogre3d.org/wiki/
Documentation and Tutorials:
- Betajaen's Guide to NxOgre, Chapter ?
- http://www.nxogre.org/NxTutorial102
- PhysX Training Programs, Lesson 102
Keys:
- Escape Quit
- F1 Save a screenshot
- F2 Debug Rendering On
- F3 Debug Rendering Off
- I,J,K,L Apply torque to the sphere in the X or Z Axis.
- U,M Apply torque to the sphere in the Y axis.
*/
#include "nxOgre.h"
#include "Ogre.h"
#include "tutorialApplication.h"
using namespace nxOgre;
using namespace Ogre;
using namespace std;
class NxTutorial : public SimpleTutorial {
public:
world *mWorld;
scene *mScene;
body *myCube;
wheelSet myWheels;
SceneNode* testWheel;
float wheelShapeRollAngle;
SceneNode *cm;
void start() {
mWorld = new world();
mScene = mWorld->createScene("Main",mSceneMgr);
mScene->hasGravity();
mScene->hasFloor();
mScene->createStaticBody("terrain", "", new heightfieldShape("terraincm.png", 4096,4096,300,513,513));
for (int i=0;i<16;i++)
mScene->createBody("", "cube.1m.mesh", new cubeShape(1), 10, Vector3(16,8+i,16));
//mScene->createStaticBody("Slide","cube.1m.mesh",new cubeShape(Vector3(16,0.1,16)),params<rigidbody>("scale:16 0.1 16"),pose(Vector3(0,1,0),Quaternion(Radian(Degree(10)),Vector3(1,0,0))));
myCube = mScene->createBody("myCube","racecar.mesh",new cubeShape(Vector3(1,1,3)),100.0f,Vector3(2048,80,2048));
myCube->mActor->setCMassOffsetLocalPosition(NxVec3(0,-1,0));
myWheels = wheelSet::createFourWheelSet(myCube, Vector3(-1,-0.1f,1.25f), Vector3(-0.75f,-0.1f,-1.25f), 2.5f);
myWheels.addEntities("wheel50cmx10cmx50cm.mesh");
myCube->mNode->attachObject(mCamera);
mCamera->setPosition(0,0,0);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void stop() {
myCube->mNode->detachObject(mCamera->getName());
mSceneMgr->getRootSceneNode()->attachObject(mCamera);
delete mWorld;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void newFrame(float _time) {
mCamera->lookAt(myCube->getGlobalPosition());
float kph = myCube->mActor->getLinearVelocity().magnitude() * 3.6;
mCaption3->setCaption("KPH " + StringConverter::toString(kph));
if (isKeyDown(X)) {
myWheels.turn(Degree(1));
}
else if (isKeyDown(NEG_X)) {
myWheels.turn(Degree(-1));
}
if (isKeyDown(Z)) {
myWheels.setMotorTorque(75);
}
else if (isKeyDown(NEG_Z)) {
myWheels.setMotorTorque(-75);
}
else {
myWheels.setMotorTorque(0);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void getTutorialSettings() {
mTutorialName = "702";
mTutorialDescription = "Suspension and Torque";
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void prestart() {}
void prestop() {}
void GUIbuttonPressed(BetaGUI::Button *ref) {}
//////////////////////////////////////////////////////////////////////////////////////////////////
};
TUTORIAL_VOIDMAIN("118, Suspension and Torque")
Grom
15-03-2007 16:00:10