0

クリッピング/表示に問題があるかどうかわからない

Windowsフォームで(四角形ではなく線の)長方形のボックスを回転および拡大縮小しようとしているだけです(OpenTKを使用)これは十分に単純ですが、線の一部をズーム/拡大縮小すると、クリップされるべきではないときにクリップされます

カメラを動かす代わりに、遠近法や奥行きの範囲など、見た目、描画の拡大縮小などを試してみました。しかし、希望する動作が得られないようです。

問題のビデオ: http ://www.youtube.com/watch?v = sDV4_LKOgVc&feature = youtu.be

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
4

2 に答える 2

0

のようなものを使用している場合は、が正でゼロ以外であるgluPerspective()ことを確認してください。zNear

于 2013-01-28T20:26:31.830 に答える
0

私はそれを考え出した。私はそれを正しかったが、OpenTK はパースペクティブをそのように宣言することを望んでいる

薄暗いパースペクティブ1 As Matrix4 = OpenTK.Matrix4.CreatePerspectiveFieldOfView(MathHelper.PiOver4, _CSng((GlControl1.Width) / (GlControl1.Height)), 0.1, 1000)

GL.LoadMatrix(perspective1)

奇妙に思えます。45.0f の代わりに MathHelper.PiOver4 を使用すると問題が解決しました

于 2013-01-29T19:12:04.210 に答える