rtcRenderNode.cpp
Go to the documentation of this file.
00001 /*
00002 * Copyright (C) 2007
00003 * Robert Bosch Corporation
00004 * Research and Technology Center North America
00005 * Palo Alto, California
00006 *
00007 * All rights reserved.
00008 */
00009 
00010 /*--------------------------------------------------------------------
00011 * project ....: PUMA: Probablistic Unsupervised Model Acquisition
00012 * file .......: RenderNode.cpp
00013 * authors ....: Benjamin Pitzer
00014 * organization: Bosch, RTC
00015 * creation ...: 16.04.2007
00016 * revisions ..: $Id: RenderNode.cpp,v 1.2 2007/05/08 18:54:45 prb2pal Exp $
00017 */
00018 
00019 //== INCLUDES =================================================================
00020 #include "rtc/rtcRenderer.h"
00021 #include <GL/gl.h>
00022 #include "rtc/rtcRenderNode.h"
00023 
00024 //== NAMESPACES ===============================================================
00025 
00026 namespace rtc {
00027 
00028 //== IMPLEMENTATION ==========================================================
00029 
00030 // --------------------------------------------------
00031 // RenderNode::Parameters
00032 // --------------------------------------------------
00033 
00034 // default constructor
00035 RenderNode::Parameters::Parameters()
00036 {
00037   draw_faces = true;
00038   draw_vertices = false;
00039   draw_wireframe = false;
00040   use_vertex_colors = false;
00041   color_mode = NO_COLOR;
00042   highlite = false;
00043 }
00044 
00045 // copy constructor
00046 RenderNode::Parameters::Parameters(const Parameters& other)
00047 {
00048   copy(other);
00049 }
00050 
00051 // destructor
00052 RenderNode::Parameters::~Parameters()
00053 {
00054 }
00055 
00056 // copy member
00057 RenderNode::Parameters&
00058   RenderNode::Parameters::copy(const Parameters& other)
00059 {
00060   draw_faces = other.draw_faces;
00061   draw_vertices = other.draw_vertices;
00062   draw_wireframe = other.draw_wireframe;
00063   use_vertex_colors = other.use_vertex_colors;
00064   color_mode = other.color_mode;
00065   highlite = other.highlite;
00066   return *this;
00067 }
00068 
00069 // alias for copy member
00070 RenderNode::Parameters&
00071   RenderNode::Parameters::operator=(const Parameters& other)
00072 {
00073   return copy(other);
00074 }
00075 
00076 // clone member
00077 RenderNode::Parameters*
00078   RenderNode::Parameters::clone() const
00079 {
00080   return new Parameters(*this);
00081 }
00082 
00083 /*
00084 * read the RenderNode parameters
00085 */
00086 bool RenderNode::Parameters::read(std::istream& is)
00087 {
00088   return true;
00089 }
00090 
00091 /*
00092 * write the RenderNode parameters
00093 */
00094 bool RenderNode::Parameters::write(std::ostream& os) const
00095 {
00096   return true;
00097 }
00098 
00099 // --------------------------------------------------
00100 // RenderNode
00101 // --------------------------------------------------
00102 
00103 // constructor
00104 RenderNode::RenderNode(Renderer* renderer)
00105 {
00106   m_params = new Parameters();
00107   m_is_initialized = false;
00108   m_renderer = renderer;
00109 }
00110 
00111 // destructor
00112 RenderNode::~RenderNode()
00113 {
00114   if(m_params) delete m_params;
00115 }
00116 
00117 /* sets the Renderer's Parameters.
00118 The Renderer keeps its own copy of the given Parameters.*/
00119 bool RenderNode::setParameters(const RenderNode::Parameters& theParams)
00120 {
00121   if(m_params) delete m_params;
00122   m_params = 0;
00123   m_params = theParams.clone();
00124   return true;
00125 }
00126 
00127 /*
00128 * returns current Parameters.
00129 */
00130 const RenderNode::Parameters& RenderNode::getParameters() const
00131 {
00132   return *m_params;
00133 }
00134 
00135 /*
00136 * returns current Parameters.
00137 */
00138 RenderNode::Parameters& RenderNode::getParameters()
00139 {
00140   return *m_params;
00141 }
00142 
00143 void RenderNode::initialize()
00144 {
00145 }
00146 
00147 void RenderNode::rebuild()
00148 {
00149   clear();
00150   initialize();
00151 }
00152 
00153 void RenderNode::clear()
00154 {
00155 }
00156 
00157 void RenderNode::render()
00158 {
00159 }
00160 
00161 void RenderNode::preRender()
00162 {
00163   // apply transform
00164   glPushMatrix();
00165   Transformf t(m_transform.transposed());
00166   glMultMatrixf(&t.x[0]);
00167 
00168   if(m_params->highlite)
00169     glColor3f(1.0,1.0,0.0); // yellow
00170   else {
00171     switch(m_params->color_mode)
00172     {
00173     case Parameters::NO_COLOR:
00174       break;
00175     case Parameters::VERTEX_COLOR:
00176       //glColor3f(0.705f, 0.976f, 0.270f); // greenish
00177       glColor3f(1.0,1.0,1.0); // white
00178       break;
00179     case Parameters::TEXTURE_COLOR:
00180       glColor3f(1,1,1);
00181       break;
00182     default:
00183       glColor3f(1,1,1);
00184       break;
00185     }
00186   }
00187 
00188 }
00189 
00190 void RenderNode::postRender()
00191 {
00192   // reset transformation matrix
00193   glPopMatrix();
00194 }
00195 
00196 
00197 void RenderNode::setTransform(Transformf transform)
00198 {
00199   m_transform = transform;
00200 }
00201 
00202 const Transformf& RenderNode::getTransform()
00203 {
00204   return m_transform;
00205 }
00206 
00207 eRenderMode RenderNode::getRenderMode()
00208 {
00209   return m_renderer->getRenderMode();
00210 }
00211 
00212 void RenderNode::displayFaces(bool b)
00213 {
00214   m_params->draw_faces = b;
00215 }
00216 
00217 void RenderNode::displayVertices(bool b)
00218 {
00219   m_params->draw_vertices = b;
00220 }
00221 
00222 void RenderNode::displayWireframe(bool b)
00223 {
00224   m_params->draw_wireframe = b;
00225 }
00226 
00227 void RenderNode::setColorMode(Parameters::ColorMode b)
00228 {
00229   m_params->color_mode = b;
00230 }
00231 
00232 void RenderNode::setHighlite(bool b)
00233 {
00234   m_params->highlite = b;
00235 }
00236 
00237 
00238 //=============================================================================
00239 } // namespace puma
00240 //=============================================================================


rtc
Author(s): Benjamin Pitzer
autogenerated on Mon Oct 6 2014 10:07:35