SolidTree.h

00001 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
00002 /* 
00003  * Copyright (C) 2008 Micha Hersch, EPFL
00004  * RobotCub Consortium, European Commission FP6 Project IST-004370
00005  * email:   micha.hersch@robotcub.org
00006  * website: www.robotcub.org
00007  * Permission is granted to copy, distribute, and/or modify this program
00008  * under the terms of the GNU General Public License, version 2 or any
00009  * later version published by the Free Software Foundation.
00010  *
00011  * A copy of the license can be found at
00012  * http://www.robotcub.org/icub/license/gpl.txt
00013  *
00014  * This program is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
00017  * Public License for more details
00018  */
00019 #ifndef __SOLIDTREE_H__
00020 #define __SOLIDTREE_H__
00021 
00022 
00023 #include "TreeParser.h"
00024 #include "Geometry.h"
00025 #include "mathlib.h"
00026 
00027 //#ifndef PLANNER_VERSION
00028 #ifndef LIGHT_VERSION
00029 #include "GLTools.h"
00030 #include <GL/glut.h>
00031 #endif
00032 
00033 #include <vector>
00034 #include <string>
00035 using namespace std;
00036 
00037 class CMesh;
00038 typedef CMesh *pCMesh;
00039 
00040 class CSolid
00041 {
00042 public:
00043   CRef_t         m_ref;
00044 
00045   CVector3_t     m_position;
00046 
00047   CVector3_t     m_size;
00048   CVector3_t     m_color;
00049 
00050   string         m_name;
00051 
00052   pCMesh          m_mesh;
00053 public:
00054   CSolid();
00055   virtual ~CSolid();
00056   virtual void Update();
00057   virtual void AddMesh(pCMesh mesh);
00058 };
00059 typedef CSolid CSolid_t, *pCSolid_t;
00060 
00061 
00062 
00063 class CSolidTree;
00064 typedef CSolidTree CSolidTree_t, *pCSolidTree_t;
00065 
00066 typedef vector<pCSolidTree_t> CSolidTreeList_t;
00067 
00068 
00069 class CSolidTree : public CSolid
00070 {
00071 public:
00072   CSolidTreeList_t m_next;
00073 
00074 public:
00075   CSolidTree();
00076   //  CsolidTree(CSolidTree *tree); // to be checked
00077   CSolidTree(pTree config);
00078   virtual ~CSolidTree();
00079   void AddSolid(pCSolidTree_t newSolid);
00080 
00081   virtual void Update();
00082   virtual void AddMesh(pCMesh mesh);
00083   pCSolidTree_t Find(string name);
00084 };
00085 
00086 
00087 // Triangles
00088 typedef int Triangle[3];
00089 typedef struct{
00090   Triangle m_Triangle;
00091 } CTriangle_ext_t;
00092 typedef vector<CTriangle_ext_t> CTriangle_List_t;
00093 
00094 class CMesh;
00095 typedef CMesh *pCMesh;
00096 
00097 // SkinMesh
00098 class SkinMesh
00099 {
00100 public:
00101   vector<int>   m_Index;
00102   vector<float> m_Weight;
00103   CRef_t        m_Ref;
00104   string        m_Name;
00105 
00106   pCRef_t       m_ExtRef;
00107 
00108   pCMesh        m_Mesh;
00109 
00110 public:
00111   SkinMesh(pCMesh mesh);
00112   SkinMesh(pCMesh mesh, pTree config);
00113 
00114   void Render();
00115   void SetExtRef(pCRef_t ref);
00116 }; 
00117 typedef SkinMesh *pSkinMesh;
00118 typedef vector<pSkinMesh> SkinMesh_List;
00119 
00120 
00121 // Mesh
00122 class CMesh
00123 {
00124 public:
00125   CVector3_List_t   m_Vertices;  
00126   CVector3_List_t   m_Normals;  
00127   CTriangle_List_t  m_Triangles;
00128 
00129   SkinMesh_List     m_SkinMeshes;
00130 
00131   CVector3_List_t   m_SkinVertices;
00132   CVector3_List_t   m_SkinNormals;  
00133 
00134   bool              m_DrawWireFrame;
00135   bool              m_DrawSolid;
00136 
00137 
00138 public:
00139   CMesh();
00140   CMesh(pTree config);
00141 #ifndef LIGHT_VERSION
00142   void Render();
00143 #endif
00144 };
00145 
00146 
00147 #ifndef LIGHT_VERSION
00148 class CSolidRenderer
00149 {
00150   pCSolid_t m_solid;
00151 
00152 public:
00153   bool      m_drawOrient;
00154   bool      m_drawRef;
00155 
00156  public:
00157   CSolidRenderer(pCSolid_t newSolid);
00158   virtual ~CSolidRenderer();
00159   void RenderBegin();
00160   void RenderEnd(); 
00161   virtual void Render();
00162   void DrawRef();
00163   void DrawOrient();
00164 };
00165 
00166 
00167 
00168 
00169 class CSolidTreeRenderer;
00170 typedef CSolidTreeRenderer CSolidTreeRenderer_t, *pCSolidTreeRenderer_t;
00171 
00172 typedef vector<pCSolidTreeRenderer_t> CSolidTreeRendererList_t;
00173 
00174 class CSolidTreeRenderer : public CSolidRenderer
00175 {
00176   CSolidTreeRendererList_t m_next;
00177 
00178  public:
00179   CSolidTreeRenderer(pCSolidTree_t newSolidTree);
00180   virtual ~CSolidTreeRenderer();
00181   virtual void Render();
00182 };
00183 
00184 #endif
00185 #endif
 All Data Structures Functions Variables

Generated on Wed Sep 22 16:51:25 2010 for Body_Schema_Learning by  doxygen 1.6.1