コード例 #1
0
ファイル: CompositeMesh.cs プロジェクト: gagho0/yeahhhhhhh
        private static BlendShapeData MergeBlendShapes([NotNull, ItemNotNull] IReadOnlyList <PrettyMesh> meshes)
        {
            var vertices = new List <BlendShapeVertex>();
            var shapes   = new List <MeshBlendShape>();
            var channels = new List <MeshBlendShapeChannel>();
            var weights  = new List <float>();

            uint meshVertexIndexStart = 0;
            var  totalFrameCount      = 0;
            uint totalVertexCount     = 0;

            foreach (var mesh in meshes)
            {
                var meshShape = mesh.Shape;

                if (meshShape != null)
                {
                    var channelFrameCount = 0;

                    foreach (var channel in meshShape.Channels)
                    {
                        var chan = new MeshBlendShapeChannel(channel.Name, channel.NameHash, channel.FrameIndex + totalFrameCount, channel.FrameCount);

                        channelFrameCount += channel.FrameCount;

                        channels.Add(chan);
                    }

                    totalFrameCount += channelFrameCount;

                    weights.AddRange(meshShape.FullWeights);

                    uint shapeVertexCount = 0;

                    foreach (var s in meshShape.Shapes)
                    {
                        var shape = new MeshBlendShape(s.FirstVertex + totalVertexCount, s.VertexCount, s.HasNormals, s.HasTangents);

                        shapeVertexCount += s.VertexCount;

                        shapes.Add(shape);
                    }

                    totalVertexCount += shapeVertexCount;

                    foreach (var v in meshShape.Vertices)
                    {
                        var vertex = new BlendShapeVertex(v.Vertex, v.Normal, v.Tangent, v.Index + meshVertexIndexStart);

                        vertices.Add(vertex);
                    }
                }

                meshVertexIndexStart += (uint)mesh.VertexCount;
            }

            return(new BlendShapeData(vertices.ToArray(), shapes.ToArray(), channels.ToArray(), weights.ToArray()));
        }
コード例 #2
0
ファイル: BlendShapeData.cs プロジェクト: gagho0/yeahhhhhhh
        internal BlendShapeData([NotNull] AssetStudio.BlendShapeData data)
        {
            {
                var vertexCount = data.vertices.Length;
                var vertices    = new BlendShapeVertex[vertexCount];

                for (var i = 0; i < vertexCount; i += 1)
                {
                    vertices[i] = new BlendShapeVertex(data.vertices[i]);
                }

                Vertices = vertices;
            }

            {
                var shapeCount = data.shapes.Length;
                var shapes     = new MeshBlendShape[shapeCount];

                for (var i = 0; i < shapeCount; i += 1)
                {
                    shapes[i] = new MeshBlendShape(data.shapes[i]);
                }

                Shapes = shapes;
            }

            {
                var channelCount = data.channels.Length;
                var channels     = new MeshBlendShapeChannel[channelCount];

                for (var i = 0; i < channelCount; i += 1)
                {
                    channels[i] = new MeshBlendShapeChannel(data.channels[i]);
                }

                Channels = channels;
            }

            FullWeights = (float[])data.fullWeights.Clone();
        }