farm improvements pt1

master
darkrose 2017-07-19 18:33:33 +10:00
parent 885bc17886
commit da3f690e4d
19 changed files with 153 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 650 B

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 801 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 427 B

After

Width:  |  Height:  |  Size: 881 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 396 B

After

Width:  |  Height:  |  Size: 763 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 830 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 888 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 403 B

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@ -2498,6 +2498,120 @@ void meshgen_plantlike_fern(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNod
}
}
void meshgen_croplike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected)
{
ContentFeatures *f = &content_features(n);
TileSpec tile = getNodeTile(n,p,v3s16(0,1,0),selected);
v3f offset(0,0,0);
if (data->m_vmanip.getNodeRO(data->m_blockpos_nodes + p + v3s16(0,-1,0)).getContent() == CONTENT_FLOWER_POT)
offset = v3f(0,-0.25*data->m_BS,0);
f32 v0 = 0.;
f32 v1 = 1.;
f32 h = 0.5;
if (f->plantlike_tiled) {
if (f->param2_type == CPT_PLANTGROWTH && n.param2 != 0 && !f->plantgrowth_on_trellis) {
h = (0.0625*(float)n.param2);
if (data->m_vmanip.getNodeRO(data->m_blockpos_nodes + p + v3s16(0,-1,0)).getContent() != n.getContent()) {
v0 = (1.0-h)/2;
}else{
v0 = ((1.0-h)/2)+0.25;
v1 = 0.75;
}
h -= 0.5;
}else if (data->m_vmanip.getNodeRO(data->m_blockpos_nodes + p + v3s16(0,-1,0)).getContent() != n.getContent()) {
v0 = 0.5;
}else if (data->m_vmanip.getNodeRO(data->m_blockpos_nodes + p + v3s16(0,1,0)).getContent() != n.getContent()) {
v1 = 0.5;
}else{
v0 = 0.25;
v1 = 0.75;
}
}else if (f->param2_type == CPT_PLANTGROWTH) {
if (n.param2 != 0 && !f->plantgrowth_on_trellis) {
h = (0.0625*(float)n.param2);
v0 = (1.0-h);
h -= 0.5;
}
}
v3f pos = offset+intToFloat(p,BS);
if (selected.is_coloured || selected.has_crack) {
//for (u32 j=0; j<2; j++) {
//video::S3DVertex vertices[4] = {
//video::S3DVertex(-0.5*BS,-0.5*BS,0., 0,0,0, video::SColor(255,255,255,255), 0.,v1),
//video::S3DVertex( 0.5*BS,-0.5*BS,0., 0,0,0, video::SColor(255,255,255,255), 1.,v1),
//video::S3DVertex( 0.5*BS, h*BS,0., 0,0,0, video::SColor(255,255,255,255), 1.,v0),
//video::S3DVertex(-0.5*BS, h*BS,0., 0,0,0, video::SColor(255,255,255,255), 0.,v0)
//};
//s16 angle = 45;
//if (j == 1)
//angle = -45;
//for (u16 i=0; i<4; i++) {
//vertices[i].Pos.rotateXZBy(angle);
//vertices[i].TCoords *= tile.texture.size;
//vertices[i].TCoords += tile.texture.pos;
//}
//u16 indices[] = {0,1,2,2,3,0};
//std::vector<u32> colours;
//if (selected.is_coloured) {
//meshgen_selected_lights(colours,255,4);
//}else{
//meshgen_lights(data,n,p,colours,255,v3s16(0,0,0),4,vertices);
//}
//for (u16 i=0; i<4; i++) {
//vertices[i].Pos += pos;
//vertices[i].Pos.X += 0.005;
//}
//data->append(tile, vertices, 4, indices, 6, colours);
//for (u16 i=0; i<4; i++) {
//vertices[i].Pos.X -= 0.01;
//}
//data->append(tile, vertices, 4, indices, 6, colours);
//}
}else{
for (u32 j=0; j<4; j++) {
video::S3DVertex vertices[4] = {
video::S3DVertex(-0.5*BS,-0.5*BS,-0.25*BS, 0,0,0, video::SColor(255,255,255,255), 0.,v1),
video::S3DVertex( 0.5*BS,-0.5*BS,-0.25*BS, 0,0,0, video::SColor(255,255,255,255), 1.,v1),
video::S3DVertex( 0.5*BS, h*BS,-0.25*BS, 0,0,0, video::SColor(255,255,255,255), 1.,v0),
video::S3DVertex(-0.5*BS, h*BS,-0.25*BS, 0,0,0, video::SColor(255,255,255,255), 0.,v0)
};
s16 angle = j*90;
for (u16 i=0; i<4; i++) {
vertices[i].Pos.rotateXZBy(angle);
vertices[i].TCoords *= tile.texture.size;
vertices[i].TCoords += tile.texture.pos;
}
u16 indices[] = {0,1,2,2,3,0};
std::vector<u32> colours;
if (selected.is_coloured) {
meshgen_selected_lights(colours,255,4);
}else{
meshgen_lights(data,n,p,colours,255,v3s16(0,0,0),4,vertices);
}
for (u16 i=0; i<4; i++) {
vertices[i].Pos += pos;
}
data->append(tile, vertices, 4, indices, 6, colours);
}
}
}
void meshgen_liquid(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected)
{
ContentFeatures *f = &content_features(n);

View File

@ -37,6 +37,7 @@ void meshgen_dirtlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &sel
void meshgen_raillike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected);
void meshgen_plantlike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected);
void meshgen_plantlike_fern(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected);
void meshgen_croplike(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected);
void meshgen_liquid(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected);
void meshgen_liquid_source(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected);
void meshgen_nodebox(MeshMakeData *data, v3s16 p, MapNode &n, SelectedNode &selected, bool meta);

