Escolar Documentos
Profissional Documentos
Cultura Documentos
Computer graphics
JANUARY 4, 2018
MUHAMMAD IBRAHIM—FA14-BSE-119
PAMIR KHAN—FA14-BSE-127
OpenGL topics covered by this project:
This is a list of all the basics that this project involves. The explanation of each one goes beyond the
logic of this article. I recommend you to start looking over the internet
FPS Camera.
CSG (Constructive Solid Geometry)
Transparency
Collisions
Skybox Technique
Vector Handling
Texture Loading and mapping.
OpenGL primitives
Object interaction
Points of Interest
You can learn a lot from this project. You can start by commenting the objects added to the
scene and see the outcome. If you get a little confident you can start adding your own objects. The
project is coded in a very modular way enabling you to add complexity without compromising the
entire structure design.
FPS CAMERA
Frame rate (expressed in frames per second or fps) is the frequency (rate) at which
consecutive images called frames appear on a display. The term applies equally to film and video
cameras, computer graphics, and motion capture systems. Frame rate may also be called
the frame frequency, and be expressed in hertz.
The temporal sensitivity and resolution of human vision varies depending on the type and
characteristics of visual stimulus, and it differs between individuals. The human visual
system can process 1 to 5 images per second and perceive them individually, while higher rates
are perceived as motion. Modulated light (such as a computer display) is perceived as stable by
the majority of participants in studies when the rate is higher than 50 Hz through 90 Hz. This
perception of modulated light as steady is known as the flicker fusion threshold. However, when
the modulated light is non-uniform and contains an image, the flicker fusion threshold can be
much higher, in the hundreds of hertz.[2] With regard to image recognition, people have been
found to recognize a specific image in an unbroken series of different images, each of which
lasts as little as 13 milliseconds.[3] Persistence of vision sometimes accounts for very short
single-millisecond visual stimulus having a perceived duration of between 100 ms and 400 ms.
Multiple stimuli that are very short are sometimes perceived as a single stimulus, such as a 10 ms
green flash of light immediately followed by a 10 MS red flash of light perceived as a single
yellow flash of light.
Suppose the block primitive is defined by its "lower left" corner < -1, -1, -1 > and "upper right"
corner < 1, 1, 1 >. To produce a rectangular box with center at < 3, 2, 3 > and height and width 3
and length 5, a user may first scale the block primitive 1.5 times in the y- and z-direction and 2.5
times in the x-direction, and then translate the result to < 3, 2, 3 >. If the block primitive is
called Block in a CSG system, the result may be obtained as follows:
In the above, the object to be transformed and the transformation data are the first and second
arguments, respectively.
Transparency
In computers, transparent means something a little different than its general meaning of having
the quality of being easily seen through, coming closer to meaning invisible or undetectable.
Computer programs and procedures that are said to be transparent are typically those that the
user is - or could be - unaware of. Transparency is considered to be especially desirable in
situations where users that are not particularly technically inclined would tend to be confused by
seeing or having to interact directly with programming components. The domain name system
(DNS), for example, operates in a transparent manner, resolving authorized domain names into
Internet Protocol (IP) addresses, all without the user's knowledge. Transparent is also used to
refer to a change or upgrade of hardware or software that is undetectable in subsequent uses of
the system.
Collisions
Collision detection is an integral component of game engines that are designed to provide
realistic animations of object interactions with the player and the game environment. Physically
realistic dynamic simulations such as flight simulators and mobile robot simulators also require
efficient collision detection algorithms. Intersection tests form the backbone of collision
detection algorithms. They are also used in ray tracing algorithms, acceleration algorithms such
as view frustum culling and portal culling, and in real-time animations. This topic gives an
extensive coverage of methods used for testing if primitives and bounding volumes overlap.
Collision detection in a large scene consisting of several objects requires efficient methods to
minimize the number of intersection tests. This topic discusses the usefulness of bounding
volume hierarchies and spatial partitioning trees such as octrees, k-d trees and bounding interval
hierarchies, and includes a coverage of important algorithms in each category.
First, we’ll need some data. These variable will be set when reading the file.
The first thing in the file is a 54-bytes header. It contains information such as “Is this file
really a BMP file?”, the size of the image, the number of bits per pixel, etc. So let’s read
this header :
The header always begins by BM. As a matter of fact, here’s what you get when you
open a .BMP file in a hexadecimal editor :
So we have to check that the two first bytes are really ‘B’ and ‘M’ :
if ( header[0]!='B' || header[1]!='M' ){
printf("Not a correct BMP file\n");
return 0;
}
Now we can read the size of the image, the location of the data in the file, etc :
Now that we know the size of the image, we can allocate some memory to read the
image into, and read :
// Create a buffer
data = new unsigned char [imageSize];
// Read the actual data from the file into the buffer
fread(data,1,imageSize,file);
We arrive now at the real OpenGL part. Creating textures is very similar to creating
vertex buffers : Create a texture, bind it, fill it, and configure it.
In glTexImage2D, the GL_RGB indicates that we are talking about a 3-component color,
and GL_BGR says how exactly it is represented in RAM. As a matter of fact, BMP does
not store Red->Green->Blue but Blue->Green->Red, so we have to tell it to OpenGL.
Vector Handling
Digital images can usually be divided into two distinct categories. They are either bitmap
files or vector graphics. If you work in prepress, you need a good understanding of the
advantages and disadvantages of both types of data. These pages try to explain the differences.
As a general rule, digital pictures and scanned images are bitmap files. These are
sometimes also called raster images.
Drawings made in applications like Adobe Illustrator or Corel Draw are saved as vector
graphics.
Technically both data formats are completely different. The end result, however, can look
virtually identical in either format. As a general rule bitmaps are typically used to depict lifelike
images whereas vector graphics are more often used for abstract images such as logos. There are
however numerous exceptions to this rule. It is often impossible to determine whether an image
is a bitmap or a vector file just by looking at it.