Surface Object Agents

 

The Surface() constructor can generate an Object Agent for an existing surface, or it can create a new surface for an object. The constructor can be called with no arguments, and the first surface defined in the system will be returned.

surfObj = Surface();

If the Surface() constructor is called with an integer value, it returns the surface in the system that corresponds to that index value.

surfObj = Surface(1);

When you provide a surface name, the constructor returns that surface if it is already defined in the system. If it does not exist, a 'nil' value is returned under Layout, and a new surface with that name is generated for the current object under Modeler.

surfName = Surface("Surface Name");

Provided a Mesh Object Agent, the constructor returns a list of the surface names defined for that object.

meshObj = Mesh("cow");

surfNames = Surface(meshObj);

Under Layout, you can create a new surface for an object. You provide the Mesh Object Agent to receive the surface as the first argument, and the name of the surface as the second argument.

meshObj = Mesh("cow");

surfNames = Surface(meshObj, "New Surface");

Constants

The following channel constants have been defined in LScript for use with the Surface Object Agent:

SURFCOLR           Base Color                       (vector)

SURFLUMI            Luminosity                       (number)

SURFDIFF            Diffuse                              (number)

SURFSPEC          Specularity                        (number)

SURFREFL           Reflectivity                        (number)

SURFTRAN           Transparency                      (number)

SURFTRNL           Translucency                   (number)

SURFRIND            IOR                                  (number)

SURFBUMP          Bump                               (number)

SURFGLOS          Glossiness                       (number)

SURFBUF1           Special Buffer 1                  (number)

SURFBUF2           Special Buffer 2                  (number)

SURFBUF3           Special Buffer 3                   (number)

SURFBUF4           Special Buffer 4                   (number)

SURFSHRP          Diffuse Sharpness                (number)

SURFSMAN         Smoothing Angle                 (degrees)

SURFRSAN         Reflection Seam Angle          (degrees)

SURFTSAN         Refraction Seam Angle          (degrees)

SURFRBLR         Reflection Blur                      (number)

SURFTBLR         Refraction Blur                      (number)

SURFCLRF         Color Filter                           (number)

SURFCLRH         Color Highlights                    (number)

SURFADTR         Additive Transparency           (number)

SURFAVAL         Alpha Value                         (number)

SURFGVAL         Glow Value                          (number)

SURFLCOL         Line Color                            (vector)

SURFLSIZ           Line Size                             (number)

SURFSIDE          Sidedness                           (integer)

SURFGLOW       Glow                                   (Boolean)

SURFLINE          Render Outlines                   (Boolean)

SURFRIMG         Reflection Image                  (Image OA)

SURFTIMG         Refraction Image                  (Image OA)

SURFVCOL        Vertex Coloring                    (number)

Data Members

name
name is the name of the surface.

Methods

getValue(channel)
getValue(channel) returns the specific value setting for the channel (whose type is defined above).

setValue(channel)
setValue(channel,value) sets the channel to the value given.

getEnvelope(channel)
getEnvelope(channel) returns the Envelope Object Agent associated with the specified channel. If no envelope exists, getEnvelope() will return ‘nil.’

getTexture(channel)
getTexture(channel) returns the Texture Object Agent associated with the specified channel. If no texture exists, getTexture() will return ‘nil.’

Example:

This example demonstrates using the Surface Object Agents. You must load the "objects/geography/genearth/earth.lwo" object from the LightWave content into Layout in order for this example to work properly.

@version 2.5
@warnings
@script generic

objName = "Earth";
surfName = "GlobeSurface";

generic
{
    // Create the Mesh Object Agent.
    meshObj = Mesh(objName);

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

     if(surfObj)
    {
         //Get some of the values.
         colr = surfObj.getValue(SURFCOLR);
         lumi = surfObj.getValue(SURFLUMI);
         diff = surfObj.getValue(SURFDIFF);
         spec = surfObj.getValue(SURFSPEC);
         refl = surfObj.getValue(SURFREFL);
         trans = surfObj.getValue(SURFTRAN);

          // Display whichever values you want here.

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

Layout Commands

Surf_SetSurf \surfacename\\meshname\ or Surf_SetSurf \surfacename
This sets the surface in layout to be edited, where surface name is a string, the name of the surface to be selected, and meshname is the name of the mesh which that surface is a part of.
Example:

Surf_SetSurf "surfacename" "meshname";

or in modeler:
mycommand="Surf_SetSurf \"surfname \" \"meshname\""; // the backslashes are needed to
CommandInput(mycommand); // keep the quote marks


Surf_SetInt channel integer
This sets the surface in layout to be edited. The channel is one of the below in string form (EG Luminosity, BaseColor) and the integer is one of 0 (base colour), 1(envelope) or 2(texture).