SGPlacementTransform::SGPlacementTransform(void) :
_placement_offset(0, 0, 0),
- _scenery_center(0, 0, 0),
_rotation(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
const osg::CopyOp& copyop):
osg::Transform(trans, copyop),
_placement_offset(trans._placement_offset),
- _scenery_center(trans._scenery_center),
_rotation(trans._rotation)
{
for (int j = 0; j < 3; ++j) {
t(j, i) = _rotation(i, j);
}
- t(3, i) = _placement_offset(i) - _scenery_center(i);
+ t(3, i) = _placement_offset(i);
}
if (_referenceFrame == RELATIVE_RF)
for (int j = 0; j < 3; ++j) {
t(j, i) = _rotation(i, j);
}
- t(3, i) = _placement_offset(i) - _scenery_center(i);
+ t(3, i) = _placement_offset(i);
}
t = osg::Matrix::inverse(t);
0, 0, 1, 0,
0, 0, 0, 1);
SGVec3d placementOffset(0, 0, 0);
- SGVec3d sceneryCenter(0, 0, 0);
if (fr[0].matchWord("rotation") && fr[1].isOpenBracket()) {
fr += 2;
else
return false;
}
- if (fr[0].matchWord("sceneryCenter")) {
- ++fr;
- if (fr.readSequence(sceneryCenter.osg()))
- fr += 3;
- else
- return false;
- }
trans.setTransform(placementOffset, rotation);
- trans.setSceneryCenter(sceneryCenter);
return true;
}
= static_cast<const SGPlacementTransform&>(obj);
const SGMatrixd& rotation = trans.getRotation();
const SGVec3d& placement = trans.getGlobalPos();
- const SGVec3d& sceneryCenter = trans.getSceneryCenter();
fw.indent() << "rotation {" << std::endl;
fw.moveIn();
fw << placement(i) << " ";
}
fw << std::endl;
- fw.indent() << "sceneryCenter ";
- for (int i = 0; i < 3; i++) {
- fw << sceneryCenter(i) << " ";
- }
- fw << std::endl;
fw.precision(prec);
return true;
}
{ _placement_offset = off; dirtyBound(); }
void setTransform(const SGVec3d& off, const SGMatrixd& rot)
{ _placement_offset = off; _rotation = rot; dirtyBound(); }
- void setSceneryCenter(const SGVec3d& center)
- { _scenery_center = center; dirtyBound(); }
const SGVec3d& getGlobalPos() const
{ return _placement_offset; }
const SGMatrixd& getRotation() const { return _rotation; }
- const SGVec3d& getSceneryCenter() const { return _scenery_center; }
virtual bool computeLocalToWorldMatrix(osg::Matrix&,osg::NodeVisitor*) const;
virtual bool computeWorldToLocalMatrix(osg::Matrix&,osg::NodeVisitor*) const;
//////////////////////////////////////////////////////////////////
SGVec3d _placement_offset;
- SGVec3d _scenery_center;
SGMatrixd _rotation;
};