absence_thelab

annotate src/3deng/motion.cpp @ 1:4d5933c261c3

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