Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (797)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (864)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Should I make a physics engine?  (Read 12632 times)
0 Members and 1 Guest are viewing this topic.
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Posted 2014-12-14 08:30:28 »

I've been playing with JBullet lately, and I must say, it's pretty flippen amazing. But there seems to be annoying little glitches everywhere, that seems to always be literally unfixable, due to how the collision works, ( things constantly shake when a mass's force is applied to them for instance ). And I was thinking of implementing a physics system into my scene-graph-oriented game engine.

I am planning on this being for "Cross", my game I've been working on for a while, and I'm learning things literally as I go. I've never touched scene-graphs, shadow mapping, post-processing, or even 3D lighting until about three weeks ago. Plus, I'm learning allot! So I've been thinking of making my own physics engine from the ground up.

All I really need is some basic knowledge on collision and vector-math/physics right? I've pretty much got the callback & software architecture side figured out. Does anyone have some good books/articles on how this is usually done?

Thanks in advance.

Offline SHC
« Reply #1 - Posted 2014-12-14 09:02:47 »

I don't think that making a new physics engine is a good idea. Even full fledged 3D engines like JME3 are using jBullet, and more-over, making a good physics engine is not a small task to achieve, there are a number of components in a physics engine, and it will be a lot of burden.

I don't want to discourage you, but it's a raw fact. If I were you (I'm in the same position as of you, really) I will look into continuing with jBullet. If you are looking for a simple 3D collision detection and not a full fledged physics engine (Which you shouldn't call a Physics engine IMO) then you may simply go and create some Box, or Sphere or other colliders that do the work for you.

(By the way, your hat looks cool  Roll Eyes)

Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #2 - Posted 2014-12-14 09:09:27 »

-snip-

Don't get me wrong, I'm not doing this for for a library or anything. I just wanted a basic collision & physics implementation in cross because JBullet is kinda... jerky. All I really need is basic AABB for now... But I'm not sure how I would handle smoother objects like terrain then...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline SHC
« Reply #3 - Posted 2014-12-14 09:15:32 »

I'm not getting you wrong, I'm just saying my opinion on it. What do you mean by jBullet is jerky? Are you talking about the conversion to Java3D's VecMath classes? If not, then I didn't quite get what you are saying.

Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #4 - Posted 2014-12-14 09:23:28 »

I mean the shaking objects, sometimes when a BoxShape is on top of another, and is a large size, the box on top will shake violently. And I converted everything in my game library + game to swing's vecmath, so it's easier to use with JBullet.

Anyway, I have my heart set on learning physics & collision over the next week or so. Cross is truly more of a tech demo, and it's more impressive for it to use it's own physics.

Offline 65K
« Reply #5 - Posted 2014-12-14 09:56:34 »

Developing a physics engine is a huge HUGE undertaking.

Lethal Running - a RPG about a deadly game show held in a futuristic dystopian society.
Offline Gibbo3771

JGO Kernel


Medals: 128
Projects: 5
Exp: 1 year


Currently inactive on forums :(


« Reply #6 - Posted 2014-12-14 10:45:59 »

For the sake of learning I say go for it.

For producing a game you plan on releasing, don't.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline basil_

« JGO Bitwise Duke »


Medals: 418
Exp: 13 years



« Reply #7 - Posted 2014-12-14 12:29:39 »

woha! ofc it is a good idea! .. getting a deeper understanding of the topic is good. implementing it by yourself will help you _alot_ .. so many different things to consider.

will you succeed ? maybe not, maybe yes. you'll never know if you dont dig into it. stay realstic tho', you will run into all the hard problems which are handled at the "big" physic engines - but are these engines any good ? ofc they are, but they're not too. any 3rd party tool is suboptimal for your project which is natural for any 3rd party generic, flexible library.

whatever you create will be perfect for your project cos' it will do what is required, but not more. if it is not sufficient cos' you cannot implement the required features, then you know your limits (and what you should learn). which is good.

my advice, look into all the available physic engines, use them and implement your own at the same time. its maybe a _huge_ thing but also is the integration of an existing library. chances a 3rd party tool will meet _all_ requirements for your project is unlikely - but if you know the matter you can evaluate and modify them properly. if you do not know the matter - you're on a blind autopilot flight - which can be poisonous for your project.
Offline Roquen

JGO Kernel


Medals: 518



« Reply #8 - Posted 2014-12-14 12:47:28 »

Real physics I'd say don't write even for the learning experience.  Read up on the techniques and call it a day.  It's a million and one devil's in the details topic that (the details) don't have much educational value.
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #9 - Posted 2014-12-14 17:09:51 »

I'll stick with JBullet for now, but I'll look into making a little collision & response system.

Thanks everyone!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ClaasJG

JGO Coder


Medals: 43



« Reply #10 - Posted 2014-12-14 17:16:13 »

I recommend the book belonging to this website. http://procyclone.com/. (http://procyclone.com/buy/)
-ClaasJG

My english has to be tweaked. Please show me my mistakes.
Offline JJengineering
« Reply #11 - Posted 2014-12-19 00:20:06 »

Hello dear Ecumene :)

The following is also just my humble opinion about the topic:

I'm seriously developing my game for the time being, and i will need a physics engine for sure.
A few weeks ago i thought that i won't be able to write a physics engine on my own. (Not just forces, AABB, Circles, but also with proper constraints etc...)
Then i started learning physic stuff, as i dislike using engines/libraries (apart from LWJGL, i'm glad somebody wrote the windowing system for me :))
After the initial bloodrush of maybe pulling of a half decent physics engine, i got to understand that there is MUCH more than just a little math and geometry. But i know that one day i will master it, and that will greatly help me with future 3d Projects. If i cant handle the 2D situation, i'm not ready for the third axis, for me IMHO :)

If you want my advice, learn/try to understand the methods behind it, and get better at implementing your own, component by component, the knowledge won't be lost! So basically what Gibbo3771 said.

Quote
From:  Gibbo3771
For the sake of learning I say go for it.
For producing a game you plan on releasing, don't.

Here's a good starting tutorial, which explains a physics engine based on impulse resolution, but beware!
The code in the examples/code snippets (if it hasn't been corrected as of lately), has quite a few errors.
So if you can read it for the sake of the 'method behind it', that's great, if you need to copy the code to test it, not so great :P

Here's the link:
http://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331

You also may like to read through the following tutorials about SAT (Separating Axis Theorem), which is also a good way of implementing a basic physics engine (without the whole architecture of something like Box2D), SAT does the collisions and you could add some basic force system to SAT, and that will also be quite challenging for the start i suppose :)

Here the links:
1) Nice explanation: http://gamedevelopment.tutsplus.com/tutorials/collision-detection-using-the-separating-axis-theorem--gamedev-169
2) With flash examples to test the math: http://www.metanetsoftware.com/technique/tutorialA.html

Box2D documentation also helps greatly! Google for some good Box2D Documentation, it is well explained depending on what Docs you read.

Greetings and all the best
JJ
Offline KudoDEV

JGO Ninja


Medals: 79
Exp: 6 years


Game Dev Hobbyist


« Reply #12 - Posted 2014-12-19 00:39:44 »

I say go for it! It would be a great learning experience. And can be tailored to your needs.

Offline JESTERRRRRR
« Reply #13 - Posted 2014-12-19 04:28:55 »

I'd say its not worth the effort, BUT I also found bullet to be a jerky unpredictable mess.

Surely though, as its so widely used, this is an error on our behalf? Perhaps playing around with it more helps. I did eventually get it to behave "acceptably" but it never looked clean and professional.
Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #14 - Posted 2014-12-19 05:45:37 »

Surely though, as its so widely used, this is an error on our behalf? Perhaps playing around with it more helps. I did eventually get it to behave "acceptably" but it never looked clean and professional.

I've noticed nothing I do can make it look even reasonable. Everything is shakey and sometimes I don't even think it knows how much one object is over the other. Yet I've seen other games with JBullet that look like they were recorded in blender...

Offline JJengineering
« Reply #15 - Posted 2014-12-19 15:26:02 »

I never tried JBullet, as every preview i've seen on youtube etc looked as if the engine really is jerky and just in general doesn't 'feel' right.
But every test/video i saw about it looked different, so playing around with values might work, but you better look into the doc's, what values the engine has been optimized for.

Also, there may be things that are not so obvious to the 'not so hardcore' programmer (like me), but make a huge difference when simulating the world:
1) Casting, floating point precision and math in general(If that is the right Terminology)
2) And that the engines written in a way, where they work best only in a certain range of values.
If i remember correctly, these sensible values are for one, the size of the objects etc.

Have you tried JBox2D yet? I dont have time atm to test it.
PS: http://www.jbox2d.org/

