+ All Categories
Home > Technology > Solar system simulation

Solar system simulation

Date post: 12-Apr-2017
Category:
Upload: ndtho8205
View: 69 times
Download: 0 times
Share this document with a friend
10
Computer Graphics 1 SOLAR SYSTEM SIMULATION
Transcript
Page 1: Solar system simulation

Computer Graphics 1

SOLAR SYSTEMSIMULATION

Page 2: Solar system simulation

Thành viên

2

- Vũ Thành Công

- Lê Quốc Huy

- Nguyễn Đức Thọ

Page 3: Solar system simulation

Nội dung1. Cấu trúc chương trình

2. Planet::draw()

3. The display callback

4. Vị trí Camera

5. Phép chiếu phối cảnh

6. The global idle callback

7. The keyboard callback

3

Page 4: Solar system simulation

Cấu trúc chương trình

4

- Class Planet- Class EarthSystem

- Namespace ConstantHelper

Page 5: Solar system simulation

Planet::draw()

5

void Planet::draw() {

glPushMatrix();

glColor3f(r, g, b);

glRotatef(angle, angleX, angleY, angleZ);

glTranslatef(x, y, z);

drawSphere(radius, slices, stacks);

glPopMatrix();

}

Page 6: Solar system simulation

The display callback

6

void drawObjects(void) {

drawAxis();

sun.draw();

sun.drawCircleLine(EARTH_SYSTEM_DISTANCE);

earthSystem.draw();

}

Page 7: Solar system simulation

Vị trí camera

7

- Thiết lập vị trí, góc, hướng cameragluLookAt(

eyeX, eyeY, eyeZ,centerX, centerY, centerZ,0, 1, 0

);

- Trong đó:+ (eyeX, eyeY, eyeZ): vị trí đặt của view,

+ (centerX, centerY, centerZ): điểm nằm trên đường thẳng xuất phát từ tâm view hướng ra ngoài,

+ (0, 1, 0): vector chỉ hướng lên trên của view

Page 8: Solar system simulation

Phép chiếu phối cảnh

8

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

// Chiế9u phố9i ca;nh, vật càng xa càng nho;

glFrustum(left, right, bottom, top, near_val, far_val);

Page 9: Solar system simulation

The global idle callback

9

- sun.angle += SUN_SPEED

- earthSystem.angle += EARTH_SYSTEM_SPEED

- earth.angle += EARTH_SPEED

- moon.angle += MOON_SPEED

Page 10: Solar system simulation

The keyboard callback

10


Recommended