Rev 1812 |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.bauzoid2.graphics.animation;
import com.gebauz.bauzoid2.graphics.model.ModelNode;
import com.gebauz.bauzoid2.math.Quaternion;
/**
* Created by cchiu on 20.01.2015.
*/
public class Animation
{
// Constants========================================================================================
// Embedded Types===================================================================================
// Fields===========================================================================================
private String mName =
null;
private BoneKeyframes
[] mBoneKeys =
null;
private float mCurrentTime = 0.0f
;
private float mTotalTime = 0.0f
;
// Methods==========================================================================================
public Animation
(String id
)
{
mName = id
;
}
public void applyAnimation
()
{
float t =
(mCurrentTime
% mTotalTime
);
//float t = mCurrentTime;
for (BoneKeyframes boneKeys : mBoneKeys
)
{
Quaternion q = boneKeys.
calcRotationAt(t
);
ModelNode bone = boneKeys.
getBone();
bone.
transform.
setFrom(bone.
bindPose);
if (q
!=
null)
//bone.getLocalTransform().preMultiply(q.toMatrix());
bone.
transform.
rotation.
set(q.
x, q.
y, q.
z, q.
w);
}
}
// Getters/Setters==================================================================================
public final void setBoneKeys
(BoneKeyframes
[] keys
) { mBoneKeys = keys
; }
public final BoneKeyframes
[] getBoneKeys
() { return mBoneKeys
; }
public final void setTotalTime
(float t
) { mTotalTime = t
; }
public final float getTotalTime
() { return mTotalTime
; }
public final void setCurrentTime
(float t
) { mCurrentTime = t
; }
public final float getCurrentTime
() { return mCurrentTime
; }
}