RayCast vs MultiBody vehicles

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

RayCast vs MultiBody vehicles

Postby DarkBoss » Fri Mar 19, 2010 8:51 pm

Hi,
great day of mine registering this really great forum.
first, i'd like to thank julio, wallaber, and pjani ( pardon me if i forgot some :( ) for the great work they give us, totally for free, and i think they are not receiving as much as they give

im going to introduce myself :
im an indie dev ( understand i do my stuff on my own, a big part for my own fun and the other for fun too ;) ), been using NGD since 1.something and always found it beats the hell out of licenced physics engine !! ( yeah litterally ! ;) )
currently i'm using NGD 2.18 + ogrenewt from the svn which has been updated to support archemedia 2.18 by kallaspirit ( thanks man too ;) dont get mad at me for forgetting u :( )

in the past years i found all my answers here, but couldnt figure out this one which i find rather simple : what's the difference between raycast and multibody vehicles
what i was able to understand by few pieces of infos i could grab, raycast is used for simulating suspension, that's all ^^

but with raycast bodies when i shoot or they get in contact with another body the wheels are not collidable.
is this my fault ? like i mis-setup some parts

so i was wondering which from raycast to multibody is the best solution, maybe neither, it just depends on what ur expecting ?!
also i was surprised to see disappear the OgreNewt::Vehicle class maybe it will come back from deadland ?! ^^

anyway feel free to answer or not if uve got some time reading this ebook ^^
thanks in advance

[Edit] : Yeah and pardon me too if i posted this in the wrong forum, maybe a moderator could move it to an appropriate place ?!
[Edit2] : I deleted some part because i answered myself ;)

Cya,
DarkBoss
Attachments
model jeep custom.zip
my custom meshes
(37.16 KiB) Downloaded 253 times
DarkBoss
 
Posts: 5
Joined: Fri Mar 19, 2010 8:33 pm

Re: RayCast vs MultiBody vehicles

Postby Julio Jerez » Sat Mar 20, 2010 7:40 pm

Ray cast car are more for arcaidy fast games, teh weel are no rigid bodies so tehy do no collide like proper rigi body objects.

if you are making an arcade game I suggest you go with Raycats car, they are faster and esiwer to tweak.
They could look very realistic too, soem tiem even more realistic that mutibody cars.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: RayCast vs MultiBody vehicles

Postby DarkBoss » Sun Mar 21, 2010 11:01 am

ok thanks julio, hope u havent take my previous post as too much "ball s*cking" ^^

anyway, only if u have some free time can u show me a simple source using ogrenewt and a multibody vehicle ? im not a noob, but with setting up a vehicle i really s*ck !

what i did was simply add convex for chassis, and for wheels, then i set up hinge between wheels and chassis, and the wheels went crazy like they were boucing all over the place
rotating and throwing the chassis into the air oO ( i know it's just my fault )

my questions are for hinges:
- pin : do u have to set it up like from the center of the wheel to the center of the chassis ( y = chassis y ) ? or the inverse ? or from the center of the wheel to the center of the chassis ( y = wheel y ) ? or from the wheel to the nearest point of the chassis ?
- position : do u have to set it up to the center of the wheel ? or the center of the chassis ? the nearest point of the chassis ? or the half of (wheelpos-nearestPointOnChassis) ?

what i previously did was :
chassis orientation UNIT_Z
wheel orientation UNIT_Z
- pin : i setup this so for example RearRightTireHinge was NEGATIVE_UNIT_X and so on so it was basically the direction of the wheel towards the chassis
- position : i setup this by the center of the wheel

and if u really are inspired : have u got some papers on doing a car engine, like having a motor class, and a gearbox, and deducing torque, speed, RPM , accel etc from provided engine props ( such as 1200 rpm, 13.5 at full torque, 120 kmh, gear ratio etc ), maybe i should just open a mechanics book. cause i built some motor classes but im doing it the trial-and-guessing way( i have really few notions of car mechanics ), just to verify if im not doing things weirdly.

why i want so bad a multibody is that for example actually when i jump from a little edge, if i decelerate the motor and the car is in the air, it will stop in the air and fall down ( i use body->setVelocity(), i think it's the same with setForce() ), so i need some kind of NewtonIsTireAirborne, which i guess i can figure it out with some contact callback, but how to do it if the wheels have no body. maybe casting ray is the solution too, yeah i think so. but i wanted to be sure.

another quick unrelated question, will u provide some "most-simple-code" for destruction thingy, 'cause omg what u did there with destruction is a really advanced physic effect that i thought would never be implemented in newton ( just because i thought it's really complex but apparently u like a genius or something ;) )

if u can answer to this it's cool, in the contrary if not, not a problem because it means we can get sooner the multibody vehicle part back in next newton beta :)

anyway thank you and have a nice sunday !
DarkBoss
 
Posts: 5
Joined: Fri Mar 19, 2010 8:33 pm

Re: RayCast vs MultiBody vehicles

Postby Mag-got » Sun Mar 21, 2010 2:07 pm

It is kind of hard to make a multibody vehicle because there are no documents for it yet, I've been fighting with it for a day now.

I thought I wouldn't make a thread for my question, what should I pass to AddSingeSuspensionTire? The spring constant and the spring damper.

The tires are going slowly through the cars body, I tried with 1000.0f for both parameters and they didn't go through,
but didn't really act like they're suspended.
Mag-got
 
Posts: 4
Joined: Tue Nov 20, 2007 12:13 pm

Re: RayCast vs MultiBody vehicles

Postby DarkBoss » Sun Mar 21, 2010 2:49 pm

hey,

i'll reply by quoting some code i took directly from the ogrenewt demo5
Code: Select all
   // for now just to get it going
   Ogre::Real mass = 10.0f;
   Ogre::Real friction = 1.0f;
   Ogre::Real susLenght = 0.2f;
   Ogre::Real susSpring = 300.0f;
   Ogre::Real susShock = 0.0f;
   mRayCastVehicle->AddSingleSuspensionTire (tireHarpointAttachement, position, mass, radius, width, friction, susLenght, susSpring, susShock);


taken from the function ( i give u this because i think that u mis-setup the tire pin etc because when i set bad values it not goes thru the chassis )
Code: Select all
void VehiculeBase::createTire( const string &tireMesh, const Vector3 &position, const Quaternion &orientation )
{
   Ogre::Entity* tireEnt = NULL;
   Ogre::SceneNode* tireNode = NULL;
   Ogre::Node* tireHarpointAttachement = NULL;
   

   // attach the tire entity as a child node of the body node
   tireEnt = mSceneMgr->createEntity( getValidBodyName("Tire"), tireMesh);

   // create the tire hard point attachment
   tireHarpointAttachement = chassisNode->createChild (position, Ogre::Quaternion::IDENTITY);

   // attach the tire to the hard point node
   tireNode = (Ogre::SceneNode*) tireHarpointAttachement->createChild (Ogre::Vector3::ZERO, orientation);

   // attach the mesh entity to the tire node
   tireNode->attachObject (tireEnt);

   // calculate the tire dimension from the entity AABB
   Ogre::AxisAlignedBox tireBox (tireEnt->getBoundingBox());
   Ogre::Real width = tireBox.getSize().z;
   Ogre::Real radius = tireBox.getHalfSize().x; 
   
   // for now just to get it going
   Ogre::Real mass = 10.0f;
   Ogre::Real friction = 1.0;
   Ogre::Real suspensionLenght = 0.2f;
   Ogre::Real susSpring = 300.0f;
   Ogre::Real susShock = 0.0f;
   mRayCastVehicle->AddSingleSuspensionTire(tireHarpointAttachement, position, mass, radius, width, friction, suspensionLenght, susSpring, susShock, true);
}

so:
- susLenght = length of the suspension
- susSpring = absorbs impact
- susShock = controls spring motion, 'suspension hardness'

