Ultimate 3D options

There is a couple of options in Ultimate 3D to modify the way it will load data, render scenes and handle errors. A few of these options have to be set up before Ultimate 3D gets initialized, while others can be changed at any time using the corresponding functions. Those that have to be set up before Ultimate 3D gets initialized get set up in the script Ultimate3DOptions(). This script is not meant to be called by the user. It will be called once when Ultimate 3D gets initialized, that's all. The fact that it's a script instead of a number of Game Maker constants results in an advantage for you, because this way you can load the options from a file. Currently there are seven options which get set up by setting up variables in the script Ultimate3DOptions():

global.u3d_splash_screen_file
You've got to set this variable to a string. If you do not want Ultimate 3D to display a splash screen while it's loading the resources, you can set this variable to an empty string (""). Otherwise, you should set up the filename including the ending and the path for this variable.

global.u3d_z_buffer_format
This variable can have either the value 16 or 32. If you set it to 32 Ultimate 3D will try to create a device that uses 32 bit z-buffering. Z-buffering is a technique that's used to avoid that objects that are in front of other objects get covered by objects behind them. If you set it to 16 Ultimate 3D will use 16 bit z-buffering for sure.

global.u3d_multi_sample_type
This variable can take an integer value in the range from 2 to 16 or 0. It defines the number of samples that will be used for antialiasing. In case it's 0 no antialiasing will be used. The higher the value is, the stronger will be the antialiasing. Note that the number of supported samples differs from graphics device to graphics device. Some graphics devices do not support antialiasing at all. Another thing you should note is that antialiasing will not have a any effect if post screen shaders are active.

global.u3d_device_type
If you do not have a good reason not to do so, you should set this variable to 0. Ultimate 3D will then create the most efficient device type that offers all required functionality. If you set it to 1, Ultimate 3D will create a device that uses software vertex processing. This means that the central processing unit (CPU) will calculate the vertex data instead of the graphics processing unit (GPU). Usually this makes no sense at all. The only case in which you should use this option is when there's a bug in the graphics device driver that leads to a crash when using particular features with hardware vertex processing. I have experienced this with an ATI driver when using vertex tweening. Finally you can set this variable to 2 to create a complete software device (using the Direct 3D reference layer). This will lead to extremely low frame rates but all features (cube mapping, shadow casting and pixel shader model 1.4) will be supported for sure.

global.u3d_log_file
This variable can be set to the filename (with path) of a text file, e.g. "LogFile.txt". If it is set to a string Ultimate 3D will create a log file, while it is running. To this log file it will output a lot of relevant information (in particular all error messages and warnings, information about the device and its capabilities and some information about the success of particular operations). If you, or a user of one of your Ultimate 3D based applications has problems with your application the log file will make it a lot easier to find the cause of this problem.

global.u3d_few_message_output
This variable can be set to true, to reduce the number of onscreen error messages Ultimate 3D will show. If it is set to true Ultimate 3D will only show error messages, if they are crucial and could make the application crash. The log file output is not effected by this.

