Ejemplo n.º 1
0
void GdsNode::SetLocalFromWorldTransform( const D3DXMATRIX& matWorld )
{
	if(m_pParentNode)
	{
		D3DXMATRIX matParentWorldInv;
		D3DXMatrixInverse( &matParentWorldInv, NULL, &m_pParentNode->GetWorldMatrix());
		D3DXMATRIX matLocal = matParentWorldInv * matWorld;
		SetLocalMatrix( matLocal );
	}
	else
	{
		SetLocalMatrix( matWorld );
	}

}
Ejemplo n.º 2
0
	void Transform::SetParent(Transform* newParent)
	{
		if( newParent == this )
			return;

		if( parent == newParent )
			return;

		if( parent != 0 )
			parent->RemoveChild(this);
		
		parent = newParent;

		if( newParent != 0 )
		{
			nextSibling = newParent->firstChild;
			newParent->firstChild = this;

			const Float4x4& world = newParent->GetWorldMatrix();
			Float4x4 invWorld = world;

			invWorld.Wx = -DotProduct(world.XAxis, world.WAxis);
			invWorld.Wy = -DotProduct(world.YAxis, world.WAxis);
			invWorld.Wz = -DotProduct(world.ZAxis, world.WAxis);
			invWorld.transpose3x3();

			Float4x4 newLocal;
			Multiply( newLocal, GetWorldMatrix(), invWorld );
			SetLocalMatrix(newLocal);
		}
	}
Ejemplo n.º 3
0
void Transform::PostMultiply( const glm::mat4 &m )
{
	SetLocalMatrix( GetLocalMatrix() * m );
}
Ejemplo n.º 4
0
void Transform::PreMultiply( const glm::mat4 &m )
{
	SetLocalMatrix( m * GetLocalMatrix() );
}
Ejemplo n.º 5
0
void Transform::Rotate( float angle, glm::vec3 axis )
{
	SetLocalMatrix( glm::rotate( angle, axis ) * GetLocalMatrix() );
}
Ejemplo n.º 6
0
void Transform::Rotate( float angle, float x, float y, float z )
{
	SetLocalMatrix( glm::rotate( angle, x, y, z ) * GetLocalMatrix() );
}