//----------------------------------------------------------------------- Real Node::getSquaredViewDepth(const Camera* cam) const { Vector3 diff = _getDerivedPosition() - cam->getDerivedPosition(); // NB use squared length rather than real depth to avoid square root return diff.squaredLength(); }
//--------------------------------------------------------------------- void Bone::setBindingPose(void) { setInitialState(); // Save inverse derived position/scale/orientation, used for calculate offset transform later mBindDerivedInversePosition = - _getDerivedPosition(); mBindDerivedInverseScale = Vector3::UNIT_SCALE / _getDerivedScale(); mBindDerivedInverseOrientation = _getDerivedOrientation().Inverse(); }
// [7/30/2008 zhangxiang] const Matrix4 &sgNode::getFullTransform(void) const{ if(m_bCachedTransformOutOfDate){ // Use derived values m_CachedTransform.makeTransform( _getDerivedPosition(), _getDerivedScale(), _getDerivedOrientation()); m_bCachedTransformOutOfDate = false; } return m_CachedTransform; }
//----------------------------------------------------------------------- bool InstancedEntity::findVisible( Camera *camera ) const { //Object is active bool retVal = isInScene(); if (retVal) { //check object is explicitly visible retVal = isVisible(); //Object's bounding box is viewed by the camera if( retVal && camera ) retVal = camera->isVisible(Sphere(_getDerivedPosition(),getBoundingRadius())); } return retVal; }
//--------------------------------------------------------------------- void Bone::_getOffsetTransform(Matrix4& m) const { // Combine scale with binding pose inverse scale, // NB just combine as equivalent axes, no shearing Vector3 scale = _getDerivedScale() * mBindDerivedInverseScale; // Combine orientation with binding pose inverse orientation Quaternion rotate = _getDerivedOrientation() * mBindDerivedInverseOrientation; // Combine position with binding pose inverse position, // Note that translation is relative to scale & rotation, // so first reverse transform original derived position to // binding pose bone space, and then transform to current // derived bone space. Vector3 translate = _getDerivedPosition() + rotate * (scale * mBindDerivedInversePosition); m.makeTransform(translate, scale, rotate); }
//----------------------------------------------------------------------- Real Node::getSquaredViewDepth(const Camera* cam) const { Vector3 diff = _getDerivedPosition() - cam->getDerivedPosition(); #if 1 Matrix4 viewObectMat; if (cam) { Matrix4 viewMat(cam->getViewMatrix(false)); Matrix4 objMat(_getFullTransform()); viewObectMat =viewMat * objMat ; } viewObectMat.getTrans(diff); diff.x =0; diff.z =0; #endif // NB use squared length rather than real depth to avoid square root return diff.squaredLength(); }
//----------------------------------------------------------------------- void SceneNode::lookAt( const Vector3& targetPoint, TransformSpace relativeTo, const Vector3& localDirectionVector) { // Calculate ourself origin relative to the given transform space Vector3 origin; switch (relativeTo) { default: // Just in case case TS_WORLD: origin = _getDerivedPosition(); break; case TS_PARENT: origin = mPosition; break; case TS_LOCAL: origin = Vector3::ZERO; break; } setDirection(targetPoint - origin, relativeTo, localDirectionVector); }
/** Save the node's current position as the previous position */ void PCZSceneNode::savePrevPosition(void) { mPrevPosition = _getDerivedPosition(); }
//----------------------------------------------------------------------- const Vector3& Node::getWorldPosition(void) const { return _getDerivedPosition(); }
//----------------------------------------------------------------------- Real InstancedEntity::getSquaredViewDepth( const Camera* cam ) const { return _getDerivedPosition().squaredDistance(cam->getDerivedPosition()); }
// [7/30/2008 zhangxiang] mabe a bug... void sgNode::setAbsolutePosition(const Vector3 &aPos){ Vector3 aTranslate = aPos - _getDerivedPosition(); translate(aTranslate, TS_PARENT); }
// [8/2/2008 zhangxiang] Vector3 sgNode::position(void) const{ return _getDerivedPosition(); }
// [7/30/2008 zhangxiang] const Vector3 &sgNode::absolutePosition(void) const{ return _getDerivedPosition(); }