princípios de implementação de jogos com modelos 3d em c++ marcelo johann ii semana de tecnologia...
TRANSCRIPT
Princípios de Implementação de Princípios de Implementação de Jogos com Modelos 3D em C++Jogos com Modelos 3D em C++
Marcelo JohannMarcelo Johann
II Semana de TecnologiaDepartamento de Tecnologia da UNIJUÍ
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 2
Outline for IntroductionOutline for Introduction
Introduction - how games evolved?Motivation - why teaching games?Goals - what to get from the course?Methodology - what’s gonna happen here?Background - what are you expected to know?Infrastructure - HW and SW that we need…Interaction - Keep questioning me…
Contents…
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 3
IntroductionIntroduction
• Back to the 80’s…
http://www.mobygames.com/game/shots/gameId,575/
Moon Patrol
Galaga
http://spacemul.emu-france.com/screen.php3?id=13&lettre=G&lang=eng
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 4
IntroductionIntroduction
• 1986: first 3D games appearing…
http://spacemul.emu-france.com/screen2.php3?id2=14687&lang=eng
Alien 8
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 5
IntroductionIntroduction
http://www.rottentomatoes.com/g/pc_games/half_life_2/http://www.rottentomatoes.com/g/pc_games/half_life_2/images.phpimages.php
• And today…
Half Life 2
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 6
IntroductionIntroduction
http://www.mobygames.com/game/shots/p,3/gameId,3758/http://www.mobygames.com/game/shots/p,3/gameId,3758/
Mobil 1 British Rally Championship
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 7
IntroductionIntroduction
• Evolution of computer games
From 1D, 2D to complex 3D universe
• Needs: hardware, software, artwork
• Trends:
Continuous hardware evolution
Engines - higher abstraction levels
Professional programming techniques
Extensive visual work -> $$$
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 8
MotivationMotivation
• Computing requires Programming• Learning how to program is not simple• Difficulty to begin and to be professional
time, interaction, experience• Need for problems that justify complex programming languages and techniques
Games: lot of fun and learning potential
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 9
GoalsGoals• Learning and Practicing Object-Oriented Programming
– Professional C++, modular, O-O• Learning technologies for the development of games that use 3D models
– Engines, 3D modeling– Game architecture and timing – Game techniques
with many other applicationswith many other applications
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 10
MethodologyMethodology• Hands-on
• based on step-by-step examples
Test/Ask about everything
• At the beginning: – No class definitions!– Avoid using complex C++ constructions;– Emphasis on productivity
• Complexity is introduced when required
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 11
BackgroundBackground• Structured programming• C language• Basic data structures
Not necessary:– experience on C++ programming– advanced computer graphics
Ask about people’s background
Should ask anything that you don’t know!
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 12
InfrastructureInfrastructure• Fast computer with:
OpenGL, “Accelerated” graphic cardLinux with gcc, g++, make (Mac OS X now)
• Gizmo3D
http://www.tooltech-software.com/
• Crystal Space
http://sourceforge.net/projects/crystal
• Open Dynamics Engine
http://ode.org
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 13
Outline for ContentsOutline for Contents
IntroductionMain engine - Gizmo3D structure and start up3D modeling - from triangles to transformsEvents - how to read keyboard inputLogic - game actions and controlSimulation loop - structure, moves, timingTerrains and LODs - levels of detailAnimation / levels - frame, skeleton conceptsCollision and Physics - world behaviorThings that we did not consider…
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 14
Main EngineMain Engine
Gizmo3DGizmo3D• Features• Tutorial slides:
* skip gzApplication methods and task* skip gzGeometry and gzTransform * stop at the Expanding Scene
• start with exe00• Essential constructions of O-O
– Just Object *pt = new Object(...);Object *pt = new Object(...);– And result = pt -> method(...);result = pt -> method(...);
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 15
3D Modeling3D Modeling
SurfacesSurfaces• Triangles
- the easiest way* exe01
• Material
• Lighting* http://www.xmission.com/~nate/tutors.html
* exe02 and exe03
* slides Gizmo Material
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 16
3D Modeling3D Modeling
• Texture
* gizmo databases
* exe04 to exe11
(0,0) (1,0)
(0,1) (1,1)
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 17
3D Modeling3D Modeling
• Transformations
* gizmo slides 66 to 76
* exe12 to exe14
• Cloning
* exe15
• Groups
* exe17 a exe19
• Billboard
* gizmo’s billboard and my tests
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 18
Control EventsControl Events
•O-O
* exe20 to exe21
• app->run and onTick
* gizmo slides 29 a 36
* exe22
•app->run and onIdle
onTickonTick and and onIdleonIdle have to call refreshWindow have to call refreshWindow
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 19
Logic of the GameLogic of the Game
Logic Model may be different from 3D
• First City
* exe25
• Estoque: “Sokoban”
* estoque
• Network
* show socketControl in drive44
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 20
Simulation LoopSimulation Loopvoid MyApp::onIdle()
{
if(m_win->m_key_left_is_down)
car1->changeDirection(-1,m_win->getFrameRate());
if(m_win->m_key_right_is_down)
car1->changeDirection(1,m_win->getFrameRate());
if(m_win->m_key_up_is_down) car1->speedup(1.3f);
if(m_win->m_key_down_is_down) car1->slowdown(1.3f);
car1->move( 1, m_win->getFrameRate());
car2->move(m_win->getFrameRate());
car3->move(m_win->getFrameRate());
cam->move(m_win->getFrameRate());
m_win->refreshWindow();
}
Drive exe44
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 21
Playing with ModelsPlaying with Models
Take drive44
Take models from: www.3dtotal.com
* sofa.3ds
* speedboat.3ds
* chevi_camaro.3DS
* tiebomber.3ds
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 22
Terrain and LODTerrain and LOD
terrain.txt of the drive44
• Window
* gizmo’s window shows LOD
Other example is broken (62)
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 23
Animation and LevelsAnimation and Levels
• Frame AnimationMap file of Crystal SpaceMap file of Crystal Space Flying Brick (exe57)Flying Brick (exe57)
Crystal Space map file
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 24
Skeleton AnimationSkeleton AnimationTypes of Joints Types of Joints Open Dynamics EngineOpen Dynamics Engine
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 25
AnimationAnimationCharacter Character Lara CroftLara Croft
http://www.3dkingdom.org
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 26
Frame sequences
Pony Tail with a math model
Animation ControlAnimation Control
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 27
CollisionCollision
• gzIntersector
• intersect(stuff,…)
• getResults
OK
NO!
r
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 28
CollisionCollision
• Car corners
• Simple Geometry
r
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 29
CollisionCollision
• To collide is hard
• To know what to do next
is even harder
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 30
CollisionCollision
• stairs and floor
• vertical versus horizontal
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 31
PhysicsPhysics
• How about collision with other objects?
• This is very hard to handle…
Model what happens in a physical system
* example odetest - from ODE’s test_buggy
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 32
MissingMissing
• Sound
• Animation Control
• Explosions, particles
• Artificial intelligence
Other Engines and Game Resources:
www.3dlinks.com
UNIJUÍ 2004 - Marcelo Johann – Mini Curso de Games : 33
Thanks toThanks to
• PUCRS - Uruguaiana
Marcus Kindel ([email protected])
Cintya Bortolazzo
• UFRGS - Computação Gráfica
Luciana Nelel (www.inf.ufrgs.br/~nedel)
[email protected], pelo ODE
• Gizmo3D & game community
Anders Modén ([email protected])
Esteban G. Clua ([email protected])
Thank you!
Marcelo JohannMarcelo [email protected]
www.inf.ufrgs.br/~johann
Princípios de Implementação de Princípios de Implementação de Jogos com Modelos 3D em C++Jogos com Modelos 3D em C++
II Semana de TecnologiaDepartamento de Tecnologia da UNIJUÍ