88 |
} |
} |
89 |
}; |
}; |
90 |
|
|
|
|
|
91 |
/** Expose the vec in TranslateXYZ and ScaleXYZ and possibly |
/** Expose the vec in TranslateXYZ and ScaleXYZ and possibly |
92 |
* others explicitly. |
* others explicitly. |
93 |
*/ |
*/ |
109 |
VOB_PRIMITIVETRANS_DEFINED(TranslateXYZ_Explicit, "translate"); |
VOB_PRIMITIVETRANS_DEFINED(TranslateXYZ_Explicit, "translate"); |
110 |
VOB_PRIMITIVETRANS_DEFINED(ScaleXYZ_Explicit, "scale"); |
VOB_PRIMITIVETRANS_DEFINED(ScaleXYZ_Explicit, "scale"); |
111 |
|
|
112 |
|
|
113 |
|
/** Rotation clockwise. |
114 |
|
*/ |
115 |
|
class RotateXY : |
116 |
|
public PrimitiveTransform, |
117 |
|
public GLPerformablePrimitiveTransform |
118 |
|
{ |
119 |
|
protected: |
120 |
|
float a; |
121 |
|
void angleWasSet() { |
122 |
|
s = sin(a * M_PI / 180); |
123 |
|
c = cos(a * M_PI / 180); |
124 |
|
} |
125 |
|
private: |
126 |
|
float s, c; |
127 |
|
public: |
128 |
|
RotateXY() { } |
129 |
|
RotateXY(float angle) { |
130 |
|
a = angle; |
131 |
|
angleWasSet(); |
132 |
|
} |
133 |
|
/** Perform the internal transformation of this |
134 |
|
* coordsys. |
135 |
|
*/ |
136 |
|
void tr(const ZPt &from, ZPt &to) const { |
137 |
|
to.x = c * from.x + -s * from.y; |
138 |
|
to.y = s * from.x + c * from.y; |
139 |
|
to.z = from.z; |
140 |
|
} |
141 |
|
void performGL() const { |
142 |
|
glRotatef(a, 0, 0, 1); |
143 |
|
} |
144 |
|
typedef RotateXY InverseType; |
145 |
|
void inverse(RotateXY &into) const { |
146 |
|
into.a = -a; |
147 |
|
into.angleWasSet(); |
148 |
|
} |
149 |
|
}; |
150 |
|
|
151 |
|
struct RotateXY_Explicit : |
152 |
|
public RotateXY, |
153 |
|
public ParametrizedPrimitiveTransform { |
154 |
|
|
155 |
|
enum {NParams = 1 }; |
156 |
|
|
157 |
|
template<class Ptr> void setParams(Ptr p) { |
158 |
|
a = p[0]; |
159 |
|
angleWasSet(); |
160 |
|
} |
161 |
|
}; |
162 |
|
VOB_PRIMITIVETRANS_DEFINED(RotateXY_Explicit, "rotate"); |
163 |
|
|
164 |
/** A no-op: same coords in and out. |
/** A no-op: same coords in and out. |
165 |
*/ |
*/ |
166 |
class Unit : |
class Unit : |
349 |
public DependentPrimitiveTransform |
public DependentPrimitiveTransform |
350 |
{ |
{ |
351 |
enum { NDepends = 1 }; // just parent |
enum { NDepends = 1 }; // just parent |
352 |
template<class SPtr> void setParams(const Transform *super, SPtr depends) { |
template<class SPtr> void setParams(SPtr depends) { |
353 |
Pt p = super->getSqSize(); |
Pt p = depends[0]->getSqSize(); |
354 |
vec.x = p.x; |
vec.x = p.x; |
355 |
vec.y = p.y; |
vec.y = p.y; |
356 |
vec.z = 1; |
vec.z = 1; |