1 #ifndef __GNUC__
2 #pragma once
3 #endif
4 #ifndef __XR_SCENE_OBJECTS_H__
5 #define __XR_SCENE_OBJECTS_H__
6 
7 #include <string>
8 #include "xr_scene_part.h"
9 #include "xr_vector3.h"
10 
11 namespace xray_re {
12 
13 // CCustomObject
14 
15 // common chunk ids
16 enum {
17 	CUSTOMOBJECT_CHUNK_PARAMS	= 0xf900,
18 	CUSTOMOBJECT_CHUNK_f902		= 0xf902,
19 	CUSTOMOBJECT_CHUNK_XFORM	= 0xf903,
20 	CUSTOMOBJECT_CHUNK_MOTION	= 0xf905,
21 	CUSTOMOBJECT_CHUNK_FLAGS	= 0xf906,
22 	CUSTOMOBJECT_CHUNK_NAME		= 0xf907,
23 	CUSTOMOBJECT_CHUNK_TIME		= 0xf908,
24 };
25 
26 // flag values for CUSTOMOBJECT_CHUNK_FLAGS
27 enum {
28 	COF_SELECTED	= 0x1,
29 	COF_VISIBLE	= 0x2,
30 	COF_LOCKED	= 0x4,
31 	COF_MOTIONABLE	= 0x8,		// has motions
32 };
33 
34 class xr_obj_motion;
35 
36 class xr_custom_object {
37 public:
38 				xr_custom_object(xr_scene& scene);
39 	virtual			~xr_custom_object();
40 	virtual void		load(xr_reader& r);
41 	virtual void		save(xr_writer& w) const;
42 
43 	virtual void		save_v12(xr_ini_writer* w) const;
44 
45 	tools_class_id		class_id() const;
46 	uint32_t&		co_flags();
47 	uint32_t		co_flags() const;
48 	std::string&		co_name();
49 	const std::string&	co_name() const;
50 	fvector3&		co_position();
51 	const fvector3&		co_position() const;
52 	fvector3&		co_rotation();
53 	const fvector3&		co_rotation() const;
54 	fvector3&		co_scale();
55 	const fvector3&		co_scale() const;
56 
57 protected:
58 				xr_custom_object(xr_scene& scene, tools_class_id class_id = TOOLS_CLASS_DEFAULT);
59 	xr_scene&		scene() const;
60 
61 private:
62 	xr_scene&		m_scene;
63 	tools_class_id		m_class_id;
64 
65 	uint32_t		m_flags;	// CUSTOMOBJECT_CHUNK_FLAGS
66 	std::string		m_name;		// CUSTOMOBJECT_CHUNK_NAME
67 	fvector3		m_position;	// CUSTOMOBJECT_CHUNK_XFORM
68 	fvector3		m_rotation;
69 	fvector3		m_scale;
70 	xr_obj_motion*		m_motion;	// CUSTOMOBJECT_CHUNK_MOTION
71 	float			m_time;		// CUSTOMOBJECT_CHUNK_TIME
72 };
73 
TYPEDEF_STD_VECTOR_PTR(xr_custom_object)74 TYPEDEF_STD_VECTOR_PTR(xr_custom_object)
75 
76 inline xr_scene& xr_custom_object::scene() const { return m_scene; }
class_id()77 inline tools_class_id xr_custom_object::class_id() const { return m_class_id; }
co_flags()78 inline uint32_t& xr_custom_object::co_flags() { return m_flags; }
co_flags()79 inline uint32_t xr_custom_object::co_flags() const { return m_flags; }
co_name()80 inline std::string& xr_custom_object::co_name() { return m_name; }
co_name()81 inline const std::string& xr_custom_object::co_name() const { return m_name; }
co_position()82 inline fvector3& xr_custom_object::co_position() { return m_position; }
co_position()83 inline const fvector3& xr_custom_object::co_position() const { return m_position; }
co_rotation()84 inline fvector3& xr_custom_object::co_rotation() { return m_rotation; }
co_rotation()85 inline const fvector3& xr_custom_object::co_rotation() const { return m_rotation; }
co_scale()86 inline fvector3& xr_custom_object::co_scale() { return m_scale; }
co_scale()87 inline const fvector3& xr_custom_object::co_scale() const { return m_scale; }
88 
89 class xr_scene_objects: public xr_scene_part {
90 public:
91 	virtual			~xr_scene_objects();
92 	virtual void		load(xr_reader& r);
93 	virtual void		save(xr_writer& w) const;
94 
95 	virtual void		save_v12(xr_ini_writer* w) const;
96 
97 	const xr_custom_object_vec&	objects() const;
98 	xr_custom_object_vec&		objects();
99 
100 protected:
101 				xr_scene_objects(xr_scene& scene, const char* file_name, scene_chunk_id chunk_id);
102 
103 private:
104 	xr_custom_object_vec	m_objects;
105 };
106 
objects()107 inline const xr_custom_object_vec& xr_scene_objects::objects() const { return m_objects; }
objects()108 inline xr_custom_object_vec& xr_scene_objects::objects() { return m_objects; }
109 
110 } // end of namespace xray_re
111 
112 #endif
113