Lecture 13 --- Building a 3D-game using XNA 1Elias Holmlid.

Slides:



Advertisements
Similar presentations
Using 2D sprite with OpenGL 2003 team Koguyue. Overview Motivation and basic concepts Advantages with using OpenGL Basic requirements of implementation.
Advertisements

Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
Lecture 38: Chapter 7: Multiprocessors Today’s topic –Vector processors –GPUs –An example 1.
Relaxed Consistency Models. Outline Lazy Release Consistency TreadMarks DSM system.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
SE 313 – Computer Graphics Lecture 13: Lighting and Materials Practice Lecturer: Gazihan Alankuş 1.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Chapter 5.2 Character Animation. CS Overview Fundamental Concepts Animation Storage Playing Animations Blending Animations Motion Extraction Mesh.
3D Concepts Coordinate Systems Coordinates specify points in space 3D coords commonly use X, Y, & Z A vertex is a 'corner' of an object Different coordinate.
Scratch the Cat. Object Oriented Programing Writing computer programs Based on Objects Instead of Actions Based on Data Instead of Logic.
11 Games and Content Session 4.1. Session Overview  Show how games are made up of program code and content  Find out about the content management system.
1 KIPA Game Engine Seminars Jonathan Blow Seoul, Korea November 29, 2002 Day 4.
Antigone Engine Kevin Kassing – Period
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Let’s Start! Pages 136 to 140 March 18, Facts about GameFactory2(TGF2) Is a game engine developed by Clickteam. Uses Object-oriented programming.
Geometric Objects and Transformations. Coordinate systems rial.html.
11 A First Game Program Session Session Overview  Begin the creation of an arcade game  Learn software design techniques that apply to any form.
Week 2 - Wednesday CS361.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Games Games GAMES. About Me:  Ariel Nehmad.  I’m 31 years old.  Live in Buenos Aires, Argentina.  CTO and father of Flare3D, FLSL and Flare3D Phys…
Web Games Programming An Introduction to Unity 3D.
Stream Processing Main References: “Comparing Reyes and OpenGL on a Stream Architecture”, 2002 “Polygon Rendering on a Stream Architecture”, 2000 Department.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
11 Adding Tomato Targets Session Session Overview  We now have a game which lets a player bounce a piece of cheese on a bread bat  Now we have.
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
Sample Video Game & Sound. The Plan 1.Game Theme 2.Game Structure 3.Sprites 4.Trackers 5.Collisions 6.Score 7.Levels 8.Splash Screens 9.Design 10.Implementation.
Learning Unity. Getting Unity
Game Maker Terminology
Making Python Pretty!. How to Use This Presentation… Download a copy of this presentation to your ‘Computing’ folder. Follow the code examples, and put.
Shader Study 이동현. Vision engine   Games Helldorado The Show Warlord.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Sprites, User Input, and Collision COSC 315 Fall 2014 Bridget M. Blodgett.
Games Development Game Architecture: Entities CO2301 Games Development 1 Week 22.
Week 8 - Wednesday.  What did we talk about last time?  Level order traversal  BST delete  2-3 trees.
1 Contents  Audio  Sprite  Input devices  Game production milestones  Course summary.
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Sky Boxes and Vector Math 2 Course Information CVG: Programming 4 My Name: Mark Walsh Website:
CSE 381 – Advanced Game Programming GLSL. Rendering Revisited.
Group9 Kenny Sanders, Ashneel Singh, Jillian Cornette, Justin Mills, Chris Woolfe, Nathaniel Escribano, Jason Hachen, Andrew Melnyk, Elizabeth Graham,
Simple Collision Detection By David Yan Under the direction of Professor Susan Rodger and Chari Distler Duke University, June 2015.
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
11 Adding a Bread Bat Session Session Overview  We have created a cheese sprite that bounces around the display  We now need to create a bread.
The Graphics Pipeline Revisited Real Time Rendering Instructor: David Luebke.
UFCFSU-30-13D Technologies for the Web An Introduction to Unity 3D.
Game Maker Tutorials Introduction Clickball IntroductionClickball Where is it? Shooting Where is it?Shooting.
Introduction to 3-D Viewing Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 27, 2003.
How to use a Pixel Shader CMT3317. Pixel shaders There is NO requirement to use a pixel shader for the coursework though you can if you want to You should.
Lecture Rendering pipeline, shaders and effects 1Elias Holmlid.
- Introduction - Graphics Pipeline
Scene Manager Creates and places movable objects like lights and cameras so as to access them efficiently, e.g. for rendering. Loads and assembles world.
Week 2 - Monday CS361.
3GB3 Game Design Unity 3D Basics.
2D Graphics and Animations in Unity 3D
Unit-2 Objects and Classes
Graphics Processing Unit
Introduction to Events
CS451Real-time Rendering Pipeline
Edvin von Otter & Todd Barker
Graphics Processing Unit
Chapter V Vertex Processing
UMBC Graphics for Games
Week 6: Time and triggers!
UE4 Vulkan Updates & Tips
Games Development Game Architecture: Entities
03 | Creating, Texturing and Moving Objects
Frame Buffers Fall 2018 CS480/680.
Presentation transcript:

