/// <summary> /// Initializes this instance. /// </summary> /// <param name="ginfo"></param> /// <param name="factory"></param> /// <param name="obj"></param> public override void Initialize(GraphicInfo ginfo, GraphicFactory factory, IObject obj) { effect = factory.GetAlphaTestEffect(); effect.ReferenceAlpha = alphaToCut; effect.AlphaFunction = CompareFunction; base.Initialize(ginfo, factory, obj); }
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(); ///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); } { SnowParticleSystem snow = new SnowParticleSystem(); DPFSParticleSystem ps = new DPFSParticleSystem("snow", snow); this.World.ParticleManager.AddAndInitializeParticleSystem(ps); ///cant set emiter position before adding the particle ///IF YOU DO SO, IT WILL NOT WORK snow.Emitter.PositionData.Position = new Vector3(500, 0, 0); } CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(-50), MathHelper.ToRadians(-10), new Vector3(-200, 150, 250), GraphicInfo); 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); { 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)); }
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(), 1, 1, 10); ///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"); stm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE); ///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 ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Deferred material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, stm, to); ///Add to the world this.World.AddObject(obj); shader.BasicEffect.EnableDefaultLighting(); CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo.Viewport); this.World.CameraManager.AddCamera(cam); }
public CameraFirstPerson(float lrRot, float udRot, Vector3 startingPos, GraphicInfo graphicInfo) #endif { init(lrRot, udRot, startingPos, graphicInfo); #if WINDOWS_PHONE this.useAcelerometer = useAcelerometer; if (useAcelerometer) { accelSensor = new Microsoft.Devices.Sensors.Accelerometer(); // Start the accelerometer try { accelSensor.Start(); accelActive = true; } catch (Microsoft.Devices.Sensors.AccelerometerFailedException e) { // the accelerometer couldn't be started. No fun! accelActive = false; } catch (UnauthorizedAccessException e) { // This exception is thrown in the emulator-which doesn't support an accelerometer. accelActive = false; } accelSensor.ReadingChanged += new EventHandler <Microsoft.Devices.Sensors.AccelerometerReadingEventArgs>(accelSensor_ReadingChanged); } #endif }
/// <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); LightProbeReader LightProbeReader = new EngineTestes.LightProbeReader(factory.GetTexture2D("Textures\\probe")); Sampler Sampler = new EngineTestes.Sampler(100, 3); MonteCarlo MonteCarlo = new EngineTestes.MonteCarlo(); MonteCarlo.ProjectLight(LightProbeReader, Sampler); { 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); } 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); 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> /// Loads the content. /// </summary> /// <param name="GraphicInfo">The graphic info.</param> internal void LoadContent(ref GraphicInfo GraphicInfo) { foreach (IComponent item in _comps.Values) { item.iLoadContent(GraphicInfo, factory); } }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { ///cast to out world instance PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld; base.LoadContent(GraphicInfo, factory, contentManager); { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); ///Physic Triangle mesh (same as bepu) PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel, Matrix.Identity, Vector3.One); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } ///Ball Throw !!! BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory); this.AttachCleanUpAble(BallThrowBullet); this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
/// <summary> /// Picking in x/y screen coordinates /// </summary> /// <param name="world"></param> /// <param name="info"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="pickingDistance"></param> /// <param name="intercept"></param> /// <returns></returns> public static SegmentInterceptInfo Pick(IWorld world, GraphicInfo info, float x, float y, float pickingDistance = 500, Func <IPhysicObject, bool> intercept = null) { if (intercept == null) { intercept = CullNothing; } Matrix viewInverse = Matrix.Invert(world.CameraManager.ActiveCamera.View); Matrix projectionInverse = Matrix.Invert(world.CameraManager.ActiveCamera.Projection); Matrix viewProjectionInverse = projectionInverse * viewInverse; Vector3 v = new Vector3(); v.X = (((2.0f * x) / info.Viewport.Width) - 1); v.Y = -(((2.0f * y) / info.Viewport.Height) - 1); v.Z = 0.0f; Ray pickRay = new Ray(); pickRay.Position.X = viewInverse.M41; pickRay.Position.Y = viewInverse.M42; pickRay.Position.Z = viewInverse.M43; pickRay.Direction = Vector3.Normalize(Vector3.Transform(v, viewProjectionInverse) - pickRay.Position); return(world.PhysicWorld.SegmentIntersect(pickRay, intercept, pickingDistance)); }
/// <summary> /// Called when an object is found ///Return the object, return null to not add this object /// </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) { ///Do what default would do. IObject[] objs = WorldLoader.CreateOBJ(world, factory, ginfo, mi); ///Change object property here !!! foreach (var obj in objs) { DeferredCustomShader cd = (obj.Material.Shader as DeferredCustomShader); ///the world loader uses deferredCustomShader for all objects System.Diagnostics.Debug.Assert(cd != null); ///if the obj does not use specular map if (!cd.UseSpecular) { ///set a constant specular for all the object cd.SpecularIntensity = 0.3f; cd.SpecularPower = 150; } } ///If you want, create the object on your own, without using the World Loader, ///THIS IS WHAT WorldLoader.CreateOBJ DOES //IModelo model = new CustomModel(factory, mi.modelName, new BatchInformation[] { mi.batchInformation}, mi.difuse, mi.bump, mi.specular, mi.glow); //IPhysicObject po = new TriangleMeshObject(model, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); //IShader shader = new DeferredCustomShader(mi.HasTexture(TextureType.GLOW), mi.HasTexture(TextureType.BUMP), mi.HasTexture(TextureType.SPECULAR), mi.HasTexture(TextureType.PARALAX)); //DeferredMaterial dm = new DeferredMaterial(shader); //return new IObject(dm, model, po); 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); ///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); this.RenderTechnic.AddPostEffect(MotionBlurPostEffect); //this.RenderTechnic.AddPostEffect(new BloomPostEffect()); ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); RasterizerState = new RasterizerState(); RasterizerState.CullMode = CullMode.None; }
public void DrawScene(GameTime gameTime, IWorld world, RenderHelper render, GraphicInfo ginfo, List <IObject> objectsToDraw) { render.ValidateSamplerStates(); Matrix view = world.CameraManager.ActiveCamera.View; Matrix projection = world.CameraManager.ActiveCamera.Projection; if (render.RenderPreComponents(gameTime, ref view, ref projection) > 0) { render.SetSamplerStates(ginfo.SamplerState); } System.Diagnostics.Debug.Assert(render.PeekBlendState() == BlendState.Opaque); System.Diagnostics.Debug.Assert(render.PeekDepthState() == DepthStencilState.Default); System.Diagnostics.Debug.Assert(render.PeekRasterizerState() == RasterizerState.CullCounterClockwise); render.DettachBindedTextures(5); foreach (IObject item in objectsToDraw) { if (item.Material.IsVisible) { item.Material.Drawn(gameTime, item, world.CameraManager.ActiveCamera, world.Lights, render); } } render.ValidateSamplerStates(); }
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); } ConfigWriter cw = new ConfigWriter("teste.properties"); cw.AddKeyValue("teste", "value"); cw.Write(); ConfigReader cr = new ConfigReader("teste.properties"); cr.Read(); String v = cr.ReadValue("teste"); System.Diagnostics.Debug.Assert(v == "value"); this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect()); }
void ginfo_OnGraphicInfoChange(object sender, EventArgs e) { GraphicInfo ginfo = (GraphicInfo)sender; if (postEffectTarget != null) { postEffectTarget.Dispose(); postEffectTargetScene.Dispose(); postEffectTarget = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, ginfo.MultiSample, RenderTargetUsage.DiscardContents); postEffectTargetScene = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, ginfo.MultiSample, RenderTargetUsage.DiscardContents); } #if !WINDOWS_PHONE && !REACH if (UseShadow) { screenShadowsNS.Dispose(); screenShadowsNS = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight); screenShadowsTESTE.Dispose(); screenShadowsTESTE = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight); lalalala.Dispose(); lalalala = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight); } screenShadows.Dispose(); screenShadows = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight); renderTarget.Dispose(); renderTarget = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.Depth24Stencil8, ginfo.MultiSample, RenderTargetUsage.DiscardContents); #endif }
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); } { SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100, 10, 10), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial()); 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)); this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect()); }
internal Cursors(IDataReader dataReader) { var graphicReader = new GraphicReader(); var graphicInfo = new GraphicInfo { Width = 16, Height = 16, Alpha = true, GraphicFormat = GraphicFormat.Palette3Bit, PaletteOffset = 24 }; Graphic ReadGraphic() { var graphic = new Graphic(); graphicReader.ReadGraphic(graphic, dataReader, graphicInfo); return(graphic); } for (int i = 0; i < Count; ++i) { entries.Add(new Cursor { HotspotX = (short)dataReader.ReadWord(), HotspotY = (short)dataReader.ReadWord(), Graphic = ReadGraphic() }); } }
//EffectParameter PcolorMap; //EffectParameter PlightMap; #endregion #region IDeferredFinalCombination Members public void LoadContent(IContentManager manager, Engine.GraphicInfo ginfo, Engine.GraphicFactory factory, bool useFloatBuffer, bool saveToTexture) { this.useFloatBuffer = useFloatBuffer; this.ginfo = ginfo; this.saveToTexture = saveToTexture; finalCombineEffect = manager.GetAsset <Effect>("CombineFinal", true); PhalfPixel = finalCombineEffect.Parameters["halfPixel"]; PambientColor = finalCombineEffect.Parameters["ambientColor"]; //PEXTRA1 = finalCombineEffect.Parameters["EXTRA1"]; //PcolorMap = finalCombineEffect.Parameters["colorMap"]; //PlightMap = finalCombineEffect.Parameters["lightMap"]; PhalfPixel.SetValue(ginfo.HalfPixel); if (saveToTexture) { if (useFloatBuffer) { target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.HdrBlendable, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.DiscardContents); } else { target = factory.CreateRenderTarget(ginfo.BackBufferWidth, ginfo.BackBufferHeight, SurfaceFormat.Color, ginfo.UseMipMap, DepthFormat.None, ginfo.MultiSample, RenderTargetUsage.DiscardContents); } } }
// Second data hunk, right behind UITexts. internal Buttons(IDataReader dataReader) { var graphicInfo = new GraphicInfo { Width = 32, Height = 13, Alpha = true, GraphicFormat = GraphicFormat.Palette3Bit, PaletteOffset = 24 }; var graphicReader = new GraphicReader(); Graphic ReadGraphic(IDataReader dataReader) { var graphic = new Graphic(); graphicReader.ReadGraphic(graphic, dataReader, graphicInfo); return(graphic); } foreach (var buttonType in Enum.GetValues <ButtonType>()) { entries.Add(buttonType, ReadGraphic(dataReader)); } dataReader.AlignToWord(); }
/// <summary> /// Initializes this instance. /// </summary> public virtual void Initialize(GraphicInfo ginfo, GraphicFactory factory, IObject obj) { #if !WINDOWS_PHONE && !REACH basicDraw = factory.GetEffect("clippingPlane", false, true); getDepth = factory.GetEffect("ShadowDepth", false, true); BasicDrawSamplerState = SamplerState.LinearWrap; #endif if (useOcclusionCulling) { if (Modelo == null) { Modelo = new SimpleModel(factory, "block", true); } if (BasicEffect == null) { BasicEffect = factory.GetBasicEffect(); BasicEffect.TextureEnabled = false; BasicEffect.VertexColorEnabled = false; } if (BlendState == null) { BlendState = new Microsoft.Xna.Framework.Graphics.BlendState(); BlendState.ColorWriteChannels = ColorWriteChannels.None; } OcclusionQuery = factory.CreateOcclusionQuery(); OcclusionQuery.Tag = "Begin"; } this.GraphicFactory = factory; isInitialized = true; }
protected override void InitScreen(GraphicInfo GraphicInfo, EngineStuff engine) { base.InitScreen(GraphicInfo, engine); SkyBox = new SkyBox(); engine.AddComponent(SkyBox); }
/// <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) { radio.SendMessage("SYSTEM", "BEGIN LOAD CONTENT " + DateTime.Now); base.LoadContent(GraphicInfo, factory, contentManager); reciever.MessageHandler += new Action <PloobsEngine.MessageSystem.Message>(reciever_MessageHandler); { 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); } ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); radio.SendMessage("SYSTEM", "END LOAD CONTENT " + DateTime.Now); }
/// <summary> /// Init Screen /// </summary> /// <param name="GraphicInfo">The graphic info.</param> /// <param name="engine"></param> protected override void InitScreen(GraphicInfo GraphicInfo, EngineStuff engine) { SetWorldAndRenderTechnich(out _renderTecnic, out _world); if (_renderTecnic == null) { ActiveLogger.LogMessage("IScene must have a renderTechnic", LogLevel.FatalError); #if WINDOWS Debug.Fail("IScene must have a renderTechnic"); #endif throw new Exception("IScene must have a renderTechnic"); } if (_world == null) { ActiveLogger.LogMessage("World cannot be null", LogLevel.FatalError); #if WINDOWS Debug.Fail("World cannot be null"); #endif throw new Exception("World cannot be null"); } this._world.GraphicsFactory = GraphicFactory; this._world.GraphicsInfo = GraphicInfo; this._world.ContentManager = screenManager.contentManager; this._world.iInitWorld(); base.InitScreen(GraphicInfo, engine); }
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); } var newCameraFirstPerson = new CameraStatic(new Vector3(100, 100, 100), -new Vector3(100, 100, 100)); this.World.CameraManager.AddCamera(newCameraFirstPerson); SimpleConcreteGestureInputPlayable SimpleConcreteGestureInputPlayable = new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.DoubleTap, (sample) => doubleTapCount++); this.BindInput(SimpleConcreteGestureInputPlayable); this.BindInput(new SimpleConcreteGestureInputPlayable(Microsoft.Xna.Framework.Input.Touch.GestureType.Hold, (sample) => { this.RemoveInputBinding(SimpleConcreteGestureInputPlayable); doubleTapDisabled = true; } )); }
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); { ///carrega o Modelo AnimatedModel am = new AnimatedModel(factory, "..\\Content\\Model\\PlayerMarine", "..\\Content\\Textures\\PlayerMarineDiffuse"); ///Inicializa o Controlador (Idle eh o nome da animacao inicial) AnimatedController arobo = new AnimatedController(am, "Idle"); ///Cria o shader e o material animados DeferredSimpleAnimationShader sas = new DeferredSimpleAnimationShader(arobo); DeferredAnimatedMaterial amat = new DeferredAnimatedMaterial(arobo, sas); CharacterControllerInput gp = new CharacterControllerInput(this, new Vector3(100, 50, 1), 25, 10, 10, Vector3.One); IObject marine = new IObject(amat, am, gp.Characterobj); ///Adiciona no mundo this.World.AddObject(marine); LightThrowBepu lt = new LightThrowBepu(this.World, factory); } { SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); DeferredNormalShader shader = new DeferredNormalShader(); DeferredMaterial fmaterial = new DeferredMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } #region NormalLight DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White); DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White); DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White); DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White); DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White); float li = 0.5f; ld1.LightIntensity = li; ld2.LightIntensity = li; ld3.LightIntensity = li; ld4.LightIntensity = li; ld5.LightIntensity = li; this.World.AddLight(ld1); this.World.AddLight(ld2); this.World.AddLight(ld3); this.World.AddLight(ld4); this.World.AddLight(ld5); #endregion CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo); cam.MoveSpeed *= 5; this.World.CameraManager.AddCamera(cam); SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube"); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc); }
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); } for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi"); TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(25 * j, 30, 15 * i), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); obj.OnUpdate += new OnUpdate(obj_OnUpdate); this.World.AddObject(obj); } } this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); }
public override void Initialize(GraphicInfo ginfo, GraphicFactory factory, IObject obj) { effect = factory.GetBasicEffect(); base.Initialize(ginfo, factory, obj); effect.PreferPerPixelLighting = true; SetDescription(desc); }
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); } { SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi"); MobileMeshObject tmesh = new MobileMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial(), BEPUphysics.CollisionShapes.MobileMeshSolidity.DoubleSided, 10); //TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100, 100, 10), Matrix.Identity, Vector3.One * 50, MaterialDescription.DefaultBepuMaterial()); ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default()); ForwardMaterial fmaterial = new ForwardMaterial(shader); IObject obj = new IObject(fmaterial, simpleModel, tmesh); this.World.AddObject(obj); } new LightThrowBepu(this.World, factory); 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); ///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(); ///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)); ///task sample taskSample taskSample = new taskSample(); ///when ended, call this (syncronous -- specified in the itask implementation) function taskSample.Ended += new Action <ITask, IAsyncResult>(taskSample_Ended); ///create and send the task to the processor TaskCommand TaskCommand = new TaskCommand(taskSample); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(TaskCommand); }