Edit: Gotta love lists :P

Offline Ecumene

JGO Kernel


Medals: 200
Projects: 4
Exp: 8 years


I did not hit her! I did not!


« Reply #16 - Posted 2014-12-19 16:21:02 »

Also, there may be things that are not so obvious to the 'not so hardcore' programmer (like me), but make a huge difference when simulating the world:
1) Casting, floating point precision and math in general(If that is the right Terminology)
2) And that the engines written in a way, where they work best only in a certain range of values.
If i remember correctly, these sensible values are for one, the size of the objects etc.

I'm getting the transforms for my matrices strait from the JBullet bodies, so that's not the problem.
I have tried JBox, but It is a 2D engine, there's only so much you can do with it. Wink

Offline JJengineering
« Reply #17 - Posted 2014-12-19 20:18:46 »

Sorry, forgot about the fact that you might need a 3d engine Smiley
Offline Roquen

JGO Kernel


Medals: 518



« Reply #18 - Posted 2014-12-21 21:16:32 »

Just to toss around mud...in 3D there's also dyn4j.  I've no personal experience with it.
Offline SHC
« Reply #19 - Posted 2014-12-22 02:59:45 »

Just to toss around mud...in 3D there's also dyn4j.  I've no personal experience with it.

A minor correction, dyn4j is a 2D physics engine, not 3D one.

Offline JESTERRRRRR
« Reply #20 - Posted 2014-12-22 03:08:25 »

I've noticed nothing I do can make it look even reasonable. Everything is shakey and sometimes I don't even think it knows how much one object is over the other. Yet I've seen other games with JBullet that look like they were recorded in blender...

Aye, I feel you. I noticed increasing the number of quads/triangles my physics objects were made up of helped, despite my original thinking of "Oh one box will make it run faster"
Offline Roquen

JGO Kernel


Medals: 518



« Reply #21 - Posted 2014-12-22 08:30:07 »

Opps..bad me.  Err yeah, 2D.
Offline ImTroyMiller
« Reply #22 - Posted 2015-01-19 05:06:14 »

I created a game engine using LibGDX that keeps a character and other objects level with the ground regardless if the ground level rises or lowers.  Not exactly a physics engine though, but partially.

With PC and mobile devices getting faster and faster, I really see no need to build a new one.  Bullet runs fine on most phones(even cheap ones) and has a lot of functionality.  You would be better spending your time learning Bullet better, IMO.  But if you wanted to learn, then definitely go for it.
Offline delt0r

JGO Wizard


Medals: 145
Exp: 18 years


Computers can do that?


« Reply #23 - Posted 2015-01-19 11:40:03 »

There are physics engines and there are physics engines. JBullet is designed to work fairly easily in a real time setting. Despite the glitches you get, it is doing a good job. Just look at all that code to deal with edge cases! It is just that hard to do stable Newtonian mechanics.

Now i have worked on real physics engines, ones where you take the results and tell people that you haven't designed your building well enough. Or that your airplane will fall out of the sky. Now they are not so glitchy, but represent 10,000 of man hours programming in them (and many PhDs thesis ). A good example of how hard it gets, it consider the classic container of balls being tipped into a hopper. To model this properly you need to model the times of every single impact. That is right, it isn't time stepped anymore, because you can show unbounded errors in that case. But you work out when the first ball collides with something and move to that time, then the second and move forward to that time..... In our code we march forward a given amount, check for a collision and then rewind the simulation to that point in time of the collision. This sort of thing is the only way to get rid of the glitches. Much more work in the field has been done since i left however.

I have no special talents. I am only passionately curious.--Albert Einstein
Pages: [1]
  ignore  |  Print  
 
 

 
hadezbladez (3676 views)
2018-11-16 13:46:03

hadezbladez (1318 views)
2018-11-16 13:41:33

hadezbladez (3681 views)
2018-11-16 13:35:35

hadezbladez (712 views)
2018-11-16 13:32:03

EgonOlsen (4024 views)
2018-06-10 19:43:48

EgonOlsen (4548 views)
2018-06-10 19:43:44

EgonOlsen (2708 views)
2018-06-10 19:43:20

DesertCoockie (3576 views)
2018-05-13 18:23:11

nelsongames (3723 views)
2018-04-24 18:15:36

nelsongames (4755 views)
2018-04-24 18:14:32
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!