ScummVM API documentation
te_3d_object2.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef TETRAEDGE_TE_TE_3D_OBJECT2_H
23#define TETRAEDGE_TE_TE_3D_OBJECT2_H
24
25#include "common/array.h"
26#include "tetraedge/te/te_color.h"
27#include "tetraedge/te/te_i_3d_object2.h"
28#include "tetraedge/te/te_matrix4x4.h"
29#include "tetraedge/te/te_quaternion.h"
30#include "tetraedge/te/te_object.h"
31#include "tetraedge/te/te_signal.h"
32#include "tetraedge/te/te_vector3f32.h"
33
34namespace Tetraedge {
35
36class Te3DObject2 : public TeI3DObject2, public TeObject {
37public:
39 virtual ~Te3DObject2();
40
41 // note, probably should be Te*I*3DObject2 args here
42 virtual void addChild(Te3DObject2 *newChild);
43 virtual void addChildBefore(Te3DObject2 *newChild, const Te3DObject2 *ref);
44 virtual Te3DObject2 *child(int offset);
45 int childCount() {
46 return _children.size();
47 }
48
49 int childIndex(Te3DObject2 *childToFind) const;
50
51 const Common::Array<Te3DObject2 *> &childList() const {
52 return _children;
53 }
54
55 bool childListChanged() const {
56 return _childListChanged;
57 }
58
59 const TeColor &color() const {
60 return _color;
61 }
62
63 bool colorInheritance() const {
64 return _colorInheritance;
65 }
66
67 /* Note: Added control for includesName not in original as Syberia 2 data format uses
68 the file name as the model name. */
69 static void deserialize(Common::ReadStream &stream, Te3DObject2 &dest, bool includesName = true);
70 static void serialize(Common::WriteStream &stream, Te3DObject2 &src);
71
72 virtual void draw() {}
73 const Common::String &name() const {
74 return _name;
75 }
76
77 virtual bool onParentWorldColorChanged();
78 bool onParentWorldTransformationMatrixChanged();
79 bool onWorldVisibleChangedSlot();
80 TeSignal0Param &onPositionChanged() {
81 return _onPositionChangedSignal;
82 }
83 TeSignal0Param &onSizeChanged() {
84 return _onSizeChangedSignal;
85 }
86 TeSignal0Param &onWorldColorChanged() {
87 return _onParentWorldColorChangedSignal;
88 }
89 TeSignal0Param &onWorldTransformationMatrixChanged() {
90 return _onParentWorldTransformationMatrixChangedSignal;
91 }
92 TeSignal0Param &onWorldVisibleChanged() {
93 return _onWorldVisibleChangedSlotSignal;
94 }
95
96 Te3DObject2 *parent() {
97 return _parent;
98 }
99 virtual TeVector3f32 position() {
100 return _position;
101 }
102 virtual void removeChild(Te3DObject2 *toRemove);
103 virtual void removeChildren();
104 void rotate(const TeQuaternion &rot);
105 const TeQuaternion &rotation() {
106 return _rotation;
107 }
108 const TeVector3f32 &scale() const {
109 return _scale;
110 }
111 virtual void setColor(const TeColor &col);
112 virtual void setColorInheritance(bool val) {
113 _colorInheritance = val;
114 }
115 virtual bool setName(const Common::String &newName) {
116 _name = newName;
117 return true;
118 }
119 virtual void setParent(Te3DObject2 *newparent); // note, probably should be Te*I*3DObject2 arg
120 virtual void setPosition(const TeVector3f32 &pos);
121 virtual void setPositionFast(const TeVector3f32 &pos);
122 virtual void setRotation(const TeQuaternion &rot);
123 virtual void setScale(const TeVector3f32 &newScale);
124 virtual void setSize(const TeVector3f32 &newSize);
125 void setVisible(bool visible);
126 virtual void setZPosition(float zpos);
127 virtual TeVector3f32 size() {
128 return _size;
129 }
130 TeMatrix4x4 transformationMatrix();
131 virtual void translate(const TeVector3f32 &vec);
132 virtual void updateZ() {};
133 virtual bool visible() const {
134 return _visible;
135 }
136
137 TeColor worldColor();
138 virtual TeVector3f32 worldPosition();
139 TeQuaternion worldRotation();
140 TeVector3f32 worldScale();
141 virtual TeMatrix4x4 worldTransformationMatrix();
142 virtual bool worldVisible();
143 virtual float xSize() { return _size.x(); };
144 virtual float ySize() { return _size.y(); };
145 virtual float zSize() { return _size.z(); };
146
147 static bool loadAndCheckFourCC(Common::ReadStream &stream, const char *str);
148 static Common::String deserializeString(Common::ReadStream &stream);
149 static void deserializeVectorArray(Common::ReadStream &stream, Common::Array<TeVector3f32> &dest);
150 static void deserializeUintArray(Common::ReadStream &stream, Common::Array<uint> &dest);
151
152protected:
153 TeVector3f32 _size;
154 TeVector3f32 _position;
155 TeQuaternion _rotation;
156 TeVector3f32 _scale;
157
158private:
160 bool _childListChanged;
161 TeColor _color;
162 bool _colorInheritance;
163 Common::String _name;
164 Te3DObject2 *_parent;
165 bool _visible;
166
167 TeSignal0Param _childListChangedSignal;
168 TeSignal0Param _onWorldVisibleChangedSlotSignal;
169 TeSignal0Param _onPositionChangedSignal;
170 TeSignal0Param _onSizeChangedSignal;
171 TeSignal0Param _onParentWorldColorChangedSignal;
172 TeSignal0Param _onParentWorldTransformationMatrixChangedSignal;
173
174 TeICallback0ParamPtr _onWorldVisibleChangedParentCallback;
175 TeICallback0ParamPtr _onWorldTransformationMatrixChangedParentCallback;
176 TeICallback0ParamPtr _onWorldColorChangedParentCallback;
177
178};
179
180} // end namespace Tetraedge
181
182#endif // TETRAEDGE_TE_TE_3D_OBJECT2_H
Definition: array.h:52
Definition: stream.h:385
Definition: str.h:59
Definition: stream.h:77
Definition: te_3d_object2.h:36
Definition: te_color.h:30
Definition: te_i_3d_object2.h:27
Definition: te_matrix4x4.h:37
Definition: te_object.h:29
Definition: te_quaternion.h:32
Definition: te_signal.h:40
Definition: te_vector3f32.h:33