CloudyDay
 All Classes Functions Variables Enumerations
CSGObject.h
1 #pragma once
2 #include <GL/glew.h>
3 #include <carve/interpolator.hpp>
4 #include <carve/csg_triangulator.hpp>
5 
6 #include <osg/Vec2>
7 #include <osg/Vec3>
8 
9 #include <osg/Geometry>
10 #include <osg/PrimitiveSet>
11 
12 struct tex_t {
13  float u;
14  float v;
15 
16  tex_t() : u(0.0f), v(0.0f) { }
17  tex_t(float _u, float _v) : u(_u), v(_v) { }
18  };
19 
20 namespace osgCloudyDay
21 {
25  class CSGObject
26  {
27  public:
28  enum CSGOperation{
29  CSG_MERGE,
30  CSG_UNION,
31  CSG_INTERSECT,
32  CSG_A_MINUS_B,
33  CSG_B_MINUS_A
34  };
35 
36  public:
40  CSGObject(void);
44  ~CSGObject(void);
45 
46  osg::ref_ptr<osg::Geometry> Perform(osg::Geometry* m1, osg::Geometry* m2, unsigned int operation);
47  osg::ref_ptr<osg::Geometry> Perform(osg::ref_ptr<osg::Geometry> m1, std::vector<osg::ref_ptr<osg::Geometry>> m2, unsigned int operation);
48 
49  carve::mesh::MeshSet<3> *texturedCube( carve::interpolate::FaceVertexAttr<tex_t> &fv_tex,
50  carve::interpolate::FaceAttr<GLuint> &f_tex_num,
51  const carve::math::Matrix &transform = carve::math::Matrix::IDENT());
52 
53  osg::Geometry* TestScene();
54 
55  carve::mesh::MeshSet<3>* SetGeometry(osg::Geometry *mesh);
56  osg::ref_ptr<osg::Geometry> GetGeometry(carve::mesh::MeshSet<3> *mesh);
57  };
58 }