NavigationUser login |
TexturesMost objects in Shattered World are textured. Texturing involves applying a 2D image to the surface of a shape like a bowl of soup. In most glscene objects a texture is applied directly to the outside of the object such as a cube. Other objects like freeform's and actor's can have different parts of a texture mapped to different parts of model such as an arm texture being mapped to the left arm and the same part of the texture mapped to the right arm. In freeform's and actor's the textures used can be defined in the model itself. In other glscene objects they are specified in the 'texture' attribute of an object. Thus for a cube object you can apply a cloud texture as follows: <CUBE cubeheight="0.2" cubewidth="0.3" cubedepth="0.1" texture="textures\clouds.jpg"/> where the clouds.jpg file will be in c:\program files\mudclient\client\textures The cloud texture will be applied using default texture settings specified in texturesettings eg texture scale is 1. To change the texture settings of a texture you can specify the texture in the textures element. For example if you wanted to scale the texture so it was scaled to be 6 times smaller and set the TEXTURE element to: <TEXTURE texture="textures\clouds.jpg" scale="6" texturewrap="both" /> textures can be shared eg a cube and freeform can shared the same texture thus saving memory. It is possible to use images when texturing. For example it is possible to draw a red cube: <CUBE cubeheight="0.2" cubewidth="0.3" cubedepth="0.1" texture="@red"/> The corresponding texture in texturelist would be: <TEXTURE texture="@red" frontpropertiesemission="FF0000" /> The '@' symbol represents a texture that has no image. Making Textures OpenGL scales textures to the power of 2 in memory thus a 129x 128 pixel texture will be stored in memory as 256x 128 pixels thus it is wise to scale textures yourself to the power of 2 eg to 128x128 to save video card memory. Transparent textures using the texture: This reduces the number of polygons required to draw a town so increases frame rate. It also useful in displaying vegetation. A transparent texture on a sprite can display plant for example: Transparency in a texture can be specified in an alpha channel in files with the '.tga' format. Jpegs have no alpha channel therefore cannot store transparency. An example of a transparent texture in Shattered World is: c:\program files\mudclient\client\textures\clock.tga In GIMP you can click on the 'erase' button to erase more parts around the clock. To view the clock in a plane you would use: <PLANE name="clock" texture="textures\clock.tga" height="0.4" width="0.2"/> and in texturelist set 'imagealpha' to default: <TEXTURE name="textures\clock.tga" imagealpha="default"/> If you do not use an image with an alpha channel you can also specify transparency with superblacktransparency. Superblack transparency means that everything in the image that is black will be made transparent. This article gives more information about superblack transparency: http://glscene.sourceforge.net/wikka/UsingSuperBlackTransparency Instead of imagealpha="default" you'd use imagealpha="superblacktransparency" If you want to make a texture transparent in its entirety you dont need an alpha channel or superblack transparency. You can just set the 'alpha' attribute of a TEXTURE so that it less than 1. For example if you want to make a transparent red cube you can define the following cube: <CUBE cubeheight="0.2" cubewidth="0.3" cubedepth="0.1" texture="@red"/> The corresponding texture in texturelist would be: <TEXTURE texture="@red" frontpropertiesemission="FF0000" alpha="0.5" /> Moving Textures
This is achieved by setting the 'addscaledvectorx' and/or 'addscaledvectory' attributes in the TEXTURE element in texturelist. For example: <TEXTURE texture="models\gargoyle.jpg" addscaledvectorx="0.1"/> will scroll the texture in the x texture direction repeating every 10 seconds. Secondary Textures This is useful if for example you have a low detail 256x256 terrain texture that you map directly onto the terrain. To add detail to the ground you might apply a repeating secondary texture such as stones to give the appearance of detail. To use secondary textures in the mud client you set the 'texture2name' attribute in the TEXTURE element to the name of the secondary texture. This 'texture2name' will then reference another texture in the texturelist. Unfortunately secondary textures can greatly reduce frame rate therefore are not used in Shattered World. Texture Management in the mud client Cubemap Reflection <TEXTURE texture="models\gargoyle.jpg" mappingmode="cubemapreflection" addscaledvectorx="0.1"/> Texture Settings based upon extensions <TEXTURESETTINGS> </TEXTURESETTINGS> |