animated_mesh.h

Go to the documentation of this file.
00001 // animated_mesh.h
00002 
00003 #ifndef ANIMATED_MESH_H
00004 #define ANIMATED_MESH_H
00005 
00006 #include <vector>
00007 #include <string>
00008 
00009 #define GLEW_STATIC 1
00010 #include <GL/glew.h>
00011 #include <GL/glut.h>
00012 
00013 //#include "vec2.h"
00014 //#include "vec3.h"
00015 //#include "quaternion2.h"
00016 
00017 #include <v3.hpp>
00018 #include <quaternion.hpp>
00019 
00021 struct AnimatedVertex
00022 {
00023   struct Part
00024     {
00025       unsigned bone;
00026       float    weight;
00027       cpe::v3     position;
00028     };
00029   Part parts[4];
00030 };
00031 
00033 class AnimatedMesh
00034 {
00035   GLint weight0_index;
00036   GLint weight1_index;
00037   GLint weight2_index;
00038   GLint weight3_index;
00039   GLint bones_index;
00040 
00041   GLuint program;
00042   GLuint vbo_weights;
00043   GLuint vbo_bones;
00044   GLuint vbo_textures;
00045   GLuint vbo_indices;
00046   std::vector<AnimatedVertex> vertices;
00047   std::vector<GLuint>         indices;
00048   std::vector<GLfloat>        tex_coords;
00049   std::vector<GLfloat>        vertex_attrib0123;
00050   std::vector<GLfloat>        vertex_attrib4;
00051 public:
00052   void load (const std::string        &filename);
00053   void draw (const std::vector<cpe::v3> &skel_pos, const std::vector<cpe::quaternion> &skel_orient, bool update);
00054   void draw_cpu (const std::vector<cpe::v3> &skel_pos, const std::vector<cpe::quaternion> &skel_orient, bool update);
00055 
00056   void setup_shader(const std::string& vertex_shader,const std::string& fragment_shader);
00057 };
00058 
00059 #endif
Generated on Tue Dec 28 10:12:04 2010 by  doxygen 1.6.3