Пример #1
0
        /// <summary>
        /// Preloads the default materials
        /// </summary>
        /// <param name="game">The game which will own these materials</param>
        public static void LoadMaterials(Game game)
        {
            Material.Game = game;

            Default = new Material(Color.Gray);
            HeatedMetal = new Material("Materials/Heated Metal/Texture", 0.8f, 8);
            Grass = new Material("Grass", 0, 0);
        }
Пример #2
0
        public ComplexModel(Game game, Model model, Vector3 position, Vector3 rotation, Vector3 scale, Material material) : base(game)
        {
            Model = model;
            ModelMaterials = new Material[Model.Meshes.Sum(m => m.MeshParts.Count)];

            for (int i = 0; i < ModelMaterials.Length; i++)
                ModelMaterials[i] = material;

            Position = position;
            //Rotation = rotation;
            Rotation = Quaternion.Identity;
            Scale = scale;
        }
Пример #3
0
        public ComplexModel(Game game, Model model, Vector3 position, Vector3 rotation, Vector3 scale) : base(game)
        {
            Model = model;
            ModelMaterials = new Material[Model.Meshes.Sum(m => m.MeshParts.Count)];

            int i = 0;
            foreach (ModelMesh mesh in Model.Meshes)
                foreach (ModelMeshPart meshPart in mesh.MeshParts)
                {
                    Texture2D texture;
                    float specularIntensity;
                    float specularPower;

                    if (meshPart.Effect is BasicEffect)
                    {
                        texture = (meshPart.Effect as BasicEffect).Texture;
                        specularIntensity = 0; // FIXME
                        specularPower = (meshPart.Effect as BasicEffect).SpecularPower;
                    }
                    else
                    {
                        texture = meshPart.Effect.Parameters["Texture"].GetValueTexture2D();
                        specularIntensity = 0;
                        specularPower = meshPart.Effect.Parameters["SpecularPower"].GetValueSingle();
                    }

                    ModelMaterials[i] = new Material(texture, specularIntensity, specularPower);

                    i++;
                }

            Position = position;
            //Rotation = rotation;
            Rotation = Quaternion.Identity;
            Scale = scale;
        }
Пример #4
0
 public ComplexModel(Game game, string assetName, Vector3 position, Vector3 rotation, Vector3 scale, Material material) : this(game, game.Content.Load<Model>(assetName), position, rotation, scale, material)
 {
 }