Yikes! So many questions! I wrote a program in C++ to do it for me, but I didn't have any graphing tools. I found out game maker has some built in trig functions and line drawing functions, so I put it to the test with that.
I want to learn openGL but I need a bit more programming experience first. If all goes well I'll be starting school in july, then my programming skill should finally begin to grow.
]]>I'm really really curious to see how its really done. A lot of matrice multiplications are used but its hard to tell what exactly their doing. I'd like to see an explanation. There's something they refer to as "the clipping plane" which limits how close objects can be to the camera, I'd like to know what it does to objects when they do get too close.
My engine works well, but not beautifully.
]]>I have a book and disk on openGL but it uses an extremly brief so called "introduction" to windows programming and I can't even get past that without getting lost. Maybe after a yearo of college I'll pick it up again.
]]>The most advanced one ive made to date, was probably when i first learnt how to clip polygons and i made a fully imersive 3d engine
http://delta.ecwhost.com/sample2.html (this was over a year ago now)
since then ive made a few things using a base engine which ive then modified and optimized to fit the situation (losing dynamicness, but gaining speed which is essential since flash player aint exactly the fastest thing at running its bytecode)
the only thing relating the 3d i have done in c++, is ray tracing of which im currently working on a large rendering package which i rambled on about in a thread i made asking for help with ray-torus intersections
But basicly it will have alot of the functionality programs like pov-ray host, but with a less complicated language (and since im not exactly an expert, probably wont run as fast, and deffinately wont be multi threaded). The simple function based language ive made is also not very complicated, and is a basic function(parameters), then to set a variable object, #s1.function(parameters), and to edit an object from its variable, or to point to an objet variable ~s1.function(paremeters), where ~s1 would be used to refer to the object
]]>I suggest you use the OpenGL API in conjunction with C/C++. It will be incredibly faster and more accurate than gamemaker. Gamemaker works on pixel coordinates, that is to say, it draws a line from position x1,y1 -> x2,y2 on your monitor, making it extremely innacurate. OGL (and DirectX but I prefer OGL, it's much cleaner) works by generating the line in a pseudo 3d environment, then takes a digital image of this environment based on the camera position and pastes this image on your screen.
]]>I can't say I know exactly where to go from here. Clearly this isn't just a math problem, its an optical illusion. So I must become a mathemagician! ;-) Anyways, I have a few idea's for some things to try. I'll let you know how it turns out.
]]>Ok heres the idea. As an object gets closer and closer, the angle from the viewer to the point gets closer and closer to 90 degree's. When its far away, changes of the distance and location of the object effect the angle at which the viewer see's it very little. This is the same reason why the sun or moon appears to follow you when your driving. Its so far away that proportionally small changes to your location hardly effect the angle at which you see it at all. As a point gets closer, the angle at which you see it begins to accelerate. Again, when your driving, it often appears nearby objects like telephone poles are moving a lot faster then the buildings far behind them. You know what I mean.
Anways, that acceleration is what makes objects go off screen when you get close or go past them. The angle to the object begins to accelerate towards 90 degrees and beyond. The viewing cone is 60 degree's wide at most so that disapears off screen.
Now when objects are far away, they vanish slower because the angles are not as abrupt. You can see the basic shape of the functions graph below. The angle to the object gets closer and closer to 90 degree's and accelerates towards it as it gets close. It slows down a bit as it gets close but its already off screen at that point.
Anyways, when I first measured the Z distance to a point and added the constant B to it, this was indirectly shifting the graph b units to the left. The red line I drew is where the y axis would be in that case. This shows why that worked to shorten the vanishing points. The curve is much slower and flater there. But it also shows why objects did not go off the screen when they were behind you. They had to go much farther back before the angles would hit 90 degree's and accelerate off the edge of the screen.
Then I had an inspiration. All I need to do to lessen the steepness of the curve is multiply (Zd/Xd) by a positive constant. Since the slope is negative, if we multiply Xd/Zd by say... 2, then the curve will be half as steep in every place. I created a constant m which would indirectly multiply the curve by 2 or whatever constant I wanted, to lessen the steapness of the curve. I tried it and it worked. Everything vanished slower. But there was a problem. It was doing what it was supposed to, no glitches, but since objects vanished slower, objects that weren't so far away weren't much smaller, and thus, they were bigger and dissapeared off the screen pretty quickly. Therefore you could not see much onscreen unless they were pretty far away, which is equivilent to just having a more narrow viewing cone. Dang.
At this point I'm not sure what else to do. Every possible adjustment I thought would be usefull I've figured out how to make, they all worked in differant ways, but none that allowed at least a 60 degree viewing cone without distortions. I can think of no other adjustments to the perspective that are not self contradictory. Objects need to both vanish slower and faster.
My design thus far would work fine for third person games, but for a first person game, you would have to have a very narrow viewing cone. 30 or maybe 40 degree's at most. I've often noticed first person video games seem to have a pretty narrow view but I doubt its as little as 30 degree's. But I could be wrong. It may be a natural consequence that a 3d illusion on a 2d plane must be limited to a narrow viewing angle to work properly.
Of course there is the possibility that certain adjustments must be made to compensate for the fact that we do not percieve a screen as a window to another world. If it were so, the objects are all in the exact locations they should be. (where we would see them through the glass) but since close and far objects are all on the same 2d plane (the screen) its more then a bit differant then just a glass window. So perhaps, adjustments must be made which in reality would be incorrect but tricks the brain into thinking it looks right. :-)
]]>