Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Need Help rendering

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2004
    Posts
    3

    Need Help rendering

    i lost where my topic was so here is a new one.
    I am trying to render a 3d object on a 2d plane in VB. i dont care about speed, i just want to learn how to do it.

    i have a base app running. it will display a cube(was tryin to draw out a large map...but i decided to downsize to a cube for now) however, the cube is in the incorrect perspective.

    here is my code to update the camera:
    Code :
    camera.magxy = Sqr((width / 2) ^ 2 + (height / 2) ^ 2)
        camera.magxz = Sqr((width / 2) ^ 2 + (getHighestpoint() + 10) ^ 2)
        camera.x = camera.magxy * Cos((camera.yaw * (pi / 180)))
        camera.y = camera.magxy * Sin((camera.yaw * (pi / 180)))
        camera.z = camera.magxz * Sin((camera.pitch * (pi / 180)))
    camera is a vector i made. my vectors have an x,y,z, a pitch, a yaw, and a magnitude for the xy plane and the xz plane.
    width is the width of the object
    height is the height of the object

    here is my code to diplay the cube
    this section is told by the rest of my code to draw a line from paint a, to point b
    Code :
    'second attempt
        If cz - z1 = 0 Then z1 = z1 + 1     'prevent division by zero
        mx1 = Sqr((cx - x1) ^ 2 + (cz - z1) ^ 2) * Cos(Atn((cx - x1) / (cz - z1)) * (pi / 180))
        my1 = Sqr((cy - y1) ^ 2 + (cz - z1) ^ 2) * Cos(Atn((cy - y1) / (cz - z1)) * (pi / 180))
        If cz - z2 = 0 Then z2 = z2 + 1     'prevent division by zero
        mx2 = Sqr((cx - x2) ^ 2 + (cz - z2) ^ 2) * Cos(Atn((cx - x2) / (cz - z2)) * (pi / 180))
        my2 = Sqr((cy - y2) ^ 2 + (cz - z2) ^ 2) * Cos(Atn((cy - y2) / (cz - z2)) * (pi / 180))
     
        'resolution will be (screen width of height)/radius
        mx1 = mx1 * (9615 / radius)
        my1 = my1 * (9615 / radius)
        mx2 = mx2 * (9615 / radius)
        my2 = my2 * (9615 / radius)
        Line (mx1, my1)-(mx2, my2)
    as it says this is my second approach to rendering.
    the last block of code i use to simply fit the object dynamically in the window.

    any help PLEASE!!!! this code will draw the cube, but out of perspective, what am i doing wrong?

  2. #2
    Member Regular Contributor
    Join Date
    Aug 2003
    Posts
    370

    Re: Need Help rendering

    Haven't seen your previous posts but have you set your projection matrix like: (excuse c syntax but I'm not much good in VB)
    Code :
    glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(// look up the specification for the values);
    glMatrixMode(GL_MODELVIEW);
    I don't know much about camera systems but maybe this helped.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2004
    Posts
    3

    Re: Need Help rendering

    i dont mind c, how ever i am trying to do this without using opengl......just straight up projection with code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •