FBX static & skin mesh loader for Irrlicht-1.7.2
This example shows us how to write a FBX file parser with FBX SDK. The mainly parts are how to retrieve vertexes, uv, normal, polygons, polygons' material, textures, skin animation data and so on.
To make the source code as easy as possible, I assume that the FBX file will contain only one mesh node. Why? For game play models, we MUST combine all those meshes into only one mesh. That means one big mesh may work with multiple materials. Less mesh may cause less draw call happen, we could avoid submit the small meshes frequently. All this will improve the GPU frame rate. When you download some model from the web site, you will notice that there are lots of separated mesh node exists. In such situation, you need to do some additional work with Maya. Good Luck for you!
Project Setting
To set up the FBX SDK(here FBX SDK 2009.3 version used) in your project, on best solution is copy them from the sdk example projects or create a empty project first and do a beyond comparing with the example project files. Of course, the first thing you always need to do before use other external libraries is set the correct include & lib directories. For FBX project, there are some additional settings:
1) You need to add those macros in your project property “Preprocessor Definition”:
KFBX_PLUGIN
KFBX_FBXSDK
KFBX_NODLL
2) You need to add those items under the “Additional Dependencies” property:
wininet.lib
For more details about how to configure the FBX sdk using settings, you could check my project file.
Export function Name Correctly
In this example, I use Irrlicht-1.7.2 to display the static mesh and skin mesh. But in this version, it does not expose some animation implementation header files to us. For example, here I need to use CSkinnedMesh.h in my own code to hold some animation data. But Irrlicht-1.7.2 library does not put this file into it’s include directory. That means I could not use this file in some project that using Irrlicht library.
To address this issue, you need to move CSkinnedMesh.h to include directory, and open source file, modify it’s class declaration like following to expose this class to outside.:
class IRRLICHT_API CSkinnedMesh: public ISkinnedMesh { public:
IRRLICHT_API will make sure we could access and use class CSkinnedMesh from outside of Irrlicht library. For more details about export class or function name from DLL, you could google on the web. As I know there are two ways to manage to do that: the first one is that you place key word __declspec(dllexport) before your output class or function name, and the other way is design your class as interface that just some class with pure virtual functions.
With these modification in Irrlicht library, then you need to re-build the whole irrlicht library.
Compile & Run Demo
The full source code can be downloaded from here. To recompile and run the demo, you need to install the following stuffs on your computer:
1) Install FBX SDK, here I used FBX SDK 2009.3; At the same time, you need to install Maya on your computer to check whether this program load and display the FBX file correct or not;
2) Irrlicht 1.7.2 and with IRRLICHT_API modification in CSkinnedMesh.h, then re-build the library;
3) I use VisualStudio 2008, Of course you could use other IDE if you wish. But you need to translate those include & library settings from VS to your IDE settings.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了