1 #ifndef __GNUC__ 2 #pragma once 3 #endif 4 #ifndef __XR_OGF_H__ 5 #define __XR_OGF_H__ 6 7 #include <vector> 8 #include <string> 9 #include "xr_ogf_format.h" 10 #include "xr_geom_buf.h" 11 #include "xr_object.h" 12 13 namespace xray_re { 14 15 class xr_reader; 16 17 class xr_ogf: public xr_object { 18 public: 19 xr_ogf(ogf_version version); 20 virtual ~xr_ogf(); 21 22 // auto-detect version and load 23 static xr_ogf* load_ogf(const std::string& path); 24 25 virtual void clear(); 26 virtual bool load_ogf(const char* path, const std::string& name); 27 virtual void load_ogf(xr_reader& r) = 0; 28 virtual void to_object(); 29 30 class ogf_error: public xr_error {}; 31 32 virtual bool hierarchical() const = 0; 33 virtual bool skeletal() const = 0; 34 virtual bool animated() const = 0; 35 virtual bool progressive() const = 0; 36 virtual bool versioned() const = 0; 37 38 const std::string& path() const; 39 ogf_version version() const; 40 ogf_model_type model_type() const; 41 const fbox& bbox() const; 42 const fsphere& bsphere() const; 43 const std::vector<xr_ogf*>& children() const; 44 const std::vector<uint32_t>& children_l() const; 45 const std::vector<xr_ogf*>& lods() const; 46 virtual const std::string& texture() const; 47 virtual const std::string& shader() const; 48 virtual uint32_t texture_l() const = 0; 49 virtual uint32_t shader_l() const = 0; 50 virtual const xr_vbuf& vb() const; 51 virtual const xr_ibuf& ib() const; 52 const ogf4_lod_face* lod_faces() const; 53 54 struct bone_motion_io: public xr_bone_motion { 55 void insert_key(float time, const ogf_key_qr* value); 56 void insert_key(float time, const fvector3* value); 57 }; 58 59 protected: 60 virtual xr_surface* create_surface(const xr_raw_surface& raw_surface) const; 61 62 bool is_chunk_loaded(uint32_t id) const; 63 void set_chunk_loaded(uint32_t id); 64 void check_unhandled_chunks(xr_reader& r) const; 65 66 void load_texture(xr_reader& r); 67 68 protected: 69 uint32_t m_loaded; // mask of loaded chunks (mostly for debugging) 70 std::string m_path; // empty if embedded 71 72 ogf_version m_version; // OGF_HEADER 73 ogf_model_type m_model_type; 74 ogf_bbox m_bbox; // OGF_HEADER or OGF_BBOX (v3) 75 ogf_bsphere m_bsphere; // OGF_HEADER or OGF_BSPHERE (v3) 76 77 std::string m_texture; // OGF_TEXTURE 78 std::string m_shader; 79 80 xr_vbuf m_vb; // OGF_VERTICES/OGF_GCONTAINER/OGF_VCONTAINER 81 xr_ibuf m_ib; // OGF_INDICES/OGF_GCONTAINER/OGF_ICONTAINER 82 83 std::vector<xr_ogf*> m_children; // OGF_CHILDREN/OGF_CHILD_REFS 84 std::vector<uint32_t> m_children_l; // OGF_CHILDREN_L 85 86 std::vector<xr_ogf*> m_lods; // OGF_LODS and OGF_S_LODS 87 88 ogf4_lod_face m_lod_faces[8]; // OGF_LODDEF2 89 }; 90 TYPEDEF_STD_VECTOR_PTR(xr_ogf)91TYPEDEF_STD_VECTOR_PTR(xr_ogf) 92 93 inline bool xr_ogf::is_chunk_loaded(uint32_t id) const { return (m_loaded & (1 << id)) != 0; } set_chunk_loaded(uint32_t id)94inline void xr_ogf::set_chunk_loaded(uint32_t id) { m_loaded |= 1 << id; } 95 path()96inline const std::string& xr_ogf::path() const { return m_path; } version()97inline ogf_version xr_ogf::version() const { return m_version; } model_type()98inline ogf_model_type xr_ogf::model_type() const { return m_model_type; } bbox()99inline const fbox& xr_ogf::bbox() const { return m_bbox; } bsphere()100inline const fsphere& xr_ogf::bsphere() const { return m_bsphere; } children()101inline const xr_ogf_vec& xr_ogf::children() const { return m_children; } children_l()102inline const std::vector<uint32_t>& xr_ogf::children_l() const { return m_children_l; } lods()103inline const xr_ogf_vec& xr_ogf::lods() const { return m_lods; } texture()104inline const std::string& xr_ogf::texture() const { return m_texture; } shader()105inline const std::string& xr_ogf::shader() const { return m_shader; } vb()106inline const xr_vbuf& xr_ogf::vb() const { return m_vb; } ib()107inline const xr_ibuf& xr_ogf::ib() const { return m_ib; } lod_faces()108inline const ogf4_lod_face* xr_ogf::lod_faces() const { return m_lod_faces; } 109 110 } // end of namespace xray_re 111 112 #endif 113