kripken / box2d.js

Port of Box2D to JavaScript using Emscripten
1.33k stars 196 forks source link

Finding vertices of an edge shape #57

Open manideepabc opened 10 years ago

manideepabc commented 10 years ago

I want to draw bodies by other rendering methods instead of debug draw. so,to draw an edge shape we have to know the vertices comprising the edgeshape.

can someone let me know how to know these vertices.

aptxyz commented 10 years ago
var x1 = edge.get_m_vertex1().get_x(),
    y1 = edge.get_m_vertex1().get_y(),
    x2 = edge.get_m_vertex2().get_x(),
    y2 = edge.get_m_vertex2().get_y();

by the way, does any know how to access an array from box2d.js fox example world.GetBodyList() or chainLoopShape.get_m_vertices() only return one object from the array

hellochar commented 10 years ago

@aptxyz GetBodyList() returns a Body object that has a GetNext() function that returns the "next" body in the World. This keeps going until GetNext() returns a body with the a property equal to 0, which represents the end of the list.