Panda3D
|
This represents the <Transform> entry of a group or texture node: a list of component transform operations, applied in order, that describe a net transform matrix. More...
#include "eggTransform.h"
Classes | |
class | Component |
Public Types | |
enum | ComponentType { CT_invalid, CT_translate2d, CT_translate3d, CT_rotate2d, CT_rotx, CT_roty, CT_rotz, CT_rotate3d, CT_scale2d, CT_scale3d, CT_uniform_scale, CT_matrix3, CT_matrix4 } |
Public Member Functions | |
EggTransform (const EggTransform ©) | |
void | add_matrix3 (const LMatrix3d &mat) |
Appends an arbitrary 3x3 matrix to the current transform. | |
void | add_matrix4 (const LMatrix4d &mat) |
Appends an arbitrary 4x4 matrix to the current transform. | |
void | add_rotate2d (double angle) |
Appends a 2-d rotation to the current transform. | |
void | add_rotate3d (double angle, const LVector3d &axis) |
Appends a 3-d rotation about an arbitrary axis to the current transform. | |
void | add_rotate3d (const LQuaterniond &quat) |
Appends an arbitrary 3-d rotation to the current transform, expressed as a quaternion. | |
void | add_rotx (double angle) |
Appends a rotation about the X axis to the current transform. | |
void | add_roty (double angle) |
Appends a rotation about the Y axis to the current transform. | |
void | add_rotz (double angle) |
Appends a rotation about the Z axis to the current transform. | |
void | add_scale2d (const LVecBase2d &scale) |
Appends a possibly non-uniform scale to the current transform. | |
void | add_scale3d (const LVecBase3d &scale) |
Appends a possibly non-uniform scale to the current transform. | |
void | add_translate2d (const LVector2d &translate) |
Appends a 2-d translation operation to the current transform. | |
void | add_translate3d (const LVector3d &translate) |
Appends a 3-d translation operation to the current transform. | |
void | add_uniform_scale (double scale) |
Appends a uniform scale to the current transform. | |
void | clear_transform () |
Resets the transform to empty, identity. | |
const LMatrix3d & | get_component_mat3 (int n) const |
Returns the 3x3 matrix associated with the nth component. | |
const LMatrix4d & | get_component_mat4 (int n) const |
Returns the 4x4 matrix associated with the nth component. | |
double | get_component_number (int n) const |
Returns the solitary number associated with the nth component. | |
ComponentType | get_component_type (int n) const |
Returns the type of the nth component. | |
const LVecBase2d & | get_component_vec2 (int n) const |
Returns the 2-component vector associated with the nth component. | |
const LVecBase3d & | get_component_vec3 (int n) const |
Returns the 3-component vector associated with the nth component. | |
int | get_num_components () const |
Returns the number of components that make up the transform. | |
LMatrix3d | get_transform2d () const |
Returns the overall transform as a 3x3 matrix. | |
const LMatrix4d & | get_transform3d () const |
Returns the overall transform as a 4x4 matrix. | |
bool | has_transform () const |
Returns true if the transform is nonempty, false if it is empty (no transform components have been added). | |
bool | has_transform2d () const |
Returns true if the transform is specified as a 2-d transform, e.g. | |
bool | has_transform3d () const |
Returns true if the transform is specified as a 3-d transform, e.g. | |
EggTransform & | operator= (const EggTransform ©) |
void | set_transform2d (const LMatrix3d &mat) |
Sets the overall transform as a 3x3 matrix. | |
void | set_transform3d (const LMatrix4d &mat) |
Sets the overall transform as a 4x4 matrix. | |
bool | transform_is_identity () const |
Returns true if the described transform is identity, false otherwise. | |
void | write (ostream &out, int indent_level, const string &label) const |
Writes the transform to the indicated stream in Egg format. | |
Protected Member Functions | |
void | internal_add_matrix (const LMatrix3d &mat) |
Appends an arbitrary 4x4 matrix to the current transform, without calling transform_changed(). | |
void | internal_add_matrix (const LMatrix4d &mat) |
Appends an arbitrary 4x4 matrix to the current transform, without calling transform_changed(). | |
void | internal_clear_transform () |
Resets the transform to empty without calling transform_changed(). | |
void | internal_set_transform (const LMatrix3d &mat) |
Sets the overall transform without calling transform_changed(). | |
void | internal_set_transform (const LMatrix4d &mat) |
Sets the overall transform without calling transform_changed(). | |
virtual void | transform_changed () |
This virtual method is called whenever the transform is changed; it is intended to provide a hook for derived classes (e.g. |
This represents the <Transform> entry of a group or texture node: a list of component transform operations, applied in order, that describe a net transform matrix.
This may be either a 3-d transform, and therefore described by a 4x4 matrix, or a 2-d transform, described by a 3x3 matrix.
Definition at line 33 of file eggTransform.h.
void EggTransform::add_matrix3 | ( | const LMatrix3d & | mat | ) | [inline] |
Appends an arbitrary 3x3 matrix to the current transform.
Definition at line 137 of file eggTransform.I.
References internal_add_matrix(), and transform_changed().
void EggTransform::add_matrix4 | ( | const LMatrix4d & | mat | ) | [inline] |
Appends an arbitrary 4x4 matrix to the current transform.
Definition at line 149 of file eggTransform.I.
References internal_add_matrix(), and transform_changed().
Referenced by EggGroup::r_transform().
void EggTransform::add_rotate2d | ( | double | angle | ) |
Appends a 2-d rotation to the current transform.
The rotation angle is specified in degrees counterclockwise about the origin.
Definition at line 102 of file eggTransform.cxx.
References LMatrix4d::rotate_mat_normaxis(), and transform_changed().
void EggTransform::add_rotate3d | ( | double | angle, |
const LVector3d & | axis | ||
) |
Appends a 3-d rotation about an arbitrary axis to the current transform.
The rotation angle is specified in degrees counterclockwise about the axis.
Definition at line 161 of file eggTransform.cxx.
References LMatrix4d::rotate_mat(), and transform_changed().
Referenced by add_rotate3d(), and FltToEggLevelState::set_transform().
void EggTransform::add_rotate3d | ( | const LQuaterniond & | quat | ) |
Appends an arbitrary 3-d rotation to the current transform, expressed as a quaternion.
This is converted to axis-angle notation for the egg file.
Definition at line 178 of file eggTransform.cxx.
References add_rotate3d(), LQuaterniond::get_angle(), LQuaterniond::get_axis(), and transform_changed().
void EggTransform::add_rotx | ( | double | angle | ) |
Appends a rotation about the X axis to the current transform.
The rotation angle is specified in degrees counterclockwise about the axis.
Definition at line 116 of file eggTransform.cxx.
References LMatrix4d::rotate_mat_normaxis(), and transform_changed().
void EggTransform::add_roty | ( | double | angle | ) |
Appends a rotation about the Y axis to the current transform.
The rotation angle is specified in degrees counterclockwise about the axis.
Definition at line 131 of file eggTransform.cxx.
References LMatrix4d::rotate_mat_normaxis(), and transform_changed().
void EggTransform::add_rotz | ( | double | angle | ) |
Appends a rotation about the Z axis to the current transform.
The rotation angle is specified in degrees counterclockwise about the axis.
Definition at line 146 of file eggTransform.cxx.
References LMatrix4d::rotate_mat_normaxis(), and transform_changed().
void EggTransform::add_scale2d | ( | const LVecBase2d & | scale | ) |
Appends a possibly non-uniform scale to the current transform.
Definition at line 191 of file eggTransform.cxx.
References LMatrix4d::scale_mat(), and transform_changed().
void EggTransform::add_scale3d | ( | const LVecBase3d & | scale | ) |
Appends a possibly non-uniform scale to the current transform.
Definition at line 206 of file eggTransform.cxx.
References LMatrix4d::scale_mat(), and transform_changed().
Referenced by FltToEggLevelState::set_transform().
void EggTransform::add_translate2d | ( | const LVector2d & | translate | ) |
Appends a 2-d translation operation to the current transform.
Definition at line 72 of file eggTransform.cxx.
References transform_changed(), and LMatrix4d::translate_mat().
void EggTransform::add_translate3d | ( | const LVector3d & | translate | ) |
Appends a 3-d translation operation to the current transform.
Definition at line 86 of file eggTransform.cxx.
References transform_changed(), and LMatrix4d::translate_mat().
Referenced by FltToEggLevelState::set_transform().
void EggTransform::add_uniform_scale | ( | double | scale | ) |
Appends a uniform scale to the current transform.
Definition at line 220 of file eggTransform.cxx.
References LMatrix4d::scale_mat(), and transform_changed().
void EggTransform::clear_transform | ( | ) | [inline] |
Resets the transform to empty, identity.
Definition at line 125 of file eggTransform.I.
References internal_clear_transform(), and transform_changed().
Referenced by EggGroup::clear_default_pose(), EggPrimitive::r_apply_texmats(), EggGroup::r_transform(), and FltToEggLevelState::set_transform().
const LMatrix3d & EggTransform::get_component_mat3 | ( | int | n | ) | const [inline] |
Returns the 3x3 matrix associated with the nth component.
It is an error to call this if the component type is not CT_matrix3.
Definition at line 344 of file eggTransform.I.
References LMatrix3d::ident_mat().
Referenced by write().
const LMatrix4d & EggTransform::get_component_mat4 | ( | int | n | ) | const [inline] |
Returns the 4x4 matrix associated with the nth component.
It is an error to call this if the component type is not CT_matrix4.
Definition at line 358 of file eggTransform.I.
References LMatrix4d::ident_mat().
Referenced by write().
double EggTransform::get_component_number | ( | int | n | ) | const [inline] |
Returns the solitary number associated with the nth component.
In the case of a rotation, this is the angle in degrees to rotate; in the case of uniform scale, this is the amount of the scale. Other types do not use this property.
Definition at line 299 of file eggTransform.I.
Referenced by write().
EggTransform::ComponentType EggTransform::get_component_type | ( | int | n | ) | const [inline] |
Returns the type of the nth component.
Definition at line 284 of file eggTransform.I.
Referenced by write().
const LVecBase2d & EggTransform::get_component_vec2 | ( | int | n | ) | const [inline] |
Returns the 2-component vector associated with the nth component.
This may be the translate vector, rotate axis, or non-uniform scale. It is an error to call this if the component type does not use a 2-d vector property.
Definition at line 314 of file eggTransform.I.
References LVector2d::zero().
Referenced by write().
const LVecBase3d & EggTransform::get_component_vec3 | ( | int | n | ) | const [inline] |
Returns the 3-component vector associated with the nth component.
This may be the translate vector, rotate axis, or non-uniform scale. It is an error to call this if the component type does not use a 3-d vector property.
Definition at line 330 of file eggTransform.I.
References LVector3d::zero().
Referenced by write().
int EggTransform::get_num_components | ( | ) | const [inline] |
Returns the number of components that make up the transform.
Definition at line 274 of file eggTransform.I.
Referenced by write().
LMatrix3d EggTransform::get_transform2d | ( | ) | const [inline] |
Returns the overall transform as a 3x3 matrix.
It is an error to call this if has_transform3d() is true.
Definition at line 234 of file eggTransform.I.
References has_transform3d(), and LMatrix3d::ident_mat().
Referenced by TextureReference::from_egg(), and XFileVertex::set_from_egg().
const LMatrix4d & EggTransform::get_transform3d | ( | ) | const [inline] |
Returns the overall transform as a 4x4 matrix.
It is valid to call this even if has_transform2d() is true; in this case, the 3x3 transform will be expanded to a 4x4 matrix.
Definition at line 251 of file eggTransform.I.
Referenced by EggGroup::adjust_under(), XFileAnimationSet::create_hierarchy(), EggTexture::is_equivalent_to(), EggPrimitive::r_apply_texmats(), EggGroup::r_transform(), and EggTexture::sorts_less_than().
bool EggTransform::has_transform | ( | ) | const [inline] |
Returns true if the transform is nonempty, false if it is empty (no transform components have been added).
This is true for either a 2-d or a 3-d transform.
Definition at line 163 of file eggTransform.I.
Referenced by EggGroup::adjust_under(), EggRenderState::fill_state(), has_transform2d(), has_transform3d(), EggTexture::is_equivalent_to(), EggPrimitive::r_apply_texmats(), EggGroup::r_transform(), EggTexture::sorts_less_than(), EggTexture::write(), and EggGroup::write().
bool EggTransform::has_transform2d | ( | ) | const [inline] |
Returns true if the transform is specified as a 2-d transform, e.g.
with a 3x3 matrix, or false if it is specified as a 3-d transform (with a 4x4 matrix), or not specified at all.
Normally, EggTextures have a 2-d matrix (but occasionally they use a 3-d matrix), and EggGroups always have a 3-d matrix.
Definition at line 180 of file eggTransform.I.
References has_transform().
Referenced by TextureReference::from_egg(), and XFileVertex::set_from_egg().
bool EggTransform::has_transform3d | ( | ) | const [inline] |
Returns true if the transform is specified as a 3-d transform, e.g.
with a 4x4 matrix, or false if it is specified as a 2-d transform (with a 2x2 matrix), or not specified at all.
Normally, EggTextures have a 3-d matrix (but occasionally they use a 3-d matrix), and EggGroups always have a 3-d matrix.
Definition at line 210 of file eggTransform.I.
References has_transform().
Referenced by get_transform2d(), and EggPrimitive::r_apply_texmats().
void EggTransform::internal_add_matrix | ( | const LMatrix3d & | mat | ) | [protected] |
Appends an arbitrary 4x4 matrix to the current transform, without calling transform_changed().
Definition at line 331 of file eggTransform.cxx.
Referenced by add_matrix3(), add_matrix4(), and internal_set_transform().
void EggTransform::internal_add_matrix | ( | const LMatrix4d & | mat | ) | [protected] |
Appends an arbitrary 4x4 matrix to the current transform, without calling transform_changed().
Definition at line 348 of file eggTransform.cxx.
void EggTransform::internal_clear_transform | ( | ) | [protected] |
Resets the transform to empty without calling transform_changed().
Definition at line 318 of file eggTransform.cxx.
References LMatrix4d::ident_mat().
Referenced by clear_transform(), internal_set_transform(), and EggGroup::r_flatten_transforms().
void EggTransform::internal_set_transform | ( | const LMatrix3d & | mat | ) | [inline, protected] |
Sets the overall transform without calling transform_changed().
Definition at line 371 of file eggTransform.I.
References internal_add_matrix(), and internal_clear_transform().
Referenced by EggGroup::r_transform(), set_transform2d(), and set_transform3d().
void EggTransform::internal_set_transform | ( | const LMatrix4d & | mat | ) | [inline, protected] |
Sets the overall transform without calling transform_changed().
Definition at line 383 of file eggTransform.I.
References internal_add_matrix(), and internal_clear_transform().
void EggTransform::set_transform2d | ( | const LMatrix3d & | mat | ) | [inline] |
Sets the overall transform as a 3x3 matrix.
This completely replaces whatever componentwise transform may have been defined.
Definition at line 192 of file eggTransform.I.
References internal_set_transform(), and transform_changed().
Referenced by TextureReference::update_egg().
void EggTransform::set_transform3d | ( | const LMatrix4d & | mat | ) | [inline] |
Sets the overall transform as a 4x4 matrix.
This completely replaces whatever componentwise transform may have been defined.
Definition at line 222 of file eggTransform.I.
References internal_set_transform(), and transform_changed().
Referenced by SoftNodeDesc::get_transform(), and FltToEggLevelState::set_transform().
void EggTransform::transform_changed | ( | ) | [protected, virtual] |
This virtual method is called whenever the transform is changed; it is intended to provide a hook for derived classes (e.g.
EggGroup) to update their internal cache appropriately.
Reimplemented in EggGroup.
Definition at line 364 of file eggTransform.cxx.
Referenced by add_matrix3(), add_matrix4(), add_rotate2d(), add_rotate3d(), add_rotx(), add_roty(), add_rotz(), add_scale2d(), add_scale3d(), add_translate2d(), add_translate3d(), add_uniform_scale(), clear_transform(), set_transform2d(), and set_transform3d().
bool EggTransform::transform_is_identity | ( | ) | const [inline] |
Returns true if the described transform is identity, false otherwise.
Definition at line 262 of file eggTransform.I.
References LMatrix4d::almost_equal(), and LMatrix4d::ident_mat().
Referenced by EggTexture::is_equivalent_to(), EggPrimitive::r_apply_texmats(), and EggTexture::sorts_less_than().
void EggTransform::write | ( | ostream & | out, |
int | indent_level, | ||
const string & | label | ||
) | const |
Writes the transform to the indicated stream in Egg format.
Definition at line 233 of file eggTransform.cxx.
References get_component_mat3(), get_component_mat4(), get_component_number(), get_component_type(), get_component_vec2(), get_component_vec3(), and get_num_components().
Referenced by EggGroup::write().