Lecture Building a 3D-game using XNA 1Elias Holmlid

 First part  General thoughts on game engine architecture, and some XNA considerations  Second part  Adding a skybox and mouse-look to our previous code Elias Holmlid2

 Engine (library)  Shared package (library)  The actual game  Editor  Playpen (sandbox)  Content pipeline- extensions Elias Holmlid3

 Break down code into smaller components  RenderingComponent  PhysicsComponent ▪ Collision ▪ Response  SoundComponent  Components should not be aware of eachother  You might use the already existing GameComponent-class Elias Holmlid4

 When working in teams, naturally breaks down responsibilities  Easier to replace code  Alot easier to nail down bugs and performance problems Elias Holmlid5

6

 Since components are not aware of eachother, they have to use an indirect way to communicate  This can be accomplished using events Elias Holmlid7

 EventManager  Basically contains a dictionary from event type to a list of listeners for each event  When an event is sent, all the listeners are notified Elias Holmlid8

 Examples  PlayerDiedEvent  GameAboutToPauseEvent  LevelCompletedEvent Elias Holmlid9

 Break it down into separable parts: Elias Holmlid10

 Find a good way to quickly add new effects  For example, decide upon common variable / semantic names for different common  The application can then set the parameters automatically for you Elias Holmlid11

 SceneManager  CameraManager  LightManager  EffectManager Elias Holmlid12

 A tree containing the entire scene  Objects can be placed and rotated relatively to eachother  Easy to group objects Elias Holmlid13

Elias Holmlid14

Elias Holmlid15

 Example1: EnemyObject  Contains common stuff like position, model etc  Enemies might have different behaviors: ChaseBehavior, JumpAroundBehavior...  Example2: Camera  Camera does not control itself, instead a CameraController-class is moving the camera Elias Holmlid16

 Use a fixed time-step or multiply all your movement calculations with the time passed since the last frame  Game.IsFixedTimeStep = true/false  No ”best” approach: Shawn Hargreaves has a good (as always) article about this: 7/07/25/understanding-gametime.aspx Elias Holmlid17

 Flips the back-buffer when the electron beam travels to the top-left of the screen (a state called vertical retrace)  SynchronizeWithVerticalRetrace property of GraphicsDeviceManager Elias Holmlid18

 The most important rule:  Never allocate reference type objects (classes) while the game is being played  Value types are ok (structs, primitive types...)  The garbage collector is a much bigger problem on the Xbox360 Elias Holmlid19

 Garbage collection  Memory allocated on the heap exceeds a given limit: ▪ GC kicks in to release unused memory  Unacceptable 1: GC triggers too often  Unacceptable 2: GC triggers infrequently but it takes a looong time for it to complete  Read more here: /07/02/twin-paths-to-garbage-collector- nirvana.aspx /07/02/twin-paths-to-garbage-collector- nirvana.aspx Elias Holmlid20

 Use pooling  For particle systems, enemies etc  Should use this in non-garbage collected environments anyway Elias Holmlid21

 So, allocate everything while the game is loading  You might also force garbage collection through System.GC.Collect() which will reset memory count to zero ▪ Do not do this while playing the game though! Elias Holmlid22

 CPU or GPU bound? Elias Holmlid23

 How can you tell if you are GPU/CPU bound?  Some detective work is needed  Example: run the game at a tiny resolution. Does the framerate improve?  In that case, you are bound by the pixel shader stage ▪ Try doing cheaper pixel calculations ▪ Or if you are happy with the framerate, you can do more heavy vertex processing for free Elias Holmlid24

 Two blog-posts I recommend:  03/31/an-elf-in-a-box.aspx 03/31/an-elf-in-a-box.aspx  04/11/santa-s-production-line.aspx 04/11/santa-s-production-line.aspx  (Read them in that order)  Elias Holmlid25

 Subscribe to Shawn Hargreaves blog:   Hang around at the Creators Club Forum:   People there are really friendly, and if you’re lucky, Shawn himself will answer your questions Elias Holmlid26

 A cheap way to simulate scenery far far away  Imagine walking around in the center of a textured sphere, where the sphere is always moving along with you Elias Holmlid27

 We can use a cubemap for the sky-texture Elias Holmlid28

Elias Holmlid29  Use the local position of the vertex as a direction vector for lookup into the cube texture

 Turn off backside culling for sphere or change cullmode (we’ll be inside the sphere)  Always pass depth test and write maximum depth (1.0) for each pixel to depth-buffer  Nothing in the scene should be farther away than the sky Elias Holmlid30

 Cubemaps constructed with special tools  CubeMapGen is a free tool from AMD: pages/default.aspx pages/default.aspx Elias Holmlid31