$search
00001 /* 00002 * Copyright (C) 2008 00003 * Robert Bosch LLC 00004 * Research and Technology Center North America 00005 * Palo Alto, California 00006 * 00007 * All rights reserved. 00008 * 00009 *------------------------------------------------------------------------------ 00010 * project ....: PUMA: Probablistic Unsupervised Model Acquisition 00011 * file .......: MeshSet3DVBONode.h 00012 * authors ....: Zhexi Wang 00013 * organization: Robert Bosch LLC 00014 * creation ...: 02/04/2009 00015 * modified ...: $Date: 2009-02-02 12:17:10 -0800 (Mon, 02 Feb 2009) $ 00016 * changed by .: $Author: wg75pal $ 00017 * revision ...: $Revision: 772 $ 00018 */ 00019 #ifndef MESHSET3DVBONODE_H 00020 #define MESHSET3DVBONODE_H 00021 00022 #include <vector> 00023 #include <GL/gl.h> 00024 #include "rtc/rtcMeshSet3D.h" 00025 #include "rtc/rtcRenderNode.h" 00026 00027 namespace rtc { 00028 class MeshSet3DVBONode : public RenderNode 00029 { 00030 public: 00031 // default constructor 00032 MeshSet3DVBONode(Renderer* renderer, MeshSet3D* meshset); 00033 MeshSet3DVBONode(Renderer* renderer, const char* vbofilename); 00034 MeshSet3DVBONode(Renderer* renderer, FILE* fp); 00035 // destructor 00036 virtual ~MeshSet3DVBONode(); 00037 // rendering call 00038 virtual void render(); 00039 void loadToGPU(); 00040 void unloadGPU(); 00041 void writeToFile(const char *filename); 00042 void write(FILE* fp); 00043 00044 protected: 00045 // draws mesh as faces in vertex buffer mode 00046 virtual void drawFacesVBO(); 00047 // draws mesh as point cloud in vertex buffer mode 00048 virtual void drawPointsVBO(); 00049 // draws mesh as wireframe in vertex buffer mode 00050 virtual void drawWireFrameVBO(); 00051 00052 protected: 00053 public: 00054 int num_mesh; 00055 struct MeshVBO{ 00056 unsigned int flag; 00057 unsigned int num_vertices; 00058 unsigned int num_faces; 00059 GLuint position_buffer; 00060 unsigned int position_size; 00061 GLfloat *position_data; 00062 GLuint normal_buffer; 00063 unsigned int normal_size; 00064 GLfloat *normal_data; 00065 GLuint color_buffer; 00066 unsigned int color_size; 00067 GLubyte *color_data; 00068 GLuint texcoord_buffer; 00069 unsigned int texcoord_size; 00070 GLfloat *texcoord_data; 00071 GLuint index_buffer; 00072 unsigned int index_size; 00073 GLuint *index_data; 00074 unsigned int texture_size; 00075 GLubyte *texture_data; 00076 unsigned int texture_width, texture_height; 00077 GLuint texture_id; 00078 ~MeshVBO(); 00079 void read(FILE* fp); 00080 void write(FILE* fp); 00081 void loadGPU(); 00082 void unloadGPU(); 00083 void bind(unsigned int vbo); 00084 void unbind(unsigned int vbo); 00085 }; 00086 MeshVBO *meshvbos; 00087 00089 static std::vector<GLuint> gpubuffers; 00090 static std::vector<GLuint> gputextures; 00091 static void getGPUBuffer(GLuint &buffer); 00092 static void retGPUBuffer(GLuint &buffer); 00093 static void getTextureId(GLuint &texid); 00094 static void retTextureId(GLuint &texid); 00095 }; 00096 } 00097 #endif //MESHSET3DVBONODE_H