texture animation

This commit is contained in:
devZoGok
2021-10-19 19:06:41 +03:00
parent d2fce970d6
commit 8d89bdc140
3 changed files with 11 additions and 14 deletions
+2
View File
@@ -30,6 +30,8 @@ namespace vb01{
SPECULAR_COLOR_X,
SPECULAR_COLOR_Y,
SPECULAR_COLOR_Z,
TEXTURE_FRAME_A,
TEXTURE_FRAME_B,
TEXTURE_MIX_RATIO
};
struct Keyframe{
+8 -12
View File
@@ -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){
+1 -2
View File
@@ -32,13 +32,12 @@ namespace vb01{
TextureTypeId typeId = DIFFUSE;
u32 *texture = nullptr;
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);}
};
}