MIDDLE EAST TEHNICAL UNIVERSITY
DEPARTMENT OF COMPUTER ENGINEERING
CENG 300 SUMMER PRACTICE REPORT
Can HOSGOR
e1395094
DEPARTMENT OF AEROSPACE ENGINEERING METU
TÜBİTAK
2.7.2006 – 12.8.2006
Table of Contents
Table of Contents
1. Information About Department
1.1 Detailed Information
1.2 Department staff
2. Information about the Association
2. 1 Detailed Information
2.2 Mission and Vision
2.3 Primary Functions
2.4 History and Background
3. Introduction
3.1 Management Of The Project
4. Report
4.1 Design of a Simple Flight Simulator
4.1.1 OpenGL
4.1.2 Glut
4.1.3 Glui
4.2 The Project
4.2.1 Rendering the Terrain
4.2.2 Objects on the Terrain
4.2.3 The SkyBox
4.2.4 Joystick Support
5. Conclusion
Appendix – Code Listing
1. Information About Department
Name:
Metu Department of Aerospace Engineering
Address:
Department of Aerospace Engineering, METU
06531, Ankara / TURKEY
Phone:
+90 (312) 210 24 71
Fax:
+90 (312) 210 42 50
Web:
E-Mail:
1.1 Detailed Information
The objectives of aerospace engineering department are to educate students in the design, production and testing of aerospace vehicles, and conduct scientific research in above disciplines of aerospace engineering.
Aerospace engineering deals with the scientific calculations of all air/space vehicles such as plane, helicopter and spacecraft. Briefly, an aircraft consists of: aerodynamic body that is capable of carrying the desired amount of volume, robust and durable structure, light-weight but efficient power sources to maintain airborne speed and control systems to relate subsystems. Thus, the department includes of four branches, namely, Aerodynamics,Thrust,Control-Avionics and Structure-Material.
Established in 1981, the department grew up rapidly and now has 7 professors, 6 docents, and 16 research assistants. Additionally part-time lecturers from Aselsan and Roketsan have been working in the department regularly.
In order to realize applied research and education the department contains 4 laboratories that are Aerodynamics,Thrust,Control-Avionics and Structure-Material labs. By October 2003, 601 students have graduated from department and because of its inter-disciplinary status the department has four minor and double major programs that are popular amongst other engineering students.
In 2001, the department received ABET (Accreditation Board for Engineering and Technology) and proved to have an equal education level to universities in USA.
1.2 Department staff
Chair:
Prof. Dr. Nafiz Alemdaroğlu
Associate Dean:
Prof. Dr. Yavuz Yaman
Assistant Chair:
Prof. Dr. Yusuf Özyörük
Assoc. Prof. Dr. Serkan Özgen
Faculty Members
Prof. Dr. Yurdanur TULUNAY
Prof. Dr. Nafiz ALEMDAROĞLU
Prof. Dr. M. Cevdet ÇELENLİGİL
Prof. Dr. İ. Sinan AKMANDOR
Prof. Dr. Yavuz YAMAN
Prof. Dr. İsmail H. TUNCER
Prof. Dr. Yusuf ÖZYÖRÜK
Prof. Dr. Ozan TEKİNALP
Assoc. Prof. Dr. Sinan EYİ
Assoc. Prof. Dr. Serkan ÖZGEN
Assoc. Prof. Dr. Altan KAYRAN
Asst. Prof. Dr. Melih ŞAHİN
Dr. Oğuz VAROL
Dr. İlkay YAVRUCUK
Graduate Research Assistants
Özhan ÖKSÜZ
Dilek Funda KURTULUŞ
Mustafa KAYA
Hüseyin Özgür DEMİR
Mehmet KARACA
Tahir TURGUT
Serpil KAYA
Fatih Mutlu KARADAL
Hakan KUTGÜN
2. Information about the Association
Name:
Tübitak, The Scientific and Technological Research Council of Turkey
Address:
TÜBİTAK Tunus Cd. No:80
06100, Kavaklıdere /Ankara
Phone:
0 312 468 53 00
Fax:
: 0 312 467 29 98
Web:
E-Mail:
2. 1 Detailed Information
Founded in 1963, TUBITAK is the public agency put in charge of promoting,
developing, organising, conducting and coordinating research and development
in line with the national targets of economical development and technical
progress.
TUBITAK acts as an advisory agency to the Turkish Government on science and
research issues, and is the secretariat of the Supreme Council of Science
and Technology, the highest S&T policy making body in Turkey. Approximately
1000 researchers work in 15 different research institutes of TUBITAK where
targeted, nation-wide important research is conducted. Furthermore, TUBITAK
funds research projects carried out in universities and other public and
private organisations, publishes scientific journals, popular science
magazines and books, and supports undergraduate and graduate students
through scholarships.
TUBITAK is the executing agency in deployment of international scientific
and technological agreements. In this context, TUBITAK is the national
coordinatig body of EU's 6th Framework Program.
2.2 Mission and Vision
The mission of TUBITAK is to “develop scientific and technological policies in line with our national priorities and in cooperation with all sectors and related establishments; contribute to establishment of infrastructure and instruments to implement said policies; support and conduct research and development activities; and to play a leading role in the creation of a science and technology culture with the aim of improving the competitive power and prosperity of the country.
TUBITAK’s Vision: “To be an innovative, guiding, participating and cooperating institution in the fields of science and technology, which serves for improvement of the life standards of our society and sustainable development of our country.”
2.3 Primary Functions
TUBITAK is not just an institution that supports researches, a formation that only determines science and technology policies, a system that only develops R&D human resources or a structure composed solely of research institutes; TUBITAK is all of these and much more. In addition to the ordinary duties of a national research institution, TUBITAK has been assigned to numerous additional tasks, which are generally executed by the Science Ministries. The main functions of the institution listed below are explained briefly in the respective pages.
- Develop the science and technology policies of Turkey;
- Support, encourage and monitor academic R&D;
- Support, encourage and monitor industrial RTD and innovations;
- Develop academic-industrial relations;
- Operate R&D institutes conducting RTD activities in line with the national priorities;
- Operate units facilitating and providing technical services for R&D activities;
- Identify and encourage scientists of the future;
- Award annual prizes to incite scientific excellence;
- Organize and manage international scientific and technological cooperation;
- Publish scientific journals, popular science books and periodicals.
2.4 History and Background
Establishment of TUBITAK coincides with the beginning of the planned economy period in Turkey in 1963. The Council was originally established to organize, coordinate and encourage basic and applied researches especially in natural sciences. A similar formation is expected in the field of social sciences and humanities.
The two main functions of the Council were initially to support academic researches and to encourage and incite young researchers. In order to fulfill said functions four research groups have been formed in the fields of Basic Sciences, Engineering, Medicine and Agriculture – Livestock along with a Scientific Human Resources Development group.
TUBITAK has undertaken the task of serving the researchers in the field of R&D by establishing the Documentation and Information Center in 1967. Said Center has been converted into the National Academic Network and Information Center with the creation of the academic computer network in 1996. Currently, numerous facilities such as the Meteorology Institute, Observatory and Test & Analysis Laboratories are at the service of researchers along with said center.
Conducting of researches has been included into the tasks of the Council with the establishment of the Institute for Building Researches (1971) and Guided Devices Technology and Measurement Center (now the Research Industries Research and Development Institute) (1973) in Ankara and Marmara Scientific and Industrial Research Institute (1972) in Gebze. Other research institutes have been added to these in the following years, and the Institute for Building Researches has been closed.
TUBITAK has undertaken the responsibility of developing the science and technology policy of the country for the first time by undertaking the preparation of the “Turkish Science Policy; 1983-2003” document. Establishment of the Supreme Council for Science and Technology in 1983 and assignment of the secretariat functions of said Council to TUBITAK have turned this responsibility into a clear and concrete duty. Within the scope of said duty, a comprehensive project titled “Vision 2023” is currently being conducted to determine the science and technology policies to be applied in the next twenty years. Another significant function, which emerged with the establishment of the Technology Forecasting and Assessment Directorate by the State in 1993 for arrangement of the support planned to be provided in order to encourage the research and technology development activities in industrial establishments, is assessment and supporting of the industrial RTD.
Since its recognition in the international platform, TUBITAK has represented Turkey in nearly all international science and technology cooperation activities. Moreover, participation of Turkey into the Sixth Framework Program has substantially increased its responsibilities in this field. It is evident that establishment and operation of the National Contact Point system shall require great effort also.
3. Introduction
I have worked in the Department of Aerospace Engineering durig my summer practice between 2 July and 12 August 2006.
I worked on a software project supported by Tubitak, with my project partner N. İlker Erçin. Our supervisor was Dr. İlkay Yavrucuk from the Aerospace Engineering of Metu.
During my summer practive I primarily focused on graphics programming using OpenGL. The creation of realistic looking 3D environments using a computer is considered to be one of the most challenging topics in computer world. I, therefore, wanted to get involved in such a project to have a better understanding of virtual reality and gain experience in computer graphics concepts.
The summer practice was quite beneficial for me, because it helped me learn a lot about a fundamental discipline in computer science, that was quite new to me. I can say that the summer practice improved my programming skills because I now have a moderate understanding of rendering three dimensional scenes using the graphics hardware as efficiently as possible.
We worked on a minimalistic version of a flight simulator in C++ with the help of third party libraries such as Glut, Glui and lib3ds. In the following sections, I’m going to describe the progress of project in detail.
3.1 Management Of The Project
Dr. İlkay YAVRUCUK
Project manager, Design of the system and software for flightdynamics modules.
Time for the project : 50%
Prof. Dr. Kemal LEBLEBİCİOĞLU
Description : Software design of the flight dynamic algorithms.
Time for the project : 30%
Ebru ARSLAN
Description : Coding of the flight dynamic modules, design of the interface and mainsoftware modules.
Time for the project : 60%
Arda COŞKUNSES
Description : Preparing graphics interface, modeling of the flight environment.
Time for the project : 60%
Emre EGE
Description : Integration of the hardware and software modules, coding the test
programs, preparing the data generator and emulator programs.
Integration of flight dynamic modules with the system.
Time for the project : 60%
4. Report
Pilot training is a demanding and time consuming task. Most of the time, both the technical and human resources are insufficient to train each person individually. One possible solution to this problem is to employ a less hands-on approach, namely by using a simulator. The problem with today’s simulators is that they are expensive and unportable.
In this project we are trying to overcome this problem by using more affordable hardware. We will be using head-mounted-displays and data gloves for input/output systems and normal PCs for running the simulator software.
The simulator will be highly interactive to user actions and it will be able to load different simulation environments and aircraft on demand.
Currently the hardware of the system consists of a head-mounted-display device, that reacts to head movements of the user; data gloves that receives user input through natural movements of hands and fingers; and a PC specially optimized for 3d rendering tasks.
For the software part we ses Linux as the base operating system. Linux allows users to incorporate software modifications easily, and is stable enough to run several months continuosly without beeing administered.
The project is separated to two main parts. First one focuses on creating the virtual environment that user sees and interacts with, while the second part focuses on how objects in this virtual environment interact with each other, in other words, the physics engine behind the simulator.
4.1 Design of a Simple Flight Simulator
We chose C++ as development environment because it’s available on virtually any platform and has a reputation in many projects that require efficient real-time processing. The mainstream approach to graphics programming in Linux is using the OpenGL library. Additionally we used Glut for window management and receiving keyboard input, and glui for creating the user interface. The following section explains the libraries used throughout this project.
4.1.1 OpenGL
OpenGL (OpenGraphics Library) is a standard specification defining a cross-language cross-platform API for writing applications that produce 3D computer graphics (and 2D computer graphics as well). The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL was developed by Silicon Graphics and is popular in the video games industry where it competes with Direct3D on Microsoft Windows platforms (see Direct3D vs. OpenGL). OpenGL is widely used in CAD, virtual reality, scientific visualization, information visualization, flight simulation and video game development.
4.1.2 Glut
The OpenGL Utility Toolkit (GLUT) is a library of utilities for OpenGL programs, which primarily perform system-level I/O with the host operating system. Functions performed include window definition, window control, and monitoring of keyboard and mouse input. Routines for drawing a number of geometric primitives (both in solid and wireframe mode) are also provided, including cubes, spheres, and the Utah teapot. GLUT even has some limited support for creating pop-up menus.
The two aims of GLUT are to allow the creation of rather portable code between operating systems (GLUT is cross-platform) and to make learning OpenGL easier. Getting started with OpenGL programming while using GLUT often takes only a few lines of code and requires no knowledge of operating system–specific windowing APIs.
4.1.3 Glui
GLUI is a GLUT-based C++ user interface library which provides controls such as buttons, checkboxes, radio buttons, and spinners to OpenGL applications. It is window-system independent, relying on GLUT to handle all system-dependent issues, such as window and mouse management. Features of the GLUI User Interface Library include: Complete integration with GLUT toolkit, Simple creation of a new user interface window with a single line of code, Support for multiple user interface windows, Standard user interface controls.
4.2 The Project
Before we got involved in this project, me and my project partner İlker Erçin had no prior experience in OpenGL or 3D programming concepts. So the first week, instead of directly starting to work on the project we were asked to get ourselves comfortable with OpenGL and generic programming. We were asked to create a simple planar environment. The user was supposed to navigate in the environment using arrow keys, and both the sky and ground should be textured. For the sake of simplicity we were allowed to use Win32 Api functions for loading bitmap files as textures.
This is a screenshot from our first OpenGL program. The ground is rendered by applying a small grass texture repeatedly to a large rectangular surface, thus giving it a tiled look. The sky is just a large sphere with a bluish texture applied onto it. The problem with rendering sphere shaped objects is that, some texture artifacts occur at poles of the sphere because of the way spheres are rendered by the graphics system. Later on, we will be using a different method for eliminating such problems.
After the warmup week, we began to improve our flight simulator gradually. Our supervisor asked us to add airplane models to the scene. The models we used in this project is in 3ds format, therefore we needed to use the lib3ds library for loading the model files, and converting to internal opengl display lists for fast rendering.
lib3ds is a free ANSI-C library for working with the popular "3ds" 3D model format. Supported platforms include GNU (autoconf, automake, libtool, make, GCC) on Unix and Cygwin, and MS Visual C++ 6.0. lib3ds loads and saves Atmosphere settings, Background settings, Shadow map settings, Viewport setting, Materials, Cameras, Lights, Meshes, Hierarchy, Animation keyframes. It also contains useful matrix, vector and quaternion mathematics tools. lib3ds usually integrates well with OpenGL. In addition, some diagnostic and conversion tools are included.
When loading a model, lib3ds gives us direct access to all of its vertices. Thus, we can easily create a bounding box for the model. A bounding box is the smallest volumed three dimensional box, which includes all vertices in the model. A bounding box’s dimensions are specified by taking the minimum and maximum values of x, y, z components of all vertices in the model. The most important use of a bounding box is that we can easily determine if an objects collides with another one simply by comparing their bounding boxes.
As I have previously stated, the simulator is supposed to run under Linux. So LoadBitmap() and other Windows specific functions are no longer available. We have decided to use Jpeg format for all image and texture purposes in the project because, (although lossy) it has better compression ratio for photographic images compared to other formats. Since completely understanding the internal structure of Jpeg files is beyond the scope of this project, we decided to use libjpeg to provide some abstraction. Libjpeg is a portable library for reading and writing jpeg formatted images. The full texture loading code can be found in appendix, the function is named load_texture().
4.2.1 Rendering the Terrain
The first thing required for terrain rendering is a representation of the terrain's shape. While there are a number of structures that can be used to perform the job, the most widely used is the height map. Others include: NURBS, which can be maintained through a number of control points, and voxels, which allow for overhangs and caves.
There is one drawback to a height map, and that is, for every point on the XZ-plane, there can only be one height value. This limits the representation of overhangs and caves by a height map. This can be overcome by using two separate models.