PDA

View Full Version : Set reflection options



Ulven
09-15-2011, 04:26 AM
I need to set the reflection options to backdrop only on a few hundred objects (I cannot just put raytraced reflections off because we need that still on other objects, but can't seem to find the lscript command to set this option for a surface. Does anyone know if this is possible / what the command would be?

Danner
09-15-2011, 07:26 AM
Select all surfaces you want to change then change the backdrop option.

Ulven
09-16-2011, 02:27 AM
It has to be an automatic solution, there are hundreds, maybe thousands of objects with multiple surfaces and many of them are too heavy for lightwave to keep all loaded at the same time, let alone to try to operate on manually.

iain_r
09-16-2011, 06:11 AM
Hi, the parameter that you need to change is in the Environment tab and is not available via lscript. You can access it through the SDK. You would still need some selection method to determine which surface would be backdrop only. In the SDK, lwsurf.h, it is defined as SURF_RFOP. The surface.html page has an example of getting this information.

Regards, Iain.

Blochi
09-16-2011, 12:44 PM
You can do it with CommandInput options.

CommandInput("Surf_SetInt ReflectionOptions 1");

The bummer is, you will have to set it blindly, but it should work.
Of course, that also means you will have to use means of CommandInput to first simulate a selection in Layout.

Even though it doesn't run as is (for obvious reasons), here is a code snippet that should get you on the way:



@version 2.5
@warnings
@script generic
objName = "Ball_A";
surfName = "TestSurf";
imgName = "Test.hdr";

generic
{
// load the image
refImage = Image();

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

if(surfObj)
{
// show reflection value:
info("Reflection value is ",surfObj.getValue(SURFREFL));

// set new reflection value using regular object agent method:
surfObj.setValue(SURFREFL, 0.5);

// show reflection value again:
info("Reflection value is now ",surfObj.getValue(SURFREFL));

// now set the reflection options to spherical map. This can only be reached by commandinput:

CommandInput("Surf_SetSurf \"" + surfName + "\" \"" + objName + "\"");
CommandInput("Surf_SetInt ReflectionOptions 2");

// as you see, we can read and change all surface stuff,
// and this is to test the reflection image now:

info(refImage.name, " has id ", refImage.id);


CommandInput("Surf_SetImage ReflectionImage " + refImage.id);

// even though it would be nicer to use the Object Agent. Feels more secure... but doesn't work

// surfObj.setValue(SURFRIMG, refImage.name);


}
else
error("This is not the ", surfName, " surface!");
}
else
error("This is not the ", objName, " object!");
}


Cheers,
Blochi