port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,396 @@
#include "stdafx.h"
#include "BLUImporter.h"
#include "IFileSystem.h"
#include "IResourceFactory.h"
BluImporter::BluImporter(IEngine& argEngine)
: m_Engine(argEngine)
{
}
BluImportResult BluImporter::Load(const string16& argFileName)
{
BluImportResult lr_Result;
m_CurrentPath = lr_Result.m_FileName = argFileName;
int li_Pos = m_CurrentPath.rfind(_T("/"));
if (li_Pos >= 0)
m_CurrentPath = m_CurrentPath.substr(0, li_Pos + 1);
else
m_CurrentPath = _T("");
IFile* lr_File_ = m_Engine.get_FileSystem().Open(argFileName);
if (lr_File_ == NULL)
return lr_Result;
char* lc_CurrentPos_ = lr_File_->get_Buffer();
try
{
// header
std::string ls_FileTag = lr_File_->ReadString();
if (ls_FileTag != "BLUF")
throw;
int li_FileVersion = lr_File_->ReadInt();
// sections
while (!lr_File_->IsEof())
{
BluSectionType::Enumeration le_ObjectType = (BluSectionType::Enumeration)lr_File_->ReadInt();
if (le_ObjectType > BluSectionType::LastKnownType)
throw _T("BLUImporter: Unknown object section detected.");
std::string ls_ObjectName = lr_File_->ReadString();
if (ls_ObjectName.empty())
throw _T("BLUImporter: Objectname not set.");
// content
switch (le_ObjectType)
{
case BluSectionType::Mesh:
this->ImportMesh(lr_File_, ls_ObjectName, lr_Result);
break;
case BluSectionType::Material:
this->ImportMaterial(lr_File_, ls_ObjectName, lr_Result);
break;
case BluSectionType::Bone:
this->ImportBone(lr_File_, ls_ObjectName, lr_Result);
break;
case BluSectionType::Animation:
this->ImportAnimation(lr_File_, ls_ObjectName, lr_Result);
break;
}
}
// build bone hierarchy
std::map<string8, BluImportedBone>::iterator lk_BonesIter = lr_Result.m_Bones.begin();
for (; lk_BonesIter != lr_Result.m_Bones.end(); ++lk_BonesIter)
{
BluImportedBone lr_Bone = lk_BonesIter->second;
std::map<string8, BluImportedBone>::iterator lk_Found = lr_Result.m_Bones.find(lr_Bone.m_ParentName);
if (lk_Found != lr_Result.m_Bones.end())
lr_Bone.m_Bone->set_Parent(lk_Found->second.m_Bone);
}
// add bone animations to bones
std::map<string8, ITransformationAnimation*>::iterator lk_AnimIter = lr_Result.m_Animations.begin();
for (; lk_AnimIter != lr_Result.m_Animations.end(); ++lk_AnimIter)
{
std::map<string8, BluImportedBone>::iterator lk_Found = lr_Result.m_Bones.find(lk_AnimIter->first);
if (lk_Found != lr_Result.m_Bones.end())
{
lk_Found->second.m_Bone->set_TransformationAnimation(lk_AnimIter->second);
}
}
// collapse bone map to super parent bones only
lk_BonesIter = lr_Result.m_Bones.begin();
for (; lk_BonesIter != lr_Result.m_Bones.end();)
if (!lk_BonesIter->second.m_ParentName.empty())
lk_BonesIter = lr_Result.m_Bones.erase(lk_BonesIter);
else
{
// create the boneindexlist structure while we are here
lk_BonesIter->second.m_Bone->get_BoneIndexList();
++lk_BonesIter;
}
if (lr_Result.m_Bones.size() > 1)
throw _T("BLUImporter: Only one bone root allowed!");
// Create a default BoneController
if (!lr_Result.m_Bones.empty())
{
lr_Result.m_BoneController = &m_Engine.get_ResourceFactory().CreateOrFindBoneController();
lr_Result.m_BoneController->Initialize(*lr_Result.m_Bones.begin()->second.m_Bone);
float lf_MaxDuration = 0.0f;
for (lk_AnimIter = lr_Result.m_Animations.begin(); lk_AnimIter != lr_Result.m_Animations.end(); ++lk_AnimIter)
lf_MaxDuration = lf_MaxDuration < lk_AnimIter->second->get_Duration() ? lk_AnimIter->second->get_Duration() : lf_MaxDuration;
lr_Result.m_BoneController->RegisterSequence(L"all", 0.0f, lf_MaxDuration, true);
}
delete lr_File_;
}
catch (...)
{
delete lr_File_;
throw;
}
lr_Result.m_SuccessfullyLoaded = true;
return lr_Result;
}
BluModel BluImporter::Load(IEngine& argEngine, const string16& argFileName)
{
BluImporter lk_Importer(argEngine);
BluImportResult lk_Result = lk_Importer.Load(argFileName);
if (lk_Result.m_SuccessfullyLoaded)
return lk_Result.GenerateRootCommandNode(argEngine);
return BluModel();
}
void BluImporter::ImportMesh(IFile* argFile, std::string argObjectName, BluImportResult& argResult)
{
std::string ls_MaterialName = argFile->ReadString();
unsigned int li_VertexCount = argFile->ReadInt();
int li_VertexElementCount = argFile->ReadInt();
unsigned int lui_VertexStride = 0;
std::vector<VertexElement> lk_VertexElements;
for (int i = 0; i < li_VertexElementCount; ++i)
{
int vertexElementOldId = argFile->ReadInt();
VertexElement vertexElement(VertexElement::Position);
switch (vertexElementOldId)
{
case 1: vertexElement = VertexElement(VertexElement::Position); break;
case 3: vertexElement = VertexElement(VertexElement::Normal); break;
case 8: vertexElement = VertexElement(VertexElement::Texture2D); break;
case 11: vertexElement = VertexElement(VertexElement::Tangent); break;
case 13: vertexElement = VertexElement(VertexElement::BlendIndices); break;
case 14: vertexElement = VertexElement(VertexElement::BlendWeight); break;
}
lk_VertexElements.push_back(vertexElement);
lui_VertexStride += vertexElement.m_Size;
}
ScopedBuffer<char> lr_VertexData((char*)argFile->ReadDataArray(li_VertexCount * lui_VertexStride));
unsigned int li_IndexCount = argFile->ReadInt();
ScopedBuffer<unsigned int> lr_IndexData((unsigned int*)argFile->ReadDataArray(li_IndexCount * sizeof(unsigned int)));
string8 uniqueName = std::to_string8(argResult.m_FileName) + "." + argObjectName;
IGeometryBuffer* lr_GeometryBuffer_ = &m_Engine.get_ResourceFactory().CreateOrFindGeometryBuffer();
lr_GeometryBuffer_->set_PrimitiveTopology(PrimitiveTopology::TriangleList);
lr_GeometryBuffer_->SetVertexData(li_VertexCount, lui_VertexStride, (void*)lr_VertexData.Detach(), lk_VertexElements, false);
lr_GeometryBuffer_->SetIndexData(li_IndexCount, (unsigned int*)lr_IndexData.Detach(), false);
lr_GeometryBuffer_->ConvertToAdjacency();
BluImportedGeometryBuffer lr_Mesh;
lr_Mesh.m_GeometryBuffer = lr_GeometryBuffer_;
lr_Mesh.m_MaterialName = std::to_string8(argResult.m_FileName) + "." + ls_MaterialName;
argResult.m_GeometryBuffers[uniqueName] = lr_Mesh;
}
void BluImporter::ImportMaterial(IFile* argFile, std::string argObjectName, BluImportResult& argResult)
{
string16 ls_DiffuseTexture = this->ConvertPath(argFile->ReadString());
string16 ls_SpecularTexture = this->ConvertPath(argFile->ReadString());
string16 ls_NormalTexture = this->ConvertPath(argFile->ReadString());
string16 ls_GlowTexture = this->ConvertPath(argFile->ReadString());
string16 ls_ReflectionTexture = this->ConvertPath(argFile->ReadString()); // not used yet
D3DXVECTOR4 lk_AmbientColor;
lk_AmbientColor.x = argFile->ReadFloat() / 255.0f;
lk_AmbientColor.y = argFile->ReadFloat() / 255.0f;
lk_AmbientColor.z = argFile->ReadFloat() / 255.0f;
lk_AmbientColor.w = argFile->ReadFloat() / 255.0f;
D3DXVECTOR4 lk_DiffuseColor;
lk_DiffuseColor.x = argFile->ReadFloat() / 255.0f;
lk_DiffuseColor.y = argFile->ReadFloat() / 255.0f;
lk_DiffuseColor.z = argFile->ReadFloat() / 255.0f;
lk_DiffuseColor.w = argFile->ReadFloat() / 255.0f;
D3DXVECTOR4 lk_SpecularColor;
lk_SpecularColor.x = argFile->ReadFloat() / 255.0f;
lk_SpecularColor.y = argFile->ReadFloat() / 255.0f;
lk_SpecularColor.z = argFile->ReadFloat() / 255.0f;
lk_SpecularColor.w = argFile->ReadFloat() / 255.0f;
D3DXVECTOR4 lk_EmissiveColor;
lk_EmissiveColor.x = argFile->ReadFloat() / 255.0f;
lk_EmissiveColor.y = argFile->ReadFloat() / 255.0f;
lk_EmissiveColor.z = argFile->ReadFloat() / 255.0f;
lk_EmissiveColor.w = argFile->ReadFloat() / 255.0f;
float lf_SpecularLevel = argFile->ReadFloat();
float lf_Glossiness = argFile->ReadFloat();
string8 uniqueName = std::to_string8(argResult.m_FileName) + "." + argObjectName;
IShaderParameterCollection* material = &m_Engine.get_ResourceFactory().CreateOrFindShaderParameterCollection(uniqueName);
material->SetParameter("AmbientColor", lk_AmbientColor);
material->SetParameter("DiffuseColor", lk_DiffuseColor);
material->SetParameter("SpecularColor", lk_SpecularColor * lf_Glossiness);
material->SetParameter("EmissiveColor", lk_EmissiveColor);
material->SetParameter("Shininess", lf_SpecularLevel);
IShader* modelShader = &m_Engine.get_ResourceFactory().CreateOrFindShader(uniqueName);
modelShader->LoadFromFile(L"Data/NormalOutput.fxo");
if (argResult.m_Bones.empty())
modelShader->set_TechniqueName("Render");
else
modelShader->set_TechniqueName("Render");
argResult.m_Shaders[uniqueName] = modelShader;
IShaderParameterCollection* params = &m_Engine.get_ResourceFactory().CreateOrFindShaderParameterCollection(uniqueName);
if (!ls_DiffuseTexture.empty())
{
ITexture& tex = m_Engine.get_ResourceFactory().CreateOrFindTexture(std::to_string8(ls_DiffuseTexture));
if (m_Engine.get_ResourceFactory().HasCreatedResource())
tex.LoadFromFile(L"Data/Wall.jpg");//ls_DiffuseTexture);
params->SetParameter("Diffuse", tex);
}
if (!ls_SpecularTexture.empty())
{
ITexture& tex = m_Engine.get_ResourceFactory().CreateOrFindTexture(std::to_string8(ls_SpecularTexture));
if (m_Engine.get_ResourceFactory().HasCreatedResource())
tex.LoadFromFile(ls_SpecularTexture);
params->SetParameter("Specular", tex);
}
if (!ls_NormalTexture.empty())
{
ITexture& tex = m_Engine.get_ResourceFactory().CreateOrFindTexture(std::to_string8(ls_NormalTexture));
if (m_Engine.get_ResourceFactory().HasCreatedResource())
tex.LoadFromFile(ls_NormalTexture);
params->SetParameter("Normal", tex);
}
if (!ls_GlowTexture.empty())
{
ITexture& tex = m_Engine.get_ResourceFactory().CreateOrFindTexture(std::to_string8(ls_GlowTexture));
if (m_Engine.get_ResourceFactory().HasCreatedResource())
tex.LoadFromFile(ls_GlowTexture);
params->SetParameter("Glow", tex);
}
argResult.m_Parameters[uniqueName] = params;
}
void BluImporter::ImportBone(IFile* argFile, std::string argObjectName, BluImportResult& argResult)
{
std::string ls_ParentBoneName = argFile->ReadString();
// translation
float lf_TransX = argFile->ReadFloat();
float lf_TransY = argFile->ReadFloat();
float lf_TransZ = argFile->ReadFloat();
// rotation
float lf_RotX = argFile->ReadFloat();
float lf_RotY = argFile->ReadFloat();
float lf_RotZ = argFile->ReadFloat();
float lf_RotW = argFile->ReadFloat();
// scale
float lf_ScaleX = argFile->ReadFloat();
float lf_ScaleY = argFile->ReadFloat();
float lf_ScaleZ = argFile->ReadFloat();
string8 uniqueName = std::to_string8(argResult.m_FileName) + "." + argObjectName;
string8 uniqueParentName;
if (!ls_ParentBoneName.empty())
uniqueParentName = std::to_string8(argResult.m_FileName) +"." + ls_ParentBoneName;
IBone& lr_Bone = m_Engine.get_ResourceFactory().CreateOrFindBone(uniqueName);
lr_Bone.Initialize(std::to_string16(uniqueName), argResult.m_Bones.size(),
D3DXVECTOR3(lf_TransX, lf_TransY, lf_TransZ),
D3DXVECTOR3(lf_ScaleX, lf_ScaleY, lf_ScaleZ),
D3DXQUATERNION(lf_RotX, lf_RotY, lf_RotZ, lf_RotW));
BluImportedBone lr_BluBone;
lr_BluBone.m_Bone = &lr_Bone;
lr_BluBone.m_ParentName = uniqueParentName;
argResult.m_Bones[uniqueName] = lr_BluBone;
}
void BluImporter::ImportAnimation(IFile* argFile, std::string argObjectName, BluImportResult& argResult)
{
string8 uniqueName = std::to_string8(argResult.m_FileName) + "." + argObjectName;
ITransformationAnimation* lr_Ta_ = &m_Engine.get_ResourceFactory().CreateTransformationAnimation();
unsigned int lui_PositionElementCount = argFile->ReadInt();
for (unsigned int i = 0; i < lui_PositionElementCount; ++i)
{
float lf_Time = argFile->ReadFloat();
float lf_X = argFile->ReadFloat();
float lf_Y = argFile->ReadFloat();
float lf_Z = argFile->ReadFloat();
lr_Ta_->AddKeyFrame(KeyFrame(KeyFrameTarget::Position, D3DXVECTOR3(lf_X, lf_Y, lf_Z), lf_Time));
}
unsigned int lui_ScaleElementCount = argFile->ReadInt();
for (unsigned int i = 0; i < lui_ScaleElementCount; ++i)
{
float lf_Time = argFile->ReadFloat();
float lf_X = argFile->ReadFloat();
float lf_Y = argFile->ReadFloat();
float lf_Z = argFile->ReadFloat();
lr_Ta_->AddKeyFrame(KeyFrame(KeyFrameTarget::Scale, D3DXVECTOR3(lf_X, lf_Y, lf_Z), lf_Time));
}
unsigned int lui_RotationElementCount = argFile->ReadInt();
for (unsigned int i = 0; i < lui_RotationElementCount; ++i)
{
float lf_Time = argFile->ReadFloat();
float lf_X = argFile->ReadFloat();
float lf_Y = argFile->ReadFloat();
float lf_Z = argFile->ReadFloat();
lr_Ta_->AddKeyFrame(KeyFrame(KeyFrameTarget::Rotation, D3DXVECTOR3(lf_X, lf_Y, lf_Z), lf_Time));
}
argResult.m_Animations[uniqueName] = lr_Ta_;
}
//////////////////////////////////////////////////////////////////////////
BluModel BluImportResult::GenerateRootCommandNode(IEngine& argEngine)
{
IResourceFactory& factory = argEngine.get_ResourceFactory();
IRenderCommandNode& rootNode = factory.CreateRenderCommandNode();
ITransformation& transformation = factory.CreateOrFindTransformation();
transformation.set_TransformationBindings(TransformationBindings::CreateDefault());
if (!m_Bones.empty())
m_Bones.begin()->second.m_Bone->GetTransformationAtTime(0.0f, D3DXMATRIX());
if (m_BoneController != NULL)
{
AddToNode(rootNode, m_BoneController);
m_BoneController->PlaySequence(L"all");
}
// Create sub nodes
std::map<string8, BluImportedGeometryBuffer>::iterator lk_Iter = m_GeometryBuffers.begin();
for (; lk_Iter != m_GeometryBuffers.end(); ++lk_Iter)
{
BluImportedGeometryBuffer meshInfo = lk_Iter->second;
std::map<string8, IShader*>::iterator shader = m_Shaders.find(meshInfo.m_MaterialName);
std::map<string8, IShaderParameterCollection*>::iterator parameter = m_Parameters.find(meshInfo.m_MaterialName);
if (shader != m_Shaders.end() && parameter != m_Parameters.end())
{
IRenderCommandNode& subNode = factory.CreateRenderCommandNode();
AddToNode(subNode, shader->second);
AddToNode(subNode, transformation);
AddToNode(subNode, parameter->second);
AddToNode(subNode, meshInfo.m_GeometryBuffer);
AddToNode(rootNode, subNode);
}
}
BluModel result;
result.RootNode = &rootNode;
result.RootTransformation = &transformation;
result.BoneController = m_BoneController;
return result;
}

View File

@@ -0,0 +1,137 @@
#pragma once
#include "IEngine.h"
#include "IBone.h"
#include "IRenderCommandNode.h"
#include "ITexture.h"
#include "IGeometryBuffer.h"
#include "IShaderParameterCollection.h"
#include "ITransformationAnimation.h"
#include "ITransformation.h"
struct BluSectionType
{
enum Enumeration
{
Mesh = 0,
Material = 1,
Bone = 2,
Animation = 3,
LastKnownType = 3
};
};
template < typename T >
struct ScopedBuffer
{
ScopedBuffer(T* argData)
{
m_Data = argData;
}
ScopedBuffer(unsigned int argCount)
{
m_Data = new T[argCount];
}
~ScopedBuffer()
{
if (m_Data != NULL)
delete [] m_Data;
}
T* Detach()
{
T* l_Tmp_ = m_Data;
m_Data = NULL;
return l_Tmp_;
}
T* get_Data() const
{
return m_Data;
}
operator const T* () { return m_Data; }
T* m_Data;
};
struct BluImportedGeometryBuffer
{
IGeometryBuffer* m_GeometryBuffer;
string8 m_MaterialName;
};
struct BluImportedBone
{
IBone* m_Bone;
string8 m_ParentName;
};
struct BluModel
{
BluModel()
: RootTransformation(NULL)
, RootNode(NULL)
, BoneController(NULL)
{}
IRenderCommandNode* RootNode;
ITransformation* RootTransformation;
IBoneController* BoneController;
};
class BluImportResult
{
public:
BluImportResult()
: m_SuccessfullyLoaded(false)
, m_BoneController(NULL)
{}
bool m_SuccessfullyLoaded;
string16 m_FileName;
std::map<string8, BluImportedGeometryBuffer> m_GeometryBuffers;
std::map<string8, IShaderParameterCollection*> m_Parameters;
std::map<string8, IShader*> m_Shaders;
std::map<string8, BluImportedBone> m_Bones;
std::map<string8, ITransformationAnimation*> m_Animations;
IBoneController* m_BoneController;
BluModel GenerateRootCommandNode(IEngine& argEngine);
};
class BluImporter
{
public:
BluImporter(IEngine& argEngine);
BluImportResult Load(const string16& argFileName);
static BluModel Load(IEngine& argEngine, const string16& argFileName);
protected:
void ImportMesh(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
void ImportMaterial(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
void ImportBone(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
void ImportAnimation(IFile* argFile, string8 argObjectName, BluImportResult& argResult);
string16 ConvertPath(const string8& argOrignal)
{
if (argOrignal.empty())
return std::to_string16(argOrignal);
int li_Pos = argOrignal.rfind("\\");
if (li_Pos >= 0)
return m_CurrentPath + std::to_string16(argOrignal.substr(li_Pos + 1, argOrignal.size() - li_Pos));
return m_CurrentPath + std::to_string16(argOrignal);
}
private:
IEngine& m_Engine;
string16 m_CurrentPath;
};

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -0,0 +1,202 @@
matrix WorldMatrix : WorldMatrix;
matrix ViewMatrix : ViewMatrix;
matrix ProjectionMatrix : ProjectionMatrix;
float3 CameraPosition : CamPos;
float3 CameraDirection : CamDir;
float3 LightPos : LightPosition;
float4 LightColor : LightColor;
Texture2D Diffuse : Diffuse;
Texture2D Normal : Normal;
SamplerState samLinear
{
Filter = ANISOTROPIC;
AddressU = Wrap;
AddressV = Wrap;
};
DepthStencilState RenderWithStencilState
{
StencilEnable = false;
DepthEnable = TRUE;
DepthWriteMask = ALL;
};
RasterizerState EnableCulling
{
CullMode = BACK;
};
struct COLOR_PAIR
{
float4 Diffuse : COLOR0;
float4 Specular : COLOR1;
};
COLOR_PAIR CalculatePointLight(float3 vPosition, float3 vNormal, float3 vViewDir, float3 vLightPos, float LightRange, float4 LightColor, float2 SpecularValue)
{
COLOR_PAIR rResult = (COLOR_PAIR)0;
float3 vLightDir = normalize(vLightPos - vPosition); // calc LightDirection
float fDiffuse = dot(vNormal, vLightDir); // get diffuse
float3 vReflect = reflect(vNormal, vLightDir);
float fSpecular = dot(vReflect, vViewDir);
if (fSpecular > 0)
fSpecular = pow( abs(fSpecular), SpecularValue.x) * SpecularValue.y;
else
fSpecular = 0;
float fAtten = 1.0f;
float LD = length(vPosition - vLightPos);
if(LD > LightRange)
{
fAtten = 0.f;
}
else
{
fAtten *= 1.f/(0 +
1*LD +
0*LD*LD);
fAtten = min(1.0f, fAtten);
}
rResult.Diffuse = max(0.0f, fAtten * fDiffuse * LightColor);
rResult.Specular = max(0.0f, fAtten * fSpecular * LightColor);
return rResult;
}
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD0;
float3 WorldPos : TEXCOORD1;
float3 ViewDir : TEXCOORD2;
};
struct VSN_OUTPUT
{
float4 Pos : SV_POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD0;
float3 WorldPos : TEXCOORD1;
float3 ViewDir : TEXCOORD2;
float3 Tangent : TEXCOORD3;
float3 Binormal : TEXCOORD4;
};
VS_OUTPUT VS(float4 Pos : POSITION, float3 Norm : NORMAL, float2 Tex : TEXCOORD)
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.Pos = mul( Pos, WorldMatrix );
output.Pos = mul( output.Pos, ViewMatrix );
output.Pos = mul( output.Pos, ProjectionMatrix );
output.Norm = mul(float4(Norm, 0.0), WorldMatrix).xyz;
output.Tex = Tex;
output.WorldPos = mul(Pos, WorldMatrix).xyz;
output.ViewDir = mul(Pos, WorldMatrix).xyz - CameraPosition;
return output;
}
VSN_OUTPUT NormalMappingVS(float4 Pos : POSITION, float3 Norm : NORMAL, float3 Tangent : TANGENT, float2 Tex : TEXCOORD)
{
VSN_OUTPUT output = (VSN_OUTPUT)0;
output.Pos = mul( Pos, WorldMatrix );
output.Pos = mul( output.Pos, ViewMatrix );
output.Pos = mul( output.Pos, ProjectionMatrix );
output.Norm = mul(float4(Norm, 0.0), WorldMatrix).xyz;
output.Tangent = mul(float4(Tangent, 0.0), WorldMatrix).xyz;
output.Binormal = cross(output.Norm, output.Tangent);
output.Tex = Tex;
output.WorldPos = mul(Pos, WorldMatrix).xyz;
output.ViewDir = mul(Pos, WorldMatrix).xyz - CameraPosition;
return output;
}
float4 NormalMappingPS( VSN_OUTPUT input) : SV_Target
{
float3x3 objToTangentSpace = float3x3( normalize(input.Tangent), normalize(input.Binormal), normalize(input.Norm) );
float4 base = Diffuse.Sample(samLinear, input.Tex);
float4 bump = Normal.Sample(samLinear, input.Tex);
bump.xyz = normalize(bump.xyz * 2 - 1);
float3 normal = mul(objToTangentSpace, bump.xyz);
float3 lightpos = mul(objToTangentSpace, LightPos);
COLOR_PAIR LightResult = CalculatePointLight(input.WorldPos, normal, normalize(input.ViewDir), lightpos, 1000.0f, LightColor, float2(16.0f, 1.0f));
float4 color = Diffuse.Sample(samLinear, input.Tex) * LightResult.Diffuse + LightResult.Specular;
return color;
}
float4 PS( VS_OUTPUT input) : SV_Target
{
COLOR_PAIR LightResult = CalculatePointLight(input.WorldPos, normalize(input.Norm), normalize(input.ViewDir), LightPos, 1000.0f, LightColor, float2(16.0f, 1.0f));
float4 color = Diffuse.Sample(samLinear, input.Tex) * LightResult.Diffuse + LightResult.Specular;
return color;
}
float4 LightPS( VS_OUTPUT input) : SV_Target
{
return float4(LightColor.x, LightColor.y, LightColor.z,1);
}
//--------------------------------------------------------------------------------------
technique10 Render
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
SetDepthStencilState( RenderWithStencilState, 0 );
SetBlendState( NULL, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetRasterizerState( EnableCulling );
}
}
technique10 NormalMapping
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, NormalMappingVS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, NormalMappingPS() ) );
SetDepthStencilState( RenderWithStencilState, 0 );
SetBlendState( NULL, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetRasterizerState( EnableCulling );
}
}
technique10 Light
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, LightPS() ) );
SetDepthStencilState( RenderWithStencilState, 0 );
SetBlendState( NULL, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetRasterizerState( EnableCulling );
}
}

View File

@@ -0,0 +1,184 @@
static const float PixelKernel[13] = { -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6 };
static const float BlurWeights[13] = { 0.002216, 0.008764, 0.026995, 0.064759, 0.120985, 0.176033, 0.199471, 0.176033, 0.120985, 0.064759, 0.026995, 0.008764, 0.002216 };
float CurrentTime : Time;
//--------------------------------------------------------------------------------------
// States
//--------------------------------------------------------------------------------------
BlendState NoBlending
{
BlendEnable[0] = FALSE;
RenderTargetWriteMask[0] = 0x0F;
};
DepthStencilState RenderWithoutStencilState
{
DepthEnable = false;
DepthWriteMask = ZERO;
DepthFunc = Always;
};
//--------------------------------------------------------------------------------------
// Textures
//--------------------------------------------------------------------------------------
Texture2D ColorMap : ColorMap;
Texture2D Calculated : InputTexture;
Texture2D DistortMap : DistortMap;
SamplerState samLinear
{
Filter = ANISOTROPIC;
AddressU = Wrap;
AddressV = Wrap;
};
SamplerState samLinearClamp
{
Filter = ANISOTROPIC;
AddressU = Clamp;
AddressV = Clamp;
};
//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float2 Tex : TEXCOORD0;
};
//--------------------------------------------------------------------------------------
// Vertex Shader
//--------------------------------------------------------------------------------------
VS_OUTPUT VS(float4 Pos : POSITION, float3 Norm : NORMAL, float2 Tex : TEXCOORD)
{
VS_OUTPUT output = (VS_OUTPUT)0;
output.Pos = Pos;
output.Pos.w = 1.0f;
output.Tex = Tex;
return output;
}
//--------------------------------------------------------------------------------------
// Pixel Shader
//--------------------------------------------------------------------------------------
float4 IntensityPS( VS_OUTPUT input) : SV_Target
{
float4 color = ColorMap.Sample(samLinear, input.Tex);
float3 ColorToIntensity = float3(0.294, 0.582, 0.114);
color.rgb *= ColorToIntensity;
color.rgb = color.r + color.g + color.b;
return color;
}
float4 ShowTexturePS( VS_OUTPUT input) : SV_Target
{
float4 color = Calculated.Sample(samLinear, input.Tex);
return color;
}
float4 ComposePS( VS_OUTPUT input) : SV_Target
{
const float DistortTextureScale = 8.0f;
const float DistortStrength = 10.0f;
const float DistortSpeed = 0.25f;
const float3 ColorToIntensity = float3(0.294, 0.582, 0.114);
float2 distort = (DistortMap.Sample(samLinear, DistortTextureScale * input.Tex + float2(sin(CurrentTime * DistortSpeed), cos(CurrentTime * DistortSpeed))).xy - 0.5f) * 1.0f;
// get DDX DDY of the input texture
float2 CalculatedSize;
ColorMap.GetDimensions(CalculatedSize.x, CalculatedSize.y);
CalculatedSize = 1.0f / CalculatedSize;
float4 bloom = Calculated.Sample(samLinear, input.Tex);
// bloom step
bloom = pow(bloom, 2.0f) * 2.0f;
float4 intensity = bloom;
intensity.rgb *= ColorToIntensity;
intensity.rgb = intensity.r + intensity.g + intensity.b;
float4 color = ColorMap.Sample(samLinearClamp, input.Tex + distort * CalculatedSize * intensity * DistortStrength);
return color + bloom;
}
const float pi4 = 3.141 / 4.0;
float4 BlurPS( VS_OUTPUT input) : SV_Target
{
// get DDX DDY of the input texture
float2 ddxy;
Calculated.GetDimensions(ddxy.x, ddxy.y);
ddxy = 1.0f / ddxy;
// Blur
float4 color = 0;
float2 SamplePos;
for (int i = 0; i < 8; i++)
{
SamplePos = input.Tex + ddxy * 4.0 * float2(sin(pi4 * i), cos(pi4 * i));
color += Calculated.Sample(samLinearClamp, SamplePos);
}
return color / 8.0;
}
//--------------------------------------------------------------------------------------
technique10 Intensity
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, IntensityPS() ) );
SetDepthStencilState( NULL, 0 );
SetBlendState( NULL, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
}
}
technique10 ShowTexture
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, ShowTexturePS() ) );
SetDepthStencilState( NULL, 0 );
SetBlendState( NULL, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
}
}
technique10 Blur
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, BlurPS() ) );
SetDepthStencilState( NULL, 0 );
SetBlendState( NULL, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
}
}
technique10 Compose
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, ComposePS() ) );
SetDepthStencilState( NULL, 0 );
SetBlendState( NULL, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
}
}

