protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); BoxObject tmesh = new BoxObject(new Vector3(0), 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); tmesh.isMotionLess = true; ForwardTransparenteShader shader = new ForwardTransparenteShader(); shader.TransparencyLevel = 0.2f; ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } Simulator.setTimeStep(0.10f); Simulator.setAgentDefaults(15.0f, 25, 5.0f, 5.0f, 2.0f,new Vector3()); for (int i = 0; i < 20; i++) { for (int j = 0; j < 20; j++) { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); GhostObject tmesh = new GhostObject(new Vector3(100 + j * 15, 5, i * 15), Matrix.Identity, new Vector3(1, 1, 1)); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); int id = Simulator.addAgent(tmesh.Position); RVOObject obj = new RVOObject(id, fmaterial, simpleModel, tmesh); obj.OnUpdate += new OnUpdate(obj_OnUpdate); /// dummy position update way =p this.World.AddObject(obj); } } this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); Picking p = new Picking(this, 1000); p.OnPickedLeftButton += new OnPicked(p_OnPickedLeftButton); }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ///Classic Island 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); { ///Procedural yellow diffuse texture SimpleModel sm = new SimpleModel(factory, "Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.BlueViolet), TextureType.DIFFUSE); ///physic Ghost object(no collision) GhostObject pi = new GhostObject(new Vector3(0, 0, 0), Matrix.Identity, new Vector3(500, 500, 500)); pi.isMotionLess = true; ///Transparency shader ///Transparent objects are NOT affected by lights ///It is a forward shader in the deferred engine (applied after all deferreed processing) ForwardTransparenteShader s = new ForwardTransparenteShader(); ///If the texture does not have Alpha, you can create an alpha for all the model s.TransparencyLevel = 0.3f; ///THIS MODEL is DRAW AFTER all the Deferred ones (remember:light wont afect it) ///You can use all the forward material the same way we are using this ForwardMaterial mat = new ForwardMaterial(s); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } ///Transparent blocks for (int k = 0; k < 5; k++) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { ///Procedural yellow diffuse texture SimpleModel sm = new SimpleModel(factory, "Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE); ///physic Ghost object(no collision) GhostObject pi = new GhostObject(new Vector3(i * 10, 50 + k * 10, j * 10), Matrix.Identity, new Vector3(5)); pi.isMotionLess = true; ///Transparency shader ///Transparent objects are NOT affected by lights ///It is a forward shader in the deferred engine (applied after all deferreed processing) ForwardTransparenteShader s = new ForwardTransparenteShader(); ///If the texture does not have Alpha, you can create an alpha for all the model s.TransparencyLevel = 0.3f; ///THIS MODEL is DRAW AFTER all the Deferred ones (remember:light wont afect it) ///You can use all the forward material the same way we are using this ForwardMaterial mat = new ForwardMaterial(s); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } } } #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(MathHelper.ToRadians(30), MathHelper.ToRadians(-10), new Vector3(200, 150, 250), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCUBE"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { ///Create the xml file model extractor ///Loads a XML file that was export by our 3DS MAX plugin ExtractXmlModelLoader ext = new ExtractXmlModelLoader("Content//ModelInfos//", "Model//", "Textures//"); this.AttachCleanUpAble(ext); ///Extract all the XML info (Model,Cameras, ...) ModelLoaderData data = ext.Load(factory, GraphicInfo, "ilha"); ///Create the WOrld Loader ///Convert the ModelLoaderData in World Entities WorldLoader wl = new WorldLoader(); ///all default wl.LoadWorld(factory, GraphicInfo, World, data); } { ///Procedural diffuse texture SimpleModel sm = new SimpleModel(factory, "Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.BlueViolet), TextureType.DIFFUSE); ///physic Ghost object(no collision) GhostObject pi = new GhostObject(new Vector3(0, 0, 0), Matrix.Identity, new Vector3(500, 500, 500)); pi.isMotionLess = true; ///Transparency shader ///Transparent objects are NOT affected by lights ///It is a forward shader in the deferred engine (applied after all deferreed processing) ForwardTransparenteShader s = new ForwardTransparenteShader(); ///If the texture does not have Alpha, you can create an alpha for all the model s.TransparencyLevel = 0.3f; ///THIS MODEL is DRAW AFTER all the Deferred ones (remember:light wont afect it) ///You can use all the forward material the same way we are using this ForwardMaterial mat = new ForwardMaterial(s); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } ///Transparent blocks for (int k = 0; k < 5; k++) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { ///Procedural yellow diffuse texture SimpleModel sm = new SimpleModel(factory, "Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE); ///physic Ghost object(no collision) GhostObject pi = new GhostObject(new Vector3(i * 10 + 100, 50 + k*10, j * 10), Matrix.Identity, new Vector3(5)); pi.isMotionLess = true; ///Transparency shader ///Transparent objects are NOT affected by lights ///It is a forward shader in the deferred engine (applied after all deferreed processing) ForwardTransparenteShader s = new ForwardTransparenteShader(); ///If the texture does not have Alpha, you can create an alpha for all the model s.TransparencyLevel = 0.3f; ///THIS MODEL is DRAW AFTER all the Deferred ones (remember:light wont afect it) ///You can use all the forward material the same way we are using this ForwardMaterial mat = new ForwardMaterial(s); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } } } lt = new LightThrowBepu(this.World, factory); #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 this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectStalker()); CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(30), MathHelper.ToRadians(-10), new Vector3(150, 150, 200), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCUBE"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }