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); } } { SimpleModel sm2 = new SimpleModel(factory, "Model\\ball"); sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red, false), TextureType.DIFFUSE); DeferredNormalShader nd = new DeferredNormalShader(); IMaterial m = new DeferredMaterial(nd); SphereObject pi2 = new SphereObject(new Vector3(100, 50, 0), 1, 10, 10, MaterialDescription.DefaultBepuMaterial()); IObject o = new IObject(m, sm2, pi2); this.World.AddObject(o); sound2 = new ObjectFollower3DSound(factory, "Songs/pianosong", o); this.World.AddSoundEmitter(sound2, true); } 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(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); }
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); }
/// <summary> /// Create a simple Sphere object /// </summary> /// <param name="pos"></param> /// <param name="ori"></param> /// <returns></returns> private IObject SpawnPrimitive(Vector3 pos, Matrix ori) { ///Load a Model with a custom texture sm2 = new SimpleModel(factory, "Model\\ball"); sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White, false), TextureType.DIFFUSE); IMaterial m; if (forward) { ForwardXNABasicShader nd = new ForwardXNABasicShader(); m = new ForwardMaterial(nd); } else { DeferredNormalShader nd = new DeferredNormalShader(); m = new DeferredMaterial(nd); } PhysxPhysicWorld PhysxPhysicWorld = _mundo.PhysicWorld as PhysxPhysicWorld; ///First we create a shape description SphereShapeDescription SphereGeometry = new SphereShapeDescription(ballSize); ///then we create the physic object PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry, 0.5f, Matrix.CreateTranslation(pos), Vector3.One * ballSize); IObject o = new IObject(m, sm2, PhysxPhysicObject); return(o); }
/// <summary> /// Called when an object is found /// </summary> /// <param name="world">The world.</param> /// <param name="factory">The factory.</param> /// <param name="ginfo">The ginfo.</param> /// <param name="mi">The mi.</param> /// <returns></returns> IObject[] wl_OnCreateIObject(IWorld world, GraphicFactory factory, GraphicInfo ginfo, ObjectInformation[] mi) { IObject[] objs = new IObject[mi.Length]; for (int i = 0; i < mi.Length; i++) { IModelo model = new CustomModel(factory, mi[i].modelName, mi[i].batchInformation, mi[i].textureInformation); IPhysicObject po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredCustomShader shader = new DeferredCustomShader(mi[i].HasTexture(TextureType.GLOW), mi[i].HasTexture(TextureType.BUMP), mi[i].HasTexture(TextureType.SPECULAR), mi[i].HasTexture(TextureType.PARALAX)); DeferredMaterial dm = new DeferredMaterial(shader); IObject obj = new IObject(dm, model, po); if (mi[i].HasTexture(TextureType.BUMP)) { withBump.Add(obj); } if (mi[i].HasTexture(TextureType.SPECULAR)) { shader.SpecularPowerMapScale = 2f; shader.SpecularIntensityMapScale = 0.1f; withSpecular.Add(obj); } objs[i] = obj; } return(objs); }
/// <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); #region Models { ///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); } { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredCustomShader shader = new DeferredCustomShader(false, false, false, false); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } #endregion #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(10), MathHelper.ToRadians(-10), new Vector3(200, 150, 250), GraphicInfo); this.World.CameraManager.AddCamera(cam); new LightThrowBepu(this.World, GraphicFactory); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f); marine = new IObject(mat, sm, character.Characterobj); 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); }
/// <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); RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc); ddrawer.AddShape(new DebugBox(new BoundingBox(new Vector3(-50), new Vector3(50)), Color.Red)); DebugLine dl = new DebugLine(Vector3.Zero, new Vector3(1000, 1000, 1000), Color.Red); ddrawer.AddShape(dl); DebugLines dls = new DebugLines(); ddrawer.AddShape(dls); dls.AddLine(Vector3.Zero, new Vector3(-1000, 1000, -1000), Color.Green); dls.AddLine(Vector3.Zero, new Vector3(-1000, 1000, 1000), Color.Pink); 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); ///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); //SnowParticleSystem snow = new SnowParticleSystem(); //DPFSParticleSystem ps = new DPFSParticleSystem("snow",snow ); //this.World.ParticleManager.AddAndInitializeParticleSystem(ps); /////cant set emiter position before adding the particle //snow.Emitter.PositionData.Position = new Vector3(1000, 0, 0); SmokeParticleSystem smoke = new SmokeParticleSystem(); DPFSParticleSystem ps = new DPFSParticleSystem("smoke", smoke); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); smoke.Emitter.PositionData.Position = new Vector3(1000, 0, 0); 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 this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); //this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectTabula()); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectStalker()); }
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); } { SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block"); sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE); BoxObject pi = new BoxObject(new Vector3(100, 40, 0), 1, 1, 1, 25, new Vector3(100, 10, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, sm, pi); this.World.AddObject(obj3); } #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 //SBlurPost hsv = new SBlurPost(1, SurfaceFormat.HdrBlendable); //hsv.ImageSamplerState = SamplerState.PointClamp; //this.RenderTechnic.AddPostEffect(hsv); DownSamplePostEffect DownSamplePostEffect = new Post.DownSamplePostEffect(); this.RenderTechnic.AddPostEffect(DownSamplePostEffect); CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.MoveSpeed *= 5; this.World.CameraManager.AddCamera(cam); LightThrowBepu lt = new LightThrowBepu(this.World, factory); }
/// <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); RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc); ///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); lt = new LightThrowBepu(this.World, factory); ///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)); }
/// <summary> /// Create a simple Sphere object /// </summary> /// <param name="pos"></param> /// <param name="ori"></param> /// <returns></returns> private IObject SpawnPrimitive(Vector3 pos, Matrix ori) { ///Load a Model with a custom texture SimpleModel sm2 = new SimpleModel(factory, "Model\\ball"); sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White, false), TextureType.DIFFUSE); DeferredNormalShader nd = new DeferredNormalShader(); IMaterial m = new DeferredMaterial(nd); SphereObject pi2 = new SphereObject(pos, 1, 0.5f, 1, MaterialDescription.DefaultBepuMaterial()); IObject o = new IObject(m, sm2, pi2); return(o); }
protected IObject CreateBoxMeshModelU(String fileName, Vector3 position, Matrix orientation, float xlengh, float ylengh, float zlengh, Vector3 scale, float mass = 10) { SimpleModel simpleModel = new SimpleModel(graphicFactory, fileName); ///Physic info (position, rotation and scale are set here) BoxObject tmesh = new BoxObject(position, xlengh, ylengh, zlengh, mass, scale, orientation, 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 return(new IObject(fmaterial, simpleModel, tmesh)); }
/// <summary> /// Create a simple Sphere object /// </summary> /// <param name="pos"></param> /// <param name="ori"></param> /// <returns></returns> private ThrowParticlesObject SpawnPrimitive(DefaultSprite3DBillboardParticleSystem particleSystem, Vector3 pos, Matrix ori) { ///Load a Model with a custom texture SimpleModel sm2 = new SimpleModel(scene.GraphicFactory, "Model\\ball"); sm2.SetTexture(scene.GraphicFactory.CreateTexture2DColor(1, 1, Color.White, false), TextureType.DIFFUSE); DeferredNormalShader nd = new DeferredNormalShader(); IMaterial m = new DeferredMaterial(nd); SphereObject pi2 = new SphereObject(pos, 1, 10, 1, MaterialDescription.DefaultBepuMaterial()); ThrowParticlesObject o = new ThrowParticlesObject(particleSystem, m, sm2, pi2); return(o); }
protected IObject CreateTriangleMeshModel(String fileName, Vector3 position, Matrix orientation, Vector3 scale) { SimpleModel simpleModel = new SimpleModel(graphicFactory, fileName); ///Physic info (position, rotation and scale are set here) TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, position, orientation, scale, 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 return(new IObject(fmaterial, simpleModel, tmesh)); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); this.contentManager = 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); //ap = new SoundAudioPlayer(contentManager); //ap.AddSoundToRepository("Songs/bye", "bye"); //se = new SimpleSoundEffect(contentManager, "Songs/alarm"); //LocalMediaAudioPlayer lm = new LocalMediaAudioPlayer(); //AlbumCollection ac = lm.MediaLibrary.Albums; //lm.PlayAlbum(ac[0]); sound = new Static3DSound(factory, "Songs/pianosong", Vector3.Zero); this.World.AddSoundEmitter(sound, true); //ObjectFollower3DSound sound2 = new ObjectFollower3DSound(contentManager, "Songs/pianosong", 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 this.World.CameraManager.AddCamera(new CameraFirstPerson(true, GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); Picking picking = new Picking(this); this.AddScreenUpdateable(picking); perlim = factory.CreateTexture2DPerlinNoise(512, 512, 0.03f, 3f, 0.5f, 1); to = new TerrainObject(factory, perlim, Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 2, 2); //TerrainObject to = new TerrainObject(factory,"..\\Content\\Textures\\Untitled",Vector3.Zero,Matrix.Identity,MaterialDescription.DefaultBepuMaterial(),2,1); TerrainModel stm = new TerrainModel(factory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass", "..\\Content\\Textures\\rock", "..\\Content\\Textures\\sand", "..\\Content\\Textures\\snow"); DeferredTerrainShader shader = new DeferredTerrainShader(TerrainType.MULTITEXTURE); DeferredMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, stm, to); this.World.AddObject(obj3); #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); ///O PICKING FUNCIONA APENAS COM OBJETOS QUE TENHAM CORPO FISICO REAL !!! ///OS GHOST E OS DUMMY NUNCA SERAO SELECIONADOS ///Para ser informado a todo frame sobre as colisoes do raio, basta utilizar o outro construtor picking.OnPickedLeftButton += new OnPicked(onPick); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ///Cenario SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\cenario"); IShader normal = new DeferredNormalShader(); IMaterial mat = new DeferredMaterial(normal); IPhysicObject pi = new TriangleMeshObject(sm, new Vector3(0, 10, 100), Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); pi.isMotionLess = true; IObject obj4 = new IObject(mat, sm, pi); this.World.AddObject(obj4); ///Luzes DirectionalLightPE ld = new DirectionalLightPE(new Vector3(4, -2, 7), Color.White); this.World.AddLight(ld); ///Camera basica ICamera cam = new CameraFirstPerson(GraphicInfo); cam.Name = "stdCam"; this.World.CameraManager.AddCamera(cam); ///Associando callbacks com eventos do teclado { InputPlayableKeyBoard ipp = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.R, Start); bkk0 = new BindKeyCommand(ipp, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk0); InputPlayableKeyBoard ipp2 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.T, Stop); bkk1 = new BindKeyCommand(ipp2, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk1); InputPlayableKeyBoard ipp3 = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Y, Load); bkk2 = new BindKeyCommand(ipp3, BindAction.ADD); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(bkk2); } ///Camera Recorder (objeto q gravara e carregara os caminhos) record = new CameraRecordPath(this, cam); record.FinishInTheStartPosition = true; }
protected IObject CreateSphereMeshModelU(String fileName, Vector3 position, Matrix orientation, float raio, float scale = 1, float mass = 10) { CreateInternalModel(fileName); SimpleModel simpleModel = new SimpleModel(graphicFactory, "Loaded/" + modelLoaded[fileName]); ///Physic info (position, rotation and scale are set here) SphereObject tmesh = new SphereObject(position, raio, mass, scale, 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 return(new IObject(fmaterial, simpleModel, tmesh)); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ///Create the Terrain Object ///Controls how the heigh map is loaded TerrainObject to = new TerrainObject(factory, "..\\Content\\Textures\\Untitled", Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 2, 1); ///Create the Model using the Terrain Object. Here we pass the textures used, in our case we are using MultiTextured Terrain so we pass lots of textures TerrainModel stm = new TerrainModel(factory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass", "..\\Content\\Textures\\rock", "..\\Content\\Textures\\sand", "..\\Content\\Textures\\snow"); ///Create the shader ///In this sample we passed lots of textures, each one describe a level in the terrain, the ground is the sand and grass. the hills are rocks and the "mountains" are snow ///They are interpolated in the shader, you can control how using the shader parameters exposed in the DeferredTerrainShader DeferredTerrainShader shader = new DeferredTerrainShader(TerrainType.MULTITEXTURE); ///the classic material DeferredMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, stm, to); this.World.AddObject(obj3); 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(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); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffectStalker()); }
/// <summary> /// Renders a test where the GBuffer is displayed containing a sphere with provided maps. /// </summary> private void testGBufferSphere(ITexture diffuse, ITexture normal, ITexture specular) { var game = createGame(); var pool = createTexturePool(game); var txDiffuse = diffuse == null ? null : pool.LoadTexture(diffuse); var txNormal = normal == null ? null : pool.LoadTexture(normal); var txSpecular = specular == null ? null : pool.LoadTexture(specular); var mat = new DeferredMaterial(game, txDiffuse, txNormal, txSpecular); var part = RenderingTestsHelper.CreateSphereMeshPart(); var fact = new MeshRenderDataFactory(game, null, null); var partData = fact.CreateMeshPartData(part); var buffer = createGBuffer(game); var perObject = DeferredMaterial.CreatePerObjectCB(game); var ctx = game.Device.ImmediateContext; perObject.UpdatePerObjectBuffer(ctx, Matrix.Identity); var scene = new RenderingTestsHelper.SimpleLightedScene(game, buffer); game.GameLoopEvent += delegate { ctx.ClearState(); buffer.Clear(); buffer.SetTargetsToOutputMerger(); mat.SetCamera(game.Camera.View, game.Camera.Projection); mat.SetToContext(ctx); mat.SetPerObjectBuffer(ctx, perObject); partData.Draw(ctx); scene.Render(); }; game.Run(); }
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()); }
protected override void LoadContent(PloobsEngine.Engine.GraphicInfo GraphicInfo, PloobsEngine.Engine.GraphicFactory factory, IContentManager contentManager) { 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); lt = new LightThrowBepu(this.World, factory); ///Create a FirstPerson Camera ///This is a special camera, used in the development ///You can move around using wasd / qz / and the mouse ICamera cam = new CameraFirstPerson(GraphicInfo); this.World.CameraManager.AddCamera(cam); PointLightCircularUpdater lcu = new PointLightCircularUpdater(this); ///Create 100 moving point lights and add to the world ///IF the radius of the point light is TOO big like 250, it will make the game slower for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { PointLightPE pl0 = new PointLightPE(new Vector3(i * 5, 25, j * 5), StaticRandom.RandomColor(), 100, 2); pl0.UsePointLightQuadraticAttenuation = true; lcu.AddLight(pl0, 0.01f, 50 * i, j / StaticRandom.Random()); this.World.AddLight(pl0); } } lcu.Start(); this.RenderTechnic.AddPostEffect(new AntiAliasingPostEffect()); }
public VoxelCustomRenderer(DX11Game game, DeferredRenderer dRenderer, DualContouringMeshBuilder dcMeshBuilder, DualContouringAlgorithm dcAlgo, MeshRenderDataFactory renderDataFactory) { this.game = game; this.dRenderer = dRenderer; this.dcMeshBuilder = dcMeshBuilder; this.dcAlgo = dcAlgo; this.renderDataFactory = renderDataFactory; var tex = new RAMTexture(); defaultMaterial = new DCVoxelMaterial() { Texture = DCFiles.UVCheckerMap11_512 }; objectBuffer = DeferredMaterial.CreatePerObjectCB(game); }
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); }
/// <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); 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); ///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()); lt = new LightThrowBepu(this.World, factory); ///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//cenario"); simpleModel.SetTexture(factory.GetTexture2D("textures/islandmap2"), TextureType.DIFFUSE); 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); this.RenderTechnic.AddPostEffect(new GammaCorrectionPostEffect(GammaType.Normal)); #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//cubeMapGamma"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
private void CreateBox(Vector3 pos) { ///Create a Simple Model SimpleModel model = new SimpleModel(GraphicFactory, "..\\Content\\Model\\cubo"); model.SetTexture(GraphicFactory.CreateTexture2DColor(1, 1, StaticRandom.RandomColor()), TextureType.DIFFUSE); ///Create a Physic Object IPhysicObject pobj = new BoxObject(pos, 1, 1, 1, 10, new Vector3(2), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); pobj.isMotionLess = true; ///Create a shader IShader nd = new DeferredNormalShader(); ///Create a Material IMaterial material = new DeferredMaterial(nd); ///Create a an Object that englobs everything and add it to the world IObject obj = new IObject(material, model, pobj); this.World.AddObject(obj); objects.Add(obj); }
private void CreateThrash(Vector3 pos) { ///Create a Simple Model ///thash Has a Texture Inside the .X file (not the texture itself, just the name of it) ///The simpleModel will find it and will attach to the Object IModelo model = new SimpleModel(GraphicFactory, "..\\Content\\Model\\trash"); ///Create a Physic Object IPhysicObject pobj = new CapsuleObject(pos, 2, 1, 10, Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); pobj.isMotionLess = true; ///Create a shader IShader nd = new DeferredNormalShader(); ///Create a Material IMaterial material = new DeferredMaterial(nd); ///Create a an Object that englobs everything and add it to the world IObject obj = new IObject(material, model, pobj); this.World.AddObject(obj); objects.Add(obj); }
private void button1_Click(object sender, RoutedEventArgs e) { OpenFileDialog OpenFileDialog = new OpenFileDialog(); OpenFileDialog.Filter = "X Files (*.x)|*.x"; OpenFileDialog.ShowDialog(); String fileName = OpenFileDialog.FileName; if (String.IsNullOrEmpty(fileName)) { return; } ContentBuilder.Add(fileName, "Model", null, "ModelProcessor"); String buildError = ContentBuilder.Build(); if (string.IsNullOrEmpty(buildError)) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + "/Content/Loaded"); MakeCopy(ContentBuilder.OutputDirectory, Directory.GetCurrentDirectory() + "/Content/Loaded/"); SimpleModel simpleModel = new SimpleModel(EditorTestScreen.GraphicFactory, "Loaded/Model"); ///Physic info (position, rotation and scale are set here) TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Microsoft.Xna.Framework.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 EditorTestScreen.World.AddObject(obj); } else { // If the build failed, display an error message. MessageBox.Show(buildError, "Error"); } }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); TerrainObject to = new TerrainObject(factory, "..\\Content\\Textures\\Untitled", Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 2, 1); TerrainModel stm = new TerrainModel(factory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass", "..\\Content\\Textures\\rock", "..\\Content\\Textures\\sand", "..\\Content\\Textures\\snow"); DeferredTerrainShader shader = new DeferredTerrainShader(TerrainType.MULTITEXTURE); DeferredMaterial mat = new DeferredMaterial(shader); IObject obj3 = new IObject(mat, stm, to); this.World.AddObject(obj3); 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 this.World.CameraManager.AddCamera(new CameraFirstPerson(true, GraphicInfo)); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//cubemap"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }