From 5b67ea1f64bc0c6d427bd06acb45163895ab7f1d Mon Sep 17 00:00:00 2001 From: devZoGok Date: Mon, 15 Mar 2021 12:42:39 +0200 Subject: [PATCH] texture animation --- keyframeChannel.h | 4 ++-- texture.cpp | 20 ++++++++------------ texture.h | 4 +--- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/keyframeChannel.h b/keyframeChannel.h index 71274be..0874f86 100644 --- a/keyframeChannel.h +++ b/keyframeChannel.h @@ -30,8 +30,8 @@ namespace vb01{ SPECULAR_COLOR_X, SPECULAR_COLOR_Y, SPECULAR_COLOR_Z, - SPOTLIGHT_INNER_ANGLE, - SPOTLIGHT_OUTER_ANGLE. + TEXTURE_FRAME_A, + TEXTURE_FRAME_B, TEXTURE_MIX_RATIO }; struct Keyframe{ diff --git a/texture.cpp b/texture.cpp index 298b40a..c542fb6 100755 --- a/texture.cpp +++ b/texture.cpp @@ -153,23 +153,19 @@ namespace vb01{ case KeyframeChannel::TEXTURE_MIX_RATIO: mixRatio = value; break; + case KeyframeChannel::TEXTURE_FRAME_A: + frameA = (int)value; + break; + case KeyframeChannel::TEXTURE_FRAME_B: + frameB = (int)value; + break; } } void Texture::update(int id){ - //updateFrame(); - select(id); + select(id, frameA); if(numFrames > 0) - select(id + 1, 1); - } - - void Texture::updateFrame(){ - if(numFrames > 0){ - if(getTime() - lastUpdateTime > updateRate){ - frame = getNextFrame(frame); - lastUpdateTime = getTime(); - } - } + select(id + 1, frameB); } void Texture::select(int id, int fr){ diff --git a/texture.h b/texture.h index a6469a2..7443505 100755 --- a/texture.h +++ b/texture.h @@ -31,15 +31,13 @@ namespace vb01{ TextureType type = TextureType::TEXTURE_2D; TextureTypeId typeId = DIFFUSE; u32 *texture = nullptr; - s32 updateRate = 0, numFrames = 0,frame = 0; s64 lastUpdateTime = 0; - int width, height, numChannels; + int width, height, numChannels, updateRate = 0, numFrames = 0, frameA = 0, frameB = 0; float mixRatio; u8 *data; std::string path = "", paths[6]; void createCubemap(bool, bool); - void updateFrame(); inline int getNextFrame(int frameId){return (frameId + 1 < numFrames ? frameId + 1 : 0);} }; }