Example #1
0
//--------------------------------------------------------------------
// setWorldPosition()
//--------------------------------------------------------------------
void LLJoint::setWorldPosition( const LLVector3& pos )
{
	if (mParent == NULL)
	{
		this->setPosition( pos );
		return;
	}

	LLMatrix4a temp_matrix = getWorldMatrix();
	temp_matrix.setTranslate_affine(pos);

	LLMatrix4a invParentWorldMatrix = mParent->getWorldMatrix();
	invParentWorldMatrix.invert();

	invParentWorldMatrix.mul(temp_matrix);

	LLVector3 localPos(	invParentWorldMatrix.getRow<LLMatrix4a::ROW_TRANS>().getF32ptr() );

	setPosition( localPos );
}
Example #2
0
//--------------------------------------------------------------------
// setWorldRotation()
//--------------------------------------------------------------------
void LLJoint::setWorldRotation( const LLQuaternion& rot )
{
	if (mParent == NULL)
	{
		this->setRotation( rot );
		return;
	}
	
	LLMatrix4a parentWorldMatrix = mParent->getWorldMatrix();
	LLQuaternion2 rota(rot);
	LLMatrix4a temp_mat(rota);

	LLMatrix4a invParentWorldMatrix = mParent->getWorldMatrix();
	invParentWorldMatrix.setTranslate_affine(LLVector3(0.f));

	invParentWorldMatrix.invert();

	invParentWorldMatrix.mul(temp_mat);

	setRotation(LLQuaternion(LLMatrix4(invParentWorldMatrix.getF32ptr())));
}