summaryrefslogtreecommitdiffstats
path: root/o3d/core/cross/param_operation.h
blob: f026421ce6334c0c3f1625c0eb79199a59c790e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
/*
 * Copyright 2009, Google Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */


// This file contains the declaration of various Parameter Operations.

#ifndef O3D_CORE_CROSS_PARAM_OPERATION_H_
#define O3D_CORE_CROSS_PARAM_OPERATION_H_

#include "core/cross/param_object.h"

namespace o3d {

// A Param operation that takes 2 floats to produce a Float2.
class ParamOp2FloatsToFloat2 : public ParamObject {
 public:
  static const char* kInput0ParamName;
  static const char* kInput1ParamName;
  static const char* kOutputParamName;

  float input_0() const {
    return input_0_param_->value();
  }

  void set_input_0(float value) {
    input_0_param_->set_value(value);
  }

  float input_1() const {
    return input_1_param_->value();
  }

  void set_input_1(float value) {
    input_1_param_->set_value(value);
  }

  Float2 output() const {
    return output_param_->value();
  }

  // Updates the output param.
  void UpdateOutputs();

 private:
  typedef SlaveParam<ParamFloat2, ParamOp2FloatsToFloat2> SlaveParamFloat2;

  explicit ParamOp2FloatsToFloat2(ServiceLocator* service_locator);

  friend class IClassManager;
  static ObjectBase::Ref Create(ServiceLocator* service_locator);

  ParamFloat::Ref input_0_param_;
  ParamFloat::Ref input_1_param_;
  SlaveParamFloat2::Ref output_param_;

  O3D_DECL_CLASS(ParamOp2FloatsToFloat2, ParamObject);
  DISALLOW_COPY_AND_ASSIGN(ParamOp2FloatsToFloat2);
};

// A Param operation that takes 3 floats to produce a Float3.
class ParamOp3FloatsToFloat3 : public ParamObject {
 public:
  static const char* kInput0ParamName;
  static const char* kInput1ParamName;
  static const char* kInput2ParamName;
  static const char* kOutputParamName;

  float input_0() const {
    return input_0_param_->value();
  }

  void set_input_0(float value) {
    input_0_param_->set_value(value);
  }

  float input_1() const {
    return input_1_param_->value();
  }

  void set_input_1(float value) {
    input_1_param_->set_value(value);
  }

  float input_2() const {
    return input_2_param_->value();
  }

  void set_input_2(float value) {
    input_2_param_->set_value(value);
  }

  Float3 output() const {
    return output_param_->value();
  }

  // Updates the output param.
  void UpdateOutputs();

 private:
  typedef SlaveParam<ParamFloat3, ParamOp3FloatsToFloat3> SlaveParamFloat3;

  explicit ParamOp3FloatsToFloat3(ServiceLocator* service_locator);

  friend class IClassManager;
  static ObjectBase::Ref Create(ServiceLocator* service_locator);

  ParamFloat::Ref input_0_param_;
  ParamFloat::Ref input_1_param_;
  ParamFloat::Ref input_2_param_;
  SlaveParamFloat3::Ref output_param_;

  O3D_DECL_CLASS(ParamOp3FloatsToFloat3, ParamObject);
  DISALLOW_COPY_AND_ASSIGN(ParamOp3FloatsToFloat3);
};

// A Param operation that takes 4 floats to produce a Float4.
class ParamOp4FloatsToFloat4 : public ParamObject {
 public:
  static const char* kInput0ParamName;
  static const char* kInput1ParamName;
  static const char* kInput2ParamName;
  static const char* kInput3ParamName;
  static const char* kOutputParamName;

  float input_0() const {
    return input_0_param_->value();
  }

  void set_input_0(float value) {
    input_0_param_->set_value(value);
  }

  float input_1() const {
    return input_1_param_->value();
  }

  void set_input_1(float value) {
    input_1_param_->set_value(value);
  }

  float input_2() const {
    return input_2_param_->value();
  }

  void set_input_2(float value) {
    input_2_param_->set_value(value);
  }

  float input_3() const {
    return input_3_param_->value();
  }

  void set_input_3(float value) {
    input_3_param_->set_value(value);
  }

  Float4 output() const {
    return output_param_->value();
  }

  // Updates the output param.
  void UpdateOutputs();

 private:
  typedef SlaveParam<ParamFloat4, ParamOp4FloatsToFloat4> SlaveParamFloat4;

  explicit ParamOp4FloatsToFloat4(ServiceLocator* service_locator);

  friend class IClassManager;
  static ObjectBase::Ref Create(ServiceLocator* service_locator);

  ParamFloat::Ref input_0_param_;
  ParamFloat::Ref input_1_param_;
  ParamFloat::Ref input_2_param_;
  ParamFloat::Ref input_3_param_;
  SlaveParamFloat4::Ref output_param_;

  O3D_DECL_CLASS(ParamOp4FloatsToFloat4, ParamObject);
  DISALLOW_COPY_AND_ASSIGN(ParamOp4FloatsToFloat4);
};

// A Param operation that takes 16 floats to produce a Matrix4.
class ParamOp16FloatsToMatrix4 : public ParamObject {
 public:
  static const char* kInput0ParamName;
  static const char* kInput1ParamName;
  static const char* kInput2ParamName;
  static const char* kInput3ParamName;
  static const char* kInput4ParamName;
  static const char* kInput5ParamName;
  static const char* kInput6ParamName;
  static const char* kInput7ParamName;
  static const char* kInput8ParamName;
  static const char* kInput9ParamName;
  static const char* kInput10ParamName;
  static const char* kInput11ParamName;
  static const char* kInput12ParamName;
  static const char* kInput13ParamName;
  static const char* kInput14ParamName;
  static const char* kInput15ParamName;
  static const char* kOutputParamName;

  float input_0() const {
    return input_0_param_->value();
  }

  void set_input_0(float value) {
    input_0_param_->set_value(value);
  }

  float input_1() const {
    return input_1_param_->value();
  }

  void set_input_1(float value) {
    input_1_param_->set_value(value);
  }

  float input_2() const {
    return input_2_param_->value();
  }

  void set_input_2(float value) {
    input_2_param_->set_value(value);
  }

  float input_3() const {
    return input_3_param_->value();
  }

  void set_input_3(float value) {
    input_3_param_->set_value(value);
  }

  float input_4() const {
    return input_4_param_->value();
  }

  void set_input_4(float value) {
    input_4_param_->set_value(value);
  }

  float input_5() const {
    return input_5_param_->value();
  }

  void set_input_5(float value) {
    input_5_param_->set_value(value);
  }

  float input_6() const {
    return input_6_param_->value();
  }

  void set_input_6(float value) {
    input_6_param_->set_value(value);
  }

  float input_7() const {
    return input_7_param_->value();
  }

  void set_input_7(float value) {
    input_7_param_->set_value(value);
  }

  float input_8() const {
    return input_8_param_->value();
  }

  void set_input_8(float value) {
    input_8_param_->set_value(value);
  }

  float input_9() const {
    return input_9_param_->value();
  }

  void set_input_9(float value) {
    input_9_param_->set_value(value);
  }

  float input_10() const {
    return input_10_param_->value();
  }

  void set_input_10(float value) {
    input_10_param_->set_value(value);
  }

  float input_11() const {
    return input_11_param_->value();
  }

  void set_input_11(float value) {
    input_11_param_->set_value(value);
  }

  float input_12() const {
    return input_12_param_->value();
  }

  void set_input_12(float value) {
    input_12_param_->set_value(value);
  }

  float input_13() const {
    return input_13_param_->value();
  }

  void set_input_13(float value) {
    input_13_param_->set_value(value);
  }

  float input_14() const {
    return input_14_param_->value();
  }

  void set_input_14(float value) {
    input_14_param_->set_value(value);
  }

  float input_15() const {
    return input_15_param_->value();
  }

  void set_input_15(float value) {
    input_15_param_->set_value(value);
  }

  Matrix4 output() const {
    return output_param_->value();
  }

  // Updates the output param.
  void UpdateOutputs();

 private:
  typedef SlaveParam<ParamMatrix4, ParamOp16FloatsToMatrix4> SlaveParamMatrix4;

  explicit ParamOp16FloatsToMatrix4(ServiceLocator* service_locator);

  friend class IClassManager;
  static ObjectBase::Ref Create(ServiceLocator* service_locator);

