Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-05-2009, 05:11 AM   #11
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,683
Send a message via Skype™ to henke37
Default

Isn't there a single invert method? Just clone the matrix, invert the clone and assign it to the parent container, bang instant camera.
henke37 is online now   Reply With Quote
Old 11-05-2009, 05:34 AM   #12
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

Quote:
Originally Posted by henke37 View Post
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.
lordofduct is offline   Reply With Quote
Old 11-05-2009, 01:29 PM   #13
Synnstar
Registered User
 
Join Date: Nov 2009
Posts: 12
Default

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
Synnstar is offline   Reply With Quote
Old 11-05-2009, 01:58 PM   #14
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

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.
lordofduct is offline   Reply With Quote
Old 11-05-2009, 02:13 PM   #15
Synnstar
Registered User
 
Join Date: Nov 2009
Posts: 12
Default

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.
Synnstar is offline   Reply With Quote
Old 11-05-2009, 03:00 PM   #16
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

Quote:
Originally Posted by Synnstar View Post
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!
lordofduct is offline   Reply With Quote
Old 11-05-2009, 03:55 PM   #17
Synnstar
Registered User
 
Join Date: Nov 2009
Posts: 12
Default

http://www.swfcabin.com/open/1257438133

That's the result.. it still rotates around its own centre point.
Synnstar is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Jump


All times are GMT. The time now is 12:39 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.