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_PRIMITIVE_H__
11 #define __MayaDM_PRIMITIVE_H__
12 #include "MayaDMTypes.h"
13 #include "MayaDMConnectables.h"
14 #include "MayaDMAbstractBaseCreate.h"
15 namespace MayaDM
16 {
17 class Primitive : public AbstractBaseCreate
18 {
19 public:
20 public:
21 
Primitive()22 	Primitive():AbstractBaseCreate(){}
23 	Primitive(FILE* file,const std::string& name,const std::string& parent="",bool shared=false,bool create=true)
24 		:AbstractBaseCreate(file, name, parent, "primitive", shared, create){}
~Primitive()25 	virtual ~Primitive(){}
26 
setPivot(const double3 & p)27 	void setPivot(const double3& p)
28 	{
29 		fprintf(mFile,"\tsetAttr \".p\" -type \"double3\" ");
30 		p.write(mFile);
31 		fprintf(mFile,";\n");
32 	}
setPivotX(double px)33 	void setPivotX(double px)
34 	{
35 		if(px == 0) return;
36 		fprintf(mFile,"\tsetAttr \".p.px\" %f;\n", px);
37 	}
setPivotY(double py)38 	void setPivotY(double py)
39 	{
40 		if(py == 0) return;
41 		fprintf(mFile,"\tsetAttr \".p.py\" %f;\n", py);
42 	}
setPivotZ(double pz)43 	void setPivotZ(double pz)
44 	{
45 		if(pz == 0) return;
46 		fprintf(mFile,"\tsetAttr \".p.pz\" %f;\n", pz);
47 	}
setAxis(const double3 & ax)48 	void setAxis(const double3& ax)
49 	{
50 		fprintf(mFile,"\tsetAttr \".ax\" -type \"double3\" ");
51 		ax.write(mFile);
52 		fprintf(mFile,";\n");
53 	}
setAxisX(double axx)54 	void setAxisX(double axx)
55 	{
56 		if(axx == 1) return;
57 		fprintf(mFile,"\tsetAttr \".ax.axx\" %f;\n", axx);
58 	}
setAxisY(double axy)59 	void setAxisY(double axy)
60 	{
61 		if(axy == 0) return;
62 		fprintf(mFile,"\tsetAttr \".ax.axy\" %f;\n", axy);
63 	}
setAxisZ(double axz)64 	void setAxisZ(double axz)
65 	{
66 		if(axz == 0) return;
67 		fprintf(mFile,"\tsetAttr \".ax.axz\" %f;\n", axz);
68 	}
getPivot()69 	void getPivot()const
70 	{
71 		fprintf(mFile,"\"%s.p\"",mName.c_str());
72 	}
getPivotX()73 	void getPivotX()const
74 	{
75 		fprintf(mFile,"\"%s.p.px\"",mName.c_str());
76 	}
getPivotY()77 	void getPivotY()const
78 	{
79 		fprintf(mFile,"\"%s.p.py\"",mName.c_str());
80 	}
getPivotZ()81 	void getPivotZ()const
82 	{
83 		fprintf(mFile,"\"%s.p.pz\"",mName.c_str());
84 	}
getAxis()85 	void getAxis()const
86 	{
87 		fprintf(mFile,"\"%s.ax\"",mName.c_str());
88 	}
getAxisX()89 	void getAxisX()const
90 	{
91 		fprintf(mFile,"\"%s.ax.axx\"",mName.c_str());
92 	}
getAxisY()93 	void getAxisY()const
94 	{
95 		fprintf(mFile,"\"%s.ax.axy\"",mName.c_str());
96 	}
getAxisZ()97 	void getAxisZ()const
98 	{
99 		fprintf(mFile,"\"%s.ax.axz\"",mName.c_str());
100 	}
getOutputSurface()101 	void getOutputSurface()const
102 	{
103 		fprintf(mFile,"\"%s.os\"",mName.c_str());
104 	}
105 protected:
106 	Primitive(FILE* file,const std::string& name,const std::string& parent,const std::string& nodeType,bool shared=false,bool create=true)
AbstractBaseCreate(file,name,parent,nodeType,shared,create)107 		:AbstractBaseCreate(file, name, parent, nodeType, shared, create) {}
108 
109 };
110 }//namespace MayaDM
111 #endif//__MayaDM_PRIMITIVE_H__
112