The 3ds Max file format, not too much documentation to be found about it. There are some hints here and there about how it's built up, but there exists no central documentation on it.

Right now we are in the following situation. A few thousand of max files, created by a very old version of max (3.x), containing path references to textures and other max files that have been renamed and relocated or which simply no longer exist. Yes, we have a maxscript that can go through them all, and that manages to fix a large number of paths. However, there are a lot of paths that are stored as part as fields in plugins and material scripts that don't get noticed, and the performance of opening and closing this number of files from 3ds Max directly is horrible. The obvious solution? Figure out how we can read and save the max file with modified contents, without having to understand all of the actual data it contains. Fortunately, this is actually possible without too much work.

Some research online brings up the following blog post, relating to a change in the max file format in version 2010, which would make it easier to update asset paths: http://www.the-area.com/blogs/chris/reading_and_modifying_asset_file_paths_in_the_3ds_max_file. That's nice and all, but it's only from version 2010 on, and it very likely won't contain any assets referenced by path by old plugins and such.

So, starting at the beginning. The blog post I referred to above nicely hints us to the OLE structured file format. Since there exist a wide range of implementations for that, we can pretty much skip that, and accept that it's basically a filesystem in a file, so it's a file containing multiple file streams. A reliable open source implementation of this container format can be found in libgsf. When scanning a fairly recent max file, using the command gsf list, we can find the following streams inside this file:

  1. f 52 VideoPostQueue
  2. f 147230 Scene
  3. f 366 FileAssetMetaData2
  4. f 2198 DllDirectory
  5. f 29605 Config
  6. f 3438 ClassDirectory3
  7. f 691 ClassData
  8. f 29576 SummaryInformation
  9. f 2320 DocumentSummaryInformation

The FileAssetMetaData2 is new in 3ds Max 2010.

One step further, we can start examining the contents of these streams. And it's usually easiest to start off with one of the more simple ones. VideoPostQueue seems small enough to figure out the overall logic of the file format, hoping that the rest is serialized in a similar way. Using the command gsf dump we can get a hex output of one of the streams, and using a simple text editor we can find how it's structured. Binary formats often contain 32 bit length values, which are usually easy to spot in small files, since they'll contain a large number of 00 values. It's basically a matter of finding possible 32bit length integers, and matching them together with various fixed length fields and other typical binary file contents, until something programatically logical turns up. Here's a manually parsed VideoPostQueue storage stream:

  1. [
  2. 50 00 (id: 0x0050)
  3. 0a 00 00 00 (size: 10 - 6 = 4)
  4. [
  5. 01 00 00 00 (value: 1)
  6. ]
  7. ]
  8. [
  9. 60 00 (id: 0x0060)
  10. 2a 00 00 80 (size: 42 - 6 = 36) (note: negative bit = container)
  11. [
  12. 10 00 (id: 0x0010)
  13. 1e 00 00 00 (size: 30 - 6 = 24)
  14. [
  15. 07 00 00 00 (value: 7)
  16. 01 00 00 00 (value: 1)
  17. 00 00 00 00
  18. 00 00 00 00
  19. 20 12 00 00 (value: 4610)
  20. 00 00 00 00
  21. ]
  22. 20 00 (id: 0x0020)
  23. 06 00 00 00 (size: 6 - 6 = 0)
  24. ]
  25. ]

The storage streams in the max container file contain a fairly simple chunk based file format (and in fact similar in format to the fairly well known .3ds file format). Being based on chunks is what allows 3ds Max to open a file for which certain plugins are missing. It's basically a tree structured format where every entry has an identifier and a size, so when an identifier is unknown, or when it's contents are incompatible, it can simply be kept as is or discarded. The only exceptions in the file that don't use this structure are SummaryInformation and DocumentSummaryInformation, which are supposedly in a standard Windows format, and the new FileAssetMetaData2 section is formatted differently as well unfortunately.

In this format, the chunk header consists of a 2-byte unsigned integer which is the identifier, and a 4-byte unsigned integer, where the 31 least significant bits are the size and the msb is a flag that helpfully lets us know if the chunk itself contains more chunks, and thus is a container, or not. For very large files, where 31 bits is insufficient for the size, the entire size field is set to 0, and the header increases with an additional 64-bit unsigned integer field which is similarly structured as the 32-bit size field. The size field includes the size of the header.

  1. 0 | 0f 20 (id)
  2. 00 00 00 00 (size missing)
  3. 17 fe 01 00 00 00 00 80 (size in 64 bits)

With this information it is possible to read a max file, modify the binary contents of chunks (most of them are fairly basic of format), and we should be able to re-save the max file with our modified data. The DllDirectory section, for example, parsed programatically starts like this:

  1. CStorageContainer - items: 20
  2. [0x21C0] CStorageValue - bytes: 4
  3. 786432216
  4. [0x2038] CStorageContainer - items: 2
  5. [0x2039] CStorageUCString - length: 39
  6. Viewport Manager for DirectX (Autodesk)
  7. [0x2037] CStorageUCString - length: 19
  8. ViewportManager.gup
  9. [0x2038] CStorageContainer - items: 2
  10. [0x2039] CStorageUCString - length: 49
  11. mental ray: Material Custom Attributes (Autodesk)
  12. [0x2037] CStorageUCString - length: 21
  13. mrMaterialAttribs.gup
  14. [0x2038] CStorageContainer - items: 2
  15. [0x2039] CStorageUCString - length: 37
  16. Custom Attribute Container (Autodesk)
  17. [0x2037] CStorageUCString - length: 23
  18. CustAttribContainer.dlo
  19. ...

