Notifications
Clear all

[Closed] Coloring a Mesh in 3DS Max SDK

Hello,

I am writing a plugin for 3DS Max to import a custom file format. The format has multiple “materials” that each cover an arbitrary number of faces on the mesh, and contain values for:

[ul]
[li]Alpha
[/li][li]Shininess
[/li][li]Diffuse
[/li][li]Ambient
[/li][li]Specular
[/li][li]Texture file
[/li][/ul]

How would I use these to color and texturize the mesh?

I’m fairly new to the 3DS Max SDK, but have been programming in C++ for years and have much experience with the Direct3D API.

3 Replies

you need to create a material containing the parameters that you mention,
then after creating the material(s) you loop through and assign the materials to the mesh faces.

This can be done by making a standard material with the SDK.

If you for example create a multisub material with all you materials inside, then you can loop through and assign the different faces to their material ID.

So what you need to look into is how to create a material, and how to loop through the mesh afterwards.

Look up the material class, and the mesh class in the helpfile, and check out the functions there.

If you need more specific help then just say so

Thank you for the reply!

I’ve created an instance of the Material class, and set the ambient, diffuse, specular, shininess, and opacity to the values from the model. How do I assign this to the faces in the mesh?

The documentation for the SDK doesn’t seem to be any help here. I see that you can set the material ID, but not the material class.

on import you do something like this:

// create import node
   ImpNode *node = = i_imp->CreateNode();
   
   // add your mesh with material ids set for the faces to this node
   node->Reference(triObject);
  

to set the material…

// set material or multi material
   node->GetINode()->SetMtl(mtl);

then add it to your scene

// add it to current scene
   i_imp->AddNodeToScene(node);

guruware