Apply Material to Portion of a Model (.obj)

Hello everyone!



I’m new to jmonkey engine and, as so, i’m still learning. Currently i’m having trouble applying a material to part of a loaded model in runtime. More specifically, I have a model of a house that i’ve created from AutoCad → 3dStudioMax → .obj , and I want to, for example, be able to apply a material to a specific wall, or to the floor of the building.



What is the best way to accomplish this?





Thanks in advance, Cheers!

Isn’t there anyone that can help me? I’m really struggling with this issue…any help is welcomed!

When you import the model, is it a node with separate geometries? Cause I think you can call Node::getChildren() and then set the material per Geometry(child). I dunno, I’m pretty new too, but someone will probably be able to help you better, just give it some time.

flcoder said:
When you import the model, is it a node with separate geometries? Cause I think you can call Node::getChildren() and then set the material per Geometry(child). I dunno, I'm pretty new too, but someone will probably be able to help you better, just give it some time.


It's a Node, my problem is how do I, in 3D Studio Max, define the different geometries? I know that this e not specifically jMonkey related, but if anyone can indicate me good reading material about the subject, I would be more then grateful!

Oh ok. You want the materials to be imported and applied as they look in 3dsmax? That’s something I guess I’ll be figuring out too so when I get to some of that, I’ll let you know, but if you want to find out now, there’s a lot of documentation. Use keywords JMonkey 3ds max model material, stuff like that, I’m sure you already know, but I’ve learned a lot from just digging around and searching forums. Sorry I can’t help much at this moment.

You can’t. One geometry = One material.

You should use uv mapping if you want to achieve this

My problem is NOT displaying the model with the materials as it comes from 3d studio max, its prior to that. What I want is to know how do I define the different elements on the model presented in 3D studio max, so that the model it self is exported in such a way that jMonkey will import it as a Node with several Geometries, each on corresponding to a element.





Example:



3D Studio Max

MyModel (editable mesh) with 6 elements (4 representing the walls, 1 the floor and 1 the ceiling)





in jMonkey I want the exported obj to be imported as Node myModel such as myModel.getChildren() returns a list with 6 Geometries.

I think I saw this somewhere… I’m not 100% on this, but I think when you export, you should get one geometry per material. So maybe if you assign a specific material per object, you’ll get the children when you import. Think I read that somewhere.

flcoder said:
I think I saw this somewhere... I'm not 100% on this, but I think when you export, you should get one geometry per material. So maybe if you assign a specific material per object, you'll get the children when you import. Think I read that somewhere.


Ok, I'm gona try that and latter i'll post the results. Tks!

Thank you very much flcoder!!! It worked perfectly! My problem is solved!