danharibo
29-04-2007 21:56:29
I'm trying to figure out how to use the Vehicle system, but i can't seem to find any tutorials on how to use the wheel class, i found some threads about it, but they aint making sense to me. so can someone show me a tutorial or how to use it?
betajaen
29-04-2007 22:09:39
Did you miss NxTutorials 701 and 702?
Remember, the Ageia tutorial numbers are the same as the NxOgre ones - If need help, find the Ageia tutorial number then you have the NxOgre tutorial number to look at.
danharibo
29-04-2007 22:42:52
There is no 702 in the nXOgre tutorials. (I know there is going to be one in the physX tutorials).
betajaen
29-04-2007 22:48:37
Then try this
small sample on how to use the wheelSet.
I took out the code there because I don't really want copies of the tutorials floating around, and my email address publicly on view for every tom, dick and webcrawler around here to spam me to death.
If you REALLY REALLY need copies of 701 and 702. I mean life and death here, I'll post them up.
danharibo
30-04-2007 17:58:33
Then try this small sample on how to use the wheelSet.
I took out the code there because I don't really want copies of the tutorials floating around, and my email address publicly on view for every tom, dick and webcrawler around here to spam me to death.
If you REALLY REALLY need copies of 701 and 702. I mean life and death here, I'll post them up.
It's rather important, because the game rathar revolves around wheeled vehicles.
betajaen
30-04-2007 18:13:27
701
#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;
wheel* myWheel;
void start() {
mWorld = new world();
mScene = mWorld->createScene("Main",mSceneMgr);
mScene->hasGravity();
mScene->hasFloor();
myCube = mScene->createBody(
"myCube",
"cube.1m-2m-1m.mesh",
new cubeShape(Vector3(1,1,2)),
1.0f,
params<rigidbody>("orientation:0.707106781 0.707106781 0 0"),
Vector3(0,3.5,0)
);
myCube->freezeRotation(Vector3(1,0,1));
myCube->setAngularDamping(0.5f);
myWheel = wheel::attachToBody(myCube, Vector3(0,-1,0));
//myWheel->addEntity("wheel50cmx10cmx50cm.mesh");
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void stop() {
// Time to go, better tell NxOgre we are leaving.
delete mWorld;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void newFrame(float _time) {
if (targetBody == 0)
return;
if (isKeyDown(Z)) {
targetBody->addTorque(Ogre::Vector3(0,0,150));
}
if (isKeyDown(NEG_Z)) {
targetBody->addTorque(Ogre::Vector3(0,0,-150));
}
if (isKeyDown(X)) {
targetBody->addTorque(Ogre::Vector3(150,0,0));
}
if (isKeyDown(NEG_X)) {
targetBody->addTorque(Ogre::Vector3(-150,0,0));
}
if (isKeyDown(Y)) {
targetBody->addTorque(Ogre::Vector3(0,150,0));
}
if (isKeyDown(NEG_Y)) {
targetBody->addTorque(Ogre::Vector3(0,-150,0));
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void prestart() {}
void prestop() {}
void GUIbuttonPressed(BetaGUI::Button *ref) {}
//////////////////////////////////////////////////////////////////////////////////////////////////
};
TUTORIAL_VOIDMAIN("701, Wheels");
702
#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));
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")
danharibo
05-05-2007 17:17:02
I Might be missing something here, but is there a way to attach a wheel to a wheelset?
betajaen
05-05-2007 18:22:57
If you mean through a fancy factory method then no...
But you could do it this way:
mWheelset.mWheels.push_back(mBody->addShape(new wheel(blah)));
Same thing really.
danharibo
05-05-2007 18:58:56
If you mean through a fancy factory method then no...
But you could do it this way:
mWheelset.mWheels.push_back(mBody->addShape(new wheel(blah)));
Same thing really.
Ah thanks, All these classes are hurting my little brain!