• Programming - WAYWO - V.37
    1,000 replies, posted
[QUOTE=Xeon06;40169880]Making proper plane physics, even "casual" ones, is incredibly hard. I tried that a few months ago for two weeks then gave up. If anyone has any examples / articles on the subject, I'm still pretty interested in it.[/QUOTE] It's not [i]that[/i] difficult, just do it in terms of simplified forces and vectors and you'll find it really easy. All you need is gravity always acting downwards, lift acting normal to the plane of the wings and in proportion to the velocity tangential to them, and thrust acting tangential to the engines/body. Find the resultant force, use newton's second law to get the acceleration, and boom basic flight sim. To keep it really simple just use the force for translation and handle rotations straight from the keyboard input as you're probably already doing :smile: For more detail- Lift is proportional to half the square of the velocity multiplied by a coefficient (and the area of the wings, reynolds number, etc, but for now we'll ignore that and include it in the constant). We want the plane to stay in the air if it is flying parallel to the ground, so lift force must equal the force of gravity. Let's assume we also want the velocity at which the plane will do this is at 110m/s (around 250mph) and the plane has a mass of 20,000kg. The force of gravity on the plane is 9.81*20000 = 196200N Lift must therefore be 196200N, and is related to velocity where L = (v^2/2)*C So the constant C you want will be roughly 32. Bare in mind the velocity in this case is the velocity tangential to the wings, not the actual velocity of the plane.
[QUOTE=Laserbeams;40169356]It crashes on mine, sorry[/QUOTE] What happens, exactly? [editline]5th April 2013[/editline] I have a very vague understanding of airplanes. If someone could point me in the right direction, that would be great.
[QUOTE=eggplant;40170200]What happens, exactly?[/QUOTE] I launch the program, and it just crashes immediately and a "Program has stopped working" message pops up
[QUOTE=Laserbeams;40170292]I launch the program, and it just crashes immediately and a "Program has stopped working" message pops up[/QUOTE] What OS are you running? Is it 64 bit or 32 bit? My plane movement code looks like this currently: [CODE] plane.setYangle(plane.getYangle()+((plane.getZangle()/5000)*World1.getTimeDelta())); plane.setX(plane.getX()-World1.getTimeDelta()*speed*TDML::Math.sin(plane.getYangle())*TDML::Math.cos(plane.getXangle())); plane.setZ(plane.getZ()-World1.getTimeDelta()*speed*TDML::Math.cos(plane.getYangle())*TDML::Math.cos(plane.getXangle())); plane.setY(plane.getY()+World1.getTimeDelta()*speed*TDML::Math.sin(plane.getXangle())); plane.setY(plane.getY()-(World1.getTimeDelta()/1000));[/CODE]
I'm running 64-bit Windows 8, if you're at all interested. :)
[QUOTE=Chris220;40170601]I'm running 64-bit Windows 8, if you're at all interested. :)[/QUOTE] Thanks, I am on 64 bit Windows 7, so maybe he is using 32 bit.
[QUOTE=eggplant;40170613]Thanks, I am on 64 bit Windows 7, so maybe he is using 32 bit.[/QUOTE] You should always compile games and engines for 32-bit for the sake of compatibility.
[QUOTE=NightmareX91;40170643]You should always compile games and engines for 32-bit for the sake of compatibility.[/QUOTE] Or provide binaries for both?
[QUOTE=NightmareX91;40169832]You spin me right round baby right round. Does the engine have anti-aliasing and shader support etc?[/QUOTE] Anti-aliasing - Yes Shaders - No
[QUOTE=chaz13;40170158]It's not [i]that[/i] difficult, just do it in terms of simplified forces and vectors and you'll find it really easy. All you need is gravity always acting downwards, lift acting normal to the plane of the wings and in proportion to the velocity tangential to them, and thrust acting tangential to the engines/body. Find the resultant force, use newton's second law to get the acceleration, and boom basic flight sim. To keep it really simple just use the force for translation and handle rotations straight from the keyboard input as you're probably already doing :smile: For more detail- Lift is proportional to half the square of the velocity multiplied by a coefficient (and the area of the wings, reynolds number, etc, but for now we'll ignore that and include it in the constant). We want the plane to stay in the air if it is flying parallel to the ground, so lift force must equal the force of gravity. Let's assume we also want the velocity at which the plane will do this is at 110m/s (around 250mph) and the plane has a mass of 20,000kg. The force of gravity on the plane is 9.81*20000 = 196200N Lift must therefore be 196200N, and is related to velocity where L = (v^2/2)*C So the constant C you want will be roughly 32. Bare in mind the velocity in this case is the velocity tangential to the wings, not the actual velocity of the plane.[/QUOTE] might be misreading something here, but this kind of solution would only produce lift if the plane is flying with < 180 degrees roll, and if it was upside down, it'd experience lift pushing it [I]downwards[/I] as well as gravity? a plane capable of rolling upside down easily (we're not talking airliners here :V) wouldn't have much trouble producing lift (though whether it is called lift in this case, I'm not sure), but its angle of attack would have to be higher - the thrust vector then helps a bit with the lower lift and the wings try to 'glide' upwards maybe to emulate it to a degree, on top of the aerofoil lift you describe, the plane has a fairly large amount of drag in it's local up/down direction (dependant on speed just like the lift), so even if there was no lift force, the plane could still fly (you'd just have to pitch up the nose more) [editline]5th April 2013[/editline] [QUOTE=eggplant;40170354]What OS are you running? Is it 64 bit or 32 bit? My plane movement code looks like this currently: [CODE] plane.setYangle(plane.getYangle()+((plane.getZangle()/5000)*World1.getTimeDelta())); plane.setX(plane.getX()-World1.getTimeDelta()*speed*TDML::Math.sin(plane.getYangle())*TDML::Math.cos(plane.getXangle())); plane.setZ(plane.getZ()-World1.getTimeDelta()*speed*TDML::Math.cos(plane.getYangle())*TDML::Math.cos(plane.getXangle())); plane.setY(plane.getY()+World1.getTimeDelta()*speed*TDML::Math.sin(plane.getXangle())); plane.setY(plane.getY()-(World1.getTimeDelta()/1000));[/CODE][/QUOTE] for more real movements, you're going to want to be talking in terms of velocities and acceleration I think
At the very least normalise your angles between -pi and pi to stop the effect I showed in my video. :v:
yeah it all depends how real looking you want it
I actually fixed it on my own really quickly! I just create a vector sticking directly out of the front of the plane, and used some rotate methods to point in front of the plane. The plane is moved along this vector, and the camera position is set to be the plane position minus the same vector. It works really well! [CODE] TDML::vector3d forward = TDML::vector3d(0,0,1); TDML::Math.rotate(forward, plane.getXangle(), plane.getYangle(), plane.getZangle(), ZXY); plane.setX(plane.getX()-World1.getAdjustedTime(forward.x, 14)); plane.setY(plane.getY()-World1.getAdjustedTime(forward.y, 14)); plane.setZ(plane.getZ()-World1.getAdjustedTime(forward.z, 14)); [/CODE] I will upload a new version soon
[QUOTE=Xeon06;40169880]Making proper plane physics, even "casual" ones, is incredibly hard. I tried that a few months ago for two weeks then gave up. If anyone has any examples / articles on the subject, I'm still pretty interested in it.[/QUOTE] have a gander at how the gmod addon fin2 handles it in its code, the no-lift method is the base - it provides no lift but resistance to falling perpendicular to the velocity vector, and then the lift methods just add a force onto that "upwards" using practically the method chaz describes using the no-lift method provides a decent experience, but it does mean that flying level does not mean flying without drop, you either add lift (which adds a force upwards, if your upside down that means you just fall faster :v) or you tilt the wings upwards a bit. real planes use a combination of both, and no-lift wings are a reality, very common in model rc planes and some aerobatics planes use symmetrical aerofoils (some might use flat wings, idk) that's all practically for a "casual" experience, if your applying that to the whole plane and treating it as a single object, realistic shit is when it gets tricky and your better off looking up papers or talking with BlackPheonix [editline]6th April 2013[/editline] [QUOTE=eggplant;40171847]I actually fixed it on my own really quickly! I just create a vector sticking directly out of the front of the plane, and used some rotate methods to point in front of the plane. The plane is moved along this vector, and the camera position is set to be the plane position minus the same vector. It works really well! [CODE] TDML::vector3d forward = TDML::vector3d(0,0,1); TDML::Math.rotate(forward, plane.getXangle(), plane.getYangle(), plane.getZangle(), ZXY); World1.setCamX(plane.getX()+(forward.x*zoom*(pow(2, zoomlevel)))); World1.setCamY(plane.getY()+(forward.y*zoom*(pow(2, zoomlevel)))); World1.setCamZ(plane.getZ()+(forward.z*zoom*(pow(2, zoomlevel)))); [/CODE] I will upload a new version soon[/QUOTE] yeah man if you don't want to do it physically (I can think of plenty of games where adding a more realistic flight model is just bloat or even detrimental to the experience) then that looks like a decent way of doing it
If you all remember, I was working on an RTS sort of like Command and Conquer, and Total Annihilation. Recently I added a few things, such as resource collection, strategic bombers, helicopters, and pedestrians that randomly walk around from one civilian building to another. These can be shut off in the map configuration. I still got a lot to do but it's a step toward the finish. [video=youtube;OUY9uWshCFE]http://www.youtube.com/watch?v=OUY9uWshCFE[/video] I'm trying to figure out what I should do with the UI and if I should have a built in level editor or just use the Tiled map editor that libGDX utilizes.
And... the new version is up. I fixed the rotations and made the camera follow behind the plane, which is cool but kind of nauseating. It also somehow broke my smoke particles upon crashing, which I will have to look into. Also, the right/left controls are backwards. Apart from that, how could I made the camera better? Once again, thank you guys! [url]http://www.eggplantanimation.com/PlaneGame/[/url]
[QUOTE=eggplant;40172219]And... the new version is up. I fixed the rotations and made the camera follow behind the plane, which is cool but kind of nauseating. It also somehow broke my smoke particles upon crashing, which I will have to look into. Also, the right/left controls are backwards. Apart from that, how could I made the camera better? Once again, thank you guys! [url]http://www.eggplantanimation.com/PlaneGame/[/url][/QUOTE] Will you ever implement a lighting engine to TDML and eventually shaders? I think it has much potential. [editline]5th April 2013[/editline] So I got a look at under the water, and it doesn't necessarily look too pleasing. [img]http://puu.sh/2uqzs[/img]
[QUOTE=Perl;40169128]msg.[b]c[/b]hat.[b]S[/b]end hnng lowercase public fields/properties/methods[/QUOTE] Did you even read my post "Desperately needs to be run through ReSharper."?
[QUOTE=NightmareX91;40172570]Will you ever implement a lighting engine to TDML and eventually shaders? I think it has much potential. [editline]5th April 2013[/editline] So I got a look at under the water, and it doesn't necessarily look too pleasing. [img]http://puu.sh/2uqzs[/img][/QUOTE] I thought I had added water collisions in. Oops! I don't know about shaders/lighting. They seem complicated, but then again that is what I said about textures, VBO's, and ground collisions. I will do more reading and might have them working in a month or two. Thank you for the compliment, by the way!
[QUOTE=eggplant;40172749]I thought I had added water collisions in. Oops! I don't know about shaders/lighting. They seem complicated, but then again that is what I said about textures, VBO's, and ground collisions. I will do more reading and might have them working in a month or two. Thank you for the compliment, by the way![/QUOTE] Considering that the fixed function pipeline is removed in OpenGL 3.2 core, and doesn't exist in OpenGL ES 2.0, I would keep it in mind.
How are you doing your collisions, by the way? I'm interested.
[QUOTE=KmartSqrl;40157915]Ruby. Ruby ruby ruby ruby ruby. I do web dev for a living and Ruby is hands down the best language I've used for it yet. It does an amazing job of getting out of your way and letting you write what you want. Rails is amazing as well, and the great gem ecosystem makes focusing on writing your application way easier too. Say I want to add facebook login to a website. Install omniauth and omniauth-facebook, write a few lines of code to integrate it, and it works.[/QUOTE] Me too, for almost a year now. We've used RoR almost exclusively for back-ends. I agree in this instance, that Ruby & Rails is the easiest way, but it's far from the best. We've been "forced to" develop on Windows, and there has been quite a few problems, but we have overcome [u]every single one[/u] of them, sometimes after days of trying though. Some gems just won't work on Windows (some of the gems with native extensions or dependencies), but usually there's a separate Windows version or at least an alternative in that case. After all it is free software and if some gem doesn't work, it's usually just because no-one has gone through the trouble of getting it to compile on Windows. Agreed, you need some knowledge about native programming if you want to understand the problems you will eventually face if you choose to develop on Windows. You're also going to face some very undescriptive error messages that don't relate to the real problem at all. This isn't exclusively a Windows or gem problem though. The biggest problem is that MRI (the original Matz's Ruby Interpreter) is just very slow (to start) and has a quite large memory footprint. It was originally developed for Unix-based systems, so it works a little faster there (still very slow). On Windows, you have to wait between 10-30 seconds just to run tests (even one), start your server or run any script. Once the interpreter is running though, everything is fine. Ruby has the concept of threads/concurrency, but [url=https://blog.engineyard.com/2011/ruby-concurrency-and-you]MRI cannot actually run Ruby code in parallel[/url], so you're stuck on one core unless you start more than one process (but it is going to hog that many times memory then). Application servers generally start multiple processes. You could try other interpreters like JRuby (real multi-threading!), but I imagine you're gonna face compatibility problems with gems as these 3rd party interpreters can't always keep up with the MRI. I'm not really surprised it's slow when it was designed with mainly developer joy in mind. It is very good at that job. Unless you like TDD, because it's going to be a waste of time to try to fix a problem and re-run tests as you spend 10-30 seconds waiting for the interpreter on every iteration. Also debuggers don't work perfectly (at least on Windows). Good news is that you can keep your development server running while you develop, as it can reload code (except of course initializers) when you refresh. Other than that, the language is incredibly flexible and allows for some great elegance, though sometimes [url=http://stackoverflow.com/questions/372652/what-are-the-ruby-gotchas-a-newbie-should-be-warned-about]it can be a problem[/url]. Rails is fantastic, but in my opinion it is getting old. Nowadays it's easy to leave the processing up to the client (JS) and just make minimal back-ends. If you want to make a single-page web application with a minimal (and FAST) back-end, Rails seems a bit overkill, although it makes it incredibly easy. [b]tl;dr[/b] Ruby is awesome as a language and RoR makes things easy, but those are the good news and there's a load of bad news to top it off. Now if we only had a good (C++ & modern/OO/minimal/fast/modular/extendable) framework for JSON API web services.
Anyone got a cheat sheet for modern rendering pipelines? google keeps giving me the fixed function pipeline
From googling "modern graphics pipeline" [img]http://traxnet.files.wordpress.com/2011/07/pipeline.png[/img]
[QUOTE=Richy19;40173138]Anyone got a cheat sheet for modern rendering pipelines? google keeps giving me the fixed function pipeline[/QUOTE] To quote nVidia and Valve, "Read the specification, it will make you more powerful than you can possibly imagine". [editline]5th April 2013[/editline] It also has a nice diagram on the cover.
[img]http://i.imgur.com/WzJLWRO.png[/img] Baby's first struct printing itself (it's a vector)
[QUOTE=robmaister12;40173167]From googling "modern graphics pipeline" [img]http://traxnet.files.wordpress.com/2011/07/pipeline.png[/img][/QUOTE] Isn't it missing geometry shaders? Either that or vertex shaders.
Here's the cover of the OpenGL 4.3 specification. [url=http://www.opengl.org/registry/doc/glspec43.core.20130214.pdf][img]http://files.bytecove.co.uk/glspec.png[/img][/url] You can get the older specifications from [url=http://www.opengl.org/registry/]here[/url].
[QUOTE=eggplant;40172749]I thought I had added water collisions in. Oops! I don't know about shaders/lighting. They seem complicated, but then again that is what I said about textures, VBO's, and ground collisions. I will do more reading and might have them working in a month or two. Thank you for the compliment, by the way![/QUOTE] Also, is there a maximum world size and height? And are custom skyboxes possible? And what about animated models? As for improving the camera in your plane game, maybe you could make it lag behind the plane's movements and smooth the camera out a bit?
[IMG]http://puu.sh/2utef[/IMG] Fuck. [IMG]http://puu.sh/2uth1[/IMG] Fuck. Why is it so hard to center a sprite...
Sorry, you need to Log In to post a reply to this thread.