  ParamFloat::Ref input_0_param_;
  ParamFloat::Ref input_1_param_;
  ParamFloat::Ref input_2_param_;
  ParamFloat::Ref input_3_param_;
  ParamFloat::Ref input_4_param_;
  ParamFloat::Ref input_5_param_;
  ParamFloat::Ref input_6_param_;
  ParamFloat::Ref input_7_param_;
  ParamFloat::Ref input_8_param_;
  ParamFloat::Ref input_9_param_;
  ParamFloat::Ref input_10_param_;
  ParamFloat::Ref input_11_param_;
  ParamFloat::Ref input_12_param_;
  ParamFloat::Ref input_13_param_;
  ParamFloat::Ref input_14_param_;
  ParamFloat::Ref input_15_param_;
  SlaveParamMatrix4::Ref output_param_;

  O3D_DECL_CLASS(ParamOp16FloatsToMatrix4, ParamObject);
  DISALLOW_COPY_AND_ASSIGN(ParamOp16FloatsToMatrix4);
};

// A Param operation that takes 9 floats to produce a Matrix4.
// It is effectively this:
//
//  output = Matrix4::translation(translateX, translateY, translateZ) *
//           Matrix4::rotationXYZ(rotateX, rotateY, rotateZ) *
//           Matrix4::scale(scaleX, scaleY, scaleZ);
class TRSToMatrix4 : public ParamObject {
 public:
  static const char* kTranslateXParamName;
  static const char* kTranslateYParamName;
  static const char* kTranslateZParamName;
  static const char* kRotateXParamName;
  static const char* kRotateYParamName;
  static const char* kRotateZParamName;
  static const char* kScaleXParamName;
  static const char* kScaleYParamName;
  static const char* kScaleZParamName;
  static const char* kOutputParamName;

  float translate_x() const {
    return translate_x_param_->value();
  }

  void set_translate_x(float value) {
    translate_x_param_->set_value(value);
  }

  float translate_y() const {
    return translate_y_param_->value();
  }

  void set_translate_y(float value) {
    translate_y_param_->set_value(value);
  }

  float translate_z() const {
    return translate_z_param_->value();
  }

  void set_translate_z(float value) {
    translate_z_param_->set_value(value);
  }

  float rotate_x() const {
    return rotate_x_param_->value();
  }

  void set_rotate_x(float value) {
    rotate_x_param_->set_value(value);
  }

  float rotate_y() const {
    return rotate_y_param_->value();
  }

  void set_rotate_y(float value) {
    rotate_y_param_->set_value(value);
  }

  float rotate_z() const {
    return rotate_z_param_->value();
  }

  void set_rotate_z(float value) {
    rotate_z_param_->set_value(value);
  }

  float scale_x() const {
    return scale_x_param_->value();
  }

  void set_scale_x(float value) {
    scale_x_param_->set_value(value);
  }

  float scale_y() const {
    return scale_y_param_->value();
  }

  void set_scale_y(float value) {
    scale_y_param_->set_value(value);
  }

  float scale_z() const {
    return scale_z_param_->value();
  }

  void set_scale_z(float value) {
    scale_z_param_->set_value(value);
  }

  Matrix4 output() const {
    return output_param_->value();
  }

  // Updates the output param.
  void UpdateOutputs();

 private:
  typedef SlaveParam<ParamMatrix4, TRSToMatrix4> SlaveParamMatrix4;

  explicit TRSToMatrix4(ServiceLocator* service_locator);

  friend class IClassManager;
  static ObjectBase::Ref Create(ServiceLocator* service_locator);

  ParamFloat::Ref translate_x_param_;
  ParamFloat::Ref translate_y_param_;
  ParamFloat::Ref translate_z_param_;
  ParamFloat::Ref rotate_x_param_;
  ParamFloat::Ref rotate_y_param_;
  ParamFloat::Ref rotate_z_param_;
  ParamFloat::Ref scale_x_param_;
  ParamFloat::Ref scale_y_param_;
  ParamFloat::Ref scale_z_param_;
  SlaveParamMatrix4::Ref output_param_;

  O3D_DECL_CLASS(TRSToMatrix4, ParamObject);
  DISALLOW_COPY_AND_ASSIGN(TRSToMatrix4);
};

}  // namespace o3d

#endif  // O3D_CORE_CROSS_PARAM_OPERATION_H_