• About
    • Resume
A Game Developer also plays some guitar

Tag Archives: Plug-in

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

May 12, 2010 4:21 pm / 2 Comments / 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, 导出插件

My Footsteps of Programming 3DS Max Exporter Plug-in

November 20, 2009 9:03 pm / 4 Comments / Benny Chen

Several months ago, I achieved to develop a 3DS Max exporter plug-in. But until recently, I didn’t get the time to jot down something about my experience while developing it. Finally, thank God, I am starting to write this article, in case that several years later I totally forget how I did it at that time.

As you know, 3DS Max is a powerful tool for creating 3D models, especially widely-used in games. But generally we cannot directly get our model from 3DS Max, otherwise, we need a sort of middleware to retrieve specified model data we need from 3DS Max and export them into a specific type of file. This middleware is right the exporter plug-in.

OK, with this concept in mind, let’s get started.

Step by step, I will roughly present my footsteps of programming a 3ds max exporter plug-in based on 3DS Max 9 SDK.

Get familiar with 3DS Max and SDK

As we all know, there are a series of 3DS Max versions. Firstly you need to choose one to program based on. At the time of my embarking on this plug-in, the latest version is 3DS Max 2009. However, I chose Max 9 because it is already a widely-used and popular version. Most importantly, my laboratory was using Max 9.

Before doing some real programming jobs, it is pretty important to gain some basic concepts of 3ds max. We needn’t to be a perfect 3D designer ourselves, but these are the essential concepts we must know.

  • what is a Node in 3ds max
  • the hierarchical chart of nodes
  • how materials are attached to a node
  • what is a node’s Modifier
  • key-frame animation and how bone nodes are attached to normal nodes
  • the Biped technique

The fact is, the more we want to export from 3DS Max, the more we need to concern about it. For example, if we also want to export the data of camera or light from Max(meshes for games usually don’t export these data), we must apprehend what is a camera or light node in Max and how they work with other nodes.

But how the hell could we get the detail of these knowledge? Turn to the Max SDK Document, whenever you have any confusion with Max. Besides, we can also log on to Autodesk’s official Web site for more help.

BTW, the assumption here is that you are already familiar with some 3D concepts, like vertex, triangle, mesh, texture, space transformation, skinned animation, etc. If you are still a 3D newbie, you’d better figure them out firstly.

To be continued…

Predefine mesh file format

Export static mesh data

Export skinned animation

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

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 2026 - A Game Developer
Infinity Theme by DesignCoral / WordPress