You are not logged in.

- Topics: Active | Unanswered

**martian****Member**- Registered: 2005-11-21
- Posts: 14

I so want to do this my self. Its really fascinating. It sounds like a cool holiday project for me.

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

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

*Last edited by mikau (2005-11-27 08:18:12)*

A logarithm is just a misspelled algorithm.

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

Aha! After all these months a glitch in the formula is found. I discovered that using my current method, if you tried to project a sphere using this engine, that was located towards the edge of the screen the engine will project an oval. Technically this is correct, take this picture of an oval. Wink one eye to loose depth perception and look at it from a glancing angle and it looks like a circle! This is what I was talking about earlier. We should see an circle from our point of view but our brain corrects it and tells us its really an oval.

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.

A logarithm is just a misspelled algorithm.

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

null and void

*Last edited by luca-deltodesco (2006-05-19 09:04:35)*

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**Zmurf****Member**- Registered: 2005-07-31
- Posts: 49

Oh great! I didn't know there were other programmers on the forum. This engine looks very impressive, my friend and I are working on just a simple program for drawing 3 dimensional objects. We got it to render properly and we were going to move on to texturing but it just got too complicated.

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.

*"When subtracted from 180, the sum of the square-root of the two equal angles of an isocoles triangle squared will give the square-root of the remaining angle squared."*

Offline

**MathsIsFun****Administrator**- Registered: 2005-01-21
- Posts: 7,560

If somehow you guys got together ... Mikau, Luca and Zmurf's famous **FlexRender** (the name is available, grab it quick)

"The physicists defer only to mathematicians, and the mathematicians defer only to God ..." - Leon M. Lederman

Offline

**luca-deltodesco****Member**- Registered: 2006-05-05
- Posts: 1,470

well although ive never made my own 3d engine in C++ or a similarly powerful language

i have written a few 3d engines in Macromedia Flashes ActionScript (v2) using its drawing API to draw filled polygons

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

The Beginning Of All Things To End.

The End Of All Things To Come.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

Mikau, my display settings can be 1280x800, 1280x768, 1024x768, or 800x600.

What about you? And the actual size of my screen with a ruler is 13 1/16" wide and 8 1/18" tall.

Are you concerned with these things when you talk of an oval for a circle?

**igloo** **myrtilles** **fourmis**

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

I believe your thinking the fact that the screen is not square is squashing the circle into an oval? No, but good question.

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.

A logarithm is just a misspelled algorithm.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

What about if you take the screen and bend it onto a sphere? Redo the formulas.

Do you like it? Now you are viewing from the center of a sphere. Even though our

screens are flat, just pretend they are curved around you a little in both the horizontal and

vertical too, if you want to. Try to come up with new equations. The angle now is linear with

respect to the pixels left or right. Maybe some formulas will be simpler?

**igloo** **myrtilles** **fourmis**

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

Yes I've tried that. It can be tricky because a sphere is not square shaped when you flatten it out. I worked out a method that worked quite well, such that objects vanish depending on their direct distance from you, unfortunatly it made a row of paralell boxes look curved, since they got smaller as they moved sideways. :-/

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.

*Last edited by mikau (2006-05-28 14:37:30)*

A logarithm is just a misspelled algorithm.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

You mean how do they make 3D video games? I don't know if different companies have different methods.

Have you seen the 3D rotations in PDF's that Kaon has created? (kaon.com)

Can you determine the optimal number of pixels you should place one open eye centered in front of the screen with your software somehow? Like put your eye 2000 pixels from the screen?

I'm glad your thing works pretty almost beautiful. Whose development tools did you use?

Does it run on Linux, Windows, DOS, Mac? Can you run it at full screen without a window titlebar?

Do you recommend me getting these tools and learning BitBlt and everything, or do you not use BitBlt?

I wrote a program to make BMPs, but haven't learned Microsofts graphics, seems hard.

And I wrote a program to concatenate the data from sound files, but I haven't done real-time stuff to the soundblaster card, if that's what they still are?

*Last edited by John E. Franklin (2006-05-28 15:23:59)*

**igloo** **myrtilles** **fourmis**

Offline

**mikau****Member**- Registered: 2005-08-22
- Posts: 1,504

I read this, http://en.wikipedia.org/wiki/3D_projection I'm not sure I understand it completly so I haven't tried it.

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.

A logarithm is just a misspelled algorithm.

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

I see all those matrices. Hmm. You know, I have some equations I never programmed in a technical diary from 15 years ago. I think I'll examine those formulas. It has to do with 3D projections on 2D screen and I remember there would be a little distortion I think because I was trying to simplify the formulas by cheating a little. ~ I heard of Open GL and saw an example demo of something rotating, but don't know anymore. ~ Once I had an interview like 13 years ago and the company was doing 3D graphs of scientific data, and they asked me some linear algebra questions at the interview and I got it all wrong. Maybe someday I'll buckle down and really get into some area of math more. I'm kind of a natural at the easy stuff, so I don't really have to study unless it gets fairly complex.

**igloo** **myrtilles** **fourmis**

Offline

**John E. Franklin****Member**- Registered: 2005-08-29
- Posts: 3,588

I looked at my 3-D to 2-D screen equations from 15 years ago, and guess what? I couldn't make heads or tails of it because I didn't write the equations in a standard format. There are colors and arrows mixed in. But I do remember trying several example coordinates on a calculator and crunching out the angles, so oh well...

**igloo** **myrtilles** **fourmis**

Offline