3D techniques in MMF2

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • [color:#003300][size:17pt]3D techniques in Multimedia fusion 2 [/size][/color]


    [color:#003300]Basic 3d

    Before making a 3D game it is essential to comprehend how implementing 3D will effect what you
    already know.

    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.

    Example: Please login to see this link.

    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]
    [color:#003300]
    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;
    [/color][color:#660000]
    X = "320+(x_( "Active" )/z_( "Active" ))"
    Y = "240+(y_( "Active" )/z_( "Active" ))"[/color]
    [color:#003300]
    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;
    [/color][color:#660000]
    Scale = "1.0/z_( "Active" )"[/color]
    [color:#003300]
    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.

    Example: Please login to see this link.

    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: Please login to see this link.

    OpenGL is a powerful and widely accepted display engine; capable of drawing polygons in
    3D.

    Polygons (or polys) are drawn by defining 'vertex's'; points in space.

    For example the vertex's:

    [/color][color:#660000][x,y,z]
    0,0,-3
    1,0,-3
    1,1,-3[/color]
    [color:#003300]
    [image]Please login to see this link.]

    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
    like:
    [/color][color:#660000]
    Translate 0,0,-3
    [x,y,z]
    0,0,0
    1,0,0
    1,1,0[/color]
    [color:#003300]
    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
    'push[ed]' it.

    Time for a working example.

    This OpenGL example generates a shaded and tiled heightmap based on several
    bitmaps and imports models into it.

    Please login to see this picture.
    Example Please login to see this link.
    [/color]

    God's in his Heaven -
    All's right with the world.

  • Wow, that's really cool! Thanks for this tutorial, I'm sure it'll help a lot of people. :) It'd be nice if your MFA was commented, though - OpenGL is not that easy, especially not for beginners!
    The example runs rather slow - that's because of MMF. Go to the frame options and check "No display surface", you don't need it since OpenGL is drawn in a separate window. This speeds it up. Unfortunately, it's Dev-only. :( HWA in Direct3D works, too... but an OpenGL application that uses Direct3D to render a blank screen...? Feels pretty weird. :/

    By the way, the MFA requires you to rename OpenGL.mfx to OpenGLX.mfx?

    Oh, and you can turn off depth writing when drawing the mini-map, after you have drawn it, activate it again. That way, it'll always be at the top. I noticed that sometimes the terrain is covering it.

    Please login to see this link.

  • LOL a Stargate with a very impressive GHD and the terrain textures you got from Warcraft 3, it all goe's together well.

    In all- it's an ok example.

    I'm the Original Dragonguy! It's true, I really am the Original Dragonguy bigger and better than ever!
    Please login to see this link.

  • Thanks for the help and thanks for fullfilling my request of this great tutorial, but the final Example is for Dev only, can you do anything to make it without RegularExpression.mfx? Also, you should rename your OpenGL.mfx file to that, because you have it as OpenGLX.mfx.

    Otherwise, thank you very much. I never thought about using that first example until now... Here's an example of it's potential for space games that I made:

    Please login to see this link.

    Arrow Keys to move
    Space accelerates
    Shift blasts you at light speed ;)

  • One of the examples will only work if you have the Developer version of MMF2. Also, there are no viruses in any of these zips. Make sure you are not getting a false positive.

    stephen1980

    _____________________________________________
    Please login to see this link. -Need extensions? Send me a PM.-

  • Quote

    Example link

    um i downloaded the file, but i need these extensions to run it:
    ini++.mfx
    openglx.mfx
    overlay.mfx
    regularexpression.mfx
    where can i get these?

    <span style="color: #4682b4">I Have The Full Version Of MMF2Dev!</span>Please login to see this picture.
    <span style="color: #dc143c">Please Visit Please login to see this link.</span>Please login to see this picture.
    <span style="color: #06a8ff">&lt;O&gt;</span>

  • ok ty anyway

    <span style="color: #4682b4">I Have The Full Version Of MMF2Dev!</span>Please login to see this picture.
    <span style="color: #dc143c">Please Visit Please login to see this link.</span>Please login to see this picture.
    <span style="color: #06a8ff">&lt;O&gt;</span>

  • Without using OpenGL, using the "Simple Poly 3D" example, is it possible to add textures to the faces of the polygon?

    If not, what's the easiest way of doing this kind of top-down 3D (in the X and Y)?

  • It is possible, but it would require some incredibly clever programming.

    Here is an extremely sophisticated engine using the "Simple Poly" technique.

    Please login to see this link.


    ... as for a GTA clone i would suggest a mix of the simple poly technique and normal MMF active objects.

    If your feeling clever you should use OpenGL.. the results can be quite amazing.

    God's in his Heaven -
    All's right with the world.

  • Is there any way to get the example that uses openglx to just use opengl instead? I can load it if i copy and rename but then i can't use other openGL event snippets i had because it doesn't seem to copy over and i have to have a clone object in my list. Not sure why it does that but if anyone can do a version with the standard openGL that would be great. I couldn't figure out how other than re-doing every single event over one by one.

  • Hey Atom. sorry I'm not sure if its possible.. but there is an option in the event editor 'replace object'.. maybe you should check it out.

    God's in his Heaven -
    All's right with the world.

  • Hi, i tried that actually but it did not list the other OpenGL extension. I think this is because you can only replace with compatible modules when replacing and as it's renamed it probably thinks it's not.

  • Yes replace object only works for objects of the exact same type that use the same extension, ect. Such as replacing one active object with another, or a byutton, or a string. Great for combining objects and events.

    Working as fast as I can on Fusion 3

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!