| 187 | void AnimationRTPhase::SerializeBin(SerializeBinStream& f) {} |
| 188 | |
| 189 | float AnimationRTPhase::Load(QIStream& in, Skeleton* skelet, int nSel, bool reversed) |
| 190 | { |
| 191 | PoseidonAssert(_matrix.Size() >= nSel); |
| 192 | PoseidonAssert(_matrix.Size() <= skelet->NBones()); |
| 193 | // Set identity for all; not every bone is keyed in each phase |
| 194 | for (int i = 0; i < _matrix.Size(); i++) |
| 195 | { |
| 196 | _matrix[i] = MIdentity; |
| 197 | } |
| 198 | float time = 0; |
| 199 | in.read((char*)&time, sizeof(time)); |
| 200 | if (in.fail()) |
| 201 | { |
| 202 | // cannol load - skip and return |
| 203 | RptF("Broken animation file"); |
| 204 | return 0; |
| 205 | } |
| 206 | for (int i = 0; i < nSel; i++) |
| 207 | { |
| 208 | char name[33] = {}; // 32 wire bytes + guaranteed NUL for the strlwr / FindBone C-string use |
| 209 | Matrix4P transformP; |
| 210 | Matrix4 transform; |
| 211 | in.read(name, 32); |
| 212 | strlwr(name); |
| 213 | int index = skelet->FindBone(name); |
| 214 | |
| 215 | in.read((char*)&transformP, sizeof(transformP)); |
| 216 | transform = ConvertToM(transformP); |
| 217 | if (reversed) |
| 218 | { |
| 219 | // const static Matrix4P swapMatrix(MRotationY,H_PI); |
| 220 | const static Matrix4 swapMatrix(MScale, -1, 1, -1); |
| 221 | transform = swapMatrix * transform * swapMatrix; |
| 222 | } |
| 223 | if (index < 0 || index >= _matrix.Size()) |
| 224 | { |
| 225 | RptF("Bad bone %s", name); |
| 226 | } |
| 227 | else |
| 228 | { |
| 229 | _matrix[index] = transform; |
| 230 | } |
| 231 | } |
| 232 | return time; |
| 233 | } |
| 234 | |
| 235 | float AnimationRTPhase::LoadFromRTM(const Poseidon::Asset::Formats::RTMPhase& phase, const int* boneMap, int nSel, |
| 236 | bool reversed) |
no test coverage detected