Edit!!! Reject this - I completely forgot about the "set normalization on" command which solves the problem.
I seem to be having a bad evening.
Original post follows:
An old problem reported on the following thread has either been reintroduced or never been corrected.
How do you avoid 'white-out' when scaling an object?
The following simple variation of IanM's code from that thread shows the problem clearly: press the up/down keys and the lighting changes whereas it shouldn't with the default directional light:
sync on
sync rate 60
scale# = 1.0
make object sphere 1, 100
do
if upkey() then inc scale#, 0.2
if downkey() then if scale# > 1.0 then dec scale#,0.2
set cursor 0, 0
print "Scale = "; scale#
set camera range scale#, scale# * 200
scale object 1, scale# * 100.0, scale# * 100.0, scale# * 100.0
position camera 0.0, 0.0, scale#*-200.0
point camera 0.0, 0.0, 0.0
sync
loop
Here's another snippet which shows three spheres side by side: the centre one is unscaled (lit correctly), the left and right-hand ones have been scaled by 10% and 1000% respectively (both lit incorrectly). They should all be identically lit. The text at the top shows that the normals are correct. I suspect the world matrix has been used incorrectly in the lighting calculation.
set display mode desktop width(), desktop height(), 32
sync on: sync rate 60: sync
autocam off
position camera 0, 50, -300
point camera 0, 0, 0
make object sphere 1, 50
position object 1, 0, 0, 0
make object sphere 2, 5
position object 2, 50, 0, 0
scale object 2, 1000, 1000, 1000
make object sphere 3, 500
position object 3, -50, 0, 0
scale object 3, 10, 10, 10
global cx#
global cy#
cx# = camera angle x()
cy# = camera angle y()
type normal
x as float
y as float
z as float
endtype
dim model(3) as normal
for obj = 1 to 3
lock vertexdata for limb obj, 0
model(obj).x = get vertexdata normals x(44)
model(obj).y = get vertexdata normals y(44)
model(obj).z = get vertexdata normals z(44)
unlock vertexdata
next obj
repeat
set cursor 0, 20
for obj = 1 to 3
print " obj= ", obj, " normal = ", model(obj).x, " ", model(obj).y, " ", model(obj).z
next obj
positionCamera()
sync
until spacekey()
end
function positionCamera()
control camera using arrowkeys 0, 1, 0
cx# = cx# + mousemovey()*0.25: cy# = cy# + mousemovex()*0.25
rotate camera cx#, cy#, 0
endfunction