Of course, it would be interesting if we could go further, and directly manipulate the parameters of our own plugins and scripts from our own tools back into the max files so that everything is centrally stored without any duplicate source data in the way. And that's exactly what I'll be doing next.

【转】http://blog.kaetemi.be/post/2012/08/17/3ds-Max-File-Format-%28Part-1%29

3ds Max File Format (Part 1: The outer file format; OLE2)的更多相关文章

  1. 3ds Max File Format (Part 5: How it all links together; ReferenceMaker, INode)

    At this point, you should start to familiarize yourself a bit with the publicly available 3ds Max AP ...

  2. [iTyran原创]iPhone中OpenGL ES显示3DS MAX模型之一:OBJ格式分析

    [iTyran原创]iPhone中OpenGL ES显示3DS MAX模型之一:OBJ文件格式分析作者:yuezang - iTyran     在iOS的3D开发中常常需要导入通过3DS MAX之类 ...

  3. AVEVA PDMS to 3ds Max - RvmTranslator6.0beta

    AVEVA PDMS to 3ds Max - RvmTranslator6.0beta eryar@163.com RvmTranslato6.0 translate PDMS RVM to 3ds ...

  4. VRay 2.0 SP1 2.10.01 for 3ds max 9/2008/2009/2010/2011/2012 32/64位 顶渲简体中文版+英文版[中国室内设计论坛-室内人]

    VRay 2.0 SP1 2.10.01 for 3ds max 9/2008/2009/2010/2011/2012 32/64位 顶渲简体中文版+英文版[中国室内设计论坛-室内人] 对最新版本的V ...

  5. 万圣节福利:红孩儿3D引擎开发课程《3ds max导出插件初步》

    ds max文件夹,插件文件夹以及3ds max的可执行程序文件夹: 位的,这里要改成x64,否则启动程序后3ds max会提示"不是有效的win32程序"之类的对话框. 然后要将 ...

  6. 【Unity】3.3 用3ds Max 2015制作模型并将其导入到Unity

    分类:Unity.C#.VS2015 创建日期:2016-04-05 一.常用三维软件简介 由于游戏引擎本身的建模功能相对较弱,无论是专业性还是自由度都无法同专业的三维软件相比,所以大多数游戏中的模型 ...

  7. 3ds Max从入门到精通

    1. 软件的下载与安装 这里用的是3ds Max2009简体中文版 32位 在 Win7上运行记得打上sp2补丁,不然会有bug. 2. 3ds Max的历史 3ds Max可以用在动画和游戏,点云数 ...

  8. 3DS MAX玩家必看!70个提高渲染速度的小技巧

    3DS MAX玩家必看!70个提高渲染速度的小技巧 (注:节省RAM不一定会加快渲染速度.请同学们根据实际情况加以利用.) 1. 尽量限制Ploygon数量,越少渲染速度越快 2. 如果使用Vray, ...

  9. (转)Unity与3ds Max的单位关系(使用FBX文件)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/a1780531/article/deta ...

随机推荐

  1. 小白的linux笔记7:批量运行复杂的linux命令组合——BASH简单使用法

    linux的BASH就相当于windows下的BAT文件,可以批处理命令.比如写好一个python脚本后,需要在运行时候加参数,但这个参数又不想每次输入,就可以用BASH的方式写好整条命令,然后直接运 ...

  2. matlab中的输出显示函数

    matlab中的输出显示函数 在matlab中使用的显示函数有disp.sprintf.fprintf比较常用.下面来介绍一下他们的用法. 1.disp()函数: disp(x)主要是用来输出变量x的 ...

  3. maven的核心概念——仓库

    第十章仓库 10.1 分类 [1]本地仓库:为当前本机电脑上的所有Maven工程服务. [2]远程仓库 (1)私服:架设在当前局域网环境下,为当前局域网范围内的所有Maven工程服务. (2)中央仓库 ...

  4. UVA1635-唯一分解定理的基本应用2

    原题:https://vjudge.net/problem/UVA-1635 这是一个极其典型的“从素因子角度出发”的题目,下面是我的代码: #include<iostream> #inc ...

  5. JVM和线程池

    本文链接:https://blog.csdn.net/liuwenliang_002/article/details/90074283 ————————————————版权声明:本文为CSDN博主「3 ...

  6. PHP0001:PHP环境搭建

    1,本机域名解析 网站域名访问流程 配置阿帕奇服务器 的 路径 阿帕奇中添加 PHP 支持 一个简单的PHP 代码 检测PHP apache 语法   httpd -t apache 的启动 获取网站 ...

  7. 再访JavaScript对象(原型链和闭包)

    一:原型链简介 JavaScript通常被描述为基于原型的语言 (从继承机制的角度)- 为了提供继承,对象(注意:区别于实例)可以拥有一个原型对象,它充当一个模板对象,它继承了方法和属性.对象的原型对 ...

  8. centos 7 安装npm

    下载网址https://nodejs.org/dist/latest-v8.x/ 安装过程参考https://blog.csdn.net/micarlxm/article/details/810912 ...

  9. mongoose pushall不支持的错误记录

    该错误发生两次,第一次解决以后第二次碰到又没有想起来怎么解决. 因为采用mongoose+node的后端项目.有两个表实现多对多关系,再中间表不做关联,只在两个主表做了 testlist: [{ ty ...

  10. xadmin使用

    xadmin使用 官方 使用参考