万卷书   首页 > 电脑书籍 > Director > Director 3D 基础(之六)
 
以下的事件设定演员的directionalPreset , directionalColor , and ambientColor属性。这些是用于修饰“scene”的灯光的。

on prepareLightAndCamera
member(‘‘scene‘‘).directionalPreset = #bottomLeft
member(‘‘scene‘‘).directionalColor = rgb(255, 255, 255)
member(‘‘scene‘‘).ambientColor = rgb(255, 255, 255)

这些代码移动摄像机到新的模型的位置:

member(‘‘scene‘‘).camera[1].transform.position = vector(266, 0, 300)
member(‘‘scene‘‘).camera[1].transform.rotation = vector(0, 0, 0)

end

以下的事件应用shLines材质球于一半的字母。注意到shLines材质球仅仅应用于材质球列表中的奇数条;shMetal材质球将显示于其它字母。这儿利用了mod函数,这儿是用来除以2,得到的余数是1或者0。

on addLinesToHalf
if member(‘‘scene‘‘).model(‘‘3dText‘‘).voidP then exit
repeat with x = 1 to member(‘‘scene‘‘).model(‘‘3dText‘‘).shaderList.count
if x mod 2 = 1 then -- if x is an odd number
member(‘‘scene‘‘).model(‘‘3dText‘‘).shaderList[x] =
member(‘‘scene‘‘).shader(‘‘shLines‘‘)
else
member(‘‘scene‘‘).model(‘‘3dText‘‘).shaderList[x] =
member(‘‘scene‘‘).shader(‘‘shMetal‘‘)
end if

end repeat
end

以下的事件指派shLines材质球于所有的字母:

on addLinesToAll
if member(‘‘scene‘‘).model(‘‘3dText‘‘).voidP then exit
repeat with x = 1 to member(‘‘scene‘‘).model(‘‘3dText‘‘).shaderList.count

member(‘‘scene‘‘).model(‘‘3dText‘‘).shaderList[x] = member(‘‘scene‘‘).shader(‘‘shLines‘‘)

end repeat

end

 
上一页