<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>www.computer-horror.co.cc</title>
	<atom:link href="http://azerdark.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://azerdark.wordpress.com</link>
	<description></description>
	<lastBuildDate>Sun, 09 Aug 2009 09:33:53 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='azerdark.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/c460ff3a361f2da96962118e4f143277?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>www.computer-horror.co.cc</title>
		<link>http://azerdark.wordpress.com</link>
	</image>
			<item>
		<title>XNA &#8211; TriangleStrip</title>
		<link>http://azerdark.wordpress.com/2009/08/09/xna-trianglestrip/</link>
		<comments>http://azerdark.wordpress.com/2009/08/09/xna-trianglestrip/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 09:30:41 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=956</guid>
		<description><![CDATA[
The idea behind TriangleStrips is that you should define each vertex only once. So for the first triangle, you have to define vertices 0,1 and 2. Now, for the next triangle, you only have to add vertex 3, XNA will always use the last 3 vertices to draw the triangle, so for the second triangle [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=956&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-744" title="xna_logo" src="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg?w=282&#038;h=163" border="0" alt="xna_logo" width="282" height="163" /></p>
<p style="text-align:justify;">The idea behind TriangleStrips is that you should define each vertex only once. So for the first triangle, you have to define vertices 0,1 and 2. Now, for the next triangle, you only have to add vertex 3, XNA will always use the last 3 vertices to draw the triangle, so for the second triangle it uses vertices 1, 2 and 3, which is correct.</p>
<p><img class="alignnone size-full wp-image-957" title="Untitled" src="http://azerdark.files.wordpress.com/2009/08/untitled.jpg?w=441&#038;h=255" alt="Untitled" width="441" height="255" /></p>
<p><span id="more-956"></span></p>
<pre class="brush: java;">

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace TriangleStripExample
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        GraphicsDevice device;
        BasicEffect basicEffect;
        QuakeCamera fpsCam;

        VertexPositionColor[] vertices;
        VertexDeclaration myVertexDeclaration;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = &quot;Content&quot;;
        }

        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = 750;
            graphics.PreferredBackBufferHeight = 500;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            fpsCam = new QuakeCamera(GraphicsDevice.Viewport);
            base.Initialize();
        }

        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;
            basicEffect = new BasicEffect(device, null);
            InitVertices();
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            KeyboardState keyState = Keyboard.GetState();
            MouseState mouseState = Mouse.GetState();
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            if (gamePadState.Buttons.Back == ButtonState.Pressed || keyState.IsKeyDown(Keys.Escape))
                this.Exit();

            fpsCam.Update(mouseState, keyState, gamePadState);

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            //draw triangles
            device.RenderState.CullMode = CullMode.None;
            basicEffect.World = Matrix.Identity;
            basicEffect.View = fpsCam.ViewMatrix;
            basicEffect.Projection = fpsCam.ProjectionMatrix;
            basicEffect.VertexColorEnabled = true;

            basicEffect.Begin();
            foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
            {
                pass.Begin();
                device.VertexDeclaration = myVertexDeclaration;
                device.DrawUserPrimitives&lt;VertexPositionColor&gt;(PrimitiveType.TriangleStrip, vertices, 0, 10);
                pass.End();
            }
            basicEffect.End();

            base.Draw(gameTime);
        }

        private void InitVertices()
        {
            myVertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);
            vertices = new VertexPositionColor[12];

            vertices[0] = new VertexPositionColor(new Vector3(-5, 1, 1), Color.Red);
            vertices[1] = new VertexPositionColor(new Vector3(-5, 5, 1), Color.Green);
            vertices[2] = new VertexPositionColor(new Vector3(-3, 1, 1), Color.Blue);

            vertices[3] = new VertexPositionColor(new Vector3(-3, 5, 1), Color.Gray);
            vertices[4] = new VertexPositionColor(new Vector3(-1, 1, 1), Color.Purple);
            vertices[5] = new VertexPositionColor(new Vector3(-1, 5, 1), Color.Orange);

            vertices[6] = new VertexPositionColor(new Vector3(1, 1, 1), Color.BurlyWood);
            vertices[7] = new VertexPositionColor(new Vector3(1, 5, 1), Color.Gray);
            vertices[8] = new VertexPositionColor(new Vector3(3, 1, 1), Color.Green);

            vertices[9] = new VertexPositionColor(new Vector3(3, 5, 1), Color.Yellow);
            vertices[10] = new VertexPositionColor(new Vector3(5, 1, 1), Color.Blue);
            vertices[11] = new VertexPositionColor(new Vector3(5, 5, 1), Color.Red);
        }
    }
}
</pre>
<p><strong></strong><br />
<strong></strong><br />
Source :<br />
XNA 3.0 Game Programming Recipes</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/956/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/956/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/956/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/956/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/956/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/956/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/956/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/956/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/956/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/956/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=956&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/08/09/xna-trianglestrip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg" medium="image">
			<media:title type="html">xna_logo</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/08/untitled.jpg" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>
	</item>
		<item>
		<title>C# Preprocessor</title>
		<link>http://azerdark.wordpress.com/2009/08/01/c-preprocessor/</link>
		<comments>http://azerdark.wordpress.com/2009/08/01/c-preprocessor/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 17:08:03 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Preprocessor]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=945</guid>
		<description><![CDATA[

These commands never translated and included into the executable file but these are very useful for compilation process. Using preprocessors, we can stop the compiler from compiling certain potion of code. This is very helpful in the situation where you are planning to release two versions of software one basic version which has less features [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=945&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img src="http://i151.photobucket.com/albums/s147/azer89/csharplogo.jpg" alt="" width="77" height="51" /></p>
<p style="text-align:justify;">
<p style="text-align:justify;">These commands never translated and included into the executable file but these are very useful for compilation process. Using preprocessors, we can stop the compiler from compiling certain potion of code. This is very helpful in the situation where you are planning to release two versions of software one basic version which has less features and one advance version which has more features. The preprocessor directives are all starts with the # symbol in the beginning of them.</p>
<p style="text-align:justify;">C# actually has almost all the standard preprocessor directives &#8211; it just happens to be that the functionality of some of them . The one notable directive that is missing is #include &#8211; and it makes sense that C# wouldn&#8217;t have it, because C# gets the same sort of functionality from the using statements (although there is the fact that #include refers to files and using refers to assemblies &#8211; so they are definitely not equivalent).</p>
<p>Rules</p>
<ol>
<li> Preprocessor directives must be on separate line</li>
<li> Must not terminate with semicolon compared to normal C# statements</li>
<li> Starts with # character</li>
<li> End of line comments are not allowed</li>
<li> Delimited comments are not allowed</li>
</ol>
<p><img class="alignnone size-full wp-image-954" title="blog" src="http://azerdark.files.wordpress.com/2009/08/blog.jpg?w=353&#038;h=123" alt="blog" width="353" height="123" /></p>
<p><span id="more-945"></span></p>
<h3>#if</h3>
<p style="text-align:justify;">lets you begin a conditional directive, testing a symbol or symbols to see if they evaluate to true. If they do evaluate to true, the compiler evaluates all the code between the #if and the next directive.</p>
<p>You can use the following operators to evaluate multiple symbols:</p>
<p>== (equality)</p>
<p>!= (inequality)</p>
<p>&amp;&amp; (and)</p>
<p>|| (or)</p>
<p style="text-align:justify;">#if, along with the #else, #elif, #endif, #define, and #undef directives, lets you include or exclude code based on the condition of one or more symbols. This can be most useful when compiling code for a debug build or when compiling for a specific configuration. A conditional directive beginning with a #if directive must explicitly be terminated with a #endif directive.</p>
<h3>#else</h3>
<p style="text-align:justify;">#else lets you create a compound conditional directive, such that, if none of the expressions in the preceding  #if or (optional)  #elif directives did not evaluate to true, the compiler will evaluate all code between #else and the subsequent #endif.</p>
<h3>#elif</h3>
<p style="text-align:justify;">#elif lets you create a compound conditional directive. The #elif expression will be evaluated if neither the preceding  #if nor any preceding (optional) #elif directive expressions evaluate to true. If a #elif expression evaluates to true, the compiler evaluates all the code between the #elif and the next directive.</p>
<h3>#endif</h3>
<p style="text-align:justify;">#endif specifies the end of a conditional directive, which began with the  #if directive.</p>
<p><em>example of #if, #else, #elif, #endif</em></p>
<pre class="brush: java;">
#if (!RELEASE)
    Console.WriteLine(”This is not a release version”);
#if (BETA)
    Console.WriteLine(”Beta, for limited release only”);
#elif (ALPHA)
    Console.WriteLine(”Alpha, for internal testing only”);
#endif
#else
    Console.WriteLine(”Welcome to Widgets 1.0?);
#endif
</pre>
<h3>#define</h3>
<p style="text-align:justify;">#define lets you define a symbol, such that, by using the symbol as the expression passed to the  #if directive, the expression will evaluate to true.</p>
<h3>#undef</h3>
<p style="text-align:justify;">#undef lets you undefine a symbol, such that, by using the symbol as the expression in a #if directive, the expression will evaluate to false.</p>
<p><em>#define and #undef example :</em></p>
<pre class="brush: java;">
#define MY_SYMBOL

/* Do Stuff */

#undef MY_SYMBOL
</pre>
<h3>#warning</h3>
<p style="text-align:justify;">#warning lets you generate a level one warning from a specific location in your code. #warning directives to output messages during compilation</p>
<pre class="brush: java;">

#if !DEBUG
#warning This code is NOT production ready
#endif
</pre>
<h3>#error</h3>
<p style="text-align:justify;">#error lets you generate an error from a specific location in your code. if the compiler encounters an #error it will report the problem and stop compiling. The #warning directive just causes a log entry to be displayed in the build output.</p>
<h3>#line</h3>
<p style="text-align:justify;">#line lets you modify the compiler&#8217;s line number and (optionally) the file name output for errors and warnings. his directive is mostly useful when you build a code generator that turns one source file into another.</p>
<p><em>example of #line and #error</em></p>
<pre class="brush: java;">

public static void Main(string[] args)
{
#line 100
#if DEBUG
#error This code is NOT production ready
#endif
}
</pre>
<h3>#region</h3>
<p style="text-align:justify;">#region lets you specify a block of code that you can expand or collapse when using the  outlining feature of the Visual Studio Code Editor.</p>
<h3>#endregion</h3>
<p style="text-align:justify;">#endregion marks the end of a  #region block. #region and #endregion – are completely ignored by the compiler. Instead these are used by the Visual Studio editor’s outlining feature.</p>
<p><em>#region and #endregion example</em></p>
<pre style="text-align:justify;">
<pre class="brush: java;">

#region myregion
    public static void Main(string[] args)
    {
        int Total = 0;
        for(int Lp = 1; Lp &lt; 10; Lp++)
	{
            LogLine(&quot;Total&quot;,Total.ToString());
            Total = Total + Lp;
       }
    }
#endregion
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/945/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/945/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/945/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=945&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/08/01/c-preprocessor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://i151.photobucket.com/albums/s147/azer89/csharplogo.jpg" medium="image" />

		<media:content url="http://azerdark.files.wordpress.com/2009/08/blog.jpg" medium="image">
			<media:title type="html">blog</media:title>
		</media:content>
	</item>
		<item>
		<title>XNA &#8211; Quaternion</title>
		<link>http://azerdark.wordpress.com/2009/07/24/xna-quaternion/</link>
		<comments>http://azerdark.wordpress.com/2009/07/24/xna-quaternion/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 16:27:31 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=935</guid>
		<description><![CDATA[
The XNA Framework provides the Quaternion structure to represent and calculate the efficient rotation about a vector around a specified angle. Quaternions represent a rotation. Typically, they are used for smooth interpolation between two angles, and for avoiding the gimbal lock problem that can occur with euler angles.

A Quaternion is much like a Matrix, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=935&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-744" title="xna_logo" src="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg?w=282&#038;h=163" border="0" alt="xna_logo" width="282" height="163" /></p>
<p style="text-align:justify;">The XNA Framework provides the Quaternion structure to represent and calculate the efficient rotation about a vector around a specified angle. Quaternions represent a rotation. Typically, they are used for smooth interpolation between two angles, and for avoiding the gimbal lock problem that can occur with euler angles.</p>
<p style="text-align:justify;">
<p style="text-align:justify;">A Quaternion is much like a Matrix, but can only store a rotation. Don’t let the name of this thing scare you away (for first time i hear it, i thinks it is a weird planet&#8217;s name <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  ), although it’s very hard to understand mathematically (it makes my head blown away) a quaternion is VERY very easy to use.</p>
<p style="text-align:justify;"><img class="alignnone size-full wp-image-940" title="Untitled" src="http://azerdark.files.wordpress.com/2009/07/untitled6.jpg?w=523&#038;h=406" alt="Untitled" width="523" height="406" /></p>
<p style="text-align:justify;">
<p style="text-align:justify;">
<p style="text-align:justify;">In this tutorial, we will create a simple example program using quaternion, we will draw a spacecraft and it would be flying through 3D world.</p>
<p style="text-align:justify;"><span id="more-935"></span></p>
<p><strong>                       </strong><br />
<strong>                       </strong><br />
First, we define two variabel below</p>
<pre class="brush: java;">
Vector3 spacecraftPosition;
Quaternion spacecraftRotation;
</pre>
<p><strong>                       </strong><br />
<strong>                       </strong><br />
Initial state for our variables</p>
<pre class="brush: java;">
spacecraftPosition = new Vector3(-1, 1, 50);
spacecraftRotation = Quaternion.Identity;
</pre>
<p><strong>                       </strong><br />
<strong>                       </strong><br />
Get the rotation</p>
<pre class="brush: java;">
Quaternion additionalRotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), updownRotation) * Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), leftrightRotation);
spacecraftRotation *= additionalRotation;
AddToSpacecraftPosition(new Vector3(0, 0, -1)); // moving forward
</pre>
<p><strong>                       </strong><br />
<strong>                       </strong><br />
Update spacecraft position</p>
<pre class="brush: java;">
float moveSpeed = 0.05f;
Vector3 rotatedVector = Vector3.Transform(vectorToAdd, spacecraftRotation);
spacecraftPosition += moveSpeed * rotatedVector;
</pre>
<p><strong>                       </strong><br />
<strong>                       </strong><br />
Complete code of Game1.cs</p>
<pre class="brush: java;">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace BookCode
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        GraphicsDevice device;
        CoordCross cCross;
        Model spacecraftModel;
        Matrix[] modelTransforms;

        Matrix viewMatrix;
        Matrix projectionMatrix;

        QuaternionRotation quatRotation;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = &quot;Content&quot;;
            Window.Title = &quot;Quaternion Example&quot;;
        }

        protected override void Initialize()
        {
            base.Initialize();

            float viewAngle = MathHelper.PiOver4;
            float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
            float nearPlane = 0.5f;
            float farPlane = 100.0f;
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(viewAngle, aspectRatio,
                nearPlane, farPlane);

            quatRotation = new QuaternionRotation();
            UpdateViewMatrix();
        }

        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;
            cCross = new CoordCross(device);
            spacecraftModel = Content.Load&lt;Model&gt;(&quot;p1_pencil&quot;);
            modelTransforms = new Matrix[spacecraftModel.Bones.Count];
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
            KeyboardState keyState = Keyboard.GetState();

            if (gamePadState.Buttons.Back == ButtonState.Pressed || keyState.IsKeyDown(Keys.Escape))
                this.Exit();

            quatRotation.Update();
            UpdateViewMatrix();
            base.Update(gameTime);
        }

        private void UpdateViewMatrix()
        {
            Vector3 cameraOriginalPosition = new Vector3(0, 0, 1);
            Vector3 cameraRotatedPosition = Vector3.Transform(cameraOriginalPosition, quatRotation.SpacecraftRotation);
            Vector3 cameraFinalPosition = quatRotation.SpacecraftPosition + cameraRotatedPosition;

            Vector3 cameraOriginalUpVector = new Vector3(0, 1, 0);
            Vector3 cameraRotatedUpVector = Vector3.Transform(cameraOriginalUpVector, quatRotation.SpacecraftRotation);

            viewMatrix = Matrix.CreateLookAt(cameraFinalPosition, quatRotation.SpacecraftPosition, cameraRotatedUpVector);
        }

        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            //draw coordcross
            cCross.Draw(viewMatrix, projectionMatrix);

            //draw model
            Matrix worldMatrix = Matrix.CreateScale(1.0f / 5000.0f) * Matrix.CreateFromQuaternion(quatRotation.SpacecraftRotation) * Matrix.CreateTranslation(quatRotation.SpacecraftPosition);
            spacecraftModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
            foreach (ModelMesh mesh in spacecraftModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
                    effect.View = viewMatrix;
                    effect.Projection = projectionMatrix;
                }
                mesh.Draw();
            }

            base.Draw(gameTime);
        }
    }
}
</pre>
<p><strong>                       </strong><br />
<strong>                       </strong><br />
Complete code of QuaternionRotation.cs</p>
<pre class="brush: java;">
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;

