Archived

This topic is now archived and is closed to further replies.

DanG

Lighting and Physics in Space

Recommended Posts

I''ve decided to create a 3D fighter game based in space, like an early Star Wars, where you stay in space and don''t get near land of any sort. The problem is i''m not sure how physics should work in this setting. There isn''t any up and down direction, and you should be able to just sit and not move. So the physics comes in trying to figure the coasting and turning radius and so forth. What kind of physics would work in this, what would they be based on? Secondly, What is the Lighting situation in space? Some of the planes might have lights attached, but what is global lighting calculations and such coming from? What makes the space effect look real? If you have anything else you would like to say on this subject, I am an enthusiastic listener. He who said money was the root of all evil knew little of the nature of money and less about the nature of man.

Share this post


Link to post
Share on other sites
Physics in space is simple Newtonian mechanics - just keep track of position and velocity for each space ship, and then accelerate the ships by applying forces to them.

If you want to get more complicated, you can try simulating rotation taking into account torque and rotational inertia as well.

For lighting, you either can have a global amount of ambient light that you use for every ship, or you can take whatever your background is going to be and accumulate it into a diffuse lighting cubemap, which you could then use to do a pretty convincing radiosity effect. This paper has some information about diffuse lighting cubemaps: http://developer.nvidia.com/docs/IO/2643/ATT/gdc2002_hdr.pdf
Look for the part about image based lighting.

j

Share this post


Link to post
Share on other sites
structural integrity / pilot mush factor

thats going to be the dominate theme in a space fighter sim. see if you crunch the numbers without some sort of inertia *changing* technology there isnt a space dog fight cause the pilot is mushhhh in the cockpick. ya you can pick up an unlimited velocity but you cant fricken slow down /accelerate in another direction. why? cause objects at rest tend to stay at rest and objects in motion tend to stay in motion. whats this mean? it means that even though the ultra powerful ships thrusters have changed the velocity vector of the ship you still have to change the velocity of the pilot. the pilot can only take soooo much velocity changing at once =).... after that its blackouts / mushhhhh

but thats good. cause that gives you game license. gravity and inertia appear to be the same thing. they may well be. we gave up that question since newton were revisiting it nowadays. but the implication is artificial gravity implies artificial inertia. that means nooo pilot mush.

But that does let you say the artificial gravity field can only work "so well" whats that mean to you? means turning radius for space crafts relative to how well the inertia damp field works. that means DOG FIGHTS! ya!

but it can also mean creative: push the evenlope if you dare game elements. pilot blackouts if you try to accelerate to hard (read turn). or damage causing flux in the damp field giving a fluctating turning radius (because of the pilot muuuush factor). You could also invent tech limitations that drive good game play.. like a rate over time you can use lots of inertia dampening now (read very tight turning/acclerations) but youll have to give up some later becuase of "goasdks effect" (made up).

Share this post


Link to post
Share on other sites
Nearly all space sims build in ''friction'' so that you just don''t keep accelerating forever. It makes for unreal physics but at least you can throttle back maximum velocities.

In Elite and Frontiers the physics was real, but combat was reduced to lining up on each other from 600 klicks and then accelerating hard and firing your lasers, combined approaching velocites would some times exceed 10 klicks per sec.

Do yourself a favour, add friction.

Off the top of my head you could modify F=m/a to become F=(m*(1+log(v)))/a.

Okay thats strght out of thin air, but what it will do is you to require greate and greater force to accelerate your ship at higher velocites.

just my 2 cents

D.V.

Carpe Diem

Share this post


Link to post
Share on other sites
How the ships maneuver and how friction is applied contributes not only to the playability but the fun factor as well. A little slide and strafe ability might not be a bad idea, either. Independence War 2 implemented that style.

For lighting, a nearby star that sends global light in a single direction should light things up well enough - even more than one star shining at different intensities from different directions might make things interesting.

Oh, and try to make your energy shots act as light sources for the nearby objects. It might make the dogfights a little more exciting. Try guided weapons like missiles, too!

Share this post


Link to post
Share on other sites
inertia dampening as a limiter to acceleration also gives resource management game elements.

it accounts for being able to acclerate faster to go forward then you can to turn. but lets say you the player can control that prior to battle.

i mean basically you have to put the sci-fi back into space combat to even have a dog fight so that really gives you license as the game designer to do what ever you want.

even with the friction whos to say that its not related to the technology required to make this all happen. i mean if a gravity/inertia field is required in the first place to even have space combat whos to say that doesnt also have a tendency to bring the effected objects to rest? and whos to say thats not affected by velocity? so i agree with the spirit of the above.

your wide open here. add what you need for fun.

Share this post


