pptx

minedesertΛογισμικό & κατασκευή λογ/κού

31 Οκτ 2013 (πριν από 3 χρόνια και 7 μήνες)

81 εμφανίσεις

Welcome

Projects

Course Mechanics

Tips for Warmup

Welcome to CS195U!


Formally, “Topics in 3D Game
Engine Development”


For computers, not consoles


Centered around developing multiple
3D game
engines from scratch


Engines implement various 3D game
technologies covered in class


Three individual
projects


Open
-
ended final
group project


Prerequisites:
CS123, one of CS32
or CS195N (latter recommended)

Course topics

DOES focus on


Building a 3D game engine
from scratch


Using OpenGL to display 3D
environments


Collision detection and
response


Game object
movement
and
interaction

Does NOT focus on


Using existing 3D game
engines (Unity, UDK, XNA…)


Advanced 3D rendering
techniques (try CS224)


Realistic physics (rigid body,
ragdoll, fluid)


Advanced
AI*, networking*,
game design*

What is a 3D game engine?


Core set of components that
facilitate game creation


Rendering


Physics


Sound


User input


Artificial intelligence


Real
-
time networking


No such thing as an engine
that can support every type

of game

Real
-
time strategy (RTS) engines


Large number of low
-
detail game units


Multiple levels of AI
(individual units as well as
computer players)


Client/server networking
with some lag tolerance


Lockstep protocol


Heightmap
-
based terrain

Vehicle simulation engines


Low number of high
-
detail models


Level
-
of
-
detail (LOD)
management


Minimal latency
networking


Peer
-
to
-
peer


Advanced realistic
physical forces

Welcome

Projects

Course Mechanics

Tips for Warmup

Warmup


One
-
week starter
assignment


First
-
person movement


OpenGL texture loading


Practice using support
code,
Qt
, OpenGL

Demo!

Minecraft

(the real game)


Indie game that made
millions


Procedurally
-
generated
block world (voxel
-
based)


Simple, pixelated graphics


Undirected multiplayer
gameplay


Players manipulate the
shape of the world

Minecraft

(the class project)


Procedural noise for
terrain generation


Simple voxel
-
based
collision detection and
response


View frustum culling


Infinite in all directions

Demo!

Platformer


Ellipsoid
-
mesh collision
detection and response


Advanced level
representation


Arbitrary 3D levels


Pathfinding

over
navigation meshes


In
-
game
UI

Demo!

Final project


Group project with 2
-
4
other classmates


Your own idea, developed
and implemented


Advanced engine features
required


Playtesting

with the general
public


Polish will be important!


You own your creation


Welcome

Projects

Course Mechanics

Tips for Warmup

Project checkpoints


Although there are only four
projects, there are weekly
checkpoints


Due at 11:59:59pm Tuesdays


Each checkpoint has well
-
defined objectives


Requirements are minimal, but
you get out what you put in


If handin is on
-
time and meets
requirements, it is “complete”


Otherwise, “incomplete”

Fixing incompletes


“Retry” within 3.5 days


H
and in a late or fixed version, new
grade replaces old


2 extra retries


Allow you to retry a previous retry


Only consumed if complete


A successful retry results in full
credit


If out of retries, you can still
complete by end by the end of
the semester for half credit


Email the TAs after handing in

Full
credit

Start

Complete?

Yes

No

Half
credit

No
credit

Finish
anyway?

Yes

No

No

No

Can use
retry?

Use
retry?

Yes

Yes

Final grades


Final grades determined
solely by number of
credits by the end of
the semester


There is no curve



Do the work, get an A!


# missed

# earned

grade

0.0

15.0

A

0.5

14.5

A

1.0

14.0

B

1.5

13.5

B

2.0

13.0

C

2.5

12.5

C

>3.0

<12.0

NC

Weeklies &
p
laytesting


In
-
class project components


Have to be made up if missed


Weeklies: 2
-
3 minute demo by
each student briefly stating
progress


Non
-
final weeks of each project


Playtesting
: Playing other
students’ games and filling out
feedback forms


Final week of each project


Exception: Warmup

Collaboration Policies

Welcome

Projects

Course Mechanics

Tips for Warmup

Overview


Build beginnings of engine from minimal starter code


Set up game
loop


Create app/screen framework


Become
familiar with
Qt

Creator


Practice simple OpenGL calls


First
-
person movement


Orient camera with mouse


Move player with keyboard

Starter code


Based on
Qt

framework


Huge, cross
-
platform
framework


Qt

handles application loop


Your code resides in callbacks


See comments in method
stubs for more details


We strongly recommend
separating your engine from
QGLWidget

(view.cpp)

Game loop refresher


