00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_GFX_EXPORTER_HH
00020 #define OST_GFX_EXPORTER_HH
00021
00022 #include <ost/geom/vec3.hh>
00023 #include <ost/geom/vec4.hh>
00024 #include <ost/geom/mat3.hh>
00025 #include <ost/geom/mat4.hh>
00026
00027 #include <ost/gfx/module_config.hh>
00028
00029 namespace ost { namespace gfx {
00030
00031 class Scene;
00032
00033 class DLLEXPORT_OST_GFX Exporter
00034 {
00035 public:
00036 enum NodeType {
00037 ROOT=1,
00038 GROUP=2,
00039 OBJ=3
00040 };
00041
00042 Exporter() :
00043 scale_(1.0),
00044 to_origin_(true)
00045 {}
00046 virtual ~Exporter() {}
00047 virtual void SceneStart(const Scene* scene) {}
00048 virtual void SceneEnd(const Scene* scene) {}
00049
00050 virtual void NodeStart(const std::string& name, NodeType t) {}
00051 virtual void NodeEnd(const std::string& name) {}
00052
00053
00054
00055 virtual void WriteVertexData(const float* v, const float* n, const float* c, const float* t,
00056 size_t stride, size_t count) {}
00057 virtual void WritePointData(const unsigned int* i, size_t count) {}
00058 virtual void WriteLineData(const unsigned int* ij, size_t count) {}
00059 virtual void WriteTriData(const unsigned int* ijk, size_t count) {}
00060 virtual void WriteQuadData(const unsigned int* ijkl, size_t count) {}
00061
00062
00063 void SetScale(float s) {scale_=s;}
00064 float GetScale() const {return scale_;}
00065
00066
00067
00068 void SetToOrigin(bool b) {to_origin_=b;}
00069 bool GetToOrigin() const {return to_origin_;}
00070
00071
00072 void SetupTransform(const Scene* scene);
00073
00074
00075 void TransformPosition(float* p) const;
00076 void TransformNormal(float* n) const;
00077
00078 private:
00079 float scale_;
00080 bool to_origin_;
00081 geom::Mat4 vertex_tf_;
00082 geom::Mat3 normal_tf_;
00083 };
00084
00085
00086
00087 }}
00088
00089 #endif