Ejemplo n.º 1
0
        void SetMaterial(MSceneObject mo, string sMaterialID)
        {
            if (sMaterialID == null)
            {
                sMaterialID = MMaterial.DEFAULT_MATERIAL;
            }
            //MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByInstanceID(e.InstanceID);
            MObject   o   = MScene.MaterialRoot.FindModuleByName(sMaterialID);
            MMaterial mat = null;

            if (o != null && o.Type == MObject.EType.Material)
            {
                mat = (MMaterial)o;
                if (mat != null)
                {
                    mo.SetMaterial(mat);
                    mat.MaterialID = sMaterialID;
                }
            }

            if (MassiveTools.IsURL(sMaterialID))
            {
                mat = (MMaterial) new MMaterial("URLShader");
                MShader DefaultShader = (MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER);
                mat.AddShader(DefaultShader);
                mat.ReplaceTexture(Globals.TexturePool.GetTexture(sMaterialID));
                mat.MaterialID = sMaterialID;
                MScene.MaterialRoot.Add(mat);
                mo.SetMaterial(mat);
                mo.material.Setup();
            }
        }
Ejemplo n.º 2
0
        private void Network_TextureHandler(object sender, Massive.Events.TextureEvent e)
        {
            MSceneObject mo = (MSceneObject)MScene.ModelRoot.FindModuleByInstanceID(e.InstanceID);
            MObject      o  = MScene.MaterialRoot.FindModuleByName(e.TextureID);

            if (o != null && o.Type == MObject.EType.Material)
            {
                MMaterial mat = (MMaterial)o;
                mo.SetMaterial(mat);
            }
            else
            {
                if (MassiveTools.IsURL(e.TextureID))
                {
                    MMaterial mat           = (MMaterial) new MMaterial("URLShader");
                    MShader   DefaultShader = (MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER);
                    mat.AddShader(DefaultShader);
                    mat.ReplaceTexture(Globals.TexturePool.GetTexture(e.TextureID));
                    MScene.MaterialRoot.Add(mat);
                    mo.SetMaterial(mat);
                    mo.material.Setup();
                    MMessageBus.ChangedTexture(this, e.InstanceID, e.TextureID);
                }
                else
                {
                    Console.WriteLine("Object " + e.InstanceID + " was null");
                    MMessageBus.Error(this, "Could not find Material:" + e.TextureID);
                }
            }
        }
Ejemplo n.º 3
0
        void SetupMaterials()
        {
            MShader BasicShader = new MShader("BasicShader");

            BasicShader.Load("default_v.glsl",
                             "default_f.glsl",
                             "Terrain\\eval.glsl",
                             "Terrain\\control.glsl"
                             );
            BasicShader.Bind();
            BasicShader.SetInt("material.diffuse", MShader.LOCATION_DIFFUSE);
            BasicShader.SetInt("material.specular", MShader.LOCATION_SPECULAR);
            BasicShader.SetInt("material.multitex", MShader.LOCATION_MULTITEX);
            BasicShader.SetInt("material.normalmap", MShader.LOCATION_NORMALMAP);
            BasicShader.SetInt("material.shadowMap", MShader.LOCATION_SHADOWMAP);

            MShader BoneShader = new MShader("AnimatedShader");
            string  sVertFile  = "Animation\\animated_vs.glsl";
            string  sFragPath  = "Animation\\animated_fs.glsl";

            BoneShader.Load(sVertFile,
                            sFragPath,
                            "",
                            ""
                            );
            BoneShader.Bind();
            BoneShader.SetInt("material.diffuse", MShader.LOCATION_DIFFUSE);
            BoneShader.SetInt("material.specular", MShader.LOCATION_SPECULAR);
            BoneShader.SetInt("material.multitex", MShader.LOCATION_MULTITEX);
            BoneShader.SetInt("material.normalmap", MShader.LOCATION_NORMALMAP);
            BoneShader.SetInt("material.shadowMap", MShader.LOCATION_SHADOWMAP);

            foreach (KeyValuePair <string, MBuildingBlock> k in Blocks)
            {
                MBuildingBlock b = k.Value;
                if (b.Type == "MMaterial")
                {
                    MMaterial MATM = new MMaterial(b.MaterialID);
                    MATM.AddShader(BasicShader);
                    MATM.SetDiffuseTexture(Globals.TexturePool.GetTexture(b.Path));
                    MScene.MaterialRoot.Add(MATM);
                }
                else
                if (b.Type == "MBoneMaterial")
                {
                    MMaterial MATM = new MMaterial(b.MaterialID);
                    MATM.AddShader(BoneShader);
                    MATM.SetDiffuseTexture(Globals.TexturePool.GetTexture(b.Path));
                    MScene.MaterialRoot.Add(MATM);
                }
            }
        }
Ejemplo n.º 4
0
        public override void Setup()
        {
            base.Setup();

            Widget = Helper.CreateModel(MScene.Overlay, "NavigationWidget", @"Models\arrow02.3ds", Vector3d.Zero);
            MMaterial mat = new MMaterial("WidgetMaterial");

            mat.AddShader((MShader)MScene.MaterialRoot.FindModuleByName(MShader.DEFAULT_SHADER));
            mat.SetDiffuseTexture(Globals.TexturePool.GetTexture("Textures\\arrow02.png"));
            Widget.AddMaterial(mat);
            Widget.transform.Scale = new Vector3d(1, 1, 1);
            Widget.Enabled         = true;
        }