Go to the documentation of this file.00001
00004
00005
00006
00007
00008 #include "../../include/qglv/gl/headers.hpp"
00009 #include "../../include/qglv/objects/particles.hpp"
00010 #include "../../include/qglv/primitives/arrow.hpp"
00011
00012
00013
00014
00015
00016 namespace qglv {
00017
00018
00019
00020
00021
00022 Particles::Particles()
00023 : updated(false)
00024 , gl_id(-1)
00025 {
00026 }
00027
00028 Particles::~Particles()
00029 {
00030 if ( gl_id > 0 ) {
00031 glDeleteLists(gl_id, 1);
00032 }
00033 }
00034
00035 void Particles::add( std::vector< Sophus::SE3f > & newTransforms )
00036 {
00037 T = newTransforms;
00038 updated = true;
00039 }
00040
00041 bool Particles::empty()
00042 {
00043 return T.empty();
00044 }
00045
00046 void Particles::clear()
00047 {
00048 T.clear();
00049 updated = true;
00050 }
00051
00052 void Particles::draw() {
00053 if ( updated )
00054 {
00055 _glGenLists();
00056 }
00057 ::glCallList(gl_id);
00058 }
00059
00060 void Particles::_glGenLists()
00061 {
00062 if( gl_id < 0 ) gl_id = ::glGenLists(1);
00063 static const float draw_arrow_length = 0.3;
00064 static const float draw_arrow_radius = 0.01;
00065
00066 glNewList( gl_id, GL_COMPILE );
00067 glColor3f(0.8f, 0.4f, 0.4f);
00068
00069
00070 for( int i(0); i<T.size(); i++ )
00071 {
00072 arrow(T[i].inverse(),
00073 0.3 * draw_arrow_length,
00074 0.5 * draw_arrow_radius
00075 );
00076 }
00077
00078 glEndList();
00079 }
00080
00081
00082 }