EdgeShapes (aka Thin Line Segments)

Quote:
how did you handle scaling the mini level(the one you import into box2d) and the one with all the backgrounds and stuff?

What backgrounds are you talking about? The SVG importer that I included does not make any attempt to handle graphics or scaling, and assumes that the scale in Inkscape is the same as in Box2D. However, if you'd like to change that, you could probably change what is currently line 121 of TestEdges.as to something more like:
Code:
chainDef.vertices.push(new b2Vec2(Number(args[i]) * METERS_PER_PIXEL + OFFSET_X, Number(args[i+1]) * METERS_PER_PIXEL + OFFSET_Y));

Figuring out the scale and offset values is up to you, but as far as I know it shouldn't present any problems.
I know it doesn't handle any graphics what i'm doing is drawing a smaller version, save, copy that into my .as file, then make the drawing bigger so that it's "actual size" that way i don't have to draw it again and then i just have to import it into photoshop and work with the graphics there.
[EDIT]

FIXED!

Just incase anyone wants to know how to set a filter for all edges of the chain -

Code:
         // Add filters
         var groundBody:b2Body = m_world.GetGroundBody();
         var groundFilterData:b2FilterData = new b2FilterData();
         groundFilterData.groupIndex = -1;
         
         for(var groundShape:b2Shape = groundBody.GetShapeList(); groundShape != null; groundShape = groundShape.GetNext()){
            groundShape.SetFilterData(groundFilterData);
            m_world.Refilter(groundShape);
         }


[/EDIT]
YagerX wrote:
I know it doesn't handle any graphics what i'm doing is drawing a smaller version, save, copy that into my .as file, then make the drawing bigger so that it's "actual size" that way i don't have to draw it again and then i just have to import it into photoshop and work with the graphics there.


Think I had a similar issue.

To set up a stage in Inkscape that is the same as your swf stage -

1. Take your swf dimensions (eg 600 x 400)
2. Divide these by your box2d physics scale (eg 30)
3. In Inkscape, set the page size to the new values (20 x 13.3 pixels)
4. Zoom in and draw!

When you load in the SVG, the lines should look the same in the swf as they did in Inkscape.
They do... What i'm talking about is quite different
Ok let me go over my steps again lol:
1.Draw Level in Inkscape at 1px = 1meter
2.Save as .svg
3. Compy contents of svg and load them into my .as file
4.Compile etc...
Now if i want to get a pic of the level without having to redraw anything this is what i do:
5.Save original drawing as another .svg file
6.Scale the drawing and the canvas with a factor of 30 (my physcale) (must not scale line width aswell)
7.Export drawing as bitmap (.png) at 0,0
(optional step: import into photoshop, use magic wand to clear away all the white and save with transparency)
8.Import the new .png of my level into my .fla and put that into my actor movieclip for my level.

After i compile it with the .png of my level there is a bit of whitespace that is quite weird between my wall and my actor mc it's really weird because it's only on one wall... Oh well

Now do you get what I mean? 😛
Hey,

Been a little inactive lately, what's the status on the lines? Have they been ported back from C++ to AS3 yet (the b2 API version)?

Also, is there any plan to include them in the box2d package by default?
Hopefully, both of those things will happen. But in the opposite order. I actually sent Erin Catto an email about getting it into the main branch yesterday. (no response yet)
Wow, this is great stuff! I can't believe I was planning on tessellating my levels. The SVG parser is just gravy. Looking forward to playing with this, many thanks!
Image
Hi, very nice work with b2StaticEdgeChain!

I have this problem with bodies being "pushed" through when it collides from the "wrong/bad" side, I saw some post about it earlier but I can't get it to work.

Any ideas?

Original thread: https://box2d.org/forum/viewtopic.php?t=1437