Skip to content

Instantly share code, notes, and snippets.

@zulman
Created June 28, 2012 12:03
Show Gist options
  • Save zulman/3010954 to your computer and use it in GitHub Desktop.
Save zulman/3010954 to your computer and use it in GitHub Desktop.
Scale Attempt
void CompositeTransformController::Rotation::set( Quaternion^ value )
{
if( controllers->Length <= 1 || !IsGlobal)
{
CQuat native = value->Native;
native.Normalize();
for each ( IObjectTransformController^ controller in controllers )
controller->Rotation = gcnew Quaternion( native );
}
else
{
CQuat delta = value->Native * tempRotation->Inverted->Native;
delta.Normalize();
for each ( IObjectTransformController^ controller in controllers )
{
const CVec3 prevRelativeLocation = controller->Location->Native - tempLocation->Native;
const CVec3 currentRelativeLocation = delta.Rotate( prevRelativeLocation );
controller->Location += gcnew Vector3( currentRelativeLocation - prevRelativeLocation );
controller->Rotation *= gcnew Quaternion( delta );
}
}
tempRotation = value;
}
void CompositeTransformController::Scale::set( Vector3^ value )
{
for each ( IObjectTransformController^ controller in controllers )
{
controller->Scale = gcnew Vector3(
ComponentProduct( ComponentInvProduct( controller->Scale->Native, tempScale->Native ), value->Native )
);
controller->Location = gcnew Vector3(controller->Location->Native->X * Scale->Native->X, controller->Location->Native->Y * scale->Y, controller->Location->Native->Z);
}
tempScale = value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment