Пример #1
0
 private static void AddShell(Mesh mesh, bool positive, bool full)
 {
   Vector3 vector3 = new Vector3(0.5f);
   Group group = mesh.AddGroup();
   if (positive)
   {
     if (full)
       group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionNormalColor>(new VertexPositionNormalColor[12]
       {
         new VertexPositionNormalColor(new Vector3(1f, -1f, -1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, -1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, 1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, -1f, 1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, -1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, -1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, -1f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, 1f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, 1f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, -1f) * vector3, Vector3.UnitY, Color.White)
       }, new int[18]
       {
         0,
         2,
         1,
         0,
         3,
         2,
         4,
         6,
         5,
         4,
         7,
         6,
         8,
         10,
         9,
         8,
         11,
         10
       }, PrimitiveType.TriangleList);
     else
       group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionNormalColor>(new VertexPositionNormalColor[24]
       {
         new VertexPositionNormalColor(new Vector3(1f, -1f, 0.0f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 0.0f, 0.0f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 0.0f, 1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, -1f, 1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, -1f, -1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, -1f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, 0.0f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, -1f, 0.0f) * vector3, Vector3.UnitX, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, -1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 0.0f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(0.0f, 0.0f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(0.0f, -1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(0.0f, -1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(0.0f, 1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, -1f, 1f) * vector3, Vector3.UnitZ, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, 0.0f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, 1f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(0.0f, 1f, 1f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(0.0f, 1f, 0.0f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, -1f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(-1f, 1f, 0.0f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, 0.0f) * vector3, Vector3.UnitY, Color.White),
         new VertexPositionNormalColor(new Vector3(1f, 1f, -1f) * vector3, Vector3.UnitY, Color.White)
       }, new int[36]
       {
         0,
         2,
         1,
         0,
         3,
         2,
         4,
         6,
         5,
         4,
         7,
         6,
         8,
         10,
         9,
         8,
         11,
         10,
         12,
         14,
         13,
         12,
         15,
         14,
         16,
         18,
         17,
         16,
         19,
         18,
         20,
         22,
         21,
         20,
         23,
         22
       }, PrimitiveType.TriangleList);
   }
   else
     group.Geometry = (IIndexedPrimitiveCollection) new IndexedUserPrimitives<VertexPositionNormalColor>(new VertexPositionNormalColor[24]
     {
       new VertexPositionNormalColor(new Vector3(-1f, 0.0f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, 1f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, 1f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, 0.0f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, -1f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, 1f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(1f, 1f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(1f, -1f, -1f) * vector3, -Vector3.UnitZ, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, 0.0f, 0.0f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, 1f, 0.0f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, 1f, -1f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, 0.0f, -1f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, -1f, 1f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, 1f, 1f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, 1f, 0.0f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, -1f, 0.0f) * vector3, -Vector3.UnitX, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, -1f, 0.0f) * vector3, -Vector3.UnitY, Color.White),
       new VertexPositionNormalColor(new Vector3(-1f, -1f, 1f) * vector3, -Vector3.UnitY, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, -1f, 1f) * vector3, -Vector3.UnitY, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, -1f, 0.0f) * vector3, -Vector3.UnitY, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, -1f, -1f) * vector3, -Vector3.UnitY, Color.White),
       new VertexPositionNormalColor(new Vector3(0.0f, -1f, 1f) * vector3, -Vector3.UnitY, Color.White),
       new VertexPositionNormalColor(new Vector3(1f, -1f, 1f) * vector3, -Vector3.UnitY, Color.White),
       new VertexPositionNormalColor(new Vector3(1f, -1f, -1f) * vector3, -Vector3.UnitY, Color.White)
     }, new int[36]
     {
       0,
       2,
       1,
       0,
       3,
       2,
       4,
       6,
       5,
       4,
       7,
       6,
       8,
       10,
       9,
       8,
       11,
       10,
       12,
       14,
       13,
       12,
       15,
       14,
       16,
       17,
       18,
       16,
       18,
       19,
       20,
       21,
       22,
       20,
       22,
       23
     }, PrimitiveType.TriangleList);
 }
Пример #2
0
 public TrileMaterializer(Trile trile, Mesh levelMesh, bool mutableSurfaces)
 {
   ServiceHelper.InjectServices((object) this);
   this.trile = trile;
   if (mutableSurfaces)
   {
     this.surfaces = new List<TrixelSurface>();
     this.added = new HashSet<TrixelFace>();
     this.removed = new HashSet<TrixelFace>();
   }
   if (levelMesh == null)
     return;
   this.group = levelMesh.AddGroup();
   this.tempInstances = new List<Vector4>();
   this.tempInstanceIds = new List<TrileInstance>();
   this.group.Geometry = (IIndexedPrimitiveCollection) this.geometry;
 }