A starting point

http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series2/Starting_point.php

So I’m back to business now, after working through this series and making sure I have everything done properly I’m ready to share how to get the flight sim up and running under XNA 4 over the next few days.

There weren’t any changes to the starting code apart from formatting for the new version, you can find the code I started with at http://pastebin.ca/1963033

The effects.fx file needs updating, further to the one we used in the last series I had to create a new technique for the textured effect since we can no longer have optional parameters as described in the previous series when we dealt with the effects file, we will use one for position and texture and one for position, normal and texture. So we carry over those previous changes in addition what needs to be done is open up the effects.fx file in visual studio copy all the code in the section:

//——- Technique: Textured ——-

and replace each occurrence of Textured with NormalTextured in the pasted code

now the original code for the Textured technique we want to change from

VertexToPixel TexturedVS( float4 inPos : POSITION, float3 inNormal: NORMAL, float2 inTexCoords: TEXCOORD0)
{
VertexToPixel Output = (VertexToPixel)0;
float4x4 preViewProjection = mul (xView, xProjection);
float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
Output.Position = mul(inPos, preWorldViewProjection);
Output.TextureCoords = inTexCoords;
float3 Normal = normalize(mul(normalize(inNormal), xWorld));
Output.LightingFactor = 1;
if (xEnableLighting)
Output.LightingFactor = saturate(dot(Normal, -xLightDirection));
return Output;
}

to this:

VertexToPixel TexturedVS( float4 inPos : POSITION, float2 inTexCoords: TEXCOORD0)
{
VertexToPixel Output = (VertexToPixel)0;
float4x4 preViewProjection = mul (xView, xProjection);
float4x4 preWorldViewProjection = mul (xWorld, preViewProjection);
Output.Position = mul(inPos, preWorldViewProjection);
Output.TextureCoords = inTexCoords;
Output.LightingFactor = 1;
return Output;
}

What we did there was to remove the parameter  float3 inNormal: NORMAL from the method signature and any code that made use of that parameter!

You can download the updated version of the effects.fx file here:

http://jump.fm/LYMQX

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s