Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 12, 2016
0 parents
commit 1e595f4
Showing
784 changed files
with
465,601 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Configuration> | ||
<CodeInspection> | ||
<AssertionMethod MethodName="System.Diagnostics.Debug.Assert" Parameter="0" Type="IS_TRUE" /> | ||
<AssertionMethod MethodName="NUnit.Framework.Assert.IsTrue" Parameter="0" Type="IS_TRUE" /> | ||
<AssertionMethod MethodName="NUnit.Framework.Assert.IsFalse" Parameter="0" Type="IS_FALSE" /> | ||
<AssertionMethod MethodName="NUnit.Framework.Assert.IsNull" Parameter="0" Type="IS_NULL" /> | ||
<AssertionMethod MethodName="NUnit.Framework.Assert.IsNotNull" Parameter="0" Type="IS_NOT_NULL" /> | ||
<TerminatingMethod MethodName="System.Diagnostics.Debug.Fail" /> | ||
<TerminatingMethod MethodName="System.Environment.Exit" /> | ||
<TerminatingMethod MethodName="NUnit.Framework.Assert.Fail" /> | ||
<StringFormatMethod MethodName="System.String.Format" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.Text.StringBuilder.AppendFormat" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.IO.TextWriter.WriteLine" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.IO.TextWriter.Write" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.Console.WriteLine" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.Console.Write" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.Console.Out.Write" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.Diagnostics.Debug.Print" FormatParameterName="format" /> | ||
<StringFormatMethod MethodName="System.Text.StringBuilder.AppendFormat" FormatParameterName="format" /> | ||
<NotNullableValueAttribute> | ||
</NotNullableValueAttribute> | ||
<CanBeNullValueAttribute> | ||
</CanBeNullValueAttribute> | ||
</CodeInspection> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<Configuration> | ||
<CompletionStatisticsManager /> | ||
<EditorManager> | ||
<RecentFiles> | ||
<File id="A255B19A-A96D-49E6-8F52-0CB660257A75/f:TerrainSample.cs" caret="7320" scrollPosition="0|163" /> | ||
</RecentFiles> | ||
</EditorManager> | ||
<FileStructureView> | ||
<AutoScrollToSource>False</AutoScrollToSource> | ||
<TrackCaretLocation>False</TrackCaretLocation> | ||
</FileStructureView> | ||
<NAntValidationSettings> | ||
<NAntPath value="" /> | ||
</NAntValidationSettings> | ||
<ReFormatCode> | ||
<ReorderMembers>False</ReorderMembers> | ||
<OptimizeUsings>False</OptimizeUsings> | ||
<RemoveRedundantThis>False</RemoveRedundantThis> | ||
<ShortenReferences>False</ShortenReferences> | ||
</ReFormatCode> | ||
<SettingsComponent> | ||
<string /> | ||
<integer /> | ||
<boolean> | ||
<setting name="SolutionAnalysisEnabled">False</setting> | ||
</boolean> | ||
</SettingsComponent> | ||
<SharedSolutionDisabledTemplatesManager> | ||
<DisabledTemplates /> | ||
</SharedSolutionDisabledTemplatesManager> | ||
<UnitTestRunner> | ||
<CustomStartDirectory> | ||
</CustomStartDirectory> | ||
<UseShadowCopy>True</UseShadowCopy> | ||
<UseCustomFolder>False</UseCustomFolder> | ||
<Providers /> | ||
</UnitTestRunner> | ||
<UserSolutionDisabledTemplatesManager> | ||
<DisabledTemplates /> | ||
</UserSolutionDisabledTemplatesManager> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 9.00 | ||
# Visual C# Express 2005 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerrainEngine", "TerrainEngine\TerrainEngine.csproj", "{A255B19A-A96D-49E6-8F52-0CB660257A75}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x86 = Debug|x86 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A255B19A-A96D-49E6-8F52-0CB660257A75}.Debug|x86.ActiveCfg = Debug|x86 | ||
{A255B19A-A96D-49E6-8F52-0CB660257A75}.Debug|x86.Build.0 = Debug|x86 | ||
{A255B19A-A96D-49E6-8F52-0CB660257A75}.Release|x86.ActiveCfg = Release|x86 | ||
{A255B19A-A96D-49E6-8F52-0CB660257A75}.Release|x86.Build.0 = Release|x86 | ||
{8FFD221F-F7EE-40FA-AE66-666A9454D8CA}.Debug|x86.ActiveCfg = Debug|x86 | ||
{8FFD221F-F7EE-40FA-AE66-666A9454D8CA}.Release|x86.ActiveCfg = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file not shown.
86 changes: 86 additions & 0 deletions
86
Fontes do Livro/Chapter 10/TerrainEngine/Content/Content.contentproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ProjectGuid>8ffd221f-f7ee-40fa-ae66-666a9454d8ca</ProjectGuid> | ||
<ProjectTypeGuids>{96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<XnaFrameworkVersion>v2.0</XnaFrameworkVersion> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<OutputPath>bin\$(Platform)\$(Configuration)</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | ||
<XnaPlatform>Windows</XnaPlatform> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | ||
<XnaPlatform>Windows</XnaPlatform> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.FBXImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.TextureImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="Microsoft.Xna.Framework.Content.Pipeline.XImporter, Version=2.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d, processorArchitecture=MSIL"> | ||
<Private>False</Private> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Effects\Terrain.fx"> | ||
<Name>Terrain</Name> | ||
<Importer>EffectImporter</Importer> | ||
<Processor>EffectProcessor</Processor> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="Terrains\Terrain1.raw"> | ||
<Name>Terrain1</Name> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</None> | ||
<Compile Include="Textures\alphaMap.tga"> | ||
<Name>alphaMap</Name> | ||
<Importer>TextureImporter</Importer> | ||
<Processor>TextureProcessor</Processor> | ||
</Compile> | ||
<Compile Include="Textures\rockbump.dds"> | ||
<Name>rockbump</Name> | ||
<Importer>TextureImporter</Importer> | ||
<Processor>TextureProcessor</Processor> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Textures\Terrain1.png"> | ||
<Name>Terrain1</Name> | ||
<Importer>TextureImporter</Importer> | ||
<Processor>TextureProcessor</Processor> | ||
</Compile> | ||
<Compile Include="Textures\Terrain2.png"> | ||
<Name>Terrain2</Name> | ||
<Importer>TextureImporter</Importer> | ||
<Processor>TextureProcessor</Processor> | ||
</Compile> | ||
<Compile Include="Textures\Terrain3.png"> | ||
<Name>Terrain3</Name> | ||
<Importer>TextureImporter</Importer> | ||
<Processor>TextureProcessor</Processor> | ||
</Compile> | ||
<Compile Include="Textures\Terrain4.png"> | ||
<Name>Terrain4</Name> | ||
<Importer>TextureImporter</Importer> | ||
<Processor>TextureProcessor</Processor> | ||
</Compile> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\v2.0\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
209 changes: 209 additions & 0 deletions
209
Fontes do Livro/Chapter 10/TerrainEngine/Content/Effects/Terrain.fx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
// ------------------------------------------------- | ||
// Matrix | ||
// ------------------------------------------------- | ||
float4x4 matW : World; | ||
float4x4 matVI : ViewInverse; | ||
float4x4 matWVP : WorldViewProjection; | ||
|
||
// Material | ||
// ------------------------------------------------- | ||
float3 diffuseColor; | ||
float3 specularColor; | ||
float specularPower; | ||
|
||
// Lights | ||
// ------------------------------------------------- | ||
float3 ambientLightColor; | ||
float3 light1Position; | ||
float3 light1Color; | ||
float3 light2Position; | ||
float3 light2Color; | ||
|
||
// Textures | ||
// ------------------------------------------------- | ||
texture diffuseTexture1; | ||
texture diffuseTexture2; | ||
texture diffuseTexture3; | ||
texture diffuseTexture4; | ||
texture alphaTexture; | ||
texture normalTexture; | ||
|
||
// UV Tiles: 0-4 Diffuse textures | ||
float2 uv1Tile; | ||
float2 uv2Tile; | ||
float2 uv3Tile; | ||
float2 uv4Tile; | ||
float2 uvNormalTile; | ||
|
||
sampler2D diffuseSampler1 = sampler_state { | ||
texture = <diffuseTexture1>; | ||
MagFilter = Linear; | ||
MinFilter = Linear; | ||
MipFilter = Linear; | ||
AddressU = Wrap; | ||
AddressV = Wrap; | ||
}; | ||
|
||
sampler2D diffuseSampler2 = sampler_state { | ||
texture = <diffuseTexture2>; | ||
MagFilter = Linear; | ||
MinFilter = Linear; | ||
MipFilter = Linear; | ||
AddressU = Wrap; | ||
AddressV = Wrap; | ||
}; | ||
|
||
sampler2D diffuseSampler3 = sampler_state { | ||
texture = <diffuseTexture3>; | ||
MagFilter = Linear; | ||
MinFilter = Linear; | ||
MipFilter = Linear; | ||
AddressU = Wrap; | ||
AddressV = Wrap; | ||
}; | ||
|
||
sampler2D diffuseSampler4 = sampler_state { | ||
texture = <diffuseTexture4>; | ||
MagFilter = Linear; | ||
MinFilter = Linear; | ||
MipFilter = Linear; | ||
AddressU = Wrap; | ||
AddressV = Wrap; | ||
}; | ||
|
||
sampler2D alphaSampler = sampler_state { | ||
Texture = <alphaTexture>; | ||
MinFilter = Linear; | ||
MagFilter = Linear; | ||
MipFilter = Linear; | ||
AddressU = Wrap; | ||
AddressV = Wrap; | ||
}; | ||
|
||
sampler2D normalSampler = sampler_state { | ||
Texture = <normalTexture>; | ||
MinFilter = linear; | ||
MagFilter = linear; | ||
MipFilter = linear; | ||
AddressU = Wrap; | ||
AddressV = Wrap; | ||
}; | ||
|
||
struct a2v | ||
{ | ||
float4 position : POSITION; | ||
float2 uv0 : TEXCOORD0; | ||
float3 tangent : TANGENT; | ||
float3 binormal : BINORMAL; | ||
float3 normal : NORMAL; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float4 hposition : POSITION; | ||
float4 uv1_2 : TEXCOORD0; | ||
float4 uv3_4 : TEXCOORD1; | ||
float4 uv5_6 : TEXCOORD2; | ||
float3 eyeVec : TEXCOORD4; | ||
float3 lightVec1 : TEXCOORD5; | ||
float3 lightVec2 : TEXCOORD6; | ||
}; | ||
|
||
v2f TerrainVS(a2v IN) | ||
{ | ||
v2f OUT; | ||
OUT.hposition = mul(IN.position, matWVP); | ||
|
||
float3x3 tangentSpace = float3x3(IN.tangent, IN.binormal, IN.normal); | ||
tangentSpace = mul(tangentSpace, matW); | ||
tangentSpace = transpose(tangentSpace); | ||
|
||
// Light vectors | ||
float3 worldPosition = mul(IN.position, matW).xyz; | ||
OUT.eyeVec = mul(matVI[3].xyz - worldPosition, tangentSpace); | ||
OUT.lightVec1 = mul(light1Position - worldPosition, tangentSpace); | ||
OUT.lightVec2 = mul(light2Position - worldPosition, tangentSpace); | ||
|
||
// Multitexturing | ||
OUT.uv1_2 = float4(IN.uv0 * uv1Tile, IN.uv0 * uv2Tile); | ||
OUT.uv3_4 = float4(IN.uv0 * uv3Tile, IN.uv0 * uv4Tile); | ||
OUT.uv5_6 = float4(IN.uv0 * uvNormalTile, IN.uv0); | ||
|
||
return OUT; | ||
} | ||
|
||
void phongShading(in float3 normal, in float3 lightVec, in float3 halfwayVec, | ||
in float3 lightColor, out float3 diffuseColor, out float3 specularColor) | ||
{ | ||
float diffuseInt = saturate(dot(normal, lightVec)); | ||
diffuseColor = diffuseInt * lightColor; | ||
float specularInt = saturate(dot(normal, halfwayVec)); | ||
specularInt = pow(specularInt, specularPower); | ||
specularColor = specularInt * lightColor; | ||
} | ||
|
||
float4 TerrainPS(v2f IN) : COLOR0 | ||
{ | ||
float3 eyeVec = normalize(IN.eyeVec); | ||
float3 lightVec1 = normalize(IN.lightVec1); | ||
float3 lightVec2 = normalize(IN.lightVec2); | ||
float3 halfwayVec1 = normalize(lightVec1 + eyeVec); | ||
float3 halfwayVec2 = normalize(lightVec2 + eyeVec); | ||
|
||
float3 normal = tex2D(normalSampler, IN.uv5_6.xy); | ||
normal.xy = normal.xy * 2.0 - 1.0; | ||
normal.z = sqrt(1.0 - dot(normal.xy, normal.xy)); | ||
|
||
float3 color1 = tex2D(diffuseSampler1, IN.uv1_2.xy); | ||
float3 color2 = tex2D(diffuseSampler2, IN.uv1_2.zw); | ||
float3 color3 = tex2D(diffuseSampler3, IN.uv3_4.xy); | ||
float3 color4 = tex2D(diffuseSampler4, IN.uv3_4.zw); | ||
float4 alpha = tex2D(alphaSampler, IN.uv5_6.zw); | ||
|
||
float3 combinedColor = lerp(color1, color2, alpha.x); | ||
combinedColor = lerp(combinedColor , color3, alpha.y); | ||
combinedColor = lerp(combinedColor , color4, alpha.z); | ||
|
||
// Calculate diffuse and specular color for each light | ||
float3 diffuseColor1, diffuseColor2; | ||
float3 specularColor1, specularColor2; | ||
phongShading(normal, lightVec1, halfwayVec1, light1Color, diffuseColor1, specularColor1); | ||
phongShading(normal, lightVec2, halfwayVec2, light2Color, diffuseColor2, specularColor2); | ||
|
||
// Phong lighting result | ||
float4 finalColor; | ||
finalColor.a = 1.0f; | ||
finalColor.rgb = combinedColor * | ||
( (diffuseColor1 + diffuseColor2) * diffuseColor + ambientLightColor) + | ||
(specularColor1 + specularColor2) * specularColor ; | ||
|
||
return finalColor; | ||
} | ||
|
||
float4 transformPosition(float4 position : POSITION) : POSITION | ||
{ | ||
return mul(position, matWVP); | ||
} | ||
|
||
float4 nullPS() : COLOR0 | ||
{ | ||
return float4(0.0f, 0.0f, 0.0f, 1.0f); | ||
} | ||
|
||
technique Terrain | ||
{ | ||
pass p0 | ||
{ | ||
ZWriteEnable = true; | ||
VertexShader = compile vs_2_0 transformPosition(); | ||
PixelShader = compile ps_2_0 nullPS(); | ||
} | ||
|
||
pass p1 | ||
{ | ||
ZWriteEnable = false; | ||
VertexShader = compile vs_2_0 TerrainVS(); | ||
PixelShader = compile ps_2_a TerrainPS(); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
Fontes do Livro/Chapter 10/TerrainEngine/Content/Terrains/Terrain1.raw
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+684 KB
Fontes do Livro/Chapter 10/TerrainEngine/Content/Textures/Terrain1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+677 KB
Fontes do Livro/Chapter 10/TerrainEngine/Content/Textures/Terrain2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+419 KB
Fontes do Livro/Chapter 10/TerrainEngine/Content/Textures/Terrain3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+684 KB
Fontes do Livro/Chapter 10/TerrainEngine/Content/Textures/Terrain4.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added
BIN
+341 KB
Fontes do Livro/Chapter 10/TerrainEngine/Content/Textures/rockbump.dds
Binary file not shown.
1 change: 1 addition & 0 deletions
1
Fontes do Livro/Chapter 10/TerrainEngine/Content/obj/Content.contentproj.FileList.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
obj\x86\Debug\ResolveAssemblyReference.cache |
1 change: 1 addition & 0 deletions
1
...es do Livro/Chapter 10/TerrainEngine/Content/obj/Content.contentproj.FileListAbsolute.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
C:\Users\jalf\Desktop\Fontes do Livro\Book Code\Book Code\Chapter 10\TerrainEngine\Content\obj\x86\Debug\ResolveAssemblyReference.cache |
Oops, something went wrong.