示例#1
0
 public YnBillboard(string textureName, float width, float height)
 {
     _material = new BasicMaterial(textureName);
     _rotation = new Vector3(-MathHelper.PiOver2, 0, MathHelper.Pi);
     _width = width;
     _height = height;
     _isFixed = true;
 }
示例#2
0
 /// <summary>
 /// Create an heightmap terrain.
 /// </summary>
 /// <param name="heightmapTexture">Texture to use for height generation.</param>
 /// <param name="textureName">Texture name to use for terrain.</param>
 public Heightmap(Texture2D heightmapTexture, string textureName, Vector3 size)
 {
     _geometry = new HeightmapGeometry(heightmapTexture, size);
     _material = new BasicMaterial(textureName);
 }
示例#3
0
        /// <summary>
        /// Update the current effect. This method will change.
        /// </summary>
        /// <param name="effect"></param>
        /// <param name="material"></param>
        private void UpdateEffect(BasicEffect effect, BasicMaterial material)
        {
            effect.Alpha = material.AlphaColor;
            effect.AmbientLightColor = material.AmbientColor * material.AmbientIntensity;
            effect.DiffuseColor = material.DiffuseColor * material.DiffuseIntensity;
            effect.EmissiveColor = material.EmissiveColor * material.EmissiveIntensity;
            effect.FogColor = material.FogColor;
            effect.FogEnabled = material.EnableFog;
            effect.FogStart = material.FogStart;
            effect.FogEnd = material.FogEnd;
            effect.LightingEnabled = true;

            if (material.EnableDefaultLighting)
                effect.EnableDefaultLighting();

            effect.PreferPerPixelLighting = material.EnabledPerPixelLighting;
            effect.SpecularColor = material.SpecularColor * material.SpecularIntensity;
            effect.VertexColorEnabled = material.EnableVertexColor;


            SceneLight light = (SceneLight)material.Light;

            if (light != null)
            {
                StockMaterial.UpdateLighting(effect, light);
                effect.AmbientLightColor *= light.AmbientColor * light.AmbientIntensity;
            }
        }
示例#4
0
        /// <summary>
        /// Gets material used by the model.
        /// </summary>
        /// <returns>An array of material used by the model.</returns>
        public BaseMaterial[] GetModelMaterial()
        {
            List<BaseMaterial> materials = new List<BaseMaterial>();
            BaseMaterial material = null;

            foreach (ModelMesh mesh in _model.Meshes)
            {
                foreach (ModelMeshPart part in mesh.MeshParts)
                {
                    material = new BasicMaterial();

                    var effect = part.Effect as BasicEffect;

                    if (effect != null)
                    {
                        material.Texture = effect.Texture;
                        material.Effect = effect;
                    }

                    materials.Add(material);
                }
            }

            return materials.ToArray();
        }
示例#5
0
 public SimpleTerrain(string textureName, int width, int depth, int segmentX, int segmentZ)
     : base(width, 0, depth)
 {
     _geometry = new SimpleTerrainGeometry(width, 0, depth, new Vector3(segmentX, 0, segmentZ));
     _material = new BasicMaterial(textureName);
 }