SilhouettePainter.cpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *  SilhouettePainter.cpp
00003  *
00004  *  (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de>
00005  *           Universitaet Koblenz-Landau
00006  *
00007  *  Additional information:
00008  *  $Id: $
00009  *******************************************************************************/
00010 
00011 #include "SilhouettePainter.h"
00012 
00013 
00014 #include "Messages/SilhouettesM.h"
00015 
00016 
00017 
00018 #include <QtOpenGL>
00019 #include <GL/glut.h>
00020 
00021 #include "Architecture/Config/Config.h"
00022 
00023 #define THIS SilhouettePainter
00024 
00025 THIS::THIS() : PainterPlugin( )
00026 {
00027     setName ( "Silhouette Painter & Following" );
00028     m_PersonModel = SceneGraph ( "config/PersonTorso.xml" );
00029     m_HeadWithHandModel= SceneGraph ( "config/PersonHeadWithHand.xml" );
00030     m_HandModel= SceneGraph ( "config/PersonHand.xml" );
00031 }
00032 
00033 
00034 THIS::~THIS()
00035 {
00036 }
00037 
00038 
00039 void THIS::processMessage ( Message* newMessage )
00040 {
00041     PainterPlugin::processMessage ( newMessage );
00042     switch ( newMessage->getType() )
00043     {
00044 
00045     case MessageTypes::SILHOUETTES_M:
00046     {
00047         if ( SilhouettesM* message = Message::castTo<SilhouettesM> ( newMessage ) )
00048         {
00049             // std::cout<<"get silhouettesM in SilhouettePainter\n";
00050             m_SilhouettesPositions3d = message->get3DPositions( );
00051             m_HeadsWithHand = message->getheadsWithHands();
00052             m_Hands = message->gethands();
00053             requestRedraw();
00054         }
00055         break;
00056     }
00057 
00058     default:
00059         break;
00060 
00061     }
00062 }
00063 
00064 void THIS::paint ( float next2DLayer )
00065 {
00066 
00067     for ( unsigned i=0; i<m_SilhouettesPositions3d.size(); i++ )
00068     {
00069         BaseLib::Math::Vec3d position =  m_SilhouettesPositions3d[i];
00070 
00071         m_PersonModel.setTranslationMatrix("Person.position",position);
00072         m_PersonModel.paintGl();
00073 
00074         glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL );
00075         glColor4f ( 1.0, 1.0, 0.0, 0.5 );
00076         float radius = 2.0;
00077         glPushMatrix();
00078         glTranslatef( position.x, position.y, 0.0 );
00079         glutSolidCone( radius, 300, 36, 1 );
00080         glPopMatrix();
00081     }
00082 
00083     for ( unsigned i=0; i<m_Hands.size(); i++ )
00084     {
00085         BaseLib::Math::Vec3d position =  m_Hands[i];
00086 
00087         m_HandModel.setTranslationMatrix("Person.position",position);
00088         m_HandModel.paintGl();
00089 
00090         glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL );
00091         glColor4f ( 1.0, 1.0, 0.0, 0.5 );
00092         float radius = 2.0;
00093         glPushMatrix();
00094         glTranslatef( position.x, position.y, 0.0 );
00095         glutSolidCone( radius, 300, 36, 1 );
00096         glPopMatrix();
00097     }
00098 
00099     for ( unsigned i=0; i<m_HeadsWithHand.size(); i++ )
00100     {
00101         BaseLib::Math::Vec3d position =  m_HeadsWithHand[i];
00102 
00103         m_HeadWithHandModel.setTranslationMatrix("Person.position",position);
00104         m_HeadWithHandModel.paintGl();
00105 
00106         glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL );
00107         glColor4f ( 1.0, 1.0, 0.0, 0.5 );
00108         float radius = 2.0;
00109         glPushMatrix();
00110         glTranslatef( position.x, position.y, 0.0 );
00111         glutSolidCone( radius, 300, 36, 1 );
00112         glPopMatrix();
00113     }
00114 
00115 
00116 
00117 }
00118 
00119 
00120 
00121 #undef THIS


obj_rec_gui
Author(s): AGAS/agas@uni-koblenz.de
autogenerated on Mon Oct 6 2014 02:53:43