Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (581)
games submitted by our members
Games in WIP (500)
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  
  I have a game written in java and I need some physics  (Read 3580 times)
0 Members and 1 Guest are viewing this topic.
Offline Browndog

Senior Newbie





« Posted 2006-05-22 06:38:14 »

Hi guys  Grin I've been working on a game for a while now and its getting to the stage where netoworking is good game-play is good and things are really comming together well, but I have hit a wall with the physics side of things(no pun intended  Wink).  My game is in space and does not require the physics to be very involved. But I would like to have fairly realistic collisions between meshes in space. I've been looking at odejava but that project seems to have been abandoned and Ive had a read through a few post here on JOODE but I dont know if its upto the job yet. Can anyone offer me some advice on how I could proceed?
Offline irrisor

Junior Member





« Reply #1 - Posted 2006-05-22 10:41:03 »

Well, using OdeJava should be fine. Even if it seems somewhat inactive.  Which scenegraph do you use? If you are using jME, of course, jmephysics 2 (which also uses ODE) would be best suited.... and I believe there is a Newton Java binding around.... DP, didn't you do something like that?
Offline hdietrich

Junior Member




Harald Dietrich


« Reply #2 - Posted 2006-05-22 11:59:15 »

At the moment I cannot encourage you to use JOODE. The trimesh implementation is not known to be finished in the near future.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline harry@dayfamilyweb

Junior Member





« Reply #3 - Posted 2006-05-22 23:56:03 »

JOODE apers to have no download on  dev.java.net
Offline Browndog

Senior Newbie





« Reply #4 - Posted 2006-05-23 00:49:06 »

I'm using a OGL scene graph written in C++ with a java binding. So I need somthing that works independent of the scene graph.

Thanks for the advice I'm going to give odejava a shot. jme physics 2 sound very interesting pitty its not independent of jme.
Offline darkprophet

Senior Member




Go Go Gadget Arms


« Reply #5 - Posted 2006-05-23 01:43:42 »

Nope, i did a Novodex binding; but thats heavily tied in with my other projects, so there's no hope of anyone else using it without going through miles of code Sad

I would recommend you use Odejava for the time being...its stable and works and the annoyances in it are documented through the pages and there are some work arounds.

If your using C++, why not just use Novodex yourself through their API ?

DP

Friends don't let friends make MMORPGs.

Blog | Volatile-Engine
Offline Browndog

Senior Newbie





« Reply #6 - Posted 2006-05-23 04:00:30 »

Ok thanks, the reason I dont use novodex/physX or newton or somthing with a C++ API is that I dont want to have to program in C++ the reason for using the java binding was because I can code at least 10 times faster in java than C++. I'm going to give odejava a shot it sounds like it may do the trick.
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #7 - Posted 2006-05-23 19:48:20 »

JOODE apers to have no download on  dev.java.net

the dev.java.net version of joode only exists, because we first requested JOODE at java.net, but because java.net was so slow we used then sourceforge instead http://joode.sourceforge.net/. But to get the code, you'll also still have to checkout the cvs at sourceforge, but a build will come soon!

:: JOODE :: Xith3d :: OdeJava ::
Offline Browndog

Senior Newbie





« Reply #8 - Posted 2006-05-24 01:37:58 »

back again  Grin. I've had a bit of a play with odejava and it seems to be ok for what I want. What I need help with now is a bit of program design. My scene graph is not thread safe and in order to get it to run I need to have a while loop and call renderScene(). Each loop I change the position/rotation of the objects in the scene based on user input. Currently I move nodes based on the time it took to render each loop. What I want to do is call odejava and say its taken X amount of time to reneder this frame move everything relative to  X, then I want to be able to get the new postitions of all my nodes set them in the scene and start the next loop. Can somone just give me a few ideas of  whats required to do this.

Edit: I've have intergrated odejava with my scene graph, I'm still not sure about how to get it to run based on time.

