# 3D Math Primer For Graphics and Game Development (Wordware Game Math Library)

All Stack Overflow 8
This Month Stack Overflow 2

I'm slightly confused by your question, but it's an interesting one nevertheless.

Do you have something isometric working and want to render a perspective projected view or the other way around ? You have a perspective view and want to go isometric ?

In the Flash CS4 IDE you can play with a '3D' few parameters. I've assembled a bunch of MovieClips into a cube to illustrate the point.

Here is the cube, rotate at 45 degrees on Y, then at 45 degrees on X as you can see in the Transform Panel:

Here is the same cube, with the Perspective Angle changed in the 3D Position And View group in the Property Inspector on the right.

The property in the IDE can be controlled through actionscript. Each DisplayObject has a transform property which holds references for objects controlling the 2D and 3D properties like: Matrix, Matrix3D, PerspectiveProjection and others.

You can control the perspective distortion through the fieldOfView property of PerspectiveProjection.

Assuming the box clip is named box, I could set it's fieldOfView to something really small ( as your allowed values larger than 0 and smaller than 180 only ) and that would be it.

e.g.

``````var isometric:PerspectiveProjection = new PerspectiveProjection();
isometric.fieldOfView = 0.00001;
box.transform.perspectiveProjection = isometric;
``````

For orbiting, check out this article on devnet. It explains an approach to orbiting as well. Depending on what you're trying to achieve, it might Ralph Hauwert's Arcball article.

Here are a few as3 isometric libraries out there like FFilmation and as3isolib, but I'm not sure what you need exactly. As antpaw was saying, if you're working on something bigger, you might use the flexibility 3D APIs like Papervision or Away3D.

At disturb we made fun isometric interface for visualizing tweets called Twigital. We used papervision for that.

UPDATE

It seems you need to rotate around a pivot dynamically. You can do that using the transform matrix. Here is how you do it in 2D:

``````/**
* Rotates a matrix about a point defined inside the matrix's transformation space.
* This can be used to rotate a movie clip around a transformation point inside itself.
*
* @param m A Matrix instance.
*
* @param x The x coordinate of the point.
*
* @param y The y coordinate of the point.
*
* @param angleDegrees The angle of rotation in degrees.
* @playerversion Flash 9.0.28.0
* @langversion 3.0
* @keyword Matrix, Copy Motion as ActionScript
* @see flash.geom.Matrix
*/
public static function rotateAroundInternalPoint(m:Matrix, x:Number, y:Number, angleDegrees:Number):void
{
var point:Point = new Point(x, y);
point = m.transformPoint(point);
m.tx -= point.x;
m.ty -= point.y;
m.rotate(angleDegrees*(Math.PI/180));
m.tx += point.x;
m.ty += point.y;
}

/**
* Rotates a matrix about a point defined outside the matrix's transformation space.
* This can be used to rotate a movie clip around a transformation point in its parent.
*
* @param m A Matrix instance.
*
* @param x The x coordinate of the point.
*
* @param y The y coordinate of the point.
*
* @param angleDegrees The angle of rotation in degrees.
* @playerversion Flash 9.0.28.0
* @langversion 3.0
* @keyword Matrix, Copy Motion as ActionScript
* @see flash.geom.Matrix
*/
public static function rotateAroundExternalPoint(m:Matrix, x:Number, y:Number, angleDegrees:Number):void
{
m.tx -= x;
m.ty -= y;
m.rotate(angleDegrees*(Math.PI/180));
m.tx += x;
m.ty += y;
}
``````

The code's not mine though, it's Adobe's ( Robert Penner's I'm guessing ), part of the MatrixTransformer class.

Now, for 3D, it's even easier, because the Matrix3D class has rotation methods like prependRotation and appendRotation, that accept 3 parameters:

• degrees:Number
• axis:Vector3D
• pivotPoint:Vector3D

So you can easily rotate a box 30 degrees on the X axis about 0,0,0 with something like:

``````var m:Matrix3D = box.transform.matrix3D;
m.prependRotation(30,Vector3D.X_AXIS,new Vector3D(0,0,0));
``````

Again, check out the devnet articles, the Matrix3D class and the Vector3D class.

If you want to get more in depth knowledge about Vectors, Matrices and Transformations, you can check out 3D Math Primer, the whole thing is really well explained, and it's just math, so the things you learn are handy in any 3d setup ( pure as3, away3d, papervision, openGL, etc. ).

HTH, George

http://techbase.kde.org/Development/Languages/Python

Many KDE styles use SVG and plenty of animation. The user can always change themes. I think you should be more specific about what kind of animations you want to do. I don't think 3D wall type affects really fall into the widget category that QT is. It sounds to me like you want to make a 3D interface for an application. If that is the case, you may want to look more into 3D engine type libraries used mainly in games. I know that some have excellent GUI widgets for programming game menus and the like.　I guess you'd decide on your engine and the see if there are python language bindings. One of my favorite engines: http://irrlicht.sourceforge.net/links.html

Another thing you would want to consider is how you want to handle the window management. Do you want to make a full screen interface? Or is to to be windowed? Also how would such an application integrate into a 3D window manager or rather a window manager with compositing.

Edit:

In that case the qtopengl module is probably something to look into: http://doc.qt.nokia.com/4.6/qtopengl.html

I do recommend QT. It's clean and easy to use and cross platform. So your app could run on windows as well.

One thing you'd want to think about before hand is the type of FX you want to perform. For example, if you want to create a page curl type effect when renaming the image, you'd have to think about how to program that, or look for libraries/code snipets that do that math. 3D engines that are used in games often have a lot of support for those kind of typical FX or animations that you'd see in a game. If you use something like qtopengl, you'd need to think about this as well. qtopengl can pretty much only render. Think of it as a viewport. However, it is the correct approach to making a 3D application for the desktop.

Programming 3D applications is really interesting and fun. I enjoyed it a lot. However, don't get discouraged be the math. I recommend getting a book about it if you are serious. I liked this one: http://www.amazon.com/Primer-Graphics-Development-Wordware-Library/dp/1556229119

However, IIRC the examples are C++ which you may not be comfortable with. When you understand such mathematical concepts, it easier to think about how you would make a page curl type affect. Of course, if you find libraries or code that shows you how to do the math, that may be fine.