Fix axis object in translate animation
This will allow an object to be moved using a line (with 2d points). Use the factor to switch direction (direction will depend on the order of definition of the end points of the vertex and) together with a (usually normalised property to define how much of the translation to apply). <animation> <type>translate</type> <object-name>mm_radios-display</object-name> <property>/sim/model/f-14/radio-position-norm</property> <factor>-1</factor> <axis> <object-name>mm_radios-display-alt-position-axis</object-name> </axis> </animation>
This commit is contained in:
parent
bf1db210d7
commit
7ac90850d3
@ -714,7 +714,7 @@ protected:
|
|||||||
* This function will take action when axis has an object-name tag and the corresponding object
|
* This function will take action when axis has an object-name tag and the corresponding object
|
||||||
* can be found within the hierarchy.
|
* can be found within the hierarchy.
|
||||||
*/
|
*/
|
||||||
bool SGAnimation::setCenterAndAxisFromObject(osg::Node *rootNode, SGVec3d& center, SGVec3d &axis, simgear::SGTransientModelData &modelData) const
|
bool SGAnimation::setCenterAndAxisFromObject(osg::Node *rootNode, SGVec3d& center, SGVec3d &axis, SGVec3d &offset, simgear::SGTransientModelData &modelData) const
|
||||||
{
|
{
|
||||||
std::string axis_object_name = std::string();
|
std::string axis_object_name = std::string();
|
||||||
bool can_warn = true;
|
bool can_warn = true;
|
||||||
@ -792,6 +792,7 @@ bool SGAnimation::setCenterAndAxisFromObject(osg::Node *rootNode, SGVec3d& cente
|
|||||||
}
|
}
|
||||||
if (axisSegment)
|
if (axisSegment)
|
||||||
{
|
{
|
||||||
|
offset = axisSegment->getStart() - axisSegment->getEnd();
|
||||||
center = 0.5*(axisSegment->getStart() + axisSegment->getEnd());
|
center = 0.5*(axisSegment->getStart() + axisSegment->getEnd());
|
||||||
axis = axisSegment->getEnd() - axisSegment->getStart();
|
axis = axisSegment->getEnd() - axisSegment->getStart();
|
||||||
return true;
|
return true;
|
||||||
@ -805,7 +806,8 @@ void SGAnimation::readRotationCenterAndAxis(osg::Node *_rootNode, SGVec3d& cente
|
|||||||
SGVec3d& axis, simgear::SGTransientModelData &modelData) const
|
SGVec3d& axis, simgear::SGTransientModelData &modelData) const
|
||||||
{
|
{
|
||||||
center = SGVec3d::zeros();
|
center = SGVec3d::zeros();
|
||||||
if (setCenterAndAxisFromObject(_rootNode, center, axis, modelData))
|
SGVec3d offsets;
|
||||||
|
if (setCenterAndAxisFromObject(_rootNode, center, axis, offsets, modelData))
|
||||||
{
|
{
|
||||||
if (8 * SGLimitsd::min() < norm(axis))
|
if (8 * SGLimitsd::min() < norm(axis))
|
||||||
axis = normalize(axis);
|
axis = normalize(axis);
|
||||||
@ -969,9 +971,11 @@ SGTranslateAnimation::SGTranslateAnimation(simgear::SGTransientModelData &modelD
|
|||||||
else
|
else
|
||||||
_initialValue = 0;
|
_initialValue = 0;
|
||||||
|
|
||||||
SGVec3d _center;
|
SGVec3d _center, _offsets;
|
||||||
if (modelData.getNode() && !setCenterAndAxisFromObject(modelData.getNode(), _center, _axis, modelData))
|
if (modelData.getNode() && !setCenterAndAxisFromObject(modelData.getNode(), _center, _axis, _offsets, modelData))
|
||||||
_axis = readTranslateAxis(modelData.getConfigNode());
|
_axis = readTranslateAxis(modelData.getConfigNode());
|
||||||
|
else
|
||||||
|
_axis = _offsets;
|
||||||
}
|
}
|
||||||
|
|
||||||
osg::Group*
|
osg::Group*
|
||||||
|
@ -82,7 +82,7 @@ protected:
|
|||||||
const SGVec3d& def = SGVec3d::zeros() ) const;
|
const SGVec3d& def = SGVec3d::zeros() ) const;
|
||||||
|
|
||||||
void readRotationCenterAndAxis(osg::Node *rootNode, SGVec3d& center, SGVec3d& axis, simgear::SGTransientModelData &modelData) const;
|
void readRotationCenterAndAxis(osg::Node *rootNode, SGVec3d& center, SGVec3d& axis, simgear::SGTransientModelData &modelData) const;
|
||||||
bool setCenterAndAxisFromObject(osg::Node *rootNode, SGVec3d& center, SGVec3d &axis, simgear::SGTransientModelData &modelData) const;
|
bool setCenterAndAxisFromObject(osg::Node *rootNode, SGVec3d& center, SGVec3d &axis, SGVec3d& offset, simgear::SGTransientModelData &modelData) const;
|
||||||
|
|
||||||
SGExpressiond* readOffsetValue(const char* tag_name) const;
|
SGExpressiond* readOffsetValue(const char* tag_name) const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user