### Author Topic: newtonian physics, well sorta  (Read 7888 times)

0 Members and 1 Guest are viewing this topic.

#### Nuke

• Ka-Boom!
• 212
• Mutants Worship Me
##### newtonian physics, well sorta
by sorta i mean it obeys the law of inertia. it doesnt take mass into account yet. this only deals with velocity so rotations are the same as normal. i want to convert max velocity to max thrust output in newtons. in other words a ship at full thrust with the max thrust of 100 will produce 100 newtons of force at full throttle. then i can have acceleration rates based on force vs mass. il deal with that later. my current concern is in making flying newtonian playable. so now im focusing on making the nessicary gauges.

also this only works on the player, need to figure out how to deal with physics on a ship by ship basis, so that all ships operate them. im hopping i can tag objects with custom varibles, then its just a matter of loopong through the ships. the other thing is that it breaks the lead indicators, cause im setting the position directly rather than changing the velocity, which doesnt work. could probibly just use wanderers lead code, which ive butchered into my scripts till i wright my own.

anyway heres the code, id advise using a ship set up for 6dof flight (with slide and rear thrust enabled). you can use any ship but youl have to come about to slow down.

Code: [Select]
`#Global Hooks\$GameInit:[--[[=============================]]----[[======= function defs =======]]----[[=============================]]--setscreenvars = function() --scalers and constants for multi res support local w = gr.getScreenWidth() local h = gr.getScreenHeight() local cx = w/2 local cy = h/2 local wf = 0 local hf = 0 local awh = 0 local hires = false if w >= 1024 then wf = w / 1024 hf = h / 768 awh = (wf + hf) / 2 hires = true else wf = w / 640 hf = h / 480 awh = ((wf + hf) / 2) * 0.625 hires = false end return w,h,cx,cy,wf,hf,awh,hiresendround = function(number) --rounds to nearest whole number, for some stupid reason, lua doesnt have this function local W,F = math.modf(number) if F < 0 then if F <= -0.5 then W = W - 1 end else if F >= 0.5 then W = W + 1 end end return Wendprograderet = function(x,y,vel) x, y = x*wf, y*hf --round theese, our vector gets jumpy gr.setColor(72,192,72,222) gr.drawGradientLine(x + (12*awh), y + (12*awh), x + (6*awh), y + (6*awh) ) gr.drawGradientLine(x - (12*awh), y - (12*awh), x - (6*awh), y - (6*awh) ) gr.drawGradientLine(x - (12*awh), y + (12*awh), x - (6*awh), y + (6*awh) ) gr.drawGradientLine(x + (12*awh), y - (12*awh), x + (6*awh), y - (6*awh) ) vel = tostring(vel) gr.setColor(128,192,128,222) gr.drawString(vel, x - (gr.getStringWidth(vel) / 2), y - (2*awh) )endw,h,cx,cy,wf,hf,awh,hires = setscreenvars()]\$Simulation:[player = mn.Ships["Alpha 1"]if player:isValid() then if lvel == nil then lvel = ba.createVector(0,0,0) end lvel = lvel + ( player.Physics.VelocityDesired * 0.01 * ba.getFrametime() ) wvel = player.Position + lvel lmag = lvel:getMagnitude() lmag = lmag / ba.getFrametime() gr.drawString( round(lmag), 100 ,100) Vx,Vy = (wvel + (lvel*lmag) ):getScreenCoords() player.Position = wvelend]\$HUD:[if player:isValid() then if Vx then prograderet( Vx, Vy, round(lmag) ) endend]#End`
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

#### Nuke

• Ka-Boom!
• 212
• Mutants Worship Me
##### Re: newtonian physics, well sorta
i set it up for real newtonian but its buggy as hell so im not gonna post it. it takes the models mass field into account. a ships max velocity converts over directly to max thrust in newtons. i did find out that to get space shuttle ohms burn equivelant acceleration on a ship with a mass of about 7500 thakes about 3800 newtons. this is a huge geuesstimation though. i figure combat will reqire about twice that much thrust. might up the conversion to kilonewtons to make it more compatable for the average freespace fighter.

the major bugs are that i cant just directly modify the physics.velocity, seems freespace still wants to run its own physics on top of everything. i can change it but freespace just ignores it. so icheat and change the position directly. this breaks anything from lead reticles to collision detection. it also stutters . cause freespace wants to put the ship in one place and i want it somewhere else. i need a way to override the submarine-physics freespace uses to implement this right.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

#### G0atmaster

• 28
##### Re: newtonian physics, well sorta
I noticed that there's a cheat code for FS2 that enables Descent physics.  Would this possibly be helpful to you?
Could we with ink the ocean fill, and were the skies of parchment made
Were every stalk on earth a quill, and every man a scribe by trade
To write the love of God above, would drain the ocean dry
Nor could the scroll contain the whole, though stretched from sky to sky!

#### Taristin

• Snipes
• 213
• BlueScalie
##### Re: newtonian physics, well sorta
Eh? How come no one else ever heard of this?
Freelance Modeler | Amateur Artist

#### Unknown Target

• Get off my lawn!
• 212
• Push.Pull?
##### Re: newtonian physics, well sorta
It's always been there, heh, it's on most sites that have cheats for FS2.

#### Backslash

• 29
• Bring Our Might To Bear
##### Re: newtonian physics, well sorta
I think if you were to set the \$Damp of all ships to 0, you might have what you need (FS not interfering with its own 'momentum' physics as much).  Give it a try.

#### Taristin

• Snipes
• 213
• BlueScalie
##### Re: newtonian physics, well sorta
It's always been there, heh, it's on most sites that have cheats for FS2.

I dont recall ever seeing them Only the usual ones... Bizarre I'd miss it...
Freelance Modeler | Amateur Artist

