AMFP Enhanced
C++ reference: the code this unofficial fork added
Loading...
Searching...
No Matches
MeshLoaderUfbx.h
Go to the documentation of this file.
1/*
2 * AMFP-2026: .FBX loading through ufbx, in place of the Autodesk FBX SDK loader the original
3 * exe used (MeshLoaderFBX.cpp, compiled out with HPL_NO_FBX). Same results as that loader:
4 * it uses the .anm / .msh cache next to the file when it is newer, otherwise reads the FBX,
5 * builds the skeleton from the skin clusters' bind pose and samples each bone at its key
6 * times (FbxAnimTimes.h). Unlike that loader it never writes a cache into the game folder.
7 *
8 * Meshes are read from their .msh cache only for now (9 of the game's 10 FBX meshes ship one);
9 * animations are read from the FBX when no cache exists.
10 */
11#ifndef HPL_MESH_LOADER_UFBX_H
12#define HPL_MESH_LOADER_UFBX_H
13
14#include "math/MathTypes.h"
15#include "resources/MeshLoader.h"
16
17struct ufbx_scene;
18struct ufbx_node;
19struct ufbx_anim_stack;
20
21namespace hpl {
22
23 class cMesh;
24 class cBone;
25 class cSkeleton;
26 class cAnimation;
27 class cMeshLoaderMSH;
28
29 class cMeshLoaderUfbx : public iMeshLoader
30 {
31 public:
32 cMeshLoaderUfbx(iLowLevelGraphics *apLowLevelGraphics, cMeshLoaderMSH *apMeshLoaderMSH, bool abLoadAndSaveMSHFormat);
34
35 cMesh* LoadMesh(const tWString& asFile, tMeshLoadFlag aFlags);
36 bool SaveMesh(cMesh* apMesh, const tWString& asFile) { return false; }
37
38 cAnimation* LoadAnimation(const tWString& asFile);
39 bool SaveAnimation(cAnimation* apAnimation, const tWString& asFile) { return false; }
40
41 /** Reads the animation from the FBX itself, ignoring and not writing any cache.
42 * Used by the dev check that compares against the original loader's .anm files. */
43 cAnimation* LoadAnimationFromFbx(const tWString& asFile);
44
45 private:
46 cSkeleton* BuildSkeleton(ufbx_scene* apScene);
47 void LoadSkeletonRec(cBone* apBone, ufbx_node* apNode);
48 void LoadBindPoseRec(cSkeleton* apSkeleton, ufbx_node* apNode);
49 void MakeFinalBonesRec(cBone* apBone, cMatrixf a_mtxParentGlobal, cMatrixf a_mtxParentGlobalUnscaled);
50 void LoadAnimationRec(ufbx_scene* apScene, ufbx_anim_stack* apStack, ufbx_node* apNode, cAnimation* apAnimation, cSkeleton* apSkeleton);
51
52 cMeshLoaderMSH *mpMeshLoaderMSH;
53 bool mbLoadAndSaveMSHFormat;
54 };
55
56};
57#endif // HPL_MESH_LOADER_UFBX_H
bool SaveAnimation(cAnimation *apAnimation, const tWString &asFile)
bool SaveMesh(cMesh *apMesh, const tWString &asFile)
cAnimation * LoadAnimationFromFbx(const tWString &asFile)
Reads the animation from the FBX itself, ignoring and not writing any cache.
cAnimation * LoadAnimation(const tWString &asFile)
cMeshLoaderUfbx(iLowLevelGraphics *apLowLevelGraphics, cMeshLoaderMSH *apMeshLoaderMSH, bool abLoadAndSaveMSHFormat)
cMesh * LoadMesh(const tWString &asFile, tMeshLoadFlag aFlags)