00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __GU_Muscle_h__
00019 #define __GU_Muscle_h__
00020
00021 #include "GU_API.h"
00022 #include "GU_Detail.h"
00023
00024 class OP_Context;
00025 class GU_PrimPoly;
00026 class GU_PrimMetaball;
00027 class GU_PrimSphere;
00028
00029
00030 #define DEFAULT_CENTER_GROUP "center"
00031
00032 typedef fpreal gu_Cubic[4];
00033
00034 enum GU_MuscleType {
00035 GU_MUSCLE_META = 0,
00036 GU_MUSCLE_SPHERE
00037 };
00038
00039
00040
00041 class GU_API GU_MuscleParms {
00042 public:
00043
00044 GU_Detail *gdp;
00045
00046 GU_Detail *myExtraGdp;
00047
00048
00049
00050
00051 UT_String name;
00052
00053
00054 fpreal fullscalex, fullscaley, fullscalez;
00055
00056
00057 fpreal pos2, pos3, pos4;
00058
00059
00060 fpreal sx1, sx2, sx3, sx4, sx5;
00061 fpreal sy1, sy2, sy3, sy4, sy5;
00062 fpreal sz1, sz2, sz3, sz4, sz5;
00063
00064
00065 int primsPerSegment;
00066
00067
00068 GU_MuscleType type;
00069
00070
00071 int basis;
00072 int sampledivs;
00073 int firstcv;
00074 int lastcv;
00075 float cvtension;
00076 };
00077
00078
00079
00080 class GU_API GU_Muscle
00081 {
00082 public:
00083
00084 GU_Muscle();
00085 ~GU_Muscle() {}
00086
00087 bool build(GU_MuscleParms &parms,
00088 const UT_RefArray<UT_Matrix4>
00089 &inputXforms);
00090
00091 GB_PointGroup *getCenterPoints() { return myCenterPoints; }
00092 GB_PrimitiveGroup *getPrimitiveGroup() { return myPrimitives; }
00093 int getNumPrimitives() { return myNumPrimitives; }
00094
00095 bool getTranslates(
00096 UT_RefArray<UT_Matrix4> &translates);
00097
00098 bool getRotates(UT_RefArray<UT_Matrix4> &rotates);
00099
00100 const GEO_PrimPoly *getCenterCurve();
00101
00102 private:
00103
00104
00105
00106 static void calcLeftCurve(gu_Cubic &curve1,
00107 gu_Cubic &curve2,
00108 fpreal y1, fpreal y2, fpreal y3,
00109 fpreal x2, fpreal x3);
00110
00111
00112
00113 static void calcRightCurve(gu_Cubic &curve1,
00114 gu_Cubic &curve2,
00115 fpreal y3, fpreal y4, fpreal y5,
00116 fpreal x3, fpreal x4);
00117
00118
00119 static inline fpreal evalProfile(fpreal t,
00120 const gu_Cubic &curve1,
00121 const gu_Cubic &curve2,
00122 const gu_Cubic &curve3,
00123 const gu_Cubic &curve4,
00124 fpreal x2, fpreal x3, fpreal x4);
00125
00126
00127
00128
00129 GEO_PrimPoly *resampleCenterLine(const UT_FloatArray
00130 &positions);
00131
00132
00133 void addPrimitives(int numPrimitives);
00134
00135
00136 void setupScaleXforms(const UT_Vector3Array
00137 &scales);
00138
00139
00140
00141
00142 bool getPrimitiveInfo( UT_FloatArray &positions,
00143 UT_Vector3Array &scales,
00144 bool controlPointsOnly=false);
00145
00146
00147
00148
00149 void transformPrimitives(GEO_PrimPoly *guide);
00150
00151
00152 bool buildCenterLine(const UT_RefArray<UT_Matrix4>
00153 &inputXforms);
00154
00155 void CENTERGROUP(UT_String &str)
00156 {
00157 str = DEFAULT_CENTER_GROUP;
00158 }
00159
00160
00161
00162 void addPoly(GB_PointGroup *group);
00163
00164
00165 void addMetaPrimitives(int numMeta);
00166
00167
00168 void addSpherePrimitives(int numSpheres);
00169
00170 void getPrimitiveTranslates(GEO_PrimPoly *guide,
00171 int numPrimitives,
00172 UT_RefArray<UT_Matrix4> &translates);
00173
00174 private:
00175
00176 GU_MuscleParms *myParms;
00177
00178
00179 GU_PrimPoly *myCenterCurve;
00180
00181
00182
00183 GB_PointGroup *myCenterPoints;
00184
00185
00186
00187 GB_PrimitiveGroup *myPrimitives;
00188
00189
00190
00191 int myNumPrimitives;
00192
00193
00194
00195
00196 int myNormalOffset;
00197
00198
00199
00200
00201 UT_RefArray<UT_Matrix4> myCachedScaleXforms;
00202
00203
00204
00205 UT_RefArray<UT_Matrix4> mySavedRotates;
00206 UT_RefArray<UT_Matrix4> mySavedTranslates;
00207 };
00208
00209
00210
00211 #endif