• About
    • Resume
A Game Developer also plays some guitar

My Footsteps of Programming 3DS Max Exporter Plug-in (continued)

May 12, 2010 4:21 pm / Benny Chen

Oh my goodness, how long has it been since I wrote the first part of this article? What on hell was I buzzing around for during this period which seemed years to me? This plug-in is nearly becoming a legacy for me. Now it’s time to bring it back and finish the remaining parts. And I will also upload the whole project’s source code and related docs later.

First part of this article: http://www.bennychen.cn/?p=640

Predefine mesh file format

After we’ve got some basic concepts about 3DS Max, now it’s time to define our own mesh file format. It’s very hard to directly define a format from the scratch. Researching some already typical and mature file formats is a good starting point. Recommended by my tutor, I chose .md2 & .md3 formats as my learning material which are famous for being used in the Quake series game. Based on several days’ research on them, I defined my own mesh file format, which is sort of like .md2 & .md3 but also differs from them at some point.

I did not just define one format. They are a suite of formats, see the following table.

File Type
File Format
Basic mesh file
*.CSM (Crowd Simulation Model)
Texture
*.jpg, *.bmp, ……
Animation
*.AM
Animation Configuration
*.CFG
Mounting Configuration
*.CSM_PACK

There are 5 parts in total. But some of them are not necessary. Only one file is essential – the basic mesh file, which is named as CSM( Crowd Simulation Model ), because at that time I programmed this plug-in mainly for a crowd simulation project. The texture part is the textures file used by the mesh. If a mesh includes animation, the AM file( short for animation ) and animation configuration file(.CFG) are also needed. My format also supports mesh mounting, so if a mesh is mounted by several sub-meshes, .CSM_PACK is used to store the mount info.

These are some of the features of my format.

  • Support multi-texture
  • Support skinned animation
  • Decouple mesh and animation
  • Support animation configuration
  • Support mesh mounting

And the 2 figures below are the inside structure of CSM and AM. If you want to know more detail of them, later I will upload the docs.

I stored my animation data in .AM file, bone by bone, animation by animation, and frame by frame.

Export static mesh data

OK, so far, all the preparation work is done. We can finally start the programming process.

For the last 2 steps, I will not present very detailed info here. I will only talk on the difficulties needed to overcome when I programmed them. All the programming job is strictly based on the format we defined last step. For more detail, please turn to my source code.

Firstly we need to handle the static mesh data. In this step, some difficulties are.

1. Transformation between different types of coordinate system.
Basically 3DS Max uses right-hand coordinate system. But some common rendering system( i.e. DirectX ) uses left-hand coordinate system. They have totally different coordinate systems, see figure below. So, the coordinate data needs to be transformed before outputting. See the figure below, the left is a typical rendering system’s coordinate system, and the right is of 3DS Max.

About how to transform, you can refer to this paper – 《一种不同坐标系之间的变换矩阵的转换方法》by 杨卫东&刘玉树.

2. Handle mesh with multiple textures.
This is a tricky problem. We know that a single vertex could be shared by different faces, so if these faces are attached with different textures, the vertex should have multiple UV coordinates. This leads to the fact that we need to split the vertex into multiple vertices, so that we can ensure one vertex only maps to one UV coordinate. And the whole mesh needs to be reorganized.

From my CSM format definition, you may have found that a mesh is comprised of multiple submeshes. Actually the submeshes are split based on textures, that is, vertices using the same texture are categorized into one submesh. So if an original vertex is using 2 textures, this vertex is firstly split into 2 vertices and will exist under 2 submeshes respectively.

3. Vertex normal
This is another painful issue. About this topic, I once wrote an article in my blog before. Turn to it here.

Export skinned animation

Now, we have come to the most complex, most sticky part of the whole work. I can still remember the time, the pain and the effort when I tried to tackle this problem. Those memories are so unforgettable. But they all deserve.

Why I did it so painfully was that, firstly I was still not familiar with the mechanism of bone animation at that time, secondly the mechanism of 3DS Max skeletal system is hard to figure out, whether its bone system or biped system, lastly, decouple the vertex data and the animation data is another challenge.

About the computational process of bone animation, thanks to this blog, it is the key article that helped me accomplish the whole work.
http://www.cnblogs.com/neoragex2002/archive/2007/09/13/Bone_Animation.html

Screenshots

The figure below is my exporter plug-in UI. The upper part is used to include animations, which will later generate .CFG file. Ant the lower part is used to configure mesh mounting, which will later generate .CSM_PACK file.

And here is an example of exporting. On the back is the 3ds max software interface, rendering a mesh with or without some animation. And on the front is the mesh viewer developed by me, which renders the same mesh with the same animation.

This is another example, the Tiananmen Gate.

Posted in: Computer Graphics / Tagged: 3ds max, exporter, plug-in, 导出插件

2 Thoughts on “My Footsteps of Programming 3DS Max Exporter Plug-in (continued)”

  1. 你家男人 on May 13, 2010 at 1:22 am said:

    导航栏里面My Project应该改成My Projects

  2. Benny on May 13, 2010 at 9:50 am said:

    细心的好男人~我有空改下哈~

Post Navigation

← Previous Post
Next Post →

LinkedIn

Milan Petrovic

Categories

  • In My Life (25)
    • A Day in the Life (8)
    • English Learning (2)
    • Learn a Word (7)
    • Something In The Way (8)
  • Music Heaven (8)
    • Guitar (1)
    • In Concert (1)
    • Lyrics (3)
  • OK Computer (54)
    • 3D (3)
    • C++ (10)
    • Computer Graphics (15)
    • Game Programming (23)
    • iOS (6)
    • Linux (1)
    • Lua (9)
    • My Projects (3)
    • Some Experiences (9)
    • Talking in Code (2)
    • Unity (2)
  • Quotations (2)
  • Uncategorized (1)
  • Visca Barça (24)
    • FCB BJ (5)

Recent Posts

  • [译]优化你的手机游戏(没有延迟的,才是健康的)- 一篇给游戏美术设计师读的文章
  • 新浪微博API for MOAI
  • 稍后继续
  • Unity Developer ++
  • Another Thread @ Moai Forum
  • 1st Day of Golden Week
  • 为SyntaxHighlighter添加新语言
  • 基于Lua的State Pattern
  • Class Diagram of Pacman
  • 基于Moai的Pacman

Recent Comments

  • 约修亚_RK on 为SyntaxHighlighter添加新语言
  • 爱装的小男孩 on 小心DLL链接静态库时的内存错误
  • happyfire on Game Loop的几种实现方式
  • William on 新浪微博API for MOAI
  • Benny Chen on 新浪微博API for MOAI
  • your man on 新浪微博API for MOAI
  • 你家男人 on 稍后继续
  • 逍遥 on 关于对std::vector的遍历
  • papa on Unity Developer ++
  • T客网 ︱ Techpot » Blog Archive » iOS开发与OpenGL ES相关问题整理(1) on iOS开发与OpenGL ES相关问题整理(1)

Tags

2d 3D 3dsmax 3ds max air Apply architecture Asia tour barca Beijing bilbao binary search blocked bob boost bruce springsteen C++ capo CGContextDrawImage Champions League Change DLL DX10 eval exporter flash framework frustum culling game game engine iniesta ios linux lua Moai opengles pacman plug-in plugin 北京 导出插件 崩溃 巴萨 游戏引擎 踢球
© Copyright 2025 - A Game Developer
Infinity Theme by DesignCoral / WordPress