PDA

View Full Version : LSscript to change Surf Prop of Obj to Matte Obj



Ciruja
04-13-2011, 05:33 PM
Hello,

I'm trying to setup an LScript to convert Obj into a matte Obj.

Ultimately, I would like it to work like this:
- User picks the obj in Layout and runs the script.
- All Texture envelopes & channels of images/procedural/gradient
- Special Buffer or Environment maps (Reflection/Refraction) images.
- Set Color to Black (works now)
- Set Lum/Diff/Spec/Refl/Trans/Trans/Bump to 0% (works now)

So far I can reassign the basic Color and set it to Black and set the values of the Lum/Diff/Spec/Refl/Trans/Transl/Bump to 0%.

The next step I'm having trouble with is clearing the texture channel or the envelope channel.

I see an example on the LScrit docs on how to add a layer on a texture channel:
texObjCOLR = surfObj.getTexture(SURFCOLR);
if (texObjCOLR)
{
textObjCOLR.addLayer(TXTRIMAGE);
}
So I was trying textObjCOLR.setValue or something like that - but no luck.

Once I get that set, I can start working on the logic side to go through all the surfaces of the object.

Thanks for any advice,

So far the code looks like this:

@version 2.5
@warnings
@script generic

objName = "Ball_1m_Red_luminous";
surfName = "Default";
generic
{
// Create the Mesh Object Agent.
meshObj = Mesh(objName);
if(meshObj)
{
// Create the Surface Object Agent.
surfObj = Surface(surfName);
if(surfObj)
{

// Set Basic Values to 0 and Color to 0,0,0,
surfObj.setValue(SURFCOLR,<0,0,0>);
surfObj.setValue(SURFLUMI,0);
surfObj.setValue(SURFDIFF,0);
surfObj.setValue(SURFSPEC,0);
surfObj.setValue(SURFREFL,0);
surfObj.setValue(SURFTRAN,0);
surfObj.setValue(SURFTRNL,0);
surfObj.setValue(SURFBUMP,0);
}
else
error("This is not the ", surfName, " surface!");
}
else
error("This is not the ", objName, " object!");
}

Ciruja
04-13-2011, 10:35 PM
After a little more time looking at the thing, I could not get to reset texture panel to be Image Map with "none" selected for the Image. But, found out that by switching the Layer Type around, it basically gave me that result.

So, if Image Map had an image, I just switched it to procedural and back to Image Map using the texObjLyr.type = 1; and then texObjLyr.type = 0;
texObjLyr hold my Obj surface first Layer.

With a switch loop I got it to cycle through all the layers and set them to Image map.

It would be nice to find the LScript command to "remove Layer" or just simply uncheck the Texture Channel.