global.u3d_character_set
This variable is used to modify the character set, which is used by Ultimate 3D to create fonts. If this variable is not set or is set to an empty string the default character set is used. This character set contains all human readable characters, which are not country-specific (ASCII codes 32 to 127). If the language you develop your game in contains special characters or if it uses its own alphabet, you need a different character set. For this purpose you have to set this variable to a string, which contains all characters, which should be included in the character set. A single character must not occur twice within the string ("AaBb" is valid, but "AaBbA" is not). Whitespaces should not be included. If a character is to be drawn, which is not contained within the character set a space will be drawn instead. The order of the characters does not matter. A very basic character set string could look like this:
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789-_.?,!+-/*'"


As I already said, the other options can be changed at any time using functions. The first available option is really easy to understand. If you are using Ultimate 3D you should know that it searches for model textures by default in the folder "gfx". If you want it to search them somewhere else you can use the following function to give a new path (including the slash at the end).

This function changes the directory Ultimate 3D searches model textures in.

SetTexturePath(
TextureDirectory
)

TextureDirectory
The directory that contains the textures including the slash at the end.


The next function does not actually change an option, but disables the render output of Ultimate 3D to give Game Maker the possibility to draw to the first view. It's called SwitchView() and does not take any parameters.

The next function changes the filtering method that is used for the given texture stage. The filtering method defines how Ultimate 3D will calculate a color from a texture and a texture coordinate. The default filtering method is linear filtering.

This function sets up a new filtering method for the given texture stage.

SetFilter(
TextureFilter,
TextureStage
)

TextureFilter
The filter that is to be used for filtering textures. Here's a list of the meanings of the different values you can enter for this parameter:
1: Nearest point filtering: The color of the closest texel will be used.
2: Linear filtering: The color of the closest four texels will be interpolated to get smoother results.
3: Anisotropic filtering: A more complex filtering method that can lead to better results. It is not supported by some graphics devices.

TextureStage
The texture stage you want to set up the texture filter for. This can be an arbitrary integer value in the range from 0 to 7. By default every texture stage uses linear filtering. If you pass -1 for this parameter, the specified texture filter will be used for drawing textures (using
DrawTex(...) and DrawTexEx(...)). By setting up nearest point filtering for texture drawing you can avoid a quality loss.


The next function sets up how many mip maps are to be created for the textures that will be loaded. Creating mip maps means creating lower resolution versions of each texture that can be used depending on the distance to the object that uses it. Each mip map will have a resolution that's half as big as the resolution of the previous mip map (e. g.: Mip map count set to three leads to: 512*256; 256*128; 128*64).

This function sets up the number of mip maps to be created for the textures that will be loaded.

SetMipMapCount(
NewMipMapCount
)

NewMipMapCount
The new mip map count, which is the number of lower resolution copies that are to be created for every texture.


You can also specify how Ultimate 3D interpolates between mip maps. By default nearest point filtering is used for this purpose. This means that every pixel uses just one mip map. Between the mip maps there are sudden changes, which can be seen quite well, especially on detailed textures. You can tell exactly where the program stops using one mip map and continuse using a lower one. Setting up linear filtering to interpolate between mip maps can avoid this undesireable effect.

This function sets the filter, which is to be used to interpolate between mip maps in the given texture stage.

SetMipMapFilter(
TextureFilter,
TextureStage
)

TextureFilter
The filter that is to be used for interpolation between mip maps. By default nearest point filtering is used (1). The common alternative is linear filtering (2). For a detailed list of all available filters refer to the description of
SetFilter(...).

TextureStage
The texture stage for which you want to set up the mip map filter. This can be an arbitrary integer value in the range from 0 to 7.


Finally there is a function to make Ultimate 3D switch to wireframe rendering for particular objects. Wireframe rendering means rendering only the outlines of the triangles. This feature is meant to be used for things like level editors. Using wireframe rendering to implement ingame effects usually does not look very good.

This function can be used to enable or disable wireframe rendering for the model, terrain or primitive object, which calls this function.

SwitchWireFrameMode(
EnableDisable
)

EnableDisable
If you pass true for this parameter wire frame rendering will get enabled, otherwise it will get disabled.


If you are using Game Maker 6.0 or higher there is one additional variable you need to know about. You may have noticed that Ultimate 3D does not show the cursor, even if the corresponding Game Maker option is enabled. The reason for this behavior is that Game Maker 6.0 and higher (in opposite to Game Maker 5.x) does not offer a possibility to find out whether it currently displays the cursor or not. For that reason you have to give this information manually. This can be done by changing the value of control.show_cursor. Setting it to true will make Ulitmate 3D show the cursor, setting it to false will disable the cursor.



© Christoph Peters. Some rights reserved.

Creative Commons License XHTML 1.0 Transitional