Compute 3D rotations with localToGlobal

Driving home from the flashconference in stuttgart we had a nice conversation about MovieClip.localToGlobal. I thought it is possible to write a complete 3D camera class with it and it is.

//-- setup
var xClip: MovieClip = createEmptyMovieClip( '0', 0 );
var yClip: MovieClip = createEmptyMovieClip( '1', 1 );

//-- apply angles
	xClip._rotation = xa * 180 / Math.PI;
	yClip._rotation = ya * 180 / Math.PI;

//-- for each point
		pt = points[p];

		pp = { x: pt.y, y: pt.z };

		xClip.localToGlobal( pp );

		tmpy = pp.x;
		pp.x = pt.x;

		yClip.localToGlobal( pp );

		tmpx = pp.x;
		tmpz = pp.y;
//-- end

The trick is to rotate 2 MovieClips representing 2 axis in 3d space. But it has not the performance boost at all, even using the native MovieClip function. A simple sin/cos Matrix is a lot of faster, but the idea was nice :o)

localToGlobal3D.zip (Rotating around 2 Axis)

3 thoughts on “Compute 3D rotations with localToGlobal”

  1. Hi André,

    at the FMX announced to publish your incomplete rigid-body-sources.
    Are you still planning to do this?
    Can´t wait to play the game you´ve shown…

    Keep up the good work

    kuat

  2. Hi Andre,

    I have made wireframes, according to you blog on your site. I don’t succeed made textures on this wireframe. I have seen the actionscript 3.0 code for this, but I can not use actionscript 3.0 (not enough ram-memory, we have 512 ram-memory).
    On this site is an example:
    http://www.freewebs.com/ogamemanist/%2D%20New%20Folder/Cubus%20flash.swf

    Is it possible to use actionscript 2.0, have you a code to made textures on wireframes with actionscript 2.0?

Comments are closed.