Commit 0eed2ffd authored by Christopher Tenter's avatar Christopher Tenter
Browse files

Added per vertex picking buffer query.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12008 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 056f4e59
......@@ -1147,12 +1147,16 @@ void DrawMeshT<Mesh>::updatePickingVertices(ACG::GLState& _state,
unsigned int idx = 0;
// Adjust size of the color buffer to the number of vertices in the mesh
pickVertColBuf_.resize( mesh_.n_vertices() );
pickVertBuf_.resize( mesh_.n_vertices() );
// Get the right picking colors from the gl state and add them per vertex to the color buffer
typename Mesh::ConstVertexIter v_it(mesh_.vertices_begin()), v_end(mesh_.vertices_end());
for (; v_it!=v_end; ++v_it, ++idx)
pickVertBuf_[idx] = _state.pick_get_name_color(idx + _offset);
{
pickVertColBuf_[idx] = _state.pick_get_name_color(idx + _offset);
pickVertBuf_[idx] = mesh_.point(mesh_.vertex_handle(idx));
}
}
......
......@@ -392,18 +392,37 @@ public:
* @return pointer to the first element of the picking buffer
*/
ACG::Vec4uc * pickVertexColorBuffer(){
if ( pickVertColBuf_.size() >0 )
return &(pickVertColBuf_)[0];
else {
std::cerr << "Illegal request to pickVertexColorBuffer when buffer is empty!" << std::endl;
return 0;
}
};
/** \brief get a pointer to the per vertex picking vertex buffer
*
* This function will return a pointer to the first element of the picking buffer.
* Use updatePickingVertices to update the buffer before you render it via
* glVertexPointer.
*
* @return pointer to the first element of the picking buffer
*/
ACG::Vec3f * pickVertexBuffer(){
if ( pickVertBuf_.size() >0 )
return &(pickVertBuf_)[0];
else {
std::cerr << "Illegal request to pickVertexColorBuffer when buffer is empty!" << std::endl;
std::cerr << "Illegal request to pickVertexBuffer when buffer is empty!" << std::endl;
return 0;
}
};
private:
/// The vertex buffer used for vertex picking
std::vector< ACG::Vec3f > pickVertBuf_;
/// The color buffer used for vertex picking
std::vector< ACG::Vec4uc > pickVertBuf_;
std::vector< ACG::Vec4uc > pickVertColBuf_;
......
Supports Markdown
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