PDA

View Full Version : ODE for Space Physics



technomage
08-01-2005, 04:31 PM
Hi everyone

This is my first post for a while so be gentle :wink:

I'm writting an application were I want to simulate space physics, I have chosen ODE to implement this and was wondering if anyone had any tips of where to start? or had used ODE for something similar?

{MSX}
08-01-2005, 04:51 PM
Hi everyone

This is my first post for a while so be gentle :wink:

I'm writting an application were I want to simulate space physics, I have chosen ODE to implement this and was wondering if anyone had any tips of where to start? or had used ODE for something similar?

I'm using ODE for my game Funkycars (http://funkycars.sf.net)
I don't know if ode is good for space physics.. space physics is usually simpler than classic one. What kind of problem do you think ode will help you for ?

Anyway if you have to start, i suggest you to try from the beginning to visualize your ODE bodies and joints. Make a generic procedure that takes an ode scene and renders it with simple boxes/sphere. This will help you trace problems, when things will go in the wrong way.
You can take a look to my DrawWorldUnit.pas in funkycars sources (note that is it GPLed).

Bye :P

PS Is your space game for DogFight ?

technomage
08-01-2005, 11:25 PM
Thanks for the feedback, I'll have a look at the code.

My main idea is that I want to actually model the hull and engines of the ships separately, so that if an engine gets knocked out the physics engine will act accordingly, so I suppose I would need a box for the hull and each engine and join these together. I did have a look at the documents but I couldn't see any joints that seemed suitable tor this purpose, they all seemed to be geared to attaching wheels etc.

Cheers :)

PS - The main game isn't for dogfight, but If I make any progress with this ODE stuff I might just do a small test game :wink:

{MSX}
09-01-2005, 10:23 AM
Thanks for the feedback, I'll have a look at the code.

My main idea is that I want to actually model the hull and engines of the ships separately, so that if an engine gets knocked out the physics engine will act accordingly, so I suppose I would need a box for the hull and each engine and join these together. I did have a look at the documents but I couldn't see any joints that seemed suitable tor this purpose, they all seemed to be geared to attaching wheels etc.


Ah i see.. Well there are a lot of joints, not just for wheels.
If your engines are fixed on the hull, you can use the fix joint. If they can move in just one direction, you can use the hinge.
Remember you can always set some variables on the joints to set the freedom of how they can move..

technomage
09-01-2005, 10:34 PM
Is says in the documentation not to use fixed joints? I wondered if there are not very efficient? I'll have a look at using a fixed joint to connect all the items together, then I suppose it's just a question of working out the way each engine workes (e.g if I press up which direction you need to add force), any tips of that area? or is it just a question of trial and error. :)

{MSX}
10-01-2005, 07:47 AM
Is says in the documentation not to use fixed joints? I wondered if there are not very efficient?
It says that becouse most of the time if you think you need a fixed joint you probably can do the same with a compound geometry without joints. But in your case i see fixed joints useful. As you said, the joints can eventually get broken and the two body can move apart.
But does your engines move about the hull ?



I'll have a look at using a fixed joint to connect all the items together, then I suppose it's just a question of working out the way each engine workes (e.g if I press up which direction you need to add force), any tips of that area? or is it just a question of trial and error. :)

Well you probably have some engines around the main body. If you add an equal force to each, you'll probably get a "forward" force.
You simply get your input from keyboard and then use some dBodyAddForce function.

technomage
11-01-2005, 10:20 AM
Hi

The engines are fixed on the hull, not rotating (although that's an interesting idea... :) ).

I have implemented a simple model which has a main "hull" and 4 engines with a fixed joint between the engines and the hull (I call dJointSetFixed after attaching the Body's to the joint). Now when I call dBodyAddRelForce (becuause it needs to be relative to the body's current orientation) the engines all move off together, but the hull lags behind and does not keep up with the engines although the joint is still active as it does response to new inputs. Any ideas on how to ensure that the hull and the engines stay together? I can post a exe to demo the problem if that will help.

I did try using dBodyAddForce as well with the same effect.

savage
11-01-2005, 10:29 AM
Hey guys, I expect some ODE tutorials to come out of these discussion ;-).

