| 4142 | } |
| 4143 | |
| 4144 | void Renderer::SetupAnimatedTextures(const RendererBucket& bucket) |
| 4145 | { |
| 4146 | const auto& set = _animatedTextureSets[bucket.Texture]; |
| 4147 | |
| 4148 | _stAnimated.Animated = 1; |
| 4149 | _stAnimated.IsWaterfall = 0; |
| 4150 | _stAnimated.Type = (int)set.Type; |
| 4151 | |
| 4152 | // Stream video texture, if video playback is active, otherwise show original texture. |
| 4153 | if (set.Type == AnimatedTextureType::Video && _videoSprite.Texture && _videoSprite.Texture->Texture) |
| 4154 | { |
| 4155 | _stAnimated.Fps = 1; |
| 4156 | _stAnimated.NumFrames = 1; |
| 4157 | |
| 4158 | // Use normalized UVs, because we are showing the whole video texture on a single face. |
| 4159 | _stAnimated.Textures[0].TopLeft = set.Textures[0].NormalizedUV[0]; |
| 4160 | _stAnimated.Textures[0].TopRight = set.Textures[0].NormalizedUV[1]; |
| 4161 | _stAnimated.Textures[0].BottomRight = set.Textures[0].NormalizedUV[2]; |
| 4162 | _stAnimated.Textures[0].BottomLeft = set.Textures[0].NormalizedUV[3]; |
| 4163 | } |
| 4164 | else if (set.Type == AnimatedTextureType::UVRotate) |
| 4165 | { |
| 4166 | _stAnimated.Fps = set.Fps; |
| 4167 | _stAnimated.UVRotateDirection = set.UVRotateDirection; |
| 4168 | _stAnimated.UvRotateSpeed = set.UVRotateSpeed; |
| 4169 | _stAnimated.NumFrames = 1; |
| 4170 | |
| 4171 | _stAnimated.Textures[0].TopLeft = set.Textures[0].UV[0]; |
| 4172 | _stAnimated.Textures[0].TopRight = set.Textures[0].UV[1]; |
| 4173 | _stAnimated.Textures[0].BottomRight = set.Textures[0].UV[2]; |
| 4174 | _stAnimated.Textures[0].BottomLeft = set.Textures[0].UV[3]; |
| 4175 | } |
| 4176 | else |
| 4177 | { |
| 4178 | _stAnimated.Fps = set.Fps; |
| 4179 | _stAnimated.NumFrames = set.NumTextures; |
| 4180 | |
| 4181 | for (unsigned char j = 0; j < set.NumTextures; j++) |
| 4182 | { |
| 4183 | if (j >= _stAnimated.Textures.size()) |
| 4184 | { |
| 4185 | TENLog("Animated frame " + std::to_string(j) + " out of bounds. Too many frames in sequence."); |
| 4186 | break; |
| 4187 | } |
| 4188 | |
| 4189 | _stAnimated.Textures[j].TopLeft = set.Textures[j].UV[0]; |
| 4190 | _stAnimated.Textures[j].TopRight = set.Textures[j].UV[1]; |
| 4191 | _stAnimated.Textures[j].BottomRight = set.Textures[j].UV[2]; |
| 4192 | _stAnimated.Textures[j].BottomLeft = set.Textures[j].UV[3]; |
| 4193 | } |
| 4194 | } |
| 4195 | |
| 4196 | UpdateConstantBuffer(_stAnimated, _cbAnimated); |
| 4197 | } |
| 4198 | |
| 4199 | void Renderer::BindBucketTextures(const RendererBucket& bucket, TextureSource textureSource, bool animated) |
| 4200 | { |