Exemplo n.º 1
0
void SceneNode::_updateBounds(void)
{
	// Reset bounds first
	m_worldAABB.setNull();

	// Update bounds from own attached objects
	if(mp_attachedMoveableObject)
	{
		m_worldAABB = mp_attachedMoveableObject->getBoundingBox();
		m_worldAABB.transformAffine(_getFullTransform());
	}
}
Exemplo n.º 2
0
void SceneNode::_findVisibleObjects(Camera *pCamera, RenderQueue &renderQueue)
{
	if(mp_attachedMoveableObject && mp_attachedMoveableObject->visible())
	{
		if(pCamera->isVisible(getWorldBoundingBox(), NULL))
		{
			mp_attachedMoveableObject->addToRenderQueue(pCamera->getProjViewMatrix() * _getFullTransform(), renderQueue);
		}	
	}
	for(ChildNodeIterator it = m_childVec.begin(); it != m_childVec.end(); ++it)
	{
		SceneNode *pChild = static_cast<SceneNode*>(*it);
		pChild->_findVisibleObjects(pCamera, renderQueue);
	}
}
Exemplo n.º 3
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();
    }
Exemplo n.º 4
0
	//-----------------------------------------------------------------------
	void Transform::updateFromParentImpl(void)
	{
		if (parent)
		{
			// Update orientation
			const Quaternion& parentOrientation = parent->_getDerivedOrientation();
			if (inheritOrientation)
			{
				// Combine orientation with that of parent
				derivedOrientation = parentOrientation * orientation;
			}
			else
			{
				// No inheritence
				derivedOrientation = orientation;
			}

			// Update scale
			const Vector3& parentScale = parent->_getDerivedScale();
			if (inheritScale)
			{
				// Scale own position by parent scale, NB just combine
				// as equivalent axes, no shearing
				derivedScale[0] = parentScale.x * scale.x;
				derivedScale[1] = parentScale.x * scale.y;
				derivedScale[2] = parentScale.x * scale.z;
			}
			else
			{
				// No inheritence
				derivedScale = scale;
			}

			// Change position vector based on parent's orientation & scale
			derivedPosition[0] = parentScale.x * position.x;
			derivedPosition[1] = parentScale.y * position.y;
			derivedPosition[2] = parentScale.z * position.z;

			derivedPosition = parentOrientation.Rotate(derivedPosition);

			// Add altered position vector to parents
			derivedPosition += parent->_getDerivedPosition();
		}
		else
		{
			// Root node, no parent
			derivedOrientation = orientation;
			derivedPosition = position;
			derivedScale = scale;
		}

		// Ensure that the cached transform is updated here too..
		_getFullTransform();

		// Update transform directional vectors
		forward = derivedOrientation * Vector3::FORWARD;
		forward.Normalise();

		up = derivedOrientation * Vector3::UP;
		up.Normalise();

		right = derivedOrientation * Vector3::RIGHT;
		right.Normalise();

		cachedTransformOutOfDate = false;
		needParentUpdate = false;

		//Log("Updated Transform: " + ThisPtr()->componentParent->GetName());

	}