VEHICLE

Xed

11-05-2007 14:15:51

Hi

Could anybody post code of 4 wheels vehicle and it control(move back\front)?

I'd like if you post for 0.6 and 0.9 too.

Thnx.

:D

betajaen

11-05-2007 14:47:58

It's in the 0.6 thread.

Xed

16-05-2007 19:47:52

Hi

I try vehicle in 0.6, so i want to see it in 0.9
but how can i do this i don't know(for 0.9).
So, could you post code of 0.9 vehicle with wheel set?

P.S. It's better if body of vehicle will be a trimesh.

Thkx

betajaen

16-05-2007 20:27:54

I'm still working on the wheel code; currently implementing the DriveShaft and Motor so any examples would be slighty out of date.

And no you can't use a tri-mesh like that, it's static or nothing else.

NickM

17-05-2007 16:37:40

Sorry to hijack the thread but will the new wheel class still allow you to create individual wheels that can be placed where ever I like?
For my game (which I'll get back to working on if I can ever get cloth working properly from an ogre mesh lol ) I need to be able to change the position of individual wheels on the fly.

betajaen

17-05-2007 16:41:24

Theoretically yes.

Xed

17-05-2007 16:44:04

So ......((
In 0.6 or 0.9

Can I make movable mesh? body of car
any way?

betajaen

17-05-2007 16:48:46

In 0.9 and triangular meshes can't be used in dynamic bodies, ever. Just use a compound of convex shapes instead.

NickM

17-05-2007 16:50:46

Thanks betajaen.
Xed I'm not sure what you are asking?

Xed

17-05-2007 17:06:11

2NickM

I'm trying to make car simulator, so i need to make car(body+wheels)
but i don't using box as body, so I'm asking any ways of create body of car as mesh?

betajaen

17-05-2007 17:28:05

Yes for the 500th time.

Use primitive shapes in a compound to make up features of the car, this is how I do it, and it's how it's normally done.

Xed

17-05-2007 17:35:46

Understand.

"compound" it's mean different shapes for doors, glass, and other part of car body?

And anybody have source code of simple car (like that with compound meshes) or some part of code?

Thnkx

NickM

17-05-2007 18:32:13

I currently use a convexShape made from a special simplified mesh for the collision shape of my car.
carShape->addShape(new convexShape("CarCollisionModel.mesh",CarBodyMaterial));

I'm still using nxOgre 0.4 RC3 though.

Xed

17-05-2007 18:38:52

Interesting.........

But what about 0.6 (0.9)?

betajaen

17-05-2007 18:50:41

It's the same.

Xed

17-05-2007 18:57:52

:D

I already try it.

It's very nice.

Thnkx.

Xed

17-05-2007 19:06:23

One else:

There are only one mesh.....(

but if my car consist of few meshes, what i need to do? (I mean code)

:shock:

Xed

17-05-2007 20:11:09

:o

What about speedometer

how can i do it?

betajaen

17-05-2007 20:15:17

float Speed_in_KPH = mBody->getNxActor()->getLinearVelocity().magnitude() * 3.6f;

Xed

18-05-2007 14:20:58

Hi

I've got some problem.

When i add meshes

mWheelSet.addMeshes("Wheel.mesh");

but they are looks like lay down on thew plane (i mean they are not stay vertical as i need)
+ they are very huge (((


So, how van I:
-turn wheel orientation
-scale

P.S. Sorry for my English)))

betajaen

18-05-2007 14:26:24

You need to set the orientation and scale within your 3D modeller.

Xed

18-05-2007 14:31:56

(((

Firsth i have few meshes as my wheel.....

How i understand i can't set it program (by coding)?

And what about get node and set it? (but how practical do it i don't know((()

Xed

18-05-2007 14:57:42

P.S.

I using 3DMAX 8 do you know what i need to do there? :?

daedar

18-05-2007 15:13:41

I don't really understand but if you're using 3DSMax and if you're experiencing little problems with the size or the orientation of your mesh, you should try to Reset XForms:

Modifiers->Reset XForms

Xed

18-05-2007 16:40:00

:(

I try to reset XForm but nothing!!!

So,

HOW TURN WHEEL(S) AND SCALE IT
:?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?: :?:

betajaen

18-05-2007 16:44:45

Right. Stop it.

This is not a 3DSMax forum.

Xed

18-05-2007 16:51:37

It's not 3dsmax question!!!!

I asking how to do this in NxOgre??? (by coding I mean)

////How to get Entinity and rotate and scale it?

betajaen

18-05-2007 16:58:17

And I've just told you, The most easiest way is via the 3D modeller.

If you have to do it via code, then you need it's SceneNode.

Now I assume your IDE has intellisense or something similar that shows you a list of functions or members of a class? If it does, go over to the wheel and hit Ctrl+Space. If it doesn't have that, I'm sure you can open the NxOgreWheelShape.h file up in notepad, and find the function that gives you the node by hand?

Xed

18-05-2007 17:23:22

:shock:

mBody->getScene()->getSceneManager()->getSceneNode(NAME)->scale(Vector3(10,10,10));


something like this (as you write)

but how can I get node of wheel?

(((I see that you generated name with


Ogre::Entity* entity = mActor->getScene()->getSceneManager()->createEntity(NxCreateID(mActor->getNbShapes(), mNode->getName()), meshName);
mNode->attachObject(entity);

betajaen

18-05-2007 17:36:31

How freaking hard is it?

mWheel->getNode()

NickM

18-05-2007 17:38:45

I'm not being nasty Xed but you really should spend more time trying to work things out for yourself, you will learn an awful lot more than just constantly asking how things are done, sure if you have tried and tried but still can't work it out, ask, but if you keep asking all of these questions people will soon stop answering you.

As has been said resetting the Xform and/or rotating the model in 3dmax is the best way to solve your current problem.

Xed

18-05-2007 19:06:27

2NickM

:? My time is going out..... I'm writing something like diplom ))) so it's seems better to ask then trying (but i'm still trying))),
because f.e. i trying to get node for wheelset, but must to get node of wheel)))

so.....i'll trying
:D :D :D :D :D

Toby

19-05-2007 10:59:34

Not just try it, explore nxOgres' code and look at examples.

Xed

28-05-2007 12:04:55

Here load function of my car:


void PLAYER::load(CAR* MyCAR)
{
//body
ELEMENTS_LIST* B=&(MyCAR->BODY);
ELEMENTS_LIST::iterator I=B->begin();

LogManager::getSingleton().logMessage("**********begin of NxOgre body");

ActorParams ap;ap.setToDefault();
NxOgre::ShapeParams shp;shp.setToDefault();

ap.nodescale=(*I).Scale;
ap.density=10.1;
ap.kinematic=false;
ap.mass=MyCAR->MASS;
ap.nodeshadows=true;

shp.mMeshScale=NxVec3((*I).Scale.x,(*I).Scale.y,(*I).Scale.z);
NxQuat NXQ;
NXQ.x=(*I).Rotation.x;
NXQ.y=(*I).Rotation.y;
NXQ.z=(*I).Rotation.z;
NXQ.w=(*I).Rotation.w;
shp.mOrientation=NXQ;


mBody=mScene->createBody(
(*I).FileName,
new MeshShape(
(*I).FileName,shp),
NxOgre::Pose(
(*I).Position,
(*I).Rotation
),
ap);

mBody->setCMassOffsetLocalPosition(Vector3(0,-1,0));
mBody->setGlobalPose(MyCAR->POSE);
//mBody->setGlobalOrientation(MyCAR->ORIENTATION);

String mParams;

LogManager::getSingleton().logMessage("**********begin of @for@");
for(++I;I!=B->end();++I)
{
LogManager::getSingleton().logMessage("**********mParams");
mParams="mesh-scale:";
mParams+=StringConverter::toString((*I).Scale);
mParams+=" orientation:";
mParams+=StringConverter::toString((*I).Rotation);
mParams+=" position:";
mParams+=StringConverter::toString((*I).Position);
LogManager::getSingleton().logMessage(mParams);

LogManager::getSingleton().logMessage("**********addShape");
mBody->addShape(new MeshShape((*I).FileName,mParams));
}

ELEMENTS_LIST* F_L=&(MyCAR->FRONT_LEFT_WHEEL);
ELEMENTS_LIST* B_L=&(MyCAR->BACK_LEFT_WHEEL);
ELEMENTS_LIST* F_R=&(MyCAR->FRONT_RIGHT_WHEEL);
ELEMENTS_LIST* B_R=&(MyCAR->BACK_RIGHT_WHEEL);

if ((F_L->empty()==true)
||(B_L->empty()==true)
||(F_R->empty()==true)
||(B_R->empty()==true)
) BOOL=false;

if (BOOL)
{

LogManager::getSingleton().logMessage("***** begin of nxOgre wheel set");
ELEMENTS_LIST::iterator a,b;

Ogre::Vector3 aa,bb;a=F_L->begin();aa=(*a).Position;b=B_L->begin();bb=(*b).Position;


mWheelSet = WheelSet::createFourWheelSet(mBody, aa, bb, MyCAR->RADIUS);
mMotor = new Motor("Motor", mScene, &mWheelSet.Drive);
mWheelSet.attachDriveShaft(mMotor);



//wheel FRONT LEFT
I=F_L->begin();
for(I;I!=F_L->end();++I)
{
LogManager::getSingleton().logMessage("******* FRONT LEFT "+(*I).Name);
mWheelSet.frontLeft->addMesh((*I).FileName);

mWheelSet.frontLeft->getNode()->setPosition((*I).Position);
mWheelSet.frontLeft->getNode()->setScale((*I).Scale);
mWheelSet.frontLeft->getNode()->setOrientation((*I).Rotation);

}
//wheel FRONT RIGHT
I=F_R->begin();
for(I;I!=F_R->end();++I)
{
LogManager::getSingleton().logMessage("******* FRONT RIGHT "+(*I).Name);
mWheelSet.frontRight->addMesh((*I).FileName);

mWheelSet.frontRight->getNode()->setPosition((*I).Position);
mWheelSet.frontRight->getNode()->setScale((*I).Scale);
mWheelSet.frontRight->getNode()->setOrientation((*I).Rotation);
}
//wheel BACK LEFT
I=B_L->begin();
for(I;I!=B_L->end();++I)
{
LogManager::getSingleton().logMessage("******* BACK LEFT "+(*I).Name);
mWheelSet.backLeft->addMesh((*I).FileName);

mWheelSet.backLeft->getNode()->setPosition((*I).Position);
mWheelSet.backLeft->getNode()->setScale((*I).Scale);
mWheelSet.backLeft->getNode()->setOrientation((*I).Rotation);
}
//wheel BACK RIGHT
I=B_R->begin();
for(I;I!=B_R->end();++I)
{
LogManager::getSingleton().logMessage("******* BACK RIGHT "+(*I).Name);
mWheelSet.backRight->addMesh((*I).FileName);

mWheelSet.backRight->getNode()->setPosition((*I).Position);
mWheelSet.backRight->getNode()->setScale((*I).Scale);
mWheelSet.backRight->getNode()->setOrientation((*I).Rotation);
}
}
}


It's work, but when it fall down to floor it stay invisible :(

I mean i set position f.e. (0,100,0) and see my car falling down
But if (0,0,0) i don't see my car

Any ideas???

:?:

betajaen

28-05-2007 13:29:38

I'm guessing you have a meshShape near 0,0,0, and your using a MeshShape in a Dynamic body. MeshShape can't collide with MeshShapes so that is probably why it's disappearing, if it's not that, then it could be the suspension or something to with the wheels.

You shouldn't use MeshShapes in with Dynamic bodies anyway. A collection of primitive shapes making up various parts of the body would do the same thing.

If in doubt record it through the Remote Debugger and see what happens.

Xed

28-05-2007 14:04:41


I'm guessing you have a meshShape near 0,0,0,


No! My scene is empty except my car (only my vehicle in scene)...

betajen, so, you mean if i'll use convexshape without meshshape i'll get right application?
:idea:

ghiboz

28-05-2007 14:20:46

do you used a floor when create the NxWorld??

mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: no");

Xed

28-05-2007 14:36:17

2 ghiboz
Yes, I use floor.

ghiboz

28-05-2007 14:38:33

2 ghiboz
Yes, I use floor.

try to remove, you should see the car that fall down at infinite...
I think that it's a problem for the meshShape. (as told by betajaen).
for performance is better that you create a basic shape to use as convexshape :wink:

betajaen

28-05-2007 15:37:52

I'd run it through the Remote Debugger. It records the scene for you, and you can go back and go step by step to see what's wrong.

Xed

28-05-2007 17:54:53

mBody=mScene->createBody(
(*I).FileName,
new ConvexShape(
(*I).FileName,shp),
NxOgre::Pose(
(*I).Position,
(*I).Rotation
),
ap);

It's crashes (((

betajaen

28-05-2007 18:01:37

You can't feed any mesh in there like that.

It has a some conditions:

a) The shape is a convex. If you don't know what that is, look it up on wikipedia.

b) Few vertices as possible. I wouldn't use any more than 50.

c) No duplicate vertices.

Xed

28-05-2007 18:21:38

O'key I'll use box
I'm :( but in the future plans will it release? (mesh fall down to plane\floor)

One else:
How can I know size of my mesh model and sat it for new CubeShape(x,y,z)
:?:

P.S. How to set right my floor?
Because I see how entity of car throw down the floor???!!!

daedar

28-05-2007 23:18:49

Just a simple question... How can I change the physic material for the wheels? Because I'd like to make my car like if it was "on the ice", I've searched into the code but nothing :(

betajaen

28-05-2007 23:36:41

Same with other shapes.

new WheelShape(0.5f, "material: myMaterial", "bleh");

daedar

28-05-2007 23:43:57

Oh ok thx, I thought material was the Ogre's material not the PhysX one :wink:

betajaen

29-05-2007 00:05:29

Nope, thats done via the node.

daedar

29-05-2007 03:15:51

it doesn't seems to work, i've created a material with low friction like that:

nxScene->createMaterial("wheels")->setAll(0.01,0.01,0.01);

then when I create my wheels, i suse this ShapeParams:

ShapeParams sp;
sp.setToDefault();
sp.mMaterial = "wheels";


and my car still seems to be on a rail :cry:

NickM

29-05-2007 06:29:10

I don't think material effects NxWheels, you are supposed to use NxTireFunctionDesc to simulate different grip levels although I've not managed to create realistic feeling tyres with it yet, I've posted on the Ageia forum to try to get some help.

betajaen

29-05-2007 09:38:25

TireFunction does help, but I believe there is a flag in the materials which you can set especially for wheels. What it is escapes me at the moment, but it's in the CHM documentation.

daedar

29-05-2007 10:06:32

Ok so I'll check the documentation and post if I find something.

luis

29-05-2007 11:55:25

From what i know, you should assign a material to the wheels with this flag:
NX_MF_DISABLE_FRICTION

in that way the wheels will just ignore all friction. Then use the 'setLateralTireForceFunction' & 'setLongitudalTireForceFunction' methods to control the friction.

The problem i'm having with this solution is that after turning on the flag every material in the scene has zero friction.

see: SampleRaycastCar and NxWheel2's constructor ;)

so i'm using almost the same work-around as you:

material->setAll( 0, 0, 0)


you are supposed to use NxTireFunctionDesc to simulate different grip levels although I've not managed to create realistic feeling tyres with it yet, I've posted on the Ageia forum to try to get some help.
i'll post my setings later maybe it will help you ;)

daedar

29-05-2007 12:25:56

Ok thx Luis, I tried what you said:


if( wMaterial == NULL ){
NxMaterialDesc materialDesc;
materialDesc.flags |= NX_MF_DISABLE_FRICTION;
materialDesc.dynamicFriction = 0;
materialDesc.staticFriction = 0;
wMaterial = mScene->createMaterial("wheel", materialDesc);
}
...
...
...
wheels.backLeft->getNxWheelShape()->setMaterial( wMaterial->getMaterialIndex() );
wheels.backRight->getNxWheelShape()->setMaterial( wMaterial->getMaterialIndex() );
wheels.frontLeft->getNxWheelShape()->setMaterial( wMaterial->getMaterialIndex() );
wheels.frontRight->getNxWheelShape()->setMaterial( wMaterial->getMaterialIndex() );


Btw, I've added a createMaterial function that take a NxMaterialDesc as second parameter. But it doesn't change the behaviour of the car at all. I think your longitual and lateral TireForceFunction setting should be helpfull :wink:

EDIT: In fact by changing the stiffnessFactor it seems to work pretty well. Now what I have to find out is which value should I put into stiffnessFactor. I'll make some tests...

Thx for the help.

luis

29-05-2007 13:25:09

ok, try these values:

friction_lateral_extremumSlip = 1.0
friction_lateral_extremumValue = 0.029
friction_lateral_asymptoteSlip = 2.0
friction_lateral_asymptoteValue = 0.01
friction_lateral_stiffnessFactor = 10.0e3
friction_longitudinal_extremumSlip = 1.0
friction_longitudinal_extremumValue = 0.02
friction_longitudinal_asymptoteSlip = 2.0
friction_longitudinal_asymptoteValue = 0.01
friction_longitudinal_stiffnessFactor = 30.0e3


if the car slides too much for you, try changing the lateral stiffness from 10e3 to 20e3 or something higher ;)

the settings i posted here are the ones i use in those videos:
http://gboot.blogspot.com

good luck ;)

daedar

29-05-2007 13:36:33

Nice!!! Thx Luis.

NickM

29-05-2007 16:30:41

ok, try these values:
the settings i posted here are the ones i use in those videos:
http://gboot.blogspot.com

I love the look you've got in those videos, the lighting and the cars look really good, well done.
I'll try your settings in my own game later and see how they feel, thanks for sharing them :D

Toby

29-05-2007 22:45:12

Great work indeed. I will try your parameters for my car game when wheels is on grass.

Your game is fun, like offroad or supersprint were.

;)

ghiboz

29-05-2007 23:15:32

Great work indeed. I will try your parameters for my car game when wheels is on grass.

Your game is fun, like offroad or supersprint were.

;)

what's the best solution to check that you're on grass??

bye!

betajaen

29-05-2007 23:19:59

Why would you change the tire functions when it moves onto the grass? Surely the grass material would take of the slippyness.

NickM

30-05-2007 06:26:52


what's the best solution to check that you're on grass??

You could get the material from the contact then alter the tyre function to give you the feel you want from grass.

luis

30-05-2007 08:47:19

thanks for all you comments guys :)

Why would you change the tire functions when it moves onto the grass? Surely the grass material would take of the slippyness.

with the flag NX_MF_DISABLE_FRICTION is set or the wheels have a 0.0s for dyn/static friction the tires doesnt respond in the usual way...

You could get the material from the contact then alter the tyre function to give you the feel you want from grass.

no sure about that but i think the contact will return the material for heightfield and it is allways the same so you cant know when you are over the grass in that way. Heightfields seems to have a material array but i dont know how to use it. Take a look in SimpleCarTutorial.

Any way i would use a simplier solution, for example if your HM has 513x513 pixels and your world has:
PageWorldX=1000
PageWorldZ=1000
It means that each pixel in the image represents 0.513 drawing units (meters in NxOgre). Then you could use a smaller texture, for example... 65x65 pixel and interpolate the world position for that resolution, get the pixel on the image and use the red component for the lateral stiffenss and the green for the longitudinal stiffness ;)

ghiboz

30-05-2007 15:42:50

but these things are in the 0.4, in the 0.9 is to be implemented, the constructors are different...right?

i ask this to avoid to make the work twice! :lol:

Xed

31-05-2007 19:42:13

Hi )))

