How to make a vehicle in BloodyMess?

James

11-01-2010 07:31:20

I read the vehicles codes from PhysX samples , but i have no idea on how to use bloodymess for it. I'm confused by machine/machinePart/wheel...
anyone help me? thanks!

hevi

19-01-2010 11:43:54

I have exactly the same question in mind!
I remember that setting up a vehicle in previous versions of NxOgre was quite simple but I couldn't sort it out in BloodyMess...
Could someone please post an example of setting up a vehicle (of course if it is possible in the current release of BloodyMess)?

Thanks a lot.

spacegaier

19-01-2010 11:59:27

Have a look at BloodyCake. There is a vehicle in it.

EDIT: Here is the link to the latest BloodyCake I found (for 1.5.4): Click me to bake a cake!

hevi

19-01-2010 12:28:07

thanks mate!

hevi

19-01-2010 20:06:49

I read the vehicles codes from PhysX samples , but i have no idea on how to use bloodymess for it. I'm confused by machine/machinePart/wheel...
anyone help me? thanks!


Well I couldn't find anything in the bloodycake about vehicles or something related
But I found this piece of code from one of betajaens's posts viewtopic.php?f=6&t=10348&p=59499&hilit=wheels#p59499
thanks to betajean

class Car : public NxOgre::Machine
{
public:

Car(const Vec3& position, Scene* scene, OGRE3DRenderSystem* renderSystem) : Machine(), mScene(scene), mRenderSystem(renderSystem)
{

RigidBodyDescription description;

description.mMass = 1000; // Make it heavy.
description.mWakeUpCounter = 1E8; // Never go to sleep.

NxOgre::Shapes shapes;
mChassisShape = new NxOgre::Box(0.751, 0.275, 3.0);
shapes.insert(mChassisShape);

addWheel(Vec3(-0.5,0,1), true, true, true);
addWheel(Vec3(0.5,0,1), true, true, true);
addWheel(Vec3(-0.5,0,-1), false, false, true);
addWheel(Vec3(0.5,0,-1), false, false, true);

for (unsigned int i=0;i < mWheels.size();i++)
shapes.insert(mWheels[i].mWheel);

mActor = mScene->createActor(shapes, position, description);

mPointRenderable = mRenderSystem->createPointRenderable("photon-frame.mesh");

mScene->registerMachine(this);
}

~Car()
{
mScene->unregisterMachine(this);
}

void addWheel(const Vec3& position, bool driving, bool steering, bool braking)
{
CarWheel w;

// Create the physics wheel, which our rules and point renderable will represent and work with.
WheelBlueprint* blueprint = new WheelBlueprint();
blueprint->mRadius = 0.433f * 0.5f;
blueprint->mLocalPose.set(position);
w.mWheel = new Wheel(blueprint);

// Create our rules about this wheel.
w.mDriving = driving;
w.mSteering = steering;
w.mBraking = braking;

mWheels.insert(w);

// Then create the machine part of that wheel, so rules can be applied to it, and it can be rendered.
createWheelMachinePart(w.mWheel, mRenderSystem->createPointRenderable("photon-wheel.mesh"));
}

void drive(float torque)
{
for (unsigned int i=0;i < mWheels.size();i++)
if (mWheels[i].mDriving)
mWheels[i].mWheel->setMotorTorque(torque);
}

void brake(float torque)
{
for (unsigned int i=0;i < mWheels.size();i++)
if (mWheels[i].mBraking)
mWheels[i].mWheel->setBrakeTorque(torque);
}

void steer(float angle)
{
for (unsigned int i=0;i < mWheels.size();i++)
if (mWheels[i].mSteering)
mWheels[i].mWheel->setSteeringAngle(angle);
}

protected:

struct CarWheel
{
Wheel* mWheel;
bool mDriving;
bool mSteering;
bool mBraking;
};

NxOgre::Array<CarWheel> mWheels;

Scene* mScene;
OGRE3DRenderSystem* mRenderSystem;
NxOgre::Box* mChassisShape;
};

James

22-01-2010 08:50:46

thanks,It's helpful!