View File

@@ -0,0 +1,319 @@
#define NOVERTEX 0xfffffffe
struct VSSceneIn
{
float4 Pos : POSITION;
float3 Norm : NORMAL;
float2 Tex : TEXCOORD;
};
struct PSSceneIn
{
float4 Pos : SV_Position;
float4 Color : COLOR0;
};
struct GSShadowIn
{
float3 Pos : POS;
float3 Norm : NORMAL;
};
struct PSShadowIn
{
float4 Pos : SV_Position;
};
matrix WorldMatrix : WorldMatrix;
matrix ViewMatrix : ViewMatrix;
matrix ProjectionMatrix : ProjectionMatrix;
float3 LightPos : LightPosition;
float ExtrudeAmt = 10.0f;
float ExtrudeBias = 0.0f;
float4 ShadowColor = float4(0.0f, 0.0f, 0.0f, 1.0f);
DepthStencilState DisableDepth
{
DepthEnable = FALSE;
DepthWriteMask = ZERO;
};
DepthStencilState EnableDepth
{
DepthEnable = TRUE;
DepthWriteMask = ALL;
};
DepthStencilState TwoSidedStencil
{
DepthEnable = true;
DepthWriteMask = ZERO;
DepthFunc = Less;
// Setup stencil states
StencilEnable = true;
StencilReadMask = 0xFFFFFFFF;
StencilWriteMask = 0xFFFFFFFF;
BackFaceStencilFunc = Always;
BackFaceStencilDepthFail = Incr;
BackFaceStencilPass = Keep;
BackFaceStencilFail = Keep;
FrontFaceStencilFunc = Always;
FrontFaceStencilDepthFail = Decr;
FrontFaceStencilPass = Keep;
FrontFaceStencilFail = Keep;
};
DepthStencilState RenderNonShadows
{
DepthEnable = true;
DepthWriteMask = ZERO;
DepthFunc = Less_Equal;
StencilEnable = true;
StencilReadMask = 0xFFFFFFFF;
StencilWriteMask = 0x0;
FrontFaceStencilFunc = NOT_EQUAL;
FrontFaceStencilPass = Keep;
FrontFaceStencilFail = ZERO;
BackFaceStencilFunc = Never;
BackFaceStencilPass = ZERO;
BackFaceStencilFail = ZERO;
};
BlendState DisableFrameBuffer
{
BlendEnable[0] = FALSE;
RenderTargetWriteMask[0] = 0x0;
};
BlendState EnableFrameBuffer
{
BlendEnable[0] = FALSE;
RenderTargetWriteMask[0] = 0x0F;
};
BlendState SrcAlphaBlending
{
AlphaToCoverageEnable = FALSE;
BlendEnable[0] = TRUE;
SrcBlend = SRC_ALPHA;
DestBlend = INV_SRC_ALPHA;
BlendOp = ADD;
SrcBlendAlpha = ZERO;
DestBlendAlpha = ZERO;
BlendOpAlpha = ADD;
RenderTargetWriteMask[0] = 0x0F;
};
BlendState AdditiveBlending
{
AlphaToCoverageEnable = FALSE;
BlendEnable[0] = TRUE;
SrcBlend = ONE;
DestBlend = ONE;
BlendOp = SUBTRACT;
SrcBlendAlpha = ZERO;
DestBlendAlpha = ZERO;
BlendOpAlpha = ADD;
RenderTargetWriteMask[0] = 0x0F;
};
RasterizerState DisableCulling
{
CullMode = NONE;
};
RasterizerState EnableCulling
{
CullMode = BACK;
};
//
// VS for sending information to the shadow GS
//
GSShadowIn VSShadowmain( VSSceneIn input )
{
GSShadowIn output = (GSShadowIn)0.0;
//output our position in world space
float4 pos = mul( float4(input.Pos.xyz,1), WorldMatrix );
output.Pos = pos.xyz;
//world space normal
output.Norm = mul( input.Norm, (float3x3)WorldMatrix );
return output;
}
PSSceneIn VSScenemain( VSSceneIn input )
{
PSSceneIn output = (PSSceneIn)0.0;
//output our final position in clipspace
output.Pos = mul(input.Pos, WorldMatrix);
output.Pos = mul(output.Pos, ViewMatrix);
output.Pos = mul(output.Pos, ProjectionMatrix);
//world space normal
float3 norm = mul( input.Norm, (float3x3)WorldMatrix );
//find the light dir
float3 wpos = mul( input.Pos, (float3x3)WorldMatrix );
float3 lightDir = normalize( LightPos - wpos );
float lightLenSq = length(LightPos - wpos);
output.Color = saturate(dot(lightDir,norm)) * ShadowColor * 8.0f/lightLenSq;
return output;
}
// PS for rendering lit and textured triangles
float4 PSScenemain(PSSceneIn input) : SV_Target
{
return input.Color;
}
// Helper to detect a silhouette edge and extrude a volume from it
void DetectAndProcessSilhouette(float3 N, // Un-normalized triangle normal
GSShadowIn v1, // Shared vertex
GSShadowIn v2, // Shared vertex
GSShadowIn vAdj, // Adjacent triangle vertex
inout TriangleStream<PSShadowIn> ShadowTriangleStream // triangle stream
)
{
float3 NAdj = cross(v2.Pos - vAdj.Pos, v1.Pos - vAdj.Pos);
float fDot = dot(normalize(N), normalize(NAdj));
if (fDot < 0.0)
{
float3 outpos[4];
float3 extrude1 = normalize(v1.Pos - LightPos);
float3 extrude2 = normalize(v2.Pos - LightPos);
outpos[0] = v1.Pos + ExtrudeBias * extrude1;
outpos[1] = v1.Pos + ExtrudeAmt * extrude1;
outpos[2] = v2.Pos + ExtrudeBias * extrude2;
outpos[3] = v2.Pos + ExtrudeAmt * extrude2;
// Extrude silhouette to create two new triangles
PSShadowIn Out;
for(int v = 0; v < 4; v++)
{
Out.Pos = mul(float4(outpos[v], 1.0f), ViewMatrix);
Out.Pos = mul(Out.Pos, ProjectionMatrix);
ShadowTriangleStream.Append(Out);
}
ShadowTriangleStream.RestartStrip();
}
}
// GS for generating shadow volumes
[maxvertexcount(18)]
void GSShadowmain(triangleadj GSShadowIn In[6], inout TriangleStream<PSShadowIn> ShadowTriangleStream)
{
// Compute un-normalized triangle normal
float3 N = normalize(cross(In[2].Pos - In[0].Pos, In[4].Pos - In[0].Pos));
// Compute direction from this triangle to the light
float3 lightDir[3];
lightDir[0] = normalize(LightPos - In[0].Pos);
lightDir[1] = normalize(LightPos - In[2].Pos);
lightDir[2] = normalize(LightPos - In[4].Pos);
//if we're facing the light
if(dot(N, lightDir[0]) > 0.0f || dot(N, lightDir[1]) > 0.0f || dot(N, lightDir[2]) > 0.0f)
{
// For each edge of the triangle, determine if it is a silhouette edge
DetectAndProcessSilhouette(lightDir[0], In[0], In[2], In[1], ShadowTriangleStream);
DetectAndProcessSilhouette(lightDir[1], In[2], In[4], In[3], ShadowTriangleStream);
DetectAndProcessSilhouette(lightDir[2], In[4], In[0], In[5], ShadowTriangleStream);
//near cap
PSShadowIn Out;
for(int v = 0; v < 6; v += 2)
{
float3 extrude = normalize(In[v].Pos - LightPos);
float3 Pos = In[v].Pos + ExtrudeBias * extrude;
Out.Pos = mul(float4(Pos, 1.0f), ViewMatrix);
Out.Pos = mul(Out.Pos, ProjectionMatrix);
ShadowTriangleStream.Append(Out);
}
ShadowTriangleStream.RestartStrip();
//far cap (reverse the order)
for(int v2 = 4; v2 >= 0; v2 -= 2)
{
float3 extrude = normalize(In[v2].Pos - LightPos);
float3 Pos = In[v2].Pos + ExtrudeAmt * extrude;
Out.Pos = mul(float4(Pos, 1.0f), ViewMatrix);
Out.Pos = mul(Out.Pos, ProjectionMatrix);
ShadowTriangleStream.Append( Out );
}
ShadowTriangleStream.RestartStrip();
}
}
// PS for rendering shadow scene
float4 PSShadowmain(PSShadowIn input) : SV_Target
{
return float4(0.3,0,0,0.25);
}
// RenderShadow - extrudes shadows from geometry
technique10 CastShadows
{
pass p0
{
SetVertexShader( CompileShader( vs_4_0, VSShadowmain() ) );
SetGeometryShader( CompileShader( gs_4_0, GSShadowmain() ) );
SetPixelShader( CompileShader( ps_4_0, PSShadowmain() ) );
SetBlendState( DisableFrameBuffer, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetDepthStencilState( TwoSidedStencil, 1 ); //state, stencilref
SetRasterizerState( DisableCulling );
}
}
technique10 ShowShadowVolume
{
pass p0
{
SetVertexShader( CompileShader( vs_4_0, VSShadowmain() ) );
SetGeometryShader( CompileShader( gs_4_0, GSShadowmain() ) );
SetPixelShader( CompileShader( ps_4_0, PSShadowmain() ) );
SetBlendState( SrcAlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetDepthStencilState( TwoSidedStencil, 1 ); //state, stencilref
SetRasterizerState( DisableCulling );
}
}
technique10 ReceiveShadows
{
pass p0
{
SetVertexShader( CompileShader( vs_4_0, VSScenemain() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PSScenemain() ) );
SetBlendState( SrcAlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
SetDepthStencilState( RenderNonShadows, 0 ); //state, stencilref
SetRasterizerState( EnableCulling );
}
}

BIN
aiwaz/Demo/Data/Wall.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 449 KiB

BIN
aiwaz/Demo/Data/Wall2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

440
aiwaz/Demo/Demo.vcproj Normal file
View File

@@ -0,0 +1,440 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="Demo"
ProjectGUID="{7AD8CE26-922D-42C9-BCA1-F3635D545EC4}"
RootNamespace="Demo"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../Aiwaz/Interfaces"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
AdditionalLibraryDirectories="$(SolutionDir)$(ConfigurationName)"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
UseFAT32Workaround="true"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(SolutionDir)obj\$(ConfigurationName)\$(ProjectName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../Aiwaz/Interfaces"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
AdditionalLibraryDirectories="$(SolutionDir)$(ConfigurationName)"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
UseFAT32Workaround="true"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\BLUImporter\BLUImporter.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\BLUImporter\BLUImporter.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>
</File>
<File
RelativePath=".\targetver.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\Data\Distortion.jpg"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Data\Wall.jpg"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Data\Wall2.jpg"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Data\Wall2Normal.jpg"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Data\WallNormal.jpg"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
</File>
</Filter>
<File
RelativePath=".\Data\ChamferBox.blu"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Copying $(InputFileName)"
CommandLine="copy /Y &quot;$(InputPath)&quot; &quot;$(OutDir)\Data\$(InputFileName)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputFileName)"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Data\NormalOutput.fx"
DeploymentContent="true"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Performing Custom Build Step"
CommandLine="fxc.exe /nologo /T fx_4_0 /Fo &quot;$(OutDir)\Data\$(InputName).fxo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputName).fxo"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="Performing Custom Build Step"
CommandLine="fxc.exe /nologo /T fx_4_0 /Fo &quot;$(OutDir)\Data\$(InputName).fxo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputName).fxo"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Data\PostProcess.fx"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="fxc.exe /nologo /T fx_4_0 /Fo &quot;$(OutDir)\Data\$(InputName).fxo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputName).fxo"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="fxc.exe /nologo /T fx_4_0 /Fo &quot;$(OutDir)\Data\$(InputName).fxo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputName).fxo"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\Data\ShadowVolume.fx"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="fxc.exe /nologo /T fx_4_0 /Fo &quot;$(OutDir)\Data\$(InputName).fxo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputName).fxo"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="fxc.exe /nologo /T fx_4_0 /Fo &quot;$(OutDir)\Data\$(InputName).fxo&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="$(OutDir)\Data\$(InputName).fxo"
/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioUserFile
ProjectType="Visual C++"
Version="9,00"
ShowAllFiles="true"
>
<Configurations>
<Configuration
Name="Debug|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory="$(OutDir)"
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="SHAIKUR"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="0"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
<Configuration
Name="Release|Win32"
>
<DebugSettings
Command="$(TargetPath)"
WorkingDirectory="$(OutDir)"
CommandArguments=""
Attach="false"
DebuggerType="3"
Remote="1"
RemoteMachine="SHAIKUR"
RemoteCommand=""
HttpUrl=""
PDBPath=""
SQLDebugging=""
Environment=""
EnvironmentMerge="true"
DebuggerFlavor="0"
MPIRunCommand=""
MPIRunArguments=""
MPIRunWorkingDirectory=""
ApplicationCommand=""
ApplicationArguments=""
ShimCommand=""
MPIAcceptMode=""
MPIAcceptFilter=""
/>
</Configuration>
</Configurations>
</VisualStudioUserFile>

295
aiwaz/Demo/main.cpp Normal file
View File

@@ -0,0 +1,295 @@
#pragma comment(lib, "Aiwaz.lib")
#include "stdafx.h"
#include "../Aiwaz/Aiwaz.h"
#include "BLUImporter/BLUImporter.h"
#define WINDOW_TITLE "BluFlame - Aiwaz"
bool WINDOW_FULLSCREEN = false;
bool START_INTRO = true;
int WINDOW_WIDTH = 1024;
int WINDOW_HEIGHT = 768;
int _tmain(int argc, TCHAR* argv[])
{
MSG message;
LARGE_INTEGER oldTime;
LARGE_INTEGER ticksPerSecond;
bool done = false;
IEngine* engine = NULL;
IWindow* window = NULL;
float elapsedTime = 0.0f;
try
{
engine = Aiwaz::CreateEngine();
engine->Initialize();
IResourceFactory& resFactory = engine->get_ResourceFactory();
engine->get_FileSystem().InitializeFromDirectory(L"");
BluModel chamferBox = BluImporter::Load(*engine, L"Data/ChamferBox.blu");
chamferBox.RootTransformation->set_LocalScale(D3DXVECTOR3(0.1f, 0.1f, 0.1f));
chamferBox.RootTransformation->set_LocalPosition(D3DXVECTOR3(1.0f, 0.0f, 2.0f));
window = &resFactory.CreateSwapChainWindow();
window->Initialize(std::to_string16(WINDOW_TITLE), WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_FULLSCREEN);
window->set_VSync(false);
window->get_SwapChain().get_Base().set_ClearColor(0xFF00AAFF);
window->get_SwapChain().get_Base().set_HasDepthStencilBuffer(true);
IPerspectiveCamera& currentCamera = resFactory.CreateOrFindPerspectiveCamera();
currentCamera.get_Base().set_AspectRatio((float)WINDOW_WIDTH / WINDOW_HEIGHT);
IShader& normalShader = resFactory.CreateOrFindShader("NormalOutput");
normalShader.LoadFromFile(L"Data/NormalOutput.fxo");
normalShader.set_TechniqueName("NormalMapping");
IShader& diffuseShader = resFactory.CreateOrFindShader("DiffuseOutput");
diffuseShader.LoadFromFile(L"Data/NormalOutput.fxo");
IShader& lightShader = resFactory.CreateOrFindShader("LightShader");
lightShader.LoadFromFile(L"Data/NormalOutput.fxo");
lightShader.set_TechniqueName("Light");
ITexture& wallTexture = resFactory.CreateOrFindTexture("Wall");
wallTexture.LoadFromFile(L"Data/Wall.jpg");
ITexture& wallNormalTexture = resFactory.CreateOrFindTexture("WallNormal");
wallNormalTexture.LoadFromFile(L"Data/WallNormal.jpg");
wallNormalTexture.set_BindingName("Normal");
ITexture& wall2Texture = resFactory.CreateOrFindTexture("Wall2");
wall2Texture.LoadFromFile(L"Data/Wall2.jpg");
ITexture& wall2NormalTexture = resFactory.CreateOrFindTexture("Wall2Normal");
wall2NormalTexture.LoadFromFile(L"Data/Wall2Normal.jpg");
wall2NormalTexture.set_BindingName("Normal");
IGeometryBuffer& cubeBuffer = *engine->get_CommonObjectFactory().CreateCube(1.0f, 1.0f, 1.0f, false, "Cube");
cubeBuffer.ConvertToAdjacency();
IGeometryBuffer& roomBuffer = *engine->get_CommonObjectFactory().CreateCube(10.0f, 10.0f, 10.0f, true, "RoomCube");
IGeometryBuffer& lightCubeBuffer = *engine->get_CommonObjectFactory().CreateCube(0.1f, 0.1f, 0.1f, false, "LightCube");
ITransformation& cubeTransformation = resFactory.CreateOrFindTransformation("CubeTransformation");
cubeTransformation.set_TransformationBindings(TransformationBindings::CreateDefault());
cubeTransformation.set_LocalPosition(D3DXVECTOR3(-1.0f, 0.0f, 2.0f));
ITransformation& roomTransformation = resFactory.CreateOrFindTransformation("RoomTransformation");
roomTransformation.set_TransformationBindings(TransformationBindings::CreateDefault());
roomTransformation.set_LocalPosition(D3DXVECTOR3(0.0f, 0.0f, 2.0f));
ITransformation& lightCubeTransformation = resFactory.CreateOrFindTransformation("LightCubeTransformation");
lightCubeTransformation.set_TransformationBindings(TransformationBindings::CreateDefault());
lightCubeTransformation.set_LocalPosition(D3DXVECTOR3(0.0f, 0.0f, 2.0f));
IShaderParameterCollection& lightParameters = resFactory.CreateOrFindShaderParameterCollection("Light");
D3DXVECTOR3 lightPosition = D3DXVECTOR3(-1.0f, 1.0f, -1.0f);
lightPosition = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
D3DXVECTOR4 lightColor = D3DXVECTOR4(2.0f, 2.0f, 1.0f, 1.0f);
lightParameters.set_IsPreconditionForFollowingShaders(true);
lightParameters.SetParameter("LightPosition", &lightPosition);
lightParameters.SetParameter("LightColor", &lightColor);
IRenderTargetTexture& colorMap = resFactory.CreateOrFindRenderTargetTexture();
colorMap.SetTextureParameters(
window->get_SwapChain().get_Base().get_RenderTargetWidth(),
window->get_SwapChain().get_Base().get_RenderTargetHeight(),
window->get_SwapChain().get_Base().get_RenderTargetFormat());
colorMap.get_TextureResource().set_BindingName("ColorMap");
colorMap.get_Base().set_ClearColor(D3DXCOLOR(0.0f, 0.2f, 0.0f, 1.0f));
colorMap.get_Base().set_HasDepthStencilBuffer(true);
IShader& shadowReceiverShader = resFactory.CreateOrFindShader();
shadowReceiverShader.LoadFromFile(L"Data/ShadowVolume.fxo");
shadowReceiverShader.set_TechniqueName("ReceiveShadows");
shadowReceiverShader.set_Priority(2);
IShader& shadowCasterShader = resFactory.CreateOrFindShader();
shadowCasterShader.LoadFromFile(L"Data/ShadowVolume.fxo");
shadowCasterShader.set_TechniqueName("CastShadows");
shadowCasterShader.set_Priority(1);
// PingPong stuff
PingPongBufferDescription pingPongDescriptor;
pingPongDescriptor.ShaderFileName = L"Data/PostProcess.fxo";
pingPongDescriptor.ShaderTechniqueA = "Blur";
pingPongDescriptor.ShaderTechniqueB = "Blur";
pingPongDescriptor.PreProcessShaderTechnique = "ShowTexture";
pingPongDescriptor.LoopCount = 4;
pingPongDescriptor.TextureWidth = window->get_SwapChain().get_Base().get_RenderTargetWidth() / 4;
pingPongDescriptor.TextureHeight = window->get_SwapChain().get_Base().get_RenderTargetHeight() / 4;
pingPongDescriptor.TextureFormat = window->get_SwapChain().get_Base().get_RenderTargetFormat();
IPingPongBuffer* blurBuffer = engine->get_CommonObjectFactory().CreatePingPongBuffer(colorMap.get_TextureResource(), pingPongDescriptor);
IShader& composeShaderResource = resFactory.CreateOrFindShader();
composeShaderResource.LoadFromFile(L"Data/PostProcess.fxo");
composeShaderResource.set_TechniqueName("Compose");
IShaderParameterCollection& shaderParameterCollection = resFactory.CreateOrFindShaderParameterCollection();
shaderParameterCollection.SetParameter("Time", &elapsedTime);
ITexture& distortTexture = resFactory.CreateOrFindTexture();
distortTexture.LoadFromFile(L"Data/Distortion.jpg");
distortTexture.set_BindingName("DistortMap");
IGeometryBuffer& quadGeometry = *engine->get_CommonObjectFactory().CreateQuad(2.0f, 2.0f, false);
IRenderCommandNode& rootNode = resFactory.CreateRenderCommandNode();
IRenderCommandNode& colorNode = resFactory.CreateRenderCommandNode();
IRenderCommandNode& intensityNode = resFactory.CreateRenderCommandNode();
IRenderCommandNode& composingNode = resFactory.CreateRenderCommandNode();
IRenderCommandNode& cubeNode = resFactory.CreateRenderCommandNode();
IRenderCommandNode& roomNode = resFactory.CreateRenderCommandNode();
IRenderCommandNode& roomShadowReceiverNode = resFactory.CreateRenderCommandNode();
IRenderCommandNode& lightNode = resFactory.CreateRenderCommandNode();
{
// create light node
AddToNode(lightNode, lightShader);
AddToNode(lightNode, lightCubeTransformation);
AddToNode(lightNode, lightCubeBuffer);
// create cube node
AddToNode(cubeNode, normalShader);
AddToNode(cubeNode, wallTexture);
AddToNode(cubeNode, wallNormalTexture);
AddToNode(cubeNode, cubeTransformation);
AddToNode(cubeNode, cubeBuffer);
// render shadow caster
AddToNode(cubeNode, shadowCasterShader);
AddToNode(cubeNode, cubeTransformation);
AddToNode(cubeNode, cubeBuffer);
AddToNode(roomNode, normalShader);
AddToNode(roomNode, wall2Texture);
AddToNode(roomNode, wall2NormalTexture);
AddToNode(roomNode, roomTransformation);
AddToNode(roomNode, roomBuffer);
// render shadow receiver
AddToNode(roomShadowReceiverNode, shadowReceiverShader);
AddToNode(roomShadowReceiverNode, roomTransformation);
AddToNode(roomShadowReceiverNode, roomBuffer);
// render colored scene to texture
AddToNode(rootNode, colorNode);
AddToNode(colorNode, colorMap);
AddToNode(colorNode, currentCamera);
AddToNode(colorNode, lightParameters);
AddToNode(colorNode, roomNode);
AddToNode(colorNode, chamferBox.RootNode);
AddToNode(colorNode, cubeNode);
AddToNode(colorNode, roomShadowReceiverNode);
AddToNode(colorNode, lightNode);
// create intensity map from colored scene
AddToNode(rootNode, intensityNode);
AddToNode(intensityNode, blurBuffer->get_RootNode());
// compose final scene
AddToNode(rootNode, composingNode);
AddToNode(composingNode, window->get_SwapChain());
AddToNode(composingNode, currentCamera);
AddToNode(composingNode, composeShaderResource);
AddToNode(composingNode, shaderParameterCollection);
AddToNode(composingNode, distortTexture);
AddToNode(composingNode, colorMap.get_TextureResource());
AddToNode(composingNode, blurBuffer->get_OutputTexture());
AddToNode(composingNode, quadGeometry);
}
IUpdatable& updatableRootNode = dynamic_cast<IUpdatable&>(rootNode);
QueryPerformanceCounter(&oldTime);
float refreshTime = 0.0f;
while (!done)
{
if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
if (message.message == WM_QUIT)
{
done = TRUE;
}
else
{
TranslateMessage(&message);
DispatchMessage(&message);
}
}
else
{
if (window->get_Active())
{
LARGE_INTEGER time;
QueryPerformanceCounter(&time);
QueryPerformanceFrequency(&ticksPerSecond);
time.QuadPart -= oldTime.QuadPart;
double timeValue = double(time.QuadPart) / (ticksPerSecond.QuadPart);
QueryPerformanceCounter(&oldTime);
elapsedTime += (float)timeValue;
D3DXVECTOR3 rotationYPR = chamferBox.RootTransformation->get_LocalRotationYPR();
const float timefactor = 0.4f;
rotationYPR.x += (float)timeValue * timefactor;
rotationYPR.y += (float)timeValue * timefactor;
rotationYPR.z += (float)timeValue * timefactor;
chamferBox.RootTransformation->set_LocalRotationYPR(rotationYPR);
rotationYPR = cubeTransformation.get_LocalRotationYPR();
const float timeCubefactor = 0.2f;
rotationYPR.x += (float)timeValue * timeCubefactor;
rotationYPR.y += (float)timeValue * timeCubefactor;
rotationYPR.z += (float)timeValue * timeCubefactor;
cubeTransformation.set_LocalRotationYPR(rotationYPR);
rotationYPR = roomTransformation.get_LocalRotationYPR();
const float timeRoomFactor = 0.05f;
rotationYPR.x += (float)timeValue * timeRoomFactor;
rotationYPR.y += (float)timeValue * timeRoomFactor;
rotationYPR.z += (float)timeValue * timeRoomFactor;
roomTransformation.set_LocalRotationYPR(rotationYPR);
//lightPosition.x = sin(elapsedTime * 0.5) * 2.0f;
lightPosition.y = cos(elapsedTime * 0.5f) * 2.0f;
lightCubeTransformation.set_LocalPosition(lightPosition);
//#ifdef _DEBUG
{
refreshTime -= (float)timeValue;
if (refreshTime < 0.0f)
{
refreshTime = 0.5f;
char title[255];
sprintf_s(title, 255, "%s - %.4f ms %.2f FPS", WINDOW_TITLE, float(timeValue * 1000), float(1.0 / timeValue));
window->set_Title(std::to_string16(title));
}
}
//#endif
updatableRootNode.Update(false);
rootNode.ProcessCommands();
window->SwapBuffers();
}
}
}
}
catch (LPCTSTR exception)
{
HWND windowHandle = 0x0;
if (window != NULL)
windowHandle = window->get_Handle();
::MessageBox(windowHandle, exception, _T("BluFlame demo system"), MB_OK);
::ExitProcess(0);
}
delete engine;
return 0;
}

1
aiwaz/Demo/stdafx.cpp Normal file
View File

@@ -0,0 +1 @@
#include "stdafx.h"

37
aiwaz/Demo/stdafx.h Normal file
View File

@@ -0,0 +1,37 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#ifndef _DEBUG
#define _SECURE_SCL 0
#endif
#include "targetver.h"
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files:
#include <windows.h>
#include <Shlwapi.h>
// C RunTime Header Files
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#define _USE_MATH_DEFINES
#include <cmath>
#include <BaseTsd.h>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <d3d10.h>
#include <d3dx10.h>
#include <DXGI.h>
#include "../Aiwaz/Common/BaseTypes.h"
#include "../Aiwaz/Common/ConsoleColor.h"
#include "../Aiwaz/Common/StringHelper.h"

25
aiwaz/Demo/targetver.h Normal file
View File

@@ -0,0 +1,25 @@
#pragma once
// The following macros define the minimum required platform. The minimum required platform
// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run
// your application. The macros work by enabling all features available on platform versions up to and
// including the version specified.
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Specifies that the minimum required platform is Windows Vista.
#define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista.
#define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows.
#endif
//
//#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98.
//#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
//#endif
#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0.
#define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE.
#endif