}
m_wieldnode->setPosition(wield_position);
m_wieldnode->setRotation(wield_rotation);
+ m_wieldnode->updateLight(player->light);
// Render distance feedback loop
updateViewingRange(frametime);
m_thickness = 0.1;
m_cubemesh = NULL;
m_is_cube = false;
+ m_light = LIGHT_MAX;
}
ExtrudedSpriteSceneNode::~ExtrudedSpriteSceneNode()
m_meshnode->getMaterial(0).MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
m_meshnode->setVisible(true);
m_is_cube = false;
+ updateLight(m_light);
}
void ExtrudedSpriteSceneNode::setCube(const TileSpec tiles[6])
}
m_meshnode->setVisible(true);
m_is_cube = true;
+ updateLight(m_light);
+}
+
+void ExtrudedSpriteSceneNode::updateLight(u8 light)
+{
+ m_light = light;
+
+ u8 li = decode_light(light);
+ video::SColor color(255,li,li,li);
+ setMeshVerticesColor(m_meshnode->getMesh(), color);
}
void ExtrudedSpriteSceneNode::removeSpriteFromCache(video::ITexture* texture)
f32 getSpriteThickness() const { return m_thickness; }
void setSpriteThickness(f32 thickness);
+ void updateLight(u8 light);
+
void removeSpriteFromCache(video::ITexture* texture);
virtual const core::aabbox3d<f32>& getBoundingBox() const;
f32 m_thickness;
scene::IMesh* m_cubemesh;
bool m_is_cube;
+ u8 m_light;
// internal extrusion helper methods
io::path getExtrudedName(video::ITexture* texture);
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
- if(mesh == NULL)
- return;
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
v3s16 ItemCAO::getLightPosition()
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
- if(mesh == NULL)
- return;
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
v3s16 RatCAO::getLightPosition()
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
- if(mesh == NULL)
- return;
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
v3s16 Oerkki1CAO::getLightPosition()
u8 li = 255;
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
- if(mesh == NULL)
- return;
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
v3s16 FireflyCAO::getLightPosition()
// Move
player->move(dtime, *m_map, 100*BS);
- // Update lighting on remote players on client
- u8 light = LIGHT_MAX;
- try{
- // Get node at head
- v3s16 p = player->getLightPosition();
- MapNode n = m_map->getNode(p);
- light = n.getLightBlend(getDayNightRatio());
- }
- catch(InvalidPositionException &e) {}
- player->updateLight(light);
}
+ // Update lighting on all players on client
+ u8 light = LIGHT_MAX;
+ try{
+ // Get node at head
+ v3s16 p = player->getLightPosition();
+ MapNode n = m_map->getNode(p);
+ light = n.getLightBlend(getDayNightRatio());
+ }
+ catch(InvalidPositionException &e) {}
+ player->updateLight(light);
+
/*
Add footsteps to grass
*/
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
#endif
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
#endif
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
#endif
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
#endif
virtual bool isLocal() const = 0;
- virtual void updateLight(u8 light_at_pos) {};
+ virtual void updateLight(u8 light_at_pos)
+ {
+ light = light_at_pos;
+ }
// NOTE: Use peer_id == 0 for disconnected
/*virtual bool isClientConnected() { return false; }
bool swimming_up;
bool is_frozen;
+ u8 light;
+
Inventory inventory;
// Actual inventory is backed up here when creative mode is used
Inventory *inventory_backup;
virtual void updateLight(u8 light_at_pos)
{
+ Player::updateLight(light_at_pos);
+
if(m_node == NULL)
return;
u8 li = decode_light(light_at_pos);
video::SColor color(255,li,li,li);
-
- scene::IMesh *mesh = m_node->getMesh();
-
- u16 mc = mesh->getMeshBufferCount();
- for(u16 j=0; j<mc; j++)
- {
- scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
- video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
- u16 vc = buf->getVertexCount();
- for(u16 i=0; i<vc; i++)
- {
- vertices[i].Color = color;
- }
- }
+ setMeshVerticesColor(m_node->getMesh(), color);
}
void move(f32 dtime, Map &map, f32 pos_max_d);
next = seed;
}
+// Sets the color of all vertices in the mesh
+void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color)
+{
+ if(mesh == NULL)
+ return;
+
+ u16 mc = mesh->getMeshBufferCount();
+ for(u16 j=0; j<mc; j++)
+ {
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
+ video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
+ u16 vc = buf->getVertexCount();
+ for(u16 i=0; i<vc; i++)
+ {
+ vertices[i].Color = color;
+ }
+ }
+}
+
/*
blockpos: position of block in block coordinates
camera_pos: position of camera in nodes
u32 *m_result;
};
+// Sets the color of all vertices in the mesh
+void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color);
+
// Calculates the borders of a "d-radius" cube
inline void getFacePositions(core::list<v3s16> &list, u16 d)
{