Retrieving path segments from ID2D1PathGeometry

495 views Asked by At

I'm currently trying to write a little game engine in C# using SlimDX just for fun.

I want my world to be destructable, so I have to be able to modify my map. My map is currently vector based, represented by an ID2D1PathGeometry (PathGeometry in SlimDX) object. This object is modified, using the CombineWithGeometry method of ID2D1Geometry (Geometry in SlimDX).

For reasonable collision detection, I need knowledge about the exact shape of my ID2D1PathGeometry object, for instance for calculating angles of balls bouncing of the walls.

So, is it possible to access all or specific (per location) segements/lines/points of my ID2D1PathGeometry object? Or are there other, better ways to accomplish my goals, e.g. storing all lines and shapes additionaly in another data structure?

Please note that bitmap based maps are not the way to go here, since I don't want to have memory as a constraint on the map size.

with best regards, Emi

1

There are 1 answers

0
vt. On BEST ANSWER

There is no way to retrieve just the geometry segments that are close to a certain point, but there is a way to retrieve all geometry segments.

  1. Implement a class that inherits from ID2D1SimplifiedGeometrySink.
  2. Create an instance of that class and pass it to ID2D1Geometry::Simplify.

More info and example are here How to Retrieve Geometry Data by Extending ID2D1SimplifiedGeometrySink

If you are interested in retrieving only portion close to a certain point, perhaps you'd like to:

  1. Create rectangular geometry surrounding the point of interest.
  2. Intersect it with your geometry via ID2D1Geometry::CombineWithGeometry using D2D1_COMBINE_MODE==D2D1_COMBINE_MODE_INTERSECT.
  3. Get sink of the intersected geometry using the method above.

More info: ID2D1Geometry::CombineWithGeometry method