Beispiel #1
0
 public void SetShapeNode(
     string name,
     int parentIndex,
     int triangleCount,
     IndexCollection indexCollection,
     VertexData[] vertices,
     BoundingSphere[] bSpheres )
 {
     ShapeNodes.Add(new ShapeReadingData
     {
         Name=name,
         ParentIndex=parentIndex,
         TriangleCount = triangleCount,
         IndexCollection = indexCollection,
         Vertices = vertices,
         BoundingSpheres = bSpheres,
     });
 }
Beispiel #2
0
        static void ProcessGeometry(GeometryContent geometry, int parentIndex,
                            string shapeNm,
                            ShapeN_SkinDContent_Writing output)
        {
            // find and process the geometry's bone weights
            for (int i = 0; i < geometry.Vertices.Channels.Count; i++)
            {
                string channelName = geometry.Vertices.Channels[i].Name;
                string baseName = VertexChannelNames.DecodeBaseName(channelName);

            }

            // retrieve the four vertex channels we require for CPU skinning. we ignore any
            // other channels the model might have.
            string normalNm = VertexChannelNames.EncodeName(VertexElementUsage.Normal, 0);
            string texCoordNm = VertexChannelNames.EncodeName(VertexElementUsage.TextureCoordinate, 0);
            string blendWeightNm = VertexChannelNames.EncodeName(VertexElementUsage.BlendWeight, 0);
            string blendIndexNm = VertexChannelNames.EncodeName(VertexElementUsage.BlendIndices, 0);

            string positionNm = VertexChannelNames.EncodeName(VertexElementUsage.Position, 0);

            //var tmp = geometry.Vertices.Channels[positionNm] as VertexChannel<Vector3>;
            VertexChannel<Vector3> normals;
            VertexChannel<Vector2> texCoords;
            VertexChannel<Vector4> blendWeights;
            VertexChannel<Vector4> blendIndices;

            //if(geometry.Vertices.Channels.Contains(normalNm))
            normals =
                geometry.Vertices.Channels[normalNm] as VertexChannel<Vector3>;

            if (geometry.Vertices.Channels.Contains(texCoordNm))
                texCoords =
                    geometry.Vertices.Channels[texCoordNm] as VertexChannel<Vector2>;

            if (geometry.Vertices.Channels.Contains(blendWeightNm))
                blendWeights =
                    geometry.Vertices.Channels[blendWeightNm] as VertexChannel<Vector4>;

            if (geometry.Vertices.Channels.Contains(blendIndexNm))
                blendIndices =
                    geometry.Vertices.Channels[blendIndexNm] as VertexChannel<Vector4>;

            // create our array of vertices
            int triangleCount = geometry.Indices.Count / 3;
            VertexData[] verticesData = new VertexData[geometry.Vertices.VertexCount];
            Vector3[] vertice = new Vector3[verticesData.Length];
            for (int i = 0; i < verticesData.Length; i++)
            {
                verticesData[i] = new VertexData
                {
                    Position = geometry.Vertices.Positions[i],
                    Normal = normals[i],
                    //TextureCoordinate = texCoords[i],
                    //BlendWeights = blendWeights[i],
                    //BlendIndices = blendIndices[i]
                };
                vertice[i] = verticesData[i].Position;
            }

            BoundingSphere[] bSpheres = new BoundingSphere[1]
                    {
                        BoundingSphere.CreateFromPoints(vertice)
                    };
            // Add the new piece of geometry to our output model.

            output.SetShapeNode(
                shapeNm,
                parentIndex,
                triangleCount,
                geometry.Indices,
                verticesData, bSpheres);
        }