SetMaterialFlag() public method

public SetMaterialFlag ( MaterialFlag flag, bool val ) : void
flag MaterialFlag
val bool
return void
Ejemplo n.º 1
0
Archivo: Point.cs Proyecto: yooyke/work
        public override void Load()
        {
            node = Render.Scene.AddSphereSceneNode(0.1f, 32, Root);
            node.SetMaterialFlag(MaterialFlag.Lighting, true);

            base.Load();
        }
Ejemplo n.º 2
0
		public WaterSceneNode(SceneNode parent, SceneManager mgr, Dimension2Df tileSize,
		                      Dimension2D tileCount, Dimension2D precision, int id) : 
			base(parent, mgr, id)
		{
			_scene = mgr;
			_driver = mgr.VideoDriver;
			
			AnimatedMesh wmesh =  _scene.AddHillPlaneMesh("watermesh" + _current,
                tileSize,
                tileCount, 0,
                new Dimension2Df(0, 0),
                new Dimension2Df(1, 1));
           	_current++; 
           	 
            int dmat = (int)MaterialType.Reflection2Layer;
            if(_driver.DriverType == DriverType.OpenGL)
                dmat = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 WATER_VERTEX_GLSL, "main", VertexShaderType._1_1, WATER_FRAGMENT_GLSL,
                 "main", PixelShaderType._1_1, OnShaderSet, MaterialType.TransparentAlphaChannel, 0);
            else
                dmat = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 WATER_HLSL, "vertexMain", VertexShaderType._2_0, WATER_HLSL,
                 "pixelMain", PixelShaderType._2_0, OnShaderSet, MaterialType.TransparentAlphaChannel, 2);

            if (_driver.DriverType == DriverType.OpenGL)
                ClampShader = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 CLAMP_VERTEX_GLSL, "main", VertexShaderType._1_1, CLAMP_FRAGMENT_GLSL,
                 "main", PixelShaderType._1_1, OnShaderSet, MaterialType.TransparentAlphaChannel, 1);
            else
                ClampShader = _driver.GPUProgrammingServices.AddHighLevelShaderMaterial(
                 CLAMP_HLSL, "vertexMain", VertexShaderType._2_0, CLAMP_HLSL,
                 "pixelMain", PixelShaderType._2_0, OnShaderSet, MaterialType.TransparentAlphaChannel, 3);
                 
           	_waternode = _scene.AddMeshSceneNode(wmesh.GetMesh(0), this, -1);  
            _waternode.SetMaterialType(dmat);
            _waternode.SetMaterialFlag(MaterialFlag.BackFaceCulling, false);
            _waternode.SetMaterialFlag(MaterialFlag.Lighting, false);
            _waternode.SetMaterialFlag(MaterialFlag.FogEnable, false);
            
            _rt = _driver.CreateRenderTargetTexture(precision);
            _waternode.SetMaterialTexture(0, _rt); 
            
            CameraSceneNode oldcam = _scene.ActiveCamera;
            _fixedcam = _scene.AddCameraSceneNode(null);
            if(oldcam != null)
            	_scene.ActiveCamera = oldcam;
		}
Ejemplo n.º 3
0
        public override int Load()
        {
            const string filename = "sea_shader_low.fx";

            int res = -1;

            string path = shaderDirectory + filename;
            if (System.IO.File.Exists(path))
            {
                try
                {
                    res = Reference.VideoDriver.GPUProgrammingServices.AddHighLevelShaderMaterialFromFiles(
                        path, "VS", VertexShaderType._2_0,
                        path, "PS", PixelShaderType._2_0,
                        ShaderEvent, MaterialType.TransparentAlphaChannel, 0
                        );
                }
                catch (Exception e)
                {
                    Reference.Log.Fatal("Load", e);
                }

                if (res > 0)
                    Reference.Log.Debug("Load: Loaded" + path);
                else
                    Reference.Log.Error("Load: not Loaded:" + path);
            }
            else
            {
                Reference.Log.Warn("Load: File not exsit:" + path);
            }

            if (res > 0)
            {
                const string meshName = "sea001.x";

                if (System.IO.File.Exists(modelDirectory + meshName))
                {
                    AnimatedMesh mesh = Reference.SceneManager.GetMesh(modelDirectory + meshName);

                    node = Reference.SceneManager.AddMeshSceneNode(mesh.GetMesh(0), parentNode, -1);
                    node.Position = new Vector3D(128, 0, 128);
                    node.SetMaterialFlag(MaterialFlag.BackFaceCulling, false);
                }
            }

            return res;
        }