Link to post
Share on other sites
My attitude is there is [virtually] no friction in space, but I just got the latest auto-braking retros, w/ programmable braking action in the absence of thrust.

So it behaves somewhat like friction, but is simply an auto-reverse-thrust (energy-consuming!) that enables easy movement in for example the confines of a space dock.

I would use a bit less of it in a dog-fight scenario, and totally disable it for long flights.


Otherwise the physics seems pretty standard.

zin

zintel.com - 3d graphics & more or less

Share this post


Link to post
Share on other sites
I realize the fact that space fights are pure sci-fi, but i don''t want to implement the complex physics of earthly (gracitational) flight.

After looking into examples i think the physics effect i''m looking for is somewhat like that seen in Descent II. The difference is that Descent II is optimized for rapid quick movements in an indoors environment, but some things are like what i want.

What i see the game as is a first person fighter flying fast, doing dogfights and attacking giant ships (50 times larger). For a dog fight i need a wind resistant style friction, the faster you go the more strongly it slows you. It also needs to be able to bring you to a stop over a medium distance. I think a fractional quadratic friction factor would do this. Also i want turns to be like they are in real planes, you have to be moving forward to turn. Also the faster you go the smaller the turn degree, the bigger the radius. I''m not really sure how to do this. I think that i could have a double that represents the maximum turn degree at the current speed, and this could be applied to controlling the turn in any direction. I think i could use this to caclulate total G''s ecpierienced by the pilot, so i could implement effects like temporary black outs on extreme turns (i saw this in a fighter sim).

How does my system for controlling turn look to you? Do you have any other comments? Also i''m still open to suggestions on the lighting.







He who said money was the root of all evil knew little of the nature of money and less about the nature of man.

Share this post


Link to post
Share on other sites
doing it like its done in real physics.

if your moving along a (0,5,0) per a second velocity and you want to be going (0,6,0) per second you accelerate right?

but also if you want to be going (2.5,2.5,0) per a second in velocity you accelerate.

any change of the velocity vector is an acceleration. Turning is accelerating.

Point your thinking? implimenting an acceleration vector gives you the turning radius effect you want.

for example lets say i want to change my velocit of (0,6,0) to (3,3,0) in a curved manner over 6 seconds. a turn. to do that an acceleration vector of (.5,-.5,0). is needed. note that you can control how tight people can turn by just limiting the magnitude of the acceleration vector. higher magnitudes make for tighter turns. lower magnitudes make for wider turns.
note that if at time 0 your position vector is:
(0,0,0) 0 time
(.5,5.5)p (.5,5.5)v
(1.5,10.5)p (1,5)v
(3,15)p (1.5, 4.5)v
(5,19)p (2,4)v
(7.5,22.5)p (2.5, 3.5)v
(10.5,25.5)p (3,3) v

a curve through space caused by a constant accleration. complex behavior from simple rules. oh btw did you ever hear my conclusion that the universe was the greatest demonstration of the power of ALife known. oh wait now you did.

actual space number crunching uses concepts related to the above + a concept of "jerk" jerk is the speed at which acceleration is changing / can change. which if applied to the above makes an even more curvy curve.



Share this post


Link to post
Share on other sites
oh you asked how do i make a turn tight when they are slow and a turn wide when they are fast? acceleration vector has that effect.


lets say your max accleration magnitude is 4. .

now lets say your velocity vector is (0,20) straight out. but you want to turn 45 degrees to make your velocity (10,10). well the fastest you could do it is 13ish seconds.

now lets suppose your velocity vector is (0,10) but you want to turn 45 degrees to (5,5) well the fastest you could do it with the same acceleration is 3.5 seconds.

the first will show a big turn with the same small accleration. the second will show a smaller turn.

the math does get harder with a frictional force. but you dont need to actually solved the frictional + velocity + acceleration + jerk equation till you want to predict things. the the frictional addition will cause you to crunch some numbers to get an accurate interpolation. course most things use a "lets ignore the fact that hes accelerating / decelerating due to friction" and just interpolate based on his current velocity. thats easy.





Share this post


Link to post
Share on other sites
I''m sorry, but i simply cannot fallow a word u say.

I understand having the velocity vector, but i don''t get how you say you use a maxumum acceleration vector to define turns. Here is what i think i''m getting out of you explanation:

The plane has a current postion and velocity.
It also has a Maximum_Acceleration number.

When the plane enters a maximum turn, a vector perpendicular to the current direction vector pointing in the turning direction and of length Maximum_Acceleration is added to the current velocity vector. This creates a new direction vector that is the hypotenuse of the triangle formed by the two vectors. If we just keep using this new vector each time for say ten segments of a turn, then it has quickly become much longer than the origonal. In this case the turn is not of uniform radius, the radius increases as we turn. That doesn''t seem right to me.

