예제 #1
0
    //-----------------------------------------------------------------------
    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();
    }
예제 #2
0
    //---------------------------------------------------------------------
    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();
    }
예제 #3
0
	//  [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;
	}
예제 #4
0
    //-----------------------------------------------------------------------
    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;
    }
예제 #5
0
    //---------------------------------------------------------------------
    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);
    }
예제 #6
0
    //-----------------------------------------------------------------------
    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();
    }
예제 #7
0
    //-----------------------------------------------------------------------
    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);
    }
예제 #8
0
 /** Save the node's current position as the previous position
 */
 void PCZSceneNode::savePrevPosition(void)
 {
     mPrevPosition = _getDerivedPosition();
 }
예제 #9
0
 //-----------------------------------------------------------------------
 const Vector3& Node::getWorldPosition(void) const
 {
     return _getDerivedPosition();
 }
예제 #10
0
 //-----------------------------------------------------------------------
 Real InstancedEntity::getSquaredViewDepth( const Camera* cam ) const
 {
     return _getDerivedPosition().squaredDistance(cam->getDerivedPosition());
 }
예제 #11
0
	//  [7/30/2008 zhangxiang]	mabe a bug...
	void sgNode::setAbsolutePosition(const Vector3 &aPos){
		Vector3 aTranslate = aPos - _getDerivedPosition();
		translate(aTranslate, TS_PARENT);
	}
예제 #12
0
	//  [8/2/2008 zhangxiang]
	Vector3 sgNode::position(void) const{
		return _getDerivedPosition();
	}
예제 #13
0
	//  [7/30/2008 zhangxiang]
	const Vector3 &sgNode::absolutePosition(void) const{
		return _getDerivedPosition();
	}