Join us on Discord!
You can help CodeWalrus stay online by donating here.

c4's 3D Game Engine [3d][lwjgl][java]

Started by c4ooo, July 22, 2016, 07:40:10 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dream of Omnimaga

Hm you really need to make collision detection non-dependent on frame rate and performance. Maybe add frame skipping while still calculating positions but just not rendering the frame? Maybe someone else like @ben_g , @TheMachine02 , @tr1p1ea or @catastropher might be able to help, especially that they all worked on calculator-based 3D polygon engines.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

c4ooo

#31
Well the collision issue is caused becouse everything in the game moves faster as FPS drops. So if your usual speed is 1 m/s at 60fps, you will be going 6 m/s at 10fps. That way objects in the game always move at the same speed regardless of FPS, but this causes inacuracies.
Also, got textures working :)

Dream of Omnimaga

What I would suggest is maybe add speed throttling l.

Also I lost. :P
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Snektron

You should make the update loop independent of the game loop, so the update loop runs at a constant speed and the render loop can vary. You could also use the time change since the last frame. For example if the last frame was 16 ms ago (a typical time in 60 fps games), and you have an object  that goes 1 m/s then you would add 0.016m.
  • Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...


c4ooo

Yea that's exactly what ime doing. "Speed is 1 m/s at 60fps, you will be going 6 m/s at 10fps" ;)

Dream of Omnimaga

Sometimes it's better to not go overboard with the frame rate. You don't need more than 60 fps normally. :P
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

c4ooo

The problem is happening because frame rates are *too low*. The higher the frame rate the more accurate the collision, as object move less per frame if frame rates are higher.

c4ooo

Heres a picture of a bed model i made:
Ime still so cing unsure if i would be able to turn this into a good looking game :/

ben_g

Quote from: c4ooo on August 05, 2016, 05:37:31 AM
The problem is happening because frame rates are *too low*. The higher the frame rate the more accurate the collision, as object move less per frame if frame rates are higher.
If 60fps is not enough, then you can 'simulate' higher framerates by handling the collision in multiple steps: If an object moves from point A to B, then first handle the collision as if the object moved to the location in the middle between A and B, and then handle it for location B if no collision occurred. You can increase the amount of steps as necessary, and you can even make it depend on the framerate.

If you don't reach 60fps, then you could try to optimize the rendering, since LWJGL should be more than capable of rendering a scene like that at 60fps even on very slow computers. If you don't have a lot of experience with shaders, then also try to find out more about how they work, since they work a bit differently than software that runs on the CPU. For example, branching (if's and loops) can cause a big performance drop in shaders, and it's often better to do extra calculations in order to avoid branching.

Dream of Omnimaga

I like the bed. I think shading would be enough for it.
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

Powered by EzPortal