TextureLayer.Move

Introduced

v4.0

Description

Moves texture layers up or down in the ordered stacks of layers. This considers the overall order of layers in other containers (Shader or Material) that share the given texture layers, so that the ordering is always consistent. If you move a layer up or down, its ordering will potentially also change in other containers, if it is shared. This is to prevent cycles from occurring, for example if shader Phong had layers A,B but shader Lambert shared those layers in the order B,A.

C# Syntax

TextureLayer.Move( Int32 in_lOffset );

Scripting Syntax

TextureLayer.Move( [Offset] );

Parameters

Parameter Type Description
Offset Long Amount to move the layer. A negative value moves it up in the list, positive moves it down. The absolute value is the number of steps to move in that direction.

Any value is valid, if more offset steps are requested than are actually available, the layer will simply move to the end (for positive offsets) or beginning (for negative offsets) of all the containers where it exists. So specifying a very large value of offset is a good way to set a layer to be the final layer in all containers where it appears.

Default Value: -1

Examples

1. JScript Example

// This example shows moving texture layers up
// and down within their containers.
oRoot = ActiveProject.ActiveScene.Root;
oSph = oRoot.AddGeometry( "Sphere", "MeshSurface" );
oMat = oSph.AddMaterial( "Phong" );
oPhong = oMat.Shaders(0);
// Add three layers.
oLayers = new Array(3);
oLayers[0] = oPhong.CreateTextureLayer( "A" );
oLayers[1] = oPhong.CreateTextureLayer( "B" );
oLayers[2] = oPhong.CreateTextureLayer( "C" );
Application.LogMessage( "Created " + oPhong.TextureLayers.count + " layers." );
DumpLayerOrder( oPhong );
oLayers[2].Move( -2 );
Application.LogMessage( "Moved layer C up two." );
DumpLayerOrder( oPhong );
oLayers[0].Move( 1 );
Application.LogMessage( "Moved layer A down one." );
DumpLayerOrder( oPhong );
function DumpLayerOrder( in_container )
{
	for ( i = 0; i < in_container.TextureLayers.count; i++ )
	{
		oLayer = in_container.TextureLayers(i);
		Application.LogMessage( (i+1) + ": " + oLayer.fullname );
	}
}
// This example should log something like:
//INFO : "Created 3 layers."
//INFO : "1: sphere.Material.Phong.A"
//INFO : "2: sphere.Material.Phong.B"
//INFO : "3: sphere.Material.Phong.C"
//INFO : "Moved layer C up two."
//INFO : "1: sphere.Material.Phong.C"
//INFO : "2: sphere.Material.Phong.A"
//INFO : "3: sphere.Material.Phong.B"
//INFO : "Moved layer A down one."
//INFO : "1: sphere.Material.Phong.C"
//INFO : "2: sphere.Material.Phong.B"
//INFO : "3: sphere.Material.Phong.A"

2. VBScript Example

' This example shows moving texture layers up
' and down within their containers.
set oRoot = ActiveProject.ActiveScene.Root
set oSph = oRoot.AddGeometry( "Sphere", "MeshSurface" )
set oMat = oSph.AddMaterial( "Phong" )
set oPhong = oMat.Shaders(0)
' Add three layers.
dim oLayers(2)
set oLayers(0) = oPhong.CreateTextureLayer( "A" )
set oLayers(1) = oPhong.CreateTextureLayer( "B" )
set oLayers(2) = oPhong.CreateTextureLayer( "C" )
logmessage "Created " & oPhong.TextureLayers.count & " layers."
DumpLayerOrder oPhong
oLayers(2).Move -2
logmessage "Moved layer C up two."
DumpLayerOrder oPhong
oLayers(0).Move 1
logmessage "Moved layer A down one."
DumpLayerOrder oPhong
sub DumpLayerOrder( in_container )
	dim i, oLayer
	i = 1
	for each oLayer in in_container.TextureLayers
		logmessage i & ": " & oLayer.fullname
		i = i + 1
	next
end sub
' This example should log something like:
'INFO : "Created 3 layers."
'INFO : "1: sphere.Material.Phong.A"
'INFO : "2: sphere.Material.Phong.B"
'INFO : "3: sphere.Material.Phong.C"
'INFO : "Moved layer C up two."
'INFO : "1: sphere.Material.Phong.C"
'INFO : "2: sphere.Material.Phong.A"
'INFO : "3: sphere.Material.Phong.B"
'INFO : "Moved layer A down one."
'INFO : "1: sphere.Material.Phong.C"
'INFO : "2: sphere.Material.Phong.B"
'INFO : "3: sphere.Material.Phong.A"

See Also

MoveTextureLayers Material.TextureLayers Shader.TextureLayers