1. Where I could get nx.materials (like wheels etc.)?

2. How can I rotate my back wheels in my vehicle?

3. I saw cloth in 0.9-23, so what about cloth metal?

:wink:

Tnkx.

NickM

31-05-2007 22:37:01

Hi )))
3. I saw cloth in 0.9-23, so what about cloth metal?

I have cloth metal working in 0.4 RC3, hopefully betajaen will be able to get my code working in the latest NxOgre.

Xed

01-06-2007 17:20:01

2 NickM

Coud you post it? (I mean full code of metal cloth)
P.S. Do you know how to set metal cloth to car? And will it work?

1
Where I can see how to setup my wheels looks like ice(and other f.e. for grass, road)?

2
How can I rotate my back wheels in my vehicle?
I mean in NxOgre rotate only front wheels then I push (go), but back wheels aren't!
Any body know how to do this?
:roll:

luis

03-06-2007 20:02:54

ok, since i have no time to get the new revision (24) and make the patch i'll post the code here and later i'll provide a patch to revision 24.

The wheels are not beeing simulated correctly with the current code, the problem is not obvious but when you drive over a hill and the car jumps the wheels changes the position to the front.

This code seems to be ok to me, at least i couldnt see any issue with it...

void Wheel::simulate(float dt) {
mWheelRollAngle += mWheel->getAxleSpeed() * dt;

while (mWheelRollAngle > NxTwoPi) //normally just 1x
mWheelRollAngle -= NxTwoPi;
while (mWheelRollAngle < -NxTwoPi) //normally just 1x
mWheelRollAngle += NxTwoPi;

mPose = mWheel->getGlobalPose();

NxWheelContactData wcd;
wcd.contactPosition = 0;
NxShape* s = mWheel->getContact(wcd);
NxReal stravel = mWheel->getSuspensionTravel(),
radious = mWheel->getRadius();

//have ground contact?
if( s )
{
mPose.t += mWheel->getLocalOrientation()*mPose.M
*NxVec3( 0.0, radious - wcd.contactPosition, 0.0 );
} else {
mPose.t += mPose.M*NxVec3( 0.0, -stravel , 0.0 );
}

NxMat33 Heading, Pitch;
Heading.rotY( mWheel->getSteerAngle() );
Pitch.rotX( mWheelRollAngle );

mPose.M = mPose.M * Heading * Pitch;

// user should take care of waking up, see Wheelset class
// mWheel->getActor().wakeUp();
}

Xed

04-06-2007 18:59:47

2luis

Tnkx


But ma last Q

Where I can see how to setup my wheels looks like ice(and other f.e. for grass, road)?

luis

04-06-2007 20:04:48

Where I can see how to setup my wheels looks like ice(and other f.e. for grass, road)?

please read all my previous posts:

if the car slides too much for you, try changing the lateral stiffness from 10e3 to 20e3 or something higher


i also explained 'my idea' on how to change the stiffness acording to the material you want to simulate ;)

Xed

18-06-2007 08:56:52

During last week I have no time, t o visit forum :(

So

Anybody say to me:

Is 9-24 set for dynamic body mesh or box (as physix)?

If no, how ican i release it?