public void Render(IRenderArgs args) { var blendState = args.GraphicsDevice.BlendState; args.GraphicsDevice.BlendState = BlendState.AlphaBlend; long vertexCount = 0; int renderCount = 0; var entities = _rendered.ToArray(); foreach (var entity in entities) { // entity.IsRendered = true; entity.Render(args); vertexCount += entity.RenderedVertices; renderCount++; } EntitiesRendered = renderCount; VertexCount = vertexCount; args.GraphicsDevice.BlendState = blendState; }
public static void RenderText(this IRenderArgs renderArgs, Vector3 vector, string text) { Vector2 textPosition; // calculate screenspace of text3d space position var screenSpace = renderArgs.GraphicsDevice.Viewport.Project(Vector3.Zero, renderArgs.Camera.ProjectionMatrix, renderArgs.Camera.ViewMatrix, Matrix.CreateTranslation(vector)); // get 2D position from screenspace vector textPosition.X = screenSpace.X; textPosition.Y = screenSpace.Y; float s = 1f; var scale = new Vector2(s, s); string clean = text; var stringCenter = Alex.Font.MeasureString(clean, s); var c = new Point((int)stringCenter.X, (int)stringCenter.Y); textPosition.X = (int)(textPosition.X - c.X); textPosition.Y = (int)(textPosition.Y - c.Y); renderArgs.SpriteBatch.FillRectangle(new Rectangle(textPosition.ToPoint(), c), new Color(Color.Black, 128)); renderArgs.SpriteBatch.DrawString(Alex.Font, clean, textPosition, TextColor.White, FontStyle.None, 0f, Vector2.Zero, scale); }
public void Render(IRenderArgs args) { Graphics.DepthStencilState = DepthStencilState.Default; Graphics.SamplerStates[0] = SamplerState.PointWrap; if (UseDepthMap) { ChunkManager.Draw(args, true); } SkyRenderer.Draw(args); ChunkManager.Draw(args, false, RenderStage.OpaqueFullCube, RenderStage.Opaque); EntityManager.Render(args); ChunkManager.Draw(args, false, RenderStage.Transparent, RenderStage.Translucent, RenderStage.Animated, RenderStage.AnimatedTranslucent, RenderStage.Liquid); //TestItemRender.Render(args.GraphicsDevice, (Camera.Position + (Camera.Direction * 2.5f))); //Player.Camera = Camera; Player.Render(args); }
public void Render(IRenderArgs args) { long vertexCount = 0; int renderCount = 0; var entities = Entities.Values.ToArray(); List <Entity> rendered = new List <Entity>(); foreach (var entity in entities) { var entityBox = entity.GetBoundingBox(); if (args.Camera.BoundingFrustum.Contains(new Microsoft.Xna.Framework.BoundingBox(entityBox.Min, entityBox.Max)) != ContainmentType.Disjoint) { entity.Render(args); vertexCount += entity.RenderedVertices; rendered.Add(entity); renderCount++; } } _rendered = rendered.ToArray(); EntitiesRendered = renderCount; VertexCount = vertexCount; }
public void Render(IRenderArgs args) { Graphics.DepthStencilState = DepthStencilState.Default; Graphics.SamplerStates[0] = SamplerState.PointWrap; if (UseDepthMap) { ChunkManager.Draw(args, true); } SkyRenderer.Draw(args); ChunkManager.Draw(args, false); EntityManager.Render(args); //TestItemRender.Render(args.GraphicsDevice, (Camera.Position + (Camera.Direction * 2.5f))); if (Camera is ThirdPersonCamera) { Player.RenderEntity = true; } else { Player.RenderEntity = false; } Player.Camera = Camera; Player.Render(args); }
public void Render2D(IRenderArgs args) { if (_rendered != null) { var entities = _rendered; if (entities.Length == 0) { return; } args.SpriteBatch.Begin( SpriteSortMode.BackToFront, BlendState.NonPremultiplied, SamplerState.PointWrap, DepthStencilState.DepthRead, RasterizerState); try { foreach (var entity in entities) { if (!entity.HideNameTag) { entity.RenderNametag(args); } } } finally { args.SpriteBatch.End(); } } }
public void Render(IRenderArgs args) { if (_destroyed) { return; } args.GraphicsDevice.DepthStencilState = DepthStencilState.Default; args.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; SkyBox.Draw(args); ChunkManager.Draw(args, RenderStage.OpaqueFullCube, RenderStage.Opaque); EntityManager.Render(args); ChunkManager.Draw(args, RenderStage.Transparent, RenderStage.Translucent, RenderStage.Animated, RenderStage.Liquid); Player.Render(args); }
public void Render(IRenderArgs args, bool mock, out int vertices) { vertices = 0; var buffer = Buffer; var effect = Effect; if (!(buffer == null || effect == null || effect.Texture == null || effect.IsDisposed || buffer.MarkedForDisposal)) { if (buffer.IndexCount == 0) { Log.Warn($"Bone indexcount = 0 || {Definition.Name}"); } args.GraphicsDevice.Indices = buffer; effect.View = args.Camera.ViewMatrix; effect.Projection = args.Camera.ProjectionMatrix; if (!mock && buffer.IndexCount > 0) { if (effect.CurrentTechnique != null && !Definition.NeverRender) { // foreach (var technique in effect.Techniques) { foreach (var pass in effect.CurrentTechnique.Passes) { pass?.Apply(); args.GraphicsDevice.DrawIndexedPrimitives( PrimitiveType.TriangleList, 0, 0, buffer.IndexCount / 3); } } } //else { // Log.Warn($"Current"); } vertices += buffer.IndexCount / 3; } else if (!mock && buffer.IndexCount == 0) { Log.Warn($"Index count = 0"); } } var children = Children.ToArray(); if (children.Length > 0) { foreach (var child in children) { child.Render(args, mock, out int childVertices); vertices += childVertices; } } }
protected override void OnLoad(IRenderArgs args) { Alex.InGame = true; World.SpawnPoint = WorldProvider.GetSpawnPoint(); World.Camera.MoveTo(World.GetSpawnPoint(), Vector3.Zero); base.OnLoad(args); }
public void Draw(IRenderArgs args, params RenderStage[] stages) { using (GraphicsContext gc = GraphicsContext.CreateContext( args.GraphicsDevice, Block.FancyGraphics ? BlendState.AlphaBlend : BlendState.Opaque, DepthStencilState, _rasterizerState, _renderSampler)) { DrawStaged(args, null, stages.Length > 0 ? stages : RenderStages); } }
public void Draw(IRenderArgs args) { OnDraw(args); //if (Gui != null) //{ // Gui.Draw(Alex.GuiManager.GuiSpriteBatch, args.GameTime); //} }
public override void Render(IRenderArgs renderArgs) { if (!CanRender) { return; } ItemRenderer?.Render(renderArgs); }
public void Render2D(IRenderArgs args) { if (_destroyed) { return; } EntityManager.Render2D(args); }
public void Render(IRenderArgs renderArgs) { if (RenderEntity) { ModelRenderer.Render(renderArgs, KnownPosition); } if (ShowItemInHand) { ItemRenderer?.Render(renderArgs.GraphicsDevice); } }
protected override void OnDraw(IRenderArgs args) { if (!_skyBox.Loaded) { _skyBox.Load(Alex.GuiRenderer); } _skyBox.Draw(args); base.OnDraw(args); }
private void DrawClouds(IRenderArgs renderArgs, Vector3 position) { // Clouds //CloudsPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3(); renderArgs.GraphicsDevice.SetVertexBuffer(CloudsPlane); foreach (var pass in CloudsPlaneEffect.CurrentTechnique.Passes) { pass.Apply(); renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); } }
protected override void OnDraw(IRenderArgs args) { if (!_backgroundSkyBox.Loaded) { _backgroundSkyBox.Load(Alex.GuiRenderer); } _backgroundSkyBox.Draw(args); base.OnDraw(args); FpsMonitor.Update(); }
protected override void OnDraw(IRenderArgs args) { args.Camera = World.Camera; SkyRenderer.Draw(args); World.Render(args); base.OnDraw(args); Draw2D(args); }
public void Draw(IRenderArgs args) { var device = args.GraphicsDevice; var camera = args.Camera; RasterizerState originalState = null; bool usingWireFrames = UseWireFrames; if (usingWireFrames) { originalState = device.RasterizerState; RasterizerState rasterizerState = new RasterizerState(); rasterizerState.FillMode = FillMode.WireFrame; device.RasterizerState = rasterizerState; } device.DepthStencilState = DepthStencilState.Default; device.BlendState = BlendState.AlphaBlend; TransparentEffect.View = camera.ViewMatrix; TransparentEffect.Projection = camera.ProjectionMatrix; AnimatedEffect.View = camera.ViewMatrix; AnimatedEffect.Projection = camera.ProjectionMatrix; OpaqueEffect.View = camera.ViewMatrix; OpaqueEffect.Projection = camera.ProjectionMatrix; var tempVertices = 0; int tempChunks = 0; var indexBufferSize = 0; ChunkData[] chunks = _renderedChunks.ToArray(); tempVertices += DrawChunks(device, chunks, OpaqueEffect, false, false); DrawChunks(device, chunks, AnimatedEffect, false, true); DrawChunks(device, chunks, TransparentEffect, true, false); if (usingWireFrames) { device.RasterizerState = originalState; } tempChunks = chunks.Count(x => x != null && ( x.SolidIndexBuffer.IndexCount > 0 || x.TransparentIndexBuffer.IndexCount > 0)); Vertices = tempVertices; RenderedChunks = tempChunks; IndexBufferSize = indexBufferSize; }
public void Load(IRenderArgs args) { if (IsLoaded) { return; } IsLoaded = true; OnLoad(args); //Init(Alex.GuiManager.GuiRenderer); InvalidateLayout(); }
private void DrawClouds(IRenderArgs renderArgs, Vector3 position) { // Clouds CloudsPlaneEffect.Texture = CloudTexture; CloudsPlaneEffect.World = Matrix.CreateTranslation(position.X, 127, position.Z); //CloudsPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3(); renderArgs.GraphicsDevice.SetVertexBuffer(CloudsPlane); foreach (var pass in CloudsPlaneEffect.CurrentTechnique.Passes) { pass.Apply(); } renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); }
private void DrawVoid(IRenderArgs renderArgs, Vector3 position) { // Void renderArgs.GraphicsDevice.SetVertexBuffer(SkyPlane); SkyPlaneEffect.World = Matrix.CreateTranslation(0, -16, 0) * Matrix.CreateTranslation(position); SkyPlaneEffect.AmbientLightColor = VoidColor.ToVector3(); foreach (var pass in SkyPlaneEffect.CurrentTechnique.Passes) { pass.Apply(); renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, SkyPlane.VertexCount); } }
private void DrawMoon(IRenderArgs renderArgs, Vector3 position) { // Moon CelestialPlaneEffect.Texture = MoonTexture; CelestialPlaneEffect.World = Matrix.CreateTranslation(0, -100, 0) * Matrix.CreateRotationX(MathHelper.TwoPi * CelestialAngle) * Matrix.CreateTranslation(position); renderArgs.GraphicsDevice.SetVertexBuffer(MoonPlane); foreach (var pass in CelestialPlaneEffect.CurrentTechnique.Passes) { pass.Apply(); renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, MoonPlane.VertexCount); } }
protected void Draw2D(IRenderArgs args) { try { args.SpriteBatch.Begin(); if (_raytracedBlock.Y > 0 && _raytracedBlock.Y < 256) { args.SpriteBatch.RenderBoundingBox( RayTraceBoundingBox, World.Camera.ViewMatrix, World.Camera.ProjectionMatrix, Color.LightGray); } if (RenderBoundingBoxes) { var hitEntity = World.Player?.HitEntity; var entities = World.Player?.EntitiesInRange; if (entities != null) { foreach (var entity in entities) { args.SpriteBatch.RenderBoundingBox(entity.GetBoundingBox(), World.Camera.ViewMatrix, World.Camera.ProjectionMatrix, entity == hitEntity ? Color.Red : Color.Yellow); } } if (World?.Player != null) { args.SpriteBatch.RenderBoundingBox(World.Player.GetBoundingBox(), World.Camera.ViewMatrix, World.Camera.ProjectionMatrix, Color.Red); } if (World.PhysicsEngine.LastKnownHit != null) { foreach (var bb in World.PhysicsEngine.LastKnownHit) { args.SpriteBatch.RenderBoundingBox(bb, World.Camera.ViewMatrix, World.Camera.ProjectionMatrix, Color.YellowGreen); } } } World.Render2D(args); } finally { args.SpriteBatch.End(); } }
private void DrawVoid(IRenderArgs renderArgs, Vector3 position) { // Void renderArgs.GraphicsDevice.SetVertexBuffer(SkyPlane); SkyPlaneEffect.World = Matrix.CreateTranslation(0, -4, 0) * Matrix.CreateTranslation(position); SkyPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3() * new Vector3(0.2f, 0.2f, 0.6f) + new Vector3(0.04f, 0.04f, 0.1f); foreach (var pass in SkyPlaneEffect.CurrentTechnique.Passes) { pass.Apply(); } renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); }
protected override void OnDraw(IRenderArgs args) { args.Camera = World.Camera; if (RenderMinimap) { MiniMap.Draw(args); } World.Render(args); base.OnDraw(args); Draw2D(args); }
public void Load(IRenderArgs args) { if (IsLoaded) { return; } IsLoaded = true; OnLoad(args); if (Gui != null) { Gui.InvalidateLayout(true); } }
private void DrawClouds(IRenderArgs renderArgs, Vector3 position) { // Clouds // CloudsPlaneEffect. // CloudsPlaneEffect.DiffuseColor = WorldSkyColor.ToVector3(); CloudsPlaneEffect.FogColor = AtmosphereColor.ToVector3(); CloudsPlaneEffect.World = Matrix.CreateTranslation(0, 16, 0) * Matrix.CreateTranslation(position); renderArgs.GraphicsDevice.SetVertexBuffer(CloudsPlane); foreach (var pass in CloudsPlaneEffect.CurrentTechnique.Passes) { pass.Apply(); renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); } }
private void DrawSky(IRenderArgs renderArgs, Vector3 position) { // Sky SkyPlaneEffect.FogColor = AtmosphereColor.ToVector3(); SkyPlaneEffect.World = Matrix.CreateRotationX(MathHelper.Pi) * Matrix.CreateTranslation(0, 100, 0) * Matrix.CreateRotationX(MathHelper.TwoPi * CelestialAngle) * Matrix.CreateTranslation(position); SkyPlaneEffect.AmbientLightColor = WorldSkyColor.ToVector3(); renderArgs.GraphicsDevice.SetVertexBuffer(SkyPlane); foreach (var pass in SkyPlaneEffect.CurrentTechnique.Passes) { pass.Apply(); } renderArgs.GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 2); }
protected override void OnLoad(IRenderArgs args) { Alex.InGame = true; World.SpawnPoint = WorldProvider.GetSpawnPoint(); World.Camera.MoveTo(World.GetSpawnPoint(), Vector3.Zero); /*RichPresenceProvider.SetPresence(new RichPresence() * { * State = "Multiplayer", * Timestamps = Timestamps.Now, * Details = $"Playing on a {WorldProvider} server.", * Assets = RichPresenceProvider.GetDefaultAssets() * }); */ base.OnLoad(args); }