PDA

View Full Version : Apply a texture to a submesh


EnvisMJ
12-07-2011, 09:35 AM
Is there a way to apply a texture to a single mesh within a model? I'm using this:

model = viz.add('Models/DynamicObjects/Vial_Default.IVE')
labelMat = viz.addTexture('Textures/VialLabels/Ampicillin & Sulbactam 1.5gm vial - WHITE.png')

vial = model.getChild("Vial-GEODE")
label = model.getChild("Label-GEODE")
cap = model.getChild("Cap-GEODE")

label.texture(labelMat)

But it isn't doing anything.

My goal is to import a single model of a vial, and within Vizard, apply a different label as needed.

Ex.
http://www.mcguffmedical.com/Images/Images550/001239%20Ampicillin%20Sodium,%202%20Grams%20per%20 Vial,%20SDV,%2010%20Vials%20per%20Tray%20McGuffMed ical.com.jpg

farshizzo
12-07-2011, 09:55 AM
First off, I would avoid using getChild unless you need to modify the transform of the child. If you just need to change the texture, then use the optional node parameter of the texture command:model.texture(labelMat,node='Label-GEODE')
Are you getting any error messages? Can you send us the model?

EnvisMJ
12-13-2011, 07:44 AM
Nope, no error messages.

************************************************** ****************************
** Loading bulks.py
************************************************** ****************************
Loading File: Models/DynamicObjects/Vial_Default.IVE
** Load Time: 0.51 seconds


The texture application doesn't seem to be doing anything, I'm just left with a floating green and white via. Not sure why the green, the texture for the glass seems not to be loading either.

See attached files

farshizzo
12-13-2011, 08:34 AM
Are you exporting the model from max? If so, it looks like you didn't export the model with a texture applied to the label. If you don't export with a texture applied, then there will not be any texture coordinates assigned to the sub-mesh. This is why the texture does not appear when you apply it within Vizard. Try assigning some placeholder texture to the label within max and reexport it.

EnvisMJ
12-28-2011, 11:34 AM
So in the process of trying to implement that, I've run into another issue, or some part of the same one.

I've been through the process of exporting the model from Maya->Max->Vizard at least a dozen times now with every variation I can think of. But still for some reason, the texture file for the glass and cap portion of the vial is coming in corrupted or something.

http://web.ics.purdue.edu/~cmankey/Vizard/screengrab.jpg

In the image (Sorry if it's huge), on the right you can see how the texture looks in Photoshop, Maya and Max, but in Vizard (on the left) it appears green with much higher contrast on the cap.

Two other coworkers and I are pretty stumped, any help would be appreciated.


Texture File:
http://web.ics.purdue.edu/~cmankey/Vizard/Vial_Glass_n_Cap.jpg

EnvisMJ
12-29-2011, 10:34 AM
Nevermind on that last problem. "Embed image data in binary files" was checked on the exporter.