09 유용한 기능들 - sangjiit.sangji.ac.kr/~3d/ppt/cg/09.pdf · 유용한 기능들 01 skybox...

Post on 26-Aug-2020

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

유용한 기능들

01 Skybox

02 Picking

03 Billboard

04 Height Map

05 Cel Shading (Cartoon Rendering)

06 Load 3D Model

07 Text

09

Skybox 01

Skybox의 원리

2

Skybox 01

Skybox의 구현 결과

3

코드 9-1

Picking 02

Selection Mode에서 Picking 처리 과정

4

Selection Mode에서 Picking 구현 결과 코드 9-2

Picking 02

MessageBox 함수에 대한 Prototype

5

glSelectBuffer 함수에 대한 Prototype

Picking 02

glGetIntegerv 함수에 대한 Prototype

6

glRenderMode 함수에 대한 Prototype

Picking 02

gluPickMatrix 함수에 대한 Prototype

7

Picking 02

Ray Picking

8

Picking 02

9

코드 9-3

x = getMouseX(); y = getMouseY(); view = cameraLookAt - cameraPosition; normalize view; h = crossProduct( view, cameraUp ); // 외적(Cross Product) normalize h; v = crossProduct( h, view); // 외적(Cross Product) normalize v;

Ray Picking을 위한 Pseudo Code

Billboard 03

Billboard가 형성되기 위한 구조

10

Billboard 03

Billboard의 구현 결과

11

코드 9-4

Billboard 03

glMultMatirxf 함수에 대한 Prototype

12

Billboard 03

Photoshop에서 Alpha Channel을 생성하기 위한 과정

13

(A) 나무 이미지 불러오기 (B) [Magic Wand Tool]로 배경 선택하기

(D) CHANNELS – Save selection as

Channel Click

(C) 메뉴 [Select > Inverse]

(E) Alpha Channel 생성 (F) Indicates channel visibility Click 및 메뉴 [Select > Deselect]

Height Map 04

Height Map의 구현 결과

14

코드 9-5

Cel Shading 05

Cel-Shading의 구현 결과

15

코드 9-6

Load 3D Model 06

16

1. 3D Studio MAX Model(*.3ds) Loader

2. 3D Studio MAX Model(*.ase) Loader

3. Wavefront OBJ Model(*.obj) Loader

06

17

1. 3DS MAX Model(*.3ds) Loader

Chunk의 구조

계층적인 Chunk 구조를 가진 3ds 파일

06

18

1. 3DS MAX Model(*.3ds) Loader

3D Studio MAX Model(*.3ds) 읽어오기의 구현 결과

코드 9-7

06

19

2. 3DS MAX Model(*.ase) Loader

ASE 파일의 Format

*SCENE

*SCENE_FIRSTFRAME 0

*SCENE_LASTFRAME 100

*SCENE_FRAMESPEED 30

*SCENE_TICKSPERFRAME 160

*MATERIAL_LIST // Material의 집합

*MATERIAL_COUNT 1 // Material의 총 개수

*MATERIAL 0 { // Material의 ID

*MATERIAL_NAME "Material #2"

*MATERIAL_CLASS "Standard" // SubMaterial을 포함하지 않는다.

*MATERIAL_CLASS "Multi/Sub-Object"

*MATERIAL_AMBIENT 0.1000 0.1000 0.1000 // 주변광

*MATERIAL_DIFFUSE 0.7000 0.7000 0.7000 // 확산광

*MATERIAL_SPECULAR 0.9000 0.9000 0.9000 // 정반사광

*NUMSUBMTLS 15 // 현재 Material이 가진 SubMaterial의 개수

*SUBMATERIAL 0 { // SubMaterial의 ID

*MAP_DIFFUSE {

*BITMAP "F:\Turret\Turret\Maps\T_Siren1.bmp“

……

06

20

2. 3DS MAX Model(*.ase) Loader

3DS MAX Model(*.ase) 읽어오기의 구현 결과

코드 9-8

06

21

3. Wavefront OBJ Model(*.obj) Loader

OBJ File Format

# List of Vertices, with (x, y, z[,w]) coordinates, w is optional and defaults to 1.0.

v 0.123 0.234 0.345 1.0

v ...

...

# Texture coordinates, in (u[,v][,w]) coordinates, v and w are optional and default to 0.

vt 0.500 -1.352 [0.234]

vt ...

...

# Normals in (x, y, z) form; normals might not be unit.

vn 0.707 0.000 0.707

vn ...

……

# Parameter space vertices in (u[,v][,w]) form; free form geometry statement vp 0.310000 3.210000 2.100000 vp ... ... ……

06

22

3. Wavefront OBJ Model(*.obj) Loader

GLM의 구성

06

23

3. Wavefront OBJ Model(*.obj) Loader

Wavefront OBJ Model(*.obj) Loader의 구현 결과

코드 9-9

06

24

3. Wavefront OBJ Model(*.obj) Loader

glmReadOBJ 함수에 대한 Prototype

glmUnitize 함수에 대한 Prototype

glmFacetNormals 함수에 대한 Prototype

06

25

3. Wavefront OBJ Model(*.obj) Loader

glmVertexNormals 함수에 대한 Prototype

glmDraw 함수에 대한 Prototype

06

26

기타 3D Model Loader

Reference Site

Text 07

27

1. 2D Text

2. 3D Text

28

07 1. 2D Text

2D 문자 - Bitmap Font 구현 결과

코드 9-10

29

07 1. 2D Text

CreateFont 함수의 Prototype

30

07 1. 2D Text

wglUseFontBitmaps 함수에 대한 Prototype

glDeleteLists 함수에 대한 Prototype

31

07 1. 2D Text

glPushAttrib 함수에 대한 Prototype

32

07 1. 2D Text

glListBase 함수에 대한 Prototype

33

07 1. 2D Text

glCallLists 함수에 대한 Prototype

34

07 1. 2D Text

glPopAttrib 함수에 대한 Prototype

glRasterPos 함수에 대한 Prototype

35

07 2. 3D Text

3D Text – Outline Font 구현 결과

코드 9-11

36

07 2. 3D Text

GLYPHMETRICSFLOAT 구조체의 Prototype

37

07 2. 3D Text

wglUseFontOutlines 함수의 Prototype

38

07 2. 3D Text

glPolygonMode 함수의 Prototype

top related