스프라이트를 중심점을 중심으로 3 차원으로 회전하려고하는데 matrix3D의 일부 동작을 이해하려고 애 쓰고 있습니다.matrix3D를 사용하여 AS3에서 중심을 중심으로 3D 회전을 수행하는 방법은 무엇입니까?
override public function set rotationX (_rotationX:Number) : void {
this.transform.matrix3D.prependTranslation(this.width/2.0, this.height/2.0, 0);
this.transform.matrix3D.prependRotation(-this.rotationX, Vector3D.X_AXIS);
this.transform.matrix3D.prependRotation(_rotationX, Vector3D.X_AXIS);
this.transform.matrix3D.prependTranslation(-(this.width/2.0), -(this.height/2.0), 0);
}
override public function set rotationY (_rotationY:Number) : void {
this.transform.matrix3D.prependTranslation(this.width/2.0, this.height/2.0, 0);
this.transform.matrix3D.prependRotation(-this.rotationY, Vector3D.Y_AXIS);
this.transform.matrix3D.prependRotation(_rotationY, Vector3D.Y_AXIS);
this.transform.matrix3D.prependTranslation(-(this.width/2.0), -(this.height/2.0), 0);
}
override public function set rotationZ (_rotationZ:Number) : void {
this.transform.matrix3D.prependTranslation(this.width/2.0, this.height/2.0, 0);
this.transform.matrix3D.prependRotation(-this.rotationZ, Vector3D.Z_AXIS);
this.transform.matrix3D.prependRotation(_rotationZ, Vector3D.Z_AXIS);
this.transform.matrix3D.prependTranslation(-(this.width/2.0), -(this.height/2.0), 0);
}
내가 회전의 중심점를 해결하기 prependTranslation을 사용하고
, 첫 번째하는 prependRotation 어떤 previously-을 취소하려면 다음과 같이
필자는 스프라이트 세트의 rotationX,의 rotationY 및 rotationZ 방법을 오버라이드 (override) 적용된 회전.
테스트 결과, rotationX는 예상대로 작동하고 Sprite는 수평 축을 중심으로 회전합니다.
rotateY 및 rotationZ도 정상적으로 작동하는 것으로 보입니다. 그러나 rotationY 또는 rotationZ가 설정 될 때마다 다른 모든 회전 값도 변경됩니다. 이 문제는 rotationX에서는 문제가되지 않습니다. rotationX를 설정하면 아무 것도 변경되지 않습니다. 그러나 rotateY 또는 rotationZ를 설정하면 회전 값이 모두 변경됩니다. 이는 내 앱 (값을 저장하고 복원하려고 시도하는 경우)의 문제입니다.
matrix3D에서 어떤 일이 벌어지고 있는지에 대한 이해가 부족하다고 생각합니다. 이 값을 상호 의존성이 없도록 구현하려면 어떻게해야합니까?
가장 좋은 것은 [UIComponent # transformAround] (http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/frameworks/projects/framework/src/mx/core/UIComponent.as)를 확인하는 것입니다.) 및 관련 AdvancedLayout.as 구현. Matrix3D를 감싸는 것과 똑같습니다. –
코드를 살펴 보지 않았지만 Gimbal Lock을 경험하고 있습니까? http://en.wikipedia.org/wiki/Gimbal_lock –