HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_AgentBlendShapeUtils.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5 */
6 
7 #ifndef __GU_AgentBlendShapeUtils__
8 #define __GU_AgentBlendShapeUtils__
9 
10 #include "GU_API.h"
11 
12 #include "GU_DetailHandle.h"
13 #include <UT/UT_StringArray.h>
14 #include <UT/UT_StringHolder.h>
15 
16 class GU_AgentRig;
17 class GU_AgentShapeLib;
18 
19 namespace GU_AgentBlendShapeUtils
20 {
21 /// Adds in-between shapes to a blendshape input (the primary shape).
22 /// This sets up the required detail attributes ("blendshape_shapenames" and
23 /// "blendshape_inbetweenweights") on the primary shape's geometry.
24 /// The shapes should be separately added to the shape library.
25 void GU_API addInBetweenShapes(GU_Detail &primary_shape_gdp,
26  const UT_StringArray &inbetween_shape_names,
27  const UT_Array<fpreal> &inbetween_weights);
28 
29 /// Adds blendshape inputs to a shape.
30 /// This sets up the required detail attributes ("blendshape_shapenames" and
31 /// "blendshape_channels") on the base shape's geometry.
32 /// The shapes should be separately added to the shape library.
33 void GU_API addInputsToBaseShape(GU_Detail &base_shape,
34  const UT_StringArray &shape_names,
35  const UT_StringArray &channel_names);
36 
37 /// Adds detail attributes to the base shape ("blendshape_ptidattr",
38 /// "blendshape_primidattr") for the blendshape deformer's optional parameters.
39 void GU_API setDeformerParameters(GU_Detail &base_shape,
40  const UT_StringHolder &attribs,
41  const UT_StringHolder &ptidattr,
42  const UT_StringHolder &primidattr);
43 
44 /// Reads the detail attributes for the blendshape deformer's optional
45 /// parameters.
46 /// If not specified, attribs is set to "P", ptidattr is set to "id", and
47 /// primidattr is set to "".
48 void GU_API getDeformerParameters(const GU_Detail &base_shape,
49  UT_StringHolder &attribs,
50  UT_StringHolder &ptidattr,
51  UT_StringHolder &primidattr);
52 
55 
57 {
58 public:
59  bool reset(const GU_Detail &base_shape, const GU_AgentRig &rig,
60  const GU_AgentShapeLib &shapelib);
61 
62  /// Returns the number of blendshape inputs.
63  exint numInputs() const { return myChannelIndices.entries(); }
64 
65  /// Returns the GU_AgentRig channel index for the specified input.
67  {
68  return myChannelIndices[i];
69  }
70 
71  /// Returns the name of the primary target shape for the specified channel.
72  const UT_StringHolder &primaryShapeName(exint i) const;
73 
74  /// Returns the names and weights of the in-between target shapes for the
75  /// specific channel (i.e. shapes with weight 0 or 1 are skipped).
76  void getInBetweenShapes(exint i, UT_StringArray &shape_names,
77  FloatArray &shape_weights) const;
78 
79  /// Appends to the provided list of shapes and weights, given an input
80  /// index and weight value. When there are in-between shapes this selects
81  /// the appropriate pair of shapes to blend between based on the provided
82  /// weight.
83  void getShapes(exint i, FloatType w, UT_Array<const GU_Detail *> &shapes,
84  FloatArray &weights) const;
85 
86 private:
87  /// Returns the number of shapes for the specified input. If there are
88  /// in-between shapes this is >= 3, since there are implicit shapes with
89  /// weights 0 and 1, and otherwise 1 is returned.
90  inline exint numShapes(exint i) const
91  {
92  return myInputStarts[i + 1] - myInputStarts[i];
93  }
94 
95  void
96  addInput(exint channel_idx, const UT_Array<GU_ConstDetailHandle> &shapes,
97  const UT_StringArray &shape_names,
98  const FloatArray &shape_weights);
99 
100  /// Channel indices for GU_AgentRig.
101  UT_Array<exint> myChannelIndices;
102 
103  /// Index into myShapes, myShapeWeights, and myShapeNames for where the
104  /// shapes for each channel start.
105  /// The shapes for each input are ordered by weight.
106  UT_Array<exint> myInputStarts;
107 
109  FloatArray myShapeWeights;
110  UT_StringArray myShapeNames;
111 };
112 
113 } // namespace GU_AgentBlendShapeUtils
114 
115 #endif
GLbyte * weights
Definition: glew.h:7551
const GLint * attribs
Definition: glew.h:14385
GLboolean reset
Definition: glew.h:4959
void GU_API getDeformerParameters(const GU_Detail &base_shape, UT_StringHolder &attribs, UT_StringHolder &ptidattr, UT_StringHolder &primidattr)
exint inputChannelIndex(exint i) const
Returns the GU_AgentRig channel index for the specified input.
A rig for the agent primitive.
Definition: GU_AgentRig.h:34
int64 exint
Definition: SYS_Types.h:120
void GU_API setDeformerParameters(GU_Detail &base_shape, const UT_StringHolder &attribs, const UT_StringHolder &ptidattr, const UT_StringHolder &primidattr)
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
void GU_API addInBetweenShapes(GU_Detail &primary_shape_gdp, const UT_StringArray &inbetween_shape_names, const UT_Array< fpreal > &inbetween_weights)
#define GU_API
Definition: GU_API.h:14
UT_Array< FloatType > FloatArray
exint numInputs() const
Returns the number of blendshape inputs.
float fpreal32
Definition: SYS_Types.h:195
void GU_API addInputsToBaseShape(GU_Detail &base_shape, const UT_StringArray &shape_names, const UT_StringArray &channel_names)