{MSX}
11-01-2005, 10:48 AM
The engines are fixed on the hull, not rotating (although that's an interesting idea... :) ).

Ok, then fixed should do the job.




Now when I call dBodyAddRelForce (becuause it needs to be relative to the body's current orientation) the engines all move off together, but the hull lags behind and does not keep up with the engines although the joint is still active as it does response to new inputs. Any ideas on how to ensure that the hull and the engines stay together?


I didn't understand the problem. Is the hull "late" in moving with respect to the engines, but still following them; or is it completely detached as if the joins wasn't there ?

In the first case, you have to adjust the joints ERP and CFM parameters. (error reduction parameter and constraint force mixing). The combination of this two values define how "loose" and how bouncy the joint is. You define them where you create the joint.
The ode guide has some nice chapter on this settings, i suggest strongly to read them (it's not a hard read), then you can experiment with values to find a model that fits your needs. I think your joints should be as fixed as possible, so it should be easy to find out.

If the hull competely detached, than probably you have some problem in your sources.. Compare it with some working project or demo.



I can post a exe to demo the problem if that will help.

I'd like to see how things are coming out :P
Does it work on linux too ?

{MSX}
11-01-2005, 10:51 AM
Hey guys, I expect some ODE tutorials to come out of these discussion ;-).

:mrgreen:

maybe, one day.. :D

technomage
11-01-2005, 11:59 AM
I'll post the source code up and you can compile it yourself. It should work under linux.

I've added a CFM if 0 and ERP of 0.8 to the world with no effect. There doesn't seem to be a way of setting these parameters for fixed joints.

I'll post the exe (it's a windows exe sorry, my linux partition is not working at the moment)

http://www.pgd.netstarweb.com/files/201/odetest.zip

The controls are

Mouse to look around
Arrow Keys to move the camera left right forward backwards

Space to apply forwad thrust.

Key Pad keys

4 & 6 thrust left right
8 & 2 thrust down and up
7 and 9 roll left and right

I've upped the forst a bit so done hold the space bar down too long otherwise the stuff will go off into the distance and the camera won't be able to catch up.. :D

technomage
11-01-2005, 12:01 PM
sorry about the spelling in that last post... :oops:

technomage
11-01-2005, 12:03 PM
plus I didn't post the source as it uses a whole load of units that I have dotted all over the place, it would take me a while to gather all the units together.

I'll try and to that later tonight (I supposed to be working at the moment :cry: )

{MSX}
11-01-2005, 12:33 PM
I'll post the exe (it's a windows exe sorry, my linux partition is not working at the moment)


I've tryed the demo. It seems to me that it's a problem in your rendering code, not in ODE.
At first look, it seems that you're appling twice the translation and/or rotation of engines mesh. Look in your code how you render things.. have you a hierarchy of object or use ODE body directly ?

Now, that's why i suggest using a proven system to "draw ODE world" while experimenting :D

technomage
11-01-2005, 11:08 PM
DOH!!!! :oops:

I just checked my code and I was in opengl mode, I was thinking the engines are owned by the hull so I needed to translate the engines along with the hull, not on there own... DOH DOH DOH.

Well I got it working :D , just need to get some nice control mechanisms in now. the dbodyAddRelForce is a fantastic, it means I don't need to figure out which way is up etc, because the force is always applied relative to the body... fantastic :D

thanks for you help, i'll post a small demo once I have a basic control system done.

savage
11-01-2005, 11:22 PM
Looking forward to the demo :).

{MSX}
12-01-2005, 07:51 AM
DOH!!!! :oops:

I just checked my code and I was in opengl mode, I was thinking the engines are owned by the hull so I needed to translate the engines along with the hull, not on there own... DOH DOH DOH.


Ehehe :P I'm too cool 8) :joker: :clown:

I'm waiting your demo :)