1

嗨,我创建了一个简单的项目来展示一些小 qube,现在我尝试插入光,我尝试了一些在线创建的示例,但现在我只能“切换”点亮每个软件的强光或 Z 方向上的一点光我无法移动光的位置。

这是我的代码:

    GL.Clear(ClearBufferMask.ColorBufferBit)
    GL.Clear(ClearBufferMask.DepthBufferBit)

    Dim perspective As Matrix4

    Dim xmin As Single = -200
    Dim ymin As Single = -200
    Dim xmax As Single = 300
    Dim ymax As Single = 300
    Dim size As Single = xmax - xmin
    Dim rate As Single = GlControl1.Width / GlControl1.Height

    ymax = ymin + (size / rate)

    perspective = Matrix4.CreateOrthographicOffCenter(xmin, xmax, ymin, ymax, -1000, 1000)


    'Perspective
    GL.MatrixMode(MatrixMode.Projection) 'load the camera
    GL.LoadIdentity()
    GL.LoadMatrix(perspective)

    GL.Viewport(0, 0, GlControl1.Width, GlControl1.Height)
    GL.Enable(EnableCap.DepthTest)
    GL.DepthFunc(DepthFunction.Less)


    GL.Enable(EnableCap.ColorMaterial)
    GL.Enable(EnableCap.Lighting)
    GL.Enable(EnableCap.Light0)

    Dim cl0() As Single = {NumericUpDown4.Value, NumericUpDown5.Value, NumericUpDown6.Value, NumericUpDown7.Value}
    GL.Light(LightName.Light0, LightParameter.Position, cl0)




    GL.Rotate(NumericUpDown3.Value, New Vector3(1, 0, 0)) 'asse X
    GL.Rotate(NumericUpDown2.Value, New Vector3(0, 1, 0)) 'asse Y
    GL.Rotate(NumericUpDown1.Value, New Vector3(0, 0, 1)) 'asse Z

    For x = -100 To 100 Step 20
        For y = -100 To 100 Step 20
            For z = -100 To 100 Step 20
                drawCube(x, y, z, 5)
            Next
        Next
    Next


    'Finally..................
    GraphicsContext.CurrentContext.VSync = True ' to syncronize with the GPU ability
    GlControl1.SwapBuffers() 'takes from GL and put to control
    GlControl1.Invalidate()

我只在 cl0 数组上获得了 #3 和 #4 值的变化,例如:如果 cl0 数组是 (0,0,1,0) 我得到这个: 0010 如果 cl0 数组是 (0,0,0,1 ) 或 (0,0,1,1) 我得到这个: 0001

我也尝试了许多其他价值,但没有任何改变。如何设置光的 X、Y、Z 位置?还有,我怎样才能开始阴影?

4

0 回答 0