Chapter 16: Simulating 3D with MMF


In the chapters leading up to this one, we have briefly turned our attention to some of the other tools that we have at our disposal. In this chapter, we’re going to get back to the development tools and will take a more in-depth look at Multimedia Fusion. More specifically, we are going to look at how we can simulate a 3D game environment with a tool that offers a mostly 2D set of tools.

3D Sprite Object

The most obvious way we can do 3D in MMF is with the 3D Sprite object. This object lets you display and manipulate 3D objects in your applications. You can rotate the 3D Sprite object around or translate it on the x-, y-, or z-axis, effectively allowing you to simulate a 3D environment in your applications. 3D Sprite objects appear larger as they move forward and smaller as they move away in your applications.

It’s very easy to add 3D Sprite objects to an application. In fact, within a few steps, you can have a fully functional object representing a 3D model in your programs. We’ll take a moment now to look at how easy it is to add a 3D Sprite to an application and how we can manipulate it once it’s available.

First, open MMF and create a new application. Next, open the Frame Editor and choose Insert New Object into Frame from the Insert menu. This displays a window that should look like Figure 16.1. Choose 3D Sprite from this window.

click to expand
Figure 16.1: The Create New Object window.

Your interface will now indicate that you have the 3D Sprite object selected as the Create New Object window will be gone, and your mouse pointer will be replaced with a cross hair (see Figure 16.2). You can now position the cross hair and click the left mouse button to open the 3D Object Editor (see Figure 16.3).

click to expand
Figure 16.2: A cross hair will replace the standard mouse pointer.

click to expand
Figure 16.3: The 3D Object Editor is displayed.

Along the bottom of the 3D Object Editor window, you should see a button that looks like a filmstrip with frames numbered 1 to 5 and the third frame resting above the others (see Figure 16.4). When you click this button to load a 3D object, a standard dialog box is displayed (see Figure 16.5). You can browse the CD-ROM that accompanies this book to load the sphere.3ds model that is included in the Graphics folder. Once the file is loaded, set the initial Z value to 250. The editor should now look like Figure 16.6.


Figure 16.4: We are interested in the button that looks like a filmstrip.

click to expand
Figure 16.5: The standard dialog box is displayed.

click to expand
Figure 16.6:

Click on the Preview Animation button (see Figure 16.7) to open a new set of options in the editor (see Figure 16.8). Click the Material Color button and choose the blue color seen in Figure 16.9. Click the OK button to go back to the original editor screen and then click the OK button on this editor as well. You will be asked if you would like to save your 3D object (see Figure 16.10), and you should choose the Yes button from the window. Give the 3D animated object the name sphere. You will now see the item in the Frame Editor (see Figure 16.11). You can use the handles to resize the object so that the sprite is completely visible, although it will not perform any actions if you run the program. We will do this next.


Figure 16.7: Click the Preview Animation button to open the 3D Object Preview window.

click to expand
Figure 16.8: The 3D Object Preview window provides a variety of options.


Figure 16.9: We’re choosing blue as a color from the available options.


Figure 16.10: A dialog box is displayed, prompting to save the 3D object.

click to expand
Figure 16.11: The Frame Editor is displayed, showcasing the changes we made to the object.

Open the Events Editor and create a new event using Mouse, User Clicks On an Object (see Figure 16.12). This will display a new window (see Figure 16.13), which should be left with the default settings of Left Mouse button and Single Click. Click OK to move to the next step, where we select our 3D Sprite (see Figure 16.14).

With the event created, we can now perform an action that will occur when the button is clicked. Right-click on the square beneath the 3D Sprite and choose Set 3D Position, Set Z Position (3D). The Set Z Position window is displayed (see Figure 16.15). Click the Retrieve Data from an Object button to display a new window (see Figure 16.16). Right-click the 3D Sprite object and choose 3D Position, Z Position. This will retrieve the current position of the 3D Sprite. We’ll need to subtract 10 from this position so that the ball moves when clicked on. Append –10 to the expression in the editor (see Figure 16.17) and click OK to add the action.

click to expand
Figure 16.12: A new condition is being created.


Figure 16.13: The default settings are OK.


Figure 16.14: Our 3D Sprite is the only object available from the window.

click to expand
Figure 16.15: The Set Z Position window with the Expression Editor.


Figure 16.16: A New Action window is opened.

click to expand
Figure 16.17: Our final expression.

Test the application to make sure that the 3D Sprite moves when executed. You can see how this type of object will be useful when we begin work on our first 3D program, but it is not our only option when using MMF. In the next sections, we’ll look at several additional ways we can simulate 3D in our games.




Awesome 3d Game Development(c) No Programming Required
Awesome 3d Game Development: No Programming Required (Charles River Media Game Development)
ISBN: 1584503254
EAN: 2147483647
Year: 2006
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net