How to create a 2D plane from a 3D image

I would like to write a program in C # that generates a 2D image from a rendered 3D object (s) by "slicing" a 3D object or a cut plane. The desired 2D output should be data that can be displayed using CAD. For example:

The 3D image is defined by its vertices, these vertices are contained in Point3DList (). The method is then called selecting Point3DList as its parameter, for example: Cut2D (Point3DList). The method then generates 2D vertices and stores it inside Point2DList (), and these vertices can be read through a CAD program displaying it in 2D.

So my question is if there is a previous implementation of this in C # (.NET compatible) or is there any suggestions for third party components / algorithms to solve this problem.

Thanks in advance.

+2


source to share


5 answers


You are presenting an interesting question, in part without including the complete definition of a three-dimensional figure. You need to specify either vertices and edges, or an algorithm to get edges from the vertex list. Since the algorithm for obtaining edges from the list of vertices turns into specifying vertices and edges, I will only talk about this case here. My description also works best when vertices and edges are converted to a list of planar polygons. To split the list of vertices down into polygons, you need to find the cycles in the undirected graph that is created by vertices and edges. For a triangular polygon with vertices A, B, and C, you get edges AB, BC, and AC.

Simplest algorithm I can think of:

  • Convert all points so that your 2D plane where the Z axis is 0. (rotate, twist and move as needed to convert the desired 2D plane to a line with the XY plane where Z = 0).

  • For each flat polygon:
    a. ... For each edge, check if the vertices have the opposite sign on the Z-axis (or if one of them is 0). If Z0 * Z1 <= 0, then it is. b. Use the line definition and solve for the point where Z = 0. This will give you the X, Y intersection.
    c. You now have a point, line, or polygon that represents the intersection of your original planar polygon from step 1 crossing the 2D plane.
    d. Fill in the polygon formed by shapes (if desired). If your 2D rendering will not create a polygon from the vertex list, you need to start rendering pixels using scan lines.

Each of the individual algorithms must be in "Algorithms in C" or similar.



Graphics programs can be quite helpful when they get started.

Enjoy,

Jacob

+5


source


This is more specific to opengl rather than C #, but what would I do:

Rotate and transform with a 3d matrix so that the "slice" you want is 1 meter in the "front" of the camera.



Then set the near and far horizon limits to 1 m and 1.001 m respectively.

-update- Are you even using opengl? If not, you can somehow do your matrix arithmetic.

0


source


It sounds like you want a 2D representation of the intersection points of a plane with a 3D surface or object. While I do not know of an algorithm for making such a thing out of hand (I have done very little with 3D modeling applications), I think this is what you are asking for.

I came across this kind of algorithm a few years ago, either in Jewelry Graphics or Graphics Graphics or a similar book. I couldn't find anything through a few Bing searches, but hopefully this will give you some ideas.

0


source


if its 3D texture can't specify 3D tex coordinates (in texture) for each vertex of the square? won't auto-interpolate texels?

0


source


If you're looking for a third-party implementation, you might want to look into Coin3d . Capable of the kind of things you need, although I'm not sure about its exact database format or input requirements. I believe your description is insufficient as you are not specifying the direction from which you want to project the 3D image onto the 2d plane.

0


source







All Articles