A developer may also wish to create materials and assign them to nodes in the scene.
Sample code using many of these functions is available in the .3ds importer plug-in. This code may be found in\MAXSDK\SAMPLES\IMPORT_EXPORT\3DSIMP.CPP.
The code below demonstrates how a 3ds Max Standard material may be assigned to a mesh object. It assigns a material with Red Ambient and Diffuse settings to the first node in the current selection set.
void AssignMtl(Interface *ip) { if (! ip->GetSelNodeCount()) return; // Nothing to assign. INode *node = ip->GetSelNode(0); // Create a new Standard material. StdMat *m = NewDefaultStdMat(); // Set its properties... m->SetName(_T("Sample")); m->SetAmbient(Color(1.0f,0.0f,0.0f),0); // Pure Red m->SetDiffuse(Color(1.0f,0.0f,0.0f),0); m->SetSpecular(Color(1.0f,1.0f,1.0f),0); m->SetShininess(0.5f,0); m->SetShinStr(.7f,0); // Assign it to the node. node->SetMtl(m); ip->RedrawViews(ip->GetTime()); }