Click or drag to resize
SoIndexedTexture2 Class

Class for 2D indexed texture.

Inheritance Hierarchy

Namespace: OIV.Inventor.Nodes
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2024.2.1.0 (10.16.1.0)
Syntax
public class SoIndexedTexture2 : SoTexture

The SoIndexedTexture2 type exposes the following members.

Constructors
  NameDescription
Public methodSoIndexedTexture2

Constructor.

Top
Methods
  NameDescription
Public methodAffectsState

Returns true if a node has an effect on the state during traversal.

(Inherited from SoNode.)
Public methodCallback
(Inherited from SoTexture.)
Public methodComputeDataRange

Compute the min and max value of the indexed image and put the result in OIV.Inventor.Nodes.SoIndexedTexture2.minValue and OIV.Inventor.Nodes.SoIndexedTexture2.maxValue.

Public methodCopy
Calls Copy(false).
(Inherited from SoNode.)
Public methodCopy(Boolean)

Creates and returns an exact copy of the node.

(Inherited from SoNode.)
Public methodCopyFieldValues(SoFieldContainer)
Calls CopyFieldValues(fc, false).
(Inherited from SoFieldContainer.)
Public methodCopyFieldValues(SoFieldContainer, Boolean)

Copies the contents of fc's fields into this object's fields.

(Inherited from SoFieldContainer.)
Public methodDispose
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.)
Public methodDistribute
(Inherited from SoNode.)
Public methodDoAction
Public methodEnableNotify

Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false).

(Inherited from SoFieldContainer.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFieldsAreEqual

Returns true if this object's fields are exactly equal to fc's fields.

(Inherited from SoFieldContainer.)
Public methodGet

Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string.

(Inherited from SoFieldContainer.)
Public methodGetAllFields

Returns a list of fields, including the eventIn's and eventOut's.

(Inherited from SoFieldContainer.)
Public methodGetAlternateRep

This method returns the alternate represention (currently only for PDF and U3D exports).

(Overrides SoNodeGetAlternateRep(SoAction).)
Public methodGetBitmapFileType

Gets the texture file format.

(Inherited from SoTexture.)
Public methodGetBoundingBox
(Inherited from SoNode.)
Public methodGetEventIn

Returns a the eventIn with the given name.

(Inherited from SoFieldContainer.)
Public methodGetEventOut

Returns the eventOut with the given name.

(Inherited from SoFieldContainer.)
Public methodGetField

Returns a the field of this object whose name is fieldName.

(Inherited from SoFieldContainer.)
Public methodGetFieldName

Returns the name of the given field in the fieldName argument.

(Inherited from SoFieldContainer.)
Public methodGetFields

Appends references to all of this object's fields to resultList, and returns the number of fields appended.

(Inherited from SoFieldContainer.)
Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetMatrix
(Inherited from SoNode.)
Public methodGetName

Returns the name of an instance.

(Inherited from SoBase.)
Public methodGetPrimitiveCount
(Inherited from SoNode.)
Public methodGetRenderEngineMode

Returns the supported Render engine mode.

(Inherited from SoNode.)
Public methodGetRenderUnitID
(Inherited from SoNode.)
Public methodGetStringName (Inherited from SoBase.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGLRender
Public methodGLRenderBelowPath
(Inherited from SoNode.)
Public methodGLRenderInPath
(Inherited from SoNode.)
Public methodGLRenderOffPath
(Inherited from SoNode.)
Public methodGrabEventsCleanup
(Inherited from SoNode.)
Public methodGrabEventsSetup
(Inherited from SoNode.)
Public methodHandleEvent
(Inherited from SoNode.)
Public methodHasDefaultValues

Returns true if all of the object's fields have their default values.

(Inherited from SoFieldContainer.)
Public methodIsBoundingBoxIgnoring

This method is used by getBoundingBox action traversal to know if the current node must be traversed or not, ie the bounding should be ignored.

(Inherited from SoNode.)
Public methodIsNotifyEnabled

Notification is the process of telling interested objects that this object has changed.

(Inherited from SoFieldContainer.)
Public methodIsOverride

Returns the state of the override field.

(Inherited from SoTexture.)
Public methodIsSynchronizable

Gets the ScaleViz synchronizable state of this object.

(Inherited from SoBase.)
Public methodPick
(Inherited from SoNode.)
Public methodRayPick
(Inherited from SoNode.)
Public methodSearch
(Inherited from SoNode.)
Public methodSet

Sets one or more fields in this object to the values specified in the given string, which should be a string in the Open Inventor file format.

(Inherited from SoFieldContainer.)
Public methodSetBitmapFileType

Sets the texture file format.

(Inherited from SoTexture.)
Public methodSetName (Inherited from SoBase.)
Public methodSetOverride

Set the state of the override field.

(Inherited from SoTexture.)
Public methodSetSynchronizable

Sets this to be a ScaleViz synchronizable object.

(Inherited from SoBase.)
Public methodSetToDefaults

Sets all fields in this object to their default values.

(Inherited from SoFieldContainer.)
Public methodToString
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.)
Public methodTouch

Marks an instance as modified, simulating a change to it.

(Inherited from SoNode.)
Public methodWrite
(Inherited from SoNode.)
Top
Properties
  NameDescription
Public propertyblendColor

Color used for BLEND model.

(Inherited from SoTexture.)
Public propertyborderColor

Defines border color used for border texture filtering.

(Inherited from SoTexture.)
Public propertyenableBorder

Enables borders for textures.

(Inherited from SoTexture.)
Public propertyenableCompressedTexture

Enables storage of textures on the graphics board in compressed form.

(Inherited from SoTexture.)
Public propertyimageIndex

This field contains the in-memory representation of the indexed texture image.

Public propertyinternalFormat

Internal format for texture storage.

(Inherited from SoTexture.)
Public propertyIsDisposable
ISafeDisposable interface implementation.
(Inherited from SoDisposable.)
Public propertymagFilter

Specifies the OpenGL magFilter.

(Inherited from SoTexture.)
Public propertymaxAnisotropy

Specifies on a per-texture object basis, the maximum degree of anisotropy to account for in texture filtering.

(Inherited from SoTexture.)
Public propertymaxValue
Public propertyminFilter

Specifies the OpenGL minFilter.

(Inherited from SoTexture.)
Public propertyminValue

Specifies the range of values which is mapped onto the color map (see OIV.Inventor.Nodes.SoColorMap).

Public propertymodel

Specifies how to map texture onto surface.

(Inherited from SoTexture.)
Public propertyrescaleTexCoord

This field controls the way an image with non-power-of-two dimension is handled:

Public propertyUserData
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.)
Public propertywrapS

Indicates what to do when texture coordinates in the S (horizontal) direction lie outside the range 0-1.

(Inherited from SoTexture.)
Public propertywrapT

Indicates what to do when texture coordinates in the T (vertical) direction lie outside the range 0-1.

Top
Remarks

This property node defines an "indexed" texture image. In a standard texture image, e.g. OIV.Inventor.Nodes.SoTexture2, each texel contains a color value that is directly applied to the geometry. In this node each texel contains a data value that is mapped to a color value using the color map defined by the current OIV.Inventor.Nodes.SoColorMap node.

This image is stored in the current texture unit (see OIV.Inventor.Nodes.SoTextureUnit) and the texture is applied to subsequent shapes as they are rendered.

The image data is stored in an OIV.Inventor.Fields.SoSFArray2D. This array can contain different types of data (UNSIGNED_BYTE, UNSIGNED_SHORT, UNSIGNED_INT32, SIGNED_BYTE, SIGNED_SHORT, SIGNED_INT32, FLOAT).

When Open Inventor creates the OpenGL texture image from the data array, the data values must be scaled into the range of values of the texture (0-255 for an 8-bit indexed texture). The OIV.Inventor.Nodes.SoIndexedTexture2.minValue and OIV.Inventor.Nodes.SoIndexedTexture2.maxValue fields specify the range of data values that will be scaled into the range of texture values. For example, if OIV.Inventor.Nodes.SoIndexedTexture2.minValue is set to 10000 and OIV.Inventor.Nodes.SoIndexedTexture2.maxValue to 38000, all values less than or equal to 10000 will be mapped to the entry 0 of the color map and all values greater than or equal to 38000 to the last entry. The image below illustrates the process of mapping and shows how it can be used to map only the used data range to the color map:

