TextureUnit
From oWiki
Attributes
mat
string ( r )
The material name associated with this TextureUnit.
technique
int ( r )
The index of technique associated with this TextureUnit.
pass
int ( r )
The index of pass associated with this TextureUnit.
index
int ( r )
The indexed location of this TextureUnit.
textureName
string ( r, w )
Gets/Sets the name of this TextureUnit. This is a short hand method to setTextureName(name, TEX_TYPE_2D).
textureType
string ( r )
Gets the type of this texture.
Possible types are:
| Value | Description |
|---|---|
| TEX_TYPE_1D | 1D texture, used in combination with 1D texture coordinates |
| TEX_TYPE_2D | 2D texture, used in combination with 2D texture coordinates (default) |
| TEX_TYPE_3D | 3D volume texture, used in combination with 3D texture coordinates |
| TEX_TYPE_CUBE_MAP | 3D cube map, used in combination with 3D texture coordinates |
textureCoordSet
int ( r, w )
Gets/Sets the index of the set of texture co-ords this layer uses.
Default is 0 for all layers. Only change this if you have provided multiple texture co-ords per vertex. Applies to both fixed-function and programmable pipeline.
currentFrame
int ( r, w )
Gets/Sets the active frame in an animated or multi-image texture. An animated texture (or a cubic texture where the images are not combined for 3D use) is made up of a number of frames. This method sets the active frame.
frameCount
int ( r )
Gets the number of frames for a texture.
animationDuration
float ( r )
Gets the duration of a texture animation in seconds.
bindingType
int ( r, w )
Gets/Sets the type of unit these texture settings should be bound to.
Some render systems, when implementing vertex texture fetch, separate the binding of textures for use in the vertex program versus those used in fragment programs. This setting allows you to target the vertex processing unit with a texture binding, in those cases. For rendersystems which have a unified binding for the vertex and fragment units, this setting makes no difference.
Possible types are: BT_FRAGMENT or BT_VERTEX.
contentType
int ( r, w )
Gets/Sets the type of content this TextureUnit references.
Possible types are: CONTENT_NAMED, CONTENT_SHADOW, or CONTENT_COMPOSITOR.
pixelFormat
int ( r, w )
Gets/Sets the desired pixel format when load the texture.
numMidmaps
int ( r, w )
Gets/Sets how many mipmaps have been requested for the texture.
isAlpha
bool ( r, w )
Gets/Sets whether this texture is requested to be loaded as alpha if single channel.
hardwareGamaEnabled
bool ( r, w )
Gets/Sets whether this texture will be set up so that on sampling it, hardware gamma correction is applied.
colorBlendMode
int ( r )
Gets multitexturing color blending mode.
The returned value is an object with the following properties:
| Value | Description |
|---|---|
| blendType | The type of blending (LBT_COLOUR or LBT_ALPHA). |
| operation | The operation to be applied. Possible values are: LBX_SOURCE1: use source1 without modification. |
| source1 | List of valid sources of values for blending operations. Possible values are: LBS_CURRENT : the colour as built up from previous stages. |
| source2 | List of valid sources of values for blending operations. Possible values are: LBS_CURRENT : the colour as built up from previous stages. |
| color1 | Manual colour value for manual source1. RGBA. |
| color2 | Manual colour value for manual source2. RGBA. |
| alpha1 | Manual alpha value for manual source1. float. |
| alpha2 | Manual alpha value for manual source2. float. |
| factor | Manual blending factor. float. |
alphaBlendMode
int ( r )
Gets multitexturing alpha blending mode.
The returned value is an object with the same properties as in colorBlendMode (see above.)
Methods
setTextureName( name, type )
name: string
type: int
| Sets this texture layer to use a single texture, given the name of the texture to use on this layer. | ||||||||||
Possible types are:
|
setCubicTextureName( name, forUVW )
name: string
forUVW: bool
| Sets this texture layer to use a combination of 6 texture maps, each one relating to a face of a cube. |
| The input parameter name is the basic name of the texture e.g. brickwall.jpg, stonefloor.png. There must be 6 versions of this texture with the suffixes _fr, _bk, _up, _dn, _lf, and _rt (before the extension) which make up the 6 sides of the box. The textures must all be the same size and be powers of 2 in width & height. |
| Set forUVW to true if you want a single 3D texture addressable with 3D texture coordinates rather than 6 separate textures. Useful for cubic environment mapping. |
setAnimatedTextureName( name, numFrames, duration )
name: string
numFrames: int
duration: float
| Sets the names of the texture images for an animated texture. |
| Animated textures are just a series of images making up the frames of the animation. All the images must be the same size, and their names must have a frame number appended before the extension, e.g. if you specify a name of "wall.jpg" with 3 frames, the image names must be "wall_0.jpg", "wall_1.jpg" and "wall_2.jpg". You can change the active frame on a texture layer by calling the setCurrentFrame method. |
| duration is the length of time it takes to display the whole animation sequence, in seconds. If 0, no automatic transition occurs. |
getTextureSize( frame )
frame: int (optional)
| Returns the width and height of the texture in the given frame. By default, frame is 0. |
| The returned value is an object with width and height properties. |
setProjectiveTexturing( enabled, proj )
enabled: bool
proj: a Projector object
| Enables or disables projective texturing on this texture unit. |
| Projective texturing allows you to generate texture coordinates based on a Projector, which gives the impression that a texture is being projected onto the surface. Note that once you have called this method, the texture unit continues to monitor the Projector you passed in and the projection will change if you can alter it. It also means that you must ensure that the Projector object you pass a pointer to remains in existence for as long as this TextureUnit does. |
| This effect cannot be combined with other texture generation effects, such as environment mapping. It also has no effect on passes which have a vertex program enabled - projective texturing has to be done in the vertex program instead. |
setFrameTextureName( name, frame )
name: string
frame: int
| Sets the name of the texture associated with a frame. |
getFrameTextureName( frame )
frame: int
Return: string
| Gets the name of the texture associated with a frame. |
addFrameTextureName( name )
name: string
| Adds a Texture name to the end of the frame container. |
deleteFrameTextureName( frame )
frame: int
| deletes a specific texture frame. |
isBlank()
Return: bool
| Determines if this texture layer is currently blank. |
setBlank()
| Sets this texture layer to be blank. |
isLoaded()
Return: bool
| Tests if the texture associated with this unit is loaded. |
isTextureLoadFailing()
Return: bool
| Tests if the texture associated with this unit has failed to load. |
retryTextureLoad()
| Tells the unit to retry loading the texture if it had failed to load. |
isCubic()
Return: bool
| Returns true if this texture unit is either a series of 6 2D textures, each in it's own frame, or is a full 3D cube map. |
is3D()
Return: bool
| Returns true if this texture layer uses a composite 3D cubic texture. |
setTextureScroll( u, v )
u: float. The amount the texture should be moved horizontally (u direction).
v: float. The amount the texture should be moved vertically (v direction).
| Sets the translation offset of the texture, i.e. scrolls the texture. |
getTextureScroll()
Return: object {u: 0.2, v: 0.5}
| Gets the currently translation offset of the texture. |
setTextureScale( u, v )
u: float. The value by which the texture is to be scaled horizontally.
v: float. The value by which the texture is to be scaled vertically.
| Sets the scaling factor applied to texture coordinates. |
getTextureScale()
Return: object {u: 0.2, v: 0.5}
| Gets the current scaling factor applied to texture coordinates. |
setTextureRotate( a )
a: float, the angle of rotation in degrees
| Sets the anticlockwise rotation factor applied to texture coordinates. |
getTextureRotate()
Return: float in degrees
| Gets the current anticlockwise rotation factor applied to texture coordinates. |
setTextureAddressingMode( u, v, w )
u: int. mode for u direction
v: int. mode for v direction
w: int. mode for w direction
| Sets the texture addressing mode, i.e. what happens at uv values above 1.0. | ||||||||||
Possible addressing modes are:
|
getTextureAddressingMode()
Return: object {u:int, v:int, w:int}
| Gets the texture addressing mode for a given coordinate. |
setTextureBorderColor( c )
c: RGBA
| Sets the texture border color. The default is Black, and this value only used when addressing mode is TAM_BORDER. |
getTextureBorderColor()
Return: RGBA
| Gets the texture border color. |
setTextureFiltering( type, opts )
type: int
opts: int
| Set a single filtering option on this texture unit. | ||||||||||
Possible filter types are:
| ||||||||||
Possible filter options are:
|
setTextureFiltering( minFilter, magFilter, mipFilter )
minFilter: int
magFilter: int
mipFilter: int
| Set a the detailed filtering options on this texture unit. | ||||||||||
Possible filter options are:
|
setTextureFiltering( filterType )
filterType: int
| Set the texture filtering for this unit, using the simplified interface. | ||||||||||
Possible filter options are:
|
getTextureFiltering()
Return: {min:int, mag:int, mip:int}
| Gets the texture filtering for this unit. |
removeAllEffects()
| Removes all effects applied to this texture layer. |
removeEffect( t )
t: int, type of effect
| Removes a single effect applied to this texture layer. | ||||||||||||||||
Possible effect types are:
|
setEnvironmentMap( enable, envMapType )
enable: bool
envMapType : int
| Turns on/off texture coordinate effect that makes this layer an environment map. | ||||||||||
| Environment maps make an object look reflective by using the object's vertex normals relative to the camera view to generate texture coordinates. | ||||||||||
| The vectors generated can either be used to address a single 2D texture which is a 'fish-eye' lens view of a scene, or a 3D cubic environment map which requires 6 textures for each side of the inside of a cube. The type depends on what texture you set up - if you use the setTextureName method then a 2D fisheye lens texture is required, whereas if you used setCubicTextureName then a cubic environemnt map will be used. | ||||||||||
| This effect works best if the object has lots of gradually changing normals. The texture also has to be designed for this effect - see the example spheremap.png included with the sample application for a 2D environment map; a cubic map can be generated by rendering 6 views of a scene to each of the cube faces with orthoganal views. | ||||||||||
Possible map types are:
|
setScrollAnimation( uSpeed, vSpeed )
uSpeed: float. The number of horizontal loops per second (+ve=moving right, -ve = moving left)
vSpeed: float. The number of vertical loops per second (+ve=moving up, -ve= moving down)
| Sets up an animated scroll for the texture layer. |
setRotateAnimation( speed )
speed: float. The number of complete anticlockwise revolutions per second (use -ve for clockwise)
| Sets up an animated texture rotation for this layer. Note: Useful for constant rotations (for varying rotations, see setTransformAnimation). |
setTransformAnimation( type, waveType, base, frequency, phase, amplitude )
type: int. The type of transform, either translate (scroll), scale (stretch) or rotate (spin)
waveType: int. see table below.
base: float. The base value for the function (range of output = {base, base + amplitude})
frequency: float. The speed of the wave in cycles per second
phase: float. The offset of the start of the wave, e.g. 0.5 to start half-way through the wave
amplitude: float. Scales the output so that instead of lying within [0, 1] it lies within [0, 1*amplitude] for exaggerated effects
| Sets up a general time-relative texture modification effect. | ||||||||||||||
Possible wave types are:
|
setColorOperation( op, source1, source2, color1, color2, manualBlend )
op: int. The operation to be used
source1: int. The source of the first color to the operation
source2: int. The source of the second color to the operation
color1: RGBA. Manually supplied color value (only required if source1 = LBS_MANUAL)
color2: RGBA. Manually supplied color value (only required if source1 = LBS_MANUAL)
manualBlend: float. Manually supplied 'blend' value - only required for operations which require manual blend e.g. LBX_BLEND_MANUAL
| Setting advanced blending options. | ||||||||||||||||||||||||||||||||
Possible opertions are:
| ||||||||||||||||||||||||||||||||
Possible blend sources are:
|
setAlphaOperation( op, source1, source2, color1, color2, manualBlend )
op: int. The operation to be used
source1: int. The source of the first alpha to the operation
source2: int. The source of the second alpha to the operation
color1: RGBA. Manually supplied alpha value (only required if source1 = LBS_MANUAL)
color2: RGBA. Manually supplied alpha value (only required if source1 = LBS_MANUAL)
manualBlend: float. Manually supplied 'blend' value - only required for operations which require manual blend e.g. LBX_BLEND_MANUAL
| Sets the alpha operation to be applied to this texture. (see setColorOperation for details.) |