Wikipedia says this :
Springs and dampers

Most conventional suspensions use passive springs to absorb impacts and dampers (or shock absorbers) to control spring motions.
Some notable exceptions are the hydropneumatic systems, which can be treated as an integrated unit of gas spring and damping components, used by the French manufacturer Citroën and the hydrolastic, hydragas and rubber cone systems used by the British Motor Corporation, most notably on the Mini. A number of different types of each have been used:


Other link that might be helpfull

i dont really know if it's what ur looking after but it gave me a good start
hope this helps, if u want i can show you my raycast vehicle class

[PS:] i wonder how people can respond by saying so less words Oo like everytime a post a reply, bam my fingers are unstoppable and i write all this book :-( wish i knew how to do it ^^
DarkBoss
 
Posts: 5
Joined: Fri Mar 19, 2010 8:33 pm

Re: RayCast vs MultiBody vehicles

Postby Mag-got » Sun Mar 21, 2010 4:08 pm

The tires spin in the right direction, so they're pin is right.

I mean what should I pass as springConst and springDamper, and what should I use to get them?

I'm using irrlicht & newton, irrlicht's units are 32 times bigger than newton's, so that might be causing problems. I tried the values in your post DarkBoss, the car wen't flying crazy :)
Mag-got
 
Posts: 4
Joined: Tue Nov 20, 2007 12:13 pm

Re: RayCast vs MultiBody vehicles

Postby DarkBoss » Sun Mar 21, 2010 4:30 pm

the prototype of the function is
void AddSingleSuspensionTire (void *userData, const Ogre::Vector3& localPosition, Ogre::Real mass, Ogre::Real radius, Ogre::Real width, Ogre::Real friction, Ogre::Real susLength, Ogre::Real susSpring, Ogre::Real susShock, bool useConvexCast = true);

what's the springConst and springDamper u talking about ? maybe u use an old version of ogrenewt / newton, try getting the ogrenewt from svn
that's all i can say, since i'm new ( 2 days ) in vehicle building ^^
maybe ask an expert around here or on the irrlicht forum ?
DarkBoss
 
Posts: 5
Joined: Fri Mar 19, 2010 8:33 pm

Re: RayCast vs MultiBody vehicles

Postby Mag-got » Sun Mar 21, 2010 5:00 pm

:) I'm asking what should springConst and springDamper be, for multibody vehicle. Maybe some expert will help me out, or find it in the old SDK. Thanks for the help

EDIT: I found this in the old SDK:

Code: Select all
   // calculate the spring and damper contact for the subquestion 
   //
   // from the equation of a simple spring the force is given by
   // a = k * x
   // where k is a spring constant and x is the displacement and a is the spring acceleration.
   // we desire that a rest length the acceleration generated by the spring equal that of the gravity
   // several gravity forces
   // m * gravity = k * SUSPENSION_LENGTH * 0.5f,
   dFloat x = SUSPENSION_LENGTH;
   tireSuspesionSpring = (200.0f * dAbs (GRAVITY)) / x;
//   tireSuspesionSpring = (100.0f * dAbs (GRAVITY)) / x;

   // from the equation of a simple spring / damper system
   // the system resonate at a frequency
   // w^2 = ks
   //
   // and the damping attenuation is given by
   // d = ks / 2.0f
   // where:
   // if   d = w = 2 * pi * f -> the system is critically damped
   // if   d > w < 2 * pi * f -> the system is super critically damped
   // if   d < w < 2 * pi * f -> the system is under damped damped
   // for a vehicle we usually want a suspension that is about 10% super critically damped 
   float w = dSqrt (tireSuspesionSpring);

//  a critically damped suspension act too jumpy for a race car,    
   tireSuspesionShock = 1.0f * w;


Gonna check tomorrow if that will sort things out
Mag-got
 
Posts: 4
Joined: Tue Nov 20, 2007 12:13 pm

Re: RayCast vs MultiBody vehicles

Postby DarkBoss » Sun Mar 21, 2010 5:19 pm

