FEATURE September 10, 2001
Using Max Script for Building Game Levels (Continued)
by Shailesh Watsa
Advantages and Disadvantages of this System
With this system in Max, one can build a level mesh with the ease associated with CSG modeling. If you compare this to building low poly level meshes in Max using loft or actually building faces, this method is far easier to create and more flexible to changes. Because the user makes the world using CSG primitives or brushes, he can easily make any changes to the primitives at any point of time. The resulting level mesh is built by script, and therefore cuts out manual work significantly.
All properties are stored against the primitives. Applying materials and mapping texture co-ordinates, are all done on the primitives. Hence, when the level mesh is built no property or work is lost. Moreover, since we are working inside Max, we can use Max modifiers like Bend, Taper and Skew on the primitives. Max modifiers are easy to use, and some of them may not exist in other CSG builders.
Here are some of the disadvantages or areas of improvement in the present system:
- The script currently depends on Max booleans while building the world from primitives. Therefore, it does not have complete control over the creation of the actual faces and vertices. Because of this, later on while building the export-mesh, the script has to check and link back the objects for export with the primitives.
- As the level mesh increases in size, building the export-mesh takes more time, especially when you want to club the tiny lightmaps into larger ones. Although this is faster than creating and mapping lightmaps manually, it could help speeding it up a bit.
- Though mapping changes to the primitives are reflected immediately, new materials assigned to these primitives are not seen on the world mesh until you build the world.
- Sometimes, some faces in the built world get wrong mapping co-ordinates while booleaning.
- Max script has no access to some elements inside Max. Two things that would have helped the existing script while building the world, are access to the vertex weld threshold spinner and the explode threshold spinner. Presently, the script file takes the threshold that was last set by the user inside Max. It can't set the threshold to a set value.
A script or plugin to generate the world mesh through BSP instead of Boolean would probably have more control over the actual faces and vertices being built. That should take care of many problems. With a little more control given to Max script over the elements inside Max, the user could get scripts that are more accurate.
Advantages of Building Levels in Max4 or GMax
When we started developing our own engine, we soon realized that we would need our own level editor. We were already using Max to create and export our meshes into our engine using custom plugin exporters. Since making our own editor would involve a lot of time and manpower, we turned to adapting Max to meet our level building needs. At this point, I must say that it has proved to be worth it. Eventually, we had our set of custom plugins and Max scripts to build game levels in Max, which met our engine specifications.
I may be a little biased towards Max since I have been a Max user since the 3D studio 2 days. However, I sincerely feel that Max is a very powerful tool, for not only building high poly scenes and characters, but also for building low-resolution level meshes.
To start with, if you are looking to make Max your game level builder, you don't have to start from scratch. You can select and use all the existing features in Max. For instance, the basic Max UI itself is ready to use. The Max UI moreover is totally customizable. You can write custom plugins and scripts, which a user can build game levels that are tailored for your game engine.
Features like object-user-properties that Max already has are very useful, and can be used extensively. The Unwrap UVW in Max is another widely used tool. When mapping low polygon meshes, it gives you total control over its mapping co-ordinates. Max actually let's you work on meshes at the basic vertex or texture vertex level, thereby giving you total control over the mesh that you are creating.
There are so many features in Max that can be used or adapted to meet your needs, such as material properties for surfaces in your level mesh, splines and bezier patches, which can be used if your game engine supports bezier patches. For instance, we used bezier splines to create and export camera paths and character paths into our engine. I couldn't possibly list all the features in Max that are available because it's too vast and its utility would vary depending on ones needs.
I have not had the opportunity to work on Max 4 or GMax until now. But from the all the reviews about it, that I have been closely observing, I can see lots of goodies in store that can be put to good use. First, the viewports claim to be WYSIWYG. One of the reasons for not lighting the mesh within Max itself was that the Max viewports could display only one texture at a time. With support for multiple textures, it could probably display textures as well as lightmaps at the same time. Since it uses DirectX8, you should be able to blend or modulate textures. You could even push other texture layers like noise and stains into the viewport display inside Max. This would get the display within Max close, if not similar to what you would see in your own game engine using DirectX8.
At present, we have our own fire and smoke particle systems. We can bring it all into Max, since Max viewports now support true transparencies. This huge enhancement in the Max viewport display itself is a big reason to consider using Max or GMax as your level editor.
Another feature that draws attention are object attributes. You can now set your own custom attributes for objects, thereby making them unique and capable of fitting the specifications that you want for your game engine. Although you can use object-user-properties to set and retrieve properties on objects, custom-object-attributes would permanently attach these attributes to every object in your scene.
Another important feature is ability to set individual properties for every face in your level mesh. For instance, the existing script can now link and store information against each face to the primitive that it belongs to, without actually breaking them apart.
Defining your own brushes is yet another big feature in Max4. A CSG level builder, for example, can make use of this feature to define and work on its own custom brushes. With DirectX8, it even supports per pixel and vertex lighting inside the Max viewports.
GMax is a subset of Max4 with a feature list that suits building game levels. Therefore, it should be a much smaller program that focuses towards building game levels. Licensed programmers will be able to define their own file types in addition to custom functions and plugins. Moreover, since GMax will be freely downloadable a game player can download your game module and run it on GMax to edit existing game levels, or to create new levels for your game.
There are hundreds of new features and enhancements in Max4 and GMax. The features that I have discussed are significant for game level editing, which I feel can be put to immense use if you plan on using Max4 or Gmax. There is so much in store included in the new version of Max and Gmax, and it is up to us to adapt and use these features to their fullest.
(Originally published in Gamasutra August 2001.)