Exemplo n.º 1
0
 /// <summary>
 /// Converts the array to an array of float points
 /// </summary>
 /// <returns>array of float points</returns>
 public xyzf[] ToFArray()
 {
     xyzf[] Result = new xyzf[Count];
     for (int i = 0; i < Count; i++)
     {
         Result[i] = new xyzf((float)data[i].x, (float)data[i].y, (float)data[i].z);
     }
     return(Result);
 }
Exemplo n.º 2
0
      /// <summary>
      /// internal.
      /// </summary>
      /// <param name="Device"></param>
      /// <param name="Indices"></param>
      /// <param name="Points"></param>
      /// <param name="Texture"></param>
      public static void drawTriangles2d(OpenGlDevice Device, List <IndexType> Indices, xyf[] Points, xyf[] Texture)
      {  //ok
          refIndices  = Indices.ToArray();
          refPoints2d = Points;


          refTexture = Texture;
          double dir = 1;

          for (int i = 0; i < Indices.Count; i += 3)
          {
              xy     A = new xy(Points[Indices[i + 1]].x - Points[Indices[i]].x, Points[Indices[i + 1]].y - Points[Indices[i]].y);
              xy     B = new xy(Points[Indices[i + 2]].x - Points[Indices[i]].x, Points[Indices[i + 2]].y - Points[Indices[i]].y);
              double F = A & B;
              if (System.Math.Abs(F) > 0.0001)
              {
                  if (F < 0)
                  {
                      dir = 1;          // schaut welche Richtung der Normal vektor haben muss
                  }
                  else
                  {
                      dir = -1;
                  }
                  break;
              }
          }
          xyzf[] Normals = new xyzf[Points.Length];
          for (int i = 0; i < Points.Length; i++)
          {
              Normals[i] = new xyz(0, 0, dir).toXYZF();
          }
          xyzf[] _Points = new xyzf[Points.Length];
          for (int i = 0; i < Points.Length; i++)
          {
              _Points[i] = new xyzf(Points[i].x, Points[i].y, 0);
          }
          refNormals = Normals;
          Primitives3d.drawTriangles(Device, Indices.ToArray(), _Points, Normals, Texture, null);
      }