Big problem with vehicle - Please help

mujtaba

04-01-2007 11:37:43

0 - I am extremely out of time, I need to finish this code in 3 days and I have little experience with PhysX.
1 - Is vehicle functional with NxOgre ? Or I have to use PhysX directly ?
2 - I have a jeep model (burrowed it from OgreODE :D ),the body and wheels are separate .mesh models.
I want to make a jeep !
I tried using Motorised Joints, everything works,but I couldn't make it the wheels to steer.How can I make the MeshShape of the Wheel steer ? Changing the Axis and the wheels direction didn't help.Breaking/deleteing and reattaching the joint gave me access violation.
If I want to use the vehicle class,Is it easy ? Is it implemented in nxogre?
I also tried using NXWheel and MeshGroups, everything worked,but how I can make the Entity of the wheel (it's .mesh visual model) to rotate with the NxWheel Object.

6 - I also wanted to implement a simplistic helicopter (nothing real about it just something hanging in mid-air , does just using Addforce(helishape->mass * 9.8) work ...

Thanks for help.

betajaen

04-01-2007 11:59:51

0 - I am extremely out of time, I need to finish this code in 3 days and I have little experience with PhysX.

Ouch.


1 - Is vehicle functional with NxOgre ? Or I have to use PhysX directly ?


You can create a vehicle through NxOgre, it'll be easier.

2 - I have a jeep model (burrowed it from OgreODE :D ),the body and wheels are separate .mesh models.
I want to make a jeep !
I tried using Motorised Joints, everything works,but I couldn't make it the wheels to steer.How can I make the MeshShape of the Wheel steer ? Changing the Axis and the wheels direction didn't help.Breaking/deleteing and reattaching the joint gave me access violation.


Please don't tell me your using a meshShape as part of the car. Collision Primitives ONLY!

If I want to use the vehicle class,Is it easy ? Is it implemented in nxogre?
I also tried using NXWheel and MeshGroups, everything worked,but how I can make the Entity of the wheel (it's .mesh visual model) to rotate with the NxWheel Object.


The vehicle class is quite quite old, and the code for it, probably won't work with the newest NxOgre.

This example (second code block) shows you how to use the WheelShape with NxOgre. It's really simple create your car chassis (a cube), then attach the WheelShapes to them. Keep a copy of the NxWheelShape points somewhere and use them to move and turn the car around.

I also wanted to implement a simplistic helicopter (nothing real about it just something hanging in mid-air , does just using Addforce(helishape->mass * 9.8) work ...


Thats basically the physics behind it, if you want to cheat you could turn off gravity or increase the damping for that body. If you really want to cheat check out the levitator example.


I'm sorry, if I can't be anymore help. But most of these questions have been answered before and can be found via searching, and the others are answered in the tutorials.

mujtaba

04-01-2007 12:12:19

Your a life saver. :D
Shame that PhpBB doesn't have rep system...
So : God bless you...

mujtaba

05-01-2007 12:20:53

Now I have made a ShapeGroup with the CarBody (CubeMesh) and 4 WheelShapes, I simply added the WheelShapes to the WheelGroups,now : how can I attach the Wheel's mesh models , entities to the WheelShapes
This simply made the Jeep do stupid things :
WheelBody[0] = CreateBody("LeftWh","jeep_lwheel.mesh",wheelshape[0],....)

this made the wheelshape get de-attached... :(

And this one :
MyShapeGroup->addentity(...)
Attaches the WheelEntity but Obviously the shape won't rotate... :cry:

-----------------------------------------------------------------------
Getting deparate, I tried using MotorisedJoints, no luck with the steering. :x

What am I going to do ??? :cry:

betajaen

05-01-2007 12:28:13

I thought the code shown was pretty clear.

However, show me the full code of the shapegroup, wheelShape and body creation code.

mujtaba

05-01-2007 12:42:05

mWorld = new world(mRoot);
nxOgre::scene* mScene = mWorld->createScene("Main",mSceneMgr);


mScene->hasGravity();
mScene->hasFloor();
mSceneMgr->setFog(Ogre::FOG_NONE);
// body * ls = mScene->createStaticBody("Landscape","landscape.mesh",new meshShape("landscape.mesh",mScene),pose(Vector3(0,6,0)));
// ls->mNode->setScale(Vector3(5,1,5));

material * wheelmat = mScene->createMaterial("wheel_material",0.7,0.8,0);

mWorld->pause();

wh[0] = new wheelShape(2.4,Vector3( 1,0.0+h0,1.8));
wh[1] = new wheelShape(2.4,Vector3(-1,0.0+h0,1.8));
wh[2] = new wheelShape(2.4,Vector3( 1,0.0+h0,-1.6));
wh[3] = new wheelShape(2.4,Vector3(-1,0.0+h0,-1.6));
CarShape = new shapeGroup();
cubeShape * tt = new cubeShape(1,pose(0,0.9+h0,0),wheelmat);
CarShape->addShape(tt);
for(int i =0;i < 4;i++)
CarShape->addShape(wh[i]);

CarB[0] = mScene->createBody("The Car","jeep_body.mesh",CarShape,3.0f,Vector3(0,0.9+h0,0));

CarB[1] = mScene->createBody("leftwheel1","jeep_wheell.mesh",wh[0],5);

Without the last line the jeep is stable...
But with adding the last line the wh[0] get's disconnected from the CarShape,gets thrown away (at least I can see the Wheel Entity shooting across the room)

betajaen

05-01-2007 14:03:05

The code needs to be more like this:

CarShape = new shapeGroup();

CarShape->addShape(new cubeShape(1,pose(0,0.9+h0,0),wheelmat));
wh[0] = new wheelShape(2.4,Vector3( 1,0.0+h0,1.8));
wh[1] = new wheelShape(2.4,Vector3(-1,0.0+h0,1.8));
wh[2] = new wheelShape(2.4,Vector3( 1,0.0+h0,-1.6));
wh[3] = new wheelShape(2.4,Vector3(-1,0.0+h0,-1.6));

for(int i =0;i < 4;i++)
CarShape->addShape(wh[i]);

CarB[0] = mScene->createBody("The Car","jeep_body.mesh",CarShape,3.0f,Vector3(0,0.9+h0,0));
CarB[0]->addEntity("leftwheel1",Vector3( 1,0.0+h0,1.8))
// Etc..


Notice; Only one body. Wheels are handed over as shapes, then the meshes are loaded in as entities.

mujtaba

05-01-2007 14:45:55

My problem is exactly this :
How to make the entity roll/steer just like the WheelShape object.
This way, the entity has the same position always,
But it doesn't have the same rotation/orientation

tengil

05-01-2007 15:10:57

I tried it this way (but then the wheels fall throw the floor):

Video:
http://freenet-homepage.de/tengil001/wheels.avi



material * wheelmat = mScene->createMaterial("wheel_material",0.7,0.8,0);

mWorld->pause();

wheelShape *wh[4];
shapeGroup *CarShape;
nxOgre::body *CarB[8];

int h0 = 4;

wh[0] = new wheelShape(1.0,Vector3( 0,0.0, 0.0));
wh[1] = new wheelShape(1.0,Vector3( 0,0.0, 0.0));
wh[2] = new wheelShape(1.0,Vector3( 0,0.0, 0.0));
wh[3] = new wheelShape(1.0,Vector3( 0,0.0, 0.0));

CarB[0] = mScene->createBody("The Car","cube.1m.mesh", new nxOgre::cubeShape(Vector3(1.0f,1.0f,1.0f)),3.0f,Vector3(0,0.0+h0,0));
CarB[1] = mScene->createBody("w1","cube.1m.mesh",wh[0],5,Vector3( 3,0.0+h0, 1.0));
CarB[2] = mScene->createBody("w2","cube.1m.mesh",wh[1],5,Vector3(-3,0.0+h0, 1.0));
CarB[3] = mScene->createBody("w3","cube.1m.mesh",wh[2],5,Vector3( 3,0.0+h0,-1.0));
CarB[4] = mScene->createBody("w4","cube.1m.mesh",wh[3],5,Vector3(-3,0.0+h0,-1.0));

CarShape = new shapeGroup();
cubeShape * tt = new cubeShape(1.0,pose(0,0,0),wheelmat);
CarShape->addShape(tt);
for(int i =1;i < 5;i++)
CarShape->addShape(CarB[i]->getAllShapes()[0]);

NxU32 nbShapes = CarB[1]->mActor->getNbShapes();
NxShape*const* shapes = CarB[1]->mActor->getShapes();

while (nbShapes--) {
if (shapes[nbShapes]->isWheel()) {
NxWheelShape *theWheel = reinterpret_cast<NxWheelShape*>(shapes[nbShapes]);
theWheel->setMotorTorque(250.0f);
}
}

nbShapes = CarB[2]->mActor->getNbShapes();
shapes = CarB[2]->mActor->getShapes();

while (nbShapes--) {
if (shapes[nbShapes]->isWheel()) {
NxWheelShape *theWheel = reinterpret_cast<NxWheelShape*>(shapes[nbShapes]);
theWheel->setMotorTorque(250.0f);
}
}


mWorld->resume();

betajaen

05-01-2007 16:15:21

Well of course they would, you have to attach the wheelShape to body that has a shape (non-wheelShape in it), such as a cube for the chassis.

mujtaba

05-01-2007 16:32:30

This settles it then.

tengil

06-01-2007 14:58:31

Hi!

Sorry, I do not understand it...

How to do this (Video-Link) is quite clear, but how can I add the visible wheels (in my case the other four cubes as Entity or Body) to it, in such a way that they will turn and so on?

regards
Tengil

betajaen

06-01-2007 18:27:38

Easiest way is to add them as scenenodes to the mNode of the car body, and set the position and orientation of them each frame.

On a similar note, I've made some good additions to the wheel system now, which will be in the next release:

myCube = mScene->createBody("myCube","cube.1m.mesh",new cubeShape(1),1.0f,Vector3(0,3.5,0));

wheelShape::attachFourWheelsToBody(myCube, Vector3(-1,0,-1), Vector3(-1,0,1));


And some other functions as:

wheels myWheels = wheel::getWheelsFromBody(mBody)
myWheels.frontLeft.setTorque(100);
myWheels.frontRight.setTorque(100);


And so on...

Toby

07-01-2007 10:18:56

Hi, I do like this for my vehicle. I am inspire of vehicle_bluePrint class in nxOgre0.3. a vehicle class contains nxOgre body, Ogre SceneNode motor class, gear class, wheel class.

create a body :
std::vector<Vector3> Verts;
//fill in it with coords

mShape->addShape(new convexShape(Verts, NULL, Vector3(0.0,-0.3,0.0)));
mBody = nxScene->createBody(mName+StringConverter::toString(mIndex),
mName+".chassis.mesh",
mShape,
40.0f,
_pos);

//Set and We down center of mass in order to keep car on its wheels
mBody->mActor->setMass(mMass);
mBody->mActor->setCMassOffsetLocalPosition(mCenterOfMass);

NxTireFunctionDesc lngTFD;
lngTFD.extremumSlip = 1.0f;
lngTFD.extremumValue = 0.02f;
lngTFD.asymptoteSlip = 2.0f;
lngTFD.asymptoteValue = 0.01f;
lngTFD.stiffnessFactor = 800000.0f;

NxTireFunctionDesc latTFD;
latTFD.extremumSlip = 1.0f;
latTFD.extremumValue = 0.02f;
latTFD.asymptoteSlip = 2.0f;
latTFD.asymptoteValue = 0.01f;
latTFD.stiffnessFactor = 800000.0f;


addWheel(0,Vehicle::wheel::STEER,0.682 / 2,
Vector3(1.412, -0.50, 0.886 ),mName+".wheel.l.mesh",
_owner, lngTFD, latTFD, mIndex,Ogre::Quaternion(sqrt(0.5),0,sqrt(0.5)));
addWheel(1,Vehicle::wheel::STEER,0.682 / 2,
Vector3(1.412, -0.50, -0.886 ),mName+".wheel.l.mesh", _owner, lngTFD, latTFD,
mIndex,Ogre::Quaternion(sqrt(0.5),0,sqrt(0.5)));
addWheel(2,Vehicle::wheel::DRIVE,0.682 / 2,
Vector3(-1.34 , -0.50, 0.886 ),mName+".wheel.l.mesh", _owner, lngTFD, slipTFD,
mIndex,Ogre::Quaternion(sqrt(0.5),0,sqrt(0.5)));
addWheel(3,Vehicle::wheel::DRIVE,0.682 / 2,
Vector3(-1.34 , -0.50, -0.886 ),mName+".wheel.l.mesh", _owner, lngTFD, slipTFD,
mIndex,Ogre::Quaternion(sqrt(0.5),0,sqrt(0.5)));


//setup motor
mMotor.mTorqueCurve = this->mMotor.mTorqueCurve;
NxReal maxTorque = 0;
NxI32 maxTorquePos = -1;

for (NxU32 i = 0; i < mMotor.mTorqueCurve.getSize(); i++) {

NxReal v = mMotor.mTorqueCurve.getValueAtIndex(i);
if (v > maxTorque) {
maxTorque = v;
maxTorquePos = i;
}

}

mMotor.mMaxTorque = maxTorque;
mMotor.mMaxTorquePos = maxTorquePos;
mMotor.mGearUp = mMotor.mGearUp;
mMotor.mGearDown = mMotor.mGearDown;
mMotor.mMaxRPM = mMotor.mMaxRPM;
mMotor.mMinRPM = mMotor.mMinRPM;

mMotorForce = 0;
mBreakForce = 0;

mBody->unFreezeAll();
mActive = true;
mBody->wakeUp();




In addWheel



void Vehicle::addWheel(int i, wheel::WheelType _type, float _radius, Ogre::Vector3 _pos, Ogre::String _meshName, nxOgre::scene *_scene, NxTireFunctionDesc lngTFD, NxTireFunctionDesc latTFD, unsigned int index, Ogre::Quaternion _quat) {

mWheels[i].mRadius = _radius;
mWheels[i].mOrientation = _quat;
mWheels[i].mWheelApproximation = 10;
mWheels[i].mWheelSuspension = 0.4f;//0.3f;
mWheels[i].mSpringDamping = 0.45f;
mWheels[i].mSpringBias = 0.0f;
mWheels[i].mSpringResitution = 2000;//2000;
mWheels[i].mMaxBrakeForce = 1.0f;
mWheels[i].mFrictionToFront = 0.1f;
mWheels[i].mFrictionToSide = 0.99f;
mWheels[i].mPosition = _pos;
mWheels[i].mWheelType = _type;
mWheels[i].mHasBreaks = true;
mWheels[i].mWheelShape = new wheelShape(mWheels[i].mRadius,mWheels[i].mPosition,_quat);
mWheels[i].mInitialLocalPos = _pos;

if (mWheels[i].mWheelType== NULL) {
mWheelCount = i - 1;
return;
}
else
mWheelCount++;

NxReal heightModifier = (mWheels[i].mWheelSuspension + mWheels[i].mRadius) / mWheels[i].mWheelSuspension;


mWheels[i].mWheelShape->mShapeDesc.suspension.spring = mWheels[i].mSpringResitution * heightModifier;
mWheels[i].mWheelShape->mShapeDesc.suspension.damper = mWheels[i].mSpringDamping*heightModifier;
mWheels[i].mWheelShape->mShapeDesc.suspension.targetValue = mWheels[i].mSpringBias * heightModifier;
mWheels[i].mWheelShape->mShapeDesc.radius = mWheels[i].mRadius;
mWheels[i].mWheelShape->mShapeDesc.suspensionTravel = mWheels[i].mWheelSuspension;
mWheels[i].mWheelShape->mShapeDesc.inverseWheelMass = 0.1f;
mWheels[i].mWheelShape->mShapeDesc.localPose.t = NxTools::convert(mWheels[i].mPosition);
mWheels[i].mWheelShape->mShapeDesc.localPose.M.fromQuat(NxTools::convert(mWheels[i].mOrientation));

mWheels[i].mWheel = static_cast<NxWheelShape *>(mBody->mActor->createShape(mWheels[i].mWheelShape->getShape()));

mWheels[i].mWheel->setLateralTireForceFunction(latTFD);
mWheels[i].mWheel->setLongitudalTireForceFunction(lngTFD);

mWheels[i].mType = mWheels[i].mWheelType;
mWheels[i].mHasBreaks = mWheels[i].mHasBreaks;
mWheels[i]._turnVelocity = 0;
mWheels[i]._turnAngle = 0;


mWheels[i].mNode = mBody->mNode->createChildSceneNode(mName + _meshName + ".lwheel." + StringConverter::toString(mIndex)+ Ogre::StringConverter::toString(i));
mWheels[i].mNode->setPosition(NxTools::convert(mWheels[i].mWheel->getLocalPosition()));

mWheels[i].mNode->attachObject(mBody->owner->mSceneMgr->createEntity(mName + _meshName + ".wheel." + Ogre::StringConverter::toString(i)+StringConverter::toString(mIndex),_meshName));



At each frame I update wheelNode position orientation.

bool Vehicle::simulate(float _time)
{
if (!mActive)
return true;

bool isContact = false;
NxWheelContactData contactData;

for (int i=0;i < this->mWheelCount;i++)
{
if (mWheels[i].mType == Vehicle::wheel::DRIVEANDSTEER || mWheels[i].mType == Vehicle::wheel::DRIVE)
{
mWheels[i].mWheel->setMotorTorque(mMotorForce);
}

if (mWheels[i].mHasBreaks)
{
mWheels[i].mWheel->setBrakeTorque(mBreakForce * 1500);
}

NxShape* ContactShape = mWheels[i].mWheel->getContact( contactData );

if(ContactShape != NULL)
{
isContact = true;
Vector3 mDirection = NxTools::convert(contactData.contactPoint - mWheels[i].mWheel->getGlobalPosition());
float mDistance = mDirection.length();

mWheels[i].mNode->setPosition(mWheels[i].mInitialLocalPos.x, getDriveVelocity()/100 + mWheels[i].mInitialLocalPos.y + mWheels[i].mWheel->getRadius() - mDistance, mWheels[i].mInitialLocalPos.z);


//modify grip and activate or not tire smoke
NxMaterialIndex mat = contactData.otherShapeMaterialIndex;
NxTireFunctionDesc tireFuncL = mWheels[i].mWheel->getLateralTireForceFunction();
tireFuncL.extremumSlip = tireFuncL.extremumSlip;
tireFuncL.extremumValue = tireFuncL.extremumValue;
tireFuncL.asymptoteSlip = tireFuncL.asymptoteSlip;
tireFuncL.asymptoteValue = tireFuncL.asymptoteValue;

if(mWheels[i].mType==Vehicle::wheel::DRIVE)
tireFuncL.stiffnessFactor = 50000 / contactData.lateralImpulse;
else
tireFuncL.stiffnessFactor = 50000 / contactData.lateralImpulse;
//tireFuncL.stiffnessFactor = 100000 * contactData.lateralImpulse; for ice
mWheels[i].mWheel->setLateralTireForceFunction(tireFuncL);

if((contactData.lateralImpulse>0.1 || contactData.lateralImpulse<-0.1) && getDriveVelocity()>1)
setSmokeTireEnabled(i, true);
else
setSmokeTireEnabled(i, false);


tireFuncL = mWheels[i].mWheel->getLongitudalTireForceFunction();
tireFuncL.extremumSlip = tireFuncL.extremumSlip;
tireFuncL.extremumValue = tireFuncL.extremumValue;
tireFuncL.asymptoteSlip = tireFuncL.asymptoteSlip;
tireFuncL.asymptoteValue = tireFuncL.asymptoteValue;
if(mWheels[i].mType==Vehicle::wheel::DRIVE)
tireFuncL.stiffnessFactor = 150000/contactData.longitudalImpulse;
else
tireFuncL.stiffnessFactor = 150000/contactData.longitudalImpulse;
//tireFuncL.stiffnessFactor = 4000000*contactData.longitudalImpulse; for ice

mWheels[i].mWheel->setLongitudalTireForceFunction(tireFuncL);

if((contactData.longitudalImpulse>0.08 || contactData.longitudalImpulse<-0.08) && (getDriveVelocity()>1 || mMotorForce > 0))
setSmokeTireEnabled(i, true);
else
setSmokeTireEnabled(i, false);

}
else
{

mWheels[i].mNode->setPosition(mWheels[i].mInitialLocalPos.x, mWheels[i].mInitialLocalPos.y - mWheels[i].mWheel->getSuspensionTravel() + mWheels[i].mWheel->getRadius(), mWheels[i].mInitialLocalPos.z);


setSmokeTireEnabled(i, false);
}


mWheels[i].mNode->setOrientation(NxTools::convert(mWheels[i].mWheel->getLocalOrientation()));

if(i==0 || i==2)
mWheels[i].mNode->yaw(Ogre::Degree(90) + Ogre::Radian(mWheels[i].mWheel->getSteerAngle()));
else if(i==1 || i==3)
mWheels[i].mNode->yaw(Ogre::Degree(-90) + Ogre::Radian(mWheels[i].mWheel->getSteerAngle()));

mWheels[i]._turnVelocity = mWheels[i].mWheel->getAxleSpeed()*mWheels[i].mWheel->getRadius() * NxPi;

if(!(i==0 || i==2))
mWheels[i]._turnAngle -= mWheels[i]._turnVelocity * _time ;
else
mWheels[i]._turnAngle += mWheels[i]._turnVelocity * _time ;

mWheels[i].mNode->roll(Ogre::Radian( mWheels[i]._turnAngle) );
}//end for wheels i

mBody->wakeUp();
getVelocity();

return true;
}




voilà.
If you want more precision tell me, but physX tutorial 70x answers to it. look also on physX forum in ageia site.

NickM

07-01-2007 11:13:54

Thanks for sharing that code Toby, it will come in handy for me when I get to that stage. :D

tengil

07-01-2007 21:44:00

Thnx for the code! That will make life much easier!

Tengil

devachan

20-01-2007 00:09:52

Hi, greetings to all.

I also had reached to same problems with the wheels. Thanks to all those that write in the forum giving solutions and publishing their codes. Nevertheless I have problems with the node attach to the wheel,
it works for the suspension, but this it does not work well for roll.


http://files.filefront.com/6568107
:shock: :P

the code fragment that would have to do roll

velcRoll = mDescRueda[i].mWheel->getAxleSpeed() * mDescRueda[i].mWheel->getRadius() * NxPi;
girarGrados = velcRoll * tmpo;
mDescRueda[i].mNodo->roll(-Radian(girarGrados));




all the function that updates the node void updateNodo(char modo, float tmpo){

NxShape *contactoRueda;
NxWheelContactData datoContacto;
Vector3 direccion;
float distancia,velcRoll,girarGrados;


switch(modo){
case 'R':

mDescRueda[RuedaFIz].mNodo->setOrientation(NxTools::convert(mDescRueda[RuedaFIz].mWheel->getLocalOrientation()));
mDescRueda[RuedaFIz].mNodo->yaw(Degree(90)+ Radian(mDescRueda[RuedaFIz].mWheel->getSteerAngle()));
break;
case 'T':
break;
}


for (int i = 0; i <= 2; i++){

contactoRueda = mDescRueda[i].mWheel->getContact(datoContacto);
direccion = NxTools::convert(datoContacto.contactPoint - mDescRueda[i].mWheel->getGlobalPosition());
distancia = direccion.length();
if(contactoRueda != NULL){
mDescRueda[i].mNodo->setPosition(mDescRueda[i].iniLocalPos.x,mDescRueda[i].iniLocalPos.y /*+
mDescRueda[RuedaFIz].mWheel->getRadius()*/ - distancia,mDescRueda[i].iniLocalPos.z);
}
else{
mDescRueda[i].mNodo->setPosition(mDescRueda[i].iniLocalPos.x,
mDescRueda[i].iniLocalPos.y - mDescRueda[i].mWheel->getSuspensionTravel() - mDescRueda[i].mWheel->getRadius(),
mDescRueda[i].iniLocalPos.z);
}

velcRoll = mDescRueda[i].mWheel->getAxleSpeed() * mDescRueda[i].mWheel->getRadius() * NxPi;
girarGrados = velcRoll * tmpo;
mDescRueda[i].mNodo->roll(-Radian(girarGrados));
}
}


thanks Toby.
excuses my english (google) :D

NickM

20-01-2007 09:54:48

It's hard to tell because of the language translation but your code looks ok to me...
Looking at the movie, could it be that the wheel mesh you are using doesn't have its pivot in the centre?

betajaen

20-01-2007 10:19:29

Yep, the wheel pivot isn't centered. Quite easy to fix in a modeller, reset the axis and move it to 0,0,0.

[Edit]

You can use mine just to make sure.

devachan

20-01-2007 17:11:14

Yes, is true. The problem was in blender. Move the center to (0,0,0,),it is the solution.

thanks to both. nice wheel betajaen :) ...

greetings

devachan

03-02-2007 22:16:34

Hello. I have a problem with the torque and acceleration of my vehicle.


I do not want to simulate the motor of the car, but I want to respect the maximum acceleration. For example. If my car accelerates to 2.7 m/s2, I don't know that torque should apply to achieve this acceleration (not to exceed). Somebody knows a relationship or formula to work with this.... or some idea that can help me.

greetings

devachan

08-02-2007 00:21:08

Well, I could not find a form of working the relationship torque / acceleration. I found one but the results are not near to the reality. (I think that it is not correct)

I found that one can work directly with the angular velocity of the wheel, "getAxleSpeed () "setAxleSpeed."

I get the angular velocity (w), I divide it for 2Pi and I obtain RPS revolutions per second, Then I multiply RPS for the diameter of the wheel (2Pi*Rwheel) and I obtain the linear velocity. Here I calculate the new velocity depending of the acceleration and finally I make the inverse transformation to angular velocity.

works well... better than my explanation :)

I realize that is not being applied any torque to the wheels, when I make getMotorTorque (), it returns zero. well I don't believe that this causes problems (in my case), I tell this thinking of the weight of the vehicle and the traction of the wheels. I think that now the weight and the traction don't have incidence in the simulation, since if the weight of the vehicle is 10 kg or 1500 kg the result will be the same one, the same speed on the wheels in the same time.

nevertheless the weight is important for the suspension

betajaen

08-02-2007 00:31:16

Oh, I wish I could let you have early access to the new wheel code.

Perhaps when NxOgre is a little more ready, I can have a secret early beta source only available to certain people - you included. :D

devachan

08-02-2007 14:57:09

:P That exciting !!, I will pray to the God of the brains so that recomposes yours. :)
That the force is with you :idea:

devachan

25-02-2007 21:54:35

Hi.
I have a problem with my car and I don't know for that happens. I want that my car stops in a point. When it is detained begins to slip to the sides (velocity zero). I need that it is immobile, would not be good that in a traffic light with red light, slip and change of track :)

some idea :?:

greetings.

betajaen

25-02-2007 21:59:25

Set the velocity of the body to zero or increase the dampening for a second.

devachan

25-02-2007 22:45:04

Hi Betajaen. The velocity of the body didn't work, but the increment of the dampening works very well. Thank you

devachan

26-02-2007 22:00:43

Back to the basic. Not I can apply any rotation type to the car. I have attempted several things but they don't have any effect.

something similar to the raycast tutorial Physx with some intermediate tutorial 1 of ogre

NxVec3 dirCar;
NxMat33 m;
Vector3 mDirection = nodeGoal->getPosition() - bodyCar->mNode->getPosition(); //toward where I want that the car looks
m = bodyCar->mActor->getGlobalOrientation();
m.getColumn(0,dirCar);
Quaternion quat = NxTools::convert(dirCar).getRotationTo(mDirection);
bodyCar->mNode->rotate(quat);


directly, for the bad way :x :lol:

bodyCar->mNode->yaw(Degree(XX))


neither ->pitch neither ->roll (although it doesn't correspond).
The code to assemble the car is very similar to that of Toby, with small modifications to manufacture well the car (to align the wheels) .

If is necessary my code, I can clean it to make it more comprehensible for you

[Edit]
****************
Well, I found it. The thing was with Physx.


Quaternion quat = NxTools::convert(bodyCar->mActor->getGlobalPosition()).getRotationTo(mDestination);
mbody->mActor->setGlobalOrientationQuat(NxTools::convert(quat));


there yes that yes :P
when the angle between the car and the destination is 180°, gives problems.

[Edit]
************
improved, according to intermediate tutorial 1


Vector3 vecDir = destination - bodyVehiculo->mNode->getPosition();
vecDir.normalise();
Vector3 vecOrient = bodyVehiculo->mNode->getOrientation() * Vector3::UNIT_X;
NxMat33 m2;
float prdDot;
prdDot = vecOrient.dotProduct(vecDir);
if(1.0 + prdDot < 0.0001){
m2.rotY(NxPi);
bodyVehiculo->mActor->setGlobalOrientation(m2);
}
else{

Quaternion quat = vecOrient.getRotationTo(vecDir);
bodyVehiculo->mActor->setGlobalOrientationQuat(NxTools::convert(quat));
}

devachan

17-03-2007 15:29:02

Hi. betajaen, I can ask here about materials and textures?. I know that it is not the place but I have not been lucky in the other side. 2 days I have passed attempting an example of the wiki materials and I don't achieve anything :cry: . I have asked in ogre but doesn't respond me, I believe that my questions are very basic and that confuses me more. that you say? please, it is for my car

betajaen

17-03-2007 18:26:50

Sadly your not going to get any responses in here.

You can repost it in the "Using Ogre in practise" forum, state your problem as clear as possible, and if English isn't your native language, append to the question a translation in your language.

Someone will answer ;)

devachan

17-03-2007 19:36:04

That thought, after everything it is the correct . at least it was useful to increase my posts number :D. Hey betajaen, you live in an island, like I, I was looking at the ogre frappr... well, this does not correspond either here :lol:

betajaen

17-03-2007 19:43:12

Yep. We call it Britain.

devachan

17-03-2007 20:02:10

jajajaja.... sorry, knew it. my island is less known, island of Chiloé

devachan

22-03-2007 18:27:32

fantastic!! physx and nxogre work well with many vehicles. I wonder if when changing the mesh of the vehicles I will be able to continue enjoying this. Maybe not. But that it would be problem of graphic card (I think that). To high speeds the wheels of the vehicle (mesh) are buried in the floor until the half, alone can see half of the wheel.

http://dodownload.filefront.com/7001094

the traffic lights are of toy, it is necessary to connect them to some battery :P

betajaen

22-03-2007 18:33:51

That's pretty amazing!

The wheel bug may be due to the mesh not being offset, or perhaps the wheel mesh entity bug in NxOgre that only shows when the car is off the ground.

Still good job!

devachan

22-03-2007 22:55:27

the solution is in this same thread

At each frame I update wheelNode position orientation.

bool Vehicle::simulate(float _time)
{

if(ContactShape != NULL)
{
isContact = true;
Vector3 mDirection = NxTools::convert(contactData.contactPoint - mWheels[i].mWheel->getGlobalPosition());
float mDistance = mDirection.length();

mWheels[i].mNode->setPosition(mWheels[i].mInitialLocalPos.x, getDriveVelocity()/100 + mWheels[i].mInitialLocalPos.y + mWheels[i].mWheel->getRadius() - mDistance, mWheels[i].mInitialLocalPos.z);




Apparently "Vector3 mDirection" is directly related with the speed. To high speeds "mDirection" becomes bigger. That makes that the wheel is buried in the floor. In these cases it is necessary to make a little more smaller to "mDirection" . in my case:
between 10 and 18 m/s: mDirection = mDirection*0 .9
between 18 and 20 m/s: mDirection = mDirection*0 .85
20 m/s up (I don't know up to where) = mDirection*0 .80

toby had already solved apparently it, but the adjustments vary with the size of the wheel (I think that)

:D

Toby

27-03-2007 21:12:33

This is a long time I come on this forum. Then yes I solved this problem, but it is very bad:
getDriveVelocity()/100

I do not know how to do otherwise.