Ejemplo n.º 4
0
        public override int Load()
        {
            string filename = "sky_shader.fx";

            if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.Low)
            {
                filename = "sky_shader_low.fx";
            }

            int res = -1;

            string path = shaderDirectory + filename;
            if (System.IO.File.Exists(path))
            {
                try
                {
                    res = Reference.VideoDriver.GPUProgrammingServices.AddHighLevelShaderMaterialFromFiles(
                        path, "VS", VertexShaderType._2_0,
                        path, "PS", PixelShaderType._2_0,
                        ShaderEvent, MaterialType.Solid, 0
                        );
                }
                catch (Exception e)
                {
                    Reference.Log.Fatal("Load", e);
                    res = -1;
                }

                if (res > 0)
                {
                    Reference.Log.Debug("Load: Loaded" + path);
                }
                else
                {
                    Reference.Log.Debug("Load: not Loaded:" + path);
                }
            }
            else
            {
                Reference.Log.Warn("Load: File not exsit:" + path);
            }

            if (res > 0)
            {
                // Create sun.
                sunNode = Reference.SceneManager.AddBillboardSceneNode(parentNode, new Dimension2Df(256, 256), -1);
                sunNode.SetMaterialTexture(0, Reference.VideoDriver.GetTexture(textureDirectory + @"sun.bmp"));
                sunNode.SetMaterialType(MaterialType.TransparentAddColor);
                sunNode.Position = new Vector3D(1, 1, 0) * 8000;
                sunNode.SetMaterialType(MaterialType.TransparentAddColor);
                sunNode.SetMaterialFlag(MaterialFlag.Lighting, false);

                // Create moon.
                moonNode = Reference.SceneManager.AddBillboardSceneNode(parentNode, new Dimension2Df(512, 512), -1);
                moonNode.SetMaterialTexture(0, Reference.VideoDriver.GetTexture(textureDirectory + @"moon.bmp"));
                moonNode.SetMaterialType(MaterialType.TransparentAddColor);
                moonNode.Position = new Vector3D(-1, 1, 0) * 8000;
                moonNode.SetMaterialType(MaterialType.TransparentAddColor);
                moonNode.SetMaterialFlag(MaterialFlag.Lighting, false);

                if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.High)
                {
                    const string memisphereMeshName = "sky.x";

                    if (System.IO.File.Exists(modelDirectory + memisphereMeshName))
                    {
                        AnimatedMesh animMesh = Reference.SceneManager.GetMesh(modelDirectory + memisphereMeshName);
                        if (animMesh != null)
                        {
                            Mesh mesh = animMesh.GetMesh(0);
                            skyNode = Reference.SceneManager.AddMeshSceneNode(mesh, parentNode, -1);
                            skyNode.Position = new Vector3D(128, 0, 128);
                            skyNode.Scale = new Vector3D(1.1f, 1.1f, 1.1f);
                            skyNode.SetMaterialFlag(MaterialFlag.BackFaceCulling, false);
                            skyNode.SetMaterialFlag(MaterialFlag.FogEnable, false);
                            skyNode.SetMaterialType(res);

            #if YK_UNUSE_MULTI_TEXTURE_STAR
                            const string starTextureName = "star.tga";
                            Texture tex = Reference.VideoDriver.GetTexture(modelDirectory + starTextureName);
                            skyNode.SetMaterialTexture(1, tex);
            #endif
                        }
                    }
                }
                else if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.Low)
                {
                    SceneNode node = Reference.SceneManager.AddSkyBoxSceneNode(
                        parentNode,
                        new Texture[]
                        {
                            Reference.VideoDriver.GetTexture(textureDirectory + "sea_sky_UP.jpg"),
                            Reference.VideoDriver.GetTexture(textureDirectory + "sea_sky_DN.jpg"),
                            Reference.VideoDriver.GetTexture(textureDirectory + "sea_sky_LF.jpg"),
                            Reference.VideoDriver.GetTexture(textureDirectory + "sea_sky_RT.jpg"),
                            Reference.VideoDriver.GetTexture(textureDirectory + "sea_sky_FR.jpg"),
                            Reference.VideoDriver.GetTexture(textureDirectory + "sea_sky_BK.jpg"),
                        },
                        -1
                        );

                    for (int i = 0; i < node.MaterialCount; i++)
                    {
            #if YK_VIDEO_WIREFRAME
                        node.GetMaterial(i).Wireframe = true;
            #endif
                    }

                    // Unuse gold sun and silver moon.
                    sunNode.Visible = false;
                    moonNode.Visible = false;
                }

                // Create  light
                sunLight = new DirectionalLight(Reference.Viewer, parentNode, "SunLight");
                sunLight.Load(Colorf.White, Colorf.Black, Colorf.Black);
            }
            else
            {
                switch (Reference.Viewer.SkyQuality)
                {
                    case Viewer.ShaderLevelType.High:
                    case Viewer.ShaderLevelType.Middle:
                        Reference.Viewer.SkyQuality = Viewer.ShaderLevelType.Low;
                        res = Load();
                        break;

                    case Viewer.ShaderLevelType.Low:
                        Reference.Viewer.ShowMessageBox(DialogText.DisabledSkyShader);
                        break;
                }
            }

            return res;
        }