Box2D Forums

It is currently Sat May 25, 2013 7:47 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Editor?
PostPosted: Mon Sep 17, 2007 8:42 am 
Offline

Joined: Mon Sep 17, 2007 8:29 am
Posts: 12
Graphic interface for editing 2d physical object would be something for all those (including myself) amateurs to get going. Creating a custom file format and graphical editor is far too much for a non-professional programmer. Including such an editor and a parser to read its creations into the game would be nice and I am sure it would spawn some cool gameMaker-like following resuluting in lost of fine 2dphysics based game stuff. Are there any plans concerning physics editor in Box2d?


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Mon Sep 17, 2007 9:14 am 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
I would not be the person to create such an editor, but I would totally support such an effort. Such editors almost become games themselves, so I would enjoy playing with one.

Interactive Physics http://www.design-simulation.com/IP/index.php is a fine example of a 2D physics editor used in education.


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Mon Sep 24, 2007 8:07 am 
Offline

Joined: Thu Sep 20, 2007 5:04 pm
Posts: 8
I built a crude Box2d physics editor:

http://sourceforge.net/project/showfile ... _id=197381

It's an ongoing project (latest version in CVS).. So far you can draw/place

Static lines (Ground)
Lines (thin boxes)
Boxes
Triangles
Circles
Pyramids with boxes
Pyramids with circles
Ragdolls
Towers with boxes
Stairs (draw line)
Stairs (boxes)
Bridges
Domino lines

1-9 and Q,W,E,R,T,Y pick options...
Z,X,C - increase/decrease sizes
A,S,D change density, friction, etc.

You press O to export the current scene into C++ source. Joints are supported, but I'm storing them so it's almost done.

TODO:

Attractors/replusors (i.e black holes, magnets etc.)
Vector fields (ala Loco Roco)
Turbulence fields
Polygon shapes
Cogs
Simple car

I plan to add as many as features as possible then clean up the UI


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Mon Sep 24, 2007 11:25 am 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
Voxel, that's really cool! You even have a ragdoll!

It seems like some of the tuning is off. I'm guessing you are using pixel units? You'll probably need to tune some of the settings in b2Settings.h. I'm guessing most length units should be increased by about 100x.

I'll post a link to this on the links page.


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Mon Sep 24, 2007 3:08 pm 
Offline

Joined: Thu Sep 20, 2007 5:04 pm
Posts: 8
Erin Catto wrote:
Voxel, that's really cool! You even have a ragdoll!

It seems like some of the tuning is off. I'm guessing you are using pixel units? You'll probably need to tune some of the settings in b2Settings.h. I'm guessing most length units should be increased by about 100x.

I'll post a link to this on the links page.


Thanks. I'll post an updated version this week with more features.

As for units, I use raw 3D units and render in "2D." The default are probably too small. I use 2.5 as the default box size...

EDIT: I think the units map to pixel width pretty closely and probably shouldn't.

Yes, it's weird that I am using a 3D engine to render 2D art. I could easily stick 6 different box2d simulations and draw each onto a cube face.

I just added polygon drawing, but it asserts (when checking the normals in shape creation) if the polygon is concave or the points were specified in clockwise order. I'll probably need to create a b2Utils class with functions like isConvex(), etc..


Last edited by voxel on Mon Sep 24, 2007 6:31 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Mon Sep 24, 2007 3:28 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
A convex hull tool is on the TODO list. That will come in a month or so. Fortunately convex hulls are a lot simpler in 2D.


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Tue Sep 25, 2007 1:11 pm 
Offline

Joined: Sun Sep 23, 2007 3:57 am
Posts: 70
Location: Here
A tool to convert a concave shape into a number of convex shapes would be nice as well 8-)


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Tue Sep 25, 2007 1:18 pm 
Offline
Site Admin

Joined: Thu Sep 06, 2007 12:34 am
Posts: 2931
I plan to support edge soups for static level geometry. These will be placed in an AABB tree for fast processing.

Convex decomposition wouldn't be hard for closed polygons. In the worst case I could just triangulate the polygon.

Both the convex hull code and the convex decomposition code could be contributions because they are external utilities.


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Wed Sep 26, 2007 8:59 pm 
Offline

Joined: Sun Sep 23, 2007 2:35 pm
Posts: 803
If anyone wants to take up the convex decomposition, the Hertel-Mehlhorn algorithm (a Google search should turn something up) is probably a good start; it's reasonably quick, produces close to optimal decompositions (usually quite a bit better than a triangulation), and is pretty easy to program. The basic idea is to triangulate the non-concave polygon and then remove "inessential" diagonals until you can't remove any more, at which point you're done. To do much better requires moving to an algorithm with much higher complexity. I don't have time to code it right now, so if someone else is up for it, give it a shot. Otherwise in a little while I may get around to it.

Christer Ericson's book has an explanation of this somewhere around page 500 - found it on Google book search, though alas, you cannot read the first part of the explanation.

You're right, though, for now, even just a triangulation would probably do, especially since Hertel-Mehlhorn requires one to start with anyways (I forget if it needs to be a particular sort of triangulation, though). There are a lot of different ways to do this, ear clipping is probably the easiest, and since this calculation really only happens on shape initialization, it doesn't matter too much that it's not the fastest: http://cgm.cs.mcgill.ca/~godfried/teach ... _ears.html .


Top
 Profile  
 
 Post subject: Re: Editor?
PostPosted: Fri Sep 28, 2007 1:52 am 
Offline

Joined: Thu Sep 20, 2007 5:04 pm
Posts: 8
I've posted a little video:

http://casuallyhardcore.com/blog/?p=100

As for the source:

http://sourceforge.net/projects/musicala (CVS is best)

The file Box2DSystem.cpp contains all useful box2d related creation calls that all the demos use. i.e ragdolls, bridges, etc. Feel free to borrow from it.

The editor will be dormant for a little while as I'm working on another project for the next few weeks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 2 guests


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:
Powered by phpBB® Forum Software © phpBB Group