# HBhvInterpolatorColorMorph

## Functions

| `HBhvInterpolatorColorMorph`
| `~HBhvInterpolatorColorMorph`
const char * | `GetType`
HBhvInterpolator * | `CreateInstance`
void | `Insert`
void | `InsertDiscrete`
void | `Replace`
void | `Serialize`
void | `Interpolate`
VArray< void * > | `GetMorphData`
int | `GetMorphDataLength`
void | `AddMorphData`
void | `SetUseFIndex`
void * | `XMLCallback`

## Detailed Description

class HBhvInterpolatorColorMorph : public HBhvInterpolator

  The HBhvInterpolatorColorMorph class performs an interpolation on the face colors of your target object.

  Public Functions

  HBhvInterpolatorColorMorph(HBhvAnimation *animation = 0, const char *name = 0)

    Constructs an HBhvInterpolatorColorMorph object.

    Parameters

      - animation – The animation that this interpolator belongs to.

      - name – The name of the interpolator.

  ~HBhvInterpolatorColorMorph()
  virtual const char *GetType()
    Returns

      The type of the interpolator which is ‘ColorMorph’.

  virtual HBhvInterpolator *CreateInstance(HBhvAnimation *ainst)

    In special cases, you may want an interpolator that references this interpolator without changing it. Use this method to create the new interpolator passing a pointer to the animation that you want it to be associated with.

    Parameters

      ainst – The animation instance that this interpolator is associated with.

    Returns

      The newly created interpolator that references this interpolator.

  inline void Insert(char *mident, int l = 0)

    This method creates a new keyframe with the passed Morph Data position index and then inserts it after the passed position l into the keyframe array. To use this method, you must first add your face color information to the Morph Data using AddMorphData(). Once you have done that, note the position index that your vertex information was added to the Morph Data array. This will be the value of the parameter mident.

    Parameters

      - mident – The Morph Data position index to your vertex array to use for the new keyframe. Note that although the index is an int, you can use itoa() to convert the index position.

      - l – The array position to insert item after.

  inline void InsertDiscrete(char *mident, int l = 0)
  inline void Replace(char *t, int l)

    Replaces the item at the given position in the keyframe array with a new keyframe that was created with the passed morph identifier. To use this method, you must first add your face color information to the Morph Data using AddMorphData(). Once you have done that, note the position index that your vertex information was added to the Morph Data array. This will be the value of the parameter t.

    Parameters

      - t – The Morph Data position index to your vertex array to use for the replace keyframe. Note that although the index is an int, you can use itoa() to convert the index position.

      - l – The array position to replace.

  virtual void Serialize(HUtilityXMLGenerator *xmlgen)

    Writes XML data to a buffer using the passed XML generator.

  virtual void Interpolate(int keyframe, float fraction)

    Performs an interpolation on the animation target.

    Parameters

      - keyframe – The reference keyframe for this interpolation.

      - fraction – The fraction value from the specified keyframe to the next keyframe. The value is from 0 to 1.

  inline VArray<void*> GetMorphData()
    Returns

      A pointer to the morph data array.

  inline int GetMorphDataLength()
    Returns

      The number of entries in the morph data array.

  virtual void AddMorphData(HPoint *md, int pnum, HBaseModel *model, int pos = -1)

    This method adds an array of colors for the vertices in the target object to morph data array. Use this method to morph your data so that it can be added to the keyframe array for this interpolator. Note Insert() and Replace() take the morph data in the form of its indexed position in the morph data array.

    Parameters

      - md – The array of colors. For an HPoint, pass the r, g and b values in the x, y and z parameters if you have set the UseFIndex flag to false. If UseFIndex is true, then pass an index to the color lookup table for the x parameter of each HPoint in the array.

      - pnum – Number of items in array.

      - model – A pointer to the base model. The point array is stored as a shell in a special MorphData segment underneath the model segment.

      - pos – Optional index into the Morph Data array which indicates where to put the point array.

  virtual void SetUseFIndex(bool tf)

    Use this method to indicate that HOOPS should use a lookup table for colors in this interpolation. When creating morph data in AddMorphData, instead of passing RGB values in the x,y,z parameters of HPoint, pass the color lookup index in x parameter.

    Parameters

      tf – Pass true to use a lookup table or false to use RGB values.

  Public Static Functions

  static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData)

    This is XML read callback which parses XML data and then populates the member variables with the associated values.