• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/OpenTissue/OpenTissue/utility/gl/gl_draw_triangle.h

Go to the documentation of this file.
00001 #ifndef OPENTISSUE_OPENTISSUE_GL_GL_DRAW_TRIANGLE_H
00002 #define OPENTISSUE_OPENTISSUE_GL_GL_DRAW_TRIANGLE_H
00003 //
00004 // OpenTissue Template Library
00005 // - A generic toolbox for physics-based modeling and simulation.
00006 // Copyright (C) 2008 Department of Computer Science, University of Copenhagen.
00007 //
00008 // OTTL is licensed under zlib: http://opensource.org/licenses/zlib-license.php
00009 //
00010 #include <OpenTissue/configuration.h>
00011 
00012 #include <OpenTissue/utility/gl/gl.h>
00013 
00014 namespace OpenTissue
00015 {
00016 
00017   namespace gl
00018   {
00019     
00026     template<typename triangle_type>
00027     inline void DrawTriangle(triangle_type const & triangle, bool wireframe = false)
00028     {
00029       typedef typename triangle_type::vector3_type vector3_type;
00030 
00031       vector3_type const & p0 = triangle.p0();
00032       vector3_type const & p1 = triangle.p1();
00033       vector3_type const & p2 = triangle.p2();
00034 
00035       vector3_type n,v,u;
00036       v = p1 - p0;
00037       u = p2 - p1;
00038       n = unit( v % u);
00039       glBegin(wireframe?GL_LINE_LOOP:GL_POLYGON);
00040       glNormal3f((GLfloat)n[0],(GLfloat)n[1],(GLfloat)n[2]);
00041       glVertex3f((GLfloat)p0[0],(GLfloat)p0[1],(GLfloat)p0[2]);
00042       glNormal3f((GLfloat)n[0],(GLfloat)n[1],(GLfloat)n[2]);
00043       glVertex3f((GLfloat)p1[0],(GLfloat)p1[1],(GLfloat)p1[2]);
00044       glNormal3f((GLfloat)n[0],(GLfloat)n[1],(GLfloat)n[2]);
00045       glVertex3f((GLfloat)p2[0],(GLfloat)p2[1],(GLfloat)p2[2]);
00046       glEnd();
00047     }
00048 
00049   } // namespace gl
00050 
00051 } // namespace OpenTissue
00052 
00053 // OPENTISSUE_OPENTISSUE_GL_GL_DRAW_TRIANGLE_H
00054 #endif

Generated on Thu Dec 1 2011 12:53:40 for HUMIM Tracker by  doxygen 1.7.1