Custom surface parms

Topics relating to D-Day modeling/coding/skinning etc.

Moderator: Rab,d

Post Reply
Boons
Developer
Developer
Posts: 597
Joined: Sat Aug 20, 2005 6:36 pm

Custom surface parms

Post by Boons »

Custom surfaceparms

With the new q3map tool you can add custom surface parameters for mods without the need to recompile the q3map tool. These custom surfaceparms are stored in a file called ?custinfoparms.txt? in the folder scripts/. An example of this file with the new surfaceparm treacle and surfaceparm grass is shown below.

// Custom Infoparms File
// Custom Contentsflags
{
treacle 0x4000
}
// Custom Surfaceflags
{
grass 0x80000
}



NOTE: For linux users, when using the -custinfoparms parameter q3map first looks in your homedir, and only if it doesn't find a custinfoparms.txt there, it uses the one stored in the

quake3 install dir (usually /usr/local/games).



Content Flags

Contents flags are flags similar to CONTENTS_FOG in the original Q3A. These flags define the contents of volumes inside the game (for instance lava, fog, water, etc.).

If you look in the source file game/surfaceflags.h, it has defines for all contents flags. The define is split into a name and a hexadecimal value, for instance CONTENTS_PLAYERCLIP 0x10000. These hexadecimal values are powers of 2 and can be ored together (binary) to form a bit mask. Up to 32 contents flags can be ored together this way.

Example: creating a volume with treacle.

The following outlines how a custom contents flag can be added and used in a mod. First open the ?custinfoparms.txt? file and add ?treacle 0x4000? to the Custom Contentsflags section as shown in the example file above (0x4000 is one of the unused values available for custom use). Next write a shader script which uses ?surfaceparm treacle?. Apply this new shader to all sides of a brush in a test map. When you compile the map, add the -custinfoparms parameter to the command line following q3map.

Next, add CONTENTS_TREACLE 0x4000 to the source file game/surfaceflags.h in your mod. Now you can call the point contents function. If the point is inside the brush with the shader using the ?surfaceparm treacle? then the point contents call will return a bit mask with CONTENTS_TREACLE set. This can for instance be used to slow down player movement when a player is inside such a brush.



Surface Flags

The surface flags are texture properties that often affect entities in contact with surfaces using such flags. The ?surfaceparm metalsteps? parameter from Q3A is a good example.

If you look in the source file game/surfaceflags.h, it has defines for all surface flags. The define is split into a name and a hexadecimal value, for instance SURF_NODAMAGE 0x1. These hexadecimal values are powers of 2 and can be ored together (binary) to form a bit mask. Up to 32 surface flags can be ored together this way.

Example: Making ?footsteps on grass? sounds

The following outlines how a custom surface flag can be added and used in a mod. First open up the ?custinfoparms.txt? file and add 'grass 0x80000' to the Custom Surfaceflags section as shown in the example file above (0x80000 is the first available unused value in surfaceflags.h for surface flags). Next write a shader script which uses a grass image and has 'surfaceparm grass?. Create a test map with the grass shader covering the ground surface. When you compile the map, add the -custinfoparms parameter to the command line following q3map.

Next, add SURF_GRASS 0x80000 to the source file game/surfaceflags.h in your mod. Now you'll be able to execute a trace and the trace information will be returned in the trace_t structure. If the trace hits a surface with the grass surfaceparm then the SURF_GRASS flag will be set in trace_t->surfaceFlags. Such a trace can be used to trigger playing a sound of a person stepping on grass. For a reference example, see the existing metal steps in the game code.



Anyone make sense of this?
Image
Image
User avatar
Night Rider
Posts: 418
Joined: Sun Feb 14, 2010 3:48 pm
Location: North of Boston,Mass
Contact:

Re: Custom surface parms

Post by Night Rider »

By the way Boons what is the new Q3Map tool that is out there?
"Life is tough, but it's tougher when you're stupid"
John Wayne

Image
Boons
Developer
Developer
Posts: 597
Joined: Sat Aug 20, 2005 6:36 pm

Re: Custom surface parms

Post by Boons »

I am assuming the newer compiler of the two.. there is nothing "new" this is old..
Image
Image
Post Reply