Show Posts
|
Pages: [1]
|
1
|
Game Development / Game Mechanics / Car Physics Problem
|
on: 2013-08-24 15:14:58
|
Hello. I have started developing a racing game, so I started by implementing the car physics by the guide of "Marco Monster", as well as a little "debug screen". It is partly german though, so here a little translation: "Geschwindigkeit"="Speed" "LW-Kraft"="Air resistance force" "RW-Kraft"="Rolling resistance force" "Beschleunigung"="Acceleration" Anyways, I'm having a few problems here. First of all, I'm tracking the wheel speed separately, this works pretty well for high speeds, but at low speeds it just spazzes out. Also, if you're not accelerating, the wheels decelerate wayyy to fast. The third problem is that the maximum speed is about 180 km/h (or 112mph) in 4th gear, because in 5th and 6th gear, the car continues to decelerate (This is pretty logical, considering the engine torque goes down, because of that the driving force goes down, so the air resistance is greater than the driving force, which decelerates the car, but that shouldn't happen, correct?) Here is the most important part of the source: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| public void update(float delta, boolean accelerating) {
float speed = v.length();
Main.renderStringFormatted(29, "%d", (int) rpm); Main.renderStringFormatted(30, "%d", gear + 1); Main.renderStringFormatted(0, "Geschwindigkeit: %.1fkm/h", speed * 3.6);
rpm = wheelSpeed * vehicle.getGearRatio(gear) * 30 / Constants.PI; if (rpm < vehicle.getMinimumRPM()) rpm = vehicle.getMinimumRPM(); if (rpm > vehicle.getMaximumRPM()) if(shiftGearsUp()) rpm = wheelSpeed * vehicle.getGearRatio(gear) * 30 / Constants.PI; else rpm = vehicle.getMaximumRPM();
float Fdrive = vehicle.getEngineTorque(gear, rpm) / vehicle.getTireDiameter(); Vector2f Ftraction = accelerating ? dir.mul(Fdrive) : new Vector2f(); Vector2f Fdrag = v.mul(-vehicle.getShapeDrag() * speed); Vector2f Frr = v.mul(-vehicle.getShapeDrag() * 30);
Vector2f Flong = Ftraction.add(Fdrag).add(Frr);
Main.renderStringFormatted(1, "LW-Kraft: %.1fN", Fdrag.lengthSigned(dir)); Main.renderStringFormatted(2, "RW-Kraft: %.1fN", Frr.lengthSigned(dir));
float Wr = vehicle.getBackTireLoad(Flong.lengthSigned(dir) / vehicle.getMass()) / (vehicle.getMass() * 9.81f); Main.renderStringFormatted(5, "Load V: %.2f%s", Wr, "%");
Flong = Ftraction.mul(Wr);
Vector2f Ffriction = new Vector2f();
if (speed > 0) { float slip = (wheelSpeed * vehicle.getTireDiameter() - speed) / speed; Main.renderStringFormatted(4, "Slip: %.2f", slip);
Ffriction = Ftraction.mul(Math.min(16.6666667f * slip, 1)); }
Flong = Flong.add(Frr); float Tfriction = Ffriction.lengthSigned(dir) * vehicle.getTireDiameter(); float Tdrive = Flong.lengthSigned(dir) * vehicle.getTireDiameter(); float Ttotal = Tdrive - Tfriction; float aa = Ttotal / vehicle.getRearTireInertia(); wheelSpeed += aa * delta; Main.renderStringFormatted(6, "Tfriction: %.2fNm", Tfriction); Main.renderStringFormatted(7, "Tdrive: %.2fNm", Tdrive); Main.renderStringFormatted(8, "Ttotal: %.2fNm", Ttotal); Main.renderStringFormatted(9, "Angular acc.: %.2frad/s^2", aa); Main.renderStringFormatted(10, "Wheel vel.: %.2fkm/h", wheelSpeed * vehicle.getTireDiameter() * 3.6); Flong = Flong.add(Fdrag); Vector2f a = Flong.div(vehicle.getMass());
Main.renderStringFormatted(3, "Beschl.: %.2fm/s^2", a.lengthSigned(dir));
v = v.add(a.mul(delta)); if (dir.dot(v) < 0) v = new Vector2f();
pos = pos.add(v.mul(delta)); } |
And here is a SSCE: download (Source code/debug scripts/LWJGL/runnable jar included, start the debug.bat for your system) Thanks for your time.
|
|
|
2
|
Games Center / Cube World Projects / Re: LWJGL - Pre-Loaded Display lists
|
on: 2012-11-16 14:04:36
|
I wouldn't worry much about performance in your case. Just make the chunks small enough, and there won't even be a dent in the FPS when a new chunk is loaded. Try to aim for 16x16 chunks.
Thanks for your answer! Well, making the chunks small enough does work for this project, since I'm using a heightmap, but for my 3D-Cube-World, it lags the game down once in a while. What I'll try now is doing the loading in the free time between the render loop and the next execution of it.
|
|
|
3
|
Discussions / Miscellaneous Topics / Re: Age is just a number....
|
on: 2012-11-12 20:28:00
|
14.
Programming web since 11. (Gave up because HTML/PHP is useless for games. Did not know about Javascript) Programming Java since late last year (modding Minecraft) Programming my own games since the start of this year. Programming a networked game (without Kryonet) since two months before I turned 14. (but I gave up) Programming with LWJGL since 1 month before I turned 14. Programming a voxel engine since two weeks before I turned 14.
You must be my lost twin lol  I'm 14, too, started HTML/PHP at ~12, gave that up, started Java last year by modding Minecraft, started programming my own games since this year, did some stuff with network programming, started lwjgl 1 month before I turned 14 and have started a voxel engine since I'm about 14, too. This is truly astonishing..
|
|
|
4
|
Games Center / Cube World Projects / LWJGL - Pre-Loaded Display lists
|
on: 2012-11-12 20:05:05
|
Here I am again with yet another question. Can you pre-render display lists without lagging the game? Like if you get into a new region of a map, it loads the new "regions" of the world and pre-renders them in display lists, maybe in another thread? I thought of doing it in the loop in the time that is usually waited for the Display to sync to like 60 fps, but that'd require me to continue a display list. Is there a call for that, like GL11.glLoadList(listid); or something similar? Thanks in advance.
|
|
|
7
|
Java Game APIs & Engines / Engines, Libraries and Tools / LWJGL - Fade Textures into eachother
|
on: 2012-11-11 18:10:27
|
Hello there, I'm new to this forum (But not too much to LWJGL  ) and I was looking for a way to fade 2 textures into eachother. But no time based fade, more like a Quad, that has the one texture on the one side, and the other texture on the other side, and fades between those two. I tried using 2 quads that faded into nothing, but that made the other one that faded the other texture in the other direction disappear. I haven't found any other way, and don't find anything on the webs. Any ideas? Thanks for your time.
|
|
|
|
|
ivj94
(584 views)
2018-03-24 14:47:39
ivj94
(48 views)
2018-03-24 14:46:31
ivj94
(382 views)
2018-03-24 14:43:53
Solater
(62 views)
2018-03-17 05:04:08
nelsongames
(109 views)
2018-03-05 17:56:34
Gornova
(159 views)
2018-03-02 22:15:33
buddyBro
(702 views)
2018-02-28 16:59:18
buddyBro
(92 views)
2018-02-28 16:45:17
xxMrPHDxx
(493 views)
2017-12-31 17:17:51
xxMrPHDxx
(733 views)
2017-12-31 17:15:51
|
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
|
|