1 Useful Tools for Making Video Games Part V An overview of.

Slides:



Advertisements
Similar presentations
An introduction to WebGL Viktor Kovács. Content A little 3D modeling. What is WebGL? Introducing Three.js. Visualizing GDL objects.
Advertisements

11 Reaction Timer Game Session 8.1. Session Overview  Find out how an XNA program can measure the passage of time and trigger events at certain points.
COMPUTER PROGRAMMING 2 Chapter 7 Sound. Objectives Find out how to prepare sounds for inclusion in Microsoft XNA projects. Incorporate sounds into XNA.
2D Graphics in XNA Game Studio Express (Modeling a Class in UML) Game Design Experience Professor Jim Whitehead February 5, 2008 Creative Commons Attribution.
Introduction to 3D in XNA Game Design Experience Professor Jim Whitehead February 27, 2009 Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0.
Sketchify Tutorial Graphics and Animation in Sketchify sketchify.sf.net Željko Obrenović
Triangles, Translations Game Design Experience Professor Jim Whitehead March 2, 2009 Creative Commons Attribution 3.0 (Except copyrighted images) creativecommons.org/licenses/by/3.0.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Shaders Feb 18, 2011 Creative Commons Attribution 3.0 (Except copyrighted.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Sound in games Think about truly memorable games – They almost always have.
Modeling and Animation with 3DS MAX R 3.1 Graphics Lab. Korea Univ. Reference URL :
Computer Science – Game DesignUC Santa Cruz CMPS 20: Game Design Experience January 14, 2010 Arnav Jhala.
GLWidget Description Jason Goffeney 3/8/2006. GLWidget The GLWidget class extends the Qt QGLWidget. The QGLWidget is a Qt Widget that happens to have.
COMPUTER PROGRAMMING 2 Timers. Game Idea: Mob Reaction Timer Use a timer variable to keep track of time and a variable for each player to measure the.
Getting Started. XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to XNA Game.
Week 2 - Wednesday CS361.
Geometric Transforms Changing coordinate systems.
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
Developing the Game User Interface (UI) Lesson 5.
11 Adding Sounds Session 7.1. Session Overview  Find out how to capture and manipulate sound on a Windows PC  Show how sound is managed as an item of.
User Input and Collisions COSC 315 Fall 2014 Bridget M. Blodgett.
Computer Science – Game DesignUC Santa Cruz Adapted from Jim Whitehead’s slides Announcements Prototype submissions will be directly from SVN on Gforge.
11 Using the Keyboard Session Session Overview  Introduce the keyboard device  Show how keys on a keyboard can be represented by enumerated types.
XP Tutorial 4 Special Animations. XP New Perspectives on Macromedia Flash MX Special Layers for Animation Animation Using a Motion Guide Layer.
Introduction to XNA Graphics Programming Asst. Prof. Rujchai Ung-arunyawee COE, KKU.
Rob Miles. Creating a Working MoodLight We know that colours in XNA are stored as values which represent the amount of red, blue, green and transparency.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
XNA An Introduction. What XNA is… Microsoft® XNA™ is composed of industry- leading software, services, resources, and communities focused on enabling.
2008/9/24 Kim, HyungSeok. HyungSeok Kim, Konkuk University Part I: Framework – 1. Windows creation – 2. Renderer – 3. Lights and Objects/Model loading.
XNA Game Studio 4.0 Keyboard and Mouse Controls + more on Animated Sprites.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
Rob Miles. How does an XNA game program work? Programs tell computers what to do A program is written in a programming language – C# is a programming.
3D Models and Meshes Asst. Prof. Rujchai Ung-arunyawee COE, KKU.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
XNA Basic Displaying Image & Collision Detect. What’s format image that XNA support? XNA support only.bmp.png and.jpg image..PNG have transparent region.
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
CHAPTER 6 Multiplayer XNA Game Studio 4.0. Objectives Discover how to detect and use individual button-press events in a game. Learn how to create and.
고려대학교 그래픽스 연구실 An Inventor Sampler - The Inventor mentor 고려대학교 그래픽스 연구실 민 성환.
G RAPHICS & I NTERACTIVE P ROGRAMMING Lecture 2 More Programming with Processing.
 Learn some important functions and process in OpenGL ES  Draw some triangles on the screen  Do some transformation on each triangle in each frame.
CHAPTER 2 The Game Loop - Variables, Types, Classes and Objects in XNA XNA Game Studio 4.0.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
Playing with Sprites. XNA Game Lifecycle In the faceBall demo program we bounced a smiley face around the graphical display against a background image.
Lecture 7 Midterm Review. OpenGL Libraries gl: Basic OpenGL library, e.g. primitives. glu: OpenGL Utility library, a set of functions to create texture.
XNA ● Proprietary Microsoft framework ● C#. Interface.
11 Using the Keyboard in XNA Session 9.1. Session Overview  Discover more detail on how the XNA keyboard is implemented  Find out how to use arrays.
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
Rob Miles. Using data in an XNA game program An XNA game program Draw and Update methods that are called to run the game Colours are held in XNA as four.
11 Adding Vibration Effects Session Session Overview  Describe how the vibration feature of the gamepad works  Show how an XNA program can control.
3D Cameras and Enemies COSC 315 Fall 2014 Bridget M. Blodgett.
XNA Sound Effects. float volume, pitch, pan; SoundEffect boing1; SoundEffect boing2; boing1 = Content.Load ("boing1"); boing2 = Content.Load ("boing2");
Computer Graphics Imaging Lecture 13 and 14 UV Mapping.
Rob Miles. Creating a Broken MoodLight An XNA game contains game data which is used by the Draw and Update methods – Update updates the game data – Draw.
Computer Science – Game DesignUC Santa Cruz Tile Engine.
2D Graphics CMT3311. This covers... How to make a transparent sprite How to add a sprite to your project and draw it Properties of sprites and how to.
Quick Intro to Unity Lecture 2.
What you will learn about today
- Introduction - Graphics Pipeline
Computer Graphics Imaging
Using and Creating Sprites
Chapter 3 Drawing In the World.
Ogre Overview.
Introduction to Events
Collision Detection.
Computer Animation UV Mapping.
Computer Animation Texture Mapping.
Model Editing (Continued)
ICT Gaming Lesson 3.
MTA-4201 Game Programming Chapter 8 : Scrolling Background & Font
Collisions with Static Objects
Presentation transcript:

1 Useful Tools for Making Video Games Part V An overview of

2 Things you need to install  Visual Studio 2005 or Visual C# Express Edition  Its service pack  XNA Game Studio  newtoxna.aspx

3 Displaying a 3D Model  Create a Windows Game project

4 Displaying a 3D Model  Add model to solution

5 Displaying a 3D Model // Set the 3D model to draw. Model myModel; // The aspect ratio determines how to scale 3d to 2d projection. float aspectRatio; protected override void LoadGraphicsContent(bool loadAllContent) { if (loadAllContent) { myModel = content.Load (“myModel"); } aspectRatio = graphics.GraphicsDevice.Viewport.Width / graphics.GraphicsDevice.Viewport.Height; }

6 Displaying a 3D Model // Set the position of the model in world space, and set the rotation. Vector3 modelPosition = Vector3.Zero; float modelRotation = 0.0f; // Set the position of the camera in world space, for our view matrix. Vector3 cameraPosition = new Vector3(0.0f, 50.0f, f); protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); // Copy any parent transforms. Matrix[] transforms = new Matrix[myModel.Bones.Count]; myModel.CopyAbsoluteBoneTransformsTo(transforms); // Draw the model. A model can have multiple meshes, so loop. foreach (ModelMesh mesh in myModel.Meshes) { // This is where the mesh orientation is set, as well as our camera and projection. foreach (BasicEffect effect in mesh.Effects) { effect.EnableDefaultLighting(); effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(modelRotation) * Matrix.CreateTranslation(modelPosition); effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up); effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 1.0f, f); } // Draw the mesh, using the effects set above. mesh.Draw(); }

7 Displaying a 3D Model  Transformation of model done through modifying its world matrix // update rotation angle protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); modelRotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.1f); base.Update(gameTime); }  Sample implementation can be found in Loading_3D_Model.zip

8 Keyboard and Mouse input  In the Update() function check for input KeyboardState keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown( Keys.Left ) {…}  mouseState is pressed as long as you keep your finger on the button, usually you want to detect the event once MouseState mouseState = Mouse.GetState(); if (mouseState.LeftButton == ButtonState.Released) released = true; // this is a global boolean if (mouseState.LeftButton == ButtonState.Pressed && released) { released = false; System.Console.WriteLine("left mouse clicked\n"); }

9 Camera  Determine the location and orientation of the camera object.  Create a view matrix using the camera position, orientation, and the world space's up vector.  Create a perspective matrix that determines the near and far clipping planes and the aspect of the projection.  In the Draw method of game, initialize a BasicEffect object with the transformational matrices created earlier (world, view projection) and then render all existing 3D models.

10 Camera  Matrix view = Matrix.CreateLookAt(cameraPosition, cameraLookat, cameraUp);  Matrix proj = Matrix.CreatePerspectiveFieldOfView(viewAngle, aspectRatio, nearClip, farClip); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect be in mesh.Effects) { be.Projection = proj; be.View = view; be.World = world; // eg. Matrix.CreateTranslation(…) } mesh.Draw(); }  Sample implementation can be found in Camera.zip

11 Skybox  apply a skybox-style TextureCube ("cube map") to a sphere using shader Effect SkySphereEffect = Content.Load ("SkySphere"); TextureCube SkyboxTexture = Content.Load ("uffizi_cross"); // Set the parameters of the effect SkySphereEffect.Parameters["ViewMatrix"].SetValue(myCamera.ViewMatrix); SkySphereEffect.Parameters["ProjectionMatrix"].SetValue(projectionMatrix); SkySphereEffect.Parameters["SkyboxTexture"].SetValue(SkyboxTexture);  Since the Effect and the Model are loaded separately, you need to apply the SkySphere effect to each Effect property on the ModelMeshPart of the SkySphere model.  Sample implementation can be found in skysphere.zip

12 Animation  Curve’s allows a path to be defined by a small number of control points with the Curve’s calculating the points on the path between the control points Curve  Add Curve3D.cs (found under cs134/lib/xna/content) to your project. Create two instances of this class, one for the position of the camera and the other for the lookAt vector. Also add variable to keep track of time:

13 Animation  Define a function called InitCurve() and specify the points that the camera will pass throught and the points that the camera will be looking at.  The number of points on the position and the lookAt curves don’t need to match, but the first and the last points on the curves should have the same time values if the curves oscillate  calculate the camera’s current position and orientation and update the view matrix  Sample implementation can be found in Animation.zip

14 References us/library/bb aspx