아래와 같이 내장 API인 Matrix3D 을 사용해서 객체를 X,Y,Z 축으로 로테이션 시켜보려하였습니다.

_mat = new Matrix3D();
_mat.identity();
_mat.appendRotation(1, Vector3D.Y_AXIS) ;

_vec = new Vector3D(100,0,0) ;

private function loop(e:Event):void
{
_vec = _mat.transformVector(_vec) ;

_obj.x = _vec.x ;
_obj.y = _vec.y ;
_obj.z = _vec.z ;
}

그런데 위와 같이 실행하면 _vec (Vector3D) 의 x,y,z 성분이 모두 0으로 수렴(?) 하게 되네요. 레퍼런스를 찾아보면 Matrix3D 의 transformVector 멤버함수는 매개변수로 넘어온 벡터에 변환을 적용한후 새로운 Vector3D 객체를 반환한다고 나오는데 해석을 잘못한건지 ..

그래서 일단 CustomMatrix3D 클레스를 만들어 보았습니다.

CustomMatrix3D 를 사용해서 위와 같은 시도를 해보았습니다.
package example.matrix {
   
    import flash.display.Shape;
    import flash.events.Event;
    import flash.geom.Vector3D;
   
    import flash.display.Sprite;

    /**
     * @author Lee
     * http://webnoon.net
     */
    public class MatrixMain extends Sprite {

       
       
       
        private var _vec : Vector3D;
        private var _ball : Shape;
        private var _mat : CustomMatrix3D;

        public function MatrixMain() {
           
           
           
           
            _vec = new Vector3D(100,0,0) ;
            _vec.w = 1 ;
            var rad : Number = Math.PI/180 ;
           
            _mat = new CustomMatrix3D() ;
            _mat.rotationY(rad) ;
            //_mat.rotationZ(rad) ;
            //_mat.rotationX(rad) ;
            //_mat.translation(0, 1, 0) ;
           
            _ball = new Shape();
            with(_ball.graphics)
            {
                beginFill(0xff0000) ;
                drawCircle(.0, .0, 10) ;
                endFill();
            }
            addChild(_ball) ;
           
            addEventListener(Event.ENTER_FRAME,loop);
        }
       
        private function loop(event : Event) : void {
           
            _mat.transformVector(_vec) ;
           
            _ball.x = _vec.x + stage.stageWidth/2;
            _ball.y = _vec.y + stage.stageHeight/2 ;
            _ball.z = _vec.z ;
           
        }
    }
}

[소스코드]

아래는 실행 결과...


rotationX,Y,Z , translation 모두 잘 적용됨을 알수 있습니다.

Flash Builder4 에서 실행결과 flash.geom.Matrix3D 사용에는 이상이 없었습니다.
오류(?) 가 발생한 환경은 FDT + Flash CS4(컴파일) 입니다.
개발 환경이 잘못된건지 제가 실수한건지 정확히 알수는 없지만 Flash Builder4 에서 실행한 코드는 같은 코드로 실행하였습니다.

저작자 표시 비영리 변경 금지
Posted by 웹눈
joshblog.net 에서는 플렉스를 효율적으로 공부할수 있는 10가지 방법에 대해 소개하고 있습니다.

Posted by 웹눈
TAG flex
import mx.filesystem.File ; // 정확한지는 모르겠지만 아무튼, Air만 이 클레스를 사용할수 있다.

File 클래스는 FileReference 클래스를 상속 받았기 때문에, FileReference의 모든 메소드와 속성을 사용할수 있다.

var file:File = new File();

file.nativePath 가 전체 경로가 됨.

'프로그래밍 > Air' 카테고리의 다른 글

Flex/Air brows() 전체 파일경로 가져오기  (0) 2009/08/10
Posted by 웹눈
TAG AIR, flex
Flex Builder cannot locate the required version of Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder.

Do you want to try to run your application with the current version?

이런 오류 발생시..

windows - > prference -> general -> web browser -> 익스플로어 선택
Posted by 웹눈
TAG flex