absence_thelab

view src/3deng/motion.cpp @ 0:1cffe3409164

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 01:46:07 +0300
parents
children
line source
1 #include "motion.h"
3 MotionController::MotionController() {
4 memset(this, 0, sizeof(MotionController));
5 }
7 void MotionController::SetTranslation(float (*xtrans)(float), float (*ytrans)(float), float (*ztrans)(float), float ScaleInput) {
8 XTranslation = xtrans;
9 YTranslation = ytrans;
10 ZTranslation = ytrans;
11 ScaleInputTrans = ScaleInput;
12 }
14 void MotionController::SetRotation(float (*xrot)(float), float (*yrot)(float), float (*zrot)(float), float ScaleInput) {
15 XRotation = xrot;
16 YRotation = yrot;
17 ZRotation = zrot;
18 ScaleInputRot = ScaleInput;
19 }
21 void MotionController::SetScaling(float (*xscale)(float), float (*yscale)(float), float (*zscale)(float), float ScaleInput) {
22 XScaling = xscale;
23 YScaling = yscale;
24 ZScaling = zscale;
25 ScaleInputScale = ScaleInput;
26 }
28 void MotionController::SetPath(const Curve &path) {
29 FollowPath = true;
30 // TODO
31 }
33 const Matrix4x4 &MotionController::GetTransformation(float t) {
34 MotionXForm.ResetIdentity();
36 if(FollowPath) {
37 // TODO
38 } else {
39 float tt = t * ScaleInputTrans;
40 float tr = t * ScaleInputRot;
41 float ts = t * ScaleInputScale;
42 MotionXForm.Scale(XScaling ? XScaling(tt) : 0, YScaling ? YScaling(tt) : 0, ZScaling ? ZScaling(tt) : 0);
43 MotionXForm.Rotate(XRotation ? XRotation(tr) : 0, YRotation ? YRotation(tr) : 0, ZRotation ? ZRotation(tr) : 0);
44 MotionXForm.Translate(XTranslation ? XTranslation(ts) : 0, YTranslation ? YTranslation(ts) : 0, ZTranslation ? ZTranslation(ts) : 0);
45 }
47 return MotionXForm;
48 }