Simple renderer in .net with SharpGL (openGL)


Re: Simple renderer in .net with SharpGL (openGL)
#51
I really appreciate your comments and ideas. But I like to stay with visual basic Smile

Maybe we can solve the issues that I have by simplyfying the context.

Given:
LDrawObject with radius of bounding box = radiusbox

Result:
Code in pure openGL, where the LDrawObject is drawn with a function called DrawLDrawObject()
DrawLDrawObject() only uses the colors and vertices just from the files.

So there needs to be code for the world and for the modelview that i am looking for.

Anybody out there who can help and post his (working) code here?
Reply
Re: Simple renderer in .net with SharpGL (openGL)
#52
You need to drop the gl.frustum call, it's an alternative to gl.perspective. In this setup it's applying both projections I think.

And like Travis wrote you might have to push the whole scene a bit back to compensate for the near plane.
Reply
Re: Simple renderer in .net with SharpGL (openGL)
#53
Thanks to all that gave input in this case Smile
Finally I got it to work (mostly wrong thinking in 3D was the error).

The last code is now:

Code:
Dim gl As New SharpGL.OpenGL
        gl = Me.OpenGLControl2.OpenGL

        gl.Clear(GL_COLOR_BUFFER_BIT Or GL_DEPTH_BUFFER_BIT)

        gl.MatrixMode(SharpGL.Enumerations.MatrixMode.Projection)
        gl.LoadIdentity()

        gl.Viewport(0, 0, OpenGLControl2.Width, OpenGLControl2.Height)

        [s]gl.Perspective(CDbl(dblFOVgrad), CDbl(OpenGLControl2.Width / OpenGLControl2.Height), CDbl(0.1), CDbl(gradiusOfBoundingbox * 5))[/s]
        gl.Perspective(CDbl(dblFOVgrad), CDbl(OpenGLControl2.Width / OpenGLControl2.Height), CDbl(0.1), CDbl(gradiusOfBoundingbox + (gradiusOfBoundingbox / Math.Sin(dblFOVradian / 2))))
        gl.MatrixMode(SharpGL.Enumerations.MatrixMode.Modelview)
        gl.LoadIdentity()

        'to see direct to the bounding box middle and push it back
        [s]gl.Translate(CSng(gmiddleofBoundingbox.X), CSng(gmiddleofBoundingbox.Y), CSng(-2 * gradiusOfBoundingbox))[/s]
        gl.Translate(CSng(gmiddleofBoundingbox.X), CSng(gmiddleofBoundingbox.Y), CSng(-1 * (gradiusOfBoundingbox / Math.Sin(dblFOVradian / 2))))

        gl.Rotate(180.0F, 0.0F, 0.0F)                     'correct -y
        gl.Rotate(45.0F, 0.0F, 1.0F, 0.0F)               'turn to see half of side
        gl.Rotate(22.5, 1, 0, 1)                              'turn to see a little bit from top
        DrawLines(gl)

        gl.Flush()

This code should work on all parts, as the dimensions of the parts are used for the values. I still need to test this, but I do not expect strange results.

After that I need to enhence the quality of the shown picture. I'll shurely come back with some questions. Smile

Edit:
With the new lines each fov value between 1 and 90 will not destroy the view.
Reply
« Next Oldest | Next Newest »



Forum Jump:


Users browsing this thread: 1 Guest(s)