Perry McDowell (mcdowell++at++cs.nps.navy.mil)
Wed, 12 Oct 94 22:32:59 PDT
I am writting an application for an architectural walkthrough. I have a
database in .flt format which I can walk through using a modified gui
from Perfly. I am trying to add a feature which would simulate the user
holding a flashlight to illuminate the scene, but it is has several
problems:
1) The doors have windows in them, and when the window is visible in what
would be the peripherial vision of the user, it is illuminated far beyond
what it should be from the flashlight (which is the only light present).
As I continue turning, the other room will go dark, as it should be.
2) Often the entire scene will go dark as the user's viewpoint is
translated or rotated. The user's viewpoint is such that a large portion
of the scene should be visible from the flashlight, but the entire scene
is dark.
3) Close to number 2), omnidirectional lights in hallways will illuminate
three of the four walls, although there is no obvious reason why the fourth
should not be illuminated.
4) When time of day is increased to daylight, the entire database is visible
as it should be in good lighting, even though many of the rooms have no windows
for light to enter from the outside.
5) When the pitch of the user's viewpoint is raised/lowered to +/-90,
no light appears on the floor/ceiling, even though debug statements indicate
that the light is directed correctly.
I have user MultiGen to ensure that all the walls have alpha values of
1.0, and high values for ambient, diffuse and spectural reflections.
I am running Performer 1.2 on an ONYX/4 (100MHZ) RE2.
Any help would be greatly appreciated.
Perry McDowell
mcdowell++at++cs.nps.navy.mil
My code is as follows:
Flashlight is declared in env.c:
/* Initialize flashlight */
ViewState->flash = pfNewLSource();
pfLightColor(ViewState->flash, 1.0f, 1.0f, 1.0f);
pfSpotLightCone(ViewState->flash, ViewState->exponent, ViewState->spread);
pfSpotLightDir(ViewState->flash, 0.0f, 0.0f, 1.0f);
pfAddChild(ViewState->scene, ViewState->flash);
/* Initialize sun */
ViewState->sun = pfNewLSource();
pfAddChild(ViewState->scene, ViewState->sun);
View position/direction is updated in walk.c
case PFUXF_DRIVE:
pfuGetXformerCoord(ViewState->xformer, &ViewState->viewCoord);
pfuGetXformerMat(ViewState->xformer, mat);
if (NumFiles == 0)
{
ViewState->viewCoord.xyz[2] = ViewState->height;
ViewState->viewCoord.hpr[1] = ViewState->pitch;
pfLightPos(ViewState->flash, (ViewState->viewCoord.xyz[0] - 1.0f), (ViewState->viewCoord.xyz[1]- 1.0f), ViewState->viewCoord.xyz[2], 1.0f);
getScrewView(&screwViewX, &screwViewY, &screwViewZ);
pfSpotLightDir(ViewState->flash, screwViewX, screwViewY, screwViewZ);
if (DEBUG)
{
pfGetLightPos(ViewState->flash, &lightX, &lightY, &lightZ, &lightW);
printf ("\nLight position: X= %f, Y= %f, Z=%f, W= %f\n", lightX, lightY, lightZ, lightW);
printf ("View Position: X= %f, Y= %f, Z=%f\n", ViewState->viewCoord.xyz[0], ViewState->viewCoord.xyz[1], ViewState->viewCoord.xyz[2]);
pfGetSpotLightDir(ViewState->flash, &dirX, &dirY, &dirZ);
printf ("Light direction: X= %f, Y= %f, Z=%f\n", dirX, dirY, dirZ);
printf ("View HPR: H= %f, P= %f, R=%f\n", ViewState->viewCoord.hpr[0], ViewState->viewCoord.hpr[1], ViewState->viewCoord.hpr[2]);
pfGetSpotLightCone(ViewState->flash, &exp, &spread);
printf ("Light cone: Exp= %f, Spread= %f\n", exp, spread);
printf("DRIVE\n\n");
}
pfLightOn(ViewState->flash);
pfChanView(chan, ViewState->viewCoord.xyz, ViewState->viewCoord.hpr);
}
(NOTE: CODE for all other cases is identical.)
Spread/exponent of spotlight can be changed by a slider in gui.c
/* Slider for Spread of Light */
wid = pfuNewWidget(panel, PFUGUI_SLIDER, GUI_SPR);
pfuWidgetDim(wid, x, y, xSize, ySize);
pfuWidgetLabel(wid, "Angle of Light");
pfuWidgetRange(wid, 90.0f, 0.0f, 90.0f, ViewState->spread);
pfuWidgetFunc(wid, controlPanel);
ViewState->guiWidgets[GUI_SPR] = wid;
y-= ySize;
/* Slider for Exponent of light */
wid = pfuNewWidget(panel, PFUGUI_SLIDER, GUI_EXP);
pfuWidgetDim(wid, x, y, xSize, ySize);
pfuWidgetLabel(wid, "Diffuseness");
pfuWidgetRange(wid, 100.0f, 0.0f, 100.0f, ViewState->exponent);
pfuWidgetFunc(wid, controlPanel);
ViewState->guiWidgets[GUI_EXP] = wid;
case GUI_SPR:
ViewState->spread= pfuGetWidgetValue(w);
pfSpotLightCone(ViewState->flash, ViewState->exponent, ViewState->spread);
pfLightOn(ViewState->flash);
break;
case GUI_EXP:
ViewState->exponent= pfuGetWidgetValue(w);
pfSpotLightCone(ViewState->flash, ViewState->exponent, ViewState->spread);
pfLightOn(ViewState->flash);
break;
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:35 PDT