PDA

View Full Version : How to group two geometry nodes using the API


lasse2010
12-09-2009, 03:45 PM
I have created an importer using the 3dsmax app wizard in visual studio 2008. The job of the importer is to import some geometry into nodes and group the nodes. I can successfully import geometry, but I am having problems with grouping. Here is a code sample of what I do:


static INode *MakeGroupObject(ImpInterface *i, TCHAR* name, Point3 p)
{
TriObject *tri = CreateNewTriObject();
Mesh *msh = &tri->GetMesh();
int numVert = 3;
int numFace = 1;
msh->setNumVerts(numVert);
msh->setNumFaces(numFace);
msh->setVert(0, 0.0, 10.0, 0.0);
msh->setVert(1, 0.0, 0.0, 10.0);
msh->setVert(2, 10.0, 0.0, 0.0);
msh->faces[0].setVerts( 0, 1, 2);
msh->faces[0].setEdgeVisFlags(1, 1, 1);
msh->buildNormals();
msh->buildBoundingBox();
msh->InvalidateEdgeList();
ImpNode *node = i->CreateNode();
node->Reference(tri);
i->AddNodeToScene(node);
node->SetName(name);
i->RedrawViews();
INode *iNode = node->GetINode();
Matrix3 tm;
tm.IdentityMatrix();
tm.SetTrans(p);
iNode->SetNodeTM(0, tm);
i->RedrawViews();
return iNode;
}

int Importer::DoImport(const TCHAR *filename,ImpInterface *i, Interface *gi, BOOL suppressPrompts)
{
INode *node1, *node2, *gnode1;
node1 = MakeGroupObject(i, _T("o1"), Point3(-50,0,0));
node2 = MakeGroupObject(i, _T("o2"), Point3(50,0,0));

// Grouping start
INodeTab tab1;
tab1.Append(1,&node1);
tab1.Append(1,&node2);

TSTR nam1("Group1");
gnode1 = gi->GroupNodes(&tab1,&nam1,FALSE);
// Grouping end

i->RedrawViews();
return TRUE;
}



The grouping fails. The code creates two nodes of type geometry - none of them grouped. What am I doing wrong?

CGTalk Moderation
12-09-2009, 03:45 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.