MAPPING WITH GMAX AND GLB Level editing tutorial for
Transcription
MAPPING WITH GMAX AND GLB Level editing tutorial for
MAPPING WITH GMAX AND GLB Level editing tutorial for Ca3DE Alvaro F. Celis March 14, 2004 Contents Contents 1 2 3 4 5 6 7 8 9 Introduction Things you require for this tutorial Installing the required software Creating a menu for GLB 2.2 in Gmax Configuring Gmax for level editing Creating your level Exporting the .map file Working the file in Hammer Credits and thanks 1 Introduction 1 Introduction This document is written as an alternative way of creating levels in the .map format using the powerful skills of a 3d modeling package such as Gmax and the amazing set of tools created by Michael Little “Game Level Builder 2.2”, which we'll be refering to as GLB. This tutorial is also written specifically for Carsten's 3d Engine (aka Ca3DE) and its growing community but it may be used and applied with similar engines that take advantage of the .map format and therefore use bsps in their levels. GLB can also be used with 3dsmax but I decided to make the tutorial Gmax specific since it's a free download and not everyone has the big bucks to get a package like 3dsmax. The combination of Gmax-GLB-Ca3DE make a powerful set of tools that will increase any level designer's creativity and imagination. GLB offers a quite simple and fast method of drawing out your levels in the top viewport of Gmax from which you get extruded walls, floor and ceiling (and even windows and doors) in a matter of seconds giving you a map file ready to be textured in Hammer (aka Worldcraft), and compiled using Ca3DE's set of tools. By the end of this tutorial we'll have a level of medium complexity up and running in Ca3DE. I'll try to make this process as painless as possible so... have fun! 2 Things you require Basically, what you need is all of the software mentioned above, so here are some links: Gmax: http://www.discreet.com/products/gmax/gmaxconsumer/downloads_text.html GLB: http://www.scriptspot.com/scripts/web_upload/Michael%20and%20John% 20Little/GLB2_22.zip or from the main site: http://www.maple3d.com/MainFrameScriptsPage.htm Ca3de: Carsten's 3d Engine http://www.ca3d-engine.de/Download.html For this tutorial we require Ca3DE's MDK (Material Development Kit) but you might as well download the engine demo to experience its power with your own eyes. Hammer 3.4: http://collective.valve-erc.com/data/docs/103963197844855700/files/hammer_v34.exe 3 Installing the software 3 Installing the software Gmax: Simply run the installer (gmax12.exe) and follow the screen instructions. Install everything to its default paths. When running Gmax for the first time an authorization is required; this is done online so an internet connection is required. Don't worry... it's free. Ca3DE: Simply unzip the contents of the MDK to C:\ You'll have a folder C:\Ca3DE-MDK . If you also downloaded the demo then just unzip it into the MDK's folder. You'll get the demo stuff in C:\Ca3DE-MDK\Ca3D-Engine . Note: remember to read the NewMaterials.pdf for specific details on how to use Carsten's 3d engine, how to create a basic set of textures to work with and how to compile levels for it. Valve Hammer editor: After downloading the file, simply run hammer_v34.exe and install everything to its default paths. Now, what's really important is configuring Hammer to work properly with Ca3DE. In order to do so, please read point 5.1 World editors of the new materials documentation that comes with Ca3DE's MDK. Here you'll find precise instructions on how to configure Hammer for Ca3DE. GLB 2.2: We are going to spend a bit more time explaining how to install Michael Little's Game Level Builder tools since many people out there might not be familiar with Max scripts and the way they're installed. After downloading the zip file, create a folder in which you'll unzip the files. After unzipping GLB2.2 files you'll have something like this: 3 Installing the software As you can see, several folders are created for each of the versions GLB is available for. We'll concentrate on installing the plugins for Gmax, so let's begin. 1. Copy the glb2 folder into Gmax's scripts folder. 3 Installing the software 2. copy the two .bmp files(splines_24a and splines_24i) in this folder to the GLB2 folder you just copied into Gmax\scripts: 3. copy the GLB2_22gmax.mcr file to your C:\Gmax\UI\macroscripts folder. Ok! So far so good. Next, we'll add a button in Gmax's menus to acces the plugins. 4 Creating a menu for GLB2.2 in Gmax 4 Creating a menu for GLB 2.2 in Gmax After having all the files properly copied into their respective folders we may now run Gmax. Go to “Customize” in the main menu bar and then click on “Customize user interface”. Select the “menus” palette: In the “Category” drop down list select the “Maple 3d” group. 4 Creating a menu for GLB2.2 in Gmax In the lower part of the menu right click and select “New Menu” and name it “GLB” Once the “GLB” menu is created, select it and drag it to the right and drop it under the “Help” menu. This way we have a created an empty button which will appear in the main menu bar of Gmax. 4 Creating a menu for GLB2.2 in Gmax To finish, grab each of the categories (menus) that appear in the upper left part under the “Maple3d” category and after hitting the plus (+) symbol in the “GLB” menu, drag each of them and drop them in our newly created menu on the right. 4 Creating a menu for GLB2.2 in Gmax Great! Now hit the “Save...” button and save your menu with a name like “MyUI” or any name you want. Just don't replace any of Gmax's default menus. Close the “customize user interface” window and a brand new “GLB” button should be placed in our main menu buttons. Hit it and you'll have different menus to choose from it. Select GLB2.2 and the plugin window should pop up, something like this: 4 Creating a menu for GLB2.2 in Gmax Sweet, huh? If everything has been done right you now know how to add personalized menu buttons in Gmax. It's done exactly the same way for 3dsmax. So if your GLB2.2 tools are up and running, we are ready for our next step: CONFIGURING GMAX FOR LEVEL EDITING. Close the GLB2.2 window by now. 5 Configuring Gmax for level editing One of game's most complicated things to understand (at least for me, he he!) is units of measure; specially if you work with a metric units sytem. Game units work on a 2x2 basis and in inches. I won't get very deep into this topic but after a lot of trial and error I've found out a work around for this and found a way to set up Gmax so that anything you draw in it will match perfectly with Hammer's units. I'm pretty sure there are a lot of tutorials that will explain this issue a bit wider but since this is a practical tutorial, I'll just keep things simple... and practical. 5 Configuring Gmax for level editing Since we already got Gmax open after creating our brand new “GLB” menu button, hit the “Customize” once more and select “Units setup” Select “Generic Units” if not selected by default. Next, select “Customize” once more and select “Grid and snap settings” Select the “Home grid” palette and set “Grid Spacing” to 16 and “Major Lines Every Nth” to 8. 5 Configuring Gmax for level editing If you check, now our grid lines in Gmax will offset every 16 units and each 16x16 square will be subdivided into 8 unit squares which perfectly fits a regular game environment with grid size set to 16. Ready? Great! One last thing and a very important one is that we'll use Gmax's snaps to ensure that everything we draw in Gmax will be snapped to the grid so that when we export our level to be opened in Hammer things will be properly snapped making calculation processes easier. In the lower right part of Gmax look for a bar with these icons: Ok, click and hold the first magnet and a Flyout menu will appear. We have 3 options here: snapping to 2d, 2.5d, or 3d. Select the 2d snap. 5 Configuring Gmax for level editing Now, right click on your selected 2d snap and another window will pop up from which we'll decide which snaps to activate. In this case we want to snap to “Grid Points” so check this option. To see it in action, select the “box” command on the right toolbar and move your mouse around the top viewport. You'll see a cyan gizmo moving from grid point to grid point so anything you draw will be snapped to the grid. Right click to exit the “box” command. We are now ready to put up our basic level! 6 Creating your level 6 Creating your level From now on, everything we do will be created using Michael Little's GLB 2.2. If you are following this tutorial without stopping you got everything ready to start working, but if you closed Gmax and went for a slice of pizza, when you open Gmax again it will be resetted to its defaults so you'll have to set grids and snaps again. From the created “GLB” menu select “GLB2.2” so that the tools are loaded: Click on the “line” button and trace out your map in the top viewport. Remember to have your 2d snaps on and set to “Grid points” so that the line you draw snaps perfectly in Hammer as well. 6 Creating your level TIP: While drawing in the top viewport, roll your middle mouse button up and down to zoom in and out so that you may trace your level out better. Once you close your spline, Gmax will ask if you want to close the line, hit “yes”. Hit the “select all splines” button, then hit the “*add to plan*” button and all of your lines should turn yellow, and finally hit the “output” button and your walls will be extruded with a default height of 128 units. Now, if you want to change the default height or width of your walls, hit the “Select all” button (this is one of the coolest tools GLB has got, and also it's pretty cool the animated way it selects all the walls) in the “edit walls” section (upper right) to highlight all the walls we just created, and then change the values in the spinners. In this case we want to make the walls taller so let's change the default “128” value to “256”. Notice that even after entering the value of “256” and hitting enter we see no changes, so in order to update the walls we must also hit the small “s” next to the spinner. Hit it and now you'll se the walls get taller. 6 Creating your level Ok, we got tall walls. Now let's create a floor for our level. The floor tool is also another of the coolest features GLB has got since it saves us from a lot of work and with just one click we got a nice floor that fits our level perfectly. Here's the procedure: First hit the “create floors” button in the “floors” section. Change the default “floor depth” value to “-16”. A negative value will draw our floor in the negative direction of the “z” axis. Using a value of “16” goes better with our level snaps. Then, on the top viewport, click anywhere inside of the map we have just created. Immediately after you click, you'll see the floor is created and that it perfectly fits our level. GLB tools handle the proper way of subdividing the brushes into separate adequate brushes for Hammer to work with. Imagine having to create each of this brushes by hand! And it's also important to notice that although the floor has been subdivided into several brushes for Hammer, it is still just one mesh in Gmax. The other good thing is that until now we've only done 2 things: draw a line and make a click, and we already hace a 3d map. Pretty cool, huh? Check the floor creation process in the next screenshot: 6 Creating your level Now, we'll use the floor to make a copy of it and make it our ceiling. Since our floor is just one mesh we don't have to worry about selecting multiple brushes and stuff, we'll just have to select it,copy it and move it into place. Let's do it the easy way. Select the arrow icon in Gmax (selector) and in any of the viewports select the newly created floor. With the floor selected, go to max's “edit” menu and select clone. A pop up message will show up asking for the type of clone you want, just leave it in “copy2 and hit “ok”. But where's our clone, I can't see anything? Well, it was placed exactly in the same 3d coordinates as its original so that's why we can't see it. The new clone is selected by default so now all we gotta do is move vertically how many units? ...... yep! If you said 256 units (our wall height) you passed the quiz! So now I'll tell you guys how to move the ceiling up. The arrow icon (selector) to select and clone your floor brush. 6 Creating your level Notice how the active viewport has got a yellow frame around it? To change active viewports just right click inside the one you want to work on. It'll immediately turn yellow. To move the floor to the ceiling we'll be using the perspective viewport, so go on and right click in it (in the air) and make it the active viewport. Now to the right of the selector arrow you'll see this icon : It's the “move” icon, so hit it and since we got our cloned floor selected our next step will be moving it up 256 units. In the lower part of Gmax you'll see the following bar: It's the “Absolute mode transform Type-in”. When activated, it allows us to enter specific values in each of the axis for the different transform operations, in this case “move”. So hit the button (it will turn white) and in the “z” axis enter a value of 256 and hit enter. Remember, you gotta be in the perspective view cause axes are relative to the viewport you are using them from. In the perspective viewport the “z” axis is the vertical axis but in the front viewport we can't see it. Use the axis gizmo in each of the viewports as a guide. Perspective's axis gizmo So now we got walls, floor and ceiling! 7 Exporting the map file We now got a perfectly closed map, with no leaks ready to be exported as a .map file for Hammer. GLB tools are also ready to help you in the creation of windows and door openings but we'll be creating a more complex level in our next tutorial. So far, this is where we'll leave our level ready to be exported. 7 Exporting the map file This should be the quickest of all the things we've done in this tutorial. I would like to remark that the workflow of GLB tools in 3dsmax is exactly the same. It's in the exporting process that we see a difference. 3Dsmax is able to export the .map file directly but since Gmax has got some limitations once we hit the “export to map” button we'll get the script of the map file which we should copy and paste into a text editor and rename this file using the .map extension. Sounds complicated? Well, it isn't...at all. And I love working with the Gmax version of the tools, even owning 3dsmax 5.1, cause you get this “indie” feeling of working with free tools and your bare nails, ha h a h a h a =) Ok, enough chit chat, let's export our map file. First hit the “export to map” buton in GLB tools. A new window will pop up. Hit the “Export scene to .MAP” button and a third window will appear with a bunch of code in it. Don't worry, you don't have to understand it. It's just the coordinate information of each of the brushes we created for Hammer. In fact, if you take any map file (i.e. Half-life) and tell it to open it with a text editor, you'll see something similar. That's why they say experienced mappers polish their levels up in the script. Ok, now select all the code in the third window and copy it, open your favorite text editor (i.e. Notepad) and paste all the code in there. Now, this is something I noticed, since our level is a bit big it produced a lot of code and if you try to select all the code you'll only be able to get half of the it so we'll have to do it in parts. Hit CTRL+A to select everything (but notice it doesn't select it all), copy and paste this part into your text editor. 7 Exporting the map file And then select the rest of the code and paste it where it belongs; in other words, as a continuation of where the original code is. Notice there's a space after my black selection on the left (before the word “notex”) so before pasting the rest of the code in notepad (right) I must enter the same space there. Select the rest of the code with your mouse, clicking and dragging down and paste it in notepad. After you have copied everything, you may close the MaxScript listener window, GLB2.2, and Gmax. You may or may not save the project you created, that really depends if you gotta come back and fix things in the level. Just don't close notepad with all the code you just pasted. Now save your notepad file as “testmap” and change the extension to .map; in other words, save the file you got open in notepad as “testmap.map”. And to make things easier, save it into C:\Ca3DE-MDK\Ca3D-Engine\Games\DeathMatch\MapsEditor which is where Ca3DE source levels are placed for compilation. In this almost final step, we'll open our map file in Hammer, texture it, place some basic entities, compile and run our level with all the eye candy of Ca3DE. 8 Working the file in Hammer 8 Working the file in Hammer Launch Hammer and open “testmap.map” from the “MapsEditor” folder in the MDK. Remember you must have already configured Hammer to work properly with Ca3DE, as well as created a basic set of textures (wad file). If you haven't please read the NewMaterials.pdf that comes with the MDK in which you'll find everything you need, in a very detailed way, to set up Hammer for Ca3DE. When we open the file in Hammer we notice it's completely white. Well, that'll be our job; to texture it: Another good idea here would be to hit the minus (-) sign in the third icon of the main toolbar (from left to right) to decrease grid size down. Hammer's grid is defaulted to be big. Hit it twice to get a 1:1 correspondence with what we created in Gmax. If we zoom in you'll notice that everything is snapped. Only diagonal lines may be misplaced but are not creating any troublesome geometry; in fact, they're snapped if you decrease the grid snap several times more and zoom in. This wouldn't be this way if we didn't work snapped in Gmax. So my advice is: work with snaps on in Gmax and you'll have a Snapped map in Hammer. 8 Working the file in Hammer Orthogonal lines perfectly snapped in Hammer. Now we are going to do a very quick texturing process. So go into camera view, select all the walls and apply a texture to them: Remember how our floor had a depth of -16 units? Since we moved it up 256 units we still got those negative 16 units overlapping with our walls. They may not be a problem but it's a good chance to make the correction in Hammer. Remember that in Gmax the floorceiling was just one mesh but in Hammer if you try to select the floor you'll notice you only grab a part of it. In hammer the Gmax meshes are divided into optimized brushes that Hammer can understand. So Ctrl+Click on all the ceiling brushes and in a side viewport move them up 16 units. So it's another cool way of checking the seamless correspondence we got beween Gmax and Hammer! Remember to work snapped! And remember to decrease the grid size to fit our map scale! 8 Working the file in Hammer Now to make things cooler, let's select all of the ceiling brushes and texture them as “Sky”. We'll change the map properties later in order to get a skybox up and running. So select Ca3DE's sky texture and apply it to all the ceiling brushes. Don't worry, sky textures don't generate leaks. The ceiling brushes moved up 16 units, selected and textured with the “sky” texture. Now let's texture the floor. The floor brushes selected from underneath and textured. Since Ca3DE's skyboxes got light shaders pre-calculated, another cool feature to add in would be some “beams” crossing our walls to cast some shadows on the floor. We can add these “beams” creating them as regular brushes in Hammer. 8 Working the file in Hammer Some beams. Now select Map-map properties and in “Sky name” type in “PK_Autumn” (which comes with the additional skyboxes downloaded from Ca3DE's site) and enter the following illumination values (in map properties): sunlight dir-vec x 6 sunlight dir-vec y 5 sunlight dir-vec z -12 Sunlight W/m2 red Sunlight W/m2 green Sunlight W/m2 blue 100 90 80 leave the other values at their default levels. Add a player start: Go to “Map” - “Check for problems” or hit Alt+p to see if anything is wrong. If nothing is wrong you're ready to compile!!!! 8 Working the file in Hammer Compilation of the map file must be done according to the MDK's newmaterials documentation. I've created a .bat batch file that performs each of the processes required in order to get the level up and running in Ca3DE, simply edit it and replace the name of your map in it. You may get the .bat file and the .map files of this tutorial here: http://www.theshower.nl/cgi-bin/genesis/web_pages/afecelis/tutorial.zip And finally, the level running in Ca3DE: Notice the cool shadows casted by the beams we added. Remember you may also play around with all the lights that come with the engine. Its potential for interior levels is amazing and also don't forget that the latest release already includes terrain and model support! Well, I think this pretty much wraps it up. I hope you found this tutorial useful and clear and I also hope to keep improving it. If you got any comments please email me at: afecelis@intercable.net.co I hope you guys had as much fun following the tutorial as I did writing it. Cheers! 9 Credits and thanks 9 Credits and thanks I would like to express my appreciation and thanks to the following people and organizations who in one way or another contributed to make this tutorial see the light: Carsten Fuchs: What else can I say, he created the engine! And he's been very supportive giving me ideas on how to improve the tutorial. He also sponsors this tutorial in his site and is giving me a hand on making it popular in the forums. Besides that, he tolerates each and every of my annoying emails asking him about every little thing that crosses my mind regarding to the engine =) , and he has also let me participate in the project in a very close way. Thanks Carsten! Michael Little: For creating the Game Level Builder set of tools and improving it with every new release. Also for making them fully workable even with version 3 in the horizon and about to come out. You really deserve to be making money out of your tools and I'll be one of the first one to acquire them! And finally for taking the time to download the tutorial and read it. Your feedback was very valuable and I tried to apply all of your ideas in this new version. I only left windows and doors out but they will be part of next tutorial. Thank you! Kai Schadwinkel (AKA Kai_S): For all the feedback you gave me in the forums. Your ideas with regard to “the snapping problem” made me look for an alternative solution that ended up by being the simplest of all: turning snaps on in Gmax and setting units properly. Ah! And also for being the first one to download and try the first version of the tutorial. And the most important, for the huge amount of work you put into the engine. I definitely think Ca3DE has got a lot of LOVE from people around it. =) DISCREET: For releasing Gmax to the public as a free download for non-commercial use. VALVE: For Hammer (besides the whole bunch of stuff they've revolutionized the gaming industry with). Finally, to everyone in the Ca3DE community as well as to anyone who uses this tutorial and makes something useful out of it. Remember, creating is better but creating requires actions! Get involved in something you like, no matter how big or small... you never know what others will think of what you're doing!!! Sincerely, ALVARO F. CELIS