Should I make a physics engine?

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.

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 ::))

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…

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.

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.

Developing a physics engine is a huge HUGE undertaking.

For the sake of learning I say go for it.

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

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.

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.

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

Thanks everyone!

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

Hello dear Ecumene :slight_smile:

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 :slight_smile:

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.

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 :stuck_out_tongue:

Here’s the link:

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 :slight_smile:

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

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

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.

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…

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 :stuck_out_tongue:

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:

Sorry, forgot about the fact that you might need a 3d engine :slight_smile:

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.