Class SoMFColor


  • public class SoMFColor
    extends SoMField
    Multiple-value field containing any number of RGB colors stored as three floats. A multiple-value field that contains any number of RGB colors, stored as instances of SbColor. Values may be set in either RGB (red, green, blue) or HSV (hue, saturation, value) color spaces.

    SoMFColors are written to file as one or more RGB triples of floating point numbers in standard scientific notation. When more than one value is present, all of the values are enclosed in square brackets and separated by commas. For example:

       [ 1.0 0.0 0.0, 0 1 0, 0 0 1 ]
    represents the three colors red, green, and blue.

    Data copying:

    SoMF fields are a kind of "smart container", automatically expanding as necessary to hold the data provided by the application. This is very convenient, but for large blocks of data it may be desireable to avoid making a copy of the application data. The setValuesBuffer() methods allow Open Inventor to directly use an array of values supplied by the application. The application data is not copied. Please see SoMFVec3f for more information and example code.

    See Also:
    SbColor
    • Method Detail

      • setValues

        public void setValues​(int start,
                              float[][] rgb)
        Sets values starting at index start to the colors in rgb.
        Parameters:
        rgb - array of array of 3 floats
        See Also:
        setValues(int, SbColor[])
      • setValues

        @Deprecated(since="9.3.1")
        public void setValues​(int start,
                              int num,
                              float[] rgb)
        Deprecated.
        As of Open Inventor 9.3.1, use setValues(int, float[]) instead.
        Sets num RGB values from an array of arrays of 3 floats. Each float should be in the range 0.0 to 1.0, and there must be 3* num floats in the array.
      • find

        public int find​(SbColor targetValue)
        Calls find(targetValue, false).
      • finishEditing

        public void finishEditing()
        Indicates that batch edits have finished. See startEditing().
      • setValuesBuffer

        public void setValuesBuffer​(java.nio.ByteBuffer userData)
        Sets the field to contain the values stored in userData. This data will not be copied into the field: it will be directly used by the field.
      • getValueAt

        public SbColor getValueAt​(int i)
      • startEditing

        public java.nio.FloatBuffer startEditing()
        Returns a pointer to the internally maintained array that can be modified. The values in the array may be changed, but values cannot be added or removed. It is illegal to call any other editing methods between startEditing() and finishEditing() (e.g. set1Value(), setValue(), etc.). Fields, engines or sensors connected to this field and sensors are not notified that this field has changed until finishEditing() is called. Calling finishEditing() always sets the isDefault() flag to false and informs engines and sensors that the field changed, even if none of the values actually were changed.
      • getDirectValues

        public java.nio.FloatBuffer getDirectValues​(int start)
        Returns a pointer into the array of values in the field, starting at index start. The values are read-only. See the startEditing()/finishEditing() methods for a way of modifying values in place.
      • getValues

        public SbColor[] getValues​(int start)
        Returns a pointer into the array of values in the field, starting at index start. The values are read-only. See the startEditing()/finishEditing() methods for a way of modifying values in place.
      • setHSVValue

        public void setHSVValue​(float h,
                                float s,
                                float v)
        Sets the field to contain one and only one value, the given color (expressed as HSV floating point values in the range 0.0 to 1.0), and deletes the second and subsequent values.
      • setValue

        public void setValue​(float[] rgb)
        Sets the field to contain one and only one value, the given color (expressed as an array of RGB floating point values in the range 0.0 to 1.0), and deletes the second and subsequent values.
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class SoField
      • setHSVValue

        public void setHSVValue​(float[] hsv)
        Sets the field to contain one and only one value, the given color (expressed as an array of HSV floating point values in the range 0.0 to 1.0), and deletes the second and subsequent values.
      • setValue

        public void setValue​(SbVec3f vec)
        Sets the field to contain one and only one value, the given color (expressed as RGB floating point values in the range 0.0 to 1.0), and deletes the second and subsequent values.
      • setValues

        public void setValues​(int start,
                              float[] rgb)
        Sets RGB values from the specified array of floats. Each float should be in the range 0.0 to 1.0, and size of the array must be a multiple of 3.
      • disableDeleteValues

        public void disableDeleteValues()
        Temporary disable value deleting.
      • setValue

        public void setValue​(float r,
                             float g,
                             float b)
        Sets the field to contain one and only one value, the given color (expressed as RGB floating point values in the range 0.0 to 1.0), and deletes the second and subsequent values.
      • set1Value

        public void set1Value​(int index,
                              SbVec3f vec)
        Sets one of N RGB colors from SbVec3f. The array will be expanded and filled with zeros as necessary.
      • setValues

        public void setValues​(int start,
                              SbColor[] newValues)
        Sets num values starting at index start to the values. in newValues. The array will automatically be made larger to accommodate the new values, if necessary. In that case, if field's values are stored in an user data array, this array is no more used.
      • set1HSVValue

        public void set1HSVValue​(int index,
                                 float h,
                                 float s,
                                 float v)
        Sets one of N HSV colors from 3 floats. The array will be expanded and filled with zeros as necessary.
      • find

        public int find​(SbColor targetValue,
                        boolean addIfNotFound)
        Finds the given targetValue in the array and returns the index of that value. in the array. If the value is not found, -1 is returned. If addIfNotFound is set, then targetValue is added to the end of the array (but -1 is still returned).
      • set1HSVValue

        public void set1HSVValue​(int index,
                                 float[] hsv)
        Sets one of N HSV colors from an array of 3 floats. The array will be expanded and filled with zeros as necessary.
      • setValue

        public void setValue​(SbColor newValue)
        Sets the first value in the array to newValue, and deletes. the second and subsequent values. If field's values are stored in an user data array, this array is no more used.
      • set1Value

        public void set1Value​(int index,
                              float r,
                              float g,
                              float b)
        Sets one of N RGB colors from 3 floats. The array will be expanded and filled with zeros as necessary.
      • set1Value

        public void set1Value​(int index,
                              SbColor newValue)
        Sets the index'th value in the array to newValue. The array will be automatically expanded, if necessary. In that case, if field's values are stored in an user data array, this array is no more used.
      • set1Value

        public void set1Value​(int index,
                              float[] rgb)
        Sets one of N RGB colors from an array of 3 floats. The array will be expanded and filled with zeros as necessary.