22 _is_transform_2d(true),
23 _transform(LMatrix4d::ident_mat())
32 _is_transform_2d(copy._is_transform_2d),
33 _components(copy._components),
34 _transform(copy._transform)
43 _is_transform_2d = copy._is_transform_2d;
44 _components = copy._components;
45 _transform = copy._transform;
61 _components.push_back(Component(CT_translate2d));
62 _components.back()._vec2 =
new LVecBase2d(translate);
63 _transform *= LMatrix4d::translate_mat(LVector3d(translate[0], translate[1], 0.0));
72 _is_transform_2d =
false;
73 _components.push_back(Component(CT_translate3d));
74 _components.back()._vec3 =
new LVecBase3d(translate);
75 _transform *= LMatrix4d::translate_mat(translate);
85 _components.push_back(Component(CT_rotate2d, angle));
86 _transform *= LMatrix4d::rotate_mat_normaxis(angle, LVector3d(0.0, 0.0, 1.0));
96 _is_transform_2d =
false;
97 _components.push_back(Component(CT_rotx, angle));
98 _transform *= LMatrix4d::rotate_mat_normaxis(angle, LVector3d(1.0, 0.0, 0.0));
108 _is_transform_2d =
false;
109 _components.push_back(Component(CT_roty, angle));
110 _transform *= LMatrix4d::rotate_mat_normaxis(angle, LVector3d(0.0, 1.0, 0.0));
120 _is_transform_2d =
false;
121 _components.push_back(Component(CT_rotz, angle));
122 _transform *= LMatrix4d::rotate_mat_normaxis(angle, LVector3d(0.0, 0.0, 1.0));
132 _is_transform_2d =
false;
133 LVector3d normaxis = normalize(axis);
134 _components.push_back(Component(CT_rotate3d, angle));
135 _components.back()._vec3 =
new LVecBase3d(normaxis);
136 _transform *= LMatrix4d::rotate_mat(angle, normaxis);
146 _is_transform_2d =
false;
156 _is_transform_2d =
false;
157 _components.push_back(Component(CT_scale2d));
158 _components.back()._vec2 =
new LVecBase2d(scale);
159 _transform *= LMatrix4d::scale_mat(LVecBase3d(scale[0], scale[1], 1.0));
168 _is_transform_2d =
false;
169 _components.push_back(Component(CT_scale3d));
170 _components.back()._vec3 =
new LVecBase3d(scale);
171 _transform *= LMatrix4d::scale_mat(scale);
180 _components.push_back(Component(CT_uniform_scale, scale));
181 _transform *= LMatrix4d::scale_mat(scale);
189 write(std::ostream &out,
int indent_level,
const std::string &label)
const {
190 indent(out, indent_level) << label <<
" {\n";
193 for (
int i = 0; i < num_components; i++) {
196 indent(out, indent_level + 2)
201 indent(out, indent_level + 2)
206 indent(out, indent_level + 2)
211 indent(out, indent_level + 2)
216 indent(out, indent_level + 2)
221 indent(out, indent_level + 2)
226 indent(out, indent_level + 2)
232 indent(out, indent_level + 2)
237 indent(out, indent_level + 2)
241 case CT_uniform_scale:
242 indent(out, indent_level + 2)
247 indent(out, indent_level + 2) <<
"<Matrix3> {\n";
249 indent(out, indent_level + 2) <<
"}\n";
253 indent(out, indent_level + 2) <<
"<Matrix4> {\n";
255 indent(out, indent_level + 2) <<
"}\n";
264 indent(out, indent_level) <<
"}\n";
271 internal_clear_transform() {
272 _is_transform_2d =
true;
274 _transform = LMatrix4d::ident_mat();
282 internal_add_matrix(
const LMatrix3d &mat) {
283 _components.push_back(Component(CT_matrix3));
284 _components.back()._mat3 =
new LMatrix3d(mat);
285 LMatrix4d mat4(mat(0, 0), mat(0, 1), 0.0, mat(0, 2),
286 mat(1, 0), mat(1, 1), 0.0, mat(1, 2),
288 mat(2, 0), mat(2, 1), 0.0, mat(2, 2));
297 internal_add_matrix(
const LMatrix4d &mat) {
298 _is_transform_2d =
false;
299 _components.push_back(Component(CT_matrix4));
300 _components.back()._mat4 =
new LMatrix4d(mat);
310 transform_changed() {
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.