Permalink
Browse files

Merge commit '68f5b87'

  • Loading branch information...
proller committed Nov 13, 2016
2 parents ae1038b + 68f5b87 commit 051fefd0bbe520b58c5d9184cb08b26edb56ef4a
Showing with 39 additions and 2 deletions.
  1. +2 −0 src/game.cpp
  2. +6 −0 src/hud.cpp
  3. +7 −2 src/hud.h
  4. +20 −0 src/mesh.cpp
  5. +4 −0 src/mesh.h
  6. BIN textures/base/pack/halo.png
View
@@ -369,6 +369,7 @@ PointedThing getPointedThing(Client *client, Hud *hud, const v3f &player_positio
min_distance = (selected_object->getPosition() - camera_position).getLength();
hud->setSelectedFaceNormal(v3f(0.0, 0.0, 0.0));
result.type = POINTEDTHING_OBJECT;
result.object_id = selected_object->getId();
}
@@ -480,6 +481,7 @@ PointedThing getPointedThing(Client *client, Hud *hud, const v3f &player_positio
if (!facebox.intersectsWithLine(shootline))
continue;
result.node_abovesurface = pointed_pos + facedir;
hud->setSelectedFaceNormal(v3f(facedir.X, facedir.Y, facedir.Z));
face_min_distance = distance;
}
}
View
@@ -558,6 +558,12 @@ void Hud::drawSelectionMesh()
video::SMaterial oldmaterial = driver->getMaterial2D();
driver->setMaterial(m_selection_material);
setMeshColor(m_selection_mesh, m_selection_mesh_color);
video::SColor face_color(0,
MYMIN(255, m_selection_mesh_color.getRed() * 1.5),
MYMIN(255, m_selection_mesh_color.getGreen() * 1.5),
MYMIN(255, m_selection_mesh_color.getBlue() * 1.5));
setMeshColorByNormal(m_selection_mesh, m_selected_face_normal,
face_color);
scene::IMesh* mesh = cloneMesh(m_selection_mesh);
translateMesh(mesh, m_selection_pos_with_offset);
u32 mc = m_selection_mesh->getMeshBufferCount();
View
@@ -144,8 +144,11 @@ class Hud {
v3f getSelectionPos() const
{ return m_selection_pos; }
void setSelectionMeshColor(const video::SColor &c)
{ m_selection_mesh_color = c; }
void setSelectionMeshColor(const video::SColor &color)
{ m_selection_mesh_color = color; }
void setSelectedFaceNormal(const v3f &face_normal)
{ m_selected_face_normal = face_normal; }
void drawLuaElements(const v3s16 &camera_offset);
@@ -174,6 +177,8 @@ class Hud {
scene::IMesh* m_selection_mesh;
video::SColor m_selection_mesh_color;
v3f m_selected_face_normal;
video::SMaterial m_selection_material;
bool m_use_selection_mesh;
};
View
@@ -230,7 +230,27 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh,
vertex->Color = colorY;
else
vertex->Color = colorZ;
}
}
}
void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal,
const video::SColor &color)
{
if (!mesh)
return;
u16 mc = mesh->getMeshBufferCount();
for (u16 j = 0; j < mc; j++) {
scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
const u32 stride = getVertexPitchFromType(buf->getVertexType());
u32 vertex_count = buf->getVertexCount();
u8 *vertices = (u8 *)buf->getVertices();
for (u32 i = 0; i < vertex_count; i++) {
video::S3DVertex *vertex = (video::S3DVertex *)(vertices + i * stride);
if (normal == vertex->Normal) {
vertex->Color = color;
}
}
}
}
View
@@ -67,6 +67,10 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh,
const video::SColor &colorX,
const video::SColor &colorY,
const video::SColor &colorZ);
void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal,
const video::SColor &color);
/*
Rotate the mesh by 6d facedir value.
Method only for meshnodes, not suitable for entities.
View
Binary file not shown.

0 comments on commit 051fefd

Please sign in to comment.