Henrik Lind (hlind++at++bvu-lads.loral.com)
Wed, 30 Aug 1995 14:39:13 -0700 (PDT)
Thanks,
Henrik Lind
-------------------------------------------------------------------
/* INITIALIZATION */
{
pfScene* scene;
pfLightSource* lSource;
char lsName[10];
int i;
pfLightModel* lm;
/* Initialize light source node names */
strcpy(lsName, "G_lightx");
/* Get light source group */
scene = pfFindScene("G_scene");
if (scene == NULL)
{
fprintf(stderr, "G_scene not found!\n");
exit(-1);
}
G_lights = pfNewGroup();
if (G_lights == NULL)
{
fprintf(stderr, "G_lights not created!\n");
exit(-1);
}
pfNodeName(G_lights, "G_lights");
pfAddChild(scene, G_lights);
/* Allocate MAXLIGHTS light sources, naming them G_light0 - G_lightn. */
for (i = 0; i < MAXLIGHTS; i++)
{
lSource = pfNewLSource();
if (lSource == NULL)
{
fprintf(stderr, "unable to alloc light source %d\n", i);
exit(-1);
}
pfSpotLightDir(lSource, 0.0f, 0.0f, -1.0f);
pfSpotLightCone(lSource, 4.0f, 45.0f);
pfLightColor(lSource, 1.0f, 1.0f, 1.0f);
pfLightPos(lSource, 0.0f, 0.0f, 0.0f, 1.0f);
pfLightOff(lSource);
lsName[7] = (char)(i + (int)'0');
pfNodeName(lSource, lsName);
pfAddChild(G_lights, lSource);
}
}
-------------------------------------------------------------------
At run time, a flare is bound to a light source by:
for (i = 0; i < MAXLIGHTS; i++)
{
lSource = (pfLightSource*) pfGetChild(Glights, i);
if (pfIsLightOn(lSource)) ;
else
{
pfLightColor(lSource, r, g, b);
pfLightPos(lSource, x, y, z, 1.0f);
pfPushIdentMatrix();
pfSpotLightDir(lSource, 0.0f, 0.0f, -1.0f);
pfSpotLightCone(lSource, 0.0f, 90.0f);
pfLightOn(lSource);
pfPopMatrix();
break;
}
}
-------------------------------------------------------------------
The position of a flare is updated by:
{
/* Change flare position */
pfLightPos(lSource, x, y, z, 1.0f);
pfPushIdentMatrix();
pfLightOn(lSource);
pfPopMatrix();
}
-------------------------------------------------------------------
Finally, a flare is turned off simply by:
pfLightOff(lSource);
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:51:51 PDT