Added top side to grass and improved worldgen a tiny bit
This commit is contained in:
parent
80e6f97275
commit
afde681ce9
|
@ -163,12 +163,14 @@ tc_cube_info_s tc_gen_unitexture_cube_info
|
||||||
void tc_create_blocks()
|
void tc_create_blocks()
|
||||||
{
|
{
|
||||||
tc_image_s *dirt_texture = tc_resolve_name_to_image("dirt");
|
tc_image_s *dirt_texture = tc_resolve_name_to_image("dirt");
|
||||||
tc_image_s *grass_texture = tc_resolve_name_to_image("grass");
|
tc_image_s *grass_texture = tc_resolve_name_to_image("grass-side");
|
||||||
|
tc_image_s *grass_top_texture = tc_resolve_name_to_image("grass-top");
|
||||||
tc_image_s *stone_texture = tc_resolve_name_to_image("stone");
|
tc_image_s *stone_texture = tc_resolve_name_to_image("stone");
|
||||||
|
|
||||||
tc_cube_info_s dirt = tc_gen_unitexture_cube_info("Dirt", 1 | TC_BLOCK_OPAQUE_BIT, dirt_texture->image_id);
|
tc_cube_info_s dirt = tc_gen_unitexture_cube_info("Dirt", 1 | TC_BLOCK_OPAQUE_BIT, dirt_texture->image_id);
|
||||||
tc_cube_info_s grass = tc_gen_unitexture_cube_info("Grass", 2 | TC_BLOCK_OPAQUE_BIT, grass_texture->image_id);
|
|
||||||
tc_cube_info_s stone = tc_gen_unitexture_cube_info("Stone", 3 | TC_BLOCK_OPAQUE_BIT, stone_texture->image_id);
|
tc_cube_info_s stone = tc_gen_unitexture_cube_info("Stone", 3 | TC_BLOCK_OPAQUE_BIT, stone_texture->image_id);
|
||||||
|
tc_cube_info_s grass = tc_gen_unitexture_cube_info("Grass", 2 | TC_BLOCK_OPAQUE_BIT, grass_texture->image_id);
|
||||||
|
grass.texture_top = grass_top_texture->image_id;
|
||||||
|
|
||||||
tc_new_cube_block(dirt);
|
tc_new_cube_block(dirt);
|
||||||
tc_new_cube_block(grass);
|
tc_new_cube_block(grass);
|
||||||
|
|
|
@ -51,14 +51,13 @@ float tc_cube_back_xyz[18] =
|
||||||
|
|
||||||
float tc_cube_west_uv[12] =
|
float tc_cube_west_uv[12] =
|
||||||
{
|
{
|
||||||
// Left
|
0.0f, 1.0f,
|
||||||
1.0f, 0.0f,
|
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
0.0f, 1.0f,
|
1.0f, 0.0f,
|
||||||
|
|
||||||
0.0f, 1.0f,
|
1.0f, 0.0f,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
1.0f, 0.0f
|
0.0f, 1.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
float tc_cube_west_xyz[18] =
|
float tc_cube_west_xyz[18] =
|
||||||
|
@ -76,14 +75,13 @@ float tc_cube_west_xyz[18] =
|
||||||
|
|
||||||
float tc_cube_east_uv[12] =
|
float tc_cube_east_uv[12] =
|
||||||
{
|
{
|
||||||
// Right
|
1.0f, 0.0f,
|
||||||
0.0f, 1.0f,
|
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
1.0f, 0.0f,
|
0.0f, 1.0f,
|
||||||
|
|
||||||
1.0f, 0.0f,
|
0.0f, 1.0f,
|
||||||
1.0f, 1.0f,
|
1.0f, 1.0f,
|
||||||
0.0f, 1.0f
|
1.0f, 0.0f
|
||||||
};
|
};
|
||||||
|
|
||||||
float tc_cube_east_xyz[18] =
|
float tc_cube_east_xyz[18] =
|
||||||
|
@ -101,7 +99,6 @@ float tc_cube_east_xyz[18] =
|
||||||
|
|
||||||
float tc_cube_top_uv[12] =
|
float tc_cube_top_uv[12] =
|
||||||
{
|
{
|
||||||
// Top
|
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
1.0f, 0.0f,
|
1.0f, 0.0f,
|
||||||
|
@ -126,7 +123,6 @@ float tc_cube_top_xyz[18] =
|
||||||
|
|
||||||
float tc_cube_bottom_uv[12] =
|
float tc_cube_bottom_uv[12] =
|
||||||
{
|
{
|
||||||
// Bottom
|
|
||||||
0.0f, 1.0f,
|
0.0f, 1.0f,
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
1.0f, 0.0f,
|
1.0f, 0.0f,
|
||||||
|
@ -151,21 +147,25 @@ float tc_cube_bottom_xyz[18] =
|
||||||
|
|
||||||
void tc_adjust_cube_uvs_for_image(tc_image_s *image, float *face_uvs)
|
void tc_adjust_cube_uvs_for_image(tc_image_s *image, float *face_uvs)
|
||||||
{
|
{
|
||||||
float lower_x = ((float) image->x) / ((float) image->width);
|
float uv_per_pixel_w = 1.0f / image->width;
|
||||||
float lower_y = ((float) image->y) / ((float) image->height);
|
float uv_per_pixel_h = 1.0f / image->height;
|
||||||
float higher_x;
|
|
||||||
float higher_y;
|
|
||||||
|
|
||||||
if(image->superimage != NULL)
|
if(image->superimage != NULL)
|
||||||
{
|
{
|
||||||
higher_x = (((float) (image->x + image->width)) / ((float) image->superimage->width));
|
uv_per_pixel_w = 1.0f / image->superimage->width;
|
||||||
higher_y = (((float) (image->y + image->height)) / ((float) image->superimage->height));
|
uv_per_pixel_h = 1.0f / image->superimage->height;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
higher_x = 1.0f;
|
|
||||||
higher_y = 1.0f;
|
|
||||||
}
|
}
|
||||||
|
printf("UV Per Pixel: %f|%f\n", uv_per_pixel_w, uv_per_pixel_h);
|
||||||
|
|
||||||
|
float lower_x = uv_per_pixel_w * ((float) image->x);
|
||||||
|
float lower_y = uv_per_pixel_h * ((float) image->y);
|
||||||
|
float higher_x = 1.0f;
|
||||||
|
float higher_y = 1.0f;
|
||||||
|
|
||||||
|
higher_x = lower_x + uv_per_pixel_w * 8; // image->width;
|
||||||
|
higher_y = lower_y + uv_per_pixel_h * 8; // image->height;
|
||||||
|
|
||||||
|
printf("Lower Coordinates: %f|%f, Higher Coordinates: %f %f\n", lower_x, lower_y, higher_x, higher_y);
|
||||||
|
|
||||||
uint32_t num_floats = 2 * 6;
|
uint32_t num_floats = 2 * 6;
|
||||||
uint32_t index = 0;
|
uint32_t index = 0;
|
||||||
|
|
|
@ -8,6 +8,9 @@ bool tc_generate_default_terrain_chunk(tc_worldgen_s *gen, tc_chunk_s *chunk)
|
||||||
block.position.y = 0.0f;
|
block.position.y = 0.0f;
|
||||||
block.position.z = 0.0f;
|
block.position.z = 0.0f;
|
||||||
|
|
||||||
|
tc_block_s grass;
|
||||||
|
grass.type_identifier = 2 | TC_BLOCK_OPAQUE_BIT;
|
||||||
|
|
||||||
if(chunk->position.y > 0) return true;
|
if(chunk->position.y > 0) return true;
|
||||||
|
|
||||||
uint32_t x_in_chunk = 0;
|
uint32_t x_in_chunk = 0;
|
||||||
|
@ -28,9 +31,20 @@ bool tc_generate_default_terrain_chunk(tc_worldgen_s *gen, tc_chunk_s *chunk)
|
||||||
}
|
}
|
||||||
++x_in_chunk;
|
++x_in_chunk;
|
||||||
}
|
}
|
||||||
tc_block_s air;
|
if(chunk->position.y == 0)
|
||||||
block.type_identifier = 0;
|
{
|
||||||
tc_set_block_in_chunk(chunk, 6, 8, 14, air);
|
x_in_chunk = 0;
|
||||||
|
while(x_in_chunk < 32)
|
||||||
|
{
|
||||||
|
z_in_chunk = 0;
|
||||||
|
while(z_in_chunk < 32)
|
||||||
|
{
|
||||||
|
tc_set_block_in_chunk(chunk, x_in_chunk, 31, z_in_chunk, grass);
|
||||||
|
++z_in_chunk;
|
||||||
|
}
|
||||||
|
++x_in_chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,14 @@ void tc_load_textures()
|
||||||
tc_image_s *dirt =
|
tc_image_s *dirt =
|
||||||
tc_create_subimage(tc_game_state_g.block_texture_atlas, 0, 0, 8, 8);
|
tc_create_subimage(tc_game_state_g.block_texture_atlas, 0, 0, 8, 8);
|
||||||
dirt->name = "dirt";
|
dirt->name = "dirt";
|
||||||
|
|
||||||
tc_image_s *grass =
|
tc_image_s *grass =
|
||||||
tc_create_subimage(tc_game_state_g.block_texture_atlas, 8, 0, 8, 8);
|
tc_create_subimage(tc_game_state_g.block_texture_atlas, 8, 0, 8, 8);
|
||||||
grass->name = "grass";
|
grass->name = "grass-side";
|
||||||
|
|
||||||
|
tc_image_s *grass_top =
|
||||||
|
tc_create_subimage(tc_game_state_g.block_texture_atlas, 8, 8, 8, 8);
|
||||||
|
grass_top->name = "grass-top";
|
||||||
|
|
||||||
tc_image_s *stone =
|
tc_image_s *stone =
|
||||||
tc_create_subimage(tc_game_state_g.block_texture_atlas, 16, 0, 8, 8);
|
tc_create_subimage(tc_game_state_g.block_texture_atlas, 16, 0, 8, 8);
|
||||||
|
|
Loading…
Reference in New Issue