Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (548)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Mechanics / Re: Phys2D question: mobile robot simulation on: 2009-05-27 13:40:15
For wheels simulation, you can do as follow :

Thanks for the suggestion. I played around a bit with it and have the following observations:
1. when the wheels have zero mass, in fact when any part of the robot has zero mass, the rotation (and position as well I believe) values become NaN -> bad.
2. setting the collision mask to anything (0, 1, another value) didn't have any effect for me, how should I set this so that a body is ignored for collision?
3. although your solution works (I adjusted the velocities of the wheels instead of the forces), it technically doesn't make any difference with setting the position and rotation of the robot body directly. The robot will still go through obstacles just as happily, if it achieves a velocity such that the displacement of the body >= its radius within one timestep. This makes sense because actually at the end of a world step, Phys2D sets the position / rotation of bodies directly as well (based on calculation of forces etc, but the idea is the same). As far as I can tell collision detection is done purely based on the current position of a body: Phys2D doesn't have continuous collision detection. So, setting the position directly shouldn't make a difference for collision detection.

Coming back to my original question, it seems then that if a body has already penetrated "far enough" into another body within one timestep, Phys2D doesn't regard it as a collision.
2  Game Development / Game Mechanics / Re: Phys2D question: mobile robot simulation on: 2009-05-26 15:11:57
So I actually just tried to set the position and rotation directly (maybe I should do that before asking questions) and it seems it works: collisions are still being detected etc.

Now I have another question though: if the "robot" (just a circle) moves a distance equal to or greater than its own radius per timestep, it tunnels through other objects. I know this can be an issue for small and fast moving objects and that the solution is usually having either smaller timesteps or applying continuous collision detection. However I thought this happened only when the object moves either completely through the obstacle within one timestep or a distance that exceeds a certain threshold. I think in Phys2D this threshold is represented by the variable "allowedPenetration" of Arbiter, but even when I set this to 0 the problem keeps occurring. The object is actually penetrating the obstacle during 5 timesteps or so (seen by rendering a frame after each step). Shouldn't a collision be detected in this case?
3  Game Development / Game Mechanics / Phys2D question: mobile robot simulation on: 2009-05-26 12:46:08
Hi,

I've got a question about Phys2D (or maybe more physics in general). I'm planning to use it to simulate movement of a mobile two-wheeled robot around a world with obstacles. The wheels are differential, i.e. the robot turns because of the different angular velocity of the wheels. On each timestep the robot determines what force/velocity to apply to each wheel.

The question is: I know how to calculate the robot's next position and rotation from the velocities. However I imagine I can't set the position and rotation directly since that will screw with the logic of the physics engine. So I imagine I need to do it by applying velocities/forces to the robot. Thing is...I don't know how to since the robot is describing a circular path most of the time, and from what I saw about velocities the best I can do i s to send it in a straight line spinning around its own axis.

Anyone knows how to go about this, or if there perhaps is a way in which I can set the position and rotation directly and still have all the functionality of the engine?

Thanks
4  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-26 12:36:55
(...) because in Box2d a lot of stuff needs to be done to get from a Shape object to the actual coordinates where the Shape should show up, since Shapes live on Bodys and need to be transformed before drawing.

(...) there are 10 methods to implement for each shape type, so it's not trivial).  We'll see...if I find a bit of time, I may just bang it out and see how it goes.

I'm not sure about JBox2D, but I tried it for Phys2D (having the Shape interface extend java.awt.Shape etc), and it's not that much extra work. The transformation before drawing needs to be done anyway, and my drawing code is a lot more concise than the custom drawing code - for example, you can use Java's AffineTransform to do the transformation, and then just call Graphics2D.draw(Shape) to do the drawing.

I think you don't need to implement the 10 methods for each Shape type yourself, you can just extend the Java classes. That's the way I did it for Phys2D and it works fine so far.

I don't think that it's good idea, physics should be independent of graphics. (...)

Some things can be pretty easy to do but still wrong in bigger picture, also it's not nice to make dependance on Java2D when user uses completely different library such as Slick or PulpCore.

I agree that physics should be independent of graphics. But a body needs to have a shape for the physics anyway, so whether it's a Shape coded from scratch or a Shape that extends Java's Shape doesn't make much of a difference IMO. Also I think this doesn't introduce a dependence on Java2D, it just gives you the option to use Java2D if you'd like. You can still use Slick (that's what I might do eventually) since all the stuff that you implemented originally is still there. It just extends Java2D now.
5  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-22 14:50:19
Uhm...but the Java2D shape classes aren't final. The GeneralPath class is final, but in 1.6 you can use Path2D which does the same as GeneralPath, and isn't final. You can then access the coordinates of the path directly and don't have to make a copy.
6  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-22 11:10:45
Awesome, thanks much for the useful info.

