Advertisement
Caiwan

Untitled

Jan 29th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.86 KB | None | 0 0
  1. #ifndef __3D_RENDER_OBJECT__
  2. #define __3D_RENDER_OBJECT__
  3.  
  4. #include <string>
  5.  
  6. #include "../core/array.h"
  7. #include "../core/vectors.h"
  8.  
  9. #include "renderer.h"
  10. #include "bufferObject.h"
  11. #include "surface.h"
  12.  
  13. #include "../math/matrix.h"
  14.  
  15. namespace FWrender {
  16.     typedef vec3float verticies_t;  // simplifcation
  17.     typedef vec3float normals_t;
  18.     typedef vec3ushort meshes_t;
  19.  
  20.     class mesh {
  21.         protected:
  22.             array_t<verticies_t>    vertList;   // mesh data
  23.             array_t<meshes_t>       meshList;   // .
  24.             array_t<normals_t>      normList;   // *
  25.             array_t<texUV_t>        uvList;     // o
  26.            
  27.             std::string name;
  28.            
  29.             FWrender::vbo_create * global_vbo;
  30.  
  31.         public:
  32.             mesh();
  33.             virtual ~mesh();
  34.            
  35.             // push
  36.             unsigned int pushVert(verticies_t* vert, unsigned int len);
  37.             unsigned int pushMesh(meshes_t* mesh, unsigned int len, unsigned int offset);
  38.             unsigned int pushTextureUV(texUV_t* texuv, unsigned int len);
  39.            
  40.             //void pushNormals(normals_t* norm, unsigned int len);
  41.  
  42.             //get
  43.             void getVertV(verticies_t *&ptr, unsigned int &len);
  44.             void getMeshV(meshes_t *&ptr, unsigned int &len);
  45.             void getNormV(normals_t *&ptr, unsigned int &len);
  46.             void getTexuvV(texUV_t *&ptr, unsigned int &len);
  47.            
  48.             // build
  49.             void calcNormals();                 // simply calc normals (retuns if already done)
  50.             void calcNormals(bool forced);      // force normal calculating if true.
  51.  
  52.             void buildArray();                  // Builds arrays
  53.             void buildVertArray();              // Builds vertex array only
  54.            
  55.             //draw
  56.             void draw();
  57.             void drawmesh(unsigned short* mesh, unsigned int len);
  58.  
  59.             //delete
  60.             void deleteArray();
  61.     };
  62.    
  63.     class modelSurface{
  64.         private:
  65.             FWrender::material mat;
  66.             FWrender::texture *tex;
  67.  
  68.             array_t<meshes_t> meshList;
  69.             array_t<meshes_t> faceList;
  70.  
  71.         public:
  72.             modelSurface();
  73.             ~modelSurface();
  74.  
  75.             //set
  76.             //void setMaterial(FWrender::material &m);
  77.             void setMaterial(FWrender::material *m);
  78.             //void setTexture(FWrender::texture &t);
  79.             void setTexture(FWrender::texture *t);
  80.             //void setTexture(FWrender::texture &t, int layer);
  81.             void setTexture(FWrender::texture *t, int layer);
  82.  
  83.             void pushFaceList(unsigned short *faces, int len);
  84.            
  85.             //get
  86.             void getMeshV(meshes_t *&ptr, unsigned int &len);
  87.  
  88.             //build
  89.             void buildMeshArray(meshes_t *ptr);
  90.  
  91.             //draw/bind
  92.             void bind();
  93.             void unbind();
  94.     };
  95.    
  96.     class model : public mesh{
  97.         private:
  98.             array_t<modelSurface> surfaces;
  99.             FWmath::localCoord_t modelview;
  100.  
  101.         public:
  102.             model();
  103.             virtual ~model();
  104.            
  105.             //set
  106.             void insertSurface();
  107.            
  108.             void setTexture(int num, FWrender::texture &t, int layer);
  109.             void setTexture(int num, FWrender::texture *t, int layer);
  110.  
  111.             void setMaterial(int num, FWrender::material &m);
  112.             void setMaterial(int num, FWrender::material *m);
  113.  
  114.             //get
  115.  
  116.             //draw
  117.             void draw();
  118.            
  119.             //..
  120.             void fetchDeleteArray();
  121.     };
  122. };
  123.  
  124. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement