/// <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); }
/// <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 ///Model with Paralax Shader enabled { ///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.SetTexture("Textures\\height_map", TextureType.PARALAX); BoxObject pi = new BoxObject(new Vector3(200, 110, 0), 1, 1, 1, 5, new Vector3(100, 100, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial()); ///Enable paralax and Normal Mapping; paralax = new DeferredCustomShader(false, false, false, false); paralax.SpecularIntensity = 0.2f; paralax.SpecularPower = 30; IMaterial mat = new DeferredMaterial(paralax); 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); { SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, Keys.H, aumentaScale); this.BindInput(ik); } { SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, Keys.G, diminuiScale); this.BindInput(ik); } { SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, Keys.Y, aumentaBias); this.BindInput(ik); } { SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, Keys.T, diminuiBias); this.BindInput(ik); } { SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.J, EnableDisableParalax); this.BindInput(ik); } { SimpleConcreteKeyboardInputPlayable ik = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.K, EnableDisableBump); this.BindInput(ik); } new LightThrowBepu(this.World, GraphicFactory); }
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 }; }