Пример #1
0
            public List <DisplayVertex> CreateDisplayVertices()
            {
                // rearrange faces
                display = getDisplayFace().ToArray();

                List <DisplayVertex> displayVertList = new List <DisplayVertex>();

                if (faces.Count <= 3)
                {
                    return(displayVertList);
                }

                foreach (Vertex v in vertices)
                {
                    DisplayVertex displayVert = new DisplayVertex()
                    {
                        pos = v.pos,
                        nrm = v.nrm,
                        col = v.col,
                    };

                    displayVertList.Add(displayVert);
                }

                return(displayVertList);
            }
Пример #2
0
        public List <DisplayVertex> CreateDisplayVertices()
        {
            List <int> Faces = new List <int>();

            foreach (var group in PolygonGroups)
            {
                Faces.AddRange(group.GetDisplayFace());
            }

            display = Faces.ToArray();

            List <DisplayVertex> displayVertList = new List <DisplayVertex>();

            if (display.Length <= 3)
            {
                return(displayVertList);
            }

            foreach (Vertex v in vertices)
            {
                DisplayVertex displayVert = new DisplayVertex()
                {
                    pos    = v.pos,
                    nrm    = v.nrm,
                    tan    = v.tan.Xyz,
                    binorm = v.bitan.Xyz,
                    col    = v.col,
                    uv     = v.uv0,
                    uv2    = v.uv1,
                    uv3    = v.uv2,
                    node   = new Vector4(
                        v.boneIds.Count > 0 ? v.boneIds[0] : -1,
                        v.boneIds.Count > 1 ? v.boneIds[1] : -1,
                        v.boneIds.Count > 2 ? v.boneIds[2] : -1,
                        v.boneIds.Count > 3 ? v.boneIds[3] : -1),
                    weight = new Vector4(
                        v.boneWeights.Count > 0 ? v.boneWeights[0] : 0,
                        v.boneWeights.Count > 1 ? v.boneWeights[1] : 0,
                        v.boneWeights.Count > 2 ? v.boneWeights[2] : 0,
                        v.boneWeights.Count > 3 ? v.boneWeights[3] : 0),
                };

                displayVertList.Add(displayVert);

                /*      Console.WriteLine($"---------------------------------------------------------------------------------------");
                 *     Console.WriteLine($"Position   {displayVert.pos.X} {displayVert.pos.Y} {displayVert.pos.Z}");
                 *     Console.WriteLine($"Normal     {displayVert.nrm.X} {displayVert.nrm.Y} {displayVert.nrm.Z}");
                 *     Console.WriteLine($"Tanget     {displayVert.tan.X} {displayVert.tan.Y} {displayVert.tan.Z}");
                 *     Console.WriteLine($"Color      {displayVert.col.X} {displayVert.col.Y} {displayVert.col.Z} {displayVert.col.W}");
                 *     Console.WriteLine($"UV Layer 1 {displayVert.uv.X} {displayVert.uv.Y}");
                 *     Console.WriteLine($"UV Layer 2 {displayVert.uv2.X} {displayVert.uv2.Y}");
                 *     Console.WriteLine($"UV Layer 3 {displayVert.uv3.X} {displayVert.uv3.Y}");
                 *     Console.WriteLine($"Bone Index {displayVert.node.X} {displayVert.node.Y} {displayVert.node.Z} {displayVert.node.W}");
                 *     Console.WriteLine($"Weights    {displayVert.weight.X} {displayVert.weight.Y} {displayVert.weight.Z} {displayVert.weight.W}");
                 *     Console.WriteLine($"---------------------------------------------------------------------------------------");*/
            }

            return(displayVertList);
        }
        public virtual List <DisplayVertex> CreateDisplayVertices()
        {
            display = new int[0];
            if (PolygonGroups.Count > 0)
            {
                List <int> Faces = new List <int>();

                foreach (var group in PolygonGroups)
                {
                    Faces.AddRange(group.GetDisplayFace());
                }

                display = Faces.ToArray();
            }

            if (lodMeshes.Count > 0)
            {
                display = lodMeshes[DisplayLODIndex].getDisplayFace().ToArray();
            }


            List <DisplayVertex> displayVertList = new List <DisplayVertex>();

            if (display.Length <= 3)
            {
                return(displayVertList);
            }

            foreach (Vertex v in vertices)
            {
                DisplayVertex displayVert = new DisplayVertex()
                {
                    pos    = v.pos,
                    nrm    = v.nrm,
                    tan    = v.tan.Xyz,
                    binorm = v.bitan.Xyz,
                    col    = v.col,
                    uv     = v.uv0,
                    uv2    = v.uv1,
                    uv3    = v.uv2,
                    node   = new Vector4(
                        v.boneIds.Count > 0 ? v.boneIds[0] : -1,
                        v.boneIds.Count > 1 ? v.boneIds[1] : -1,
                        v.boneIds.Count > 2 ? v.boneIds[2] : -1,
                        v.boneIds.Count > 3 ? v.boneIds[3] : -1),
                    weight = new Vector4(
                        v.boneWeights.Count > 0 ? v.boneWeights[0] : 0,
                        v.boneWeights.Count > 1 ? v.boneWeights[1] : 0,
                        v.boneWeights.Count > 2 ? v.boneWeights[2] : 0,
                        v.boneWeights.Count > 3 ? v.boneWeights[3] : 0),
                };

                displayVertList.Add(displayVert);
            }

            return(displayVertList);
        }
