Commit 9f0de563 authored by Mike Kremer's avatar Mike Kremer

Added draw mode for colored vertices.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15058 383ad7c9-94d9-4d36-a494-682f7c89f535
parent aa284365
......@@ -47,6 +47,7 @@
#include <ACG/GL/gl.hh>
#include <ACG/Scenegraph/BaseNode.hh>
#include <ACG/Scenegraph/MaterialNode.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <OpenVolumeMesh/Core/OpenVolumeMeshHandle.hh>
#include <OpenVolumeMesh/Core/BaseEntities.hh>
......@@ -105,7 +106,8 @@ public:
OpenVolumeMesh::StatusAttrib& _statusAttrib,
OpenVolumeMesh::ColorAttrib<Vec4f>& _colorAttrib,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& _normalAttrib,
BaseNode* _parent = 0, std::string _name = "<VolumeMeshNode>");
const MaterialNode* _matNode, BaseNode* _parent = 0,
std::string _name = "<VolumeMeshNode>");
/// Destructor
~VolumeMeshNodeT();
......@@ -278,12 +280,11 @@ private:
// Hold color of selection
ACG::Vec4f selection_color_;
// Store point size
float point_size_;
OpenVolumeMesh::StatusAttrib& statusAttrib_;
OpenVolumeMesh::ColorAttrib<Vec4f>& colorAttrib_;
OpenVolumeMesh::NormalAttrib<VolumeMesh>& normalAttrib_;
const MaterialNode* materialNode_;
};
//=============================================================================
......
......@@ -61,7 +61,8 @@ VolumeMeshNodeT<VolumeMeshT>::VolumeMeshNodeT(const VolumeMesh& _mesh,
OpenVolumeMesh::StatusAttrib& _statusAttrib,
OpenVolumeMesh::ColorAttrib<Vec4f>& _colorAttrib,
OpenVolumeMesh::NormalAttrib<VolumeMesh>& _normalAttrib,
BaseNode* _parent, std::string _name) :
const MaterialNode* _matNode, BaseNode* _parent,
std::string _name) :
BaseNode(_parent, _name),
mesh_(_mesh),
scale_(1.0),
......@@ -77,10 +78,10 @@ translucency_factor_(0.1),
show_irregs_(false),
show_outer_val2_irregs_(false),
selection_color_(ACG::Vec4f(1.0f, 0.0f, 0.0f, 1.0f)),
point_size_(2.0f),
statusAttrib_(_statusAttrib),
colorAttrib_(_colorAttrib),
normalAttrib_(_normalAttrib) {
normalAttrib_(_normalAttrib),
materialNode_(_matNode) {
// Initialize rendering display list
init();
......@@ -114,7 +115,7 @@ void VolumeMeshNodeT<VolumeMeshT>::boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) {
template<class VolumeMeshT>
DrawModes::DrawMode VolumeMeshNodeT<VolumeMeshT>::availableDrawModes() const {
return (DrawModes::WIREFRAME | DrawModes::POINTS | DrawModes::SOLID_FLAT_SHADED);
return (DrawModes::WIREFRAME | DrawModes::POINTS | DrawModes::POINTS_COLORED | DrawModes::SOLID_FLAT_SHADED);
}
//----------------------------------------------------------------------------
......@@ -147,8 +148,7 @@ void VolumeMeshNodeT<VolumeMeshT>::draw_vertices(GLState& _state, const DrawMode
if (_drawMode & DrawModes::POINTS) {
// Set point size
float p_backup = _state.point_size();
glPointSize(point_size_);
glPointSize(materialNode_->point_size());
// draw all points
glBegin(GL_POINTS);
......@@ -166,8 +166,31 @@ void VolumeMeshNodeT<VolumeMeshT>::draw_vertices(GLState& _state, const DrawMode
}
}
glEnd();
} else if (_drawMode & DrawModes::POINTS_COLORED) {
glPointSize(p_backup);
// Set point size
glPointSize(materialNode_->point_size());
// draw all points
glBegin(GL_POINTS);
int n_vertices(mesh_.n_vertices());
for (int i = 0; i < n_vertices; ++i) {
Vec3d p = mesh_.vertex(VertexHandle(i));
if(is_inside(p)) {
// Skip selected
if(statusAttrib_[VertexHandle(i)].selected()) continue;
const Vec4f& c = colorAttrib_[VertexHandle(i)];
glColor4f(c[0], c[1], c[2], c[3]);
glVertex3d(p[0], p[1], p[2]);
}
}
glEnd();
}
}
......@@ -358,7 +381,7 @@ void VolumeMeshNodeT<VolumeMeshT>::draw_vertex_selection(GLState& _state, const
// Set point size
float p_backup = _state.point_size();
glPointSize(point_size_ * 3.0f);
glPointSize(materialNode_->point_size() * 3.0f);
// draw all points
glBegin(GL_POINTS);
......@@ -706,14 +729,14 @@ ACG::Vec4f VolumeMeshNodeT<VolumeMeshT>::get_valence_color_code(unsigned int _va
template<class VolumeMeshT>
void VolumeMeshNodeT<VolumeMeshT>::draw(GLState& _state, const DrawModes::DrawMode& _drawMode) {
// Update the geometry if something has changed
if(geom_changed_ || BaseNode::isDirty() || lastDrawMode_ != _drawMode)
update_geometry(_state, _drawMode);
// Update the selection if something has changed
if(selection_changed_ || BaseNode::isDirty() || lastDrawMode_ != _drawMode) {
if(geom_changed_ || BaseNode::isDirty() || lastDrawMode_ != _drawMode) {
update_selection(_state, _drawMode);
update_geometry(_state, _drawMode);
} else {
if(selection_changed_) {
update_selection(_state, _drawMode);
}
}
// Update the geometry if something has changed
......@@ -768,6 +791,11 @@ void VolumeMeshNodeT<VolumeMeshT>::draw(GLState& _state, const DrawModes::DrawMo
ACG::GLState::depthFunc(GL_LESS);
}
if(_drawMode & DrawModes::POINTS_COLORED) {
ACG::GLState::disable(GL_LIGHTING);
ACG::GLState::disable(GL_BLEND);
}
glCallList(geometryList_);
if(lighting) {
......
......@@ -68,7 +68,7 @@ VolumeMeshObject<MeshT>::VolumeMeshObject(const VolumeMeshObject& _object) :
meshNode_((OpenFlipper::Options::nogui() ?
NULL :
new ACG::SceneGraph::VolumeMeshNodeT<MeshT>(*mesh_, statusAttrib_, colorAttrib_,
normalAttrib_, NULL, "NEW VolumeMeshNode"))) {
normalAttrib_, materialNode(), materialNode(), "NEW VolumeMeshNode"))) {
init();
......@@ -79,12 +79,12 @@ template<class MeshT>
VolumeMeshObject<MeshT>::VolumeMeshObject(DataType _typeId) :
BaseObjectData(), mesh_(new MeshT()),
statusAttrib_(*mesh_),
colorAttrib_(*mesh_),
colorAttrib_(*mesh_, ACG::Vec4f(1.0f, 1.0f, 1.0f, 1.0f) /* Default color */),
normalAttrib_(*mesh_),
meshNode_((OpenFlipper::Options::nogui() ?
NULL :
new ACG::SceneGraph::VolumeMeshNodeT<MeshT>(*mesh_, statusAttrib_, colorAttrib_,
normalAttrib_, NULL, "NEW VolumeMeshNode"))) {
normalAttrib_, materialNode(), materialNode(), "NEW VolumeMeshNode"))) {
setDataType(_typeId);
init();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment