OenGL 3D Project: XJTLU Central Building

This is a report for 3D modeling project using freeglut.

1. Introduction

This is a 3D scene describing Central building (CB) and Science buildings (SBs) in north campus of Xi’an Jiaotong-Liverpool University (XJTLU) in real life. This scene contains techniques such as lighting, fog, texture mapping and viewing transformation, moving animation. There are ten objects in this scene in total, which are respectively Central building, four science buildings (SA, SB, SC, SD), road, trees, moving cars and buses
and skybox. In addition, keyboard interactions and mouse control are implemented in the program, which provide zoom function and viewing transformation along with switches of texture, lighting, and fog effects. This report will discuss the graphic features in detail and provide instructions to run the program interactively by posting screen shots of each stage and image materials used in the program.

2. Graphic Features

All the graphic techniques are drawn in a world coordinate system, and they are placed in a large virtual
box. Objects in the scene are drawn by hierarchical modelling with their own coordinate systems. For the
viewing and window reshaping, perspective projection matrix is utilized. In the texture mapping technique,
there are totally 12 pictures used in this program. After transferring the bmp picture to pixel data and
binding, their IDs are stored in an integer list GLuint texture[12] whose length is 12.

2.1 Central Building

This central Building is drawn through hierarchical modelling. Cubes composing of the main body of the building are bound with strips in black and white which are generated by texture mapping through “strip.bmp”
which is shown below. Similarly, the logos of XJTLU on the top of the building are generated through “XJTLU.bmp”. To fuse the colour of textures and materials GL_MODULATE is used in glTexParameterf(). Edges
of each fragment are decorated with brown cubes stretched by scaling and they are translated to the right
position. Coordinates of each fragment of CB are computed elaborately and translated to the position.
D:\zwh52\coursework\sem5\CSE209\AS3

Image1: XJTLU.bmp

在这里插入图片描述

Image2: Strip.bmp

2.2 Science Buildings

Science buildings are also drawn through hierarchical modelling. The green grids on the front and back are generated by texture mapping through “greenGrid.bmp” and the brown grids on the left and right are generated through “brownGrid.bmp”. Also, the strips on the intermediate layer are produced through “strip1.bmp”. The three textures are demonstrated below. After modelling SA, the other three buildings SB, SC, SD are drawn by translating and rotating the original SA, thus reducing the redundant codes.

在这里插入图片描述

Image3: greenGrid.bmp

D:\zwh52\coursework\sem5\CSE209\AS3\AS3\brownGrid.bmp

Image4: brownGrid.bmp

Strip1

Image5: strip1.bmp

2.3 Skybox

Skybox is generated through sticking six separated sky pictures to a large cube surrounding the whole scene and it ranges from (-6000, -6000, -60000) to (6000, 6000 ,6000). The six consecutive images “front.bmp”, ”back.bmp”, ”left.bmp” ,”right.bm”, ”top.bmp”, ”bottom.bmp” are mapped to the top, bottom, front, back, left and right of the surrounding cubic respectively and they are connected to each other, so that if observing inside the large box, the sky is the same as a whole picture taken in the real world. To make the
textures not interfered with materials, GL_REPLACE is used in glTexParameterf().

The consecutive images are presented below:

在这里插入图片描述

Image6: front.bmp

在这里插入图片描述

Image7: back.bmp

在这里插入图片描述

Image8: left.bmp

在这里插入图片描述

Image9: right.bmp

在这里插入图片描述

Image10: top.bmp

在这里插入图片描述

Image11: bottom.bmp

2.4 Road and Trees

The road is drawn by stretching the cubes. Zebra lines on it and trees consisting of Icosahedrons and cubes beside it are drawn through translations embedded in a for loop, so that they are placed consecutively. In addition, the road on the back of CB is generated through translating and rotating the original front road. The ground where all the objects stand is drawn by a huge cube with grass texture “greenGrass.bmp” bound to
it which is shown below:

在这里插入图片描述

Image11: greenGrass.bmp

2.5 Moving Cars

There are moving cars on each of the two roads. The cars are drawn by a body consisting of cubes and four tyres consisting of cylinders. Two different kinds of cars are all generated by copying the original car. The motion of each car is enabled by glutIdleFunc(), so that they can appear moving in the opposite direction on the different lanes. Each round of function call, a global variable named carD will increase by one. In the
drawing function drawCars() where this global variable is used, translate function is applied to move the cars by the value of carD.

2.6 Viewing

Perspective transformation is implemented through gluLookAt(). The detailed parameters inside are
demonstrated below:
gluLookAt(fltX0 * fltZoom, fltY0 * fltZoom, fltZ0 * fltZoom, fltXRef * fltZoom, fltYRef * fltZoom, fltZRef * fltZoom, fltXUp, fltYUp, fltZUp);
Where fltX0, fltY0,fltZ0 are the camera position of X, Y, Z coordinate, fltXRef, fltYRef, fltZRef are the coordinates of lookat position, and fltZoom is the zoom value of viewing, fltXUp, fltYUp, fltZUp are the direction of camera up vector which are not changeable.

When moving the viewing position, parameters of look at positions and camera positions are changed simultaneously. Parallelly, when changing look-at position, only parameters of look at position are changed. So that the viewing transformation is implemented. In addition, viewing is triggered by keyboard interaction.

2.7 Fog and Lighting

To make the scene real, fog and lighting are implemented in the program. Also, they can be trigger by pressing left key of mouse and pressing “z” on the keyboard. To make the fog effects real, the colour of fog is set to
light blue which is the same as the sky. Besides, colour materials are enabled to allow different colour displaying on the transferred objects by calling glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE),
glEnable(GL_COLOR_MATERIAL) and glEnable(GL_NORMALIZE).

3. Instructions

3.1 Keyboard Interactions

To change viewing in the virtual world, there are fourteen operations:

  1. To change viewing direction up or down, please press ‘n’ or ‘m’.

  2. To change viewing position left or right, press ‘,’ or ‘.’.

  3. To change viewing direction front or back, press ‘]’ or ‘[‘.

  4. To move viewing position left or right, press ‘a’ or ‘d’.

  5. To move viewing position up or down, press ‘w’ or ‘s’.

  6. To move viewing position forward or back, press ‘e’ or ‘q’.

  7. To zoom in or zoom out, press ‘I’ or ‘o’. To enable effects, there are three operations:

  8. To enable or disable lighting, press ‘z’.

  9. To enable or disable skybox, press ‘t’.

  10. To enable or disable fog, press left mouse.
    Entering the program, the scene is presented as image12, also, the scene without any effects is presented as image13:

在这里插入图片描述

Image13: Stage1 without any effects

Turn on the light effect and fog effect, the scene is demonstrated below:

在这里插入图片描述

Image14: Stage1 with lighting

在这里插入图片描述

Image15: Stage1 with lighting and fog

To move around in the virtual world, anywhere in the skybox can be reached, the scene between SC and SD
is demonstrated below:

在这里插入图片描述

Image16: Stage2 without effect

在这里插入图片描述

Image17: Stage2 with lighting

在这里插入图片描述

Image18: Stage2 with lighting and fog

The Scene beside the central building is presented as stage3:

在这里插入图片描述

Image19: stage3

在这里插入图片描述

Image20: stage3 with lighting

在这里插入图片描述

Image21: stage3 with lighting and fog

The resources can be accessed below:

https://download.csdn.net/download/Hhhhhaohao/14944522?spm=1001.2014.3001.5503

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值