Another question (maybe I should start a new topic because it's no longer really on suggestions, is it): is there a particular reason why JBox2D (and Phys2D as well) implements the "shape hierarchy" from scratch? In other words, why doesn't it use the interfaces/classes provided as part of Java2D?  This would make the shapes much easier to draw by simply using Java's drawing mechanism, or at least providing the option of doing so, while still being able to create your own drawing mechanism if desired.

If additional functionality on top of the Java Shapes is required (which I guess it is), you could have a Box2DShape or PhysicsShape or whatever interface that extends the java.awt.Shape interface. A CircleShape would either extend Ellipse2D or have an Ellipse2D, etc. Or was it maybe done for performance reasons?
7  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-21 10:32:06
Ok I see, thanks for the explanation. I might need it then since I've been encountering exactly these problems (tunneling through walls) in a commercial simulation package for robotics (Webots). Is there a way to choose between the two types of collision detection in JBox2D (for performance reasons)?
8  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-20 21:13:42
I'm learning so many new things here Smiley

Quote
I'm pretty sure Phys2D is made with Slick integration in mind, or at least there are good examples of how to do it

Could you point me to some of these examples?

Quote
The main feature JBox2d has over Phys2d is continuous collision detection

I might need that, depending on what you mean...what is the difference between continuous collision detection and the type of collision detection Phys2D does?
9  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-20 13:22:34
Cool, thanks guys! I'll check those three things out.
10  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-19 16:05:00
Thanks, I'll check the code out.

So I've been browsing around some more and I'm getting bit dizzied by all the packages / engines that are out there.

For example, Slick was made by the same guy that made Phys2D. What's the difference between the two? Is Phys2D purely collision and physics while Slick has more to do with graphics rendering? Does Slick incorporate physics as well?

I think I'll go with one of those two, but I'd like to know what the difference is exactly and which one is supposed to be best (if they can be compared at all).

With regards to the progress of my project, I can post the location of the code when I have something working. It's not really game oriented though, more an app to try different learning algorithms (although I'm trying to design it in such a way that learning agents can easily be plugged into other apps, like games).

Cheers
Han
11  Game Development / Newbie & Debugging Questions / Re: Suggestions for (2D) simulation package on: 2009-05-19 11:55:09
Thanks for your reply. I had a look at Phys2D and it's getting close to what I'm looking for, at least for continuous worlds. Maybe with a bit more functionality than I need, but I guess that might come in handy for when things need to get more realistic. Only thing is that I'm looking to simulate a world from bird's-eye view, i.e. looking down on top of it, so I guess this would mean turning gravity off otherwise the objects in the world would start falling to the bottom of the screen? Actually what I'm looking for is quite like your SydneyEngine (in which I managed to get myself killed in record time, btw). Did you use Phys2D for that as well? Would you mind if I had a look at your source code?

I'm not trying to teach anything Smiley I'm developing a toolkit for doing reinforcement learning, a field of AI in which agents learn from their actions by receiving rewards and punishments. So basically, a user of the toolkit should be able to easily program / config whatever world they want ("give me a continuous world with x objects and y agents, placed on these locations. When a collision happens, it should be handled like such", etc). Then they plugin some standard learning algorithm for the agents that comes with the toolkit, or some algorithm of their own. For example, in your SydneyEngine I could place a learning agent inside the "main character", and after a number of iterations it would hopefully learn to avoid obstacles and enemies (without path finding) and shoot at enemies.

Thanks again for the help!
12  Game Development / Newbie & Debugging Questions / Suggestions for (2D) simulation package on: 2009-05-19 03:40:13
Hi,

I'm looking for an open-source Java simulation package for simulation of 2D (for now) worlds, very preferably with things like collision detection and simple kinematics already included. I have done some Googling but haven't really found any satisfactory results yet. Does anyone have any suggestions?

Some additional info (not sure if it's relevant, but better too much than too little I guess): I'm trying to write a toolkit for doing reinforcement learning. Some common (and the most applicable to my own work) scenarios include agents moving about in continuous- or grid worlds, avoiding / collecting / moving around objects, etc. So I was about to start coding that myself when in one of my brighter moments I realised it would probably be better to take an existing package for that and focus my own efforts on the learning algorithms.

So...if anyone knows of a package that suits my purposes, I would be very grateful Smiley

Thanks
Han
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (14 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (59 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!