Hi

Is there any way to get the mesh point (x,y) from a shape in Dyn4j?

## Get mesh points from shape

### Re: Get mesh points from shape

It will depend on the shape:

Shapes that implement Wound will have getVertices() and getNormals() methods: Link, Segment, Polygon, Rectangle, Triangle.

The other shapes; Circle, Ellipse, HalfEllipse, and Slice have curved features so technically have an infinite number of vertices. Each one is stored differently. For example, a circle is represented as a center point and a radius, an ellipse is represented by it's width/height and local axis, and so on.

If you are using the Shape or Convex interfaces you'll need to do some type checking:

If you need all your shapes to have vertices, look into the Geometry.createPolygonalX methods to create polygonal approximations of the curved shapes.

William

Shapes that implement Wound will have getVertices() and getNormals() methods: Link, Segment, Polygon, Rectangle, Triangle.

The other shapes; Circle, Ellipse, HalfEllipse, and Slice have curved features so technically have an infinite number of vertices. Each one is stored differently. For example, a circle is represented as a center point and a radius, an ellipse is represented by it's width/height and local axis, and so on.

If you are using the Shape or Convex interfaces you'll need to do some type checking:

- Convex c = // whatever;
- if (c instanceof Wound) {
- Wound w = (Wound)c;
- Vector2[] points = w.getVertices();
- }

If you need all your shapes to have vertices, look into the Geometry.createPolygonalX methods to create polygonal approximations of the curved shapes.

William

### Re: Get mesh points from shape

Thanks. I found the JavaDoc after I posted and also found the method you mentioned. I converted my circles to polygonals. I guess some of my shapes will have to have circle-shape (due to game logic I want projectiles to bounce correctly off surfaces for example, but it doesn't matter that much for impact on enemies if the enemy is circular or polygonal).

Thanks for the quick response

Thanks for the quick response

Return to “General Discussion”

### Who is online

Users browsing this forum: No registered users and 1 guest