0

インスタンス化された 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()」関数はありません。

助けてくれてありがとう。

4

1 に答える 1

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.
        }
    }
于 2014-12-15T09:03:55.177 に答える