LDraw.org Discussion Forums

Full Version: Simple renderer in .net with SharpGL (openGL)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6
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.

LDrawObject with radius of bounding box = radiusbox

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?
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.
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:

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



        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))))

        '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


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

With the new lines each fov value between 1 and 90 will not destroy the view.
Pages: 1 2 3 4 5 6