Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case NDT_NODEBOX:
- static const v3s16 tile_dirs[6] = {
- v3s16(0, 1, 0),
- v3s16(0, -1, 0),
- v3s16(1, 0, 0),
- v3s16(-1, 0, 0),
- v3s16(0, 0, 1),
- v3s16(0, 0, -1)
- };
- TileSpec tiles[6];
- u16 l = getInteriorLight(n, 0, data);
- video::SColor c = MapBlock_LightColor(255, l, decode_light(f.light_source));
- v3f pos = intToFloat(p, BS);
- std::vector<aabb3f> boxes = n.getNodeBoxes(nodedef);
- for(std::vector<aabb3f>::iterator
- i = boxes.begin();
- i != boxes.end(); i++)
- {
- for(int j = 0; j < 6; j++)
- {
- // Handles facedir rotation for textures
- tiles[j] = getNodeTile(n, p, tile_dirs[j], data);
- }
- aabb3f box = *i;
- box.MinEdge += pos;
- box.MaxEdge += pos;
- f32 temp;
- if (box.MinEdge.X > box.MaxEdge.X)
- {
- temp=box.MinEdge.X;
- box.MinEdge.X=box.MaxEdge.X;
- box.MaxEdge.X=temp;
- }
- if (box.MinEdge.Y > box.MaxEdge.Y)
- {
- temp=box.MinEdge.Y;
- box.MinEdge.Y=box.MaxEdge.Y;
- box.MaxEdge.Y=temp;
- }
- if (box.MinEdge.Z > box.MaxEdge.Z)
- {
- temp=box.MinEdge.Z;
- box.MinEdge.Z=box.MaxEdge.Z;
- box.MaxEdge.Z=temp;
- }
- // Compute texture coords
- f32 tx1 = (i->MinEdge.X/BS)+0.5;
- f32 ty1 = (i->MinEdge.Y/BS)+0.5;
- f32 tz1 = (i->MinEdge.Z/BS)+0.5;
- f32 tx2 = (i->MaxEdge.X/BS)+0.5;
- f32 ty2 = (i->MaxEdge.Y/BS)+0.5;
- f32 tz2 = (i->MaxEdge.Z/BS)+0.5;
- f32 txc[24] = {
- // up
- tx1, 1-tz2, tx2, 1-tz1,
- // down
- tx1, tz1, tx2, tz2,
- // right
- tz1, 1-ty2, tz2, 1-ty1,
- // left
- 1-tz2, 1-ty2, 1-tz1, 1-ty1,
- // back
- 1-tx2, 1-ty2, 1-tx1, 1-ty1,
- // front
- tx1, 1-ty2, tx2, 1-ty1,
- };
- f32 t;
- for(int k = 0; k < 6; k++)
- {
- switch (tiles[k].rotation)
- {
- case 0:
- break;
- case 2: //R180
- t = txc[k*4];
- txc[k*4] = txc[k*4+2];
- txc[k*4+2] = t;
- t = txc[k*4+1];
- txc[k*4+1] = txc[k*4+3];
- txc[k*4+3] = t;
- break;
- default:
- break;
- }
- }
- makeCuboid(&collector, box, tiles, 6, c, txc);
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement