SoIndexedTexture2 Class |
Class for 2D indexed texture.
Namespace: OIV.Inventor.Nodes
The SoIndexedTexture2 type exposes the following members.
Name | Description | |
---|---|---|
SoIndexedTexture2 | Constructor. |
Name | Description | |
---|---|---|
AffectsState | Returns true if a node has an effect on the state during traversal. | |
Callback | (Inherited from SoTexture.) | |
ComputeDataRange | 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. | |
Copy | Calls Copy(false). (Inherited from SoNode.) | |
Copy(Boolean) | Creates and returns an exact copy of the node. | |
CopyFieldValues(SoFieldContainer) | Calls CopyFieldValues(fc, false). (Inherited from SoFieldContainer.) | |
CopyFieldValues(SoFieldContainer, Boolean) | Copies the contents of fc's fields into this object's fields. | |
Dispose |
Releases all resources used by SoDisposable.
(Inherited from SoDisposable.) | |
Distribute | (Inherited from SoNode.) | |
DoAction | (Overrides SoTextureDoAction(SoAction).) | |
EnableNotify | Notification at this Field Container is enabled (if flag == true) or disabled (if flag == false). | |
Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
FieldsAreEqual | Returns true if this object's fields are exactly equal to fc's fields. | |
Get | Returns the values of the fields of this object in the Open Inventor ASCII file format in the given string. | |
GetAllFields | Returns a list of fields, including the eventIn's and eventOut's. | |
GetAlternateRep | This method returns the alternate represention (currently only for PDF and U3D exports). | |
GetBitmapFileType | Gets the texture file format. | |
GetBoundingBox | (Inherited from SoNode.) | |
GetEventIn | Returns a the eventIn with the given name. | |
GetEventOut | Returns the eventOut with the given name. | |
GetField | Returns a the field of this object whose name is fieldName. | |
GetFieldName | Returns the name of the given field in the fieldName argument. | |
GetFields | Appends references to all of this object's fields to resultList, and returns the number of fields appended. | |
GetHashCode |
Overrides GetHashCode().
(Inherited from SoNetBase.) | |
GetMatrix | (Inherited from SoNode.) | |
GetName | Returns the name of an instance. | |
GetPrimitiveCount | (Inherited from SoNode.) | |
GetRenderEngineMode | Returns the supported Render engine mode. | |
GetRenderUnitID | (Inherited from SoNode.) | |
GetStringName | (Inherited from SoBase.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
GLRender | (Overrides SoTextureGLRender(SoGLRenderAction).) | |
GLRenderBelowPath | (Inherited from SoNode.) | |
GLRenderInPath | (Inherited from SoNode.) | |
GLRenderOffPath | (Inherited from SoNode.) | |
GrabEventsCleanup | (Inherited from SoNode.) | |
GrabEventsSetup | (Inherited from SoNode.) | |
HandleEvent | (Inherited from SoNode.) | |
HasDefaultValues | Returns true if all of the object's fields have their default values. | |
IsBoundingBoxIgnoring | 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. | |
IsNotifyEnabled | Notification is the process of telling interested objects that this object has changed. | |
IsOverride | Returns the state of the override field. | |
IsSynchronizable | Gets the ScaleViz synchronizable state of this object. | |
Pick | (Inherited from SoNode.) | |
RayPick | (Inherited from SoNode.) | |
Search | (Inherited from SoNode.) | |
Set | 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. | |
SetBitmapFileType | Sets the texture file format. | |
SetName | (Inherited from SoBase.) | |
SetOverride | Set the state of the override field. | |
SetSynchronizable | Sets this to be a ScaleViz synchronizable object. | |
SetToDefaults | Sets all fields in this object to their default values. | |
ToString |
Converts this SoBase structure to a human readable string.
(Inherited from SoBase.) | |
Touch | Marks an instance as modified, simulating a change to it. | |
Write | (Inherited from SoNode.) |
Name | Description | |
---|---|---|
blendColor | Color used for BLEND model. | |
borderColor | Defines border color used for border texture filtering. | |
enableBorder | Enables borders for textures. | |
enableCompressedTexture | Enables storage of textures on the graphics board in compressed form. | |
imageIndex | This field contains the in-memory representation of the indexed texture image. | |
internalFormat | Internal format for texture storage. | |
IsDisposable | ISafeDisposable interface implementation.
(Inherited from SoDisposable.) | |
magFilter | Specifies the OpenGL magFilter. | |
maxAnisotropy | Specifies on a per-texture object basis, the maximum degree of anisotropy to account for in texture filtering. | |
maxValue | ||
minFilter | Specifies the OpenGL minFilter. | |
minValue | Specifies the range of values which is mapped onto the color map (see OIV.Inventor.Nodes.SoColorMap). | |
model | Specifies how to map texture onto surface. | |
rescaleTexCoord | This field controls the way an image with non-power-of-two dimension is handled: | |
UserData |
Gets or sets the user data to be contained by the field container.
(Inherited from SoFieldContainer.) | |
wrapS | Indicates what to do when texture coordinates in the S (horizontal) direction lie outside the range 0-1. | |
wrapT | Indicates what to do when texture coordinates in the T (vertical) direction lie outside the range 0-1. |
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).
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 );
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; }
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);
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 |
OIV.Inventor.Actions.SoGLRenderAction, OIV.Inventor.Actions.SoCallbackAction Sets: OIV.Inventor.Elements.SoTextureImageElement