Slick Forums

Discuss the Slick 2D Library
It is currently Sun May 26, 2013 4:25 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Rendering without Fizzy
PostPosted: Sun Jul 08, 2012 7:14 pm 
Offline

Joined: Thu May 19, 2011 9:43 am
Posts: 50
How to render JBox bodies without Fizzy? I know I need to cycle through the bodies somehow, and check what shape they have, but I can't grasp how JBox2D works.

Fizzy stores its own body list and then link those bodies to JBox bodies. When using Fizzy, you have to manipulate the JBox world always through Fizzy, and Fizzy is not complete. You can't use all of JBox2D's features through Fizzy. And the development of Fizzy is discontinued.
That's why I'd like to learn how JBox2D really works, and make my own little wrapper.


Top
 Profile  
 
PostPosted: Mon Jul 09, 2012 8:45 am 
Offline
Slick2D Developer

Joined: Thu Mar 31, 2011 5:06 am
Posts: 239
From a developer who has investigated this - my advise is not to use Fizzy. Although it provides a more pretty-looking abstraction to the actual JBox2D library, it is more beneficial to just learn JBox2D straight up (Without direct access to the JBox2D world, you can't do many things).

For JBox2D, I have created a DebugDraw script.

_________________
Liam (liamzebedee) Edwards-Playne
Cryptum


Top
 Profile  
 
PostPosted: Mon Jul 09, 2012 11:06 am 
Offline

Joined: Thu May 19, 2011 9:43 am
Posts: 50
Thank you so much!


Top
 Profile  
 
PostPosted: Tue Jul 10, 2012 7:48 am 
Offline

Joined: Thu May 19, 2011 9:43 am
Posts: 50
[EDIT] got it working. I copied the line from the other thread into the render method.

**Original***

I can't get your class to work.
I've created a body, but I can't see any graphics when I run the app.

Here's my Main class:
Quote:
private Slick2DJBox2DDebugDraw debugDraw;
...

public void init(GameContainer container) throws SlickException {

universe = new Universe();

debugDraw = new Slick2DJBox2DDebugDraw(container);
debugDraw.setFlags(DebugDraw.e_shapeBit);
universe.world.jBoxWorld.setDebugDraw(debugDraw); // Where world is your JBox2D world

...
}

The only thing I have in the update method, is the jBoxWorld step. render method is empty
Quote:
for (int i = 0; i < 60; ++i) {
....jBoxWorld.step(timeStep, velocityIterations, positionIterations);
...
}

In the same update loop I debug the position of the body, and I can see that it really moves. So I created the body correctly into the jBoxWorld.

Here's how I create the body
Quote:
//body definition
BodyDef bd = new BodyDef();
bd.position.set(1, 1);
bd.type = BodyType.DYNAMIC;

//define shape of the body.
CircleShape cs = new CircleShape();
cs.m_radius = 5.5f;

//define fixture of the body.
FixtureDef fd = new FixtureDef();
fd.shape = cs;
fd.density = 0.5f;
fd.friction = 0.3f;
fd.restitution = 0.5f;

//create the body and add fixture to it
character = jBoxWorld.createBody(bd);
character.createFixture(fd);


I tried to debug your class with System.out.println("!!!"); but I couldn't see any other class using the debug class in a loop. Should my update or render class be used for this somehow? Right now it looks like the class is not being used, even though I initialized everything correctly. The other possibility is that for some reason the rendering is done incorrectly. Does the class use 1:1 scale when rendering objects (1 meter = 1 pixel)?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group