Home Tutorials Forums Articles Blogs Movies Library Employment Press

 ActionScript.org Forums Navigating in 3d box
 Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

 11-05-2009, 05:11 AM #11 henke37 Senior Member     Join Date: Mar 2009 Location: Sweden Posts: 10,885 Isn't there a single invert method? Just clone the matrix, invert the clone and assign it to the parent container, bang instant camera.
11-05-2009, 05:34 AM   #12
lordofduct
Senior Member

Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872

Quote:
 Originally Posted by henke37 Isn't there a single invert method? Just clone the matrix, invert the clone and assign it to the parent container, bang instant camera.
Not quite... not all 4x4 matrices can be easily inverted... hence the determinant property and the fact the invert method returns a boolean. It returns false when the matrix fails to invert.

The main reason a matrix fails to invert is because the determinant is 0. Other reasons can occur due to imaginary values that appear in a product series of n degree matrices of very high values.

Our 2D matrix doesn't fail really ever because of its form. Because of the padded zeros it protects the 3x3 matrix from failing to invert. But there is no protection like this for 4x4 matrices. Of course yes though in our 4x4 matrix representing realistic transformations, the chance of it occuring is slim. But for those rare occassions you need a catch for it. But if you want proof of the failure to invert quickly and easily... take a reference to a projection matrix and invert it (though the projection matrix doesn't really conform to standard transformation matrices... but it's the proof in itself).

It's actually why I suggested a Quaternion based camera. Most modern video games use the Quaternion based camera instead because of many reasons. One being this issue... as well as the compactness of a Quat (4 values of rotation and scale, 3 values of translatoin. Instead of the 16 in the 4x4 matrix... 3 of which are padding.), and the fact quaternions don't suffer from the dreaded "gimbal lock".

There are of course other types as well, but none of which are as compact and versatile as the Matrix and Quaternion based cameras.
__________________
www.lordofduct.com - come read my blog!

If you want to know how to program, take a math class, take a lot of math classes!

Last edited by lordofduct; 11-05-2009 at 05:44 AM.

 11-05-2009, 01:29 PM #13 Synnstar Registered User   Join Date: Nov 2009 Posts: 12 ActionScript Code: ```var startX:int=room.x; var startY:int=room.y; var startZ:int=room.z; stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownHandler); function keyDownHandler(event:KeyboardEvent):void {     var curX:int=room.x;     var curY:int=room.y;     var curZ:int=room.z;     var cameraX:int=curX-startX;     var cameraY:int=curY-startY;     var cameraZ:int=curZ-startZ;     trace(cameraX+" "+cameraY+" "+cameraZ);             if (event.keyCode==Keyboard.LEFT) {              room.transform.matrix3D.appendRotation(10, Vector3D.Y_AXIS, new Vector3D(cameraX+startX,cameraY+startY,cameraZ+startZ));     }     if (event.keyCode==Keyboard.RIGHT) {         room.transform.matrix3D.appendRotation(-10, Vector3D.Y_AXIS, new Vector3D(cameraX+startX,cameraY+startY,cameraZ+startZ));     }     if (event.keyCode==Keyboard.UP) {         room.z-=10;     }     if (event.keyCode==Keyboard.DOWN) {         room.z+=10;     }     }``` This is what I have now, it's still not working properly. I did some research on that quaternion based camera. Didn't find much flash related examples. Any new input on this would be greatly appreciated
 11-05-2009, 01:58 PM #14 lordofduct Senior Member     Join Date: Feb 2008 Location: West Palm Beach, FL Posts: 3,872 I said earlier a camera object is going to be very difficult to set up as it takes a completely different approach to how everything is done. It requires set up a couple classes to represent a Camera and allow updating and sorting the display with it. And I completely understand why there isn't an quaternion based camera tutorials out there. There are barely any camera tutorials for flash as is, the built in 3D aspect of flash is extremely young, and Quaternions tend to scare the shit out of people because it's 3 complex values and a real value... complex number == a + bi | where i is the sqrt(-1) but that's uber tangential to the issue at hand with what it is you're attempting to accomplish. Now back at where I was before... now I suggested the pivot point thing because I assumed it worked a specific way. Alas it must not be doing what I expect. But I showed you some example of code the long way of doing it as well. But moving the object around the origin, rotating and then moving it back over the point of interest (its location). ActionScript Code: ```var vec:Vector3D = new Vector3D( room.x, room.y, room.z ); room.transform.matrix3D.appendTranslation( -vec.x, -vec.y, -vec.z ); room.transform.matrix3D.appendRotation( 10, Vector3D.Y_AXIS ); room.transform.matrix3D.appendTranslation( vec.x, vec.y, vec.z );``` it should work oh, and you might be getting some weird visual issues when you're close to walls due to a lack of a z-buffer in flash. It does NOT resolve the the layering of objects based on there z position relative to the camera. You have to solve this yourself and resort the child objects to create the correct overlapping effect. __________________ www.lordofduct.com - come read my blog! If you want to know how to program, take a math class, take a lot of math classes! Last edited by lordofduct; 11-05-2009 at 02:02 PM.
 11-05-2009, 02:13 PM #15 Synnstar Registered User   Join Date: Nov 2009 Posts: 12 the room will still rotate around its own center point using this technique right? You move it back to the origin, it rotates arround its own center point and then you put it back around the camera. I don't see how this is any different from rotating it using rotationY.
11-05-2009, 03:00 PM   #16
lordofduct
Senior Member

Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872

Quote:
 Originally Posted by Synnstar the room will still rotate around its own center point using this technique right? You move it back to the origin, it rotates arround its own center point and then you put it back around the camera. I don't see how this is any different from rotating it using rotationY.
just try it... you'll be surprised.
__________________
www.lordofduct.com - come read my blog!

If you want to know how to program, take a math class, take a lot of math classes!

 11-05-2009, 03:55 PM #17 Synnstar Registered User   Join Date: Nov 2009 Posts: 12 http://www.swfcabin.com/open/1257438133 That's the result.. it still rotates around its own centre point.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home ActionScript Forums Group     ActionScript 3.0     ActionScript 2.0     ActionScript 1.0 (and below)     Simple Stuff (Newbies) Flash General Questions     Flash 10 General Questions     Flash 9 General Questions     Flash 8 General Questions     Other Flash General Questions Flex     Flex 2, 3 & 4     Flex 1 Extensions and Plugins     Components     JSFL - Extending Flash Desktop, Mobile and non-browser Environments     AIR (Apollo)     FlashLite / Portable Devices Development     Projectors and CDs Supporting Technologies     HTML and JavaScript     haXe     Server-Side Scripting     Flash Remoting     Flash Media Server General     Best Practices     Gaming and Game Development     Animation and Effects     Flashants Support Forum Community Boards     General Chat     Just for Kicks Challenges     Detention Flash In Action     Site Check     Cool Sites     Widgets Decommissioned     Projects and Positions CMS Forums     Announcements Board     Content Postings / Updates     Product Review Requests     CMS Technical Questions     Process Questions     Collaboration & Suggested Articles

All times are GMT. The time now is 06:30 AM.

///