Пример #4
0
        public List <DisplayVertex> CreateDisplayVertices()
        {
            List <uint> Faces = new List <uint>();

            foreach (var group in PolygonGroups)
            {
                Faces.AddRange(group.Faces);
            }

            display = Faces.ToArray();

            List <DisplayVertex> displayVertList = new List <DisplayVertex>();

            if (display.Length <= 3)
            {
                return(displayVertList);
            }

            foreach (STVertex v in Vertices)
            {
                DisplayVertex displayVert = new DisplayVertex()
                {
                    Position   = v.Position,
                    Normal     = v.Normal,
                    Color      = v.Colors.Length > 0 ? v.Colors[0] : Vector4.One,
                    TexCoord0  = v.TexCoords.Length > 0 ? v.TexCoords[0] : Vector2.Zero,
                    TexCoord1  = v.TexCoords.Length > 1 ? v.TexCoords[1] : Vector2.Zero,
                    TexCoord2  = v.TexCoords.Length > 2 ? v.TexCoords[2] : Vector2.Zero,
                    BoneIdices = new Vector4(
                        v.BoneIndices.Count > 0 ? v.BoneIndices[0] : -1,
                        v.BoneIndices.Count > 1 ? v.BoneIndices[1] : -1,
                        v.BoneIndices.Count > 2 ? v.BoneIndices[2] : -1,
                        v.BoneIndices.Count > 3 ? v.BoneIndices[3] : -1),
                    BoneWeights = new Vector4(
                        v.BoneWeights.Count > 0 ? v.BoneWeights[0] : 0,
                        v.BoneWeights.Count > 1 ? v.BoneWeights[1] : 0,
                        v.BoneWeights.Count > 2 ? v.BoneWeights[2] : 0,
                        v.BoneWeights.Count > 3 ? v.BoneWeights[3] : 0),
                };

                displayVertList.Add(displayVert);
            }

            return(displayVertList);
        }
Пример #5
0
        static List <DisplayVertex> CreateDisplayVertices(FMDL model, FSHP mesh)
        {
            // rearrange faces
            mesh.display = mesh.lodMeshes[mesh.DisplayLODIndex].getDisplayFace().ToArray();

            List <DisplayVertex> displayVertList = new List <DisplayVertex>();

            if (mesh.lodMeshes[mesh.DisplayLODIndex].faces.Count <= 3)
            {
                return(displayVertList);
            }

            foreach (Vertex v in mesh.vertices)
            {
                model.MaxPosition = OpenGLUtils.GetMax(model.MaxPosition, v.pos);
                model.MinPosition = OpenGLUtils.GetMin(model.MinPosition, v.pos);

                DisplayVertex displayVert = new DisplayVertex()
                {
                    Position   = v.pos,
                    Normal     = v.nrm,
                    Color0     = v.col,
                    Color1     = v.col2,
                    TexCoord0  = v.uv0,
                    TexCoord1  = v.uv1,
                    TexCoord2  = v.uv2,
                    BlendIndex = new Vector4(
                        v.boneIds.Count > 0 ? v.boneIds[0] : -1,
                        v.boneIds.Count > 1 ? v.boneIds[1] : -1,
                        v.boneIds.Count > 2 ? v.boneIds[2] : -1,
                        v.boneIds.Count > 3 ? v.boneIds[3] : -1),
                    BlendWeight = new Vector4(
                        v.boneWeights.Count > 0 ? v.boneWeights[0] : 0,
                        v.boneWeights.Count > 1 ? v.boneWeights[1] : 0,
                        v.boneWeights.Count > 2 ? v.boneWeights[2] : 0,
                        v.boneWeights.Count > 3 ? v.boneWeights[3] : 0),
                };

                displayVertList.Add(displayVert);
            }

            return(displayVertList);
        }
Пример #6
0
            private List <DisplayVertex> CreateDisplayVertices()
            {
                // rearrange faces
                display = GetRenderingVertexIndices().ToArray();

                List <DisplayVertex> displayVertList = new List <DisplayVertex>();

                if (vertexIndices.Count < 3)
                {
                    return(displayVertList);
                }
                foreach (Vertex v in vertices)
                {
                    DisplayVertex displayVert = new DisplayVertex()
                    {
                        pos     = v.pos,
                        nrm     = v.nrm,
                        tan     = v.tan.Xyz,
                        bit     = v.bitan.Xyz,
                        col     = v.color / 127,
                        uv      = v.uv.Count > 0 ? v.uv[0] : new Vector2(0, 0),
                        uv2     = v.uv.Count > 1 ? v.uv[1] : new Vector2(0, 0),
                        uv3     = v.uv.Count > 2 ? v.uv[2] : new Vector2(0, 0),
                        boneIds = new Vector4I
                                  (
                            v.boneIds.Count > 0 ? v.boneIds[0] : -1,
                            v.boneIds.Count > 1 ? v.boneIds[1] : -1,
                            v.boneIds.Count > 2 ? v.boneIds[2] : -1,
                            v.boneIds.Count > 3 ? v.boneIds[3] : -1
                                  ),
                        weight = new Vector4(
                            v.boneWeights.Count > 0 ? v.boneWeights[0] : 0,
                            v.boneWeights.Count > 1 ? v.boneWeights[1] : 0,
                            v.boneWeights.Count > 2 ? v.boneWeights[2] : 0,
                            v.boneWeights.Count > 3 ? v.boneWeights[3] : 0),
                    };
                    displayVertList.Add(displayVert);
                }

                selectedVerts = new int[displayVertList.Count];
                return(displayVertList);
            }