fixed the clock

This commit is contained in:
JonnyW 2018-03-03 18:50:32 +00:00
parent 617f5c91d4
commit f7d3480951
4 changed files with 22 additions and 11 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 B

After

Width:  |  Height:  |  Size: 124 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 B

After

Width:  |  Height:  |  Size: 265 B

View File

@ -1419,10 +1419,10 @@ void content_nodebox_clock(ContentFeatures *f)
-0.4375*BS,0.1875*BS,-0.125*BS,0.4375*BS,0.25*BS,-0.0625*BS -0.4375*BS,0.1875*BS,-0.125*BS,0.4375*BS,0.25*BS,-0.0625*BS
)); ));
f->addNodeBox(NodeBox( f->addNodeBox(NodeBox(
0.*BS,-0.0625*BS,-0.125*BS,0.0625*BS,0.*BS,-0.0625*BS -0.02*BS,-0.0625*BS,-0.125*BS,0.0225*BS,0.*BS,-0.0625*BS
)); ));
f->addNodeBox(NodeBox( f->addNodeBox(NodeBox(
0.*BS,-0.1875*BS,-0.125*BS,0.0625*BS,-0.125*BS,-0.0625*BS -0.02*BS,-0.1875*BS,-0.125*BS,0.0225*BS,-0.125*BS,-0.0625*BS
)); ));
} }

View File

@ -76,28 +76,39 @@ std::vector<NodeBox> ClockNodeMetadata::getNodeBoxes(MapNode &n) {
v[2] = m/10; v[2] = m/10;
v[3] = m%10; v[3] = m%10;
f32 x[4] = {-0.125,0.0625,0.3125,0.5}; f32 x[4] = {-0.180,0.0225,0.2925,0.5};
u8 b[10] = {0xFC,0x0C,0xB6,0x9E,0x4E,0xDA,0xFA,0x8C,0xFE,0xDE}; u8 b[10] = {0xFC,0x0C,0xB6,0x9E,0x4E,0xDA,0xFA,0x8C,0xFE,0xDE};
float z1 = -0.125;
float z2 = -0.0625;
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
// clock numbers are built from 7 segments
// top
if ((b[v[i]]&0x80)) if ((b[v[i]]&0x80))
boxes.push_back(NodeBox((-0.25+x[i])*BS,0.0625*BS,-0.125*BS,(-0.0625+x[i])*BS,0.125*BS,-0.0625*BS)); boxes.push_back(NodeBox((-0.25+x[i])*BS,0.0625*BS,z1*BS,(-0.0625+x[i])*BS,0.125*BS,z2*BS));
// top right
if ((b[v[i]]&0x04)) if ((b[v[i]]&0x04))
boxes.push_back(NodeBox((-0.125+x[i])*BS,-0.0625*BS,-0.125*BS,(-0.0625+x[i])*BS,0.0625*BS,-0.0625*BS)); boxes.push_back(NodeBox((-0.125+x[i])*BS,-0.125*BS,z1*BS,(-0.0625+x[i])*BS,0.125*BS,z2*BS));
// bottom right
if ((b[v[i]]&0x08)) if ((b[v[i]]&0x08))
boxes.push_back(NodeBox((-0.125+x[i])*BS,-0.25*BS,-0.125*BS,(-0.0625+x[i])*BS,-0.125*BS,-0.0625*BS)); boxes.push_back(NodeBox((-0.125+x[i])*BS,-0.3125*BS,z1*BS,(-0.0625+x[i])*BS,-0.0625*BS,z2*BS));
// bottom
if ((b[v[i]]&0x10)) if ((b[v[i]]&0x10))
boxes.push_back(NodeBox((-0.25+x[i])*BS,-0.3125*BS,-0.125*BS,(-0.0625+x[i])*BS,-0.25*BS,-0.0625*BS)); boxes.push_back(NodeBox((-0.25+x[i])*BS,-0.3125*BS,z1*BS,(-0.0625+x[i])*BS,-0.25*BS,z2*BS));
// bottom left
if ((b[v[i]]&0x20)) if ((b[v[i]]&0x20))
boxes.push_back(NodeBox((-0.25+x[i])*BS,-0.25*BS,-0.125*BS,(-0.1875+x[i])*BS,-0.125*BS,-0.0625*BS)); boxes.push_back(NodeBox((-0.25+x[i])*BS,-0.3125*BS,z1*BS,(-0.1875+x[i])*BS,-0.0625*BS,z2*BS));
// top left
if ((b[v[i]]&0x40)) if ((b[v[i]]&0x40))
boxes.push_back(NodeBox((-0.25+x[i])*BS,-0.0625*BS,-0.125*BS,(-0.1875+x[i])*BS,0.0625*BS,-0.0625*BS)); boxes.push_back(NodeBox((-0.25+x[i])*BS,-0.125*BS,z1*BS,(-0.1875+x[i])*BS,0.125*BS,z2*BS));
// middle
if ((b[v[i]]&0x02)) if ((b[v[i]]&0x02))
boxes.push_back(NodeBox((-0.1875+x[i])*BS,-0.125*BS,-0.125*BS,(-0.125+x[i])*BS,-0.0625*BS,-0.0625*BS)); boxes.push_back(NodeBox((-0.25+x[i])*BS,-0.125*BS,z1*BS,(-0.0625+x[i])*BS,-0.0625*BS,z2*BS));
} }
return transformNodeBox(n,boxes); return boxes;
} }
bool ClockNodeMetadata::step(float dtime, v3s16 pos, ServerEnvironment *env) bool ClockNodeMetadata::step(float dtime, v3s16 pos, ServerEnvironment *env)
{ {