[color:#003300][size:17pt]3D techniques in Multimedia fusion 2 [/size][/color]
Before making a 3D game it is essential to comprehend how implementing 3D will effect what you
Anyone who has used MMF should have a good grasp of 2D; 'X' being left and right and 'Y' being up
and down; here is a simple example including a 'Z' axis acting as forward and backward.
In this example we are positioning and scaling each object as such:
[color:#660000]X = "320+(x_( "Active" )/z_( "Active" ))"
Y = "240+(y_( "Active" )/z_( "Active" ))"
Scale = "1.0/z_( "Active" )"[/color][/color]
In 2D we consider 0x,0y to be at the top left of the screen,
in 3D '0' is always considered the center of the screen, so by adding half the screens width "320"
to the 'X' position and half the screens height "240" to the 'Y' position we effectively make 0x,0y
the center of the screen.
The second part of positioning;
X = "320+(x_( "Active" )/z_( "Active" ))"
Y = "240+(y_( "Active" )/z_( "Active" ))"[/color]
Involves taking the 'X' and 'Y' dimensions and dividing them by the 'Z' dimension, remember
that 'Z' in this example represents how far the object is from the camera, and the further an
object is, the closer it is to the center of the screen (0)
The first and final part of scaling;
Scale = "1.0/z_( "Active" )"[/color]
simply makes the object smaller as it's distance from the camera becomes larger.
polygons in 3d
Positioning and scaling objects may give a sense of 3 dimensions, however not all 3D
geometry can be displayed this way.
Polygons are closed shapes (eg. triangle's) which are drawn at runtime, this example uses
polygons and the above principles to draw a cube.
In this example the 'X' and 'Y' positing is slightly more complex; now we have included
'CAMX', 'CAMY' and 'CAMZ', the camera can now me manipulated.
This is done by simply subtracting the cameras coordinates from the objects coordinated.
OpenGL in MMF2
MMF2's 3d capabilities are currently being expanded on; one example of this is the
integration of OpenGL into mmf2
Information and download link: here
OpenGL is a powerful and widely accepted display engine; capable of drawing polygons in
Polygons (or polys) are drawn by defining 'vertex's'; points in space.
For example the vertex's:
would draw a triangular poly just infront of the camera; to the top right of the screen.
Just as we can move the camera in the previous 'cube' example so too can we move the
camera in OpenGl; this is done by 'Translating' the matrix before drawing.
Whenever performing an action in OpenGL it is necessary to consider the current
matrix state as well as the effect that action will have on the Matrix.
The previous example; using vertex's to draw a triangle, could also be written in OpenGL
Thats because translating 'Z' to -3 effectively makes '0:Z' equivalent to '-3:Z'
OpenGL can keep track of multiple matrices by putting them onto a 'matrix stack'
To avoid losing track or relativity of your matrix; 'push' the matrix stack before
any redundant action then 'pop' the matrix stack after to return to where you last
Time for a working example.
This OpenGL example generates a shaded and tiled heightmap based on several
bitmaps and imports models into it.