Edit 2: is there an easy way to work out scale between my scene graph and ode? The objects I draw are not the same as ode objects.
Offline NewbTon

Junior Member




Odejava games rock!


« Reply #9 - Posted 2006-05-26 02:18:26 »

I'm not sure I understand what you mean with scale. But if you have a nested scenegraph you can forget about using
ODE as I understand it. You need to flatten your scenegraph first, that means all nodes must reside at the same level.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Browndog

Senior Newbie





« Reply #10 - Posted 2006-05-26 06:05:48 »

odejava and my scene graph are woking together fine. The problem I have is that 1 unit on my scene graph is different in size to 1 unit in ode.


I have another problem now as well. I have a body in space and I want it to have a thrust from an engine, the problem I have is that each loop of my program I do Body.setForce(forceWithDirection), The body keeps getting faster and faster it never reaches top speed(or doesnt seem to). There must be somthing I need to do the counter the thrust force so that the body reaches a top speed. This is also creating the problem that when I turn the body it has momentum in its original direction that never goes away unless it is directly opposed(ie the ship turns 180 and thrust in the reverse direction). I think these two problems are one in the same. I some how need to create a force that reverses old forces so that the new ones can move the body in a more friendly manner.
Offline harry@dayfamilyweb

Junior Member





« Reply #11 - Posted 2006-05-26 08:14:31 »

have a way to stop your while loop for the fist probled do this

1  
2  
3  
4  
5  
6  
7  
int cCount;
while(a == true) {
 cCount += 1;
 Body.setForce(forceWithDirection);
 if(cCount > ?) {
     a = false;
  }

 }
Offline Browndog

Senior Newbie





« Reply #12 - Posted 2006-05-26 09:29:00 »

yeah thats a solution but not a very dynamic one. Currenly I'm thinking that if I do body.setForce(forceWithDirection-Velocity) it fixes the problem as long as I'm going forwards, if my body goes backwards I'm adding the thrust with the velocity and getting more thrust that I should. There must be some sort of calculation I can do to get it so that it work no matter which direction my body is traveling.
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #13 - Posted 2006-05-26 10:50:27 »

in Odejava you call step to process the simulation, so you simply can dynamically set the step size.

:: JOODE :: Xith3d :: OdeJava ::
Offline Browndog

Senior Newbie





« Reply #14 - Posted 2006-05-26 11:04:06 »

ok, tried that and it works well thanks.
Offline otelo

Junior Member





« Reply #15 - Posted 2006-05-28 18:49:15 »

in Odejava you call step to process the simulation, so you simply can dynamically set the step size.
sure , but steping through the simulation with a different time each iteration should be avoided. the step(float steptime) method can create quite a mess (unpredictable behaviour) if your step times vary too much. Ode supposedly does a lot of predicting in between steps. it's better to step ode with a constant step time and to adjust the sleep time in between steps to compensate.
Offline arne

Senior Member




money is the worst drug- we should not let it rule


« Reply #16 - Posted 2006-05-28 20:18:05 »

mmh that could explain, why I sometimes got those jumpy effects...

:: JOODE :: Xith3d :: OdeJava ::
Offline Browndog

Senior Newbie





« Reply #17 - Posted 2006-05-29 01:08:30 »

yeah In that case I'm going to use a constant step size and I'm got to try to control the velocity of each body manualy.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (60 views)
2014-04-15 18:08:23

BurntPizza (58 views)
2014-04-15 03:46:01

UprightPath (71 views)
2014-04-14 17:39:50

UprightPath (54 views)
2014-04-14 17:35:47

Porlus (71 views)
2014-04-14 15:48:38

tom_mai78101 (97 views)
2014-04-10 04:04:31

BurntPizza (157 views)
2014-04-08 23:06:04

tom_mai78101 (252 views)
2014-04-05 13:34:39

trollwarrior1 (207 views)
2014-04-04 12:06:45

CJLetsGame (214 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!