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_POLYMOVEVERTEX_H__
11 #define __MayaDM_POLYMOVEVERTEX_H__
12 #include "MayaDMTypes.h"
13 #include "MayaDMConnectables.h"
14 #include "MayaDMPolyModifierWorld.h"
15 namespace MayaDM
16 {
17 class PolyMoveVertex : public PolyModifierWorld
18 {
19 public:
20 public:
21 
PolyMoveVertex()22 	PolyMoveVertex():PolyModifierWorld(){}
23 	PolyMoveVertex(FILE* file,const std::string& name,const std::string& parent="",bool shared=false,bool create=true)
24 		:PolyModifierWorld(file, name, parent, "polyMoveVertex", shared, create){}
~PolyMoveVertex()25 	virtual ~PolyMoveVertex(){}
26 
setTranslate(const double3 & t)27 	void setTranslate(const double3& t)
28 	{
29 		if(t == double3(0.0, 0.0, 0.0)) return;
30 		fprintf(mFile,"\tsetAttr \".t\" -type \"double3\" ");
31 		t.write(mFile);
32 		fprintf(mFile,";\n");
33 	}
setTranslateX(double tx)34 	void setTranslateX(double tx)
35 	{
36 		if(tx == 0) return;
37 		fprintf(mFile,"\tsetAttr \".t.tx\" %f;\n", tx);
38 	}
setTranslateY(double ty)39 	void setTranslateY(double ty)
40 	{
41 		if(ty == 0) return;
42 		fprintf(mFile,"\tsetAttr \".t.ty\" %f;\n", ty);
43 	}
setTranslateZ(double tz)44 	void setTranslateZ(double tz)
45 	{
46 		if(tz == 0) return;
47 		fprintf(mFile,"\tsetAttr \".t.tz\" %f;\n", tz);
48 	}
setRotate(const double3 & ro)49 	void setRotate(const double3& ro)
50 	{
51 		if(ro == double3(0.0, 0.0, 0.0)) return;
52 		fprintf(mFile,"\tsetAttr \".ro\" -type \"double3\" ");
53 		ro.write(mFile);
54 		fprintf(mFile,";\n");
55 	}
setRotateX(double rx)56 	void setRotateX(double rx)
57 	{
58 		if(rx == 0) return;
59 		fprintf(mFile,"\tsetAttr \".ro.rx\" %f;\n", rx);
60 	}
setRotateY(double ry)61 	void setRotateY(double ry)
62 	{
63 		if(ry == 0) return;
64 		fprintf(mFile,"\tsetAttr \".ro.ry\" %f;\n", ry);
65 	}
setRotateZ(double rz)66 	void setRotateZ(double rz)
67 	{
68 		if(rz == 0) return;
69 		fprintf(mFile,"\tsetAttr \".ro.rz\" %f;\n", rz);
70 	}
setScale(const double3 & s)71 	void setScale(const double3& s)
72 	{
73 		if(s == double3(1.0, 1.0, 1.0)) return;
74 		fprintf(mFile,"\tsetAttr \".s\" -type \"double3\" ");
75 		s.write(mFile);
76 		fprintf(mFile,";\n");
77 	}
setScaleX(double sx)78 	void setScaleX(double sx)
79 	{
80 		if(sx == 0.0) return;
81 		fprintf(mFile,"\tsetAttr \".s.sx\" %f;\n", sx);
82 	}
setScaleY(double sy)83 	void setScaleY(double sy)
84 	{
85 		if(sy == 0.0) return;
86 		fprintf(mFile,"\tsetAttr \".s.sy\" %f;\n", sy);
87 	}
setScaleZ(double sz)88 	void setScaleZ(double sz)
89 	{
90 		if(sz == 0.0) return;
91 		fprintf(mFile,"\tsetAttr \".s.sz\" %f;\n", sz);
92 	}
setPivot(const float3 & pvt)93 	void setPivot(const float3& pvt)
94 	{
95 		if(pvt == float3(0.0f,0.0f,0.0f)) return;
96 		fprintf(mFile,"\tsetAttr \".pvt\" -type \"float3\" ");
97 		pvt.write(mFile);
98 		fprintf(mFile,";\n");
99 	}
setPivotX(float pvx)100 	void setPivotX(float pvx)
101 	{
102 		if(pvx == 0) return;
103 		fprintf(mFile,"\tsetAttr \".pvt.pvx\" %f;\n", pvx);
104 	}
setPivotY(float pvy)105 	void setPivotY(float pvy)
106 	{
107 		if(pvy == 0) return;
108 		fprintf(mFile,"\tsetAttr \".pvt.pvy\" %f;\n", pvy);
109 	}
setPivotZ(float pvz)110 	void setPivotZ(float pvz)
111 	{
112 		if(pvz == 0) return;
113 		fprintf(mFile,"\tsetAttr \".pvt.pvz\" %f;\n", pvz);
114 	}
setRandom(float ran)115 	void setRandom(float ran)
116 	{
117 		if(ran == 0.0) return;
118 		fprintf(mFile,"\tsetAttr \".ran\" %f;\n", ran);
119 	}
setRandomSeed(int rs)120 	void setRandomSeed(int rs)
121 	{
122 		if(rs == 0) return;
123 		fprintf(mFile,"\tsetAttr \".rs\" %i;\n", rs);
124 	}
setLocalTranslate(const double3 & lt)125 	void setLocalTranslate(const double3& lt)
126 	{
127 		if(lt == double3(0.0, 0.0, 0.0)) return;
128 		fprintf(mFile,"\tsetAttr \".lt\" -type \"double3\" ");
129 		lt.write(mFile);
130 		fprintf(mFile,";\n");
131 	}
setLocalTranslateX(double ltx)132 	void setLocalTranslateX(double ltx)
133 	{
134 		if(ltx == 0) return;
135 		fprintf(mFile,"\tsetAttr \".lt.ltx\" %f;\n", ltx);
136 	}
setLocalTranslateY(double lty)137 	void setLocalTranslateY(double lty)
138 	{
139 		if(lty == 0) return;
140 		fprintf(mFile,"\tsetAttr \".lt.lty\" %f;\n", lty);
141 	}
setLocalTranslateZ(double ltz)142 	void setLocalTranslateZ(double ltz)
143 	{
144 		if(ltz == 0) return;
145 		fprintf(mFile,"\tsetAttr \".lt.ltz\" %f;\n", ltz);
146 	}
setLocalDirection(const double3 & ld)147 	void setLocalDirection(const double3& ld)
148 	{
149 		if(ld == double3(1.0, 0.0, 0.0)) return;
150 		fprintf(mFile,"\tsetAttr \".ld\" -type \"double3\" ");
151 		ld.write(mFile);
152 		fprintf(mFile,";\n");
153 	}
setLocalDirectionX(double ldx)154 	void setLocalDirectionX(double ldx)
155 	{
156 		if(ldx == 0) return;
157 		fprintf(mFile,"\tsetAttr \".ld.ldx\" %f;\n", ldx);
158 	}
setLocalDirectionY(double ldy)159 	void setLocalDirectionY(double ldy)
160 	{
161 		if(ldy == 0) return;
162 		fprintf(mFile,"\tsetAttr \".ld.ldy\" %f;\n", ldy);
163 	}
setLocalDirectionZ(double ldz)164 	void setLocalDirectionZ(double ldz)
165 	{
166 		if(ldz == 0) return;
167 		fprintf(mFile,"\tsetAttr \".ld.ldz\" %f;\n", ldz);
168 	}
setGain(size_t ga_i,float ga)169 	void setGain(size_t ga_i,float ga)
170 	{
171 		if(ga == 1.0) return;
172 		fprintf(mFile,"\tsetAttr \".ga[%i]\" %f;\n", ga_i,ga);
173 	}
setGain(size_t ga_start,size_t ga_end,float * ga)174 	void setGain(size_t ga_start,size_t ga_end,float* ga)
175 	{
176 		fprintf(mFile,"\tsetAttr \".ga[%i:%i]\" ", ga_start,ga_end);
177 		size_t size = (ga_end-ga_start)*1+1;
178 		for(size_t i=0;i<size;++i)
179 		{
180 			fprintf(mFile,"%f",ga[i]);
181 			if(i+1<size) fprintf(mFile," ");
182 		}
183 		fprintf(mFile,";\n");
184 	}
startGain(size_t ga_start,size_t ga_end)185 	void startGain(size_t ga_start,size_t ga_end)const
186 	{
187 		fprintf(mFile,"\tsetAttr \".ga[%i:%i]\"",ga_start,ga_end);
188 	}
appendGain(float ga)189 	void appendGain(float ga)const
190 	{
191 		fprintf(mFile," %f",ga);
192 	}
endGain()193 	void endGain()const
194 	{
195 		fprintf(mFile,";\n");
196 	}
getTranslate()197 	void getTranslate()const
198 	{
199 		fprintf(mFile,"\"%s.t\"",mName.c_str());
200 	}
getTranslateX()201 	void getTranslateX()const
202 	{
203 		fprintf(mFile,"\"%s.t.tx\"",mName.c_str());
204 	}
getTranslateY()205 	void getTranslateY()const
206 	{
207 		fprintf(mFile,"\"%s.t.ty\"",mName.c_str());
208 	}
getTranslateZ()209 	void getTranslateZ()const
210 	{
211 		fprintf(mFile,"\"%s.t.tz\"",mName.c_str());
212 	}
getRotate()213 	void getRotate()const
214 	{
215 		fprintf(mFile,"\"%s.ro\"",mName.c_str());
216 	}
getRotateX()217 	void getRotateX()const
218 	{
219 		fprintf(mFile,"\"%s.ro.rx\"",mName.c_str());
220 	}
getRotateY()221 	void getRotateY()const
222 	{
223 		fprintf(mFile,"\"%s.ro.ry\"",mName.c_str());
224 	}
getRotateZ()225 	void getRotateZ()const
226 	{
227 		fprintf(mFile,"\"%s.ro.rz\"",mName.c_str());
228 	}
getScale()229 	void getScale()const
230 	{
231 		fprintf(mFile,"\"%s.s\"",mName.c_str());
232 	}
getScaleX()233 	void getScaleX()const
234 	{
235 		fprintf(mFile,"\"%s.s.sx\"",mName.c_str());
236 	}
getScaleY()237 	void getScaleY()const
238 	{
239 		fprintf(mFile,"\"%s.s.sy\"",mName.c_str());
240 	}
getScaleZ()241 	void getScaleZ()const
242 	{
243 		fprintf(mFile,"\"%s.s.sz\"",mName.c_str());
244 	}
getPivot()245 	void getPivot()const
246 	{
247 		fprintf(mFile,"\"%s.pvt\"",mName.c_str());
248 	}
getPivotX()249 	void getPivotX()const
250 	{
251 		fprintf(mFile,"\"%s.pvt.pvx\"",mName.c_str());
252 	}
getPivotY()253 	void getPivotY()const
254 	{
255 		fprintf(mFile,"\"%s.pvt.pvy\"",mName.c_str());
256 	}
getPivotZ()257 	void getPivotZ()const
258 	{
259 		fprintf(mFile,"\"%s.pvt.pvz\"",mName.c_str());
260 	}
getRandom()261 	void getRandom()const
262 	{
263 		fprintf(mFile,"\"%s.ran\"",mName.c_str());
264 	}
getRandomSeed()265 	void getRandomSeed()const
266 	{
267 		fprintf(mFile,"\"%s.rs\"",mName.c_str());
268 	}
getLocalTranslate()269 	void getLocalTranslate()const
270 	{
271 		fprintf(mFile,"\"%s.lt\"",mName.c_str());
272 	}
getLocalTranslateX()273 	void getLocalTranslateX()const
274 	{
275 		fprintf(mFile,"\"%s.lt.ltx\"",mName.c_str());
276 	}
getLocalTranslateY()277 	void getLocalTranslateY()const
278 	{
279 		fprintf(mFile,"\"%s.lt.lty\"",mName.c_str());
280 	}
getLocalTranslateZ()281 	void getLocalTranslateZ()const
282 	{
283 		fprintf(mFile,"\"%s.lt.ltz\"",mName.c_str());
284 	}
getLocalDirection()285 	void getLocalDirection()const
286 	{
287 		fprintf(mFile,"\"%s.ld\"",mName.c_str());
288 	}
getLocalDirectionX()289 	void getLocalDirectionX()const
290 	{
291 		fprintf(mFile,"\"%s.ld.ldx\"",mName.c_str());
292 	}
getLocalDirectionY()293 	void getLocalDirectionY()const
294 	{
295 		fprintf(mFile,"\"%s.ld.ldy\"",mName.c_str());
296 	}
getLocalDirectionZ()297 	void getLocalDirectionZ()const
298 	{
299 		fprintf(mFile,"\"%s.ld.ldz\"",mName.c_str());
300 	}
getMatrix()301 	void getMatrix()const
302 	{
303 		fprintf(mFile,"\"%s.cma\"",mName.c_str());
304 	}
getCompId()305 	void getCompId()const
306 	{
307 		fprintf(mFile,"\"%s.cid\"",mName.c_str());
308 	}
getGain(size_t ga_i)309 	void getGain(size_t ga_i)const
310 	{
311 		fprintf(mFile,"\"%s.ga[%i]\"",mName.c_str(),ga_i);
312 	}
getGain()313 	void getGain()const
314 	{
315 
316 		fprintf(mFile,"\"%s.ga\"",mName.c_str());
317 	}
318 protected:
319 	PolyMoveVertex(FILE* file,const std::string& name,const std::string& parent,const std::string& nodeType,bool shared=false,bool create=true)
PolyModifierWorld(file,name,parent,nodeType,shared,create)320 		:PolyModifierWorld(file, name, parent, nodeType, shared, create) {}
321 
322 };
323 }//namespace MayaDM
324 #endif//__MayaDM_POLYMOVEVERTEX_H__
325