<?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/"
	>

<channel>
	<title>Rony&#039;s &#187; Graphics</title>
	<atom:link href="http://rony.creash.com.bd/category/graphics/feed/" rel="self" type="application/rss+xml" />
	<link>http://rony.creash.com.bd</link>
	<description>Blogor Blogor</description>
	<lastBuildDate>Fri, 26 Mar 2010 21:34:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Load Mesh from External File and Operation on It</title>
		<link>http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/</link>
		<comments>http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 23:16:52 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[Graphics]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[Mesh]]></category>

		<guid isPermaLink="false">http://rony.creash.com.bd/?p=100</guid>
		<description><![CDATA[What I did in this project is quite simple but a little out of the track. In this project I have all those regular graphical tasks like rotation, lightning, projection etc. But the main thing I did is to build a communication between DirectX, the platform I’ve used, and other graphics libraries and 3D modeling [...]]]></description>
			<content:encoded><![CDATA[<p>What I did in this project is quite simple but a little out of the track. In this project I have all those regular graphical tasks like rotation, lightning, projection etc. But the main thing I did is to build a communication between DirectX, the platform I’ve used, and other graphics libraries and 3D modeling software.</p>
<p>This is a well discussed and pretty advanced way of DirectX. I’ve just studied on it and found some way to implement. Nothing new I’ve proposed here, but learned a lot.</p>
<p>I’ve worked on popular DirectX file format &#8211; .x and rendered the graphics information from .x to the screen.</p>
<p>I’ve used Microsoft Visual C# as programming language.<span id="more-100"></span></p>
<p>I’ve become interested about this .x file format while I was thinking of modeling my bedroom in 3D. That seemed to me like an amazing project, but it was a bit complex and large scale. Then I found this bridge between renowned 3D modeling software and DirectX. It’s possible to make a 3D model of almost anything using those software (e.g. 3D Studio Max, Maya, Poser etc.) and then I can export that model in DirectX format.</p>
<p>Most of the 3D modeling software supports this format. For 3D Studio Max I’ve used “<em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">PandaDXExport</span></em>” plug-in.</p>
<p>I’d like to leave the discussion about the modeling process of 3D Studio Max or Maya to their own tutorials or documents. When I’ve been able to export the model in .x format, it’s now my job to extract the information from the file and display on screen.</p>
<p>First we need to know the format of X File.</p>
<p>Well, it’s not as hard like the unsolved case of FBI in the TV serial – X Files. It’s not even related. The .x file format is pretty simple. Some tag based information storing system. It is template-driven file format and is used by Direct3D Retained Mode to describe geometry data, frame hierarchies, and animations. In short, we store all information of a Mesh in an .x file.</p>
<p>Each file is lead by a header which contains the file format (e.g. text or binary), float length etc.</p>
<p>Then the templates are defined. Templates define how the data stream is interpreted—the data is modulated by the template definition.</p>
<p>Then data is defined. Data objects contain the actual data or a reference to that data. Each has a corresponding template that specifies the data type.</p>
<p>For more detail about .x file format, following website can be a good resource:</p>
<ul>
<li><!--[if !supportLists]--><em></em><!--[endif]--><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">http://local.wasp.uwa.edu.au/~pbourke/dataformats/directx/</span></em></li>
</ul>
<p>Mesh can hold all the Material and Texture information you need to draw an object. As an example, we could again put our whole 3D city into one mesh, have it optimized and displayed.<a name="_Toc221302974"></a></p>
<p>While loading a file that stores Mesh, it would be too complex to call individual function for individual type of object. So I’ve built a generic Mesh loading function where the file name is passed as argument.<br />
<code>LoadMesh(string file_path, string   file_name)</code><br />
Then I have loaded the Mesh file using the LoadMesh() function of Direct3D.<br />
<code>this.m_Mesh = Mesh.FromFile(file_name,   MeshFlags.Managed, m_Device, out exmaterials)</code><br />
Then I have extracted the material and texture information in separate arrays with the following code:</p>
<p><code>for (int i = 0; i &lt;   exmaterials.Length; i++)<br />
{<br />
string   texture_file = exmaterials[i].TextureFilename;<br />
if   (texture_file != null)<br />
{<br />
if   (texture_file.Length &gt; 0)<br />
{<br />
try<br />
{<br />
m_Textures[i]   = TextureLoader.FromFile(m_Device, file_path + texture_file);<br />
}<br />
catch<br />
{<br />
MessageBox.Show("Error   loading texture " + texture_file, "Error");<br />
}<br />
}<br />
}<br />
this.m_Materials[i]   = exmaterials[i].Material3D;<br />
this.m_Materials[i].Ambient   = m_Materials[i].Diffuse;<br />
}</code></p>
<p>After this point I have all the material and texture information.</p>
<p>Now I have to draw the 3D object with the information I have in my hand. For this purpose, I have initialized the graphics earlier with the <span class="MsoSubtleEmphasis">InitializeGraphics()</span> function.</p>
<p><code>public bool InitializeGraphics()<br />
{<br />
PresentParameters parms = new PresentParameters();<br />
parms.Windowed = true;<br />
parms.SwapEffect = SwapEffect.Discard;<br />
parms.EnableAutoDepthStencil = true; // Depth stencil on.<br />
parms.AutoDepthStencilFormat = DepthFormat.D16;<br />
try<br />
{<br />
this.m_Device = new Device(0, DeviceType.Hardware, this.viewPort,<br />
CreateFlags.SoftwareVertexProcessing, parms);<br />
}<br />
catch<br />
{<br />
MessageBox.Show("Hardware initialization failed", "Exception");<br />
}<br />
// Turn on D3D lighting.<br />
m_Device.RenderState.Lighting = true;<br />
// Turn on the Z-buffer.<br />
m_Device.RenderState.ZBufferEnable = true;<br />
// Cull triangles that are oriented counter clockwise.<br />
m_Device.RenderState.CullMode = Cull.CounterClockwise;<br />
// Make points bigger so they're easy to see.<br />
m_Device.RenderState.PointSize = 4;<br />
// Start in solid mode.<br />
m_Device.RenderState.FillMode = FillMode.Solid;<br />
// Make the lights.<br />
SetupLights();<br />
return true;<br />
}</code></p>
<p>Then in the paint function, first I have to setup the world and view matrixes, setup the camera and the lights. I have done this inside the function: <span class="MsoSubtleEmphasis">SetupMatrices()</span>.</p>
<p>Inside the function, I have checked the user’s input and determined the rotation axes, camera position etc. The function definition of <span class="MsoSubtleEmphasis">SetupMatrices()</span> is like this:</p>
<p><code>private void SetupMatrices()<br />
{<br />
// World Matrix:<br />
const int TICKS_PER_REV = 10000;<br />
double angle = Environment.TickCount * (2 * Math.PI) / TICKS_PER_REV;<br />
switch (this.rotationAxes)<br />
{<br />
case 1: //X Axes<br />
this.m_Device.Transform.World = Matrix.RotationX((float)angle);<br />
break;<br />
case 2: //Y Axes<br />
this.m_Device.Transform.World = Matrix.RotationY((float)angle);<br />
break;<br />
case 3: //Z Axes<br />
this.m_Device.Transform.World = Matrix.RotationZ((float)angle);<br />
break;<br />
}<br />
// View Matrix:<br />
Vector3 camera_position = new Vector3(this.camXPos, this.camYPos, -20);<br />
camera_position.Normalize();<br />
camera_position.Multiply(this.m_Range);<br />
this.m_Device.Transform.View = Matrix.LookAtLH(<br />
camera_position,<br />
new Vector3(0, 0, 0),<br />
new Vector3(0, 1, 0));<br />
// Projection Matrix:<br />
this.m_Device.Transform.Projection =<br />
Matrix.PerspectiveFovLH((float)(Math.PI / 4), 1, 1, 100);<br />
}</code></p>
<p>And finally when all the setups are done, I draw all the Mesh and subsets from the .x file.<br />
<code><br />
// Draw the mesh's subsets.<br />
for (int i = 0; i &lt; this.m_NumSubSets; i++)<br />
{<br />
this.m_Device.Material = m_Materials[i];<br />
this.m_Device.SetTexture(0, m_Textures[i]);<br />
this.m_Mesh.DrawSubset(i);<br />
}</code></p>
<p>That’s all except for the last line inside the <span class="MsoSubtleEmphasis">OnPaint()</span> function.</p>
<p><code>this.Invalidate();</code></p>
<p>This line refreshes the viewport on each tick and displays the new object position.</p>
<p>That described the flow of my work – how I have processed the .x file and printed the 3D Mesh on the screen.</p>
<p>Except the above codes, I have some user input handling methods. I have handled input for zoom in/out, moving the camera about X axes and Y axes, changing the .X File on the go etc.</p>
<p>The project loads .X file and renders it perfectly. Only has some problem with animation template. There has to be some more complex handling. I could not do it here but wish to. I had developed a sample animation in 3D Studio Max and added the exported .X file (Truck.x) in the project. But it does not load properly.</p>
<p>I had the plan to develop a 3D model of my bedroom and display it, but could not finish processing all those images to develop a 3D view. As a sample I have added a 3D view of a lobby which I found on the internet.</p>
<p>The .X files I have used here are from Microsoft’s ® sample file and from internet. Some are exported from 3D Studio Max.</p>
<p><strong>Methods Used</strong></p>
<table class="MsoTableGrid" style="border: medium none ; border-collapse: collapse;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">public displayX()</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">The constructor. This initializes the form.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">public bool InitializeGraphics()</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Initializes graphics variables.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">public void LoadMesh(string file_path,   string file_name)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Loads the Mesh from file (.x file).</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">protected override void   OnPaint(System.Windows.Forms.PaintEventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">The paint method. Renders the object on   viewport.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void SetupMatrices()</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Sets up the matrices required for 3D   rendering.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void SetupLights()</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Sets up the lights.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void InitializeComponent()</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Initializes the form components like buttons,   combo boxes etc.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void   FillMode_CheckedChanged(object sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Method handles the change of fill mode. Three   options are available – filled, wire frame and point.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void zoomIn_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Handles the zoom in operation.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void zoomOut_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Handles the zoom out operation.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void xPlusButton_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Moves camera to the positive X axes.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void xMinusButton_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Moves camera to the negative X axes.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void yPlusButton_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Moves camera to the positive Y axes.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void yMinusButton_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Moves camera to the negative Y axes.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void   XFile_SelectedIndexChanged(object sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Handles the change of selected .x file and   loads the new Mesh from file on the go.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void dispalyX_Load(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">This method is called on the form load. This   lists all the available .x files and populates the combo box.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void xButton_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Changes the rotation axes according to the X   axes.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void yButton_Click(object   sender, EventArgs e) </span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Changes the rotation axes according to the Y   axes.</span></em></p>
</td>
</tr>
<tr>
<td style="padding: 0in 5.4pt; background: #92cddc none repeat scroll 0% 0%; width: 18.9pt;" width="25" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;">
</td>
<td style="padding: 0in 5.4pt; width: 1.75in;" width="168" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><span class="MsoSubtleEmphasis">private void zButton_Click(object   sender, EventArgs e)</span></p>
</td>
<td style="padding: 0in 5.4pt; width: 333.9pt;" width="445" valign="top">
<p style="margin-bottom: 0.0001pt; line-height: normal;"><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">Changes the rotation axes according to the Z   axes.</span></em></p>
</td>
</tr>
</tbody>
</table>
<p><strong>The Code</strong></p>
<p>There are several files and a lot of code in them. Most are for initializing the forms and UI development. All the codes and project files are available inside the download archive. The main code file required to render Mesh from external .X file is display.cs file. Code is commented for better understanding.</p>
<p><strong>External Resources Used</strong></p>
<p>Plug-in to export .x from 3D Studio Max</p>
<ul>
<li>PandaDXExport4.6.62.0</li>
</ul>
<ul>
<li>Downloaded from Pandasoft (http://www.andytather.co.uk/Panda/directxmax.aspx).</li>
</ul>
<p><strong>References</strong></p>
<ul>
<li><!--[if !supportLists]--><!--[endif]-->Riemer’s XMA Tutorial</li>
</ul>
<p style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><em><span style="font-style: normal; font-family: &quot;Courier New&quot;;"><span>o<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></em><!--[endif]--><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><a href="http://www.riemers.net/eng/Tutorials/XNA/Csharp/series1.php" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.riemers.net/eng/Tutorials/XNA/Csharp/series1.php?referer=');">http://www.riemers.net/eng/Tutorials/XNA/Csharp/series1.php</a></span></em></p>
<p style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><em><span style="font-style: normal; font-family: &quot;Courier New&quot;;"><span>o<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></em><!--[endif]--><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><a href="http://www.riemers.net/eng/Tutorials/DirectX/Csharp/Series2/tut5.php" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.riemers.net/eng/Tutorials/DirectX/Csharp/Series2/tut5.php?referer=');">http://www.riemers.net/eng/Tutorials/DirectX/Csharp/Series2/tut5.php</a></span></em></p>
<ul>
<li><!--[if !supportLists]--><!--[endif]-->DirectX Format</li>
</ul>
<p style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><em><span style="font-style: normal; font-family: &quot;Courier New&quot;;"><span>o<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></em><!--[endif]--><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><a href="http://local.wasp.uwa.edu.au/~pbourke/dataformats/directx/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/local.wasp.uwa.edu.au/_pbourke/dataformats/directx/?referer=');">http://local.wasp.uwa.edu.au/~pbourke/dataformats/directx/</a></span></em></p>
<ul>
<li><!--[if !supportLists]--><!--[endif]-->MSDN Forum</li>
</ul>
<p style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><em><span style="font-style: normal; font-family: &quot;Courier New&quot;;"><span>o<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></em><!--[endif]--><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><a href="http://forums.msdn.microsoft.com" target="_blank" onclick="pageTracker._trackPageview('/outgoing/forums.msdn.microsoft.com?referer=');">http://forums.msdn.microsoft.com</a></span></em></p>
<ul>
<li><!--[if !supportLists]--><!--[endif]-->DirectX Resources and Documentation</li>
</ul>
<p style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><em><span style="font-style: normal; font-family: &quot;Courier New&quot;;"><span>o<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></em><!--[endif]--><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><a href="http://msdn.microsoft.com/en-us/directx/bb896684.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/directx/bb896684.aspx?referer=');">http://msdn.microsoft.com/en-us/directx/bb896684.aspx</a></span></em></p>
<p style="margin-left: 1in; text-indent: -0.25in;"><!--[if !supportLists]--><em><span style="font-style: normal; font-family: &quot;Courier New&quot;;"><span>o<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: &quot;Times New Roman&quot;;"> </span></span></span></em><!--[endif]--><em><span style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;"><a href="http://msdn.microsoft.com/en-us/library/aa139763.aspx" target="_blank" onclick="pageTracker._trackPageview('/outgoing/msdn.microsoft.com/en-us/library/aa139763.aspx?referer=');">http://msdn.microsoft.com/en-us/library/aa139763.aspx</a></span></em></p>
<p style="margin-left: 1in; text-indent: -0.25in;">
<p style="text-align: left;"><strong>Screen Shot</strong></p>
<p style="text-align: center;" align="center"><img class="aligncenter size-medium wp-image-98" title="Screenshot" src="http://rony.creash.com.bd/wp-content/uploads/2009/02/untitled1-300x252.jpg" alt="" width="300" height="252" /></p>
<p style="text-align: center;" align="center">Displaying the airplane model from .x file</p>
<p style="text-align: left;"><strong>Downloads</strong></p>
<p style="text-align: left;">Download code and project files <a href="http://www.ziddu.com/download/3490696/GraphicsProject.rar.html" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.ziddu.com/download/3490696/GraphicsProject.rar.html?referer=');">here</a>.</p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><em>Bookmark:</em><br /><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/del.icio.us/post?url=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/_amp_title=Load+Mesh+from+External+File+and+Operation+on+It&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;title=Load+Mesh+from+External+File+and+Operation+on+It" title="Add 'Load Mesh from External File and Operation on It' to Del.icio.us"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Load Mesh from External File and Operation on It' to Del.icio.us" alt="Add 'Load Mesh from External File and Operation on It' to Del.icio.us" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/digg.com/submit?phase=2_amp_url=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/_amp_title=Load+Mesh+from+External+File+and+Operation+on+It&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;title=Load+Mesh+from+External+File+and+Operation+on+It" title="Add 'Load Mesh from External File and Operation on It' to digg"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Load Mesh from External File and Operation on It' to digg" alt="Add 'Load Mesh from External File and Operation on It' to digg" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/www.technorati.com/faves?add=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/" title="Add 'Load Mesh from External File and Operation on It' to Technorati"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Load Mesh from External File and Operation on It' to Technorati" alt="Add 'Load Mesh from External File and Operation on It' to Technorati" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/www.stumbleupon.com/submit?url=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/_amp_title=Load+Mesh+from+External+File+and+Operation+on+It&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;title=Load+Mesh+from+External+File+and+Operation+on+It" title="Add 'Load Mesh from External File and Operation on It' to Stumble Upon"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Load Mesh from External File and Operation on It' to Stumble Upon" alt="Add 'Load Mesh from External File and Operation on It' to Stumble Upon" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/www.google.com/bookmarks/mark?op=edit_amp_output=popup_amp_bkmk=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/_amp_title=Load+Mesh+from+External+File+and+Operation+on+It&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;title=Load+Mesh+from+External+File+and+Operation+on+It" title="Add 'Load Mesh from External File and Operation on It' to Google Bookmarks"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Load Mesh from External File and Operation on It' to Google Bookmarks" alt="Add 'Load Mesh from External File and Operation on It' to Google Bookmarks" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/slashdot.org/bookmark.pl?title=Load+Mesh+from+External+File+and+Operation+on+It_amp_url=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?title=Load+Mesh+from+External+File+and+Operation+on+It&amp;url=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/" title="Add 'Load Mesh from External File and Operation on It' to SlashDot"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/slashdot.png" title="Add 'Load Mesh from External File and Operation on It' to SlashDot" alt="Add 'Load Mesh from External File and Operation on It' to SlashDot" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/www.facebook.com/share.php?u=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/_amp_t=Load+Mesh+from+External+File+and+Operation+on+It&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/share.php?u=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;t=Load+Mesh+from+External+File+and+Operation+on+It" title="Add 'Load Mesh from External File and Operation on It' to FaceBook"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Load Mesh from External File and Operation on It' to FaceBook" alt="Add 'Load Mesh from External File and Operation on It' to FaceBook" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/www.myspace.com/Modules/PostTo/Pages/?t=Load+Mesh+from+External+File+and+Operation+on+It_amp_c=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.myspace.com/Modules/PostTo/Pages/?t=Load+Mesh+from+External+File+and+Operation+on+It&amp;c=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/" title="Add 'Load Mesh from External File and Operation on It' to MySpace"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/myspace.png" title="Add 'Load Mesh from External File and Operation on It' to MySpace" alt="Add 'Load Mesh from External File and Operation on It' to MySpace" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/twitter.com/home?status=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home?status=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/" title="Add 'Load Mesh from External File and Operation on It' to Twitter"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/twitter.png" title="Add 'Load Mesh from External File and Operation on It' to Twitter" alt="Add 'Load Mesh from External File and Operation on It' to Twitter" /></a><a class="social_img" onclick="pageTracker._trackPageview('/outgoing/www.google.com/reader/link?url=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/_amp_title=Load+Mesh+from+External+File+and+Operation+on+It_amp_srcURL=http_//rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;referer=');window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,border=0,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/reader/link?url=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/&amp;title=Load+Mesh+from+External+File+and+Operation+on+It&amp;srcURL=http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/" title="Add 'Load Mesh from External File and Operation on It' to Google Buzz"><img src="http://rony.creash.com.bd/wp-content/plugins/social-bookmarking-reloaded/googlebuzz.png" title="Add 'Load Mesh from External File and Operation on It' to Google Buzz" alt="Add 'Load Mesh from External File and Operation on It' to Google Buzz" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://rony.creash.com.bd/load-mesh-from-external-file-and-operation-on-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
