public virtual void Update() { PreviousPosition = Position; Velocity *= (1.0f - 0.05f); Position += (Velocity * Delta.Time); UpdateAABBPosition(); Chunk = World.GetChunkAt(GridLatch.MTWGetChunk(Position)); }
public static void DrawChunk(PlayerCamera camera, Chunk chunk) { DrawCube( camera, GridLatch.WTMGetChunk(chunk.Location), GridLatch.ChunkScale, 1.0f, 0.1f, 0.1f); }
public static void DrawChunkBlocks(PlayerCamera camera, Chunk chunk) { foreach (KeyValuePair <Block, CubeMesh> pair in WorldMeshMap.GetChunkCubeMeshMap(chunk)) { if (pair.Key.ShouldRender) { BlockObject.Mesh = pair.Value; BlockObject.Texture = TextureMap.GetTextureFromID(pair.Key.ID); BlockObject.Position = GridLatch.WTMGetWorldBlock(chunk.Location, pair.Key.Location); BlockObject.Draw(camera); } } }
public static void DrawBlock(Block block, int x, int y, int z, PlayerCamera camera) { string textureName = TextureMap.GetTextureNameFromID(block.ID); if (textureName == "") { return; } Texture texture = TextureMap.GetTexture(textureName); Cube.Texture = texture; Cube.Position = GridLatch.WTMGetBlock(x, y, z); Cube.Draw(camera); }
public Block(World world, BlockLocation location, int id = 1, bool isTransparent = false) { ShouldRender = true; World = world; Location = location; ID = id; //Hardness = hardness; //Resistance = resistance; IsTransparent = isTransparent; if (location.Chunk != null) { BlockLocation blockLocation = GridLatch.GetBlockOffsetByChunk(location, location.Chunk.Location); BoundingBox = new AxisAlignedBB(blockLocation); } }
public static void DrawChunkCenterOutline(PlayerCamera camera, Chunk chunk, float r = 0.2f, float g = 0.8f, float b = 0.3f) { Vector3 position = GridLatch.WTMGetChunk(chunk.Location); Matrix4 mvp = camera.Matrix() * Matrix4.CreateLocalToWorld(position, Vector3.Zero, GridLatch.ChunkScale); Vector4 v1 = mvp * new Vector4(1.0f, -1.0f, 0.0f, 1.0f); Vector4 v2 = mvp * new Vector4(1.0f, 1.0f, 0.0f, 1.0f); Vector4 v3 = mvp * new Vector4(0.0f, -1.0f, -1.0f, 1.0f); Vector4 v4 = mvp * new Vector4(0.0f, 1.0f, -1.0f, 1.0f); Vector4 v5 = mvp * new Vector4(-1.0f, -1.0f, 0.0f, 1.0f); Vector4 v6 = mvp * new Vector4(-1.0f, 1.0f, 0.0f, 1.0f); Vector4 v7 = mvp * new Vector4(0.0f, -1.0f, 1.0f, 1.0f); Vector4 v8 = mvp * new Vector4(0.0f, 1.0f, 1.0f, 1.0f); GL.DepthFunc(DepthFunction.Lequal); GL.UseProgram(0); GL.LineWidth(2); GL.Color3(r, g, b); GL.Begin(PrimitiveType.LineLoop); Vertex4(v1); Vertex4(v2); GL.End(); GL.Begin(PrimitiveType.LineLoop); Vertex4(v3); Vertex4(v4); GL.End(); GL.Begin(PrimitiveType.LineLoop); Vertex4(v5); Vertex4(v6); GL.End(); GL.Begin(PrimitiveType.LineLoop); Vertex4(v7); Vertex4(v8); GL.End(); GL.DepthFunc(DepthFunction.Less); GL.LineWidth(1); }