namespace BookCode
{
    class QuaternionRotation
    {
        Vector3 spacecraftPosition;
        Quaternion spacecraftRotation;       

        public QuaternionRotation()
        {
            spacecraftPosition = new Vector3(-1, 1, 50);
            spacecraftRotation = Quaternion.Identity;
        }

        public void Update()
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);            

            float updownRotation = 0.0f;
            float leftrightRotation = 0.0f;

            leftrightRotation -= gamePadState.ThumbSticks.Left.X / 500.0f;
            updownRotation += gamePadState.ThumbSticks.Left.Y / 500.0f;

            KeyboardState keys = Keyboard.GetState();
            if (keys.IsKeyDown(Keys.Up)  || keys.IsKeyDown(Keys.W))
                updownRotation = 0.025f;
            if (keys.IsKeyDown(Keys.Down) || keys.IsKeyDown(Keys.S))
                updownRotation = -0.025f;
            if (keys.IsKeyDown(Keys.Right) || keys.IsKeyDown(Keys.D))
                leftrightRotation = -0.025f;
            if (keys.IsKeyDown(Keys.Left) || keys.IsKeyDown(Keys.A))
                leftrightRotation = 0.025f;

            leftrightRotation -= gamePadState.ThumbSticks.Left.X / 500.0f;
            updownRotation += gamePadState.ThumbSticks.Left.Y / 500.0f;

