Monday, May 19, 2008

3D Graphics 1

Today I'm going to move else where. This project displays 3d boxes in 3-point perspective, or at least the edges as lines. This program does not use matrices to display the box. I have little knowledge about how the 3d graphics with matrices work but this uses a much simpler method. This idea came about from a bunch of drawings i had done. I'm having some difficulty explaining the idea so take a look at this picture as reference. As you can see there are three perspective points and a center point. The way i draw just the box/cube is by using the intersections of the the perspective points and points that are on the lines that connect the center point and the perspective points (the red lines). The calculations involved are all relatively simply and include intersections of lines and finding a point a the x% of a line (ie. 50% would be the midpoint and 75% would be between the midpoint and a endpoint). The program uses a line drawing function similar to that of Bresenham's line algorithm but is buggy and wont draw a vertical line (any suggestions or links would be helpful). I doubt that this is A. an efficient way to draw 3d objects or B. that has any potential for any graphical use. With that being said don't get excited over this however it may have potential with devises that aren't capable of fully rendering 3d objects but need simple shapes. also note that it wouldn't be difficult to map a texture to this box. Since all the points are calculated it would be simple to map a texture by using Bresenham's algorithm on a bitmap. Any thoughts on this would be appreciated but i don't think I'm going to pursue this any time soon. the source code is for a program that will just draw out the 3d box. it is setup so that it draws a box where ever the user clicks. It always crashes on my laptop after a little less than a minute so any suggestions on how to fix than would be cool. As always source code is for free use as long as proper credit is given to me and anyone else i borrowed code or ideas from, in this case Bresenham.

No comments: