Surface FunctionsAvailability LightWave® 6.0 This global allows you to get information about surfaces and surface parameters. Global Call LWSurfaceFuncs *surff; surff = global( LWSURFACEFUNCS_GLOBAL, GFUSE_TRANSIENT ); The global function returns a pointer to an LWSurfaceFuncs. typedef struct st_LWSurfaceFuncs {
LWSurfaceID (*create) (const char *objName,
const char *surfName);
LWSurfaceID (*first) (void);
LWSurfaceID (*next) (LWSurfaceID);
LWSurfaceID * (*byName) (const char *name, const char *obj);
LWSurfaceID * (*byObject) (const char *name);
const char * (*name) (LWSurfaceID);
const char * (*sceneObject) (LWSurfaceID);
int (*getInt) (LWSurfaceID, const char *channel);
double * (*getFlt) (LWSurfaceID, const char *channel);
LWEnvelopeID (*getEnv) (LWSurfaceID, const char *channel);
LWTextureID (*getTex) (LWSurfaceID, const char *channel);
LWImageID (*getImg) (LWSurfaceID, const char *channel);
LWChanGroupID (*chanGrp) (LWSurfaceID);
const char * (*getColorVMap)(LWSurfaceID surf);
void (*setColorVMap)(LWSurfaceID surf,
const char *vmapName, int type);
} LWSurfaceFuncs;
Example The scenscan SDK sample includes a getObjectSurfs function that collects surface information for all of an object's surfaces. For some parameters, you'll want to consult the object file format specification, since the form of the data returned by the get functions is in some cases the same as its binary image in the object file. This code fragment reads and interprets the reflection options. #include <lwserver.h>
#include <lwsurf.h>
LWSurfaceFuncs *surff;
LWSurfaceID surfid;
LWImageID rimg;
double refl, rsan, *dval;
int rfop;
... assume surff and surfid have been initialized ...
dval = surff->getFlt( surfid, SURF_REFL ); // reflectivity
refl = *dval;
if ( refl > 0.0f ) {
rfop = surff->getInt( surfid, SURF_RFOP ); // options
switch ( rfop ) {
case 0: /* backdrop only */ ... break;
case 1: /* raytrace + backdrop */ ... break;
case 2: /* spherical map */ ... break;
case 3: /* raytrace + map */ ... break;
}
if ( rfop == 2 || rfop == 3 ) {
rimg = surff->getImg( surfid, SURF_RIMG ); // image map
dval = surff->getFlt( surfid, SURF_RSAN ); // seam angle
rsan = *dval;
}
}
|