Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwardMaterial"/> class.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="shader">The shader.</param>
 public DeferredAnimatedMaterial(IAnimatedController controller, DeferredSimpleAnimationShader shader)
 {
     System.Diagnostics.Debug.Assert(shader.MaterialType == Material.MaterialType.DEFERRED);
     this.Shader     = shader;
     this.controller = controller;
     CanAppearOfReflectionRefraction = true;
     CanCreateShadow = true;
     IsVisible       = true;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ForwardMaterial"/> class.
 /// </summary>
 /// <param name="controller">The controller.</param>
 /// <param name="shader">The shader.</param>
 public DeferredAnimatedMaterial(IAnimatedController controller, DeferredSimpleAnimationShader shader)
 {
     System.Diagnostics.Debug.Assert(shader.MaterialType == Material.MaterialType.DEFERRED);
     this.Shader = shader;
     this.controller = controller;
     CanAppearOfReflectionRefraction = true;
     CanCreateShadow = true;
     IsVisible = true;
 }
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            {
                ///carrega o Modelo
                AnimatedModel am = new AnimatedModel(factory, "..\\Content\\Model\\PlayerMarine", "..\\Content\\Textures\\PlayerMarineDiffuse");
                ///Inicializa o Controlador (Idle eh o nome da animacao inicial)
                AnimatedController arobo = new AnimatedController(am, "Idle");

                ///Cria o shader e o material animados 
                DeferredSimpleAnimationShader sas = new DeferredSimpleAnimationShader(arobo);
                DeferredAnimatedMaterial amat = new DeferredAnimatedMaterial(arobo, sas);

                CharacterControllerInput gp = new CharacterControllerInput(this, new Vector3(100, 50, 1), 25, 10, 10, Vector3.One);

                IObject marine = new IObject(amat, am, gp.Characterobj);
                ///Adiciona no mundo
                this.World.AddObject(marine);

                LightThrowBepu lt = new LightThrowBepu(this.World, factory);
            }

            {
                SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
                TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
                DeferredNormalShader shader = new DeferredNormalShader();
                DeferredMaterial fmaterial = new DeferredMaterial(shader);
                IObject obj = new IObject(fmaterial, simpleModel, tmesh);
                this.World.AddObject(obj);
            }



            #region NormalLight
            DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
            DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
            DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
            DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
            DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
            float li = 0.5f;
            ld1.LightIntensity = li;
            ld2.LightIntensity = li;
            ld3.LightIntensity = li;
            ld4.LightIntensity = li;
            ld5.LightIntensity = li;
            this.World.AddLight(ld1);
            this.World.AddLight(ld2);
            this.World.AddLight(ld3);
            this.World.AddLight(ld4);
            this.World.AddLight(ld5);
            #endregion

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
            cam.MoveSpeed *= 5;
            this.World.CameraManager.AddCamera(cam);

            SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube");
            CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);

        }