Class SoSFImage3
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.inventor.fields.SoField
-
- com.openinventor.inventor.fields.SoSField
-
- com.openinventor.inventor.fields.SoSFImage3
-
public class SoSFImage3 extends SoSField
Field containing a 3D image. A field containing a three-dimensional image. A three-dimensional image can be thought of as a sequence of two-dimensional image "slices."Images can be grayscale (intensity), grayscale with transparency information, RGB, or RGB with transparency. Each component of the image (intensity, red, green, blue or transparency (alpha)) can have an unsigned one-byte value from 0 to 255.
Values are returned as arrays of unsigned chars. The image is stored in this array starting at the bottom left front corner of the image with the intensity or red component of that pixel, followed by either the alpha, the green and blue, or the green, blue and alpha components (depending on the number of components in the image). The next value is the first component of the next pixel to the right.
SoSFImage3s are written to file as four integers representing the width, height, depth and number of components in the image, followed by width*height*depth hexadecimal values representing the pixels in the image, separated by whitespace. A one-component image will have one-byte hexadecimal values representing the intensity of the image. For example, 0xFF is full intensity, 0x00 is no intensity. A two-component image puts the intensity in the first (high) byte and the transparency in the second (low) byte. Pixels in a three-component image have the red component in the first (high) byte, followed by the green and blue components (so 0xFF0000 is red). Four-component images put the transparency byte after red/green/blue (so 0x0000FF80 is semi-transparent blue). Note: each pixel is actually read as a single unsigned number, so a 3-component pixel with value "0x0000FF" can also be written as "0xFF" or "255" (decimal).
For example,
is a 1 pixel wide by 2 pixel high by 3 pixel deep grayscale image, with the bottom pixel white and the top pixel black in the first (front-most) slice. In the second slice the bottom pixel is black and the top pixel is white. And:1 2 3 1 0xFF 0x00 0x00 0xFF 0xFF 0x00
is a 2 pixel wide by 4 pixel high by 3 pixel deep RGB image, with the bottom left pixel red, the bottom right pixel green, the two middle rows of pixels black, the top left pixel white, and the top right pixel yellow in the first slice. Subsequent slices are not shown.2 4 3 3 0xFF0000 0xFF00 0 0 0 0 0xFFFFFF 0xFFFF00 ...
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SoSFImage3.BufferObject
static class
SoSFImage3.CopyPolicies
SoSFImage3
may be manipulating some large amounts of memory.static class
SoSFImage3.SubTextureImage
static class
SoSFImage3.TextureImage
-
Nested classes/interfaces inherited from class com.openinventor.inventor.fields.SoField
SoField.FieldTypes
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Constructor Summary
Constructors Constructor Description SoSFImage3(SoFieldContainer fieldContainer, java.lang.String fieldName, SoField.FieldTypes fieldType)
Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
SoSFImage3.BufferObject
getBufferObject()
Returns the pixels in the image as a buffer object.int
getNumComponents()
Returns the number of components in each pixels of the image.int
getNumSubTextures()
Returns true if subTextures have been defined or false if none have been defined.SoSFImage3.SubTextureImage
getSubTexture(int index)
Returns a buffer to a given subTexture set by setSubValue, setSubValues, or a startEditing()/finishEditing() pair.SoSFImage3.TextureImage
getValue()
Returns the pixels in the image as an array of unsigned chars.boolean
isNeverWrite()
As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action.void
setNeverWrite(boolean neverWrite)
As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action.void
setValue(SbVec3i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject)
Calls setValue(size, nc, dataType, bufferObject, SoSFImage3.CopyPolicies.valueOf( SoSFImage3.CopyPolicies.COPY.getValue() )).void
setValue(SbVec3i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject, SoSFImage3.CopyPolicies copy)
Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.void
setValue(SbVec3s size, int nc, SoBufferObject bufferObject)
Calls setValue(size, nc, bufferObject, SoSFImage3.CopyPolicies.valueOf( SoSFImage3.CopyPolicies.COPY.getValue() )).void
setValue(SbVec3s size, int nc, SoBufferObject bufferObject, SoSFImage3.CopyPolicies copy)
Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values.-
Methods inherited from class com.openinventor.inventor.fields.SoField
appendConnection, appendConnection, connectFrom, connectFrom, disconnect, disconnect, disconnect, enableConnection, get, getConnectedEngine, getConnectedField, getContainer, getNumConnections, getValueSize, isConnected, isConnectedFromEngine, isConnectedFromField, isConnectedFromVRMLInterp, isConnectionEnabled, isDefault, isIgnored, set, setIgnored, touch
-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Constructor Detail
-
SoSFImage3
public SoSFImage3(SoFieldContainer fieldContainer, java.lang.String fieldName, SoField.FieldTypes fieldType)
Default constructor.
-
-
Method Detail
-
setValue
public void setValue(SbVec3i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject)
Calls setValue(size, nc, dataType, bufferObject, SoSFImage3.CopyPolicies.valueOf( SoSFImage3.CopyPolicies.COPY.getValue() )).
-
setValue
public void setValue(SbVec3s size, int nc, SoBufferObject bufferObject)
Calls setValue(size, nc, bufferObject, SoSFImage3.CopyPolicies.valueOf( SoSFImage3.CopyPolicies.COPY.getValue() )).
-
getValue
public SoSFImage3.TextureImage getValue()
Returns the pixels in the image as an array of unsigned chars. The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc *sizeof( <dataType>).
This is a convenience method for the unsigned char datatype.
-
getNumSubTextures
public int getNumSubTextures()
Returns true if subTextures have been defined or false if none have been defined. Also returns the number of subTextures defined.
-
getSubTexture
public SoSFImage3.SubTextureImage getSubTexture(int index)
Returns a buffer to a given subTexture set by setSubValue, setSubValues, or a startEditing()/finishEditing() pair. These methods append subTextures to a list. Also returns the size of the subtexture and the offset from the beginning of the image of the requested subImage.
This is a convenience method for the unsigned char datatype.
-
isNeverWrite
public boolean isNeverWrite()
As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action. By default, the "neverWrite" condition is true.
-
setValue
public void setValue(SbVec3s size, int nc, SoBufferObject bufferObject, SoSFImage3.CopyPolicies copy)
Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values. size[0]*size[1]*size[2]*nc*sizeof( <dataType>) bytes from the given array will be copied into internal storage maintained by theSoSFImage3
field.At times,
SoSFImage3
may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See alsosetNeverWrite()
.
-
getNumComponents
public int getNumComponents()
Returns the number of components in each pixels of the image.
-
setNeverWrite
public void setNeverWrite(boolean neverWrite)
As this field may have to handle large amounts of data and its representation in an .iv file is not very efficient, it is often a good idea not to allow that data to be written out when required by a write action. By default, the "neverWrite" condition is true.
-
getBufferObject
public SoSFImage3.BufferObject getBufferObject()
Returns the pixels in the image as a buffer object. The size and nc arguments are filled in with the dimensions of the image and the number of components in the image; the number of bytes in the array returned will be size [0]* size [1]* size [2]* nc .
-
setValue
public void setValue(SbVec3i32 size, int nc, SoSFImage.DataTypes dataType, SoBufferObject bufferObject, SoSFImage3.CopyPolicies copy)
Sets the value of this field to be an image of the given size, with the given number of components, and with the given pixel values. size[0]*size[1]*size[2]*nc*sizeof( <dataType>) bytes from the given array will be copied into internal storage maintained by theSoSFImage3
field.At times,
SoSFImage3
may need to manipulate large amounts of memory. Therefore, it is useful to be able to specify the memory usage policy dynamically. By default, the memory policy is COPY, which is consistent with other Open Inventor fields. The most likely to be efficient is NO_COPY. See alsosetNeverWrite()
.
-
-