# razaron's Physics Engine Project Log



## razaron (Jan 31, 2012)

I'm currently making the physics engine for an action rpg.

Here's the engine. You need Java and a gpu/igp that supports openGL. 



Spoiler: Controls



Controls:
-_Enter _pauses/plays the simulation
-_R _resets the simulation
-_1_, _2_ & _3_ selects a shape
-_A_ & _D_ rotates the selected shape





Spoiler: Feature checklist



Feature checklist(not done, half done, done):
-Rigid bodies
-Cloth bodies
-Fluids
-Variable masses
-Variable friction coefficients
-Variable restitution (bounce) coefficients
-Magnetism
-Destructible rigid bodies (cracking, breaking)
-Destructible cloth bodies (tearing)





Spoiler: Update Log



*02/02/2012*
-Added different shapes
-Made the screen bigger (800*600)
-Under the hood changes

*31/01/2012*
-Functioning rigid body simulator





Spoiler: Images











If it closes on start up try changing the first word ("java") in the batch file to the path of your Java executable. Make sure to include the quotes around path.
E.g. Change _*java*_ to _*"C:\Program Files\Java\jre7\bin\java.exe"*_


----------



## Maelstrom (Jan 31, 2012)

So i DLed it, extracted it, and doubled clicked the "Start" batch file, and nothing really happened. CMD popped up for a second, but that's about it. Am I doing something wrong? I have java installed and I know my gpu supports openGL.


----------



## cheesy999 (Jan 31, 2012)

5002 on a phenom II x4

CPU-Z + screenshot -->


----------



## razaron (Jan 31, 2012)

cheesy999 said:


> 5002 on a phenom II x4
> 
> CPU-Z + screenshot --> http://img.techpowerup.org/120131/physics engine.gif



To start the simulation press the _enter_ key. My bad, I forgot to mention that.
Also, pressing the _R_ key resets the simulation.


----------



## helloWorld (Feb 1, 2012)

I have Java 6 Update 30 installed and the nVidia 290.53 drivers installed with a GTX 580, so I believe that I am good on the software and hardware installed.

However, I am running into the same issue that Maelstrom ran in to. Every time I try to execute the program, a command prompt pops up and then disappears within a second.


----------



## pantherx12 (Feb 1, 2012)

When I get to around 70 polys I get a massive performance hit.
System specs <--


----------



## razaron (Feb 1, 2012)

helloWorld said:


> I have Java 6 Update 30 installed and the nVidia 290.53 drivers installed with a GTX 580, so I believe that I am good on the software and hardware installed.
> 
> However, I am running into the same issue that Maelstrom ran in to. Every time I try to execute the program, a command prompt pops up and then disappears within a second.





Maelstrom said:


> So i DLed it, extracted it, and doubled clicked the "Start" batch file, and nothing really happened. CMD popped up for a second, but that's about it. Am I doing something wrong? I have java installed and I know my gpu supports openGL.



You have to change something in the batch file but I'm not sure what. Sorry.




pantherx12 said:


> When I get to around 70 polys I get a massive performance hit.
> System specs <--


Odd. I can get to 105-110 polys before the performance drops. 
This is probably because I've coded it in Java 1.7 (then ran it using Java 1.7).


----------



## razaron (Feb 1, 2012)

razaron said:


> You have to change something in the batch file but I'm not sure what. Sorry.



Change the first word ("java") in the batch file to the path of your Java executable.

E.g. Change _*java*_ to _*"C:\Program Files\Java\jre7\bin\java.exe"*_


----------



## theJesus (Feb 1, 2012)

And make sure to keep the quotes so it doesn't parse the space in "program files"


----------



## theJesus (Feb 1, 2012)

I can't get much past ~135 polys without it crashing (I assume due to the squares having to overlap at that point).  At 128 polys it was ~1000fps


----------



## theJesus (Feb 2, 2012)

You have to press enter to start the simulation.


----------



## Maelstrom (Feb 2, 2012)

theJesus said:


> You have to press enter to start the simulation.


Reading comprehension fail on my part xD. I'm an idiot. Thanks though.

OK, 2nd go. At around 90 blocks the program just crashes. FPS was way above 60 when it happens.


----------



## razaron (Feb 2, 2012)

Added different shapes
Made the screen bigger

Next up; friction and "bounce".


----------



## Maelstrom (Feb 2, 2012)

DL'ed the new version. It's entertaining, but I made it crash again, this time at only 25 polys (I had shapes flying all over the place).

Edit: got it to crash even quicker. I created 4 blocks very quickly in the same position and it crashed. It doesn't appear to know how to handle lots of stuff overlapping.

Edit 2: Yep, it is an overlapping problem. I created 7 block in the same area, pressed enter, and this happened:




Crashes if you try to create more shapes.
Granted, that's not the way you're supposed to use it.


----------



## razaron (Feb 2, 2012)

I think the crash happens because something is divided by (a number very close to) zero, lol.
For the next update I'll make it so you can't stack 3 or more shapes on top of each other.


----------



## pantherx12 (Feb 3, 2012)

Downloading new version, is multi-core support something you will be implementing at all?

New version is a whole lot better got to 196 before the frame rate took a massive hit and then crashed.

I'd say 170 would of been above 300 fps still though.

Will retry ina bit.


----------



## razaron (Feb 3, 2012)

After I've finished the physics engine I'll try offloading it to the GPU. If that fails I might make it use 2 threads. This is because the engine is for use in a game with a VERY big scope, so I'll need other threads to handle AI etc.


----------



## pantherx12 (Feb 3, 2012)

razaron said:


> After I've finished the physics engine I'll try offloading it to the GPU. If that fails I might make it use 2 threads. This is because the engine is for use in a game with a VERY big scope, so I'll need other threads to handle AI etc.



Looking forward to GPU acceleration! 

Love apps that use my gpu XD


----------

