54 |
void tr(const ZPt &from, ZPt &to) const { |
void tr(const ZPt &from, ZPt &to) const { |
55 |
to = from + vec; |
to = from + vec; |
56 |
} |
} |
57 |
void performGL() { |
void performGL() const { |
58 |
glTranslatef(vec.x, vec.y, vec.z); |
glTranslatef(vec.x, vec.y, vec.z); |
59 |
} |
} |
60 |
typedef TranslateXYZ InverseType; |
typedef TranslateXYZ InverseType; |
79 |
void tr(const ZPt &from, ZPt &to) const { |
void tr(const ZPt &from, ZPt &to) const { |
80 |
to = from * vec; |
to = from * vec; |
81 |
} |
} |
82 |
void performGL() { |
void performGL() const { |
83 |
glScalef(vec.x, vec.y, vec.z); |
glScalef(vec.x, vec.y, vec.z); |
84 |
} |
} |
85 |
typedef ScaleXYZ InverseType; |
typedef ScaleXYZ InverseType; |
171 |
void tr(const ZPt &from, ZPt &to) const { |
void tr(const ZPt &from, ZPt &to) const { |
172 |
to = from; |
to = from; |
173 |
} |
} |
174 |
void performGL() { |
void performGL() const { |
175 |
} |
} |
176 |
typedef Unit InverseType; |
typedef Unit InverseType; |
177 |
void inverse(InverseType &into) const { } |
void inverse(InverseType &into) const { } |
195 |
void tr(const ZPt &from, ZPt &to) const { |
void tr(const ZPt &from, ZPt &to) const { |
196 |
to = from; |
to = from; |
197 |
} |
} |
198 |
void performGL() { |
void performGL() const { |
199 |
} |
} |
200 |
Pt getSqSize() const { return box; } |
Pt getSqSize() const { return box; } |
201 |
|
|
218 |
}; |
}; |
219 |
VOB_PRIMITIVETRANS_DEFINED(Box_Explicit, "box"); |
VOB_PRIMITIVETRANS_DEFINED(Box_Explicit, "box"); |
220 |
|
|
221 |
|
struct RotateXYZ: |
222 |
|
public PrimitiveTransform, |
223 |
|
public GLPerformablePrimitiveTransform |
224 |
|
{ |
225 |
|
public: |
226 |
|
ZVec vec; |
227 |
|
/** Angle, degs. |
228 |
|
*/ |
229 |
|
float a; |
230 |
|
/** Sine and cosine of angle. |
231 |
|
*/ |
232 |
|
float s, c; |
233 |
|
|
234 |
|
void angleWasSet() { |
235 |
|
s = sin(a * M_PI / 180); |
236 |
|
c = cos(a * M_PI / 180); |
237 |
|
} |
238 |
|
|
239 |
|
void tr(const ZPt &from, ZPt &to) const { |
240 |
|
ZVec v(from); |
241 |
|
float same = v.dot(vec); |
242 |
|
ZVec para = v - same*vec; |
243 |
|
float paral = para.length(); |
244 |
|
para = (1/paral)*para; |
245 |
|
ZVec ortho = para.crossp(vec).normalized(); |
246 |
|
to = ZPt( same * vec + paral * (c * para - s * ortho) ); |
247 |
|
} |
248 |
|
virtual void performGL() const { |
249 |
|
glRotatef(a, vec.x, vec.y, vec.z); |
250 |
|
} |
251 |
|
typedef RotateXYZ InverseType; |
252 |
|
void inverse(InverseType &inv) const { |
253 |
|
inv.vec = vec; |
254 |
|
inv.a = -a; |
255 |
|
inv.angleWasSet(); |
256 |
|
} |
257 |
|
}; |
258 |
|
|
259 |
|
struct RotateXYZ_Explicit : |
260 |
|
public RotateXYZ, |
261 |
|
public ParametrizedPrimitiveTransform |
262 |
|
{ |
263 |
|
enum { NParams = 4 }; |
264 |
|
template<class Ptr> void setParams(Ptr p) { |
265 |
|
vec.x = p[0]; |
266 |
|
vec.y = p[1]; |
267 |
|
vec.z = p[2]; |
268 |
|
vec = vec.normalized(); |
269 |
|
a = p[3]; |
270 |
|
|
271 |
|
angleWasSet(); |
272 |
|
} |
273 |
|
}; |
274 |
|
VOB_PRIMITIVETRANS_DEFINED(RotateXYZ_Explicit, "rotateXYZ"); |
275 |
|
|
276 |
/** Affine coordinate system (in xy), offset in z. |
/** Affine coordinate system (in xy), offset in z. |
277 |
* Can't be used in HierarchicalTransform directly |
* Can't be used in HierarchicalTransform directly |
278 |
* because parameters are required. |
* because parameters are required. |
294 |
to.y += ydot.dot(from); |
to.y += ydot.dot(from); |
295 |
to.z += from.z; |
to.z += from.z; |
296 |
} |
} |
297 |
void performGL() { |
void performGL() const { |
298 |
GLfloat matrix[16] = { |
GLfloat matrix[16] = { |
299 |
xdot.x, ydot.x, 0, 0, |
xdot.x, ydot.x, 0, 0, |
300 |
xdot.y, ydot.y, 0, 0, |
xdot.y, ydot.y, 0, 0, |
362 |
to.y = y + from.y * sy; |
to.y = y + from.y * sy; |
363 |
to.z = z + from.z; |
to.z = z + from.z; |
364 |
} |
} |
365 |
void performGL() { |
void performGL() const { |
366 |
glTranslatef(x, y, z); |
glTranslatef(x, y, z); |
367 |
glScalef(sx, sy, 1); |
glScalef(sx, sy, 1); |
368 |
} |
} |
441 |
|
|
442 |
VOB_PRIMITIVETRANS_DEFINED(UnitSqBox, "unitSqBox"); |
VOB_PRIMITIVETRANS_DEFINED(UnitSqBox, "unitSqBox"); |
443 |
|
|
444 |
|
|
445 |
} |
} |
446 |
} |
} |
447 |
|
|