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) {
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
int get_num_transform_steps() const
Returns the number of individual steps that define the net transform on this bead as returned by set_...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
FltTransformRecord * get_transform_step(int n)
Returns the nth individual step that defines the net transform on this bead.
A base class for nodes in the hierarchy that are not leaf nodes.
const LMatrix4d & get_transform() const
Returns the single-precision 4x4 matrix that represents the transform applied to this bead,...
A base class for any of a broad family of flt records that represent particular beads in the hierarch...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
bool has_transform() const
Returns true if the bead has been transformed, false otherwise.
EggGroupNode * get_synthetic_group(const std::string &name, const FltBead *transform_bead, FltGeometry::BillboardType type=FltGeometry::BT_none)
Sometimes it is necessary to synthesize a group within a particular EggGroup, for instance to insert ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
void set_transform(const FltBead *flt_bead, EggGroup *egg_group)
Sets up the group to reflect the transform indicated by the given record, if any.