Drawing simple custom geometries (basic usage of GeometryMesh)
#1
Hi!

I am trying to modify the MultiThreadingSample.xaml.cs to draw other custom geometries. To minimize code changes I just change this:

Code:
       public static SceneNode CreateBoxSceneNodes(MeshGeometry3D mesh, Point3D center, Size3D size, float modelScaleFactor, bool useSingleColor, int xCount, int yCount, int zCount)
       {
           var rootSceneNode = new SceneNode();

           var dxMeshGeometry3D = new GeometryMesh(
               new List<Vector3>() { new Vector3(1,1,0),
                   new Vector3(1,-1,0),
                   new Vector3(-1,1,0),
                   new Vector3(-1,-1,0),
                   new Vector3(0,0,1),
               },
               new List<Vector3>() { },
               new List<Vector2>(),
               new List<int>() { 0, 1, 3, 1, 2, 3, 0, 4, 3, 2, 3, 4, 2, 4, 1, 1, 0, 4 });


That is to draw a Pyramid with square base. I also tried something even simpler, just a flat triangle:


Code:
var dxMeshGeometry3D = new GeometryMesh(
                new List<Vector3>() {
                    new Vector3(0,1,0),
                    new Vector3(1,0,0),
                    new Vector3(1,1,0)
                },
                new List<Vector3>() {
                    new Vector3(0,0,1),
                    new Vector3(0,0,1),
                    new Vector3(0,0,1)},
                new List<Vector2>(),
                new List<int>() { 0, 1, 2 });

But it does just not render any figure. The reason I am trying to do this is because I need to render advanced cad models (that assimp cannot load, so I load them aside and get the list of points and triangle indices). Also the normals are not usually available (I can compute them myself, but is there a method to do it, or do I always need to create the geometry mesh with the normals per point?).

Moreover, I do not need to apply any texture onto the models (just solid colors) can I leave the texture indices list empty?

Just add that I do not want to use the WPF models since I need to render all in the DXEngine (so avoiding the conversion from wpf 3d models to DXEngine objects).

Thanks for the support.
  


Messages In This Thread
Drawing simple custom geometries (basic usage of GeometryMesh) - by Marc - 06-01-2021, 06:40 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)