Hi RTR,
Quote: "However, if you set (say) the X and Z values to be 1000 out of step with each other, set y# to 0 and then rotate both together you get a perfectly smooth rotation about the y-axis."
That is correct. That is why I was saying earlier the angle and the step value combined influence the direction of the light. Think of each of the step values as an influence (in the positive and negetive direction). The greater the step value for an individual ordinate (x y or z), the greater the influence towards the axis and direction. You don't really have to use the NEWXVALUE, NEWYVALUE, and NEWZVALUE - they just make it simple to get a new end point from a starting point. All you need are positive or negetive values for x, y and z. If you start with 0,1,0, that means the light is beaming straight up along y. 1,1,0 means a 45 degreangle towards the upper right (assuming you are looking down z). Now by increasing or decreasing the coordinates, you are in essence setting the direction of the light. The larger the number, the greater the influence along that particular axis.
I can see how this is a bit tricky. When I was talking about a vector, I was talking about a directional vector. If you are familiar with normals, that may help to conceptualize what I'm trying to say. A normal is the directional vector away from a polygon that light is "reflected". The step value of newxvalue, newyvalue, and newzvalue can be thought of as the outside of the radius from the initial value. In combination they make up the direction. Since a directional light is infinite, the size of the vector doesn't have influence on intensity (as it would with a normal), but slight variances in the step value of x y and z will alter the direction of the light somewhat. Even though that makes sense in my head, it sounds terrible the way I'm writing it.
A point in space takes at least to components to make a coordinate. If you want to identify a point in 2d, you have x and y. Each has to have a value in order to identify the point. They have to work together. Now, in 3d, you have three points that have to work together. I think your mistake is in that you are treating x,y and z as their own thing. Changing only the x value will not make a rotation around the x axis. The same goes for y and z. You have to treat them as friends and they all have to work together in a common way. A rotation around the x axis is determined by a change in the y coordinate and the z coordinate. The angle that this change influences is the x angle.
A rotation around y is determined by a change in the x coordinate and the z coordinate. The angle here is the y angle.
So what about around z? You guessed it x and y and the angle is z.
So if you want to change the rotation of the directional light, and you want to do it interms of an angle you have to change the proper coordinates and angle. It will always be at least in pairs.
But again, just changeing the coordinate values will change the direction. I rewrote the example so that you could change the rotation using the keyboard. However, I did run into problems using the NEWVALUE functions when it came to the z axis. I used a little trig to solve that.
[EDIT]
In my estimation, there seems to be a problem with the NEWYVALUE function in relation to the NEWXVALUE fucntion. The relationship between the two should be 90 degrees, but the values returned are at 180 which would cause a problem with rotation around the z axis. This can be solved in a couple of different ways, one way is to use trig, the other is just to add 90 degrees to the angle in NEWYVALUE if x and y are using the same angle (the angle around z axis). This 180 offset probably has to do with Euler angles but at any rate it's easy enough to solve by adding 90 degrees. I removed the trig and used the NEWYVALUE function in the example - also I forgot to mention all directions are realtive to the origin (0,0,0)
Anyway here's the updated example. You'll notice a bit of a jump when you switch axis. I didn't compensate for changing angles between the same axis so the coordinate values can change suddenly. I've written enough for now and the example should still show you how the method works:
[EDIT]
rem rotating directional light example
rem by latch 06/15/2007
rem Modified by Robert The Robot 06/16/07
rem Modified by latch 06/17/2007
sync on
sync rate 60
hide mouse
autocam off
rem make spheres that we'll watch the lighting effect on
make object sphere 1,50
position camera 0,50,-200
make object sphere 2,50
position object 2,150,100,50
make object sphere 3,50
position object 3,-45,75,-100
rem make a directional light
make light 1
set directional light 1,0,-1,0
set ambient light 0
color light 0,0
color backdrop 0
ink rgb(0,255,0),0
rem start loop to move light around
do
rem let's rotate around the y axis.
rem for this we need a change in x and z
if rightkey()=1 or leftkey()=1
if rightkey()=1 then yang#=wrapvalue(yang#-1)
if leftkey()=1 then yang#=wrapvalue(yang#+1)
x#=newxvalue(0,yang#,1000)
z#=newzvalue(0,yang#,1000)
endif
rem let's rotate around the x axis
if upkey()=1 or downkey()=1
if upkey()=1 then xang#=wrapvalue(xang#+1)
if downkey()=1 then xang#=wrapvalue(xang#-1)
y#=newyvalue(0,xang#,1000)
z#=newzvalue(0,xang#,1000)
endif
rem let's rotate around the z axis
if shiftkey()=1 or controlkey()=1
if shiftkey()=1 then zang#=wrapvalue(zang#+1)
if controlkey()=1 then zang#=wrapvalue(zang#-1)
x#=newxvalue(0,zang#,1000)
y#=newyvalue(0,zang#+90,1000)
endif
set directional light 1,x#,y#,z#
text 0,0,"x = "+str$(x#)
text 0,20,"y = "+str$(y#)
text 0,40,"z = "+str$(z#)
sync
loop
Enjoy your day.