Jump to content

Sign in to follow this  
Guest Zevious Zoquis

One thing I have never thought about since now......

Recommended Posts

Without reading all the responses, a couple of decades ago I bought a book on 3-d graphics programming and as a personal project, built my own wire frame flight simulator in "C" akin to the earliest version of FS. I had to learn (and have subsequently forgotten most everything) about 3-d transforms, using a matrix, clipping, page flipping (where you draw the scene off screen and flip the page when the scene is done) etc.... I still have that very basic flight simulator.Essentially, as it was described then, I had to build a virtual world which I then moved and turned around my fixed eyepoint. I actually took a map of the US, traced it onto graph paper, and assigned each major airport a set of coordinates based on it's position on the graph paper. I think I included five airports--JFK, SFO, SNA, ORD, and RNO.The code essentially added an offset to those coordinates to put them into the proper orientation based on bank angle, viewpoint, and aircraft position.Attached is a screenshot from the program--what memories does this thread bring back!-John http://forums.avsim.net/user_files/157867.jpg

Share this post


Link to post
Share on other sites
Guest Mr Chips

The aircraft moves around the scenery, the same as any well designed 3D application. How else can other objects in the world move within the same world independantly - think about AI aircraft?Even if there were no AI aircraft, think about tranforming the coordinates 10 squillion polygons as opposed to a few thousand in an aircraft model.

Share this post


Link to post
Share on other sites

"The aircraft moves around the scenery, the same as any well designed 3D application. How else can other objects in the world move within the same world independantly - think about AI aircraft?Even if there were no AI aircraft, think about tranforming the coordinates 10 squillion polygons as opposed to a few thousand in an aircraft model."I think you need to read my post above. Again, having designed a simple 3-d sim, the offsets are applied to the scenery. From the pilot's POV, it appears like the aircraft is moving but it isn't. Actually nothing's moving if you want to be a stickler on this--it's a sim. Here is the core of my code for rendering one point from the database onto the screen. X, Y and Z reference the coordinates of the scenery:scene_flag=0;x_processed=0;y_processed=0;z_processed=0;if (first_a!=angle_a || first_b!=angle_b || first_c!=angle_c) { scene_flag=1; first_a=angle_a;first_b=angle_b;first_c=angle_c; theta=angle_a*convert_degrees; phi=angle_b*convert_degrees; alpha=angle_c*convert_degrees; c1=cos(theta);c2=cos(phi);alpha=alpha*c2;c3=cos(alpha); s1=sin(theta);s2=sin(phi);s3=sin(alpha); ux=c1*c3+s1*s2*s3; uy=s1*c3-c1*s2*s3; uz=s3*c2; vx=-c1*s3+s1*s2*c3; vy=s3*s1+c1*s2*c3; vz=c3*c2; wx=s1*c2; wy=c1*c2; wz=s2; }a_processed=a*ux-b*uy-altitude*uz;b_processed=a*vx+b*vy-altitude*vz;altitude_processed=a*wx+b*wy+altitude*wz;cleardevice();Think about it. Doesn't matter what you see from the pilots POV. Something has to tell the computer to render the scene according to how the position of the aircraft has changed. All those bits of data that describe the world around you still need to be handled. There's no shortcut by "moving the aircraft, not the scenery". By strict definition, that isn't what's happening. One thing to also understand, is most sims don't transform the entire planet. My program, just like the "Big Boys" such as X-Plane and FS9, has limits on how far out the scenery is rendered. Also, all scenery that isn't in my viewport is clipped from the scene and never displayed.-John

Share this post


Link to post
Share on other sites

Let me also add a second part to this. I limit the scenery displayed by calculating where in the virtual world the aircraft is. Based on that position, I load all the points describing the region within roughly 180 miles of the aircraft into an array, and apply an offset to those points based on that position which essentially "moves" those points into position underneath the aircraft. The offset is updated every frame as I calculate how far the aircraft has moved, and whether it's changed bank angle, pitch, and heading. To convey speed, I simply add more to the offset. It's been a blast sifting through my old cold. It was my first "C" project although the program was originally coded for an Atari ST in GFA_Basic. It was also my last real "C" project. I put coding on the back burner for several years, then was introduced to Visual Basic after Windows 3.x was released. By that time, commercial sims had evolved far beyond what I was doing and included features such as incremental fill to fill in oceans, etc. They were still using poly mountains then (Mount Tam appears in my SFO picture as a 3-sided pyramid).Of course today we have mesh, 3-d graphics cards, etc... But the principles haven't changed much.-John

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...