Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
OpenGL剪辑、深度和相机_Opengl_Camera_Clipping_Depth_Opentk - Fatal编程技术网

OpenGL剪辑、深度和相机

OpenGL剪辑、深度和相机,opengl,camera,clipping,depth,opentk,Opengl,Camera,Clipping,Depth,Opentk,剪辑/查看有问题不确定 我只是想在windows窗体(使用OpenTK)中旋转和缩放一个矩形框(线不是四边形) 这很简单,但当我缩放线条的部分时,它们会在不应该的时候被剪裁 试着玩透视和深度范围等,以及看,缩放绘图,而不是移动相机等,但我似乎无法得到我想要的行为 问题视频: 如果您使用的是类似的任何东西,请确保zNear为正且不为零。我已经找到了答案。我说得对,但OpenTK希望您像这样声明透视图 Dim perspective1作为Matrix4=OpenTK.Matrix4.Create

剪辑/查看有问题不确定

我只是想在windows窗体(使用OpenTK)中旋转和缩放一个矩形框(线不是四边形) 这很简单,但当我缩放线条的部分时,它们会在不应该的时候被剪裁

试着玩透视和深度范围等,以及看,缩放绘图,而不是移动相机等,但我似乎无法得到我想要的行为

问题视频:



如果您使用的是类似的任何东西,请确保
zNear
为正且不为零。

我已经找到了答案。我说得对,但OpenTK希望您像这样声明透视图

Dim perspective1作为Matrix4=OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4,_CSng((GlControl1.Width)/(GlControl1.Height)),0.11000)

总帐负荷矩阵(透视图1)


这似乎很奇怪。使用MathHelper.PiOver4而不是45.0f解决了问题

您似乎没有在任何地方设置投影矩阵。
Private Sub GlControl1_Paint(sender As Object, e As PaintEventArgs) Handles GlControl1.Paint
    If (_STARTED = False) Then Return

    'Set Up
    GL.Clear(ClearBufferMask.ColorBufferBit)
    GL.Clear(ClearBufferMask.DepthBufferBit)


    Dim eye = New Vector3(cam_x, cam_y, cam_z)
    Dim lookat = New Vector3(cam_x - Pan_X / GlControl1.Width, cam_y - pan_Y / GlControl1.Height, cam_z + look_z)
    Dim camera = Matrix4.LookAt(eye, lookat, Vector3.UnitY)

    TextBox1.Text = cam_x.ToString + ", " + cam_y.ToString + ", " + cam_z.ToString
    GL.MatrixMode(MatrixMode.Modelview)

    GL.LoadIdentity()
    GL.LoadMatrix(camera)


    'Draw Items

    'Perform panning action
    'Applies to all items in GL window
    GL.Translate(Pan_X / GlControl1.Width, pan_Y / GlControl1.Height, 0.0)

    'Initial View Angle
    'GL.Rotate(45, 1.0, 1.0, 0.0)

    If show_axes Then draw_axes()


    GL.PushMatrix() 'Save matrix

    'Perform rotations
    GL.Rotate(CType(_Part.XRotation, Single), 1.0F, 0.0F, 0.0F)
    GL.Rotate(CType(_Part.YRotation, Single), 0.0F, 1.0F, 0.0F)
    GL.Rotate(CType(_Part.ZRotation, Single), 0.0F, 0.0F, 1.0F)

    'Resize
    'GL.Scale(Zoom, Zoom, Zoom)

    GL.PushMatrix() ' Save Matrix for center translation
    GL.Translate(-_Part.Length / 2, -_Part.Thickness / 2, _Part.Width / 2)   'Center Object

    'Draw the box
    draw_object(CSng(_Part.Length), CSng(_Part.Width), CSng(_Part.Thickness))


    GL.PopMatrix()


    GlControl1.SwapBuffers()

End Sub
    Private Sub GlControl1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
    If e.Delta > 0 Then
        'Zoom = CSng(Zoom + Zoom_inc)
        cam_z -= cam_inc
    Else
        'Zoom = CSng(Zoom - Zoom_inc)
        cam_z += cam_inc
    End If
    GlControl1.Invalidate()
End Sub