public void setBlock(BlockPos pos, EnumBlock blockType, int meta, bool redraw) { var chunk = getChunkFromPos(pos); if (chunk == null) { var chp = pos.ChunkPos(); ThreadPool.RunTask(true, () => { generateChunk(chp, false); setBlock(pos, blockType, meta, redraw); }); return; } chunk.setBlock(pos - chunk.chunkPos, blockType, meta); if (redraw) { updateModelForChunk(chunk.chunkPos); markNeighbourChunksForUpdate(chunk, pos); } }
public BlockModel(EnumBlock block, ShaderProgram shader, bool canBeInteractedWith) { this.shader = shader; this.block = block; this.canBeInteractedWith = canBeInteractedWith; var cube = ModelManager.createTexturedCubeModel(block); rawModel = GraphicsManager.loadBlockModelToVAO(cube); boundingBox = AxisAlignedBB.BLOCK_FULL; }
public static BlockTextureUV getUVsFromBlock(EnumBlock block) { BlockTextureUV uv; UVs.TryGetValue(block, out uv); if (uv == null) { UVs.TryGetValue(EnumBlock.MISSING, out uv); } return(uv); }
public static Dictionary <EnumFacing, RawQuad> createTexturedCubeModel(EnumBlock block) { var quads = new Dictionary <EnumFacing, RawQuad>(); var uvs = TextureManager.getUVsFromBlock(block); foreach (var face in CUBE.Keys) { if (CUBE.TryGetValue(face, out var data)) { var uvNode = uvs.getUVForSide(face); if (uvNode != null) { quads.Add(face, new RawQuad(data, uvNode.ToArray(), ModelHelper.calculateNormals(data))); } } } return(quads); }
public static BlockModel getModelForBlock(EnumBlock blockType, int meta) { if (blockType == EnumBlock.AIR) { return(null); } models.TryGetValue(blockType, out var states); for (int i = 0; i < states.Count; i++) { var state = states[i]; if (state.meta == meta) { return(state.Model); } } return(null); }
protected virtual void renderBlock(EnumBlock block, float scale, int x, int y) { var UVs = TextureManager.getUVsFromBlock(block); GraphicsManager.overrideModelUVsInVAO(itemModel.rawModel.bufferIDs[1], UVs.getUVForSide(EnumFacing.SOUTH).ToArray()); var unit = new Vector2(1f / Game.INSTANCE.ClientSize.Width, 1f / Game.INSTANCE.ClientSize.Height); float width = 16; float height = 16; float scaledWidth = 16 * scale; float scaledHeight = 16 * scale; float posX = x + scaledWidth / 2; float posY = -y - scaledHeight / 2; var pos = new Vector2(posX, posY) * unit; var mat = MatrixHelper.createTransformationMatrix(pos * 2 - Vector2.UnitX + Vector2.UnitY, scale * new Vector2(width, height) * unit); itemModel.shader.start(); itemModel.shader.loadTransformationMatrix(mat); GL.BindVertexArray(itemModel.rawModel.vaoID); GL.EnableVertexAttribArray(0); GL.EnableVertexAttribArray(1); GL.ActiveTexture(TextureUnit.Texture0); GL.BindTexture(TextureTarget.Texture2D, TextureManager.blockTextureAtlasID); GL.DrawArrays(itemModel.shader.renderType, 0, 4); GL.DisableVertexAttribArray(0); GL.DisableVertexAttribArray(1); GL.BindVertexArray(0); itemModel.shader.stop(); }
public ItemBlock(EnumBlock block) : base(block.ToString(), block) { }
public void setBlock(BlockPos pos, EnumBlock blockType, int meta) { short id = (short)((short)blockType << 4 | meta); chunkBlocks[pos.x, pos.y, pos.z] = id; }
public void Enum(EnumBlock enumBlock) { ParentBlock.Add(enumBlock); }
public static CodeEntityDetails Convert(EnumBlock node, ExternalReferences externalReferences) { return(CreateCodeEntityDetails(node.Identifier, node.Reference.Namespace, node.Identifier, node.Identifier, CodeEntityType.Enum, node, node.Reference, externalReferences)); }
public BlockModel(EnumBlock block, ShaderProgram shader, AxisAlignedBB bb, bool canBeInteractedWith) : this(block, shader, canBeInteractedWith) { boundingBox = bb; }