absence_thelab

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/3deng/motion.cpp	Thu Oct 23 01:46:07 2014 +0300
     1.3 @@ -0,0 +1,50 @@
     1.4 +#include "motion.h"
     1.5 +
     1.6 +MotionController::MotionController() {
     1.7 +	memset(this, 0, sizeof(MotionController));
     1.8 +}
     1.9 +
    1.10 +void MotionController::SetTranslation(float (*xtrans)(float), float (*ytrans)(float), float (*ztrans)(float), float ScaleInput) {
    1.11 +	XTranslation = xtrans;
    1.12 +	YTranslation = ytrans;
    1.13 +	ZTranslation = ytrans;
    1.14 +	ScaleInputTrans = ScaleInput;
    1.15 +}
    1.16 +
    1.17 +void MotionController::SetRotation(float (*xrot)(float), float (*yrot)(float), float (*zrot)(float), float ScaleInput) {
    1.18 +	XRotation = xrot;
    1.19 +	YRotation = yrot;
    1.20 +	ZRotation = zrot;
    1.21 +	ScaleInputRot = ScaleInput;
    1.22 +}
    1.23 +
    1.24 +void MotionController::SetScaling(float (*xscale)(float), float (*yscale)(float), float (*zscale)(float), float ScaleInput) {
    1.25 +	XScaling = xscale;
    1.26 +	YScaling = yscale;
    1.27 +	ZScaling = zscale;
    1.28 +	ScaleInputScale = ScaleInput;
    1.29 +}
    1.30 +
    1.31 +void MotionController::SetPath(const Curve &path) {
    1.32 +	FollowPath = true;
    1.33 +	// TODO
    1.34 +}
    1.35 +
    1.36 +const Matrix4x4 &MotionController::GetTransformation(float t) {
    1.37 +	MotionXForm.ResetIdentity();
    1.38 +
    1.39 +	if(FollowPath) {
    1.40 +		// TODO
    1.41 +	} else {
    1.42 +		float tt = t * ScaleInputTrans;
    1.43 +		float tr = t * ScaleInputRot;
    1.44 +		float ts = t * ScaleInputScale;
    1.45 +        MotionXForm.Scale(XScaling ? XScaling(tt) : 0, YScaling ? YScaling(tt) : 0, ZScaling ? ZScaling(tt) : 0);
    1.46 +		MotionXForm.Rotate(XRotation ? XRotation(tr) : 0, YRotation ? YRotation(tr) : 0, ZRotation ? ZRotation(tr) : 0);
    1.47 +		MotionXForm.Translate(XTranslation ? XTranslation(ts) : 0, YTranslation ? YTranslation(ts) : 0, ZTranslation ? ZTranslation(ts) : 0);
    1.48 +	}
    1.49 +
    1.50 +	return MotionXForm;
    1.51 +}
    1.52 +
    1.53 +