What i thought up to fix this is to divide the newly created direction vector by the previous one and and then multiply the new vector by this number. This number than becomes the G effect experienced through that segment of the turn, but the turn radiu and speed stay the same.

Does this seem like it works?



He who said money was the root of all evil knew little of the nature of money and less about the nature of man.

Share this post


Link to post
Share on other sites
i gave cheap examples =)

the "g-effect" and the acceleration are always the same. knowing one knows the other. they are just opposites.

whooo someone is thinking. what bout the tilt-a-whirl at the fair. the "g-effect" is pushing me straight out of the round thing up against the cage wall. "if the "g-effect and your acceleration are the same then your saying that im acclererating straight inward?" EXACTLY =)

the tilt-a-whirl is a fine conceptual example. the slower you go the softer you are pushed against the cage right? cause the slower you turn the less acceleration you need to turn in that radius.

if you spin that thing faster the harder you are pushed into the wall cause the more acceleration you need to keep that same radius.

now on to my cheap examples.

the problem with your picture where you say that inward accleration increases the velocity vector over time is where your picturing the resultant vectors.


ok draw a circle. put a dot on that circle. now tangent to the circle extend a vector. thats your velocity. now draw an acceleration vector from the end of the vector tip straight towards the center of the circle...

notice there are no right angles. =)the acceleration will be angled back towards the position dot. even though its aiming straight at the center. thats where you went wrong in your picture. with no right angles there is no implication that there is a hypothenus. in fact with this picture its easy to see that with accleration angled straight at the center its angled slightly against the velocity vector. keeping it the same size.

i didnt give that in my examples cuase its messy. the smallest possible turning radius that keeps velocity the same will always be with acceleration angled slightly against velocity (this is without friction). if velocity increases then acceleration cant turn it as fast. LIKEWISE the smallest possible turn period involves slowing down. acceleration against velocity. you see this in your car when you want to make the right turn going down the road. same will be true in your space sim.



you dont want that. hard to avoid really.







Share this post


Link to post
Share on other sites
Alright, i''m starting to conceptually see what u are saying. we have our current velocity vector, which is a tangent segment to the turn circle at our location. If we are turning maxed, we have a vector of length MAX_CONST pointing into our circle from the tip of our velocity vector. To calculate our location at the end of of this frame we put the toe of the MAX vector to the head of current velocity vector. The head of the MAX vector is now our current location. Now, if you calculated our old pos to the new in a straight line, then we would be shorter. This is because in theory we went around the perimeter of the circle. Ok its starting to make sense. What i don''t see now is how to calculate the "G effect" of our turn. Where is the vector that represents the force pointing away from the center of the circle over the average of our moved distance?

He who said money was the root of all evil knew little of the nature of money and less about the nature of man.

Share this post


Link to post
Share on other sites
Wait a second, if "G effect" is just a measure of current acceleration, and it can be in any direction, then is the number of G''s linearly related to the length of the MAX_TURN vector + speed acceleratio vector? In this case if the plane can''t turn faster than MAX_TURN and u don''t accelerate through the turn, the G''s are just MAX_TURN mapped in someway to 32 ft per second squared? What about if u are accelerating through the turn (or decelerating for that matter)? In that case, the G''s would still be MAX_TURN because the deceleration is being compensated for in our turn radius, right?

Share this post


Link to post
Share on other sites
gravity is acceleration.

all of this that follows is to make that conceptually clear:
when i let go of something. it falls with acceleration due to gravity.

1g is accelerating at 9.2 meters a second second. so if you know how fast your ship is accelerating you know how much g''s the pilot feels. however notice space numbers are very very large compared to that measly 9.2 meters a second second. changing your velocity by 90 meters per a second say from a 100 meters a second to 190 meters a second in one second is a 10g acceleration. thats why i said in the beginging there is clearly a technology in the story line. theres lots of room for game here.

also note turns. like your car. when you push the gas to much you dont go anywhere: you broke the static friction on your tires. you slow down to fast you break the static friction on your tires cant decelerate as fast. but if you turn you are accelerating so combining any of the above with turning breaks static friction even faster. you see that real life if you try to turn and stop. you only stop faster if your breaks suck. if your breaks are already in full anti-lock mode then turning just causes anti-lock breaks to spend less time actually stopping and more time trying to get static friction back. turning and stopping dont mix well cause they are both forms of acceleration.

the point is now imagine your car doing a constant circle. its accelerating towards center constantly we have established that. but whats going on with the passanger when you do that? hes being pushed up against the door. a fine example of the "g-effect" being acceleration.

so what that means is you take the magnitude of your acceleration divide it by some game technology say divide the acceleration by 15 "effects of dampening field" then divide by 9.2 if its in meters and that tells you how much g force the pilot is feeling. (9.2 because thats the number for acceleration due to one gravity)



