Surface Types

From The DarkMod Wiki
Revision as of 13:36, 11 September 2006 by Greebo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Originally written by Ishtvan on http://forums.thedarkmod.com/topic/2974

Okay, adding the new surface types wasn't as easy as I thought, but I have put in a system for it and it works. This is subject to change. However, unless people really don't like this, I think we can go with this.

The following surfaces are standard D3 surfaces. We cannot change the name of these even if we wanted to.

Old (D3) Surface Types

Put these in the first line of the .mtr file

  • none
  • metal
  • stone
  • flesh
  • wood
  • cardboard
  • liquid
  • glass
  • plastic
  • ricochet
  • surftype10
  • surftype11
  • surftype12
  • surftype13
  • surftype14

New (unique to TDM) surface types

Use surftype15 and put surface in description string (this list is not fixed, we can keep adding to it):

  • tile
  • carpet
  • dirt
  • gravel
  • grass
  • rock
  • twigs
  • foliage
  • sand
  • mud
  • brokeglass
  • snow
  • ice
  • squeakboard
  • puddle
  • moss
  • cloth
  • ceramic
  • climbable
  • slate
  • straw
  • armor_leath
  • armor_chain
  • armor_plate

Instructions on putting in new surfaces

We had to do some tricks to expand the list of surfaces. In the material file, put surftype15 as the first line. Then, in the "description" line, put the new surface type in quotes. If you want to add anything after that, that's fine, just make sure the surface type is the first thing in the description, and you put a space after it.

NOTE: Old surfaces can be entered the same way as new surfaces, but it decreases performance You could use the surftype15/description method to enter surface types for old D3 textures if you wanted. Entering it the "old" way would lead to slightly faster performance though, since wood is in the enumeration so no string manipulation is required. I don't think this performance impact will be noticable, but you never know.

Examples

Putting in one of the old D3 surface types, wood:

textures/darkmod/mansion/floor/manfloor03
{    
   wood
   qer_editorimage  textures/darkmod/mansion/floor/manfloor03.tga
   diffusemap       textures/darkmod/mansion/floor/manfloor03.tga      
   specularmap      textures/darkmod/mansion/floor/manfloor03_s.tga
}

Putting in a new surface type, tile:

textures/darkmod/mansion/floor/manfloor02cen2
{  
   surftype15 

   description "tile"
 
   qer_editorimage  textures/darkmod/mansion/floor/manfloor02cen2.tga    
   diffusemap       textures/darkmod/mansion/floor/manfloor02cen2.tga  
   specularmap      textures/darkmod/mansion/floor/manfloor02cen2_s.tga
}

Again, note that you could put more in the description line, for example:

   description "tile This is a tile mosaic that might look nice in a mansion entry hall"

This will work because the first word is tile and there's a space after it.

Warning!

As of now, there is no system to tell you when you make a typo in the new surface type name that goes in the description field. The surface just won't play the proper sounds, etc, it will play the default sounds or none. In the final release, we will hopefully include a quick parser that will go thru the material files for the map and let you know if the new surface types don't match the valid ones.

What surfaces do

Surfaces are used to tell what sound to play when you walk on a surface (this code is already in D3, we just have to tell it what sounds to play and how loud those sounds should be to AI). They are also used when a projectile hits a surface, to play a specific sound, give off a specific particle effect, or, in the future, to trigger a specific action (rope arrow only sticks in wood).

We also plan to play a sound unique to the combination of two surfaces when two objects collide (for example, a ceramic cup hitting a wood floor). We also plan to use surfaces to determine armor factors in combat (an arrow will bounce off the AI's helmet, but if you shoot it right into the eye opening, it will hurt). Some of these are for coding purposes only, like "climbable." This does not mean we have any climbing code done, it's just planning for the future.

Also note that soundprop data has not been added for the majority of surfaces, so it's not a bug that AI don't respond to your footsteps on wood or carpet, it just doesn't have the footstep volume modifier data entered for those surfaces yet.