ah ok sorry, i gave u the addSingleSusp func for raycast vehicle, because in the last ogrenewt multibody vehicle are disabled.
hope u' ll find what u need
cya
DarkBoss
 
Posts: 5
Joined: Fri Mar 19, 2010 8:33 pm

Re: RayCast vs MultiBody vehicles

Postby Stucuk » Sun Mar 21, 2010 8:59 pm

Mag-got wrote:I'm using irrlicht & newton, irrlicht's units are 32 times bigger than newton's, so that might be causing problems.


When you send information to Newton you should divide it by 32, and multiply when sending information the other way. That way newton will always run with 1 unit = 1 meter and irrlicht can render with its insane size's.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast vs MultiBody vehicles

Postby Sash » Tue Apr 06, 2010 2:44 am

Mag-got wrote:irrlicht's units are 32 times bigger than newton's

In fact this is not true. Both are using the same floating-point values.
Single or double - just a matter of precision. It's up to you how to interpreat them - either be it
metric or inches/feets.

I saw these Irrlicht-Newton tutorials and I found them a bit confusing - I just dropped this IrrToNewt conversion and everything
working just fine.
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

Re: RayCast vs MultiBody vehicles

Postby Stucuk » Tue Apr 06, 2010 9:26 am

The standard units 99% of engines use are not in the 1 meter per unit scale. If you don't convert the Rendering Engines units into a 1 unit = 1 meter scale then you will not have as good a physics simulation as Newton expects the units you send to it to be in meters.

It may "Seem" to be working fine, but it won't be physically accurate. If Irrlicht is using 32 units = 1 meter then you will most likley have objects falling slower than they should, etc.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast vs MultiBody vehicles

Postby Sash » Tue Apr 06, 2010 1:52 pm

Sorry, but most rendering engines I know does not even operate such a term as distance unit.
Just a plain numbers, in native hardware format. CPU operates on numbers, and GPU draws triangles according to these numbers.
Nothing more. It's only a matter of someone's interpreation to treat for example value 1.0f as 1 meter or 1 inch or 1 feet.

I don't know for sure where this "magic number" 32.0 came from to Irrlicht (not really Irllicht, but a tutorial), probably it's origins - some 3D CAD software.
Many of these packages DO have (unlike rendering engines) distance unit system, and thus it may influence their models output scale.
Probably in some engines some 3D model import code may contain some variable parameter like "import scale" or "units" but when import procedure is done,
rendering engine operates just with plain numbers: float, doubble and vector-arrays of them. Rendering engine just don't need this unnescessary complexity as units.
It only draws what they told to do ... in native hardware format.

Stucuk wrote:If Irrlicht is using 32 units = 1 meter then you will most likley have objects falling slower than they should, etc.

Irrlicht is not using neither units nor meters.
Please, just check it for yourself.
Sash
 
Posts: 34
Joined: Wed Sep 30, 2009 3:38 am
Location: Novosibirsk

Re: RayCast vs MultiBody vehicles

Postby Stucuk » Wed Apr 07, 2010 2:35 pm

Rearly? Here was me thinking that everything a computer does had to be divided by 32 or else it wouldn't work right.... (Sarcasm).

Most rendering engines have there own scale determined not by what level/model editor you use but by the size of the player controller(Which is most likely where 32 units comes from. Personally i don't care where it comes from). It determines what scale you can use on the level (Because if your player can't fit through doors, etc you will have to make them larger).

In any case, unless your units are in meters then you will need to scale numbers going in and out of newton unless your happy with errors cropping into your simulation.

Irrlicht is not using neither units nor meters.


Everything works in "units". A unit is just "1.0f", its a unit of measurement that has no set conversion scale.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: RayCast vs MultiBody vehicles

Postby kallaspriit » Wed Apr 07, 2010 3:37 pm

What kind of player controller of Irrlicht are you talking about? I once used Irrlicht without the 32x conversion and had no problems :P
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests

cron