【问题标题】:Get mesh of instanced GeomObject获取实例化 GeomObject 的网格
【发布时间】:2015-02-11 01:14:06
【问题描述】:

如何从实例化的 GeomObject 中获取网格?

我在 maxscript 中:

gsphere = createInstance geosphere radius:1 segs:4
gsphere_mesh = gsphere.mesh

这是翻译成 C++ 的 maxscript 的第一行:

GeomObject *GSphere = (GeomObject*)ip->CreateInstance(GEOMOBJECT_CLASS_ID, GSPHERE_CLASS_ID);
GSphere->GetParamBlockByID(2)->SetValue(0, 0, 1);
GSphere->GetParamBlockByID(2)->SetValue(1, 0, 4);

现在,我需要获取网格,但我不知道如何获取。没有“GetMesh()”或“GetTriMesh()”函数。

感谢您的帮助。

【问题讨论】:

    标签: c++ 3dsmax maxscript


    【解决方案1】:

    要访问节点的网格,您可以使用以下内容:

    for (int t = 0; maxscene->NumChildren() > t; t++)
        {
            INode* currNode = maxscene->GetChildNode(t);
            Object* obj;
            ObjectState os = currNode->EvalWorldState(GetCOREInterface()->GetTime());
            obj = os.obj;
    
            switch (os.obj->SuperClassID())
            {
            case GEOMOBJECT_CLASS_ID:
                TriObject *p_triobj = NULL;
            BOOL fConvertedToTriObject = obj->CanConvertToType(triObjectClassID) && (p_triobj = (TriObject*)obj->ConvertToType(0, triObjectClassID)) != NULL;
                if (!fConvertedToTriObject)
                {
                    mprintf(L"Error: Could not triangulate object.);
                    return false;
                }
                Mesh *p_trimesh = &p_triobj->mesh;
                int faceCount = p_trimesh->getNumFaces();
                //work with the mesh here.
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-04
      • 1970-01-01
      • 1970-01-01
      • 2016-10-05
      • 2011-04-28
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      相关资源
      最近更新 更多