码迷,mamicode.com
首页 > 其他好文 > 详细

Reading and Modifying Asset File Paths in the 3ds Max File

时间:2015-03-02 12:46:25      阅读:661      评论:0      收藏:0      [点我收藏+]

标签:

Some people found the following information in the MAXScript reference for 2010:

 NEW in 3ds Max 2010: The 3ds Max scene file now provides Asset Metadata in a separate stream which can be accessed and modified by external applications. The Asset data is generated and managed by the AssetManager and AssetUser objects.

What left several people scratching their head and wondering was "how exactly can an external application" access and modify this data?! While the 3ds Max file format is not released to the public, we do publicize the fact that it uses the Microsoft OLE structured storage format. This means that you can browse, and even edit, certain properties of a 3ds Max file by using the IStorage and IPropertyStorage interfaces.

This is especially useful if you want to modify asset file paths in a 3ds Max file, without opening the file. This can be accomplished with MAXScript using the functions: getMAXFileAssetMetadata and setMAXFileAssetMetadata. The MAXScript documentation has several pages that discuss the asset file streams in MAX files, but unfortunately doesn‘t say anything more about how an external application can access these streams.

Unfortunately reading and writing of structured storage files is far from trivial, and out of the scope of what we can cover in the 3ds Max SDK documentation.That said, I can at least provide some tips and pointers that can help you get started if you are determined to edit max files outside of 3ds Max.

First off it is useful to know that the actual C++ implementation of the MAXScript functions for modifying asset file data is released with the 3ds Max SDK and can be found in the file "maxsdksamplesmaxscriptmxsagniavg_dlx.cpp"  at around line 7600. Search for "get_max_file_asset_metadata_cf" and "set_max_file_asset_metadata_cf". Also in the SDK is a file in "maxsdksamplesutitliesmaxfindShowPropDlg.cpp" that has an algorithm for opening a Max file using the IPropertySetStorage COM interface.

If you are really motivated, this might be enough to get you started but the documentation is extremely sparse and it is hard to follow. OLE programming in C++ is not for the faint-hearted. I strongly suggest looking at the structured storage documentation on MSDN for some help (http://msdn.microsoft.com/en-us/library/aa380365(VS.85).aspx).

I did find a C++ project on CodeProject.com while researching this problem which may also prove to be useful: An ATL and MFC wrapper for structured storagehttp://www.codeproject.com/KB/atl/structuredstorage.aspx .

Because I really hate programming OLE in C++, I also did some research on structured file format reading and writing in C#. Again on CodeProject.cp, I found two project which were helpful:

  1. An MS word file viewer - http://www.codeproject.com/KB/cs/getwordtext.aspx
  2. An HTML file reader - http://www.codeproject.com/KB/cs/htmlcb.aspx

After all of this I found that rolling my own C# reader isn‘t too hard if you have the Microsoft Visual Studio SDK installed. With it is a .NET assembly "Microsoft.VisualStudio.OLE.Interop.dll". This assembly isn‘t documented at all, but using the Object Browser and the MSDN reference I mentioned above I was able to roll a quick and dirty MAX file reader in a couple of hours.

Apart from adding a reference to the dll, the only tricky things that I had to do were:

  1. Define my own constants
  2. Use "dllimport" to import the API StgOpenStg.

I hope that you find this information at least helpful enough to get you started down the path of reading and writing 3ds Max files.

 

【转】http://area.autodesk.com/blogs/chris/reading_and_modifying_asset_file_paths_in_the_3ds_max_file

Reading and Modifying Asset File Paths in the 3ds Max File

标签:

原文地址:http://www.cnblogs.com/veimr/p/4308238.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!