30 ~FltToEggLevelState() {
32 for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
40 FltToEggLevelState::ParentNodes::
42 _axial_billboard =
nullptr;
43 _point_billboard =
nullptr;
61 FltGeometry::BillboardType type) {
63 bool is_identity = transform.almost_equal(LMatrix4d::ident_mat());
65 (type != FltGeometry::BT_axial &&
66 type != FltGeometry::BT_point)) {
74 pi = _parents.find(transform);
76 if (pi != _parents.end()) {
79 nodes =
new ParentNodes;
80 _parents.insert(Parents::value_type(transform, nodes));
84 case FltGeometry::BT_axial:
85 if (nodes->_axial_billboard ==
nullptr) {
86 nodes->_axial_billboard =
new EggGroup(name);
87 _egg_parent->
add_child(nodes->_axial_billboard);
88 nodes->_axial_billboard->set_billboard_type(EggGroup::BT_axis);
91 nodes->_axial_billboard->set_group_type(EggGroup::GT_instance);
94 return nodes->_axial_billboard;
96 case FltGeometry::BT_point:
97 if (nodes->_point_billboard ==
nullptr) {
98 nodes->_point_billboard =
new EggGroup(name);
99 _egg_parent->
add_child(nodes->_point_billboard);
100 nodes->_point_billboard->set_billboard_type(EggGroup::BT_point_world_relative);
103 nodes->_point_billboard->set_group_type(EggGroup::GT_instance);
106 return nodes->_point_billboard;
110 if (nodes->_plain ==
nullptr) {
115 nodes->_plain->set_group_type(EggGroup::GT_instance);
118 return nodes->_plain;
129 egg_group->set_group_type(EggGroup::GT_instance);
132 bool componentwise_ok = !_converter->_compose_transforms;
134 if (num_steps == 0) {
135 componentwise_ok =
false;
141 for (
int i = num_steps -1; i >= 0 && componentwise_ok; i--) {
143 if (step->
is_exact_type(FltTransformTranslate::get_class_type())) {
145 DCAST_INTO_V(trans, step);
146 if (!trans->get_delta().almost_equal(LVector3d::zero())) {
150 }
else if (step->
is_exact_type(FltTransformRotateAboutPoint::get_class_type())) {
152 DCAST_INTO_V(rap, step);
154 if (!rap->get_center().almost_equal(LVector3d::zero())) {
157 LVector3d axis = LCAST(
double, rap->get_axis());
159 if (!rap->get_center().almost_equal(LVector3d::zero())) {
164 }
else if (step->
is_exact_type(FltTransformRotateAboutEdge::get_class_type())) {
166 DCAST_INTO_V(rae, step);
168 if (!rae->get_point_a().almost_equal(LVector3d::zero())) {
171 LVector3d axis = rae->get_point_b() - rae->get_point_a();
173 if (!rae->get_point_a().almost_equal(LVector3d::zero())) {
178 }
else if (step->
is_exact_type(FltTransformScale::get_class_type())) {
180 DCAST_INTO_V(scale, step);
181 if (!scale->get_scale().almost_equal(LVecBase3(1.0f, 1.0f, 1.0f))) {
182 if (scale->has_center() &&
183 !scale->get_center().almost_equal(LVector3d::zero())) {
186 egg_group->
add_scale3d(LCAST(
double, scale->get_scale()));
187 if (scale->has_center() &&
188 !scale->get_center().almost_equal(LVector3d::zero())) {
193 }
else if (step->
is_exact_type(FltTransformPut::get_class_type())) {
195 DCAST_INTO_V(put, step);
197 if (!put->get_from_origin().almost_equal(LVector3d::zero())) {
201 look_at(q1, put->get_from_align() - put->get_from_origin(),
202 put->get_from_track() - put->get_from_origin(),
204 look_at(q2, put->get_to_align() - put->get_to_origin(),
205 put->get_to_track() - put->get_to_origin(),
208 LQuaterniond q = invert(q1) * q2;
210 if (!q.is_identity()) {
213 if (!put->get_to_origin().almost_equal(LVector3d::zero())) {
220 componentwise_ok =
false;
225 if (!componentwise_ok) {