/// <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); { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = -i * 100; y = -j * 100; TreeModel tm = new TreeModel(factory, "Trees\\Pine", null, null); ForwardTreeShader ts = new ForwardTreeShader(); TreeMaterial tmat = new TreeMaterial(ts, new WindStrengthSin()); GhostObject go = new GhostObject(new Vector3(x, 0, y), Matrix.Identity, new Vector3(0.05f)); IObject ox = new IObject(tmat, tm, go); this.World.AddObject(ox); } } } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo.Viewport)); }
/// <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 a simple object ///Geomtric Info and textures (this model automaticaly loads the texture) SimpleModel simpleModel = new SimpleModel(factory, "model/dude"); for (int i = 0; i < simpleModel.GetTextureInformation(0).Count(); i++) { simpleModel.GetTextureInformation(0)[i].SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); } ///Physic info (position, rotation and scale are set here) GhostObject pi = new GhostObject(new Vector3(200, 10, 0), Matrix.Identity, new Vector3(4)); ///Shader info (must be a deferred type) ForwardGradativeAlphaShader shader = new ForwardGradativeAlphaShader(); ///Material info (must be a deferred type also) ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, pi); ///Add to the world this.World.AddObject(obj); } { ///Create a simple object ///Geomtric Info and textures (this model automaticaly loads the texture) SimpleModel simpleModel = new SimpleModel(factory, "model/dude"); //simpleModel.SetTexture(factory.CreateTexture2DColor(1,1,Color.Red), TextureType.DIFFUSE); ///Physic info (position, rotation and scale are set here) GhostObject pi = new GhostObject(new Vector3(200, 10, 0), Matrix.Identity, new Vector3(4)); ///Shader info (must be a deferred type) ForwardEMTransparentShader shader = new ForwardEMTransparentShader("Textures/Cubemap"); ///Material info (must be a deferred type also) ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, pi); ///Add to the world this.World.AddObject(obj); } { SimpleModel simpleModel = new SimpleModel(factory, "model/cenario"); ///Physic info (position, rotation and scale are set here) TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Deferred material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world //this.World.AddObject(obj); } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///must be called before all base.LoadContent(GraphicInfo, factory, contentManager); { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = -i * 100; y = -j * 100; TreeModel tm = new TreeModel(factory,"Trees\\Pine",null,null); DeferredTreeShader ts = new DeferredTreeShader(); TreeMaterial tmat = new TreeMaterial(ts, new WindStrengthSin()); GhostObject go = new GhostObject(new Vector3(x, 0, y), Matrix.Identity, new Vector3(0.05f)); IObject ox = new IObject(tmat, tm, go); this.World.AddObject(ox); } } } ///Add some directional lights to completely iluminate the world #region Lights 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.4f; 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 ///Add a AA post effect this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo.Viewport)); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo,factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//techdemo"); GhostObject tmesh = new GhostObject(); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } LightThrowBepu 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); DirectionalLightPE ld6 = new DirectionalLightPE(Vector3.Up, Color.White); float li = 0.9f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; ld6.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); this.World.AddLight(ld6); #endregion CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.MoveSpeed *= 5; this.World.CameraManager.AddCamera(cam); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); }
IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] oi) { IObject[] objs = new IObject[oi.Count()]; int i = 0; foreach (var mi in oi) { mi.batchInformation.ModelLocalTransformation = Matrix.Identity; IModelo model = new CustomModel(factory, mi.modelName, mi.batchInformation, mi.textureInformation, mi.meshIndex, mi.meshPartIndex); //IPhysicObject po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); GhostObject po = new GhostObject(mi.position, Matrix.CreateFromQuaternion(mi.rotation), mi.scale); IShader shader = new ForwardXNABasicShader(); ForwardMaterial dm = new ForwardMaterial(shader); IObject obj = new IObject(dm, model, po); objs[i++] = obj; } return objs; }
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); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models { simpleModel = new SimpleModel(factory, "..\\Content\\Model\\teapot"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); GhostObject tmesh = new GhostObject(Vector3.Zero, Matrix.Identity, Vector3.One * 2); ///Environment Map Shader, there are 2 options, the first is a fully reflective surface (dont use the object texture) and the second ///is a mix of the object texture and the environment texture ///Used to fake ambient reflection, give metal appearence to an object .... shader = new ForwardEnvironmentShader(factory.GetTextureCube("Textures\\cubeMap"),1,false); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject tea = new IObject(fmaterial, simpleModel, tmesh); tea.OnUpdate += new OnUpdate(tea_OnUpdate); this.World.AddObject(tea); } //{ // SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); // simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); // BoxObject tmesh = new BoxObject(new Vector3(0,-20,0), 1, 1, 1, 10, new Vector3(200, 1, 200), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); // tmesh.isMotionLess = true; // DeferredNormalShader shader = new DeferredNormalShader(); // DeferredMaterial fmaterial = new DeferredMaterial(shader); // IObject obj = new IObject(fmaterial, simpleModel, tmesh); // this.World.AddObject(obj); //} #endregion cam = new RotatingCamera(this); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubeMap"); 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); { GhostObject GhostObject = new PloobsEngine.Physics.Bepu.GhostObject(); SkinnedIObject SkinnedIObject = new SkinnedIObject(factory, "Model/Dude/dude", GhostObject); this.World.AddObject(SkinnedIObject); AnimationClip clip = SkinnedIObject.SkinnedModel.SkinningData.AnimationClips["Take 001"]; SkinnedIObject.SkinnedModel.AnimationPlayer.StartClip(clip); SkinnedIObject.ForwardSkinnedShader.SkinnedEffect.EnableDefaultLighting(); SkinnedIObject.ForwardSkinnedShader.SkinnedEffect.SpecularColor = new Vector3(0.25f); SkinnedIObject.ForwardSkinnedShader.SkinnedEffect.SpecularPower = 16; } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(MathHelper.ToRadians(50), MathHelper.ToRadians(-10), new Vector3(50), GraphicInfo)); }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///must be called before all base.LoadContent(GraphicInfo, factory, contentManager); ///Uncoment to Add an object /////Create a simple object /////Geomtric Info and textures (this model automaticaly loads the texture) //SimpleModel simpleModel = new SimpleModel(factory, "Model FILEPATH GOES HERE", "Diffuse Texture FILEPATH GOES HERE -- Use only if it is not embeded in the Model file"); /////Physic info (position, rotation and scale are set here) //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); /////Shader info (must be a deferred type) //DeferredNormalShader shader = new DeferredNormalShader(); /////Material info (must be a deferred type also) //DeferredMaterial fmaterial = new DeferredMaterial(shader); /////The object itself //IObject obj = new IObject(fmaterial, simpleModel, tmesh); /////Add to the world //this.World.AddObject(obj); { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE); BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(500, 5, 500), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); tmesh.isMotionLess = true; ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE); GhostObject go = new GhostObject(Vector3.Zero, Matrix.Identity, new Vector3(1, 100, 1)); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); BaseObject obj = new BaseObject(fmaterial, simpleModel, go); obj.Name = "TORRE1"; this.World.AddObject(obj); //entityFactory.CreateShooterTower(obj, 3, 2, 100); } { Texture2D tex = factory.GetTexture2D("Textures//spriteteste"); SpriteAnimated SpriteAnimated = new PloobsEngine.Modelo2D.SpriteAnimated(tex, 9, 8); SpriteAnimated.PlayCurrentAnimation(); CharacterObject Characterobj = new CharacterObject(new Vector3(25, 15, 25), Matrix.Identity, 10, 5, 10, 1f, Vector3.One, 5); Sprite3DShader Sprite3DShader = new Sprite3DShader(Vector2.One); ForwardMaterial fmaterial = new ForwardMaterial(Sprite3DShader); ISpriteObject obj = new ISpriteObject(fmaterial, SpriteAnimated, Characterobj); obj.Name = "Enemy"; this.World.AddObject(obj); obj.OnUpdate += new OnUpdate(obj_OnUpdate); } ///Add some directional lights to completely iluminate the world #region Lights 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.4f; 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 ///Add a AA post effect this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Trigger ///Criacao de um Trigger ///Create a trigger { ///Modelo cujo formato sera utilizado para disparar o trigger ///Model used as base the for the trigger SimpleModel sm = new SimpleModel(factory,"..\\Content\\Model\\cubo" ); sm.SetTexture(factory.CreateTexture2DColor(1,1, Color.Red), TextureType.DIFFUSE); ///VERMELHO ///Criacao do Triangle Mesh ///Create the triangle mesh from the model TriangleMeshObject tm = new TriangleMeshObject(sm,new Vector3(200, 5, 0),Matrix.Identity,Vector3.One * 10,MaterialDescription.DefaultBepuMaterial()); ///Criacao do Evento q sera disparado qd o trigger for acionado ///Pode-se criar outros tipos de eventos, basta extender a classe IEvent ///O parametro passado eh o canal em que o trigger enviara suas mensagens ///Qualquer Entidade que extende IRecieveMessageEntity pode receber mensagens ///Create the eventr that the trigger will fire ///TriggerEvent is the name of the CHANNEL (SEE CHANGINGMESSAGESSCREEN.CS) where the trigger will send the messages. (you can change the name at your will, change also the channel that the other objects are listening) TriggerEvent te = new TriggerEvent("TriggerEvent","TriggerTest1"); ///Criacao do Trigger ///Creating and adding the trigger to the physic world BepuPhysicWorld physicWorld = this.World.PhysicWorld as BepuPhysicWorld; System.Diagnostics.Debug.Assert(physicWorld != null); ///Setting triggers configuration, IT RECIEVES A TRIANGLE MESH ///TRIGGERS ARE ALWAYS TRIANGLE MESHES !!!! BepuTrigger bt = new BepuTrigger(physicWorld, tm, te, true, true, true, true); ///Adiciona o trigger ao mundo this.World.AddTrigger(bt); ///Adicona um objeto na posicao do trigger (Objeto FANTASMA, nao sera detectado pelo trigger) ///Facilita na localizacao do Trigger ///CREATE A VISUAL OBJECT FOR THE TRIGGER (SO WE CAN SEE IT) ///GHOST OBJECT (NO COLLISION) GhostObject ghost = new GhostObject(new Vector3(200, 5, 0), Matrix.Identity,Vector3.One * 10); ///material and shader DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); /// add the visual object (DONT NEED, WE ADDED JUST TO SEE THE TRIGGER) IObject obj3 = new IObject(mat, sm, ghost); this.World.AddObject(obj3); } #endregion ///Criacao de um Objeto q recebera mensagens do trigger ///THIS OBJECT THAT WILL RECIEVE MESSAGE FROM the trigger #region Models { SimpleModel sm = new SimpleModel(factory,"..\\Content\\Model\\cubo"); sm.SetTexture(factory.CreateTexture2DColor(1,1, Color.White), TextureType.DIFFUSE); ///BRANCO IPhysicObject pi = new TriangleMeshObject( sm,new Vector3(20,50,50), Matrix.Identity,Vector3.One * 10,MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); ///Cadastra uma funcao para tratar das mensagens recebidas ///existem outras maneiras de fazer isso, como Extender a classe IObject e sobrescrever o metodo HandleMessage ///MESSAGE HANDLER obj3.OnRecieveMessage += new OnRecieveMessage(obj3_OnRecieveMessage); this.World.AddObject(obj3); ///Adiciona o Objeto criado ao grupo "TriggerEvent" que recebera as mensagens do trigger ///Register to recieve TriggerEvent Messages (registering to the channel) EntityMapper.getInstance().AddgrouptagRecieveEntity("TriggerEvent", obj3); } ///Cenario de sempre { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cenario"); IPhysicObject pi = new TriangleMeshObject(sm,Vector3.Zero,Matrix.Identity,Vector3.One,MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #endregion ///Demonstracao de que qualquer entidade pode receber mensagens ///Olhar a implementacao desta classe, esta no fim deste arquivo ///Creating an entity to recieve the trigger message also ///JUST to show that everyone can recieve messages rmessage = new ReciveMessage(); cam = new CameraFirstPerson(GraphicInfo); cam.FarPlane = 2000; lt = new LightThrowBepu(this.World, factory); #region NormalLight ///Conjunto de luzes direcionais 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.4f; 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.World.CameraManager.AddCamera(cam); }
/// <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); RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc); dlines = new DebugLines(); ddrawer.AddShape(dlines); Picking pick = new Picking(this,2000); pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton); { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); ///Physic info (position, rotation and scale are set here) BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); tmesh.isMotionLess = true; ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Deferred material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); } wh = new WaypointHandler(); wh.LoadConnectedWaypoints("waypoints.xml"); start = wh.CurrentWaypointsCollection.GetWaypointsList()[0]; { ///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(start.WorldPos, Matrix.Identity, new Vector3(5)); ForwardXNABasicShader s = new ForwardXNABasicShader(); ForwardMaterial mat = new ForwardMaterial(s); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); { SimpleModel sm = new SimpleModel(factory, "Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); GhostObject pi = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5)); ForwardXNABasicShader s = new ForwardXNABasicShader(); ForwardMaterial mat = new ForwardMaterial(s); IObject obj4 = new IObject(mat, sm, pi); obj4.OnUpdate += new OnUpdate(obj4_OnUpdate); this.World.AddObject(obj4); } }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///must be called before all base.LoadContent(GraphicInfo, factory, contentManager); { IModelo sm = new SimpleModel(factory, "Model\\block"); Matrix trans = Matrix.CreateTranslation(new Vector3(100, 50, 0)); Plane plano = Plane.Transform(new Plane(0, 1, 0, 0), trans); IPhysicObject pi = new BoxObject(Vector3.Zero, 1, 1, 1, 5, new Vector3(1300, 0.1f, 1300), trans, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; ///Water shader, will refract and reflect according to the plano passed in the parameter ///Using default Parameters, there are lots of things that can be changed. See WaterCompleteShader DeferredWaterCompleteShader shader = new DeferredWaterCompleteShader(800, 600, plano, 0); shader.SpecularIntensity = 0.01f; shader.SpecularPower = 50; IMaterial mat = new DeferredMaterial(shader); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } { ///Need to load the height, the normal texture and the difuse texture SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block", "..\\Content\\Textures\\color_map"); sm.SetTexture("Textures\\normal_map", TextureType.BUMP); sm.SetCubeTexture(factory.GetTextureCube("Textures//cubemap"), TextureType.ENVIRONMENT); BoxObject pi = new BoxObject(new Vector3(200, 110, 0), 1, 1, 1, 5, new Vector3(100, 100, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); DeferredEnvironmentCustomShader DeferredEnvironmentCustomShader = new DeferredEnvironmentCustomShader(false, true, false); DeferredEnvironmentCustomShader.SpecularIntensity = 0.2f; DeferredEnvironmentCustomShader.SpecularPower = 30; DeferredEnvironmentCustomShader.ShaderId = ShaderUtils.CreateSpecificBitField(true); IMaterial mat = new DeferredMaterial(DeferredEnvironmentCustomShader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } { List<Vector3> poss = new List<Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 100; y = j * 100; poss.Add(new Vector3(x, 100, y)); } } StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss); DeferredCilindricGPUBilboardShader cb = new DeferredCilindricGPUBilboardShader(); DeferredMaterial matfor = new DeferredMaterial(cb); GhostObject go = new GhostObject(); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } ///Add some directional lights to completely iluminate the world #region Lights 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.4f; 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 ///Add a AA post effect this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
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; ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } Simulator = Simulator.Instance; Simulator.setTimeStep(0.25f); Simulator.setAgentDefaults(5.0f, 25, 10.0f, 25.0f, 2.0f, 4.0f,new Vector2(0)); 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); BoxObject tmesh = new BoxObject(new Vector3(100 + j*5, 5, i * 5), 1, 1, 1, 10, new Vector3(1, 1, 1), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); 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); } } ///counterclockwise vertices Simulator.addObstacle( new List<Vector2>() { new Vector2(20,20), new Vector2(40,20), new Vector2(40,40), new Vector2(40,40), new Vector2(20,40), new Vector2(20,20), } ); Simulator.processObstacles(); ///obstacle { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE); GhostObject tmesh = new GhostObject(new Vector3(30,0,30),Matrix.Identity,new Vector3(10)); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); Picking p = new Picking(this, 1000); p.OnPickedLeftButton += new OnPicked(p_OnPickedLeftButton); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { 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); } ///Varios blocos transparentes for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { SimpleModel sm = new SimpleModel(factory, "Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE); GhostObject pi = new GhostObject(new Vector3(i * 10, 50, j * 10), Matrix.Identity, new Vector3(5)); pi.isMotionLess = true; DeferredNormalShader s = new DeferredNormalShader(); DeferredMaterial mat = new DeferredMaterial(s); IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); } } LightThrowBepu 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 CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.MoveSpeed *= 5; this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); //this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectStalker()); //this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectTabula()); this.RenderTechnic.AddPostEffect(new MLAntiAliasingPostEffect()); //this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } ///using component Billboard3D Billboard3D = new Billboard3D(factory.GetTexture2D("Textures\\grama1"), new Vector3(100, 20, 100), Vector2.One * 0.2f); BillboardComponent.Billboards.Add(Billboard3D); ///using old mode (IObject billboard) { List<Billboard> poss = new List<Billboard>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 10; y = j * 10; poss.Add( new Billboard() { Position = new Vector3(x, 50 , y), Scale = Vector2.One * 0.01f, Enabled = true } ); } } CPUBillboardModel bm = new CPUBillboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss.ToArray()); ForwardAlphaTestShader cb = new ForwardAlphaTestShader(128,CompareFunction.GreaterEqual); ForwardMaterial matfor = new ForwardMaterial(cb); matfor.RasterizerState = RasterizerState.CullNone; GhostObject go = new GhostObject(); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); //Text Billboards TextBillboard3D TextBillboard3D = new TextBillboard3D("TEST 123 SPHERICAL", Color.Black, new Vector3(100), 0.5f); sBillboardComponent.Billboards.Add(TextBillboard3D); TextBillboard3D = new TextBillboard3D("TEST 123 Cylinder", Color.Black, new Vector3(200, 50, 200), 0.5f); cBillboardComponent.Billboards.Add(TextBillboard3D); } this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
/// <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); }
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.White),TextureType.DIFFUSE); BoxObject tmesh = new BoxObject(new Vector3(0,10,0), 1, 1,1,50,new Vector3(5000,1,5000),Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); tmesh.isMotionLess = true; DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); { List<BilboardInstance> poss = new List<BilboardInstance>(); for (int i = -10 ; i < 20; i++) { for (int j = -10; j < 20; j++) { float x, y; x = i * 100; y = j * 100; BilboardInstance bi = new BilboardInstance(); bi.Scale = new Vector2(100, 100); bi.Position = new Vector3(x, 5, y); poss.Add(bi); } } ///same as before, just the name of the class change ///You can change the position of a individual bilboard using bm.GetBilboardInstances(), updating the structure recieved and ///using bm.SetBilboardInstances(). Dont do this every frame pls =P ///You can change lots of parameters of the DeferredInstancedBilboardShader, check it InstancedBilboardModel bm = new InstancedBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree",poss.ToArray()); DeferredInstancedBilboardShader cb = new DeferredInstancedBilboardShader(BilboardType.Cilindric); DeferredMaterial matfor = new DeferredMaterial(cb); GhostObject go = new GhostObject(); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } #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(-50), MathHelper.ToRadians(-15), new Vector3(-200, 300, 250), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); #region Models { SimpleModel simpleModel = new SimpleModel(factory, "..\\Content\\Model\\teapot"); simpleModel.SetTexture(factory.CreateTexture2DColor(1,1, Color.Red), TextureType.DIFFUSE); //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); GhostObject tmesh = new GhostObject(Vector3.Zero, Matrix.Identity, Vector3.One); ///Environment Map Shader, there are 2 options, the first is a fully reflective surface (dont use the object texture) and the second ///is a mix of the object texture and the environment texture ///Used to fake ambient reflection, give metal appearence to an object .... DeferredEMReflectiveShader shader = new DeferredEMReflectiveShader("Textures\\grassCUBE", 0.9f); DeferredMaterial fmaterial = new DeferredMaterial(shader); tea = new IObject(fmaterial, simpleModel, tmesh); tea.OnUpdate += new OnUpdate(tea_OnUpdate); this.World.AddObject(tea); } //{ // SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); // simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); // BoxObject tmesh = new BoxObject(new Vector3(0,-20,0), 1, 1, 1, 10, new Vector3(200, 1, 200), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); // tmesh.isMotionLess = true; // DeferredNormalShader shader = new DeferredNormalShader(); // DeferredMaterial fmaterial = new DeferredMaterial(shader); // IObject obj = new IObject(fmaterial, simpleModel, tmesh); // this.World.AddObject(obj); //} #endregion 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 SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCUBE"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(30), MathHelper.ToRadians(-30), new Vector3(30, 30, 50), GraphicInfo); cam.FarPlane = 500; cam.NearPlane = 1; this.World.CameraManager.AddCamera(cam); //AntiAliasingPostEffectTabula aa = new AntiAliasingPostEffectTabula(); //aa.Weights = 2; //this.RenderTechnic.AddPostEffect(aa); }
public static IObject[] CreateOBJ(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi) { IModelo model = new CustomModel(factory, mi); MaterialDescription material; if (mi[0].staticfriction == -1 || mi[0].dinamicfriction == -1 || mi[0].ellasticity == -1) { material = MaterialDescription.DefaultBepuMaterial(); } else { material = new MaterialDescription(mi[0].staticfriction, mi[0].dinamicfriction, mi[0].ellasticity); } IPhysicObject po; bool massflag = false; if (mi[0].mass == 0) { massflag = true; mi[0].mass = 0.5f; } BatchInformation binf = model.GetBatchInformation(0)[0]; BoundingBox bb; switch (mi[0].collisionType) { case "Ghost": po = new GhostObject(mi[0].position,Matrix.CreateFromQuaternion(mi[0].rotation), mi[0].scale); break; case "Cylinder": binf.ModelLocalTransformation = Matrix.Identity; bb = ModelBuilderHelper.CreateBoundingBoxFromModel(binf); Vector3 len = bb.Max - bb.Min; po = new CylinderObject(mi[0].position, len.Y, len.X / 2,Vector3.Up ,mi[0].mass, Matrix.CreateFromQuaternion(mi[0].rotation), material); break; case "Sphere": binf.ModelLocalTransformation = Matrix.Identity; po = new SphereObject(mi[0].position, model.GetModelRadius(), mi[0].mass, mi[0].scale.X, material); po.Rotation = Matrix.CreateFromQuaternion(mi[0].rotation); break; case "Box": bb = ModelBuilderHelper.CreateBoundingBoxFromModel(binf); len = bb.Max - bb.Min; po = new BoxObject(mi[0].position, len.X, len.Y, len.Z, mi[0].mass, mi[0].scale, Matrix.CreateFromQuaternion(mi[0].rotation), material); break; case "Water": po = new GhostObject(mi[0].position, Matrix.CreateFromQuaternion(mi[0].rotation), mi[0].scale); break; case "TriangleMesh": default: po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, new Vector3(1), material); break; } po.isMotionLess = massflag; IShader shader = null; #if !REACH && !WINDOWS_PHONE if (mi[0].HasTexture(TextureType.ENVIRONMENT)) { shader = new DeferredEMReflectiveShader(); (shader as DeferredEMReflectiveShader).TextureCube = mi[0].textureInformation.getCubeTexture(TextureType.ENVIRONMENT); } else if (mi[0].collisionType != null && mi[0].collisionType.Contains("Water")) { Vector3 position = (Vector3)(mi[0].extra["position"]); var width = (mi[0].extra["width"]); var height = (mi[0].extra["length"]); shader = new DeferredWaterCompleteShader((int)width,(int)height, new Plane(position.X, position.Y, position.Z, 1),10.0f); } else { shader = new DeferredCustomShader(mi[0].HasTexture(TextureType.GLOW), mi[0].HasTexture(TextureType.BUMP), mi[0].HasTexture(TextureType.SPECULAR), mi[0].HasTexture(TextureType.PARALAX)); } DeferredMaterial dm = new DeferredMaterial(shader); #else shader = new ForwardXNABasicShader(); ForwardMaterial dm = new ForwardMaterial(shader); #endif IObject ob = new IObject(dm, model, po); ob.Name = mi[0].modelName; return new IObject[] { ob }; }
/// <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); { ///Uncoment to add your model SimpleModel simpleModel = new SimpleModel(factory, "Model/cenario"); ///Physic info (position, rotation and scale are set here) TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Forward material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); } { SimpleModel simpleModel = new SimpleModel(factory, "duck"); simpleModel.SetTexture(factory.CreateTexture2DColor(1,1,Color.White)); ///Physic info (position, rotation and scale are set here) GhostObject tmesh = new GhostObject(new Vector3(100, 60, 120), Matrix.Identity, Vector3.One ); ///Forward Shader (look at this shader construction for more info) DynEnvMaterial DynEnvMaterial = new PloobsProjectTemplate.TemplateScreens.DynEnvMaterial(); ///The object itself IObject obj = new IObject(DynEnvMaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); } { SimpleModel simpleModel = new SimpleModel(factory, "duck"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White)); ///Physic info (position, rotation and scale are set here) GhostObject tmesh = new GhostObject(new Vector3(200, 60, 320), Matrix.Identity, Vector3.One); ///Forward Shader (look at this shader construction for more info) DynEnvMaterial DynEnvMaterial = new PloobsProjectTemplate.TemplateScreens.DynEnvMaterial(); ///The object itself IObject obj = new IObject(DynEnvMaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); } Texture2D t = factory.CreateTexture2DColor(1, 1, Color.Red); for (int i = 0; i < 10; i++) { for (int j = 0; j < 5; j++) { SimpleModel simpleModel = new SimpleModel(factory, "Model/block"); simpleModel.SetTexture(t); ///Physic info (position, rotation and scale are set here) BoxObject tmesh = new BoxObject(new Vector3(j * 10 + 200, 100, i * 10 + 200), 1, 1, 1, 10, Vector3.One * 2, Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); tmesh.isMotionLess = true; ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Forward material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); } } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { { simpleModel = new FullAnimatedModel(factory, "Model//tank"); GhostObject tmesh = new GhostObject(); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); Model tankModel = simpleModel.model; // Look up shortcut references to the bones we are going to animate. leftBackWheelBone = tankModel.Bones["l_back_wheel_geo"]; rightBackWheelBone = tankModel.Bones["r_back_wheel_geo"]; leftFrontWheelBone = tankModel.Bones["l_front_wheel_geo"]; rightFrontWheelBone = tankModel.Bones["r_front_wheel_geo"]; leftSteerBone = tankModel.Bones["l_steer_geo"]; rightSteerBone = tankModel.Bones["r_steer_geo"]; turretBone = tankModel.Bones["turret_geo"]; cannonBone = tankModel.Bones["canon_geo"]; hatchBone = tankModel.Bones["hatch_geo"]; // Store the original transform matrix for each animating bone. leftBackWheelTransform = leftBackWheelBone.Transform; rightBackWheelTransform = rightBackWheelBone.Transform; leftFrontWheelTransform = leftFrontWheelBone.Transform; rightFrontWheelTransform = rightFrontWheelBone.Transform; leftSteerTransform = leftSteerBone.Transform; rightSteerTransform = rightSteerBone.Transform; turretTransform = turretBone.Transform; cannonTransform = cannonBone.Transform; hatchTransform = hatchBone.Transform; // Allocate the transform matrix array. boneTransforms = new Matrix[tankModel.Bones.Count]; } #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(40), MathHelper.ToRadians(-15), new Vector3(500, 500, 500), GraphicInfo); cam.MoveSpeed *= 5; this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager) { base.LoadContent(GraphicInfo,factory, contentManager); 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); //{ // List<Vector3> poss = new List<Vector3>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // poss.Add(new Vector3(x, 5, y)); // } // } // StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss); // DeferredCilindricGPUBilboardShader cb = new DeferredCilindricGPUBilboardShader(); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} //{ // List<Vector3> poss = new List<Vector3>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // poss.Add(new Vector3(x, 5, y)); // } // } // StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree", poss); // DeferredSphericalBilboardShader cb = new DeferredSphericalBilboardShader(); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} // { // List<Vector3> poss = new List<Vector3>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // poss.Add(new Vector3(x, 5, y)); // } // } // StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "Textures\\grama1", poss); // DeferredProceduralAnimatedcilindricBilboardShader cb = new DeferredProceduralAnimatedcilindricBilboardShader(); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} { List<Vector3> poss = new List<Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 100; y = j * 100; poss.Add(new Vector3(x, 5, y)); } } StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "Textures\\wizard", poss); DeferredAnimatedTextureShader cb = new DeferredAnimatedTextureShader(3, 100, BilboardType.Cilindric); cb.Amplitude = 0f; cb.Scale = new Vector2(50, 50); cb.Atenuation = new Vector4(0.4f, 0.4f, 0.4f, 1); DeferredMaterial matfor = new DeferredMaterial(cb); GhostObject go = new GhostObject(new Vector3(0, 10, 0), Matrix.Identity, Vector3.One); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } //{ // List<BilboardInstance> poss = new List<BilboardInstance>(); // for (int i = 0; i < 10; i++) // { // for (int j = 0; j < 10; j++) // { // float x, y; // x = i * 100; // y = j * 100; // BilboardInstance bi = new BilboardInstance(); // bi.Scale = new Vector2(100, 100); // bi.Position = new Vector3(x, 5, y); // poss.Add(bi); // } // } // InstancedBilboardModel bm = new InstancedBilboardModel(factory, "Bilbs", "..\\Content\\Textures\\tree",poss.ToArray()); // DeferredInstancedBilboardShader cb = new DeferredInstancedBilboardShader(BilboardType.Cilindric); // DeferredMaterial matfor = new DeferredMaterial(cb); // GhostObject go = new GhostObject(); // IObject obj2 = new IObject(matfor, bm, go); // this.World.AddObject(obj2); //} #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.World.CameraManager.AddCamera(new CameraFirstPerson(true,GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); 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(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///must be called before all base.LoadContent(GraphicInfo, factory, contentManager); { ///Create a simple object ///Geomtric Info and textures (this model automaticaly loads the texture) SimpleModel simpleModel = new SimpleModel(factory, "model/dude"); //simpleModel.SetTexture(factory.CreateTexture2DColor(1,1,Color.Red), TextureType.DIFFUSE); ///Physic info (position, rotation and scale are set here) GhostObject pi = new GhostObject(new Vector3(200, 10, 0), Matrix.Identity, new Vector3(4)); ///Shader info (must be a deferred type) DeferredNormalShader shader = new DeferredNormalShader(); shader.ShaderId = ShaderUtils.CreateBitField(false,false,false,false,true); ///Material info (must be a deferred type also) DeferredMaterial fmaterial = new DeferredMaterial(shader); fmaterial.IsVisible = false; ///The object itself IObject obj = new IObject(fmaterial, simpleModel, pi); ///Add to the world this.World.AddObject(obj); StealthPostEffect StealthPostEffect = new StealthPostEffect(); StealthPostEffect.objs.Add(obj); this.RenderTechnic.AddPostEffect(StealthPostEffect); } { ///Create a simple object ///Geomtric Info and textures (this model automaticaly loads the texture) SimpleModel simpleModel = new SimpleModel(factory, "model/cenario"); ///Physic info (position, rotation and scale are set here) TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ///Shader info (must be a deferred type) DeferredNormalShader shader = new DeferredNormalShader(); ///Material info (must be a deferred type also) DeferredMaterial fmaterial = new DeferredMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); } ///Add some directional lights to completely iluminate the world #region Lights 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.4f; 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 ///Add a AA post effect //this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); 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); 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); { List<Vector3> poss = new List<Vector3>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { float x, y; x = i * 15; y = j * 15; poss.Add(new Vector3(x, 5, y)); } } ///The Bilboard Model StaticBilboardModel bm = new StaticBilboardModel(factory, "Bilbs", "Textures\\grama2", poss); ///The Procedural Animated BilboardShader DeferredProceduralAnimatedcilindricBilboardShader cb = new DeferredProceduralAnimatedcilindricBilboardShader(); ///You can change parameters like Amplitude and Speed to control the movement cb.MovimentSpeedControl = 1000; DeferredMaterial matfor = new DeferredMaterial(cb); GhostObject go = new GhostObject(); go.Position = new Vector3(70, 0, 0); IObject obj2 = new IObject(matfor, bm, go); this.World.AddObject(obj2); } #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(-40), MathHelper.ToRadians(-5), new Vector3(-50, 50, 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); ///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); RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc); path.AddCircularObstacle(Vector3.Zero, 10); path.AddCircularObstacle(new Vector3(0,20,0), 15); path.AddCircularObstacle(new Vector3(200), 10); foreach (var item in path.Obstacles) { SphericalObstacle SphericalObstacle = item as SphericalObstacle; DebugSphere s = new DebugSphere(SphericalObstacle.Center, SphericalObstacle.Radius,Color.Blue); ddrawer.AddShape(s); } //DebugSphere.WireFrameEnabled = true; DebugLines dls = new DebugLines(); ddrawer.AddShape(dls); for (int i = 0; i < path.PolyPath.pointCount - 1; i++) { dls.AddLine(path.PolyPath.points[i], path.PolyPath.points[i ] + Vector3.Up * 200, Color.Brown); dls.AddLine(path.PolyPath.points[i], path.PolyPath.points[i + 1], Color.Red); } dls.AddLine(path.PolyPath.points[path.PolyPath.pointCount - 1], path.PolyPath.points[path.PolyPath.pointCount - 1] + Vector3.Up * 200, Color.Brown); PlugIn = new PedestrianPlugIn(this.World, path, (pd) => { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE); ///Physic info (position, rotation and scale are set here) GhostObject tmesh = new GhostObject(); ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Deferred material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); obj.IObjectAttachment.Add(new SteerAtachment(pd)); return obj; }); PlugIn.Init(); { SimpleModel simpleModel = new SimpleModel(factory, "Model//block"); simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); ///Physic info (position, rotation and scale are set here) BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); tmesh.isMotionLess = true; ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Deferred material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself this.World.AddObject(new IObject(fmaterial, simpleModel, tmesh)); } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { ///Must be called before everything in the LoadContent base.LoadContent(GraphicInfo, factory, contentManager); ///Create a Simple Model IModelo sm = new SimpleModel(factory,"..\\Content\\Model\\cenario"); ///Create a Physic Object IPhysicObject pi = new TriangleMeshObject(sm, Vector3.Zero,Matrix.Identity,Vector3.One,MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; ///Create a shader IShader shader = new DeferredNormalShader(); ///Create a Material IMaterial mat = new DeferredMaterial(shader); ///Create a an Object that englobs everything and add it to the world IObject obj4 = new IObject(mat, sm,pi); this.World.AddObject(obj4); ///Create the Physic Objects { for (int i = 0; i < 15; i++) { CreateThrash(new Vector3(-70 + i * 5, 50, 10)); } for (int i = 0; i < 15; i++) { CreateBox(new Vector3(-70 + i * 7, 100, 50)); } for (int i = 0; i < 15; i++) { CreateThrash(new Vector3(-70 + i * 5, 80, 50)); } for (int i = 0; i < 15; i++) { CreateBall(new Vector3(-70 + i * 5, 50, 30)); } for (int i = 0; i < 15; i++) { CreateBox(new Vector3(-70 + i * 7, 130, -20)); } for (int i = 0; i < 15; i++) { CreateBox(new Vector3(-70 + i * 7, 60, -50)); } ///Create A Ghost Object (Do Not Collide) { ///Create a Simple Model SimpleModel model = new SimpleModel(factory, "..\\Content\\Model\\ball"); model.SetTexture(factory.CreateTexture2DColor(1,1,Color.Purple), TextureType.DIFFUSE); ///Create a Physic Object IPhysicObject pobj = new GhostObject(new Vector3(50, 13f, 50), Matrix.Identity, Vector3.One * 5); pobj.isMotionLess = true; ///Create a shader IShader nd = new DeferredNormalShader(); ///Create a Material IMaterial material = new DeferredMaterial(shader); ///Create a an Object that englobs everything and add it to the world IObject obj = new IObject(material, model, pobj); this.World.AddObject(obj); } } ///Call the function releaseObjects when Space key is pressed InputPlayableKeyBoard ip1 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Space, releaseObjects); ///Using the Global Method, need to release when screen is cleaned ///Check the KeyboardInputScreen for how to use it locally mm = new BindKeyCommand(ip1, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(mm); ///Create a FirstPerson Camera ///This is a special camera, used in the development ///You can move around using wasd / qz / and the mouse CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); this.World.CameraManager.AddCamera(cam); ///Create some directionals lights and add to the world DirectionalLightPE ld = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Down, Color.White); ld.LightIntensity = 0.5f; ld2.LightIntensity = 0.5f; ld3.LightIntensity = 0.5f; this.World.AddLight(ld); this.World.AddLight(ld2); this.World.AddLight(ld3); lightThrow = new LightThrowBepu(this.World,factory); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); OceanModel wm = new OceanModel(factory, "WaterModel", Vector3.Zero, 256, 256); GhostObject go = new GhostObject(new Vector3(-300,0,-300), Matrix.Identity, Vector3.One * 2); waterShader = new DeferredWaterShader("Textures/cubemap"); waterShader.SetDefault(); DeferredMaterial wmaterial = new DeferredMaterial(waterShader); IObject obj = new IObject(wmaterial, wm, go); 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.4f; 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(-120), MathHelper.ToRadians(-5), new Vector3(-70, 70, 90), GraphicInfo); this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }