Scott McMillan (scott++at++ht.com)
Wed, 10 Apr 1996 17:15:54 -0400 (EDT)
// set up the headlight - this is the only real light in the scene
ViewState->headlight = new pfLightSource();
// make it a local light source - set at orgin for now
ViewState->headlight->setPos(0.0f,0.0f,0.0f,1.0f);
scene->addChild(ViewState->headlight);
to initialize the light. The code that updates the view gets an eye point
(eye) a lookat point (lookat) and an up point. After computing the new
view matrix from these, I tried this approach:
ViewState->headlight->setPos(eye[PF_X],eye[PF_Y],eye[PF_Z],1.0f);
ViewState->headlight->setSpotDir(lookat[PF_X],lookat[PF_Y],lookat[PF_Z]);
ViewState->headlight->setSpotCone(5.0f,55.0f);
to move the light to the new pose.
This did not work. The view pose works flawlessly, but the light remained
at the origin (I saw it as I flew past).
I then tried this idea for the move:
ViewState->headlight->setPos(eye[PF_X],eye[PF_Y],eye[PF_Z],1.0f);
pfPushIdentMatrix();
ViewState->headlight->setSpotDir(lookat[PF_X],lookat[PF_Y],lookat[PF_Z]);
ViewState->headlight->setSpotCone(5.0f,90.0f);
ViewState->headlight->on();
pfPopMatrix();
which also had no effect on the position or orientation. So I attempted to
ensure that the light was not being culled by doing the following in the
initialization stage:
/* set a large empty sphere for the bounding sphere of the light,
keeping it from being culled
*/
pfSphere * sph = new pfSphere();
sph->makeEmpty();
sph->radius = (float)PF_HUGEVAL;
ViewState->headlight->setBound(sph,PFBOUND_STATIC);
which again had no effect.
My question is has anyone done this who would be willing to share code? Am I
on the right track (and just have some small error), am I on a totally wrong
track or is it a case of "this should work" and therefore there must be
something else in my application which is causing the problem? Any help would
be greatly appreciated.
Thanks in advance,
--Paul Sherman
Please CC responses to paul++at++ht.com as well...thanks.
-- Scott McMillan / scott++at++ht.com / (301)984-3706 x250 / FAX (301)984-2104 High Techsplanations Inc. 6001 Montrose Road, Suite 902 / Rockville, MD 20852-4874
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:42 PDT