15 #include "fltToEggLevelState.h"
16 #include "fltToEggConverter.h"
17 #include "fltTransformTranslate.h"
18 #include "fltTransformRotateAboutPoint.h"
19 #include "fltTransformRotateAboutEdge.h"
20 #include "fltTransformScale.h"
21 #include "fltTransformPut.h"
33 ~FltToEggLevelState() {
35 for (pi = _parents.begin(); pi != _parents.end(); ++pi) {
45 FltToEggLevelState::ParentNodes::
70 FltGeometry::BillboardType type) {
74 (type != FltGeometry::BT_axial &&
75 type != FltGeometry::BT_point)) {
84 pi = _parents.find(transform);
86 if (pi != _parents.end()) {
89 nodes =
new ParentNodes;
90 _parents.insert(Parents::value_type(transform, nodes));
94 case FltGeometry::BT_axial:
96 nodes->_axial_billboard =
new EggGroup(name);
97 _egg_parent->
add_child(nodes->_axial_billboard);
98 nodes->_axial_billboard->set_billboard_type(EggGroup::BT_axis);
101 nodes->_axial_billboard->set_group_type(EggGroup::GT_instance);
104 return nodes->_axial_billboard;
106 case FltGeometry::BT_point:
108 nodes->_point_billboard =
new EggGroup(name);
109 _egg_parent->
add_child(nodes->_point_billboard);
110 nodes->_point_billboard->set_billboard_type(EggGroup::BT_point_world_relative);
113 nodes->_point_billboard->set_group_type(EggGroup::GT_instance);
116 return nodes->_point_billboard;
125 nodes->_plain->set_group_type(EggGroup::GT_instance);
128 return nodes->_plain;
141 egg_group->set_group_type(EggGroup::GT_instance);
144 bool componentwise_ok = !_converter->_compose_transforms;
146 if (num_steps == 0) {
147 componentwise_ok =
false;
154 for (
int i = num_steps -1; i >= 0 && componentwise_ok; i--) {
156 if (step->
is_exact_type(FltTransformTranslate::get_class_type())) {
158 DCAST_INTO_V(trans, step);
163 }
else if (step->
is_exact_type(FltTransformRotateAboutPoint::get_class_type())) {
165 DCAST_INTO_V(rap, step);
170 LVector3d axis = LCAST(
double, rap->get_axis());
177 }
else if (step->
is_exact_type(FltTransformRotateAboutEdge::get_class_type())) {
179 DCAST_INTO_V(rae, step);
184 LVector3d axis = rae->get_point_b() - rae->get_point_a();
191 }
else if (step->
is_exact_type(FltTransformScale::get_class_type())) {
193 DCAST_INTO_V(scale, step);
199 egg_group->
add_scale3d(LCAST(
double, scale->get_scale()));
206 }
else if (step->
is_exact_type(FltTransformPut::get_class_type())) {
208 DCAST_INTO_V(put, step);
214 look_at(q1, put->get_from_align() - put->get_from_origin(),
215 put->get_from_track() - put->get_from_origin(),
217 look_at(q2, put->get_to_align() - put->get_to_origin(),
218 put->get_to_track() - put->get_to_origin(),
223 if (!q.is_identity()) {
233 componentwise_ok =
false;
238 if (!componentwise_ok) {
This is the base class for all three-component vectors and points.
This is a 4-by-4 transform matrix.
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.
This is the base quaternion class.
const LMatrix4d & get_transform() const
Returns the single-precision 4x4 matrix that represents the transform applied to this bead...
bool is_exact_type(TypeHandle handle) const
Returns true if the current object is the indicated type exactly.
A base class for any of a broad family of flt records that represent particular beads in the hierarch...
bool almost_equal(const LVecBase3d &other, double threshold) const
Returns true if two vectors are memberwise equal within a specified tolerance.
int get_num_transform_steps() const
Returns the number of individual steps that define the net transform on this bead as returned by set_...
static const LVector3d & zero()
Returns a zero-length vector.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
bool almost_equal(const LMatrix4d &other, double threshold) const
Returns true if two matrices are memberwise equal within a specified tolerance.
bool has_transform() const
Returns true if the bead has been transformed, false otherwise.
static const LMatrix4d & ident_mat()
Returns an identity matrix.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
EggNode * add_child(EggNode *node)
Adds the indicated child to the group and returns it.
bool almost_equal(const LVecBase3f &other, float threshold) const
Returns true if two vectors are memberwise equal within a specified tolerance.
EggGroupNode * get_synthetic_group(const 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 ...
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. ...