            Quaternion additionalRotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), updownRotation) * Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), leftrightRotation);
            spacecraftRotation *= additionalRotation;

            AddToSpacecraftPosition(new Vector3(0, 0, -1));  // moving forward
        }

        private void AddToSpacecraftPosition(Vector3 vectorToAdd)
        {
            float moveSpeed = 0.05f;
            Vector3 rotatedVector = Vector3.Transform(vectorToAdd, spacecraftRotation);
            spacecraftPosition += moveSpeed * rotatedVector;
        }

        public Vector3 SpacecraftPosition
        {
            get { return spacecraftPosition; }
            set { spacecraftPosition = value; }
        }

        public Quaternion SpacecraftRotation
        {
            get { return spacecraftRotation; }
            set { spacecraftRotation = value; }
        }

    }
}
</pre>
<p><strong>                       </strong><br />
<strong>                       </strong><br />
References:<br />
<a href="http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Quaternions.php">http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Quaternions.php</a><br />
<a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.quaternion.aspx">http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.quaternion.aspx</a><br />
<a href="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.quaternion_members.aspx">http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.quaternion_members.aspx</a><br />
<strong>                       </strong><br />
<strong>                       </strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/935/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/935/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/935/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/935/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/935/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/935/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/935/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/935/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/935/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/935/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=935&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/24/xna-quaternion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg" medium="image">
			<media:title type="html">xna_logo</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/untitled6.jpg" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>
	</item>
		<item>
		<title>Linux Mint 7 Video Installation</title>
		<link>http://azerdark.wordpress.com/2009/07/19/linux-mint-7-video-installation/</link>
		<comments>http://azerdark.wordpress.com/2009/07/19/linux-mint-7-video-installation/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 16:30:55 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Open Source Tutorial]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[linux mint 7]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=913</guid>
		<description><![CDATA[
                                          
Just a video about Linux Mint 7 Installation.
      [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=913&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p style="text-align:center;"><img class="size-full wp-image-918 aligncenter" title="linuxmint7logo" src="http://azerdark.files.wordpress.com/2009/07/linuxmint7logo.png?w=200&#038;h=200" alt="linuxmint7logo" width="200" height="200" /><br />
<strong>                                          </strong><br />
Just a video about Linux Mint 7 Installation.<br />
<strong>                                          </strong><br />
Well, Linux Mint 7 is a great Distro <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<strong>                                          </strong><br />
<span style="text-align:center; display: block;"><a href="http://azerdark.wordpress.com/2009/07/19/linux-mint-7-video-installation/"><img src="http://img.youtube.com/vi/9ShbhYytrQ0/2.jpg" alt="" /></a></span></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/913/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/913/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/913/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/913/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/913/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/913/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/913/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/913/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/913/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/913/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=913&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/19/linux-mint-7-video-installation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/linuxmint7logo.png" medium="image">
			<media:title type="html">linuxmint7logo</media:title>
		</media:content>

		<media:content url="http://img.youtube.com/vi/9ShbhYytrQ0/2.jpg" medium="image" />
	</item>
		<item>
		<title>XNA &#8211; Camera Rotation</title>
		<link>http://azerdark.wordpress.com/2009/07/19/xna-camera-rotation/</link>
		<comments>http://azerdark.wordpress.com/2009/07/19/xna-camera-rotation/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 14:34:26 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=905</guid>
		<description><![CDATA[
In this article, we will create a simple XNA program that load a 3D model, and rotating the camera around the model. In this example,  showing how to moving your camera position around the model. Camera target and camera up vector will remain same, what we need is to change camera position vector.


First, define variables [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=905&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-744" title="xna_logo" src="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg?w=282&#038;h=163" border="0" alt="xna_logo" width="282" height="163" /></p>
<p style="text-align:justify;">In this article, we will create a simple XNA program that load a 3D model, and rotating the camera around the model. In this example,  showing how to moving your camera position around the model. Camera target and camera up vector will remain same, what we need is to change camera position vector.</p>
<p><img class="alignnone size-full wp-image-906" title="Untitled" src="http://azerdark.files.wordpress.com/2009/07/untitled5.jpg?w=523&#038;h=365" alt="Untitled" width="523" height="365" /></p>
<p><span id="more-905"></span></p>
<p>First, define variables for projectionMatrix and viewMatrix</p>
<pre class="brush: java;">
Matrix viewMatrix;
Matrix projectionMatrix;

Vector3 camPosition;
Vector3 camTarget;
Vector3 camUpVector;

float viewAngle;
float aspectRatio;
float nearPlane;
float farPlane;
</pre>
<p style="text-align:justify;">Since we are using world space coordinates, this is very easy to do. Let&#8217;s first add a variable &#8216;angle&#8217; to our class to store the current rotation angle. Just add this one to your variables.</p>
<pre class="brush: java;">
private float angle = 0f;
</pre>
<p>Setting up camera</p>
<pre class="brush: java;">
private void SetUpCamera()
{
    camPosition = new Vector3(35, 0, 0);
    camTarget = new Vector3(0, 0, 0);
    camUpVector = new Vector3(0, 1, 0);
    viewMatrix = Matrix.CreateLookAt(camPosition, camTarget, camUpVector);

    viewAngle = MathHelper.PiOver4;
    aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
    nearPlane = 0.5f;
    farPlane = 500.0f;
    projectionMatrix = Matrix.CreatePerspectiveFieldOfView(viewAngle, aspectRatio, nearPlane, farPlane);
}
</pre>
<p style="text-align:justify;">Now, we should increase this variable with 0.05f every frame. We place it in Update method, it is called 60 times each second</p>
<pre class="brush: java;">
protected override void Update(GameTime gameTime)
{
    if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
        this.Exit();

     angle += 0.010f;

     base.Update(gameTime);
 }
</pre>
<p style="text-align:justify;">Rotating camera around Y Axis (Pitch). Rotating view matrix based on angle variable. Remember that CreateRotation method using radian.</p>
<pre class="brush: java;">
Matrix rotationMatrix = Matrix.CreateRotationY(3 * angle);
Vector3 transformedReference = Vector3.Transform(camPosition, rotationMatrix);
Vector3 cameraLookat = camPosition + transformedReference;
viewMatrix = Matrix.CreateLookAt(transformedReference, camTarget, camUpVector);
</pre>
<p>Complete code&#8230;..</p>
<pre class="brush: java;">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace SimpleRotation
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        GraphicsDevice device;

        Model myModel;
        Matrix[] modelTransforms;

        Matrix viewMatrix;
        Matrix projectionMatrix;

        Vector3 camPosition;
        Vector3 camTarget;
        Vector3 camUpVector;

        float viewAngle;
        float aspectRatio;
        float nearPlane;
        float farPlane;

        private float angle = 0f;        

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = &quot;Content&quot;;
        }

        protected override void Initialize()
        {
           graphics.PreferredBackBufferWidth = 750;
           graphics.PreferredBackBufferHeight = 500;
           graphics.IsFullScreen = false;
           graphics.ApplyChanges();
           Window.Title = &quot;Riemer's XNA Tutorials -- Series 1&quot;;        

           base.Initialize();
        }

        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;
            spriteBatch = new SpriteBatch(GraphicsDevice);

            myModel = Content.Load&lt;Model&gt;(&quot;p1_pencil&quot;);
            modelTransforms = new Matrix[myModel.Bones.Count];

            SetUpCamera();
        }

        private void SetUpCamera()
        {
            camPosition = new Vector3(35, 0, 0);
            camTarget = new Vector3(0, 0, 0);
            camUpVector = new Vector3(0, 1, 0);
            viewMatrix = Matrix.CreateLookAt(camPosition, camTarget, camUpVector);

            viewAngle = MathHelper.PiOver4;
            aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
            nearPlane = 0.5f;
            farPlane = 500.0f;
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(viewAngle, aspectRatio, nearPlane, farPlane);
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

             angle += 0.010f;

             base.Update(gameTime);
         }

         protected override void Draw(GameTime gameTime)
         {
             device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

             // setting up rotation
             Matrix rotationMatrix = Matrix.CreateRotationY(3 * angle);
             Vector3 transformedReference = Vector3.Transform(camPosition, rotationMatrix);
             Vector3 cameraLookat = camPosition + transformedReference;
             viewMatrix = Matrix.CreateLookAt(transformedReference, camTarget, camUpVector);

             //draw model
             myModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
             Matrix worldMatrix2 = Matrix.CreateScale(0.01f, 0.01f, 0.01f);
             foreach (ModelMesh mesh in myModel.Meshes)
             {
                 foreach (BasicEffect effect in mesh.Effects)
                 {
                     effect.EnableDefaultLighting();
                     effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix2;
                     effect.View = viewMatrix;
                     effect.Projection = projectionMatrix;
                 }
                 mesh.Draw();
             }          

             base.Draw(gameTime);
         }
     }
}
</pre>
<p><strong>                                 </strong><br />
<strong>                                 </strong><br />
When you run the application, you will see that your model is spinning around its (0,0,0) point<br />
<strong>                                 </strong><br />
<strong>                                 </strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/905/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/905/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/905/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=905&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/19/xna-camera-rotation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg" medium="image">
			<media:title type="html">xna_logo</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/untitled5.jpg" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>
	</item>
		<item>
		<title>XNA &#8211; Using Effect</title>
		<link>http://azerdark.wordpress.com/2009/07/19/xna-using-effect/</link>
		<comments>http://azerdark.wordpress.com/2009/07/19/xna-using-effect/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 02:55:15 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=895</guid>
		<description><![CDATA[
The XNA Content Pipeline is pretty good. It implifies the process for importing and loading models, textures, and other content. Unfortunately, it is optimized for loading data, not code. Effect files are essentially code, so an alternative approach could provide additional benefits.
Like the XNA Content Pipeline, Effect Generator compiles your .fx files at build time, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=895&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-744" title="xna_logo" src="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg?w=282&#038;h=163" border="0" alt="xna_logo" width="282" height="163" /></p>
<p style="text-align:justify;"><span>The XNA Content Pipeline is pretty good. It implifies the process for importing and loading models, textures, and other content. Unfortunately, it is optimized for loading data, not code. Effect files are essentially code, so an alternative approach could provide additional benefits.</span></p>
<p style="text-align:justify;">Like the XNA Content Pipeline, Effect Generator compiles your .fx files at build time, reducing game load times. Additionally, Effect Generator further simplifies run-time loading and effect parameterization.<br />
<strong>                              </strong><br />
<strong>                              </strong></p>
<p style="text-align:justify;">Place your effect file in Content folder :</p>
<p style="text-align:justify;"><img class="alignnone size-full wp-image-899" title="Untitled" src="http://azerdark.files.wordpress.com/2009/07/untitled4.jpg?w=352&#038;h=254" alt="Untitled" width="352" height="254" /></p>
<p><strong>                              </strong><br />
<strong>                              </strong></p>
<p style="text-align:justify;"><span>We start by declaring an Effect:</span></p>
<pre class="brush: java;">
Effect effect;
</pre>
<p><strong>                              </strong><br />
<strong> </strong><span>We&#8217;ll use the Content pipeline to load an instance of the Effect class</span><span>:</span></p>
<pre class="brush: java;">
effect = Content.Load&lt;Effect&gt;(&quot;effects&quot;);
</pre>
<p><strong>                              </strong><br />
<span>And render using the effect:</span></p>
<pre class="brush: java;">
effect.CurrentTechnique = effect.Techniques[&quot;Pretransformed&quot;];
effect.Begin();
foreach (EffectPass pass in effect.CurrentTechnique.Passes)
{
    pass.Begin();

    pass.End();
}
effect.End();
</pre>
<p><span id="more-895"></span><br />
The complete code :</p>
<pre class="brush: java;">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace EffectsExample
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        GraphicsDevice device;
        Effect effect;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = &quot;Content&quot;;
        }

        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = 500;
            graphics.PreferredBackBufferHeight = 500;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Window.Title = &quot;Effect&quot;;

            base.Initialize();
        }

        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;
            spriteBatch = new SpriteBatch(GraphicsDevice);

            effect = Content.Load&lt;Effect&gt;(&quot;effects&quot;);
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            device.Clear(Color.DarkSlateBlue);

            effect.CurrentTechnique = effect.Techniques[&quot;Pretransformed&quot;];
            effect.Begin();
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Begin();

                pass.End();
            }
            effect.End();

            base.Draw(gameTime);
        }
    }
}
</pre>
<p><strong>                              </strong><br />
<strong>                              </strong><br />
Other source :<br />
<a href="http://msdn.microsoft.com/en-us/library/bb203872.aspx">http://msdn.microsoft.com/en-us/library/bb203872.aspx</a><br />
<a href="http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/The_effect_file.php">http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/The_effect_file.php</a><br />
<strong>                              </strong><br />
<strong>                              </strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/895/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/895/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/895/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=895&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/19/xna-using-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg" medium="image">
			<media:title type="html">xna_logo</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/untitled4.jpg" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>
	</item>
		<item>
		<title>XNA &#8211; Set Up Camera</title>
		<link>http://azerdark.wordpress.com/2009/07/18/xna-set-up-camera/</link>
		<comments>http://azerdark.wordpress.com/2009/07/18/xna-set-up-camera/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 16:44:50 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=868</guid>
		<description><![CDATA[
Before we render 3D world, we need set up camera. We do this by specifying the View and Projection matrices. Before rendering, both matrices are needed so the graphics card can correctly transform 3D world to 2D screen in our monitor.
Setting up camera in 3D world comes down to specifying two matrices. We can save [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=868&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-744" title="xna_logo" src="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg?w=282&#038;h=163" border="0" alt="xna_logo" width="282" height="163" /></p>
<p style="text-align:justify;">Before we render 3D world, we need set up camera. We do this by specifying the View and Projection matrices. Before rendering, both matrices are needed so the graphics card can correctly transform 3D world to 2D screen in our monitor.</p>
<p style="text-align:justify;">Setting up camera in 3D world comes down to specifying two matrices. We can save the camera position and direction in a single matrix, which is called the View matrix. To create the View matrix, XNA needs to know the Position, Targer, and Up vector of camera. We can also save the view frustum, which is the part of the 3D world that is actually seen by the camera, in another matrix, which is called the Projection matrix.</p>
<p style="text-align:justify;"><img class="alignnone size-full wp-image-877" title="Untitled" src="http://azerdark.files.wordpress.com/2009/07/untitled.jpg?w=522&#038;h=388" alt="Untitled" width="522" height="388" /></p>
<p style="text-align:justify;"><span id="more-868"></span></p>
<p><strong>                                        </strong><br />
<strong>View Matrix</strong></p>
<p style="text-align:justify;">The View matrix holds the definition of the camera position and the direction into which it is looking. We can create this matrix by a simple call method CreateLookAt</p>
<pre class="brush: java;">
public static Matrix CreateLookAt (
         Vector3 cameraPosition,
         Vector3 cameraTarget,
         Vector3 cameraUpVector
)
</pre>
<address><em><span style="text-decoration:underline;">Parameters :</span></em></address>
<address><em>cameraPosition</em><em> &#8211; The position of the camera.</em></address>
<address>cameraTarget <em>- The target towards which the camera is pointing.</em></address>
<address>cameraUpVector &#8211; <em>The direction that is &#8220;up&#8221; from the camera&#8217;s point of view.</em></address>
<p><strong>                                        </strong><br />
<strong>                                        </strong><br />
<strong>View Frustum</strong></p>
<p style="text-align:justify;">A frustum in computer graphics is generally a volume of 3D space, defined as the part of a rectangular pyramid that lies between two planes perpendicular to its center line. A frustum is often used to represent what a &#8220;camera&#8221; sees in your 3D space.</p>
<p style="text-align:justify;"><img class="alignnone size-full wp-image-873" title="image006" src="http://azerdark.files.wordpress.com/2009/07/image006.jpg?w=553&#038;h=288" alt="image006" width="553" height="288" /></p>
<p style="text-align:justify;">Look at figure below, the pyramid minus the top of the left side of the image is called  view fustrum. All object you instruct XNA to render, only inside this volume are actually rendered to the screen</p>
<pre class="brush: java;">
public static Matrix CreatePerspectiveFieldOfView (
         float fieldOfView,
         float aspectRatio,
         float nearPlaneDistance,
         float farPlaneDistance
)
</pre>
<address><span style="text-decoration:underline;">Parameters :</span></address>
<address>fieldOfView &#8211; Field of view in radians.</address>
<address>aspectRatio &#8211; Aspect ratio, defined as view space width divided by height.</address>
<address>nearPlaneDistance &#8211; Distance to the near view plane.</address>
<address>farPlaneDistance &#8211; Distance to the far view plane.</address>
<p><strong>                                        </strong><br />
<strong>                                        </strong><br />
<strong>Example Code</strong><em><br />
</em></p>
<pre class="brush: java;">
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace ViewCamera
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        BasicEffect basicEffect;
        GraphicsDevice device;

        Model myModel;
        Matrix[] modelTransforms;

        Matrix viewMatrix;
        Matrix projectionMatrix;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = &quot;Content&quot;;
        }

        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = 700;
            graphics.PreferredBackBufferHeight = 500;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();
            Window.Title = &quot;View Camera Example&quot;;

            base.Initialize();

            float viewAngle = MathHelper.PiOver4;
            float aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
            float nearPlane = 0.5f;
            float farPlane = 500.0f;
            projectionMatrix = Matrix.CreatePerspectiveFieldOfView(viewAngle, aspectRatio, nearPlane, farPlane);
        }

        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;
            basicEffect = new BasicEffect(device, null);

            myModel = Content.Load&lt;Model&gt;(&quot;tank&quot;);
            modelTransforms = new Matrix[myModel.Bones.Count];
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            Vector3 camPosition = new Vector3(7, 8, 8);
            Vector3 camTarget = new Vector3(0, 0, 0);
            Vector3 camUpVector = new Vector3(0, 1, 0);
            viewMatrix = Matrix.CreateLookAt(camPosition, camTarget, camUpVector);

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

            basicEffect.World = Matrix.Identity;
            basicEffect.View = viewMatrix;
            basicEffect.Projection = projectionMatrix;
            basicEffect.Begin();
            basicEffect.End();

            //draw model
            Matrix worldMatrix = Matrix.CreateScale(0.01f, 0.01f, 0.01f);
            myModel.CopyAbsoluteBoneTransformsTo(modelTransforms);

            foreach (ModelMesh mesh in myModel.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
                    effect.View = viewMatrix;
                    effect.Projection = projectionMatrix;
                }
                mesh.Draw();
            }            

            base.Draw(gameTime);
        }
    }
}
</pre>
<p><strong>                                        </strong><br />
<strong>                                        </strong><br />
Sorry i don&#8217;t upload the complete source code files&#8230;because size of tank model file is very huge :/</p>
<p><strong>                                        </strong><br />
<strong>                                        </strong><br />
Source :</p>
<p><em>XNA 3.0 Game Programming Recipes &#8211; Riemer Grootjans<br />
</em><br />
<strong>                                        </strong><br />
<strong>                                        </strong></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/868/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/868/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/868/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/868/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/868/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/868/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/868/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/868/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/868/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/868/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=868&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/18/xna-set-up-camera/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg" medium="image">
			<media:title type="html">xna_logo</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/untitled.jpg" medium="image">
			<media:title type="html">Untitled</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/image006.jpg" medium="image">
			<media:title type="html">image006</media:title>
		</media:content>
	</item>
		<item>
		<title>Enable Ping Replies From Win Server 2008</title>
		<link>http://azerdark.wordpress.com/2009/07/17/enable-ping-replies-from-win-server-2008/</link>
		<comments>http://azerdark.wordpress.com/2009/07/17/enable-ping-replies-from-win-server-2008/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 10:29:55 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[Computer Networking]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=859</guid>
		<description><![CDATA[
Windows Firewall in Windows Server 2008 has very tight security. For default, ping to Windows Server 2008 won&#8217;t get any response. Here&#8217;s the configuration to enable ping replies :
Goto Window Firewall with Advance Settings from Administrator Tools menu.

Look into list in the left and Click Inbound Rules
Right click File and Sharing (Echo Request &#8211; ICMPv4-In) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=859&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-863" title="windows2008logoas2" src="http://azerdark.files.wordpress.com/2009/07/windows2008logoas2.png?w=236&#038;h=91" alt="windows2008logoas2" width="236" height="91" /></p>
<p>Windows Firewall in Windows Server 2008 has very tight security. For default, ping to Windows Server 2008 won&#8217;t get any response. Here&#8217;s the configuration to enable ping replies :</p>
<p>Goto Window Firewall with Advance Settings from Administrator Tools menu.</p>
<p><img class="alignnone size-full wp-image-860" title="Untitled1" src="http://azerdark.files.wordpress.com/2009/07/untitled1.jpg?w=514&#038;h=320" alt="Untitled1" width="514" height="320" /></p>
<p>Look into list in the left and Click <em>Inbound Rules</em></p>
<p>Right click<em> File and Sharing (Echo Request &#8211; ICMPv4-In) </em>and choose <em>Enable Rule</em></p>
<p><em><img class="alignnone size-full wp-image-861" title="Untitled2" src="http://azerdark.files.wordpress.com/2009/07/untitled2.jpg" alt="Untitled2" /><br />
</em></p>
<p>Do same thing to <em>Distributed Transaction Coordinator (TCP-In)</em></p>
<p><img class="alignnone size-full wp-image-862" title="Untitled3" src="http://azerdark.files.wordpress.com/2009/07/untitled3.jpg" alt="Untitled3" /></p>
<p>Okay, now you can ping your server machine <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/859/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/859/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/859/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/859/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/859/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/859/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/859/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/859/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/859/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/859/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=859&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/17/enable-ping-replies-from-win-server-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/windows2008logoas2.png" medium="image">
			<media:title type="html">windows2008logoas2</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/untitled1.jpg" medium="image">
			<media:title type="html">Untitled1</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/untitled2.jpg" medium="image">
			<media:title type="html">Untitled2</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/untitled3.jpg" medium="image">
			<media:title type="html">Untitled3</media:title>
		</media:content>
	</item>
		<item>
		<title>Moonlight &#8211; Open Source Implementation for Silverlight</title>
		<link>http://azerdark.wordpress.com/2009/07/15/moonlight-open-source-implementation-for-silverlight/</link>
		<comments>http://azerdark.wordpress.com/2009/07/15/moonlight-open-source-implementation-for-silverlight/#comments</comments>
		<pubDate>Wed, 15 Jul 2009 15:51:24 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Open Source Reference]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[moonlight]]></category>
		<category><![CDATA[silverlight]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=847</guid>
		<description><![CDATA[
What is Moonlight ?
Moonlight is an open source implementation of Silverlight (http://silverlight.net), primarily for Linux and other Unix/X11 based operating systems. In September of 2007, Microsoft and Novell announced a technical collaboration that includes access to Microsoft&#8217;s test suites for Silverlight and the distribution of a Media Pack for Linux users that will contain licensed [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=847&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-851" title="moonlight_logo" src="http://azerdark.files.wordpress.com/2009/07/moonlight_logo.png?w=100&#038;h=125" alt="moonlight_logo" width="100" height="125" /></p>
<p><em><strong>What is Moonlight ?</strong></em></p>
<p>Moonlight is an open source implementation of Silverlight (http://silverlight.net), primarily for Linux and other Unix/X11 based operating systems. In September of 2007, Microsoft and Novell announced a technical collaboration that includes access to Microsoft&#8217;s test suites for Silverlight and the distribution of a Media Pack for Linux users that will contain licensed media codecs for video and audio.</p>
<p>I tested it in Linux Mint 7 and it works fine with Silverlight 1.0 website. The bad thing, it not works in Silverlight 2.0 :/</p>
<p><a href="http://azerdark.files.wordpress.com/2009/07/screenshot-the-official-microsoft-silverlight-site-mozilla-firefox.png"><img class="alignnone size-full wp-image-848" title="Screenshot-The Official Microsoft Silverlight Site - Mozilla Firefox" src="http://azerdark.files.wordpress.com/2009/07/screenshot-the-official-microsoft-silverlight-site-mozilla-firefox.png?w=314&#038;h=225" alt="Screenshot-The Official Microsoft Silverlight Site - Mozilla Firefox" width="314" height="225" /></a></p>
<p><a href="http://azerdark.files.wordpress.com/2009/07/screenshot.png"><img class="alignnone size-full wp-image-849" title="Screenshot" src="http://azerdark.files.wordpress.com/2009/07/screenshot.png?w=316&#038;h=189" alt="Screenshot" width="316" height="189" /></a></p>
<p><a href="http://azerdark.files.wordpress.com/2009/07/screenshot-1.png"><img class="alignnone size-full wp-image-850" title="Screenshot-1" src="http://azerdark.files.wordpress.com/2009/07/screenshot-1.png?w=316&#038;h=298" alt="Screenshot-1" width="316" height="298" /></a><em><strong></strong></em></p>
<p><em><strong>Next Release ?</strong></em></p>
<p>Moonlight 2.0 still in Preview Release, this version will be compatible with Silverlight 2.0</p>
<p><em><strong>Minimum Requirements&#8230;</strong></em></p>
<p>An x86 or x86-64 computer with at least 128 megs of RAM to use Moonlight, Firefox 2.0 or Firefox 3.0.</p>
<p><em><strong>Links :</strong></em><br />
<a href="http://silverlight.net/">http://silverlight.net</a><br />
<a href="http://mono-project.com/Moonlight">http://mono-project.com/Moonlight</a><br />
<a href="http://go-mono.com/moonlight-preview/">http://go-mono.com/moonlight-preview/</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/847/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/847/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/847/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=847&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/15/moonlight-open-source-implementation-for-silverlight/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/moonlight_logo.png" medium="image">
			<media:title type="html">moonlight_logo</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/screenshot-the-official-microsoft-silverlight-site-mozilla-firefox.png" medium="image">
			<media:title type="html">Screenshot-The Official Microsoft Silverlight Site - Mozilla Firefox</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/screenshot.png" medium="image">
			<media:title type="html">Screenshot</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/screenshot-1.png" medium="image">
			<media:title type="html">Screenshot-1</media:title>
		</media:content>
	</item>
		<item>
		<title>XNA &#8211; Load 3D Model</title>
		<link>http://azerdark.wordpress.com/2009/07/11/xna-load-3d-model/</link>
		<comments>http://azerdark.wordpress.com/2009/07/11/xna-load-3d-model/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 05:24:18 +0000</pubDate>
		<dc:creator>azer89</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[XNA]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Pro]]></category>

		<guid isPermaLink="false">http://azerdark.wordpress.com/?p=829</guid>
		<description><![CDATA[
here&#8217;s the screenshot (click image for larger view):
 
 
 

source code :
variables

GraphicsDeviceManager graphics;
GraphicsDevice device;
BasicEffect basicEffect;

Model myModel;
Matrix[] modelTransforms;

how to load content

protected override void LoadContent()
{
    device = graphics.GraphicsDevice;
    basicEffect = new BasicEffect(device, null);
    cCross = new CoordCross(device);

    LoadModel(1);
}

private void LoadModel(int num)
{
    [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=829&subd=azerdark&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><img class="alignnone size-full wp-image-744" title="xna_logo" src="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg?w=282&#038;h=163" border="0" alt="xna_logo" width="282" height="163" /></p>
<p>here&#8217;s the screenshot (click image for larger view):</p>
<p><a href="http://azerdark.files.wordpress.com/2009/07/one1.jpg"><img class="alignnone size-medium wp-image-833" title="one" src="http://azerdark.files.wordpress.com/2009/07/one1.jpg?w=300&#038;h=233" alt="one" width="300" height="233" /></a><a href="http://azerdark.files.wordpress.com/2009/07/two.jpg"> <img class="alignnone size-medium wp-image-831" title="two" src="http://azerdark.files.wordpress.com/2009/07/two.jpg?w=300&#038;h=233" alt="two" width="300" height="233" /></a></p>
<p><a href="http://azerdark.files.wordpress.com/2009/07/three.jpg"><img class="alignnone size-medium wp-image-832" title="three" src="http://azerdark.files.wordpress.com/2009/07/three.jpg?w=300&#038;h=234" alt="three" width="300" height="234" /></a><a href="http://azerdark.files.wordpress.com/2009/07/four.jpg"> <img class="alignnone size-medium wp-image-834" title="four" src="http://azerdark.files.wordpress.com/2009/07/four.jpg?w=300&#038;h=234" alt="four" width="300" height="234" /></a></p>
<p><a href="http://azerdark.files.wordpress.com/2009/07/five.jpg"><img class="alignnone size-medium wp-image-835" title="five" src="http://azerdark.files.wordpress.com/2009/07/five.jpg?w=300&#038;h=233" alt="five" width="300" height="233" /></a><a href="http://azerdark.files.wordpress.com/2009/07/six.jpg"> <img class="alignnone size-medium wp-image-836" title="six" src="http://azerdark.files.wordpress.com/2009/07/six.jpg?w=300&#038;h=233" alt="six" width="300" height="233" /></a></p>
<p><span id="more-829"></span></p>
<p><em><strong>source code :</strong></em></p>
<p>variables</p>
<pre class="brush: java;">
GraphicsDeviceManager graphics;
GraphicsDevice device;
BasicEffect basicEffect;

Model myModel;
Matrix[] modelTransforms;
</pre>
<p>how to load content</p>
<pre class="brush: java;">
protected override void LoadContent()
{
    device = graphics.GraphicsDevice;
    basicEffect = new BasicEffect(device, null);
    cCross = new CoordCross(device);

    LoadModel(1);
}

private void LoadModel(int num)
{
    switch (num)
    {
        case 1:
        {
            myModel = Content.Load&lt;Model&gt;(&quot;p2_wedge&quot;);
            break;
        }
        case 2:
        {
            myModel = Content.Load&lt;Model&gt;(&quot;tank&quot;);
            break;
        }
        case 3:
        {
            myModel = Content.Load&lt;Model&gt;(&quot;T-88-FBX&quot;);
            break;
        }
        case 4:
        {
            myModel = Content.Load&lt;Model&gt;(&quot;p1_dual&quot;);
            break;
        }
        case 5:
        {
            myModel = Content.Load&lt;Model&gt;(&quot;p1_pencil&quot;);
            break;
        }
        case 6:
        {
            myModel = Content.Load&lt;Model&gt;(&quot;p2_mgun&quot;);
            break;
        }
        default:
        {
            break;
        }
    }
    modelTransforms = new Matrix[myModel.Bones.Count];
}
</pre>
<p>Update Method()</p>
<pre class="brush: java;">
protected override void Update(GameTime gameTime)
{
    MouseState mouseState = Mouse.GetState();
    KeyboardState keyState = Keyboard.GetState();

    GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);
#if XBOX
    if (gamePadState.Buttons.Back == ButtonState.Pressed)
        this.Exit();
#else

    if (keyState.IsKeyDown(Keys.Escape))
    {
        this.Exit();
    }
#endif

    if (keyState.IsKeyDown(Keys.D1))
    {
        LoadModel(1);
    }
    else if (keyState.IsKeyDown(Keys.D2))
    {
        LoadModel(2);
    }
    else if (keyState.IsKeyDown(Keys.D3))
    {
        LoadModel(3);
    }
    else if (keyState.IsKeyDown(Keys.D4))
    {
        LoadModel(4);
    }
    else if (keyState.IsKeyDown(Keys.D5))
    {
        LoadModel(5);
    }
    else if (keyState.IsKeyDown(Keys.D6))
    {
        LoadModel(6);
    }

    fpsCam.Update(mouseState, keyState, gamePadState);
    base.Update(gameTime);
}
</pre>
<p>Draw() Method</p>
<pre class="brush: java;">
protected override void Draw(GameTime gameTime)
{
    device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.CornflowerBlue, 1, 0);

    cCross.Draw(fpsCam.ViewMatrix, fpsCam.ProjectionMatrix);

    //draw model
    Matrix worldMatrix = Matrix.CreateScale(0.01f, 0.01f, 0.01f);
    myModel.CopyAbsoluteBoneTransformsTo(modelTransforms);

    foreach (ModelMesh mesh in myModel.Meshes)
    {
        foreach (BasicEffect effect in mesh.Effects)
        {
            effect.EnableDefaultLighting();
            effect.World = modelTransforms[mesh.ParentBone.Index] * worldMatrix;
            effect.View = fpsCam.ViewMatrix;
            effect.Projection = fpsCam.ProjectionMatrix;
        }
        mesh.Draw();
    }

    base.Draw(gameTime);
}
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/azerdark.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/azerdark.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/azerdark.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/azerdark.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/azerdark.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/azerdark.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/azerdark.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/azerdark.wordpress.com/829/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/azerdark.wordpress.com/829/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/azerdark.wordpress.com/829/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=azerdark.wordpress.com&blog=4345711&post=829&subd=azerdark&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://azerdark.wordpress.com/2009/07/11/xna-load-3d-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">azer89</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/xna_logo.jpg" medium="image">
			<media:title type="html">xna_logo</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/one1.jpg?w=300" medium="image">
			<media:title type="html">one</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/two.jpg?w=300" medium="image">
			<media:title type="html">two</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/three.jpg?w=300" medium="image">
			<media:title type="html">three</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/four.jpg?w=300" medium="image">
			<media:title type="html">four</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/five.jpg?w=300" medium="image">
			<media:title type="html">five</media:title>
		</media:content>

		<media:content url="http://azerdark.files.wordpress.com/2009/07/six.jpg?w=300" medium="image">
			<media:title type="html">six</media:title>
		</media:content>
	</item>
	</channel>
</rss>