Share this post


Link to post
Share on other sites
oh there might come a conceptual messy question if you ask does that mean i feal gravity because im acceleration?

no. and nobody knows why. its a question as old as newton. no bright eyed science student since newton doesnt think to themselves:
its damn odd that we cant tell the difference between inertia and gravity.

inertia is behind this whole thing btw. objects in motion have a tendency to stay in motion. but in our terms your velocity vector will stay the same if left alone is what thats saying. what that means to turning? well your in your car and your car turns. your velocity vector is still going straight however. and if left alone you will continue to go straight. alas the door on your right arm (for passangers) stops you from going straight. likewise the blood in your head would continue to go straight after the door stop your head from going straight. not to noticable there. but if your talking bout the pushing being 5gs at your feet the blood in your head tends to end up in your legs before your body has stoped it from going straight.

back to my point. to date. meaning with modern physics. if you knock out some scientist. drag them into an elevator car. and tell them "you are either on the surface of the earth or you are accelerating foward in space at 9.8 meters per a second second " there isnt a gravity/inertia/time way to measure that question. to date you cant tell the difference.

for the longest time people held onto the belieft that you might have a gravitational mass AND an inertia mass. mass being the statement of these two effects in a scaler form. mass is defined as a bodies resistance to change in motion. thats the actual def. so the question is why does my body always have the same resistance to changes in motion in gravity as it does to inertia. why should that be?

it just is. that was the classical decision over time. why that is? not sure. dunno. there are exotic theories but nothing concrete.








Share this post


Link to post
Share on other sites
Hi guys. Well, I haven''t read the whole post/reply (forgive me...). Yet, I try to write a space sim, and forces computing was a problem.
I solve it by changing the whole calculation: my ships are now controlled by forces, each defined by a direction, a point of application and a magnitude. Then I compute force with newtonian formula (for acceleration and rotationnal effect).
To avoid infinite speed (or constant acceleration), as mentionned in a previous reply, I had an "artifact" (it''s like friction, both for linear and rotational speed), to justify friction (call it a Inertial Compensator ). A ship is controled by 12 forces (10 is enough, but I allow the pilote to ride without the compensator in emergency cases, so he needs a braking device like some thrusters on the front side of the ship).
thoses forces are placed around the ship: 8 to control pitch/yaw/roll and 2 to accelerate on the back side of the ship(I say 2, but one can put as many as one wants!). Physics with forces allow a easy implemtation of gravity or directional as well as rotational force fields. Collision shocks are also easy to add.You can also implement some kind of cool malfunction (i.e a thruster offline, the compensator offline, etc...) with realistic responses of the ship.

For the gameplay and story aspect, it allows a complete explaination of space fight conditions:I always found strange to fight in space at a limited speed, in previous game. by the way, this explained why some ship were faster than others...
so you can say it''s impossible to control a fast flying ship, and engineers have designed an internial compensator. The maximum speed is set by the compensator power (or say anything you want, it''s your game!).

I don''t know if it''s a good way to deal with physic in space, but it works very well for my program!

I hope it will help,
Freeman.

Share this post


Link to post
Share on other sites
Freeman, that seems perfect! For my basic plane i could have a vector straight ahead, one straight back, one up and one down. Since i want to turn by roatating the plane and then pulling straight up, these are all i need (except maybe for small sliding in docking situations). All i have then is just the current velocity vector and these directional vectors. When i want to go faster i add a vector in the same direction as forward and of the length for the speed of acceleration. Friction force is determined by the length of the current velocity and is added in the backward direction. I''m still not sure about how to do the tuirning

He who said money was the root of all evil knew little of the nature of money and less about the nature of man.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
1 g is 9.8 meters per second per second

there''s a suit either in service soon or still being tested that will allow pilots to go up to 10 g''s, and what''s not being done but could be is making the cockpit able to move slightly independent of the ship, kind of like why they put barrels of sand in front of big, hard structures on the roads

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://www.jsc.nasa.gov/er/seh/math55.html

Share this post


Link to post
Share on other sites
quote:
and what''s not being done but could be is making the cockpit able to move slightly independent of the ship


um, this, combined with directional force application (like thrust vectoring or attitude control forces) works like of good.
especially if your cockpit can rotate independently of the ship kindof deals with some of the "pilot mush" when turning.

[andrew''s comment] as you''re in a zero-g environment....

you''d need your inertial compensator tech to be working good too...

centripedal force, well, interesting. think mass transfer being necessary to change the direction of a force when turning.

rambling...

inertial compensator+attitude control+retros = goodness

that''s my two cents'' worth.

flame me.



die or be died...i think

Share this post


Link to post
Share on other sites