SHARE
TWEET

Geometry - interface

Archon Jun 2nd, 2011 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // (C) 2011 Tim Gurto
  2.  
  3. #ifndef GEOMETRY_H
  4. #define GEOMETRY_H
  5.  
  6. #include <map>
  7. #include "d3d_wrappers.h"
  8. #include "Shape.h"
  9.  
  10. typedef std::map<int, Shape> shapesIndex_t;
  11.  
  12. //Maintains a contiguous list of "shapes" (sets of vertices),
  13. //which can be independently transformed or removed.
  14.  
  15. class Geometry{
  16.  
  17.    const static size_t ARRAY_CHUNK_SIZE;
  18.    const static size_t VERTEX_BUFFER_SIZE;
  19.  
  20.    //a directory of shapes within the array
  21.    shapesIndex_t shapesIndex_;
  22.  
  23.    //next shape index; removed shapes' indices are not reclaimed
  24.    int nextIndex_;
  25.  
  26.    //the vertex array
  27.    CUSTOMVERTEX *array_;
  28.    size_t
  29.       arraySize_,
  30.       totalVertices_;
  31.  
  32.    
  33.  
  34. public:
  35.    Geometry(LPDIRECT3DVERTEXBUFFER9 *vertexBuffer = 0);
  36.    ~Geometry();
  37.  
  38.    int addShape(CUSTOMVERTEX* start, size_t size, D3DMATERIAL9 *material = 0); //returns index
  39.    void removeShape(int index);
  40.    
  41.    //copies vertices into the buffer
  42.    void pushBuffer() const;
  43.  
  44.    //renders geometry
  45.    void render() const;
  46.  
  47.    //transform shape
  48.    void translate(int index, float x, float y);
  49.    void rotate(int index, double angle);
  50.    void scale(int index, float x, float y);
  51.  
  52.    //debugging
  53.    void printShapes() const;
  54. };
  55.  
  56. #endif
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top