Author Topic: Entity System - Light rotation  (Read 3166 times)

Offline matty47

  • Mr. Drawsprite
  • **
  • Posts: 69
    • View Profile
    • Matt and Marg's Homesite
Entity System - Light rotation
« on: 2008-May-20 »
Hi, I have been playing with the Entity System code but am having trouble with the light direction. The lights are drawn in the following code
Code: GLBasic [Select]
X_SPOT_LT iLight, o.color, o.Mg[12], o.Mg[13], o.Mg[14], _
        o.Mg[12]+o.Mg[0], o.Mg[13]+o.Mg[1], o.Mg[14]+o.Mg[2], o.cutoff
and I know that the first three entries on the second line are supposed to give the vector of the light direction. Note that I have added a new field to the entity type (cutoff) with a couple of functions tha allow me to change the cutoff angle of the spotlight. My problem is that if I set the cutoff to say 45 to make a regular spotlight and then do an entity rotate in the main loop the light doesn't seem to rotate. I suspect this line as the camera uses the same code but with the camera you are specifying the point to which the camera is pointed whereas with the light I believe you are specifying a vector from the light (not a point). Before I go off writing separate light routines can anyone tell me the correct entries for the vector - or have I missed something again.
Thanks for any help
Matthew

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: Entity System - Light rotation
« Reply #1 on: 2008-May-20 »
The parameters int the 2nd line are the direction. Thus, you should write:
Code: GLBasic [Select]
X_SPOT_LT iLight, o.color, o.Mg[12], o.Mg[13], o.Mg[14], _
        o.Mg[0], o.Mg[1], o.Mg[2], o.cutoff
 
to get it working. Thanks a lot for using this functions and extending them!  :good:

Offline matty47

  • Mr. Drawsprite
  • **
  • Posts: 69
    • View Profile
    • Matt and Marg's Homesite
Re: Entity System - Light rotation
« Reply #2 on: 2008-May-20 »
Thanks mighty quick answer. Sort of fixed it I need to play with it some more.
Matthew