#### G0atmaster

• 28
##### Re: newtonian physics, well sorta
Could we with ink the ocean fill, and were the skies of parchment made
Were every stalk on earth a quill, and every man a scribe by trade
To write the love of God above, would drain the ocean dry
Nor could the scroll contain the whole, though stretched from sky to sky!

#### Nuke

• Ka-Boom!
• 212
• Mutants Worship Me
##### Re: newtonian physics, well sorta
if it doesnt follow all 3 newton laws its not newtonian i think i got 2 down, but im not gonna mess with it for awhile. actually i did set damp and all acceleration values to zero, which prevented freepace physics from coming full on, and that in combination with forcing the ship to may own position variable. it still stutters, like the ship wants to be much further behind where it actually is.

i think this actually has something to do with the max velocity of 3800 (which my code interprets as force in newtons) i was using. the ship wanted to jump 4 clicks before getting told where it needs to be. come to think of it converting the force to kilonewtons so that my max velocity is only 18 might work. i wouldnt mind having Ship.Physics.VelocityApplied, which is essentially a direct line from the imput device. would also make cockpit controls work smoother. right now we have Physics.VelocityDesired, which is really just the axis imputs ramped by acceleration.

flying newtonian is much more about thrust timing than throttle position. contrary to popular belief its incredibly fun if you use a sci-fi based engine thrust characteristics, such as using an orbital incertion engine for orbital manuvers a couple space shuttle oms engines are enough to make a small fighter incredibly fun to fly. but you must consider that in the future we will have engines that can throw you back in your seat at about 9 gs.

as for the descent physics, im sure they would be usefull if people wanted a descent mod. actually i thought they were in fs1, i never could get em working in fs2. technically the engine is better suited for a battletech mod, which can be done with scripting by the way. get me a fully textured 10,000 poly timberwolf and watch me not implement it
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

#### chief1983

• Still lacks a custom title
• 212
• ⬇️⬆️⬅️⬅️🅰➡️⬇️
##### Re: newtonian physics, well sorta
Mechwarrior 5 here we come.  Sign me up!
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

#### -Joshua-

• 211
##### Re: newtonian physics, well sorta
Mechwarrior 5 here we come.  Sign me up!

Mechwarrior 5? WHERE?

This mod works on all the ships

#### Mobius

• Back where he started
• 213
• Porto l'azzurro Dolce Stil Novo nella fantascienza
##### Re: newtonian physics, well sorta
Stupid question: a ship at full throttle that collides with another it will transfer its energy?
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

#### Nuke

• Ka-Boom!
• 212
• Mutants Worship Me
##### Re: newtonian physics, well sorta
it shoud, i think, but my script breaks collisions. full throttle just means your accelerating, turn it off and you stop accelerating but you continue your flight path. if your momentum cant carry itself out, as in it hits something. well that energy needs to go somewhere. and if you smack into a ship it will more likely blow up both ships and send pieces in all directions than transfer momentum. if its at slow speed, youl hit, transfer some of your energy, and the other object should slightly change its speed. sorta like what you see when they try and couple train cars.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

#### Mobius

• Back where he started
• 213
• Porto l'azzurro Dolce Stil Novo nella fantascienza
##### Re: newtonian physics, well sorta
...which is realistic. Excellent work, Nuke!
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

#### Nuke

• Ka-Boom!
• 212
• Mutants Worship Me
##### Re: newtonian physics, well sorta
well i wouldnt say that. this is a flopped implementation of physics through scripting. id need a +override tag for physics and a replacement for colision detection. for newtonian tourque id need to have access to the moi tensor and of knoledge of physics math. which sucks because i can barely manage to do transformations. also it turns out my physics is only a cheap aproximation of what really goes on.
« Last Edit: May 14, 2007, 07:50:35 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

#### Mobius

• Back where he started
• 213
• Porto l'azzurro Dolce Stil Novo nella fantascienza
##### Re: newtonian physics, well sorta
But it appears to be something interesting.

Can you do this for beams? I mean...

I want to know if you can recreate a strange-real beam effect, with the beams influencing the way you move compromising everything(meneuverability, speed)if you're close to them.
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

#### Nuke

• Ka-Boom!
• 212
• Mutants Worship Me
##### Re: newtonian physics, well sorta
i dont know about that. getting hit by a beam is one of the few occasions where freespace actually uses proper physics.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

#### Mobius

• Back where he started
• 213
• Porto l'azzurro Dolce Stil Novo nella fantascienza
##### Re: newtonian physics, well sorta
Let me use a simple scheme:

Spacecraft

-------------------------
Beam
-------------------------

Is there a way to compromise speed and meneuverability of a spacecraft close to the beam? It would be perfect in an atmospheric environment, for example.
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

#### Nuke

• Ka-Boom!
• 212
• Mutants Worship Me
##### Re: newtonian physics, well sorta
not sure. you need to know where the beam is in space first. you can get the gunpoint, but im not tu sure about the other end of the beam. ypou can calculatre where the turret is pointing using the turret object's  .gunOrientation field. its a matrix so use it to unrotate some arbitrary vector. i did this before with my turret script but it probibly works way different for single part turrets, and the beam might not fire along that vector, depending on the type of beam, turret and so on. once you have that you can use some math to determine how far you are from the closest part of the beam. i think theres a hook for weapon impacts so you can hook into it, then check your distance from the photon shaft, and apply some amount of random distortion the your ships velocity vector. so what you want is somewhat possible.
« Last Edit: May 18, 2007, 03:09:41 am by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

#### Mobius

• Back where he started
• 213
• Porto l'azzurro Dolce Stil Novo nella fantascienza
##### Re: newtonian physics, well sorta
Which, translated, means:

No, you suck. You can't.
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]