If OIV.Inventor.Nodes.SoIndexedTexture2.minValue or OIV.Inventor.Nodes.SoIndexedTexture2.maxValue change, then the OpenGL texture must be recreated. If the texture is large, this may be time consuming. Generally it's more efficient to modify the OIV.Inventor.Nodes.SoColorMap node because the OpenGL texture corresponding to the data does not need to be recreated only the texture containing the colormap, which is normally quite small.

NOTE: Texture data values are stored with 12 bits of precision instead of the usual 8 bits, when:

  • ARB_fragment_program is supported by the graphics card.

  • The number of color map entries is greater than 256.

  • The texture data type has more than 8 bits of precision (i.e., not UNSIGNED_BYTE or SIGNED_BYTE).

EXAMPLE

The following example shows how to apply an indexed texture on a geometry node:

SoColorMap colorMap = new SoColorMap();
 colorMap.predefinedColorMap.SetValue( (int)SoColorMap.PredefinedColorMaps.TEMPERATURE );
 colorMap.min.Value = -1000;
 colorMap.max.Value = 20000;

SoIndexedTexture2 indexedTexture = new SoIndexedTexture2();
 indexedTexture.imageIndex.SetValue(size, (int)SoSFArray.DataTypes.SIGNED_SHORT, data);

root.AddChild( colorMap );
root.AddChild( indexedTexture );
root.AddChild( geometry );

EXAMPLE

On graphics cards supporting ARB_fragment_program , the model field will be ignored and multitexturing will not work. It is possible to circumvent this limitation by using a custom shader. The following GLSL code shows how to do multitexturing between two indexed textures sharing the same color map:

uniform sampler2D colormap;
uniform sampler2D indexedTex1; 
uniform sampler2D indexedTex2;  

void main()
{
 // Fetch first value and its assigned color
 float value1 = texture(indexedTex1, gl_TexCoord[0].xy).x;
 vec4  color1 = texture(colormap, vec2(value1, 0));

 // Fetch second and its assigned color
 float value2 = texture(indexedTex2, gl_TexCoord[0].xy).x;
 vec4  color2 = texture(colormap, vec2(value2, 0));

 // Combine the colors
 gl_FragColor = color1 * color2 * gl_Color;
}

The scene graph would be initialized like this:

SoColorMap colorMap = new SoColorMap();
. . .
SoIndexedTexture2 indexedTex1 = new SoIndexedTexture2();
. . .
SoIndexedTexture2 indexedTex2 = new SoIndexedTexture2();
. . .

SoFragmentShader fragShader = new SoFragmentShader();
 fragShader.sourceProgram.Value = "filename.glsl";

SoShaderParameter1i parameter = new SoShaderParameter1i();
 parameter.name.Value = "colorMap";
 parameter.value.Value = 0;
 fragShader.parameter[0] = parameter;

parameter = new SoShaderParameter1i();
 parameter.name.Value = "indexedTex1";
 parameter.value.Value = 1;
 fragShader.parameter[1] = parameter;

parameter = new SoShaderParameter1i();
 parameter.name.Value = "indexedTex2";
 parameter.value.Value = 2;
 fragShader.parameter[2] = parameter;

SoShaderProgram shaderProgram = new SoShaderProgram();
 shaderProgram.shaderObject.SetValue(fragShader);

SoTextureUnit textureUnit = new SoTextureUnit();
 textureUnit.unit.Value = 2;  //Texture unit for the second indexed texture

root.AddChild(colorMap);      //Color map must come first (texture unit 1)
root.AddChild(indexedTex1);   //First indexed texture (texture unit 0)
root.AddChild(textureUnit);
root.AddChild(indexedTex2);   //Second indexed texture (texture unit 2)
root.AddChild(shaderProgram);
root.AddChild(geometry);

FILE FORMAT/DEFAULT

IndexedTexture2 {
minValue 0
maxValue 0
imageIndex 0 0
rescaleTexCoord false
wrapS REPEAT
wrapT REPEAT
model MODULATE
blendColor 0 0 0
enableBorder false
borderColor 0 0 0 0
maxAnisotropy 1.0
minFilter AUTO
magFilter AUTO
useAutoMipmap false
internalFormat AUTO_INTERNAL_FORMAT
}

ACTION BEHAVIOR

OIV.Inventor.Actions.SoGLRenderAction, OIV.Inventor.Actions.SoCallbackAction Sets: OIV.Inventor.Elements.SoTextureImageElement

See Also