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_UVCHOOSER_H__
11 #define __MayaDM_UVCHOOSER_H__
12 #include "MayaDMTypes.h"
13 #include "MayaDMConnectables.h"
14 #include "MayaDMDependNode.h"
15 namespace MayaDM
16 {
17 class UvChooser : public DependNode
18 {
19 public:
20 public:
21 
UvChooser()22 	UvChooser():DependNode(){}
23 	UvChooser(FILE* file,const std::string& name,const std::string& parent="",bool shared=false,bool create=true)
24 		:DependNode(file, name, parent, "uvChooser", shared, create){}
~UvChooser()25 	virtual ~UvChooser(){}
26 
setUvSets(size_t uvs_i,const string & uvs)27 	void setUvSets(size_t uvs_i,const string& uvs)
28 	{
29 		if(uvs == "NULL") return;
30 		fprintf(mFile,"\tsetAttr \".uvs[%i]\" -type \"string\" ",uvs_i);
31 		uvs.write(mFile);
32 		fprintf(mFile,";\n");
33 	}
setUvSets(size_t uvs_start,size_t uvs_end,string * uvs)34 	void setUvSets(size_t uvs_start,size_t uvs_end,string* uvs)
35 	{
36 		fprintf(mFile,"\tsetAttr \".uvs[%i:%i]\" ", uvs_start,uvs_end);
37 		size_t size = (uvs_end-uvs_start)*1+1;
38 		for(size_t i=0;i<size;++i)
39 		{
40 			uvs[i].write(mFile);
41 			fprintf(mFile,"\n");
42 		}
43 		fprintf(mFile,";\n");
44 	}
startUvSets(size_t uvs_start,size_t uvs_end)45 	void startUvSets(size_t uvs_start,size_t uvs_end)const
46 	{
47 		fprintf(mFile,"\tsetAttr \".uvs[%i:%i]\"",uvs_start,uvs_end);
48 		fprintf(mFile," -type \"string\" ");
49 	}
appendUvSets(const string & uvs)50 	void appendUvSets(const string& uvs)const
51 	{
52 		fprintf(mFile," ");
53 		uvs.write(mFile);
54 	}
endUvSets()55 	void endUvSets()const
56 	{
57 		fprintf(mFile,";\n");
58 	}
setVertexUvOne(const float2 & vt1)59 	void setVertexUvOne(const float2& vt1)
60 	{
61 		fprintf(mFile,"\tsetAttr \".vt1\" -type \"float2\" ");
62 		vt1.write(mFile);
63 		fprintf(mFile,";\n");
64 	}
setVertexUvOneU(float t1u)65 	void setVertexUvOneU(float t1u)
66 	{
67 		if(t1u == 0.0) return;
68 		fprintf(mFile,"\tsetAttr \".vt1.t1u\" %f;\n", t1u);
69 	}
setVertexUvOneV(float t1v)70 	void setVertexUvOneV(float t1v)
71 	{
72 		if(t1v == 0.0) return;
73 		fprintf(mFile,"\tsetAttr \".vt1.t1v\" %f;\n", t1v);
74 	}
setVertexUvTwo(const float2 & vt2)75 	void setVertexUvTwo(const float2& vt2)
76 	{
77 		fprintf(mFile,"\tsetAttr \".vt2\" -type \"float2\" ");
78 		vt2.write(mFile);
79 		fprintf(mFile,";\n");
80 	}
setVertexUvTwoU(float t2u)81 	void setVertexUvTwoU(float t2u)
82 	{
83 		if(t2u == 0.0) return;
84 		fprintf(mFile,"\tsetAttr \".vt2.t2u\" %f;\n", t2u);
85 	}
setVertexUvTwoV(float t2v)86 	void setVertexUvTwoV(float t2v)
87 	{
88 		if(t2v == 0.0) return;
89 		fprintf(mFile,"\tsetAttr \".vt2.t2v\" %f;\n", t2v);
90 	}
setVertexUvThree(const float2 & vt3)91 	void setVertexUvThree(const float2& vt3)
92 	{
93 		fprintf(mFile,"\tsetAttr \".vt3\" -type \"float2\" ");
94 		vt3.write(mFile);
95 		fprintf(mFile,";\n");
96 	}
setVertexUvThreeU(float t3u)97 	void setVertexUvThreeU(float t3u)
98 	{
99 		if(t3u == 0.0) return;
100 		fprintf(mFile,"\tsetAttr \".vt3.t3u\" %f;\n", t3u);
101 	}
setVertexUvThreeV(float t3v)102 	void setVertexUvThreeV(float t3v)
103 	{
104 		if(t3v == 0.0) return;
105 		fprintf(mFile,"\tsetAttr \".vt3.t3v\" %f;\n", t3v);
106 	}
setVertexCameraOne(const float3 & vc1)107 	void setVertexCameraOne(const float3& vc1)
108 	{
109 		fprintf(mFile,"\tsetAttr \".vc1\" -type \"float3\" ");
110 		vc1.write(mFile);
111 		fprintf(mFile,";\n");
112 	}
setVertexCameraOneX(float c1x)113 	void setVertexCameraOneX(float c1x)
114 	{
115 		if(c1x == 0.0) return;
116 		fprintf(mFile,"\tsetAttr \".vc1.c1x\" %f;\n", c1x);
117 	}
setVertexCameraOneY(float c1y)118 	void setVertexCameraOneY(float c1y)
119 	{
120 		if(c1y == 0.0) return;
121 		fprintf(mFile,"\tsetAttr \".vc1.c1y\" %f;\n", c1y);
122 	}
setVertexCameraOneZ(float c1z)123 	void setVertexCameraOneZ(float c1z)
124 	{
125 		if(c1z == 0.0) return;
126 		fprintf(mFile,"\tsetAttr \".vc1.c1z\" %f;\n", c1z);
127 	}
setOutVertexUvOne(const float2 & ov1)128 	void setOutVertexUvOne(const float2& ov1)
129 	{
130 		fprintf(mFile,"\tsetAttr \".ov1\" -type \"float2\" ");
131 		ov1.write(mFile);
132 		fprintf(mFile,";\n");
133 	}
setOutVertexUvOneU(float o1u)134 	void setOutVertexUvOneU(float o1u)
135 	{
136 		if(o1u == 0.0) return;
137 		fprintf(mFile,"\tsetAttr \".ov1.o1u\" %f;\n", o1u);
138 	}
setOutVertexUvOneV(float o1v)139 	void setOutVertexUvOneV(float o1v)
140 	{
141 		if(o1v == 0.0) return;
142 		fprintf(mFile,"\tsetAttr \".ov1.o1v\" %f;\n", o1v);
143 	}
setOutVertexUvTwo(const float2 & ov2)144 	void setOutVertexUvTwo(const float2& ov2)
145 	{
146 		fprintf(mFile,"\tsetAttr \".ov2\" -type \"float2\" ");
147 		ov2.write(mFile);
148 		fprintf(mFile,";\n");
149 	}
setOutVertexUvTwoU(float o2u)150 	void setOutVertexUvTwoU(float o2u)
151 	{
152 		if(o2u == 0.0) return;
153 		fprintf(mFile,"\tsetAttr \".ov2.o2u\" %f;\n", o2u);
154 	}
setOutVertexUvTwoV(float o2v)155 	void setOutVertexUvTwoV(float o2v)
156 	{
157 		if(o2v == 0.0) return;
158 		fprintf(mFile,"\tsetAttr \".ov2.o2v\" %f;\n", o2v);
159 	}
setOutVertexUvThree(const float2 & ov3)160 	void setOutVertexUvThree(const float2& ov3)
161 	{
162 		fprintf(mFile,"\tsetAttr \".ov3\" -type \"float2\" ");
163 		ov3.write(mFile);
164 		fprintf(mFile,";\n");
165 	}
setOutVertexUvThreeU(float o3u)166 	void setOutVertexUvThreeU(float o3u)
167 	{
168 		if(o3u == 0.0) return;
169 		fprintf(mFile,"\tsetAttr \".ov3.o3u\" %f;\n", o3u);
170 	}
setOutVertexUvThreeV(float o3v)171 	void setOutVertexUvThreeV(float o3v)
172 	{
173 		if(o3v == 0.0) return;
174 		fprintf(mFile,"\tsetAttr \".ov3.o3v\" %f;\n", o3v);
175 	}
setOutVertexCameraOne(const float3 & oc1)176 	void setOutVertexCameraOne(const float3& oc1)
177 	{
178 		fprintf(mFile,"\tsetAttr \".oc1\" -type \"float3\" ");
179 		oc1.write(mFile);
180 		fprintf(mFile,";\n");
181 	}
setOutVertexCameraOneX(float o1x)182 	void setOutVertexCameraOneX(float o1x)
183 	{
184 		if(o1x == 0.0) return;
185 		fprintf(mFile,"\tsetAttr \".oc1.o1x\" %f;\n", o1x);
186 	}
setOutVertexCameraOneY(float o1y)187 	void setOutVertexCameraOneY(float o1y)
188 	{
189 		if(o1y == 0.0) return;
190 		fprintf(mFile,"\tsetAttr \".oc1.o1y\" %f;\n", o1y);
191 	}
setOutVertexCameraOneZ(float o1z)192 	void setOutVertexCameraOneZ(float o1z)
193 	{
194 		if(o1z == 0.0) return;
195 		fprintf(mFile,"\tsetAttr \".oc1.o1z\" %f;\n", o1z);
196 	}
getUvSets(size_t uvs_i)197 	void getUvSets(size_t uvs_i)const
198 	{
199 		fprintf(mFile,"\"%s.uvs[%i]\"",mName.c_str(),uvs_i);
200 	}
getUvSets()201 	void getUvSets()const
202 	{
203 
204 		fprintf(mFile,"\"%s.uvs\"",mName.c_str());
205 	}
getUvCoord()206 	void getUvCoord()const
207 	{
208 		fprintf(mFile,"\"%s.uv\"",mName.c_str());
209 	}
getUCoord()210 	void getUCoord()const
211 	{
212 		fprintf(mFile,"\"%s.uv.u\"",mName.c_str());
213 	}
getVCoord()214 	void getVCoord()const
215 	{
216 		fprintf(mFile,"\"%s.uv.v\"",mName.c_str());
217 	}
getVertexUvOne()218 	void getVertexUvOne()const
219 	{
220 		fprintf(mFile,"\"%s.vt1\"",mName.c_str());
221 	}
getVertexUvOneU()222 	void getVertexUvOneU()const
223 	{
224 		fprintf(mFile,"\"%s.vt1.t1u\"",mName.c_str());
225 	}
getVertexUvOneV()226 	void getVertexUvOneV()const
227 	{
228 		fprintf(mFile,"\"%s.vt1.t1v\"",mName.c_str());
229 	}
getVertexUvTwo()230 	void getVertexUvTwo()const
231 	{
232 		fprintf(mFile,"\"%s.vt2\"",mName.c_str());
233 	}
getVertexUvTwoU()234 	void getVertexUvTwoU()const
235 	{
236 		fprintf(mFile,"\"%s.vt2.t2u\"",mName.c_str());
237 	}
getVertexUvTwoV()238 	void getVertexUvTwoV()const
239 	{
240 		fprintf(mFile,"\"%s.vt2.t2v\"",mName.c_str());
241 	}
getVertexUvThree()242 	void getVertexUvThree()const
243 	{
244 		fprintf(mFile,"\"%s.vt3\"",mName.c_str());
245 	}
getVertexUvThreeU()246 	void getVertexUvThreeU()const
247 	{
248 		fprintf(mFile,"\"%s.vt3.t3u\"",mName.c_str());
249 	}
getVertexUvThreeV()250 	void getVertexUvThreeV()const
251 	{
252 		fprintf(mFile,"\"%s.vt3.t3v\"",mName.c_str());
253 	}
getVertexCameraOne()254 	void getVertexCameraOne()const
255 	{
256 		fprintf(mFile,"\"%s.vc1\"",mName.c_str());
257 	}
getVertexCameraOneX()258 	void getVertexCameraOneX()const
259 	{
260 		fprintf(mFile,"\"%s.vc1.c1x\"",mName.c_str());
261 	}
getVertexCameraOneY()262 	void getVertexCameraOneY()const
263 	{
264 		fprintf(mFile,"\"%s.vc1.c1y\"",mName.c_str());
265 	}
getVertexCameraOneZ()266 	void getVertexCameraOneZ()const
267 	{
268 		fprintf(mFile,"\"%s.vc1.c1z\"",mName.c_str());
269 	}
getInfoBits()270 	void getInfoBits()const
271 	{
272 		fprintf(mFile,"\"%s.ib\"",mName.c_str());
273 	}
getOutUv()274 	void getOutUv()const
275 	{
276 		fprintf(mFile,"\"%s.ouv\"",mName.c_str());
277 	}
getOutU()278 	void getOutU()const
279 	{
280 		fprintf(mFile,"\"%s.ouv.ou\"",mName.c_str());
281 	}
getOutV()282 	void getOutV()const
283 	{
284 		fprintf(mFile,"\"%s.ouv.ov\"",mName.c_str());
285 	}
getOutVertexUvOne()286 	void getOutVertexUvOne()const
287 	{
288 		fprintf(mFile,"\"%s.ov1\"",mName.c_str());
289 	}
getOutVertexUvOneU()290 	void getOutVertexUvOneU()const
291 	{
292 		fprintf(mFile,"\"%s.ov1.o1u\"",mName.c_str());
293 	}
getOutVertexUvOneV()294 	void getOutVertexUvOneV()const
295 	{
296 		fprintf(mFile,"\"%s.ov1.o1v\"",mName.c_str());
297 	}
getOutVertexUvTwo()298 	void getOutVertexUvTwo()const
299 	{
300 		fprintf(mFile,"\"%s.ov2\"",mName.c_str());
301 	}
getOutVertexUvTwoU()302 	void getOutVertexUvTwoU()const
303 	{
304 		fprintf(mFile,"\"%s.ov2.o2u\"",mName.c_str());
305 	}
getOutVertexUvTwoV()306 	void getOutVertexUvTwoV()const
307 	{
308 		fprintf(mFile,"\"%s.ov2.o2v\"",mName.c_str());
309 	}
getOutVertexUvThree()310 	void getOutVertexUvThree()const
311 	{
312 		fprintf(mFile,"\"%s.ov3\"",mName.c_str());
313 	}
getOutVertexUvThreeU()314 	void getOutVertexUvThreeU()const
315 	{
316 		fprintf(mFile,"\"%s.ov3.o3u\"",mName.c_str());
317 	}
getOutVertexUvThreeV()318 	void getOutVertexUvThreeV()const
319 	{
320 		fprintf(mFile,"\"%s.ov3.o3v\"",mName.c_str());
321 	}
getOutVertexCameraOne()322 	void getOutVertexCameraOne()const
323 	{
324 		fprintf(mFile,"\"%s.oc1\"",mName.c_str());
325 	}
getOutVertexCameraOneX()326 	void getOutVertexCameraOneX()const
327 	{
328 		fprintf(mFile,"\"%s.oc1.o1x\"",mName.c_str());
329 	}
getOutVertexCameraOneY()330 	void getOutVertexCameraOneY()const
331 	{
332 		fprintf(mFile,"\"%s.oc1.o1y\"",mName.c_str());
333 	}
getOutVertexCameraOneZ()334 	void getOutVertexCameraOneZ()const
335 	{
336 		fprintf(mFile,"\"%s.oc1.o1z\"",mName.c_str());
337 	}
338 protected:
339 	UvChooser(FILE* file,const std::string& name,const std::string& parent,const std::string& nodeType,bool shared=false,bool create=true)
DependNode(file,name,parent,nodeType,shared,create)340 		:DependNode(file, name, parent, nodeType, shared, create) {}
341 
342 };
343 }//namespace MayaDM
344 #endif//__MayaDM_UVCHOOSER_H__
345