Exemplo n.º 1
0
        /// <summary>
        /// overrides the <see cref="Surface.OnDraw(OpenGlDevice)"/> method.
        /// </summary>
        /// <param name="Device">the <see cref="OpenGlDevice"/> in which will be painted.</param>

        protected override void OnDraw(OpenGlDevice Device)
        {
            if (!plane)
            {
                base.OnDraw(Device); return;
            }
            object Handle = null;

            if ((Device.RenderKind == RenderKind.SnapBuffer) || (Entity.Compiling))
            {
                SurfaceSnappItem S = new SurfaceSnappItem();
                Handle    = Device.Selector.RegisterSnapItem(S);
                S.Surface = this;
            }
            IndexType[] Indices = null;
            xyzf[]      Points  = null;
            xyzf[]      Normals = null;
            xyf[]       Texture = null;
            //         if ((BoundedCurves != null) && (BoundedCurves.Count > 0))
            {
                Indices = new IndexType[] { 0, 1, 2, 0, 2, 3 };
                Points  = new xyzf[] { A, B, C, D };
                Normals = new xyzf[] { N00.toXYZF(), N00.toXYZF(), N00.toXYZF(), N00.toXYZF() };
                Texture = new xyf[] { new xyf(0, 0), new xyf(0, 0), new xyf(0, 0), new xyf(0, 0) };
            }
            //else
            //    GetTrianglesFull(ref Indices, ref Points, ref Normals, ref Texture);
            if (Device.PolygonMode == PolygonMode.Fill)
            {
                Primitives3d.drawTriangles(Device, Indices, Points, Normals, Texture, null);
            }
            else
            {
                Primitives3d.drawFouranglesLined(Device, Indices, Points, Normals, Texture);
            }

            Entity.CheckCompiling();
            if ((Device.RenderKind == RenderKind.SnapBuffer) || (Entity.Compiling))
            {
                Device.Selector.UnRegisterSnapItem(Handle);
            }
        }
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);
      }