Created
June 28, 2012 12:03
-
-
Save zulman/3010954 to your computer and use it in GitHub Desktop.
Scale Attempt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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