1 /*
2     Copyright (c) 2008-2009 NetAllied Systems GmbH
3 
4     This file is part of MayaDataModel.
5 
6     Licensed under the MIT Open Source License,
7     for details please see LICENSE file or the website
8     http://www.opensource.org/licenses/mit-license.php
9 */
10 #ifndef __MayaDM_JOINT_H__
11 #define __MayaDM_JOINT_H__
12 #include "MayaDMTypes.h"
13 #include "MayaDMConnectables.h"
14 #include "MayaDMTransform.h"
15 namespace MayaDM
16 {
17 class Joint : public Transform
18 {
19 public:
20 public:
21 
Joint()22 	Joint():Transform(){}
23 	Joint(FILE* file,const std::string& name,const std::string& parent="",bool shared=false,bool create=true)
24 		:Transform(file, name, parent, "joint", shared, create){}
~Joint()25 	virtual ~Joint(){}
26 
setJointOrientType(const string & jot)27 	void setJointOrientType(const string& jot)
28 	{
29 		if(jot == "xyz") return;
30 		fprintf(mFile,"\tsetAttr \".jot\" -type \"string\" ");
31 		jot.write(mFile);
32 		fprintf(mFile,";\n");
33 	}
setJointTypeX(bool jtx)34 	void setJointTypeX(bool jtx)
35 	{
36 		if(jtx == true) return;
37 		fprintf(mFile,"\tsetAttr \".jtx\" %i;\n", jtx);
38 	}
setJointTypeY(bool jty)39 	void setJointTypeY(bool jty)
40 	{
41 		if(jty == true) return;
42 		fprintf(mFile,"\tsetAttr \".jty\" %i;\n", jty);
43 	}
setJointTypeZ(bool jtz)44 	void setJointTypeZ(bool jtz)
45 	{
46 		if(jtz == true) return;
47 		fprintf(mFile,"\tsetAttr \".jtz\" %i;\n", jtz);
48 	}
setJointOrient(const double3 & jo)49 	void setJointOrient(const double3& jo)
50 	{
51 		fprintf(mFile,"\tsetAttr \".jo\" -type \"double3\" ");
52 		jo.write(mFile);
53 		fprintf(mFile,";\n");
54 	}
setJointOrientX(double jox)55 	void setJointOrientX(double jox)
56 	{
57 		if(jox == 0) return;
58 		fprintf(mFile,"\tsetAttr \".jo.jox\" %f;\n", jox);
59 	}
setJointOrientY(double joy)60 	void setJointOrientY(double joy)
61 	{
62 		if(joy == 0) return;
63 		fprintf(mFile,"\tsetAttr \".jo.joy\" %f;\n", joy);
64 	}
setJointOrientZ(double joz)65 	void setJointOrientZ(double joz)
66 	{
67 		if(joz == 0) return;
68 		fprintf(mFile,"\tsetAttr \".jo.joz\" %f;\n", joz);
69 	}
setSegmentScaleCompensate(bool ssc)70 	void setSegmentScaleCompensate(bool ssc)
71 	{
72 		if(ssc == true) return;
73 		fprintf(mFile,"\tsetAttr \".ssc\" %i;\n", ssc);
74 	}
setInverseScale(const double3 & is)75 	void setInverseScale(const double3& is)
76 	{
77 		fprintf(mFile,"\tsetAttr \".is\" -type \"double3\" ");
78 		is.write(mFile);
79 		fprintf(mFile,";\n");
80 	}
setInverseScaleX(double isx)81 	void setInverseScaleX(double isx)
82 	{
83 		if(isx == 1.0) return;
84 		fprintf(mFile,"\tsetAttr \".is.isx\" %f;\n", isx);
85 	}
setInverseScaleY(double isy)86 	void setInverseScaleY(double isy)
87 	{
88 		if(isy == 1.0) return;
89 		fprintf(mFile,"\tsetAttr \".is.isy\" %f;\n", isy);
90 	}
setInverseScaleZ(double isz)91 	void setInverseScaleZ(double isz)
92 	{
93 		if(isz == 1.0) return;
94 		fprintf(mFile,"\tsetAttr \".is.isz\" %f;\n", isz);
95 	}
setStiffness(const double3 & st)96 	void setStiffness(const double3& st)
97 	{
98 		fprintf(mFile,"\tsetAttr \".st\" -type \"double3\" ");
99 		st.write(mFile);
100 		fprintf(mFile,";\n");
101 	}
setStiffnessX(double stx)102 	void setStiffnessX(double stx)
103 	{
104 		if(stx == 0.0) return;
105 		fprintf(mFile,"\tsetAttr \".st.stx\" %f;\n", stx);
106 	}
setStiffnessY(double sty)107 	void setStiffnessY(double sty)
108 	{
109 		if(sty == 0.0) return;
110 		fprintf(mFile,"\tsetAttr \".st.sty\" %f;\n", sty);
111 	}
setStiffnessZ(double stz)112 	void setStiffnessZ(double stz)
113 	{
114 		if(stz == 0.0) return;
115 		fprintf(mFile,"\tsetAttr \".st.stz\" %f;\n", stz);
116 	}
setPreferredAngle(const double3 & pa)117 	void setPreferredAngle(const double3& pa)
118 	{
119 		fprintf(mFile,"\tsetAttr \".pa\" -type \"double3\" ");
120 		pa.write(mFile);
121 		fprintf(mFile,";\n");
122 	}
setPreferredAngleX(double pax)123 	void setPreferredAngleX(double pax)
124 	{
125 		if(pax == 0) return;
126 		fprintf(mFile,"\tsetAttr \".pa.pax\" %f;\n", pax);
127 	}
setPreferredAngleY(double pay)128 	void setPreferredAngleY(double pay)
129 	{
130 		if(pay == 0) return;
131 		fprintf(mFile,"\tsetAttr \".pa.pay\" %f;\n", pay);
132 	}
setPreferredAngleZ(double paz)133 	void setPreferredAngleZ(double paz)
134 	{
135 		if(paz == 0) return;
136 		fprintf(mFile,"\tsetAttr \".pa.paz\" %f;\n", paz);
137 	}
setMinRotateDampRange(const double3 & ndr)138 	void setMinRotateDampRange(const double3& ndr)
139 	{
140 		fprintf(mFile,"\tsetAttr \".ndr\" -type \"double3\" ");
141 		ndr.write(mFile);
142 		fprintf(mFile,";\n");
143 	}
setMinRotateDampRangeX(double ndx)144 	void setMinRotateDampRangeX(double ndx)
145 	{
146 		if(ndx == 0) return;
147 		fprintf(mFile,"\tsetAttr \".ndr.ndx\" %f;\n", ndx);
148 	}
setMinRotateDampRangeY(double ndy)149 	void setMinRotateDampRangeY(double ndy)
150 	{
151 		if(ndy == 0) return;
152 		fprintf(mFile,"\tsetAttr \".ndr.ndy\" %f;\n", ndy);
153 	}
setMinRotateDampRangeZ(double ndz)154 	void setMinRotateDampRangeZ(double ndz)
155 	{
156 		if(ndz == 0) return;
157 		fprintf(mFile,"\tsetAttr \".ndr.ndz\" %f;\n", ndz);
158 	}
setMinRotateDampStrength(const double3 & nst)159 	void setMinRotateDampStrength(const double3& nst)
160 	{
161 		fprintf(mFile,"\tsetAttr \".nst\" -type \"double3\" ");
162 		nst.write(mFile);
163 		fprintf(mFile,";\n");
164 	}
setMinRotateDampStrengthX(double nstx)165 	void setMinRotateDampStrengthX(double nstx)
166 	{
167 		if(nstx == 0.0) return;
168 		fprintf(mFile,"\tsetAttr \".nst.nstx\" %f;\n", nstx);
169 	}
setMinRotateDampStrengthY(double nsty)170 	void setMinRotateDampStrengthY(double nsty)
171 	{
172 		if(nsty == 0.0) return;
173 		fprintf(mFile,"\tsetAttr \".nst.nsty\" %f;\n", nsty);
174 	}
setMinRotateDampStrengthZ(double nstz)175 	void setMinRotateDampStrengthZ(double nstz)
176 	{
177 		if(nstz == 0.0) return;
178 		fprintf(mFile,"\tsetAttr \".nst.nstz\" %f;\n", nstz);
179 	}
setMaxRotateDampRange(const double3 & xdr)180 	void setMaxRotateDampRange(const double3& xdr)
181 	{
182 		fprintf(mFile,"\tsetAttr \".xdr\" -type \"double3\" ");
183 		xdr.write(mFile);
184 		fprintf(mFile,";\n");
185 	}
setMaxRotateDampRangeX(double xdx)186 	void setMaxRotateDampRangeX(double xdx)
187 	{
188 		if(xdx == 0) return;
189 		fprintf(mFile,"\tsetAttr \".xdr.xdx\" %f;\n", xdx);
190 	}
setMaxRotateDampRangeY(double xdy)191 	void setMaxRotateDampRangeY(double xdy)
192 	{
193 		if(xdy == 0) return;
194 		fprintf(mFile,"\tsetAttr \".xdr.xdy\" %f;\n", xdy);
195 	}
setMaxRotateDampRangeZ(double xdz)196 	void setMaxRotateDampRangeZ(double xdz)
197 	{
198 		if(xdz == 0) return;
199 		fprintf(mFile,"\tsetAttr \".xdr.xdz\" %f;\n", xdz);
200 	}
setMaxRotateDampStrength(const double3 & xst)201 	void setMaxRotateDampStrength(const double3& xst)
202 	{
203 		fprintf(mFile,"\tsetAttr \".xst\" -type \"double3\" ");
204 		xst.write(mFile);
205 		fprintf(mFile,";\n");
206 	}
setMaxRotateDampStrengthX(double xstx)207 	void setMaxRotateDampStrengthX(double xstx)
208 	{
209 		if(xstx == 0.0) return;
210 		fprintf(mFile,"\tsetAttr \".xst.xstx\" %f;\n", xstx);
211 	}
setMaxRotateDampStrengthY(double xsty)212 	void setMaxRotateDampStrengthY(double xsty)
213 	{
214 		if(xsty == 0.0) return;
215 		fprintf(mFile,"\tsetAttr \".xst.xsty\" %f;\n", xsty);
216 	}
setMaxRotateDampStrengthZ(double xstz)217 	void setMaxRotateDampStrengthZ(double xstz)
218 	{
219 		if(xstz == 0.0) return;
220 		fprintf(mFile,"\tsetAttr \".xst.xstz\" %f;\n", xstz);
221 	}
setBindPose(const matrix & bps)222 	void setBindPose(const matrix& bps)
223 	{
224 		if(bps == identity) return;
225 		fprintf(mFile,"\tsetAttr \".bps\" -type \"matrix\" ");
226 		bps.write(mFile);
227 		fprintf(mFile,";\n");
228 	}
setDrawStyle(unsigned int ds)229 	void setDrawStyle(unsigned int ds)
230 	{
231 		if(ds == 0) return;
232 		fprintf(mFile,"\tsetAttr \".ds\" %i;\n", ds);
233 	}
setDrawLabel(bool dl)234 	void setDrawLabel(bool dl)
235 	{
236 		if(dl == false) return;
237 		fprintf(mFile,"\tsetAttr \".dl\" %i;\n", dl);
238 	}
setSide(unsigned int sd)239 	void setSide(unsigned int sd)
240 	{
241 		if(sd == 0) return;
242 		fprintf(mFile,"\tsetAttr \".sd\" %i;\n", sd);
243 	}
setType(unsigned int typ)244 	void setType(unsigned int typ)
245 	{
246 		if(typ == 0) return;
247 		fprintf(mFile,"\tsetAttr \".typ\" %i;\n", typ);
248 	}
setOtherType(const string & otp)249 	void setOtherType(const string& otp)
250 	{
251 		if(otp == "jaw") return;
252 		fprintf(mFile,"\tsetAttr \".otp\" -type \"string\" ");
253 		otp.write(mFile);
254 		fprintf(mFile,";\n");
255 	}
setRadius(double radi)256 	void setRadius(double radi)
257 	{
258 		if(radi == 1.0) return;
259 		fprintf(mFile,"\tsetAttr \".radi\" %f;\n", radi);
260 	}
setHikNodeID(int hni)261 	void setHikNodeID(int hni)
262 	{
263 		if(hni == -1) return;
264 		fprintf(mFile,"\tsetAttr \".hni\" %i;\n", hni);
265 	}
getJointTypeX()266 	void getJointTypeX()const
267 	{
268 		fprintf(mFile,"\"%s.jtx\"",mName.c_str());
269 	}
getJointTypeY()270 	void getJointTypeY()const
271 	{
272 		fprintf(mFile,"\"%s.jty\"",mName.c_str());
273 	}
getJointTypeZ()274 	void getJointTypeZ()const
275 	{
276 		fprintf(mFile,"\"%s.jtz\"",mName.c_str());
277 	}
getJointOrient()278 	void getJointOrient()const
279 	{
280 		fprintf(mFile,"\"%s.jo\"",mName.c_str());
281 	}
getJointOrientX()282 	void getJointOrientX()const
283 	{
284 		fprintf(mFile,"\"%s.jo.jox\"",mName.c_str());
285 	}
getJointOrientY()286 	void getJointOrientY()const
287 	{
288 		fprintf(mFile,"\"%s.jo.joy\"",mName.c_str());
289 	}
getJointOrientZ()290 	void getJointOrientZ()const
291 	{
292 		fprintf(mFile,"\"%s.jo.joz\"",mName.c_str());
293 	}
getSegmentScaleCompensate()294 	void getSegmentScaleCompensate()const
295 	{
296 		fprintf(mFile,"\"%s.ssc\"",mName.c_str());
297 	}
getInverseScale()298 	void getInverseScale()const
299 	{
300 		fprintf(mFile,"\"%s.is\"",mName.c_str());
301 	}
getInverseScaleX()302 	void getInverseScaleX()const
303 	{
304 		fprintf(mFile,"\"%s.is.isx\"",mName.c_str());
305 	}
getInverseScaleY()306 	void getInverseScaleY()const
307 	{
308 		fprintf(mFile,"\"%s.is.isy\"",mName.c_str());
309 	}
getInverseScaleZ()310 	void getInverseScaleZ()const
311 	{
312 		fprintf(mFile,"\"%s.is.isz\"",mName.c_str());
313 	}
getStiffness()314 	void getStiffness()const
315 	{
316 		fprintf(mFile,"\"%s.st\"",mName.c_str());
317 	}
getStiffnessX()318 	void getStiffnessX()const
319 	{
320 		fprintf(mFile,"\"%s.st.stx\"",mName.c_str());
321 	}
getStiffnessY()322 	void getStiffnessY()const
323 	{
324 		fprintf(mFile,"\"%s.st.sty\"",mName.c_str());
325 	}
getStiffnessZ()326 	void getStiffnessZ()const
327 	{
328 		fprintf(mFile,"\"%s.st.stz\"",mName.c_str());
329 	}
getPreferredAngle()330 	void getPreferredAngle()const
331 	{
332 		fprintf(mFile,"\"%s.pa\"",mName.c_str());
333 	}
getPreferredAngleX()334 	void getPreferredAngleX()const
335 	{
336 		fprintf(mFile,"\"%s.pa.pax\"",mName.c_str());
337 	}
getPreferredAngleY()338 	void getPreferredAngleY()const
339 	{
340 		fprintf(mFile,"\"%s.pa.pay\"",mName.c_str());
341 	}
getPreferredAngleZ()342 	void getPreferredAngleZ()const
343 	{
344 		fprintf(mFile,"\"%s.pa.paz\"",mName.c_str());
345 	}
getMinRotateDampRange()346 	void getMinRotateDampRange()const
347 	{
348 		fprintf(mFile,"\"%s.ndr\"",mName.c_str());
349 	}
getMinRotateDampRangeX()350 	void getMinRotateDampRangeX()const
351 	{
352 		fprintf(mFile,"\"%s.ndr.ndx\"",mName.c_str());
353 	}
getMinRotateDampRangeY()354 	void getMinRotateDampRangeY()const
355 	{
356 		fprintf(mFile,"\"%s.ndr.ndy\"",mName.c_str());
357 	}
getMinRotateDampRangeZ()358 	void getMinRotateDampRangeZ()const
359 	{
360 		fprintf(mFile,"\"%s.ndr.ndz\"",mName.c_str());
361 	}
getMinRotateDampStrength()362 	void getMinRotateDampStrength()const
363 	{
364 		fprintf(mFile,"\"%s.nst\"",mName.c_str());
365 	}
getMinRotateDampStrengthX()366 	void getMinRotateDampStrengthX()const
367 	{
368 		fprintf(mFile,"\"%s.nst.nstx\"",mName.c_str());
369 	}
getMinRotateDampStrengthY()370 	void getMinRotateDampStrengthY()const
371 	{
372 		fprintf(mFile,"\"%s.nst.nsty\"",mName.c_str());
373 	}
getMinRotateDampStrengthZ()374 	void getMinRotateDampStrengthZ()const
375 	{
376 		fprintf(mFile,"\"%s.nst.nstz\"",mName.c_str());
377 	}
getMaxRotateDampRange()378 	void getMaxRotateDampRange()const
379 	{
380 		fprintf(mFile,"\"%s.xdr\"",mName.c_str());
381 	}
getMaxRotateDampRangeX()382 	void getMaxRotateDampRangeX()const
383 	{
384 		fprintf(mFile,"\"%s.xdr.xdx\"",mName.c_str());
385 	}
getMaxRotateDampRangeY()386 	void getMaxRotateDampRangeY()const
387 	{
388 		fprintf(mFile,"\"%s.xdr.xdy\"",mName.c_str());
389 	}
getMaxRotateDampRangeZ()390 	void getMaxRotateDampRangeZ()const
391 	{
392 		fprintf(mFile,"\"%s.xdr.xdz\"",mName.c_str());
393 	}
getMaxRotateDampStrength()394 	void getMaxRotateDampStrength()const
395 	{
396 		fprintf(mFile,"\"%s.xst\"",mName.c_str());
397 	}
getMaxRotateDampStrengthX()398 	void getMaxRotateDampStrengthX()const
399 	{
400 		fprintf(mFile,"\"%s.xst.xstx\"",mName.c_str());
401 	}
getMaxRotateDampStrengthY()402 	void getMaxRotateDampStrengthY()const
403 	{
404 		fprintf(mFile,"\"%s.xst.xsty\"",mName.c_str());
405 	}
getMaxRotateDampStrengthZ()406 	void getMaxRotateDampStrengthZ()const
407 	{
408 		fprintf(mFile,"\"%s.xst.xstz\"",mName.c_str());
409 	}
getBindPose()410 	void getBindPose()const
411 	{
412 		fprintf(mFile,"\"%s.bps\"",mName.c_str());
413 	}
getDrawLabel()414 	void getDrawLabel()const
415 	{
416 		fprintf(mFile,"\"%s.dl\"",mName.c_str());
417 	}
getRadius()418 	void getRadius()const
419 	{
420 		fprintf(mFile,"\"%s.radi\"",mName.c_str());
421 	}
getHikNodeID()422 	void getHikNodeID()const
423 	{
424 		fprintf(mFile,"\"%s.hni\"",mName.c_str());
425 	}
426 protected:
427 	Joint(FILE* file,const std::string& name,const std::string& parent,const std::string& nodeType,bool shared=false,bool create=true)
Transform(file,name,parent,nodeType,shared,create)428 		:Transform(file, name, parent, nodeType, shared, create) {}
429 
430 };
431 }//namespace MayaDM
432 #endif//__MayaDM_JOINT_H__
433