Irrlicht Mesh Viewer – How to write Maya Plugin with c++

screen_shot-300x248

This sample program shows us how to write a Maya static mesh exporter with c++. At first, I planed to write some additional features on the skin animation, but Maya C++ API seems very complicated for me. I could own a copy of Maya programming white paper, and know all the classes. but I could not figure out what the relationship among them, and can not easily grab a path from class A object to class B object. That is how the graphic goes in the Maya editor. I am not family with such big stuff. Cause I am a programmer, not a artist.

I defined a customized kind of static mesh format, that will be used to hold the exported data. To view the exporting meshes, I implemented a simple mesh loader with Irrlicht engine 1.7.2. The above screen shot was from the demo screen-shot.

 

Some Ideas

During the process of coding, some ideas grow up in my mind:
1) The first questions is how to resolve the vertex shared problem. The way I collect all of the triangles was like this: go though all polygons and find all triangles for each polygon; For each triangle, I collected 3 vertex elements without considering some of them could be shared by other triangles. That means 3 new elements will be added into the vertex buffer for each triangle, and 1 triangle (3 vertex index number) will be added into the index buffer. I tried to save each vertex element and do a quick search before a new vertex element need to add. But here come a very serious problem. The search process it-self take too much time. I tried to use the binary search to address the search performance issue, but the result was far from what I expected. So finally I made some duplicated vertex elements into my vertex buffer.
2) At last a continue vertex buffer and an index buffer were used.  Yes, this solution will increase some memory usage, but maybe we could get some performance improved. Because we make those two memory access continuously, the GPU process units do not need to jump back and forward to fetch the vertex data. Of course there are still some optimization space here: we could reduce some duplicated vertex element and also get some performance better. Remember that the GPU has some cache hardware, that device could cache some vertex data that need to access frequently.
3) You could some some low polygon model instead of high polygon model. Too many geometry will be a big burden for GPU. I tried to use a model with 12M in Maya, and the frame rate drops dramatically.
4) Thanks to http://www.mayawu.com/ that provide me with a free robot Maya model.

 

Run the Demo

The full source code could be downloaded from here. Here are some limitations when you want to compile and run the program:
1) I will not provide maya libraries and dlls. and I used Maya2009 develop kit, so you’d better to do a full Maya2009 installing on your computer. You should  install the Maya software package, develop kit and full documents. I did not try other Maya version, it may work. I am not sure.
2) To make the exporter could be run  more smoothly, you need to set MAYA_LOCATION environment path to figure out where you maya have installed. For example, I set MAYA_LOCATION to “C:Program FilesAutodeskMaya2009″ on my computer.
3) I will not provide some library about Irrlicht. This is an open source graphics engine, you could download it from website for free. The Irrlicht engine version that I used here is Irrlicht-1.7.2. After you re-compile the Irrlicht locally, you need to copy Irrlicht.dll file into the MayaPluginbin directory.
4) After you download the Irrlicht, you could un-zip it. You should put my source code under the “Irrlicht-1.7.2tool” directory if you do not want to change the include & lib path.
5) Be care of where you install the Maya, you need to set the Maya include & lib path in your project if possible.
6) Obviously, I used the windows OS. And of course VS2008 used here. You need to do translate works when you want to use other make tools.
7) Another project “objExporter” also provided here. If you want to write a Maya Plug-in, and put all exporting stuff under the Maya “Export All..” menu item, you could deep further.
8) Some other documents that I collected from the web site also provided.

原文链接: https://www.cnblogs.com/open-coder/archive/2012/08/24/2653565.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    Irrlicht Mesh Viewer – How to write Maya Plugin with c++

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/60752

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月9日 上午9:36
下一篇 2023年2月9日 上午9:36

相关推荐