Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Air Resistance  (Read 2171 times)
0 Members and 1 Guest are viewing this topic.
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Posted 2004-10-16 11:25:33 »

Hi,
I am trying to simulate air resistance in Ode. But im having a bit of trouble doing it in a proper way that doesn't affect alot of gravity stuff:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
            if (airResistance < 1) {
                  javax.vecmath.Vector3f velocity = bod.getLinearVel();
                  javax.vecmath.Vector3f angVeloc = bod.getAngularVel();

                  velocity.x *= airResistance;
                  velocity.y *= airResistance;
                  velocity.z *= airResistance;

                  angVeloc.x *= airResistance;
                  angVeloc.y *= airResistance;
                  angVeloc.z *= airResistance;

                  bod.setLinearVel(velocity);
                  bod.setAngularVel(angVeloc);
            }


Seems a hack to me, and not the way i should be doing things...

Any ideas?

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline Mithrandir

Senior Member




Cut from being on the bleeding edge too long


« Reply #1 - Posted 2004-10-16 21:54:27 »

When working with physics models, forces are far better to model in rather than velocity - that's why you're using a physics model in the first place.

Air resistance should be calculated as a force.  In general, air resistance is proportional to the square of the speed. Find out what your velocity is for the frame, calculate the airresistance in the exact opposite direction to the velocity, and add a force which is equivalent to the amount of power you're getting from the engine providing forward motion.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #2 - Posted 2004-10-16 23:11:10 »

right, ok.

So I have a force thats making a sphere move forwads, say 10 newtons. So i have to make 100 newtons oppose it, wouldn't that just make it go backwards?

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Malohkan

Senior Member




while (true) System.out.println("WOO!!!!");


« Reply #3 - Posted 2004-10-17 00:25:38 »

if your air resistance force is calculated to be stronger than the original force you're exerting, you've done something wrong.  

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline the2bears

Senior Member


Projects: 2


Little Bear: Code Fu!


« Reply #4 - Posted 2004-10-17 02:34:40 »

Quote
...In general, air resistance is proportional to the square of the speed....


Not *is* the square, as quoted the air resistance is proportional to the square... big difference:)

Bill

the2bears - the indie shmup blog
Offline Mithrandir

Senior Member




Cut from being on the bleeding edge too long


« Reply #5 - Posted 2004-10-17 03:17:34 »

Ya. The proportionality factor is normally known as the drag-coefficient ( cd).  For most ground vehicles, this is in the range of 0.2 to 0.45. For aircraft, values are around 0.05 to 0.15.

Also note that the values are proportional to the velocity of the object not to the force that is applied by the motor.  A vehicle at rest has no air resistance, so that motor force of 10N can be all used to accelerate the vehicle. Once you start getting a decent velocity, then the air resistance force starts to increase, until you get to the point of equilibrium.

The site for 3D Graphics information http://www.j3d.org/
Aviatrix3D JOGL Scenegraph http://aviatrix3d.j3d.org/
Programming is essentially a markup language surrounding mathematical formulae and thus, should not be patentable.
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #6 - Posted 2004-10-17 10:17:56 »

thank you all for your help. Il implement it, and il come back with the good news  Wink

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline dansoton

Innocent Bystander




Java games rock!


« Reply #7 - Posted 2005-01-07 09:01:34 »

darkProphet (or anyone else),

Any update on this? I'm looking to do a similar thing - attempting to model the EDL (entry, descent and landing) of the nasa rover on mars, and so air resistance is crucial in this.

(I'm trying to create a simulation which allows the user to select a custom EDL (when to open the parachute etc) and see the results modelled, very ambitious for a newbie i must admit, but i'm game for trying!)

If you have made any headway with air resistance that would be helpful.

Also Is ODEJava still the best java phyics engine to use in this scenario where most of the forces applied will be through air resistance and drag?

Thanks
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #8 - Posted 2005-01-11 09:50:47 »

well...

I know pretty much what im supposed to do to get air resistance working. But im preoccupied with getting an API neutral physics system for jme at the moment.

What you need to do is approximate a contact constant for the object depending on its width/height/length. Basically, a face to it. Then you need to "map" those values on the different faces... (imaging a 2 dimentional quad, the longer side would obviously have more resistance).

Then when the object is moving, obtain the force by doing something like body.getForce() or something similar (i dont have it infront of me sorry). This will give you a Vector3f and a float. The Vector3f represents the direction of movement the force.

Then you find out which face is facing the direction of movement (you might have to guess sometimes). Then you do this:

float secondForce = faceConstant * drivingForce * drivingForce

body.addForce(secondConstant, new Vector3f(-df.x, -df.y, -df.z));

And you have air resistance. It looks pretty complicated, but its not really. The only complex bit is the approximation and mapping (usually onto a boundingBox, unless its a sphere, then the constant is always the same).

Hope that helps,
DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (16 views)
2014-08-01 22:53:16

CogWheelz (15 views)
2014-08-01 22:51:43

CopyableCougar4 (18 views)
2014-08-01 19:37:19

CogWheelz (19 views)
2014-07-30 21:08:39

Riven (27 views)
2014-07-29 18:09:19

Riven (16 views)
2014-07-29 18:08:52

Dwinin (14 views)
2014-07-29 10:59:34

E.R. Fleming (35 views)
2014-07-29 03:07:13

E.R. Fleming (13 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36
Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

Resources for WIP games
by CogWheelz
2014-08-01 18:19:50

List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!