mirror of https://github.com/buggins/dlangui.git
dminer example: fix block texture coords - #247
This commit is contained in:
parent
9dc12cde78
commit
7a6a9b1ab6
|
@ -83,53 +83,59 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
0 1
|
||||
3 2
|
||||
*/
|
||||
|
||||
// pos, normal, color, tx
|
||||
static const float[VERTEX_COMPONENTS * 4] face_vertices_north =
|
||||
[
|
||||
-0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0,
|
||||
-0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
-0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0,
|
||||
0.5, 0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
-0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
0.5, -0.5, -0.5, 0.0, 0.0, -1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
];
|
||||
|
||||
static const float[VERTEX_COMPONENTS * 4] face_vertices_south =
|
||||
[
|
||||
-0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0,
|
||||
-0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
-0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
-0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
0.5, 0.5, 0.5, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0,
|
||||
];
|
||||
|
||||
static const float[VERTEX_COMPONENTS * 4] face_vertices_west =
|
||||
[
|
||||
-0.5, -0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
-0.5, -0.5, 0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0,
|
||||
-0.5, 0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
-0.5, 0.5, 0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0
|
||||
-0.5, -0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
-0.5, -0.5, 0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
-0.5, 0.5, -0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
-0.5, 0.5, 0.5, -1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0
|
||||
];
|
||||
|
||||
static const float[VERTEX_COMPONENTS * 4] face_vertices_east =
|
||||
[
|
||||
0.5, -0.5, 0.5, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
0.5, -0.5, -0.5, 1.0, 0.0, 0.0,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X_COMPONENTS * 4] face_vertices_down =
|
||||
[
|
||||
-0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0,
|
||||
-0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
-0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0,
|
||||
0.5, -0.5, -0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
|
||||
-0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
|
||||
0.5, -0.5, 0.5, 0.0, -1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
|
||||
];
|
||||
|
||||
static const ushort[6] face_indexes =
|
||||
|
@ -245,6 +251,8 @@ enum BlockImage : int {
|
|||
brick,
|
||||
stonebrick,
|
||||
red_sand,
|
||||
|
||||
face_test=64,
|
||||
}
|
||||
|
||||
enum BlockId : cell_t {
|
||||
|
@ -258,7 +266,8 @@ enum BlockId : cell_t {
|
|||
red_sand,
|
||||
sand,
|
||||
dirt,
|
||||
grass
|
||||
grass,
|
||||
face_test
|
||||
}
|
||||
|
||||
/// init block types array
|
||||
|
@ -288,6 +297,10 @@ __gshared static this() {
|
|||
registerBlockType(new BlockDef(BlockId.dirt, "dirt", BlockVisibility.OPAQUE, BlockImage.dirt));
|
||||
registerBlockType(new CustomTopBlock(BlockId.grass, "grass", BlockVisibility.OPAQUE, BlockImage.dirt, BlockImage.grass_top, BlockImage.grass_side));
|
||||
|
||||
|
||||
// for face texture test
|
||||
registerBlockType(new BlockDef(BlockId.face_test, "face_test", BlockVisibility.OPAQUE, BlockImage.face_test));
|
||||
|
||||
//registerBlockType(new BlockDef(50, "box", BlockVisibility.HALF_OPAQUE, 50));
|
||||
|
||||
//registerBlockType(new TerrainBlock(100, "terrain_bedrock", 2));
|
||||
|
|
|
@ -483,7 +483,8 @@ void initWorldTerrain(World world, int terrSizeBits = 10, int x0 = 0, int z0 = 0
|
|||
int cellz = z0 + z - terrSize / 2;
|
||||
int h = terr.get(x, z);
|
||||
//cell_t cell = BlockId.bedrock;
|
||||
cell_t cell = BlockId.grass;
|
||||
//cell_t cell = BlockId.grass;
|
||||
cell_t cell = BlockId.face_test;
|
||||
//if (h < CHUNK_DY / 10)
|
||||
// cell = 100;
|
||||
//else if (h < CHUNK_DY / 5)
|
||||
|
|
|
@ -109,6 +109,11 @@ class UiWidget : VerticalLayout, CellVisitor {
|
|||
}
|
||||
_world.camPosition = Position(Vector3d(0, cy0, 0), Vector3d(0, 0, 1));
|
||||
|
||||
_world.setCell(5, cy0 + 5, 7, BlockId.face_test);
|
||||
_world.setCell(-5, cy0 + 5, 7, BlockId.face_test);
|
||||
_world.setCell(5, cy0 + 5, -7, BlockId.face_test);
|
||||
_world.setCell(3, cy0 + 5, 13, BlockId.face_test);
|
||||
|
||||
_world.setCellRange(Vector3d(3, 11, 5), Vector3d(1, 100, 1), 1);
|
||||
_world.setCellRange(Vector3d(13, 11, -5), Vector3d(1, 100, 1), 3);
|
||||
_world.setCellRange(Vector3d(-6, 11, 10), Vector3d(1, 100, 1), 4);
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 32 KiB |
Loading…
Reference in New Issue