Thông tin tài liệu:
CREATING GAME ART FOR 3D ENGINES- P7: Iwish to thank the editing team at Charles River Media (Emi Smith,Karen Gill, Jennifer Blaney, and Jenifer Niles) for their help in gettingthis book publish-ready. Thanks, too, to my technical editor, MikeDuggan. Also deserving recognition are the guys who make the TorqueGame Engine available, GarageGames, who directly or indirectly madethis book and the accompanying CD possible. In particular, I want tothank Joe Maruschak at GarageGames for the great articles and forumanswers that have helped me and many others get a handle on this engine.I...
Nội dung trích xuất từ tài liệu:
CREATING GAME ART FOR 3D ENGINES- P7158 Creating Game Art for 3D Engines Find: function onServerCreated() Edit: exec(“./crossbow.cs”); To read: exec(“./raygun.cs”); Find: // Starting equipment Edit: %player.setInventory(Crossbow,1); %player.setInventory(CrossbowAmmo,100); %player.mountImage(CrossbowImage,0); To read: %player.setInventory(RayGun,1); %player.setInventory(RayGunAmmo,100); %player.mountImage(RayGunImage,0); Editing Player.cs Player.cs is the script file that sets many of the parameters that the main character in the game uses. Here, two inventory lines are being added. Find: //Allowable Inventory Items Then add these lines: maxInv[RayGunAmmo] = 50; maxInv[RayGun] = 1; Chapter 6 Exporting Game Art 159 Editing AiPlayer.cs The example given here applies if you want to assign the raygun to both the player and the AI player (the character that the computer controls). In Chapter 12, “Character Exporting,” another scenario is presented, in which a new player defini- tion is created for the AI player. This scenario uses a robot character mesh and a blaster instead of a raygun. Find: function AIManager::spawn Edit: %player.mountImage(CrossbowImage,0); %player.setInventory(CrossbowAmmo,1000); To read: %player.mountImage(RayGunImage,0); %player.setInventory(RayGunAmmo,1000); The raygun data files are located in ScriptsDataShapesRaygun on the compan- ion CD-ROM. The associated scripts for the raygun are located in ScriptsServer ON THE CD Scripts on the companion CD-ROM.PRODUCING SIMPLE SHAPE ANIMATIONS If you want to animate a simple shape, such as getting a flag to wave, a tree to move, or a door to slide open and closed continuously, the first thing you need is an anima- tion that works. You also need a Sequence object that defines the frames of the animation and the correct export settings. In addition, you need a datablock that defines the DTS file as well as the name of the animation sequence, and a reference in the game.cs file that points to the datablock. Finally, you need to place your DTS object in the proper folder and add the DTS object to your Torque mission via the Torque Editor. Figure 6.19 depicts the hierarchy for a simple shape animation; the components look the same as for a simple shape like the oil drum, except that the mesh and the collision mesh are animated, and we have added a Sequence object. Creating the Simple Shape Datablock The following file excerpt comes from platform.cs. This script references a simple box with no texture that has been animated to move up and down. The first part of160 Creating Game Art for 3D Engines FIGURE 6.19 The hierarchy of an animated simple shape. this file is the definition of the datablock. The category variable describes where to find the DTS object in the Mission Editor’s creator tree (see Figure 6.20). Platform.dts is the shape file. In this case, we created the folder animated to have a place for all static shape animations. The next part of the file is the function Platform. This runs an animation called ambient. Ambient is the name of the Sequence object in the 3ds Max file. The last part of the file is the function StaticShapeData. This method creates the StaticShape datablock type. datablock StaticShapeData(platform) { category = “Misc”; shapeFile = “~/data/shapes/animated/platform.dts”; }; function platform::onAdd(%this,%obj) { %obj.playThread(0,”ambient”); } function StaticShapeData::create(%block) { %obj = new StaticShape() { dataBlock = %block; }; return(%obj); } You can use this code for any static shape ani ...