昨天的代码中,我们还不能说用到了Max的类库,今日小小增加一些代码,来我们能得到一个Max场景中有多少的节点。最后的结果:
代码只要修改DoExport()这个的内容,如下:
// 1, Get IGame interface m_pMaxScene = GetIGameInterface(); // 2, Right after initialize the IGame, we need to set conversion IGameConversionManager *pConMan = GetConversionManager(); pConMan->SetCoordSystem (IGameConversionManager::CoordSystem::IGAME_OGL); // 3, Initialize IGame, IGameProp.xml is default (path: [maxRoot]\plugcfg\IGameProp.xml) m_pMaxScene->SetPropertyFile("IGameProp.xml"); m_pMaxScene->InitialiseIGame(false); // 4, Check how many nodes m_iNodeCount = m_pMaxScene->GetTopLevelNodeCount(); if (m_iNodeCount == 0) { MessageBox (NULL, "No node in current scene", "Max plug-in", MB_OK); return 0; } else { char buf[256]; memset(buf, 0, 256); sprintf (buf, "Node count = %d", iNodeCount); MessageBox(NULL, buf, "Max plug-in", MB_OK); } return 1;
注意,在相关头文件中,我们必须加入:
// game scene IGameScene* m_pMaxScene; // nodes count in scene int m_iNodeCount;