コード例 #1
0
	void TransformComponent::onUpdate(float dt)
	{
        if(localdirty)
        {
            CalcLocalTransform();
        } else if(worlddirty) {
            CalcWorldTransform();
        }
	}
コード例 #2
0
 //----------------------------------------------------------------------------------------------
 Vector& IDrawInterface::GlobalToLocalTransform(Vector& OutLocalPoint, const Vector& InGlobalPoint) const
 {
	 // build global space matrix
	 Matrix WTM = CalcWorldTransform();

	 Vector UnTransformedLocalPosition = InGlobalPoint - WTM.t;

	 // calc projection to local axis
	 Vector AxisX = WTM._row0;
	 Vector AxisY = WTM._row1;
	 Vector AxisZ = WTM._row2;

	 AxisX.normalize();
	 AxisY.normalize();
	 AxisZ.normalize();

	 Matrix IWTM;	
	 invert(IWTM, WTM);

	 OutLocalPoint = Vector(UnTransformedLocalPosition.Dot(AxisX) * IWTM._row0.Length(),
							UnTransformedLocalPosition.Dot(AxisY) * IWTM._row1.Length(),
							UnTransformedLocalPosition.Dot(AxisZ) * IWTM._row2.Length());
	 return OutLocalPoint;
 }