示例#1
0
        public static void SetModelTechniques(Model model, string techniqueAppend, RenderMethod renderMethod)
        {
            for (int i = 0; i < model.Meshes.Count; i++)
            {
                //model.Meshes[i].ParentBone.Transform = Matrix.Identity;
                for (int j = 0; j < model.Meshes[i].MeshParts.Count; j++)
                {
                    VertexElement[] d      = model.Meshes[i].MeshParts[j].VertexBuffer.VertexDeclaration.GetVertexElements();
                    Effect          effect = model.Meshes[i].Effects[j];

                    string renderType = d.Any(f => f.VertexElementUsage == VertexElementUsage.TextureCoordinate) ? "Texture" : "Color";
                    string bone       = d.Any(f => f.VertexElementUsage == VertexElementUsage.BlendIndices) ? "Bone" : "";

                    //object[][] v = GetVertexDataObject(model.Meshes[i].MeshParts[j], VertexElementUsage.Position, VertexElementUsage.BlendIndices, VertexElementUsage.BlendWeight);
                    //for (int k = 3; k < 4; k++)
                    //{
                    //    for (int l = 0; l < v[k].Length; l++)
                    //    {
                    //        v[k][l] = (byte)5;
                    //    }
                    //}
                    //SetVertexDataObject(model.Meshes[i].MeshParts[j], v, VertexElementUsage.Position, VertexElementUsage.BlendIndices, VertexElementUsage.BlendWeight);
                    ////v = GetVertexDataObject(model.Meshes[i].MeshParts[j], VertexElementUsage.Position, VertexElementUsage.BlendIndices, VertexElementUsage.BlendWeight);

                    if (effect.CurrentTechnique != effect.Techniques[renderMethod.ToString() + renderType + bone])
                    {
                        effect.CurrentTechnique = effect.Techniques[renderMethod.ToString() + renderType + bone];
                    }

                    //if (techniqueAppend == "Bone" && bone == "")
                    {
                        //if (i >= 5 && i <= 8)
                        //    ModelHelper.ApplyTransform(model.Meshes[i].MeshParts[j], Matrix.CreateScale(10, -10, -10));
                    }
                }
            }
        }