View Single Post
  #3  
Old 08-21-2008, 01:49 PM
michaelrepucci michaelrepucci is offline
Member
 
Join Date: Jul 2008
Posts: 53
Okay. One annoying undocumented bug down. I'm getting other strange effects too.

Firstly, based on my initial tests, the setting viz.lightModel.twoSided (default=0) seems to imply 0="make the back look just like the front" and 1="make the back respond realistically to light". Consider the following code:
Code:
headLight = viz.MainView.getHeadLight()
headLight.disable()
myLight = viz.addLight()
myLight.enable()
myLight.position(0,1,0,0) #make a "sun"
myLight.spread(180)
myLight.intensity(1)
myLight.color(viz.WHITE)

viz.startlayer(viz.QUADS)
viz.vertexcolor(0.8,0.4,0.4)
viz.normal(0,0,-1)
viz.vertex([1,1,0])
viz.vertex([-1,1,0])
viz.vertex([-1,-1,0])
viz.vertex([1,-1,0])
obj = viz.endlayer() #make square in the XY plane at Z=0
obj.setEuler(0,30,0)
obj.setPosition(0,0,1)
obj.enable(viz.LIGHTING)
With viz.lightModel.twoSided=0 both sides look pink, but with viz.lightModel.twoSided=1 the top side looks pink, while the bottom side is darker. What is really odd is that if I draw a disc with:
Code:
viz.startlayer(viz.POLYGON)
viz.vertexcolor(0.8,0.4,0.4)
viz.normal(0,0,-1)
for i in range(32):
	radians = 2*math.pi*i/32
	viz.vertex([0.1*math.sin(radians),0.1*math.cos(radians),0])
	viz.vertex([0.1*math.sin(radians),0.1*math.cos(radians),0])
obj = viz.endlayer()
and do the same thing as above, the bright and dark faces seem to get swapped. Both the square and the disk are drawn counter-clockwise, and have the same normals, so what gives?

When I start grouping these objects together, and setting the color for the group, then the dark sides get even darker. I now think I understand that this is because the bug described above. Please correct me if I'm wrong.
Reply With Quote