View File

@ -36,8 +36,9 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_FARM_DIRT;
f = &content_features(i);
f->description = gettext("Farm Dirt");
f->setAllTextures("dirt.png");
f->setInventoryTextureCube("dirt.png","dirt.png","dirt.png");
f->setAllTextures("mud.png");
f->setTexture(0,"dirt.png");
f->setInventoryTextureCube("dirt.png","mud.png","mud.png");
f->draw_type = CDT_CUBELIKE;
f->is_ground_content = true;
f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1";
@ -87,8 +88,9 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_WHEAT;
f = &content_features(i);
f->description = gettext("Wheat Seeds");
f->setAllTextures("farm_seeds_wheat.png");
f->draw_type = CDT_PLANTLIKE;
f->setAllTextures("farm_seeds.png");
f->setInventoryTexture("farm_seeds_wheat.png");
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
f->walkable = false;
@ -107,7 +109,8 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_MELON;
f = &content_features(i);
f->description = gettext("Melon Seeds");
f->setAllTextures("farm_seeds_melon.png");
f->setAllTextures("farm_seeds_central.png");
f->setInventoryTexture("farm_seeds_melon.png");
f->draw_type = CDT_PLANTLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
@ -129,7 +132,8 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_PUMPKIN;
f = &content_features(i);
f->description = gettext("Pumpkin Seeds");
f->setAllTextures("farm_seeds_pumpkin.png");
f->setAllTextures("farm_seeds_central.png");
f->setInventoryTexture("farm_seeds_pumpkin.png");
f->draw_type = CDT_PLANTLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
@ -151,8 +155,9 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_POTATO;
f = &content_features(i);
f->description = gettext("Potato Seeds");
f->setAllTextures("farm_seeds_potato.png");
f->draw_type = CDT_PLANTLIKE;
f->setAllTextures("farm_seeds.png");
f->setInventoryTexture("farm_seeds_potato.png");
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
f->walkable = false;
@ -173,8 +178,9 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_CARROT;
f = &content_features(i);
f->description = gettext("Carrot Seeds");
f->setAllTextures("farm_seeds_carrot.png");
f->draw_type = CDT_PLANTLIKE;
f->setAllTextures("farm_seeds.png");
f->setInventoryTexture("farm_seeds_carrot.png");
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
f->walkable = false;
@ -195,8 +201,9 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_BEETROOT;
f = &content_features(i);
f->description = gettext("Beetroot Seeds");
f->setAllTextures("farm_seeds_beetroot.png");
f->draw_type = CDT_PLANTLIKE;
f->setAllTextures("farm_seeds.png");
f->setInventoryTexture("farm_seeds_beetroot.png");
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
f->walkable = false;
@ -217,8 +224,9 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_GRAPE;
f = &content_features(i);
f->description = gettext("Grape Seeds");
f->setAllTextures("farm_seeds_grape.png");
f->draw_type = CDT_PLANTLIKE;
f->setAllTextures("farm_seeds.png");
f->setInventoryTexture("farm_seeds_grape.png");
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
f->walkable = false;
@ -239,8 +247,9 @@ void content_mapnode_farm(bool repeat)
i = CONTENT_SEEDS_COTTON;
f = &content_features(i);
f->description = gettext("Cotton Seeds");
f->setAllTextures("farm_seeds_cotton.png");
f->draw_type = CDT_PLANTLIKE;
f->setAllTextures("farm_seeds.png");
f->setInventoryTexture("farm_seeds_cotton.png");
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->setAllTextureFlags(0);
f->walkable = false;
@ -260,7 +269,7 @@ void content_mapnode_farm(bool repeat)
f = &content_features(i);
f->description = gettext("Wheat");
f->setAllTextures("farm_wheat.png");
f->draw_type = CDT_PLANTLIKE;
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->param2_type = CPT_PLANTGROWTH;
f->setAllTextureFlags(0);
@ -342,7 +351,7 @@ void content_mapnode_farm(bool repeat)
f = &content_features(i);
f->description = gettext("Potato");
f->setAllTextures("farm_potato.png");
f->draw_type = CDT_PLANTLIKE;
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->param2_type = CPT_PLANTGROWTH;
f->setAllTextureFlags(0);
@ -362,7 +371,7 @@ void content_mapnode_farm(bool repeat)
f = &content_features(i);
f->description = gettext("Carrot");
f->setAllTextures("farm_carrot.png");
f->draw_type = CDT_PLANTLIKE;
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->param2_type = CPT_PLANTGROWTH;
f->setAllTextureFlags(0);
@ -382,7 +391,7 @@ void content_mapnode_farm(bool repeat)
f = &content_features(i);
f->description = gettext("Beetroot");
f->setAllTextures("farm_beetroot.png");
f->draw_type = CDT_PLANTLIKE;
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->param2_type = CPT_PLANTGROWTH;
f->setAllTextureFlags(0);
@ -402,7 +411,7 @@ void content_mapnode_farm(bool repeat)
f = &content_features(i);
f->description = gettext("Grape");
f->setAllTextures("farm_grapevine.png");
f->draw_type = CDT_PLANTLIKE;
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->param2_type = CPT_PLANTGROWTH;
f->setAllTextureFlags(0);
@ -423,7 +432,7 @@ void content_mapnode_farm(bool repeat)
f = &content_features(i);
f->description = gettext("Cotton");
f->setAllTextures("farm_cotton.png");
f->draw_type = CDT_PLANTLIKE;
f->draw_type = CDT_CROPLIKE;
f->param_type = CPT_LIGHT;
f->param2_type = CPT_PLANTGROWTH;
f->setAllTextureFlags(0);

View File

@ -606,6 +606,9 @@ void MapBlockMesh::generate(MeshMakeData *data, v3s16 camera_offset, JMutex *mut
case CDT_PLANTLIKE_FERN:
meshgen_plantlike_fern(data,p,n,selected);
break;
case CDT_CROPLIKE:
meshgen_croplike(data,p,n,selected);
break;
case CDT_LIQUID:
meshgen_liquid(data,p,n,selected);
break;

View File

@ -105,6 +105,7 @@ enum ContentDrawType
CDT_RAILLIKE,
CDT_PLANTLIKE,
CDT_PLANTLIKE_FERN,
CDT_CROPLIKE,
CDT_MELONLIKE,
CDT_LIQUID,
CDT_LIQUID_SOURCE,

View File

@ -239,6 +239,9 @@ void SelectionMesh::generate(MeshMakeData *data)
case CDT_PLANTLIKE_FERN:
meshgen_plantlike_fern(data,p,n,selected);
break;
case CDT_CROPLIKE:
meshgen_croplike(data,p,n,selected);
break;
case CDT_LIQUID:
meshgen_liquid(data,p,n,selected);
break;