コード例 #1
0
        /// <summary>
        /// internal.
        /// </summary>
        internal static void MeshdrawTriangles2d(OpenGlDevice Device, List <IndexType> Indices, xyf[] Points, xyf[] Texture)
        {
            float 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;
                    }
                    else
                    {
                        dir = -1;
                    }
                    break;
                }
            }
            int ID = MeshVertices.Count;

            for (int i = 0; i < Indices.Count; i++)
            {
                MeshIndices.Add((IndexType)(Indices[i] + ID));
            }
            if (MeshVertices.Count + Points.Length > IndexType.MaxValue)
            {
                int CT = (MeshVertices.Count + Points.Length);
                MeshIndices = new List <IndexType>();
                Renew();
                throw new Exception("Points count to large " + CT.ToString());
            }
            for (int i = 0; i < Points.Length; i++)
            {
                MeshVertices.Add(Device.ModelMatrix * new xyz(Points[i].x, Points[i].y, 0).toXYZF());
            }
            xyzf NP = Device.ModelMatrix * new xyzf(0, 0, 0);
            xyzf N  = Device.ModelMatrix * new xyzf(0, 0, dir) - NP;

            for (int i = 0; i < Points.Length; i++)
            {
                MeshNormals.Add(N);
            }
            if (Texture != null)
            {
                MeshTextureCoords.AddRange(Texture);
            }
            MeshMode = PolygonMode.Fill;
            if (Entity.Compiling)
            {
                if (Device.RenderKind == RenderKind.SnapBuffer)
                {
                    MeshCreator.Renew();
                }
            }
        }
コード例 #2
0
 /// <summary>
 /// internal.
 /// </summary>
 internal static void MeshPaintEntity(OpenGlDevice Device, Entity Entity)
 {
     MeshCreator.Renew();
     Entity._Ondraw(Device);
     for (int i = 0; i < Entity.Children.Count; i++)
     {
         MeshPaintEntity(Device, Entity.Children[i]);
     }
 }
コード例 #3
0
        private void setTexture(Texture value)
        {
            int Active = GL.GetInteger(GetPName.TextureBinding2D);

            if (RenderKind == Drawing3d.RenderKind.SnapBuffer)
            {
                return;
            }

            //if (value == _texture)
            //     return;

            if (Entity.Compiling)
            {
                if (MeshCreator.HasTexture)
                {
                    MeshCreator.Renew();
                }
                MeshCreator.Texture = value;
            }
            _texture = value;

            if ((value == null))
            {
                GL.BindTexture(TextureTarget.Texture2D, 0);
                GL.Disable(EnableCap.Texture2D);
                if (Shader != null)
                {
                    Field C = Shader.getvar("Texture0Enabled");
                    if (C != null)
                    {
                        C.SetValue(0);
                    }
                    C = Shader.getvar("Texture1Enabled");
                    if (C != null)
                    {
                        C.SetValue(0);
                    }
                }

                return;
            }
            if ((value.Handle == 0) && (value.Bitmap == null))
            {
                return;
            }
            if (value.Handle == 0)
            {
                GL.ActiveTexture(TextureUnit.Texture0 + value.Index);
                RegisterTexture(value);
                GL.ActiveTexture(TextureUnit.Texture0);
            }
            if ((Shader != null) && (Shader.Using))
            {
                value.SetAttributes(Shader);
            }
        }
コード例 #4
0
 private void CheckCompiling(Color value, ref Color MaterialColor)
 {
     if (Entity.Compiling)
     {
         if (MeshCreator.Material.Emission != value)
         {
             MeshCreator.Renew();
             MeshCreator.Material = FMaterial;
         }
     }
 }
コード例 #5
0
ファイル: Primitives2d.cs プロジェクト: unitycoder/Drawing3D
        void _drawPolyPolyCurve(Loxy L, Loca Loca, int id)
        {
            Object Handle = null;

            if (PolygonMode == PolygonMode.Fill)
            {
                if ((RenderKind == RenderKind.SnapBuffer))
                {
                    Handle = Selector.RegisterSnapItem(getSI(id, Loca, L, -1));
                }
                drawFilledArray2d(this, L);

                if ((RenderKind == RenderKind.SnapBuffer))
                {
                    MeshCreator.Renew();
                    Selector.UnRegisterSnapItem(Handle);
                }
                return;
            }

            if ((RenderKind == RenderKind.SnapBuffer))
            {
                SnappItem S = (getSI(id, Loca, L, -1));

                Handle = Selector.RegisterSnapItem(S);
            }
            {
                for (int i = 0; i < L.Count; i++)
                {
                    //IndexType[] Indices = new IndexType[L[i].Count];
                    //for (int k = 0;k < L[i].Count; k++)
                    //{
                    //    Indices[k] = k;
                    //}
                    //xyzf[] Points = new xyzf[L[i].Count];
                    //for (int k = 0; k < L[i].Count; k++)
                    //{
                    //    Points[k] = new xyzf((float)L[i][k].X, (float)L[i][k].y, 0f);
                    //}
                    //Primitives3d.drawTriangles(this,Indices, Points, null, null, null);
                    ////if ((RenderKind == RenderKind.SnapBuffer))
                    ////  Selector.ToSnapBuffer((uint)i);
                    Primitives2d.drawArrayLined(this, L[i]);
                }
            }
            if ((RenderKind == RenderKind.SnapBuffer))
            {
                Selector.UnRegisterSnapItem(Handle);
            }
        }
コード例 #6
0
 private void setEmission(Color value)
 {
     FMaterial.Emission = value;
     if (Entity.Compiling)
     {
         if (MeshCreator.HasEmission)
         {
             MeshCreator.Renew();
         }
         MeshCreator.Emission = value;
     }
     else
     if ((Shader != null) && (Shader.Using))
     {
         Field A = Shader.getvar("Emission");
         if (A != null)
         {
             A.Update();
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// internal.
        /// </summary>
        internal static void MeshdrawLined(OpenGlDevice Device, xyzf[] A)
        {
            int ID = MeshVertices.Count;

            for (int i = 0; i < A.Length; i++)
            {
                MeshIndices.Add((IndexType)(i + ID));
            }
            for (int i = 0; i < A.Length; i++)
            {
                MeshVertices.Add(((Device.ModelMatrix * A[i])));
            }
            // MeshVertices.Add((( A[i])));
            MeshMode = PolygonMode.Line;
            if (Entity.Compiling)
            {
                if (Device.RenderKind == RenderKind.SnapBuffer)
                {
                    MeshCreator.Renew();
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// internal.
        /// </summary>
        internal static void MeshdrawLined(OpenGlDevice Device, xyzArray A)
        {
            PolygonMode Save = Device.PolygonMode;
            int         ID   = MeshVertices.Count;

            for (int i = 0; i < A.Count; i++)
            {
                MeshIndices.Add((IndexType)(i + ID));
            }
            for (int i = 0; i < A.Count; i++)
            {
                MeshVertices.Add(((Device.ModelMatrix * A[i]).toXYZF()));
            }
            MeshMode            = PolygonMode.Line;
            Device._PolygonMode = Save; // verursacht ein renew falls fill
            MeshCreator.Renew();
            if (Entity.Compiling)
            {
                if (Device.RenderKind == RenderKind.SnapBuffer)
                {
                    MeshCreator.Renew();
                }
            }
        }