macromedia DIRECTOR MX 1002004 training from the source [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

macromedia DIRECTOR MX 1002004 training from the source [Electronic resources] - نسخه متنی

Dave Mennenoh

نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
افزودن یادداشت
افزودن یادداشت جدید

Creating the Game Board

As you know, the game of "Memory" consists of placing a certain number of shuffled cards face down and then turning them over two at a time, trying to match the pair. If the pair doesn't match, you flip the cards back over and try again. You keep trying until you've matched all the pairsor until you've learned you no longer have any short-term memory due to the effects of, er, your college days.

For our game we will use a 4 x 4 board, totaling 16 cards (8 different pairs). The board will be laid out like so:

To create the actual 3D models for the board, you could use primitive cubes. But an easier way is to use one of the many 3D programs that will export to Director's W3D file format.

The W3D format is like many other 3D file formats in that it contains the models, textures, animations, etc. in a single file. Many manufacturers have used Macromedia's W3D SDK (Software Development Kit) to enable their software to create files in this format.

Using a Dedicated 3D Modeler

Using a stand-alone, dedicated 3D program is an easy way to create models and scenes for use in your Director work. Not only can you see your models as you build them, you can experiment with various materials and adjust your lights and cameras to get the scene just the way you want it. When you're ready you can export the scene to the W3D format, ready for import into Director.

Today, most of the major 3D applications on the market will export to Director's W3D format, although they don't all provide the same level of export quality. When considering purchasing a 3D application, you will want to research the level of support it provides for W3D. All of the major playersDiscreet's 3ds max, Alias' Maya, Newtek's LightWave, and Maxon's Cinema 4Dprovide very good support.

Other packages that provide W3D support include Caligari's TrueSpace, and the ever-popular ShapeShifter3D by Tabuleiro, which is an Xtra that runs right inside Director.

Shown here is the finished game board inside 3ds max, which is what I used to create it:

[View full size image]

One of the most compelling reasons for using a dedicated 3D package is ease of use, especially in applying your materials. Take one of the playing cards for the game, for instance. Each card has a similar top image, and it also has a unique bottom image. This means that each card will need to have two separate texture maps applied, and this is where using a dedicated 3D application really makes life easier.

You know that a model's shader contains the texture applied to the model. But a shader actually allows you to place up to eight textures on a model. Using a program such as 3ds max makes this simple.

In 3ds max I created what is known as a multi-sub object material. The material was told to have three sub-materials: one material on the top, one on the bottom, and one for the sides. This material was then duplicated 15 times, resulting in a separate material for each of the 16 cards:

However, the real trick is that the sub-materials have unique names. Note the second sub-material is named "b1". This is the material applied to the bottom of the card, while the first sub-material is applied to the top of the card. When exported to the W3D, format each sub-material with a unique name will create a unique shader within the 3D world. Because the first sub-material used on each card doesn't have a unique name, only one shader will be created and shared among the card tops. Because all of the second sub-materials used on the bottom of the cards are uniquely named, 16 separate shaders will be created. This is what will allow you to individually change the images displayed on the bottom of each card.

If this isn't completely clear, it will be when you create the Lingo to change the images.

Note

A consideration when using W3D files exported from 3ds max is that the coordinate system doesn't match Director's default. Instead of Y going up and down, max-created files have Z going up and down and Y going in and out. This is a trivial consideration once you are aware of it, however.

Importing the Game Board

Once the W3D file has been exported from your modeling software, it's ready to be imported into Director. In this section you'll import the finished game board into Director and begin working with it.

1.

Within Director select File > New > Movie. Set the Stage size to 800 x 600 with a black background. Import memory.w3d from the Lesson15\media folder on the CD.

An 800 x 600 Stage size will provide a nice large area for the game to be played in.

2.

Drag the 3D member from the internal cast and drop it into sprite channel 1 of the Score. Modify the span length so the sprite spans frames 1 through 10.

Remember, when you drop a sprite into the Score it will appear centered on the Stage.

3.

Use the Property inspector to change the sprite's width to 800 and its height to 577. Move the sprite down 12 pixels, so that its bottom is at the very bottom of the Stage, at 600 pixels.

The game board should now be taking up almost the entire Stage, except for a small area at the top. This area will be used to show a timer, so you can record how long it takes to win the game. Because a 3D sprite is, by default, a Direct To Stage (DTS) sprite, no other sprites can be placed over it.

Although you can change a 3D sprite to be non Direct To Stage, doing so will typically degrade the playback performance. By leaving a small open area above the 3D sprite, you can place text without degrading the game performance.

4.

Double-click the Score's behavior channel at frame 10 and create a standard loop on frame script. Name the script loop on frame.

on exitFrame me
_movie.go(_movie.frame)
end

5.

Play the movie, then open the Message window. Enter the following Lingo:

wrld = member("memory")
wrld.model("c1").rotate(0, 180, 0)

Because the game board has been exported from 3ds max, rotating the card 180 degrees about the Y axis causes it to flip over:

Let's flip one more card:

wrld.model("c16").rotate(0, 180, 0)

The card in the lower right corner flips over... and reveals the same image as the card at upper left. In fact, because the material in 3ds max was duplicated and applied to the cards, all of the cards contain the same texture map on the reverse side. Don't worry, this is by design. In the next section you'll import the images, then create texture maps to replace the current ones.

6.

Stop the movie and save it. Create a project_four folder on your hard drive and save the movie as memory.dir.

/ 165