Separate logical steps that happen not necessarily in sync:


Handle user input


Read/write network data


Tick game state


Draw game state


We recommend measuring ticks in
float

seconds

rather
than
int

milliseconds


Some games max out CPU, spinning as fast as possible


Don’t do this if not needed (wasteful, kills laptop batteries)


Starter code uses timer to target 60 updates/second

Coordinate systems


Different game engines define
coordinate systems differently


Most of you will probably use the
OpenGL coordinate system


TAs will strive to be coordinate
-
system independent


“Horizontal plane”


Plane parallel to the ground (in
OpenGL, the
xz
-
plane)


“Up
-
axis”


Axis perpendicular to horizontal
plane (in OpenGL, the y
-
axis)

z

x

y

z

y

x

z

x

y

Horizontal player movement


Simple trigonometry for horizontal movement


Player is rotated (yawed) around the up
-
axis at some angle


Get vector of forward velocity in horizontal plane


Multiply velocity by time since last tick and add to position


Strafing


Same as above, but use angle 90
°

left or right from the
player’s facing direction

Vertical player movement


Acceleration due to gravity


𝑔
=

(a reasonable negative constant)


𝑝
𝑢𝑝
+
=
𝑡
𝑣
𝑢𝑝
+
.
5𝑔
𝑡
2


𝑣
𝑢𝑝
+
=
𝑔𝑡


Collision with ground


After previous step:
𝑝
𝑢𝑝
=
max

(
0
,
𝑝
𝑢𝑝
)

OpenGL matrix transformations


Not the same as the five matrices
from CS123


OpenGL conflates them into two
matrices (projection,
modelview
)


Stored in column
-
major order
rather than row
-
major


Modelview

matrix


Transforms object space to camera
space, usually changes every frame


Projection matrix


Has camera parameters (aspect
ratio, field of view), usually only
changes on window resize

Vertex

Modelview

matrix

Object space

Camera space

Projection

matrix

Clip space

Perspective
division

Viewport
transformation

Normalized
device space

Screen space

First
-
person camera


Before drawing


Reset
modelview

matrix to the identity matrix


Rotate to the player’s look orientation (
pitch+yaw
)


Translate to negative player
eyepoint


Reasonable distance above player position


On window resize


Use
gluPerspective
()

to set up projection matrix


Remember to switch
glMatrixMode
()
!

Texture loading


Easiest to leverage
Qt

framework:


Remember to delete textures!


QImage

img
(path);

unsigned
int

id;

id =
view.bindTexture
(
img
,
GL_TEXTURE_2D
,
GL_RGBA
,



QGLContext
::
MipMapBindOption

|



QGLContext
::
LinearFilteringBindOption
);

Texture loading


If you’d rather use straight GL calls:


QImage

img
(path);

img

=
QGLWidget
::
convertToGLFormat
(
img
);


unsigned
int

id;

glGenTextures
(
1
, &id);

glBindTexture
(
GL_TEXTURE_2D
, id);

glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);

glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);

glTexImage2D(
GL_TEXTURE_2D
, 0,
GL_RGBA
,
img.width
(),
img.height
(),


0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
img.bits
());


Drawing geometry


For this week, you can just use immediate mode:


glBindTexture
(
GL_TEXTURE_2D
, id);

glEnable
(
GL_TEXTURE_2D
);

glBegin
(
GL_QUADS
);

glTexCoord2f(
0
,
0
); glVertex3f(
0
,
0
,
0
);
// remember winding order!

glTexCoord2f(
1
,
0
);
glVertex3f(
1
,
0
,
0
);

glTexCoord2f(
1
,
1
); glVertex3f(
1
,
1
,
0
);

glTexCoord2f(
0
,
1
); glVertex3f(
0
,
1
,
0
);

glEnd
();

glDisable
(
GL_TEXTURE_2D
);

C++ tip of the week


Helpful
Qt

data structures!



class

QList
<T>


Like
std
::vector

but much easier to use and usually faster,
overrides
+=

and
<<

for quick manipulations



class

QHash
<K,V>


Useful, general
hashtable

implementation. Overload the
global
qHash
()

function to return
int

hash for new key types



class

QPair
<A,B>


A tuple of two types, comes in handy for hash table keys.

C++ tip of the week


Qt

foreach

loop macro:


#include <
QtGlobal
>


QList
<
int
>
ints
;

ints

<<
1

<<
2

<<
3
;


foreach

(
int

i
,
ints
) {


cout

<<
i

<<
endl
;
// Value is a copy

}


foreach

(
const

int

&
i
,
ints
) {


cout

<<
i

<<
endl
;
// Value is a reference

}

Good Luck!


Remember,
warmup

is due next week!