Difference between revisions of "Game Programming Class12"

esse quam videri
Jump to: navigation, search
m (Meshes)
m (Text replacement - "syntaxhighlight lang="csharp" line="1" " to "syntaxhighlight lang="csharp"")
 
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==BillBoards==
+
==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.
 
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 [http://creators.xna.com/en-US/sample/3daudio XNA 3DAudio example] has a good example of using billboards.
+
The XNA 3DAudio example from
 +
 
 +
<html>
 +
<a href="http://creators.xna.com/en-US/sample/3daudio">
 +
<img src="http://creators.xna.com/assets/cms/images/XNA_Audio3D_02_small.jpg"></a>
 +
<br />
 +
<a href="http://creators.xna.com/en-US/sample/3daudio">
 +
http://creators.xna.com/en-US/sample/3daudio</a>
 +
 
 +
</html>
 +
 
 +
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
 +
<syntaxhighlight lang="csharp">
 +
/// <summary>
 +
        /// Constructs a new quadrilateral drawing worker.
 +
        /// </summary>
 +
        public QuadDrawer(GraphicsDevice device)
 +
        {
 +
            graphicsDevice = device;
 +
 
 +
            effect = new AlphaTestEffect(device);
 +
 
 +
            effect.AlphaFunction = CompareFunction.Greater;
 +
            effect.ReferenceAlpha = 128;
  
Quad Drawer Class SpriteEntity/Quad Sprite I changed the name
+
            // Preallocate an array of four vertices.
 +
            vertices = new VertexPositionTexture[4];
  
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.zip IntoGameLibrary.zip
+
            vertices[0].Position = new Vector3(2, 2, 0);
 +
            vertices[1].Position = new Vector3(-2, 2, 0);
 +
            vertices[2].Position = new Vector3(2, -2, 0);
 +
            vertices[3].Position = new Vector3(-2, -2, 0);
 +
        }
 +
 
 +
 
 +
        /// <summary>
 +
        /// Draws a quadrilateral as part of the 3D world.
 +
        /// </summary>
 +
        public void DrawQuad(Texture2D texture, float textureRepeats,
 +
                            Matrix world, Matrix view, Matrix projection)
 +
        {
 +
            // Set our effect to use the specified texture and camera matrices.
 +
            effect.Texture = texture;
 +
 
 +
            effect.World = world;
 +
            effect.View = view;
 +
            effect.Projection = projection;
 +
 
 +
            // Update our vertex array to use the specified number of texture repeats.
 +
            vertices[0].TextureCoordinate = new Vector2(0, 0);
 +
            vertices[1].TextureCoordinate = new Vector2(textureRepeats, 0);
 +
            vertices[2].TextureCoordinate = new Vector2(0, textureRepeats);
 +
            vertices[3].TextureCoordinate = new Vector2(textureRepeats, textureRepeats);
 +
 
 +
            // Draw the quad.
 +
            effect.CurrentTechnique.Passes[0].Apply();
 +
 
 +
            graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
 +
        }
 +
</syntaxhighlight>
 +
 
 +
integrated in to QuadSprite
 +
 
 +
https://iam.colum.edu:8443/svn/XNAProg4/trunk/XNA4Jeff/IntoGameLibrary/ThreeD/QuadSprite.cs
  
 
==Meshes==
 
==Meshes==
 
A mesh is a collection of vertices, faces and edges that define a 3d shape.
 
A mesh is a collection of vertices, faces and edges that define a 3d shape.
 
XNA can import .X or .Fbx files.
 
XNA can import .X or .Fbx files.
.X files are Files created for DirectX, while FBX is an platform independant 3D mesh file type
+
.X files are Files created for DirectX, while FBX is an platform independent 3D mesh file type.
  
Mesh Example IntroMesh.zip http://brookfield.rice.iit.edu/jmeyers/gbrowser.php?file=/ITM496-595/ClassSource/Projects/IntroMesh/IntroMesh/Game1.cs
+
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 [http://www.turbosquid.com/xna TurboSquid],
 
You can get some free models from [http://www.turbosquid.com/xna TurboSquid],
Line 19: Line 97:
  
 
==Blender==
 
==Blender==
Blender is a free 3D program.
+
[http://www.blender.org/ Blender] is a free 3D program. It can export fbx models for xna.
# It can export fbx models for xna. Blender Installing Blender
+
 
# Getting Started with Blender 3D and XNA
+
# Installing Blender
# Blender Manual
+
# [http://www.virtualrealm.com.au/articles/blender-3d/installing-blender-3d/ Getting Started with Blender 3D and XNA]
# Blender_3D:_Noob_to_Pro
+
# [http://www.virtualrealm.com.au/articles/blender-3d/getting-started-with-blender-3d-and-xna/ Blender Manual]
# Beginner_Tutorials/Print_version
+
# [http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro Blender_3D:_Noob_to_Pro]
 +
# [http://en.wikibooks.org/wiki/Blender_3D:_Noob_to_Pro/Beginner_Tutorials/Print_version Beginner_Tutorials/Print_version]
  
 
==Homework==
 
==Homework==
Try out blender. Make a model and load it into XNA
+
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.

Latest revision as of 03:23, 9 February 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

/// <summary>
        /// Constructs a new quadrilateral drawing worker.
        /// </summary>
        public QuadDrawer(GraphicsDevice device)
        {
            graphicsDevice = device;

            effect = new AlphaTestEffect(device);

            effect.AlphaFunction = CompareFunction.Greater;
            effect.ReferenceAlpha = 128;

            // Preallocate an array of four vertices.
            vertices = new VertexPositionTexture[4];

            vertices[0].Position = new Vector3(2, 2, 0);
            vertices[1].Position = new Vector3(-2, 2, 0);
            vertices[2].Position = new Vector3(2, -2, 0);
            vertices[3].Position = new Vector3(-2, -2, 0);
        }


        /// <summary>
        /// Draws a quadrilateral as part of the 3D world.
        /// </summary>
        public void DrawQuad(Texture2D texture, float textureRepeats,
                             Matrix world, Matrix view, Matrix projection)
        {
            // Set our effect to use the specified texture and camera matrices.
            effect.Texture = texture;

            effect.World = world;
            effect.View = view;
            effect.Projection = projection;

            // Update our vertex array to use the specified number of texture repeats.
            vertices[0].TextureCoordinate = new Vector2(0, 0);
            vertices[1].TextureCoordinate = new Vector2(textureRepeats, 0);
            vertices[2].TextureCoordinate = new Vector2(0, textureRepeats);
            vertices[3].TextureCoordinate = new Vector2(textureRepeats, textureRepeats);

            // Draw the quad.
            effect.CurrentTechnique.Passes[0].Apply();

            graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, vertices, 0, 2);
        }

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.