Difference between revisions of "Game Programming Class12"

esse quam videri
Jump to: navigation, search
m (Text replacement - "</csharp>" to "</syntaxhighlight>")
m (Text replacement - "<csharp>" to "<syntaxhighlight lang="csharp" line="1" >")
Line 25: Line 25:
  
 
IntroQuad Project
 
IntroQuad Project
<csharp>
+
<syntaxhighlight lang="csharp" line="1" >
 
/// <summary>
 
/// <summary>
 
         /// Constructs a new quadrilateral drawing worker.
 
         /// Constructs a new quadrilateral drawing worker.

Revision as of 18:29, 25 January 2016

Safe Cropping zones

Show safe zones for XBox

Billboards

Billboards are basically textured squares (two triangles) that point towards the camera and appear to be a 3D model. They are cheaper and easier to work with than models many early 3D games consisted mainly of billboards. Billboards are still used to fake 3D objects.

The XNA 3DAudio example from


http://creators.xna.com/en-US/sample/3daudio

has a good example of using billboards. This example also demonstrates 3D audio.

Quad Drawer Class

SpriteEntity/Quad Sprite I changed the name

I've added these two classes to our IntroGameLibrary Project. Here's an example. I did change the projection view size and some of the scales of the billboards.

IntroQuad Project

 1 /// <summary>
 2         /// Constructs a new quadrilateral drawing worker.
 3         /// </summary>
 4         public QuadDrawer(GraphicsDevice device)
 5         {
 6             graphicsDevice = device;
 7 
 8             effect = new AlphaTestEffect(device);
 9 
10             effect.AlphaFunction = CompareFunction.Greater;
11             effect.ReferenceAlpha = 128;
12 
13             // Preallocate an array of four vertices.
14             vertices = new VertexPositionTexture[4];
15 
16             vertices[0].Position = new Vector3(2, 2, 0);
17             vertices[1].Position = new Vector3(-2, 2, 0);
18             vertices[2].Position = new Vector3(2, -2, 0);
19             vertices[3].Position = new Vector3(-2, -2, 0);
20         }
21 
22 
23         /// <summary>
24         /// Draws a quadrilateral as part of the 3D world.
25         /// </summary>
26         public void DrawQuad(Texture2D texture, float textureRepeats,
27                              Matrix world, Matrix view, Matrix projection)
28         {
29             // Set our effect to use the specified texture and camera matrices.
30             effect.Texture = texture;
31 
32             effect.World = world;
33             effect.View = view;
34             effect.Projection = projection;
35 
36             // Update our vertex array to use the specified number of texture repeats.
37             vertices[0].TextureCoordinate = new Vector2(0, 0);
38             vertices[1].TextureCoordinate = new Vector2(textureRepeats, 0);
39             vertices[2].TextureCoordinate = new Vector2(0, textureRepeats);
40             vertices[3].TextureCoordinate = new Vector2(textureRepeats, textureRepeats);
41 
42             // Draw the quad.
43             effect.CurrentTechnique.Passes[0].Apply();
44 
45             graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
46         }

integrated in to QuadSprite

https://iam.colum.edu:8443/svn/XNAProg4/trunk/XNA4Jeff/IntoGameLibrary/ThreeD/QuadSprite.cs

Meshes

A mesh is a collection of vertices, faces and edges that define a 3d shape. XNA can import .X or .Fbx files. .X files are Files created for DirectX, while FBX is an platform independent 3D mesh file type.

FBX is now a platform and has its own API and SDK from Autodesk

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=6837478

Mesh Class

https://iam.colum.edu:8443/svn/XNAProg4/trunk/XNA4Jeff/IntoGameLibrary/ThreeD/Mesh.cs

IntroMesh

You can get some free models from TurboSquid, or you can make your own models with Blender.

Blender

Blender is a free 3D program. It can export fbx models for xna.

  1. Installing Blender
  2. Getting Started with Blender 3D and XNA
  3. Blender Manual
  4. Blender_3D:_Noob_to_Pro
  5. Beginner_Tutorials/Print_version

Homework

Try out blender. Make a model and load it into XNA and draw a picture with models. The take a screenshot of your picture and post it on your site.