Transformations (C++)
- group FnXFormUtil
-
class FnXFormUtil
- #include <FnXFormUtil.h>
Provides a number of matrix transform utilities.
Matrix ordering matches the IMath convention:
FnAttribute::DoubleAttribute::array_type m = attr.getNearestSample(0.f); Imath::M44d(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]);
or,
Imath::M44d( (double(*)[4]) m.data());
Public Static Functions
-
static std::pair<FnAttribute::DoubleAttribute, bool> CalcTransformMatrixAtTime(const FnAttribute::GroupAttribute &groupAttr, float time)
- Parameters:
groupAttr – the FnAttribute::GroupAttribute to calculate the transform from.
time – the sample time at which to calculate the transform.
- Returns:
(4x4 matrix attr, isAbsolute)
-
static std::pair<FnAttribute::DoubleAttribute, bool> CalcTransformMatrixAtTimes(const FnAttribute::GroupAttribute &groupAttr, const float *time, int numSamples)
Note
This will do xform interpolation as needed
- Parameters:
groupAttr – FnAttribute::GroupAttribute containing the transform
time – sample time to calculate the transform at.
numSamples – number of time samples in time argument.
- Returns:
return (4x4 matrix attr, isAbsolute)
-
static std::pair<FnAttribute::DoubleAttribute, bool> CalcTransformMatrixAtExistingTimes(const FnAttribute::GroupAttribute &groupAttr)
Note
This will do xform interpolation as needed
- Parameters:
groupAttr – FnAttribute::GroupAttribute containing the transform
- Returns:
return (4x4 matrix attr, isAbsolute)
-
static FnAttribute::DoubleAttribute CreateBoundsAttr(double xMin, double xMax, double yMin, double yMax, double zMin, double zMax)
Creates a bounds attribute with the following properties:
Tuple Size: 2
Length: 6,
Values: [xMin, xMax, yMin, yMax, zMin, zMax]
- Parameters:
xMin – x min
xMax – x max
yMin – y min
yMax – y max
zMin – z max
zMax – z max
- Returns:
an FnAttribute::DoubleAttribute instance.
-
static FnAttribute::DoubleAttribute MergeBounds(const FnAttribute::DoubleAttribute &boundAttr1, const FnAttribute::DoubleAttribute &boundAttr2)
Merge the two bounds attributes. If the boundsAttrs are multi-sampled, the output bounds will be up-sampled to the union of incoming sample times. Bounds data at sample-times not provided (but needed) will be synthesized using fillInterpSample()
- Parameters:
boundAttr1 – first bounds attribute
boundAttr2 – second bounds attribute
- Returns:
an instance of FnAttribute::DoubleAttribute containing the merged attributes.
-
static FnAttribute::DoubleAttribute CalcTransformedBoundsAtExistingTimes(const FnAttribute::Attribute &xform, const FnAttribute::DoubleAttribute &boundAttr)
Calculates a new bounds attribute after baking in the specified coordinate system.
The input transform can either be specified as a 4 x 4 FnAttribute::DoubleAttribute (matrix) or as an unbaked FnAttribute::GroupAttribute
xform
hierarchy. All other types will result in failure an invalid FnAttribute instance being returned.The computed bounds attribute will contain time samples at the union of existing samples in the incoming
xform
andbound
attributes.If a user requires a non-multisampled bound attribute, this call should be followed up with a call to CollapseBoundTimeSamples()
- Parameters:
xform – the coordinate system
boundAttr – the bound attribute to transform
- Returns:
the new transformed bound attribute.
-
static FnAttribute::DoubleAttribute CollapseBoundsTimeSamples(const FnAttribute::DoubleAttribute &boundAttr)
Creates a single sampled attribute with the merged union of the mutlisampled input attribute.
- Parameters:
boundAttr – Multisampled bound attribute
- Returns:
Single sample merged union of the input bound attribute
-
static void InitXForm(FnAttribute::GroupBuilder &gb)
This group of function accepting FnAttribute::GroupBuilder references are used to simplify the construction of
xform
attributes.For the specified GroupBuilder, set
group
inherit
tofalse
(as all xforms should be) and then do a shallow update with the specified attribute, if provided.Note that if one’s command sequence utilizes only:
Init(gb, ...) PushXXX(...) PushXXX(...) PushXXX(...) etc...
It’s OK to construct the group builder with the GroupBuilder::BuilderModeStrict argument.
Note
All children must be either instances of FnAttribute::DoubleAttributes or FnAttribute::GroupAttribute.
- Parameters:
gb – An instance of FnAttribute::GroupBuilder
-
static void InitXForm(FnAttribute::GroupBuilder &gb, const FnAttribute::Attribute &xform)
-
static void PushRotateAttr(FnAttribute::GroupBuilder &gb, double angle, double x, double y, double z)
-
static FnAttribute::Attribute PushRotateAttr(const FnAttribute::Attribute &xform, double angle, double x, double y, double z)
-
static void PushTranslateAttr(FnAttribute::GroupBuilder &gb, double x, double y, double z)
-
static FnAttribute::Attribute PushTranslateAttr(const FnAttribute::Attribute &xform, double x, double y, double z)
-
static void PushScaleAttr(FnAttribute::GroupBuilder &gb, double x, double y, double z)
-
static FnAttribute::Attribute PushScaleAttr(const FnAttribute::Attribute &xform, double x, double y, double z)
-
static void PushMatrixAttr(FnAttribute::GroupBuilder &gb, const double *mtx16)
-
static FnAttribute::Attribute PushMatrixAttr(const FnAttribute::Attribute &xform, const double *mtx16)
-
static void PushOriginAttr(FnAttribute::GroupBuilder &gb)
-
static FnAttribute::Attribute PushOriginAttr(const FnAttribute::Attribute &xform)
-
static std::pair<FnAttribute::DoubleAttribute, bool> CalcTransformMatrixAtTime(const FnAttribute::GroupAttribute &groupAttr, float time)
-
class FnXFormUtil