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