forked from metin2/client
Solution refactoring and restructuring, removed Boost dependency, removed unused tools
This commit is contained in:
1717
src/CWebBrowser/CWebBrowser.c
Normal file
1717
src/CWebBrowser/CWebBrowser.c
Normal file
File diff suppressed because it is too large
Load Diff
19
src/CWebBrowser/CWebBrowser.h
Normal file
19
src/CWebBrowser/CWebBrowser.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int WebBrowser_Startup(HINSTANCE hInstance);
|
||||
void WebBrowser_Cleanup();
|
||||
void WebBrowser_Destroy();
|
||||
int WebBrowser_Show(HWND parent, const char* addr, const RECT* rcWebBrowser);
|
||||
void WebBrowser_Hide();
|
||||
void WebBrowser_Move(const RECT* rcWebBrowser);
|
||||
|
||||
int WebBrowser_IsVisible();
|
||||
const RECT& WebBrowser_GetRect();
|
||||
|
||||
}
|
180
src/CWebBrowser/CWebBrowser.vcxproj
Normal file
180
src/CWebBrowser/CWebBrowser.vcxproj
Normal file
@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Distribute|Win32">
|
||||
<Configuration>Distribute</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<ProjectName>CWebBrowser</ProjectName>
|
||||
<ProjectGuid>{D64AE35F-F982-46D4-8E38-09E5C9752955}</ProjectGuid>
|
||||
<RootNamespace>CWebBrowser</RootNamespace>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>17.0.32203.90</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader />
|
||||
<PrecompiledHeaderOutputFile>.\Debug/CWebBrowser.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Debug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader />
|
||||
<PrecompiledHeaderOutputFile>.\Release/CWebBrowser.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Release/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Release/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader />
|
||||
<PrecompiledHeaderOutputFile>.\Distribute/CWebBrowser.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Distribute/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Distribute/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Distribute/</ProgramDataBaseFileName>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CWebBrowser.c">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CWebBrowser.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
221
src/EffectLib/EffectData.cpp
Normal file
221
src/EffectLib/EffectData.cpp
Normal file
@ -0,0 +1,221 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectData.h"
|
||||
|
||||
CDynamicPool<CEffectData> CEffectData::ms_kPool;
|
||||
|
||||
CEffectData* CEffectData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectData::Delete(CEffectData* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CEffectData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
|
||||
CParticleSystemData::DestroySystem();
|
||||
CEffectMeshScript::DestroySystem();
|
||||
CLightData::DestroySystem();
|
||||
}
|
||||
|
||||
bool CEffectData::LoadScript(const char * c_szFileName)
|
||||
{
|
||||
m_strFileName = c_szFileName;
|
||||
CFileNameHelper::StringPath(m_strFileName);
|
||||
|
||||
CTextFileLoader TextFileLoader;
|
||||
if (!TextFileLoader.Load(c_szFileName))
|
||||
return false;
|
||||
|
||||
TextFileLoader.SetTop();
|
||||
|
||||
if (!TextFileLoader.GetTokenFloat("boundingsphereradius", &m_fBoundingSphereRadius))
|
||||
{
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
}
|
||||
|
||||
if (!TextFileLoader.GetTokenVector3("boundingsphereposition", &m_v3BoundingSpherePosition))
|
||||
{
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
}
|
||||
|
||||
for (DWORD i = 0; i < TextFileLoader.GetChildNodeCount(); ++i)
|
||||
{
|
||||
if (!TextFileLoader.SetChildNode(i))
|
||||
continue;
|
||||
|
||||
std::string strName;
|
||||
|
||||
if (!TextFileLoader.GetCurrentNodeName(&strName))
|
||||
continue;
|
||||
|
||||
if (0 == strName.compare("mesh"))
|
||||
{
|
||||
CEffectMeshScript * pMesh = AllocMesh();
|
||||
pMesh->Clear();
|
||||
pMesh->LoadScript(TextFileLoader);
|
||||
}
|
||||
else if (0 == strName.compare("particle"))
|
||||
{
|
||||
CParticleSystemData * pParticleSystemData = AllocParticle();
|
||||
pParticleSystemData->Clear();
|
||||
pParticleSystemData->LoadScript(TextFileLoader);
|
||||
}
|
||||
else if (0 == strName.compare("light"))
|
||||
{
|
||||
CLightData * pLightData = AllocLight();
|
||||
pLightData->Clear();
|
||||
pLightData->LoadScript(TextFileLoader);
|
||||
}
|
||||
|
||||
TextFileLoader.SetParentNode();
|
||||
}
|
||||
|
||||
// Load Sound
|
||||
std::string strPathHeader = "d:/ymir work/";
|
||||
std::string strNoExtensionName = CFileNameHelper::NoExtension(m_strFileName);
|
||||
int iPos = strNoExtensionName.find(strPathHeader.c_str());
|
||||
if (iPos >= 0)
|
||||
if (strNoExtensionName.size() > strPathHeader.size())
|
||||
{
|
||||
std::string strSoundFileName;
|
||||
strSoundFileName = "sound/";
|
||||
strSoundFileName += &strNoExtensionName[strPathHeader.size()];
|
||||
strSoundFileName += ".mss";
|
||||
|
||||
LoadSoundScriptData(strSoundFileName.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEffectData::LoadSoundScriptData(const char * c_szFileName)
|
||||
{
|
||||
NSound::TSoundDataVector SoundDataVector;
|
||||
|
||||
if (NSound::LoadSoundInformationPiece(c_szFileName, SoundDataVector))
|
||||
{
|
||||
NSound::DataToInstance(SoundDataVector, &m_SoundInstanceVector);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CParticleSystemData * CEffectData::AllocParticle()
|
||||
{
|
||||
CParticleSystemData * pParticle = CParticleSystemData::New();
|
||||
m_ParticleVector.push_back(pParticle);
|
||||
return pParticle;
|
||||
}
|
||||
|
||||
CEffectMeshScript * CEffectData::AllocMesh()
|
||||
{
|
||||
CEffectMeshScript * pMesh = CEffectMeshScript::New();
|
||||
m_MeshVector.push_back(pMesh);
|
||||
return pMesh;
|
||||
}
|
||||
|
||||
CLightData * CEffectData::AllocLight()
|
||||
{
|
||||
CLightData * pLight = CLightData::New();
|
||||
m_LightVector.push_back(pLight);
|
||||
return pLight;
|
||||
}
|
||||
|
||||
DWORD CEffectData::GetLightCount()
|
||||
{
|
||||
return m_LightVector.size();
|
||||
}
|
||||
|
||||
CLightData * CEffectData::GetLightPointer(DWORD dwPosition)
|
||||
{
|
||||
assert(dwPosition < m_LightVector.size());
|
||||
return m_LightVector[dwPosition];
|
||||
}
|
||||
|
||||
DWORD CEffectData::GetParticleCount()
|
||||
{
|
||||
return m_ParticleVector.size();
|
||||
}
|
||||
CParticleSystemData * CEffectData::GetParticlePointer(DWORD dwPosition)
|
||||
{
|
||||
if(dwPosition < m_ParticleVector.size())
|
||||
return m_ParticleVector[dwPosition];
|
||||
else
|
||||
{
|
||||
assert(false);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CEffectData::GetMeshCount()
|
||||
{
|
||||
return m_MeshVector.size();
|
||||
}
|
||||
CEffectMeshScript * CEffectData::GetMeshPointer(DWORD dwPosition)
|
||||
{
|
||||
assert(dwPosition < m_MeshVector.size());
|
||||
return m_MeshVector[dwPosition];
|
||||
}
|
||||
|
||||
NSound::TSoundInstanceVector * CEffectData::GetSoundInstanceVector()
|
||||
{
|
||||
return &m_SoundInstanceVector;
|
||||
}
|
||||
|
||||
float CEffectData::GetBoundingSphereRadius()
|
||||
{
|
||||
return m_fBoundingSphereRadius;
|
||||
}
|
||||
|
||||
D3DXVECTOR3 CEffectData::GetBoundingSpherePosition()
|
||||
{
|
||||
return m_v3BoundingSpherePosition;
|
||||
}
|
||||
|
||||
const char * CEffectData::GetFileName() const
|
||||
{
|
||||
return m_strFileName.c_str();
|
||||
}
|
||||
|
||||
void CEffectData::__ClearParticleDataVector()
|
||||
{
|
||||
std::for_each(m_ParticleVector.begin(), m_ParticleVector.end(), CParticleSystemData::Delete);
|
||||
m_ParticleVector.clear();
|
||||
}
|
||||
|
||||
void CEffectData::__ClearLightDataVector()
|
||||
{
|
||||
std::for_each(m_LightVector.begin(), m_LightVector.end(), CLightData::Delete);
|
||||
m_LightVector.clear();
|
||||
}
|
||||
|
||||
void CEffectData::__ClearMeshDataVector()
|
||||
{
|
||||
std::for_each(m_MeshVector.begin(), m_MeshVector.end(), CEffectMeshScript::Delete);
|
||||
m_MeshVector.clear();
|
||||
}
|
||||
|
||||
void CEffectData::Clear()
|
||||
{
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
__ClearParticleDataVector();
|
||||
__ClearLightDataVector();
|
||||
__ClearMeshDataVector();
|
||||
}
|
||||
|
||||
CEffectData::CEffectData()
|
||||
{
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
}
|
||||
CEffectData::~CEffectData()
|
||||
{
|
||||
}
|
69
src/EffectLib/EffectData.h
Normal file
69
src/EffectLib/EffectData.h
Normal file
@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include "../milesLib/Type.h"
|
||||
|
||||
#include "ParticleSystemData.h"
|
||||
#include "EffectMesh.h"
|
||||
#include "SimpleLightData.h"
|
||||
|
||||
class CEffectData
|
||||
{
|
||||
public:
|
||||
typedef std::vector<CParticleSystemData*> TParticleVector;
|
||||
typedef std::vector<CEffectMeshScript*> TMeshVector;
|
||||
typedef std::vector<CLightData*> TLightVector;
|
||||
|
||||
public:
|
||||
CEffectData();
|
||||
virtual ~CEffectData();
|
||||
|
||||
void Clear();
|
||||
bool LoadScript(const char * c_szFileName);
|
||||
bool LoadSoundScriptData(const char * c_szFileName);
|
||||
|
||||
DWORD GetParticleCount();
|
||||
CParticleSystemData * GetParticlePointer(DWORD dwPosition);
|
||||
|
||||
DWORD GetMeshCount();
|
||||
CEffectMeshScript * GetMeshPointer(DWORD dwPosition);
|
||||
|
||||
DWORD GetLightCount();
|
||||
CLightData * GetLightPointer(DWORD dwPosition);
|
||||
|
||||
NSound::TSoundInstanceVector * GetSoundInstanceVector();
|
||||
|
||||
float GetBoundingSphereRadius();
|
||||
D3DXVECTOR3 GetBoundingSpherePosition();
|
||||
|
||||
const char * GetFileName() const;
|
||||
|
||||
protected:
|
||||
void __ClearParticleDataVector();
|
||||
void __ClearLightDataVector();
|
||||
void __ClearMeshDataVector();
|
||||
|
||||
// FIXME : <20><> <20>κ<EFBFBD><CEBA><EFBFBD> <20>״<EFBFBD><D7B4><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʴ´<CAB4>. <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̵<EFBFBD><CCB5> ã<>Ƴ<EFBFBD><C6B3><EFBFBD> <20><>ġ<EFBFBD><C4A1>.
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (Ưȭ<C6AF><C8AD>) <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٲ<EFBFBD><D9B2><EFBFBD><EFBFBD><EFBFBD> <20>Ѵٴ<D1B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϴ<EFBFBD>. - [levites]
|
||||
virtual CParticleSystemData * AllocParticle();
|
||||
virtual CEffectMeshScript * AllocMesh();
|
||||
virtual CLightData * AllocLight();
|
||||
|
||||
protected:
|
||||
TParticleVector m_ParticleVector;
|
||||
TMeshVector m_MeshVector;
|
||||
TLightVector m_LightVector;
|
||||
NSound::TSoundInstanceVector m_SoundInstanceVector;
|
||||
|
||||
float m_fBoundingSphereRadius;
|
||||
D3DXVECTOR3 m_v3BoundingSpherePosition;
|
||||
|
||||
std::string m_strFileName;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectData* New();
|
||||
static void Delete(CEffectData* pkData);
|
||||
|
||||
static CDynamicPool<CEffectData> ms_kPool;
|
||||
};
|
168
src/EffectLib/EffectElementBase.cpp
Normal file
168
src/EffectLib/EffectElementBase.cpp
Normal file
@ -0,0 +1,168 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
|
||||
void CEffectElementBase::GetPosition(float fTime, D3DXVECTOR3 & rPosition)
|
||||
{
|
||||
if (m_TimeEventTablePosition.empty())
|
||||
{
|
||||
rPosition = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
return;
|
||||
}
|
||||
if (m_TimeEventTablePosition.size()==1)
|
||||
{
|
||||
rPosition = m_TimeEventTablePosition[0].m_vecPosition;
|
||||
return;
|
||||
}
|
||||
if (m_TimeEventTablePosition.front().m_fTime > fTime)
|
||||
{
|
||||
rPosition = m_TimeEventTablePosition.front().m_vecPosition;
|
||||
return;
|
||||
}
|
||||
if (m_TimeEventTablePosition.back().m_fTime < fTime)
|
||||
{
|
||||
rPosition = m_TimeEventTablePosition.back().m_vecPosition;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef TTimeEventTablePosition::iterator iterator;
|
||||
iterator result = std::lower_bound( m_TimeEventTablePosition.begin(), m_TimeEventTablePosition.end(), fTime );
|
||||
|
||||
TEffectPosition & rEffectPosition = *result;
|
||||
iterator rPrev = result;
|
||||
if (m_TimeEventTablePosition.begin() != result)
|
||||
{
|
||||
rPrev = result-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rPosition = result->m_vecPosition;
|
||||
return;
|
||||
}
|
||||
TEffectPosition & rPrevEffectPosition = *rPrev;
|
||||
int iMovingType = rPrevEffectPosition.m_iMovingType;
|
||||
|
||||
if (MOVING_TYPE_DIRECT == iMovingType)
|
||||
{
|
||||
float Head = fabs(rEffectPosition.m_fTime - fTime) / fabs(rEffectPosition.m_fTime - rPrevEffectPosition.m_fTime);
|
||||
float Tail = 1.0f - fabs(rEffectPosition.m_fTime - fTime) / fabs(rEffectPosition.m_fTime - rPrevEffectPosition.m_fTime);
|
||||
rPosition = (rPrevEffectPosition.m_vecPosition*Head) + (rEffectPosition.m_vecPosition*Tail);
|
||||
}
|
||||
else if (MOVING_TYPE_BEZIER_CURVE == iMovingType)
|
||||
{
|
||||
float ft = (fTime - rPrevEffectPosition.m_fTime) / (rEffectPosition.m_fTime - rPrevEffectPosition.m_fTime);
|
||||
|
||||
rPosition = rPrevEffectPosition.m_vecPosition * (1.0f - ft) * (1.0f - ft) +
|
||||
(rPrevEffectPosition.m_vecPosition + rPrevEffectPosition.m_vecControlPoint) * (1.0f - ft) * ft * 2 +
|
||||
rEffectPosition.m_vecPosition * ft * ft;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
bool CEffectElementBase::isVisible(float fTime)
|
||||
{
|
||||
for (DWORD i = 0; i < m_TimeEventTableVisible.size(); ++i)
|
||||
{
|
||||
float fPointTime = m_TimeEventTableVisible[i];
|
||||
|
||||
if (fTime < fPointTime)
|
||||
{
|
||||
if (1 == i % 2)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return 1 == (m_TimeEventTableVisible.size() % 2);
|
||||
}
|
||||
|
||||
void CEffectElementBase::GetAlpha(float fTime, float * pAlpha)
|
||||
{
|
||||
GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventAlpha, pAlpha);
|
||||
}
|
||||
|
||||
void CEffectElementBase::GetScale(float fTime, float * pScale)
|
||||
{
|
||||
GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventScale, pScale);
|
||||
}
|
||||
*/
|
||||
|
||||
bool CEffectElementBase::isData()
|
||||
{
|
||||
return OnIsData();
|
||||
}
|
||||
|
||||
void CEffectElementBase::Clear()
|
||||
{
|
||||
m_fStartTime = 0.0f;
|
||||
|
||||
OnClear();
|
||||
}
|
||||
|
||||
BOOL CEffectElementBase::LoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
CTokenVector * pTokenVector;
|
||||
if (!rTextFileLoader.GetTokenFloat("starttime",&m_fStartTime))
|
||||
{
|
||||
m_fStartTime = 0.0f;
|
||||
}
|
||||
if (rTextFileLoader.GetTokenVector("timeeventposition", &pTokenVector))
|
||||
{
|
||||
m_TimeEventTablePosition.clear();
|
||||
|
||||
DWORD dwIndex = 0;
|
||||
for (DWORD i = 0; i < pTokenVector->size(); ++dwIndex)
|
||||
{
|
||||
TEffectPosition EffectPosition;
|
||||
EffectPosition.m_fTime = atof(pTokenVector->at(i++).c_str());
|
||||
if (pTokenVector->at(i)=="MOVING_TYPE_BEZIER_CURVE")
|
||||
{
|
||||
i++;
|
||||
|
||||
EffectPosition.m_iMovingType = MOVING_TYPE_BEZIER_CURVE;
|
||||
|
||||
EffectPosition.m_vecPosition.x = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.y = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.z = atof(pTokenVector->at(i++).c_str());
|
||||
|
||||
EffectPosition.m_vecControlPoint.x = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecControlPoint.y = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecControlPoint.z = atof(pTokenVector->at(i++).c_str());
|
||||
}
|
||||
else if (pTokenVector->at(i) == "MOVING_TYPE_DIRECT")
|
||||
{
|
||||
i++;
|
||||
|
||||
EffectPosition.m_iMovingType = MOVING_TYPE_DIRECT;
|
||||
|
||||
EffectPosition.m_vecPosition.x = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.y = atof(pTokenVector->at(i++).c_str());
|
||||
EffectPosition.m_vecPosition.z = atof(pTokenVector->at(i++).c_str());
|
||||
|
||||
EffectPosition.m_vecControlPoint = D3DXVECTOR3(0.0f,0.0f,0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_TimeEventTablePosition.push_back(EffectPosition);
|
||||
}
|
||||
}
|
||||
|
||||
return OnLoadScript(rTextFileLoader);
|
||||
}
|
||||
|
||||
float CEffectElementBase::GetStartTime()
|
||||
{
|
||||
return m_fStartTime;
|
||||
}
|
||||
|
||||
CEffectElementBase::CEffectElementBase()
|
||||
{
|
||||
m_fStartTime = 0.0f;
|
||||
}
|
||||
CEffectElementBase::~CEffectElementBase()
|
||||
{
|
||||
}
|
37
src/EffectLib/EffectElementBase.h
Normal file
37
src/EffectLib/EffectElementBase.h
Normal file
@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
class CEffectElementBase
|
||||
{
|
||||
public:
|
||||
CEffectElementBase();
|
||||
virtual ~CEffectElementBase();
|
||||
|
||||
void Clear();
|
||||
bool isData();
|
||||
|
||||
BOOL LoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
void GetPosition(float fTime, D3DXVECTOR3 & rPosition);
|
||||
float GetStartTime();
|
||||
/*
|
||||
bool isVisible(float fTime);
|
||||
void GetAlpha(float fTime, float * pAlpha);
|
||||
void GetScale(float fTime, float * pScale);
|
||||
*/
|
||||
|
||||
protected:
|
||||
virtual void OnClear() = 0;
|
||||
virtual bool OnIsData() = 0;
|
||||
virtual BOOL OnLoadScript(CTextFileLoader & rTextFileLoader) = 0;
|
||||
|
||||
protected:
|
||||
float m_fStartTime;
|
||||
TTimeEventTablePosition m_TimeEventTablePosition;
|
||||
/*
|
||||
TTimeEventTable m_TimeEventTableVisible;
|
||||
TTimeEventTableFloat m_TimeEventAlpha;
|
||||
TTimeEventTableFloat m_TimeEventScale;
|
||||
*/
|
||||
};
|
97
src/EffectLib/EffectElementBaseInstance.cpp
Normal file
97
src/EffectLib/EffectElementBaseInstance.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectElementBaseInstance.h"
|
||||
|
||||
bool CEffectElementBaseInstance::Update(float fElapsedTime)
|
||||
{
|
||||
if (m_bStart)
|
||||
{
|
||||
m_fElapsedTime = fElapsedTime;
|
||||
m_fLocalTime += fElapsedTime;
|
||||
|
||||
return OnUpdate(fElapsedTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_fRemainingTime -= fElapsedTime;
|
||||
if (m_fRemainingTime<=0.0f)
|
||||
m_bStart = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::Render()
|
||||
{
|
||||
if (!m_bStart)
|
||||
return;
|
||||
|
||||
assert(mc_pmatLocal);
|
||||
|
||||
OnRender();
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::SetLocalMatrixPointer(const D3DXMATRIX * c_pMatrix)
|
||||
{
|
||||
mc_pmatLocal = c_pMatrix;
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::SetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
m_pBase = pElement;
|
||||
|
||||
m_dwStartTime = CTimer::Instance().GetCurrentMillisecond();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//add by ipkn, start time management
|
||||
|
||||
m_fRemainingTime = pElement->GetStartTime();
|
||||
if (m_fRemainingTime<=0.0f)
|
||||
m_bStart = true;
|
||||
else
|
||||
m_bStart = false;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
OnSetDataPointer(pElement);
|
||||
}
|
||||
|
||||
bool CEffectElementBaseInstance::isActive()
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
void CEffectElementBaseInstance::SetActive()
|
||||
{
|
||||
m_isActive = true;
|
||||
}
|
||||
void CEffectElementBaseInstance::SetDeactive()
|
||||
{
|
||||
m_isActive = false;
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::Initialize()
|
||||
{
|
||||
mc_pmatLocal = NULL;
|
||||
|
||||
m_isActive = true;
|
||||
|
||||
m_fLocalTime = 0.0f;
|
||||
m_dwStartTime = 0;
|
||||
m_fElapsedTime = 0.0f;
|
||||
|
||||
m_bStart = false;
|
||||
m_fRemainingTime = 0.0f;
|
||||
|
||||
OnInitialize();
|
||||
}
|
||||
|
||||
void CEffectElementBaseInstance::Destroy()
|
||||
{
|
||||
OnDestroy();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CEffectElementBaseInstance::CEffectElementBaseInstance()
|
||||
{
|
||||
}
|
||||
CEffectElementBaseInstance::~CEffectElementBaseInstance()
|
||||
{
|
||||
}
|
46
src/EffectLib/EffectElementBaseInstance.h
Normal file
46
src/EffectLib/EffectElementBaseInstance.h
Normal file
@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
class CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
CEffectElementBaseInstance();
|
||||
virtual ~CEffectElementBaseInstance();
|
||||
|
||||
void SetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void Initialize();
|
||||
void Destroy();
|
||||
|
||||
void SetLocalMatrixPointer(const D3DXMATRIX * c_pMatrix);
|
||||
bool Update(float fElapsedTime);
|
||||
void Render();
|
||||
|
||||
bool isActive();
|
||||
void SetActive();
|
||||
void SetDeactive();
|
||||
|
||||
protected:
|
||||
virtual void OnSetDataPointer(CEffectElementBase * pElement) = 0;
|
||||
|
||||
virtual void OnInitialize() = 0;
|
||||
virtual void OnDestroy() = 0;
|
||||
|
||||
virtual bool OnUpdate(float fElapsedTime) = 0;
|
||||
virtual void OnRender() = 0;
|
||||
|
||||
protected:
|
||||
const D3DXMATRIX * mc_pmatLocal;
|
||||
|
||||
bool m_isActive;
|
||||
|
||||
float m_fLocalTime;
|
||||
DWORD m_dwStartTime;
|
||||
float m_fElapsedTime;
|
||||
float m_fRemainingTime;
|
||||
bool m_bStart;
|
||||
|
||||
private:
|
||||
CEffectElementBase * m_pBase;
|
||||
};
|
288
src/EffectLib/EffectInstance.cpp
Normal file
288
src/EffectLib/EffectInstance.cpp
Normal file
@ -0,0 +1,288 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EffectInstance.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
#include "../eterBase/Stl.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
#include "../MilesLib/SoundManager.h"
|
||||
|
||||
CDynamicPool<CEffectInstance> CEffectInstance::ms_kPool;
|
||||
int CEffectInstance::ms_iRenderingEffectCount = 0;
|
||||
|
||||
bool CEffectInstance::LessRenderOrder(CEffectInstance* pkEftInst)
|
||||
{
|
||||
return (m_pkEftData<pkEftInst->m_pkEftData);
|
||||
}
|
||||
|
||||
void CEffectInstance::ResetRenderingEffectCount()
|
||||
{
|
||||
ms_iRenderingEffectCount = 0;
|
||||
}
|
||||
|
||||
int CEffectInstance::GetRenderingEffectCount()
|
||||
{
|
||||
return ms_iRenderingEffectCount;
|
||||
}
|
||||
|
||||
CEffectInstance* CEffectInstance::New()
|
||||
{
|
||||
CEffectInstance* pkEftInst=ms_kPool.Alloc();
|
||||
return pkEftInst;
|
||||
}
|
||||
|
||||
void CEffectInstance::Delete(CEffectInstance* pkEftInst)
|
||||
{
|
||||
pkEftInst->Clear();
|
||||
ms_kPool.Free(pkEftInst);
|
||||
}
|
||||
|
||||
void CEffectInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
|
||||
CParticleSystemInstance::DestroySystem();
|
||||
CEffectMeshInstance::DestroySystem();
|
||||
CLightInstance::DestroySystem();
|
||||
}
|
||||
|
||||
void CEffectInstance::UpdateSound()
|
||||
{
|
||||
if (m_pSoundInstanceVector)
|
||||
{
|
||||
CSoundManager& rkSndMgr=CSoundManager::Instance();
|
||||
rkSndMgr.UpdateSoundInstance(m_matGlobal._41, m_matGlobal._42, m_matGlobal._43, m_dwFrame, m_pSoundInstanceVector);
|
||||
// NOTE : <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>´<EFBFBD> - [levites]
|
||||
}
|
||||
++m_dwFrame;
|
||||
}
|
||||
|
||||
struct FEffectUpdator
|
||||
{
|
||||
BOOL isAlive;
|
||||
float fElapsedTime;
|
||||
FEffectUpdator(float fElapsedTime)
|
||||
: isAlive(FALSE), fElapsedTime(fElapsedTime)
|
||||
{
|
||||
}
|
||||
void operator () (CEffectElementBaseInstance * pInstance)
|
||||
{
|
||||
if (pInstance->Update(fElapsedTime))
|
||||
isAlive = TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
void CEffectInstance::OnUpdate()
|
||||
{
|
||||
Transform();
|
||||
|
||||
#ifdef WORLD_EDITOR
|
||||
FEffectUpdator f(CTimer::Instance().GetElapsedSecond());
|
||||
#else
|
||||
FEffectUpdator f(CTimer::Instance().GetCurrentSecond()-m_fLastTime);
|
||||
#endif
|
||||
f = std::for_each(m_ParticleInstanceVector.begin(), m_ParticleInstanceVector.end(),f);
|
||||
f = std::for_each(m_MeshInstanceVector.begin(), m_MeshInstanceVector.end(),f);
|
||||
f = std::for_each(m_LightInstanceVector.begin(), m_LightInstanceVector.end(),f);
|
||||
m_isAlive = f.isAlive;
|
||||
|
||||
m_fLastTime = CTimer::Instance().GetCurrentSecond();
|
||||
}
|
||||
|
||||
void CEffectInstance::OnRender()
|
||||
{
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_NONE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_NONE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHATESTENABLE, FALSE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
/////
|
||||
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TFACTOR);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ|D3DFVF_TEX1);
|
||||
std::for_each(m_ParticleInstanceVector.begin(),m_ParticleInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
||||
std::for_each(m_MeshInstanceVector.begin(),m_MeshInstanceVector.end(),std::void_mem_fun(&CEffectElementBaseInstance::Render));
|
||||
|
||||
/////
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MINFILTER);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_MAGFILTER);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHABLENDENABLE);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_SRCBLEND);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_DESTBLEND);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_ALPHATESTENABLE);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_CULLMODE);
|
||||
STATEMANAGER.RestoreRenderState(D3DRS_ZWRITEENABLE);
|
||||
|
||||
++ms_iRenderingEffectCount;
|
||||
}
|
||||
|
||||
void CEffectInstance::SetGlobalMatrix(const D3DXMATRIX & c_rmatGlobal)
|
||||
{
|
||||
m_matGlobal = c_rmatGlobal;
|
||||
}
|
||||
|
||||
BOOL CEffectInstance::isAlive()
|
||||
{
|
||||
return m_isAlive;
|
||||
}
|
||||
|
||||
void CEffectInstance::SetActive()
|
||||
{
|
||||
std::for_each(
|
||||
m_ParticleInstanceVector.begin(),
|
||||
m_ParticleInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetActive));
|
||||
std::for_each(
|
||||
m_MeshInstanceVector.begin(),
|
||||
m_MeshInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetActive));
|
||||
std::for_each(
|
||||
m_LightInstanceVector.begin(),
|
||||
m_LightInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetActive));
|
||||
}
|
||||
|
||||
void CEffectInstance::SetDeactive()
|
||||
{
|
||||
std::for_each(
|
||||
m_ParticleInstanceVector.begin(),
|
||||
m_ParticleInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetDeactive));
|
||||
std::for_each(
|
||||
m_MeshInstanceVector.begin(),
|
||||
m_MeshInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetDeactive));
|
||||
std::for_each(
|
||||
m_LightInstanceVector.begin(),
|
||||
m_LightInstanceVector.end(),
|
||||
std::void_mem_fun(&CEffectElementBaseInstance::SetDeactive));
|
||||
}
|
||||
|
||||
void CEffectInstance::__SetParticleData(CParticleSystemData * pData)
|
||||
{
|
||||
CParticleSystemInstance * pInstance = CParticleSystemInstance::New();
|
||||
pInstance->SetDataPointer(pData);
|
||||
pInstance->SetLocalMatrixPointer(&m_matGlobal);
|
||||
|
||||
m_ParticleInstanceVector.push_back(pInstance);
|
||||
}
|
||||
void CEffectInstance::__SetMeshData(CEffectMeshScript * pMesh)
|
||||
{
|
||||
CEffectMeshInstance * pMeshInstance = CEffectMeshInstance::New();
|
||||
pMeshInstance->SetDataPointer(pMesh);
|
||||
pMeshInstance->SetLocalMatrixPointer(&m_matGlobal);
|
||||
|
||||
m_MeshInstanceVector.push_back(pMeshInstance);
|
||||
}
|
||||
|
||||
void CEffectInstance::__SetLightData(CLightData* pData)
|
||||
{
|
||||
CLightInstance * pInstance = CLightInstance::New();
|
||||
pInstance->SetDataPointer(pData);
|
||||
pInstance->SetLocalMatrixPointer(&m_matGlobal);
|
||||
|
||||
m_LightInstanceVector.push_back(pInstance);
|
||||
}
|
||||
|
||||
void CEffectInstance::SetEffectDataPointer(CEffectData * pEffectData)
|
||||
{
|
||||
m_isAlive=true;
|
||||
|
||||
m_pkEftData=pEffectData;
|
||||
|
||||
m_fLastTime = CTimer::Instance().GetCurrentSecond();
|
||||
m_fBoundingSphereRadius = pEffectData->GetBoundingSphereRadius();
|
||||
m_v3BoundingSpherePosition = pEffectData->GetBoundingSpherePosition();
|
||||
|
||||
if (m_fBoundingSphereRadius > 0.0f)
|
||||
CGraphicObjectInstance::RegisterBoundingSphere();
|
||||
|
||||
DWORD i;
|
||||
|
||||
for (i = 0; i < pEffectData->GetParticleCount(); ++i)
|
||||
{
|
||||
CParticleSystemData * pParticle = pEffectData->GetParticlePointer(i);
|
||||
|
||||
__SetParticleData(pParticle);
|
||||
}
|
||||
|
||||
for (i = 0; i < pEffectData->GetMeshCount(); ++i)
|
||||
{
|
||||
CEffectMeshScript * pMesh = pEffectData->GetMeshPointer(i);
|
||||
|
||||
__SetMeshData(pMesh);
|
||||
}
|
||||
|
||||
for (i = 0; i < pEffectData->GetLightCount(); ++i)
|
||||
{
|
||||
CLightData * pLight = pEffectData->GetLightPointer(i);
|
||||
|
||||
__SetLightData(pLight);
|
||||
}
|
||||
|
||||
m_pSoundInstanceVector = pEffectData->GetSoundInstanceVector();
|
||||
}
|
||||
|
||||
bool CEffectInstance::GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius)
|
||||
{
|
||||
v3Center.x = m_matGlobal._41 + m_v3BoundingSpherePosition.x;
|
||||
v3Center.y = m_matGlobal._42 + m_v3BoundingSpherePosition.y;
|
||||
v3Center.z = m_matGlobal._43 + m_v3BoundingSpherePosition.z;
|
||||
fRadius = m_fBoundingSphereRadius;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectInstance::Clear()
|
||||
{
|
||||
if (!m_ParticleInstanceVector.empty())
|
||||
{
|
||||
std::for_each(m_ParticleInstanceVector.begin(), m_ParticleInstanceVector.end(), CParticleSystemInstance::Delete);
|
||||
m_ParticleInstanceVector.clear();
|
||||
}
|
||||
|
||||
if (!m_MeshInstanceVector.empty())
|
||||
{
|
||||
std::for_each(m_MeshInstanceVector.begin(), m_MeshInstanceVector.end(), CEffectMeshInstance::Delete);
|
||||
m_MeshInstanceVector.clear();
|
||||
}
|
||||
|
||||
if (!m_LightInstanceVector.empty())
|
||||
{
|
||||
std::for_each(m_LightInstanceVector.begin(), m_LightInstanceVector.end(), CLightInstance::Delete);
|
||||
m_LightInstanceVector.clear();
|
||||
}
|
||||
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
void CEffectInstance::__Initialize()
|
||||
{
|
||||
m_isAlive = FALSE;
|
||||
m_dwFrame = 0;
|
||||
m_pSoundInstanceVector = NULL;
|
||||
m_fBoundingSphereRadius = 0.0f;
|
||||
m_v3BoundingSpherePosition.x = m_v3BoundingSpherePosition.y = m_v3BoundingSpherePosition.z = 0.0f;
|
||||
|
||||
m_pkEftData=NULL;
|
||||
|
||||
D3DXMatrixIdentity(&m_matGlobal);
|
||||
}
|
||||
|
||||
CEffectInstance::CEffectInstance()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
CEffectInstance::~CEffectInstance()
|
||||
{
|
||||
assert(m_ParticleInstanceVector.empty());
|
||||
assert(m_MeshInstanceVector.empty());
|
||||
assert(m_LightInstanceVector.empty());
|
||||
}
|
90
src/EffectLib/EffectInstance.h
Normal file
90
src/EffectLib/EffectInstance.h
Normal file
@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterlib/GrpObjectInstance.h"
|
||||
#include "../eterlib/Pool.h"
|
||||
#include "../mileslib/Type.h"
|
||||
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "EffectData.h"
|
||||
#include "EffectMeshInstance.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
class CEffectInstance : public CGraphicObjectInstance
|
||||
{
|
||||
public:
|
||||
typedef std::vector<CEffectElementBaseInstance*> TEffectElementInstanceVector;
|
||||
|
||||
enum
|
||||
{
|
||||
ID = EFFECT_OBJECT
|
||||
};
|
||||
int GetType() const
|
||||
{
|
||||
return CEffectInstance::ID;
|
||||
}
|
||||
|
||||
bool GetBoundingSphere(D3DXVECTOR3 & v3Center, float & fRadius);
|
||||
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectInstance* New();
|
||||
static void Delete(CEffectInstance* pkEftInst);
|
||||
|
||||
static void ResetRenderingEffectCount();
|
||||
static int GetRenderingEffectCount();
|
||||
|
||||
public:
|
||||
CEffectInstance();
|
||||
virtual ~CEffectInstance();
|
||||
|
||||
bool LessRenderOrder(CEffectInstance* pkEftInst);
|
||||
|
||||
void SetEffectDataPointer(CEffectData * pEffectData);
|
||||
|
||||
void Clear();
|
||||
BOOL isAlive();
|
||||
void SetActive();
|
||||
void SetDeactive();
|
||||
void SetGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
|
||||
void UpdateSound();
|
||||
void OnUpdate();
|
||||
void OnRender();
|
||||
void OnBlendRender() {} // Not used
|
||||
void OnRenderToShadowMap() {} // Not used
|
||||
void OnRenderShadow() {} // Not used
|
||||
void OnRenderPCBlocker() {} // Not used
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __SetParticleData(CParticleSystemData * pData);
|
||||
void __SetMeshData(CEffectMeshScript * pMesh);
|
||||
void __SetLightData(CLightData * pData);
|
||||
|
||||
virtual void OnUpdateCollisionData(const CStaticCollisionDataVector * pscdVector) {} // Not used
|
||||
virtual void OnUpdateHeighInstance(CAttributeInstance * pAttributeInstance) {}
|
||||
virtual bool OnGetObjectHeight(float fX, float fY, float * pfHeight) { return false; }
|
||||
|
||||
protected:
|
||||
BOOL m_isAlive;
|
||||
DWORD m_dwFrame;
|
||||
D3DXMATRIX m_matGlobal;
|
||||
|
||||
CEffectData * m_pkEftData;
|
||||
|
||||
std::vector<CParticleSystemInstance*> m_ParticleInstanceVector;
|
||||
std::vector<CEffectMeshInstance*> m_MeshInstanceVector;
|
||||
std::vector<CLightInstance*> m_LightInstanceVector;
|
||||
|
||||
NSound::TSoundInstanceVector * m_pSoundInstanceVector;
|
||||
|
||||
float m_fBoundingSphereRadius;
|
||||
D3DXVECTOR3 m_v3BoundingSpherePosition;
|
||||
|
||||
float m_fLastTime;
|
||||
|
||||
public:
|
||||
static CDynamicPool<CEffectInstance> ms_kPool;
|
||||
static int ms_iRenderingEffectCount;
|
||||
};
|
568
src/EffectLib/EffectLib.vcxproj
Normal file
568
src/EffectLib/EffectLib.vcxproj
Normal file
@ -0,0 +1,568 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Distribute|Win32">
|
||||
<Configuration>Distribute</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="MfcDebug|Win32">
|
||||
<Configuration>MfcDebug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="MfcRelease|Win32">
|
||||
<Configuration>MfcRelease</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="VTune|Win32">
|
||||
<Configuration>VTune</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<ProjectName>EffectLib</ProjectName>
|
||||
<ProjectGuid>{790B152D-6582-467F-B767-8603C5A9E613}</ProjectGuid>
|
||||
<RootNamespace>EffectLib</RootNamespace>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>17.0.32203.90</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalOptions>/Gs /Gs %(AdditionalOptions)</AdditionalOptions>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\VTune/EffectLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\VTune/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\VTune/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\VTune/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\VTune\EffectLib.lib</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;WORLD_EDITOR;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\EffectLib___Win32_MfcDebug/EffectLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\EffectLib___Win32_MfcDebug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\EffectLib___Win32_MfcDebug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\EffectLib___Win32_MfcDebug/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\EffectLib___Win32_MfcDebug\EffectLib.lib</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\Release/EffectLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Release/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Release/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\Debug/EffectLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Debug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\Distribute/EffectLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\Distribute/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Distribute/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Distribute/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\EffectLib___Win32_MfcRelease/EffectLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\EffectLib___Win32_MfcRelease/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\EffectLib___Win32_MfcRelease/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\EffectLib___Win32_MfcRelease/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\EffectLib___Win32_MfcRelease\EffectLib.lib</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EffectData.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectElementBase.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectElementBaseInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectManager.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectMesh.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectMeshInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectUpdateDecorator.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EmitterProperty.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FrameController.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleProperty.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleSystemData.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleSystemInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleLightData.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleLightInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">Create</PrecompiledHeader>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Create</PrecompiledHeader>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">Create</PrecompiledHeader>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Type.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MaxSpeed</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="EffectData.h" />
|
||||
<ClInclude Include="EffectElementBase.h" />
|
||||
<ClInclude Include="EffectElementBaseInstance.h" />
|
||||
<ClInclude Include="EffectInstance.h" />
|
||||
<ClInclude Include="EffectManager.h" />
|
||||
<ClInclude Include="EffectMesh.h" />
|
||||
<ClInclude Include="EffectMeshInstance.h" />
|
||||
<ClInclude Include="EffectUpdateDecorator.h" />
|
||||
<ClInclude Include="EmitterProperty.h" />
|
||||
<ClInclude Include="FrameController.h" />
|
||||
<ClInclude Include="ParticleInstance.h" />
|
||||
<ClInclude Include="ParticleProperty.h" />
|
||||
<ClInclude Include="ParticleSystemData.h" />
|
||||
<ClInclude Include="ParticleSystemInstance.h" />
|
||||
<ClInclude Include="SimpleLightData.h" />
|
||||
<ClInclude Include="SimpleLightInstance.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
<ClInclude Include="Type.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
125
src/EffectLib/EffectLib.vcxproj.filters
Normal file
125
src/EffectLib/EffectLib.vcxproj.filters
Normal file
@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{34b0c1d5-11b0-4f40-91de-38bbe725d755}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{74681033-a4dd-4ff0-9104-15edeb2496a0}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EffectData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectElementBase.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectElementBaseInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectManager.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectMesh.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectMeshInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffectUpdateDecorator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EmitterProperty.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FrameController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleProperty.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleSystemData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ParticleSystemInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleLightData.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SimpleLightInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Type.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="EffectData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffectElementBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffectElementBaseInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffectInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffectManager.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffectMesh.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffectMeshInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffectUpdateDecorator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EmitterProperty.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FrameController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ParticleInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ParticleProperty.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ParticleSystemData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ParticleSystemInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SimpleLightData.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SimpleLightInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Type.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
468
src/EffectLib/EffectManager.cpp
Normal file
468
src/EffectLib/EffectManager.cpp
Normal file
@ -0,0 +1,468 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterBase/Random.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "EffectManager.h"
|
||||
|
||||
|
||||
|
||||
void CEffectManager::GetInfo(std::string* pstInfo)
|
||||
{
|
||||
char szInfo[256];
|
||||
|
||||
sprintf(szInfo, "Effect: Inst - ED %d, EI %d Pool - PSI %d, MI %d, LI %d, PI %d, EI %d, ED %d, PSD %d, EM %d, LD %d",
|
||||
m_kEftDataMap.size(),
|
||||
m_kEftInstMap.size(),
|
||||
CParticleSystemInstance::ms_kPool.GetCapacity(),
|
||||
CEffectMeshInstance::ms_kPool.GetCapacity(),
|
||||
CLightInstance::ms_kPool.GetCapacity(),
|
||||
CParticleInstance::ms_kPool.GetCapacity(),
|
||||
//CRayParticleInstance::ms_kPool.GetCapacity(),
|
||||
CEffectInstance::ms_kPool.GetCapacity(),
|
||||
CEffectData::ms_kPool.GetCapacity(),
|
||||
CParticleSystemData::ms_kPool.GetCapacity(),
|
||||
CEffectMeshScript::ms_kPool.GetCapacity(),
|
||||
CLightData::ms_kPool.GetCapacity()
|
||||
);
|
||||
pstInfo->append(szInfo);
|
||||
}
|
||||
|
||||
void CEffectManager::UpdateSound()
|
||||
{
|
||||
for (TEffectInstanceMap::iterator itor = m_kEftInstMap.begin(); itor != m_kEftInstMap.end(); ++itor)
|
||||
{
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
|
||||
pEffectInstance->UpdateSound();
|
||||
}
|
||||
}
|
||||
|
||||
bool CEffectManager::IsAliveEffect(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator f = m_kEftInstMap.find(dwInstanceIndex);
|
||||
if (m_kEftInstMap.end()==f)
|
||||
return false;
|
||||
|
||||
return f->second->isAlive() ? true : false;
|
||||
}
|
||||
|
||||
void CEffectManager::Update()
|
||||
{
|
||||
|
||||
// 2004. 3. 1. myevan. <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϴ<EFBFBD> <20>ڵ<EFBFBD>
|
||||
/*
|
||||
if (GetAsyncKeyState(VK_F9))
|
||||
{
|
||||
Tracenf("CEffectManager::m_EffectInstancePool %d", m_EffectInstancePool.GetCapacity());
|
||||
Tracenf("CEffectManager::m_EffectDataPool %d", m_EffectDataPool.GetCapacity());
|
||||
Tracenf("CEffectInstance::ms_LightInstancePool %d", CEffectInstance::ms_LightInstancePool.GetCapacity());
|
||||
Tracenf("CEffectInstance::ms_MeshInstancePool %d", CEffectInstance::ms_MeshInstancePool.GetCapacity());
|
||||
Tracenf("CEffectInstance::ms_ParticleSystemInstancePool %d", CEffectInstance::ms_ParticleSystemInstancePool.GetCapacity());
|
||||
Tracenf("CParticleInstance::ms_ParticleInstancePool %d", CParticleInstance::ms_kPool.GetCapacity());
|
||||
Tracenf("CRayParticleInstance::ms_RayParticleInstancePool %d", CRayParticleInstance::ms_kPool.GetCapacity());
|
||||
Tracen("---------------------------------------------");
|
||||
}
|
||||
*/
|
||||
|
||||
for (TEffectInstanceMap::iterator itor = m_kEftInstMap.begin(); itor != m_kEftInstMap.end();)
|
||||
{
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
|
||||
pEffectInstance->Update(/*fElapsedTime*/);
|
||||
|
||||
if (!pEffectInstance->isAlive())
|
||||
{
|
||||
itor = m_kEftInstMap.erase(itor);
|
||||
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct CEffectManager_LessEffectInstancePtrRenderOrder
|
||||
{
|
||||
bool operator() (CEffectInstance* pkLeft, CEffectInstance* pkRight)
|
||||
{
|
||||
return pkLeft->LessRenderOrder(pkRight);
|
||||
}
|
||||
};
|
||||
|
||||
struct CEffectManager_FEffectInstanceRender
|
||||
{
|
||||
inline void operator () (CEffectInstance * pkEftInst)
|
||||
{
|
||||
pkEftInst->Render();
|
||||
}
|
||||
};
|
||||
|
||||
void CEffectManager::Render()
|
||||
{
|
||||
STATEMANAGER.SetTexture(0, NULL);
|
||||
STATEMANAGER.SetTexture(1, NULL);
|
||||
|
||||
if (m_isDisableSortRendering)
|
||||
{
|
||||
for (TEffectInstanceMap::iterator itor = m_kEftInstMap.begin(); itor != m_kEftInstMap.end();)
|
||||
{
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
pEffectInstance->Render();
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
static std::vector<CEffectInstance*> s_kVct_pkEftInstSort;
|
||||
s_kVct_pkEftInstSort.clear();
|
||||
|
||||
TEffectInstanceMap& rkMap_pkEftInstSrc=m_kEftInstMap;
|
||||
TEffectInstanceMap::iterator i;
|
||||
for (i=rkMap_pkEftInstSrc.begin(); i!=rkMap_pkEftInstSrc.end(); ++i)
|
||||
s_kVct_pkEftInstSort.push_back(i->second);
|
||||
|
||||
std::sort(s_kVct_pkEftInstSort.begin(), s_kVct_pkEftInstSort.end(), CEffectManager_LessEffectInstancePtrRenderOrder());
|
||||
std::for_each(s_kVct_pkEftInstSort.begin(), s_kVct_pkEftInstSort.end(), CEffectManager_FEffectInstanceRender());
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CEffectManager::RegisterEffect(const char * c_szFileName,bool isExistDelete,bool isNeedCache)
|
||||
{
|
||||
std::string strFileName;
|
||||
StringPath(c_szFileName, strFileName);
|
||||
DWORD dwCRC = GetCaseCRC32(strFileName.c_str(), strFileName.length());
|
||||
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.find(dwCRC);
|
||||
if (m_kEftDataMap.end() != itor)
|
||||
{
|
||||
if (isExistDelete)
|
||||
{
|
||||
CEffectData* pkEftData=itor->second;
|
||||
CEffectData::Delete(pkEftData);
|
||||
m_kEftDataMap.erase(itor);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TraceError("CEffectManager::RegisterEffect - m_kEftDataMap.find [%s] Already Exist", c_szFileName);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
CEffectData * pkEftData = CEffectData::New();
|
||||
|
||||
if (!pkEftData->LoadScript(c_szFileName))
|
||||
{
|
||||
TraceError("CEffectManager::RegisterEffect - LoadScript(%s) Error", c_szFileName);
|
||||
CEffectData::Delete(pkEftData);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_kEftDataMap.insert(TEffectDataMap::value_type(dwCRC, pkEftData));
|
||||
|
||||
if (isNeedCache)
|
||||
{
|
||||
if (m_kEftCacheMap.find(dwCRC)==m_kEftCacheMap.end())
|
||||
{
|
||||
CEffectInstance* pkNewEftInst=CEffectInstance::New();
|
||||
pkNewEftInst->SetEffectDataPointer(pkEftData);
|
||||
m_kEftCacheMap.insert(TEffectInstanceMap::value_type(dwCRC, pkNewEftInst));
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
// CEffectData <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20>ϰ<EFBFBD>..
|
||||
// CEffectData<74><61><EFBFBD><EFBFBD> CRC<52><43> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ְ<EFBFBD> <20>Ѵ<EFBFBD>
|
||||
BOOL CEffectManager::RegisterEffect2(const char * c_szFileName, DWORD* pdwRetCRC, bool isNeedCache)
|
||||
{
|
||||
std::string strFileName;
|
||||
StringPath(c_szFileName, strFileName);
|
||||
DWORD dwCRC = GetCaseCRC32(strFileName.c_str(), strFileName.length());
|
||||
*pdwRetCRC=dwCRC;
|
||||
|
||||
return RegisterEffect(c_szFileName,false,isNeedCache);
|
||||
}
|
||||
|
||||
int CEffectManager::CreateEffect(const char * c_szFileName, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation)
|
||||
{
|
||||
DWORD dwID = GetCaseCRC32(c_szFileName, strlen(c_szFileName));
|
||||
return CreateEffect(dwID, c_rv3Position, c_rv3Rotation);
|
||||
}
|
||||
|
||||
int CEffectManager::CreateEffect(DWORD dwID, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation)
|
||||
{
|
||||
int iInstanceIndex = GetEmptyIndex();
|
||||
|
||||
CreateEffectInstance(iInstanceIndex, dwID);
|
||||
SelectEffectInstance(iInstanceIndex);
|
||||
D3DXMATRIX mat;
|
||||
D3DXMatrixRotationYawPitchRoll(&mat,D3DXToRadian(c_rv3Rotation.x),D3DXToRadian(c_rv3Rotation.y),D3DXToRadian(c_rv3Rotation.z));
|
||||
mat._41 = c_rv3Position.x;
|
||||
mat._42 = c_rv3Position.y;
|
||||
mat._43 = c_rv3Position.z;
|
||||
SetEffectInstanceGlobalMatrix(mat);
|
||||
|
||||
return iInstanceIndex;
|
||||
}
|
||||
|
||||
void CEffectManager::CreateEffectInstance(DWORD dwInstanceIndex, DWORD dwID)
|
||||
{
|
||||
if (!dwID)
|
||||
return;
|
||||
|
||||
CEffectData * pEffect;
|
||||
if (!GetEffectData(dwID, &pEffect))
|
||||
{
|
||||
Tracef("CEffectManager::CreateEffectInstance - NO DATA :%d\n", dwID);
|
||||
return;
|
||||
}
|
||||
|
||||
CEffectInstance * pEffectInstance = CEffectInstance::New();
|
||||
pEffectInstance->SetEffectDataPointer(pEffect);
|
||||
|
||||
m_kEftInstMap.insert(TEffectInstanceMap::value_type(dwInstanceIndex, pEffectInstance));
|
||||
}
|
||||
|
||||
bool CEffectManager::DestroyEffectInstance(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator itor = m_kEftInstMap.find(dwInstanceIndex);
|
||||
|
||||
if (itor == m_kEftInstMap.end())
|
||||
return false;
|
||||
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
|
||||
m_kEftInstMap.erase(itor);
|
||||
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectManager::DeactiveEffectInstance(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator itor = m_kEftInstMap.find(dwInstanceIndex);
|
||||
|
||||
if (itor == m_kEftInstMap.end())
|
||||
return;
|
||||
|
||||
CEffectInstance * pEffectInstance = itor->second;
|
||||
pEffectInstance->SetDeactive();
|
||||
}
|
||||
|
||||
void CEffectManager::CreateUnsafeEffectInstance(DWORD dwEffectDataID, CEffectInstance ** ppEffectInstance)
|
||||
{
|
||||
CEffectData * pEffect;
|
||||
if (!GetEffectData(dwEffectDataID, &pEffect))
|
||||
{
|
||||
Tracef("CEffectManager::CreateEffectInstance - NO DATA :%d\n", dwEffectDataID);
|
||||
return;
|
||||
}
|
||||
|
||||
CEffectInstance* pkEftInstNew=CEffectInstance::New();
|
||||
pkEftInstNew->SetEffectDataPointer(pEffect);
|
||||
|
||||
*ppEffectInstance = pkEftInstNew;
|
||||
}
|
||||
|
||||
bool CEffectManager::DestroyUnsafeEffectInstance(CEffectInstance * pEffectInstance)
|
||||
{
|
||||
if (!pEffectInstance)
|
||||
return false;
|
||||
|
||||
CEffectInstance::Delete(pEffectInstance);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CEffectManager::SelectEffectInstance(DWORD dwInstanceIndex)
|
||||
{
|
||||
TEffectInstanceMap::iterator itor = m_kEftInstMap.find(dwInstanceIndex);
|
||||
|
||||
m_pSelectedEffectInstance = NULL;
|
||||
|
||||
if (m_kEftInstMap.end() == itor)
|
||||
return FALSE;
|
||||
|
||||
m_pSelectedEffectInstance = itor->second;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectTextures(DWORD dwID, std::vector<std::string> textures)
|
||||
{
|
||||
CEffectData * pEffectData;
|
||||
if (!GetEffectData(dwID, &pEffectData))
|
||||
{
|
||||
Tracef("CEffectManager::CreateEffectInstance - NO DATA :%d\n", dwID);
|
||||
return;
|
||||
}
|
||||
|
||||
for(DWORD i = 0; i < textures.size(); i++)
|
||||
{
|
||||
CParticleSystemData * pParticle = pEffectData->GetParticlePointer(i);
|
||||
pParticle->ChangeTexture(textures.at(i).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectInstancePosition(const D3DXVECTOR3 & c_rv3Position)
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
{
|
||||
// assert(!"Instance to use is not yet set!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_pSelectedEffectInstance->SetPosition(c_rv3Position);
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectInstanceRotation(const D3DXVECTOR3 & c_rv3Rotation)
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
{
|
||||
// assert(!"Instance to use is not yet set!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_pSelectedEffectInstance->SetRotation(c_rv3Rotation.x,c_rv3Rotation.y,c_rv3Rotation.z);
|
||||
}
|
||||
|
||||
void CEffectManager::SetEffectInstanceGlobalMatrix(const D3DXMATRIX & c_rmatGlobal)
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
|
||||
m_pSelectedEffectInstance->SetGlobalMatrix(c_rmatGlobal);
|
||||
}
|
||||
|
||||
void CEffectManager::ShowEffect()
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
|
||||
m_pSelectedEffectInstance->Show();
|
||||
}
|
||||
|
||||
void CEffectManager::HideEffect()
|
||||
{
|
||||
if (!m_pSelectedEffectInstance)
|
||||
return;
|
||||
|
||||
m_pSelectedEffectInstance->Hide();
|
||||
}
|
||||
|
||||
bool CEffectManager::GetEffectData(DWORD dwID, CEffectData ** ppEffect)
|
||||
{
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.find(dwID);
|
||||
|
||||
if (itor == m_kEftDataMap.end())
|
||||
return false;
|
||||
|
||||
*ppEffect = itor->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEffectManager::GetEffectData(DWORD dwID, const CEffectData ** c_ppEffect)
|
||||
{
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.find(dwID);
|
||||
|
||||
if (itor == m_kEftDataMap.end())
|
||||
return false;
|
||||
|
||||
*c_ppEffect = itor->second;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD CEffectManager::GetRandomEffect()
|
||||
{
|
||||
int iIndex = random() % m_kEftDataMap.size();
|
||||
|
||||
TEffectDataMap::iterator itor = m_kEftDataMap.begin();
|
||||
for (int i = 0; i < iIndex; ++i, ++itor);
|
||||
|
||||
return itor->first;
|
||||
}
|
||||
|
||||
int CEffectManager::GetEmptyIndex()
|
||||
{
|
||||
static int iMaxIndex=1;
|
||||
|
||||
if (iMaxIndex>2100000000)
|
||||
iMaxIndex = 1;
|
||||
|
||||
int iNextIndex = iMaxIndex++;
|
||||
while(m_kEftInstMap.find(iNextIndex) != m_kEftInstMap.end())
|
||||
iNextIndex++;
|
||||
|
||||
return iNextIndex;
|
||||
}
|
||||
|
||||
void CEffectManager::DeleteAllInstances()
|
||||
{
|
||||
__DestroyEffectInstanceMap();
|
||||
}
|
||||
|
||||
void CEffectManager::__DestroyEffectInstanceMap()
|
||||
{
|
||||
for (TEffectInstanceMap::iterator i = m_kEftInstMap.begin(); i != m_kEftInstMap.end(); ++i)
|
||||
{
|
||||
CEffectInstance * pkEftInst = i->second;
|
||||
CEffectInstance::Delete(pkEftInst);
|
||||
}
|
||||
|
||||
m_kEftInstMap.clear();
|
||||
}
|
||||
|
||||
void CEffectManager::__DestroyEffectCacheMap()
|
||||
{
|
||||
for (TEffectInstanceMap::iterator i = m_kEftCacheMap.begin(); i != m_kEftCacheMap.end(); ++i)
|
||||
{
|
||||
CEffectInstance * pkEftInst = i->second;
|
||||
CEffectInstance::Delete(pkEftInst);
|
||||
}
|
||||
|
||||
m_kEftCacheMap.clear();
|
||||
}
|
||||
|
||||
void CEffectManager::__DestroyEffectDataMap()
|
||||
{
|
||||
for (TEffectDataMap::iterator i = m_kEftDataMap.begin(); i != m_kEftDataMap.end(); ++i)
|
||||
{
|
||||
CEffectData * pData = i->second;
|
||||
CEffectData::Delete(pData);
|
||||
}
|
||||
|
||||
m_kEftDataMap.clear();
|
||||
}
|
||||
|
||||
void CEffectManager::Destroy()
|
||||
{
|
||||
__DestroyEffectInstanceMap();
|
||||
__DestroyEffectCacheMap();
|
||||
__DestroyEffectDataMap();
|
||||
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
void CEffectManager::__Initialize()
|
||||
{
|
||||
m_pSelectedEffectInstance = NULL;
|
||||
m_isDisableSortRendering = false;
|
||||
}
|
||||
|
||||
CEffectManager::CEffectManager()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
CEffectManager::~CEffectManager()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
// just for map effect
|
||||
|
86
src/EffectLib/EffectManager.h
Normal file
86
src/EffectLib/EffectManager.h
Normal file
@ -0,0 +1,86 @@
|
||||
#pragma once
|
||||
|
||||
#include "EffectInstance.h"
|
||||
|
||||
class CEffectManager : public CScreen, public CSingleton<CEffectManager>
|
||||
{
|
||||
public:
|
||||
enum EEffectType
|
||||
{
|
||||
EFFECT_TYPE_NONE = 0,
|
||||
EFFECT_TYPE_PARTICLE = 1,
|
||||
EFFECT_TYPE_ANIMATION_TEXTURE = 2,
|
||||
EFFECT_TYPE_MESH = 3,
|
||||
EFFECT_TYPE_SIMPLE_LIGHT = 4,
|
||||
|
||||
EFFECT_TYPE_MAX_NUM = 4,
|
||||
};
|
||||
|
||||
typedef std::map<DWORD, CEffectData*> TEffectDataMap;
|
||||
typedef std::map<DWORD, CEffectInstance*> TEffectInstanceMap;
|
||||
|
||||
public:
|
||||
CEffectManager();
|
||||
virtual ~CEffectManager();
|
||||
|
||||
void Destroy();
|
||||
|
||||
void UpdateSound();
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
void GetInfo(std::string* pstInfo);
|
||||
|
||||
bool IsAliveEffect(DWORD dwInstanceIndex);
|
||||
|
||||
// Register
|
||||
BOOL RegisterEffect(const char * c_szFileName,bool isExistDelete=false,bool isNeedCache=false);
|
||||
BOOL RegisterEffect2(const char * c_szFileName, DWORD* pdwRetCRC, bool isNeedCache=false);
|
||||
|
||||
void DeleteAllInstances();
|
||||
|
||||
// Usage
|
||||
int CreateEffect(DWORD dwID, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation);
|
||||
int CreateEffect(const char * c_szFileName, const D3DXVECTOR3 & c_rv3Position, const D3DXVECTOR3 & c_rv3Rotation);
|
||||
|
||||
void CreateEffectInstance(DWORD dwInstanceIndex, DWORD dwID);
|
||||
BOOL SelectEffectInstance(DWORD dwInstanceIndex);
|
||||
bool DestroyEffectInstance(DWORD dwInstanceIndex);
|
||||
void DeactiveEffectInstance(DWORD dwInstanceIndex);
|
||||
|
||||
void SetEffectTextures(DWORD dwID, std::vector<std::string> textures);
|
||||
void SetEffectInstancePosition(const D3DXVECTOR3 & c_rv3Position);
|
||||
void SetEffectInstanceRotation(const D3DXVECTOR3 & c_rv3Rotation);
|
||||
void SetEffectInstanceGlobalMatrix(const D3DXMATRIX & c_rmatGlobal);
|
||||
|
||||
void ShowEffect();
|
||||
void HideEffect();
|
||||
|
||||
// Temporary function
|
||||
DWORD GetRandomEffect();
|
||||
int GetEmptyIndex();
|
||||
bool GetEffectData(DWORD dwID, CEffectData ** ppEffect);
|
||||
bool GetEffectData(DWORD dwID, const CEffectData ** c_ppEffect);
|
||||
|
||||
// Area<65><61> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Effect<63><74> <20>Լ<EFBFBD>... EffectInstance<63><65> Pointer<65><72> <20><>ȯ<EFBFBD>Ѵ<EFBFBD>.
|
||||
// EffectManager <20><><EFBFBD><EFBFBD> EffectInstanceMap<61><70> <20>̿<EFBFBD><CCBF><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´<CAB4>.
|
||||
void CreateUnsafeEffectInstance(DWORD dwEffectDataID, CEffectInstance ** ppEffectInstance);
|
||||
bool DestroyUnsafeEffectInstance(CEffectInstance * pEffectInstance);
|
||||
|
||||
int GetRenderingEffectCount();
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __DestroyEffectInstanceMap();
|
||||
void __DestroyEffectCacheMap();
|
||||
void __DestroyEffectDataMap();
|
||||
|
||||
protected:
|
||||
bool m_isDisableSortRendering;
|
||||
TEffectDataMap m_kEftDataMap;
|
||||
TEffectInstanceMap m_kEftInstMap;
|
||||
TEffectInstanceMap m_kEftCacheMap;
|
||||
|
||||
CEffectInstance * m_pSelectedEffectInstance;
|
||||
};
|
699
src/EffectLib/EffectMesh.cpp
Normal file
699
src/EffectLib/EffectMesh.cpp
Normal file
@ -0,0 +1,699 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "../eterlib/ResourceManager.h"
|
||||
#include "../eterpack/EterPackManager.h"
|
||||
#include "EffectMesh.h"
|
||||
|
||||
CDynamicPool<CEffectMesh::SEffectMeshData> CEffectMesh::SEffectMeshData::ms_kPool;
|
||||
|
||||
CEffectMesh::SEffectMeshData* CEffectMesh::SEffectMeshData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectMesh::SEffectMeshData::Delete(SEffectMeshData* pkData)
|
||||
{
|
||||
pkData->EffectFrameDataVector.clear();
|
||||
pkData->pImageVector.clear();
|
||||
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CEffectMesh::SEffectMeshData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
|
||||
DWORD CEffectMesh::GetFrameCount()
|
||||
{
|
||||
return m_iFrameCount;
|
||||
}
|
||||
|
||||
DWORD CEffectMesh::GetMeshCount()
|
||||
{
|
||||
return m_pEffectMeshDataVector.size();
|
||||
}
|
||||
|
||||
CEffectMesh::TEffectMeshData * CEffectMesh::GetMeshDataPointer(DWORD dwMeshIndex)
|
||||
{
|
||||
assert(dwMeshIndex < m_pEffectMeshDataVector.size());
|
||||
return m_pEffectMeshDataVector[dwMeshIndex];
|
||||
}
|
||||
|
||||
std::vector<CGraphicImage*>* CEffectMesh::GetTextureVectorPointer(DWORD dwMeshIndex)
|
||||
{
|
||||
if (dwMeshIndex>=m_pEffectMeshDataVector.size())
|
||||
return NULL;
|
||||
|
||||
return &m_pEffectMeshDataVector[dwMeshIndex]->pImageVector;
|
||||
}
|
||||
|
||||
std::vector<CGraphicImage*> & CEffectMesh::GetTextureVectorReference(DWORD dwMeshIndex)
|
||||
{
|
||||
return m_pEffectMeshDataVector[dwMeshIndex]->pImageVector;
|
||||
}
|
||||
|
||||
CEffectMesh::TType CEffectMesh::Type()
|
||||
{
|
||||
static TType s_type = StringToType("CEffectMesh");
|
||||
return s_type;
|
||||
}
|
||||
|
||||
bool CEffectMesh::OnIsType(TType type)
|
||||
{
|
||||
if (CEffectMesh::Type() == type)
|
||||
return true;
|
||||
|
||||
return CResource::OnIsType(type);
|
||||
}
|
||||
|
||||
bool CEffectMesh::OnLoad(int iSize, const void * c_pvBuf)
|
||||
{
|
||||
if (!c_pvBuf)
|
||||
return false;
|
||||
|
||||
const BYTE * c_pbBuf = static_cast<const BYTE *> (c_pvBuf);
|
||||
|
||||
char szHeader[10+1];
|
||||
memcpy(szHeader, c_pbBuf, 10+1);
|
||||
c_pbBuf += 10+1;
|
||||
|
||||
if (0 == strcmp("EffectData", szHeader))
|
||||
{
|
||||
if (!__LoadData_Ver001(iSize, c_pbBuf))
|
||||
return false;
|
||||
}
|
||||
else if (0 == strcmp("MDEData002", szHeader))
|
||||
{
|
||||
if (!__LoadData_Ver002(iSize, c_pbBuf))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
m_isData = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CEffectMesh::__LoadData_Ver002(int iSize, const BYTE * c_pbBuf)
|
||||
{
|
||||
std::vector<D3DXVECTOR3> v3VertexVector;
|
||||
std::vector<int> iIndexVector;
|
||||
std::vector<D3DXVECTOR2> v3TextureVertexVector;
|
||||
std::vector<int> iTextureIndexVector;
|
||||
|
||||
m_iGeomCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
m_iFrameCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
|
||||
m_pEffectMeshDataVector.clear();
|
||||
m_pEffectMeshDataVector.resize(m_iGeomCount);
|
||||
|
||||
for (short n = 0; n < m_iGeomCount; ++n)
|
||||
{
|
||||
SEffectMeshData * pMeshData = SEffectMeshData::New();
|
||||
|
||||
memcpy(pMeshData->szObjectName, c_pbBuf, 32);
|
||||
c_pbBuf += 32;
|
||||
memcpy(pMeshData->szDiffuseMapFileName, c_pbBuf, 128);
|
||||
c_pbBuf += 128;
|
||||
|
||||
pMeshData->EffectFrameDataVector.clear();
|
||||
pMeshData->EffectFrameDataVector.resize(m_iFrameCount);
|
||||
|
||||
for(int i = 0; i < m_iFrameCount; ++i)
|
||||
{
|
||||
TEffectFrameData & rFrameData = pMeshData->EffectFrameDataVector[i];
|
||||
|
||||
memcpy(&rFrameData.byChangedFrame, c_pbBuf, sizeof(BYTE));
|
||||
c_pbBuf += sizeof(BYTE);
|
||||
|
||||
memcpy(&rFrameData.fVisibility, c_pbBuf, sizeof(float));
|
||||
c_pbBuf += sizeof(float);
|
||||
|
||||
memcpy(&rFrameData.dwVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&rFrameData.dwIndexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&rFrameData.dwTextureVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
v3VertexVector.clear();
|
||||
v3VertexVector.resize(rFrameData.dwVertexCount);
|
||||
iIndexVector.clear();
|
||||
iIndexVector.resize(rFrameData.dwIndexCount);
|
||||
v3TextureVertexVector.clear();
|
||||
v3TextureVertexVector.resize(rFrameData.dwTextureVertexCount);
|
||||
iTextureIndexVector.clear();
|
||||
iTextureIndexVector.resize(rFrameData.dwIndexCount);
|
||||
|
||||
memcpy(&v3VertexVector[0], c_pbBuf, rFrameData.dwVertexCount*sizeof(D3DXVECTOR3));
|
||||
c_pbBuf += rFrameData.dwVertexCount*sizeof(D3DXVECTOR3);
|
||||
memcpy(&iIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
memcpy(&v3TextureVertexVector[0], c_pbBuf, rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2));
|
||||
c_pbBuf += rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2);
|
||||
memcpy(&iTextureIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
rFrameData.PDTVertexVector.clear();
|
||||
rFrameData.PDTVertexVector.resize(rFrameData.dwIndexCount);
|
||||
for (DWORD j = 0; j < rFrameData.dwIndexCount; ++j)
|
||||
{
|
||||
TPTVertex & rVertex = rFrameData.PDTVertexVector[j];
|
||||
|
||||
DWORD dwIndex = iIndexVector[j];
|
||||
DWORD dwTextureIndex = iTextureIndexVector[j];
|
||||
|
||||
assert(dwIndex < v3VertexVector.size());
|
||||
assert(dwTextureIndex < v3TextureVertexVector.size());
|
||||
|
||||
rVertex.position = v3VertexVector[dwIndex];
|
||||
rVertex.texCoord = v3TextureVertexVector[dwTextureIndex];
|
||||
rVertex.texCoord.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
pMeshData->pImageVector.clear();
|
||||
|
||||
std::string strExtension;
|
||||
GetFileExtension(pMeshData->szDiffuseMapFileName, strlen(pMeshData->szDiffuseMapFileName), &strExtension);
|
||||
stl_lowers(strExtension);
|
||||
|
||||
if (0 == strExtension.compare("ifl"))
|
||||
{
|
||||
LPCVOID pMotionData;
|
||||
CMappedFile File;
|
||||
|
||||
if (CEterPackManager::Instance().Get(File, pMeshData->szDiffuseMapFileName, &pMotionData))
|
||||
{
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
std::vector<std::string> stTokenVector;
|
||||
|
||||
textFileLoader.Bind(File.Size(), pMotionData);
|
||||
|
||||
std::string strPathName;
|
||||
GetOnlyPathName(pMeshData->szDiffuseMapFileName, strPathName);
|
||||
|
||||
std::string strTextureFileName;
|
||||
for (DWORD i = 0; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
const std::string & c_rstrFileName = textFileLoader.GetLineString(i);
|
||||
|
||||
if (c_rstrFileName.empty())
|
||||
continue;
|
||||
|
||||
strTextureFileName = strPathName;
|
||||
strTextureFileName += c_rstrFileName;
|
||||
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(strTextureFileName.c_str());
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(pMeshData->szDiffuseMapFileName);
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
m_pEffectMeshDataVector[n] = pMeshData;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CEffectMesh::__LoadData_Ver001(int iSize, const BYTE * c_pbBuf)
|
||||
{
|
||||
std::vector<D3DXVECTOR3> v3VertexVector;
|
||||
std::vector<int> iIndexVector;
|
||||
std::vector<D3DXVECTOR2> v3TextureVertexVector;
|
||||
std::vector<int> iTextureIndexVector;
|
||||
|
||||
m_iGeomCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
m_iFrameCount = *(int *)c_pbBuf;
|
||||
c_pbBuf += 4;
|
||||
|
||||
m_pEffectMeshDataVector.clear();
|
||||
m_pEffectMeshDataVector.resize(m_iGeomCount);
|
||||
|
||||
for (short n = 0; n < m_iGeomCount; ++n)
|
||||
{
|
||||
SEffectMeshData * pMeshData = SEffectMeshData::New();
|
||||
|
||||
memcpy(pMeshData->szObjectName, c_pbBuf, 32);
|
||||
c_pbBuf += 32;
|
||||
memcpy(pMeshData->szDiffuseMapFileName, c_pbBuf, 128);
|
||||
c_pbBuf += 128;
|
||||
|
||||
//
|
||||
|
||||
DWORD dwVertexCount;
|
||||
DWORD dwIndexCount;
|
||||
DWORD dwTextureVertexCount;
|
||||
|
||||
memcpy(&dwVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&dwIndexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
memcpy(&dwTextureVertexCount, c_pbBuf, sizeof(DWORD));
|
||||
c_pbBuf += sizeof(DWORD);
|
||||
|
||||
pMeshData->EffectFrameDataVector.clear();
|
||||
pMeshData->EffectFrameDataVector.resize(m_iFrameCount);
|
||||
|
||||
for(int i = 0; i < m_iFrameCount; ++i)
|
||||
{
|
||||
TEffectFrameData & rFrameData = pMeshData->EffectFrameDataVector[i];
|
||||
|
||||
rFrameData.dwVertexCount = dwVertexCount;
|
||||
rFrameData.dwIndexCount = dwIndexCount;
|
||||
rFrameData.dwTextureVertexCount = dwTextureVertexCount;
|
||||
|
||||
v3VertexVector.clear();
|
||||
v3VertexVector.resize(rFrameData.dwVertexCount);
|
||||
iIndexVector.clear();
|
||||
iIndexVector.resize(rFrameData.dwIndexCount);
|
||||
v3TextureVertexVector.clear();
|
||||
v3TextureVertexVector.resize(rFrameData.dwTextureVertexCount);
|
||||
iTextureIndexVector.clear();
|
||||
iTextureIndexVector.resize(rFrameData.dwIndexCount);
|
||||
|
||||
memcpy(&rFrameData.fVisibility, c_pbBuf, sizeof(float));
|
||||
c_pbBuf += sizeof(float);
|
||||
memcpy(&v3VertexVector[0], c_pbBuf, rFrameData.dwVertexCount*sizeof(D3DXVECTOR3));
|
||||
c_pbBuf += rFrameData.dwVertexCount*sizeof(D3DXVECTOR3);
|
||||
memcpy(&iIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
memcpy(&v3TextureVertexVector[0], c_pbBuf, rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2));
|
||||
c_pbBuf += rFrameData.dwTextureVertexCount*sizeof(D3DXVECTOR2);
|
||||
memcpy(&iTextureIndexVector[0], c_pbBuf, rFrameData.dwIndexCount*sizeof(int));
|
||||
c_pbBuf += rFrameData.dwIndexCount*sizeof(int);
|
||||
|
||||
///////////////////////////////
|
||||
|
||||
rFrameData.PDTVertexVector.clear();
|
||||
rFrameData.PDTVertexVector.resize(rFrameData.dwIndexCount);
|
||||
for (DWORD j = 0; j < rFrameData.dwIndexCount; ++j)
|
||||
{
|
||||
TPTVertex & rVertex = rFrameData.PDTVertexVector[j];
|
||||
|
||||
DWORD dwIndex = iIndexVector[j];
|
||||
DWORD dwTextureIndex = iTextureIndexVector[j];
|
||||
|
||||
assert(dwIndex < v3VertexVector.size());
|
||||
assert(dwTextureIndex < v3TextureVertexVector.size());
|
||||
|
||||
rVertex.position = v3VertexVector[dwIndex];
|
||||
rVertex.texCoord = v3TextureVertexVector[dwTextureIndex];
|
||||
rVertex.texCoord.y *= -1;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
pMeshData->pImageVector.clear();
|
||||
|
||||
std::string strExtension;
|
||||
GetFileExtension(pMeshData->szDiffuseMapFileName, strlen(pMeshData->szDiffuseMapFileName), &strExtension);
|
||||
stl_lowers(strExtension);
|
||||
|
||||
if (0 == strExtension.compare("ifl"))
|
||||
{
|
||||
LPCVOID pMotionData;
|
||||
CMappedFile File;
|
||||
|
||||
if (CEterPackManager::Instance().Get(File, pMeshData->szDiffuseMapFileName, &pMotionData))
|
||||
{
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
std::vector<std::string> stTokenVector;
|
||||
|
||||
textFileLoader.Bind(File.Size(), pMotionData);
|
||||
|
||||
std::string strPathName;
|
||||
GetOnlyPathName(pMeshData->szDiffuseMapFileName, strPathName);
|
||||
|
||||
std::string strTextureFileName;
|
||||
for (DWORD i = 0; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
const std::string & c_rstrFileName = textFileLoader.GetLineString(i);
|
||||
|
||||
if (c_rstrFileName.empty())
|
||||
continue;
|
||||
|
||||
strTextureFileName = strPathName;
|
||||
strTextureFileName += c_rstrFileName;
|
||||
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(strTextureFileName.c_str());
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(pMeshData->szDiffuseMapFileName);
|
||||
|
||||
pMeshData->pImageVector.push_back(pImage);
|
||||
}
|
||||
|
||||
////////////////////////////////////
|
||||
|
||||
m_pEffectMeshDataVector[n] = pMeshData;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CEffectMesh::GetMeshElementPointer(DWORD dwMeshIndex, TEffectMeshData ** ppMeshData)
|
||||
{
|
||||
if (dwMeshIndex >= m_pEffectMeshDataVector.size())
|
||||
return FALSE;
|
||||
|
||||
*ppMeshData = m_pEffectMeshDataVector[dwMeshIndex];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CEffectMesh::OnClear()
|
||||
{
|
||||
if (!m_isData)
|
||||
return;
|
||||
|
||||
for (DWORD i = 0; i < m_pEffectMeshDataVector.size(); ++i)
|
||||
{
|
||||
m_pEffectMeshDataVector[i]->pImageVector.clear();
|
||||
m_pEffectMeshDataVector[i]->EffectFrameDataVector.clear();
|
||||
|
||||
SEffectMeshData::Delete(m_pEffectMeshDataVector[i]);
|
||||
}
|
||||
m_pEffectMeshDataVector.clear();
|
||||
|
||||
m_isData = false;
|
||||
}
|
||||
|
||||
bool CEffectMesh::OnIsEmpty() const
|
||||
{
|
||||
return !m_isData;
|
||||
}
|
||||
|
||||
CEffectMesh::CEffectMesh(const char * c_szFileName) : CResource(c_szFileName)
|
||||
{
|
||||
m_iGeomCount = 0;
|
||||
m_iFrameCount = 0;
|
||||
m_isData = false;
|
||||
}
|
||||
|
||||
CEffectMesh::~CEffectMesh()
|
||||
{
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CDynamicPool<CEffectMeshScript> CEffectMeshScript::ms_kPool;
|
||||
|
||||
void CEffectMeshScript::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CEffectMeshScript* CEffectMeshScript::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectMeshScript::Delete(CEffectMeshScript* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CEffectMeshScript::ReserveMeshData(DWORD dwMeshCount)
|
||||
{
|
||||
if (m_MeshDataVector.size() == dwMeshCount)
|
||||
return;
|
||||
|
||||
m_MeshDataVector.clear();
|
||||
m_MeshDataVector.resize(dwMeshCount);
|
||||
|
||||
for (DWORD i = 0; i < m_MeshDataVector.size(); ++i)
|
||||
{
|
||||
TMeshData & rMeshData = m_MeshDataVector[i];
|
||||
|
||||
rMeshData.byBillboardType = MESH_BILLBOARD_TYPE_NONE;
|
||||
rMeshData.bBlendingEnable = TRUE;
|
||||
rMeshData.byBlendingSrcType = D3DBLEND_SRCCOLOR;
|
||||
rMeshData.byBlendingDestType = D3DBLEND_ONE;
|
||||
rMeshData.bTextureAlphaEnable = FALSE;
|
||||
|
||||
rMeshData.byColorOperationType = D3DTOP_MODULATE;
|
||||
rMeshData.ColorFactor = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
rMeshData.bTextureAnimationLoopEnable = true;
|
||||
rMeshData.fTextureAnimationFrameDelay = 0.02f;
|
||||
rMeshData.dwTextureAnimationStartFrame = 0;
|
||||
}
|
||||
}
|
||||
|
||||
const char * CEffectMeshScript::GetMeshFileName()
|
||||
{
|
||||
return m_strMeshFileName.c_str();
|
||||
}
|
||||
|
||||
bool CEffectMeshScript::CheckMeshIndex(DWORD dwMeshIndex)
|
||||
{
|
||||
if (dwMeshIndex >= m_MeshDataVector.size())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEffectMeshScript::GetMeshDataPointer(DWORD dwMeshIndex, TMeshData ** ppMeshData)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
*ppMeshData = &m_MeshDataVector[dwMeshIndex];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CEffectMeshScript::GetMeshDataCount()
|
||||
{
|
||||
return m_MeshDataVector.size();
|
||||
}
|
||||
|
||||
int CEffectMeshScript::GetBillboardType(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].byBillboardType;
|
||||
}
|
||||
BOOL CEffectMeshScript::isBlendingEnable(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].bBlendingEnable;
|
||||
}
|
||||
BYTE CEffectMeshScript::GetBlendingSrcType(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].byBlendingSrcType;
|
||||
}
|
||||
BYTE CEffectMeshScript::GetBlendingDestType(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].byBlendingDestType;
|
||||
}
|
||||
BOOL CEffectMeshScript::isTextureAlphaEnable(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return false;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].bTextureAlphaEnable;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::GetColorOperationType(DWORD dwMeshIndex, BYTE * pbyType)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
*pbyType = m_MeshDataVector[dwMeshIndex].byColorOperationType;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
BOOL CEffectMeshScript::GetColorFactor(DWORD dwMeshIndex, D3DXCOLOR * pColor)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
*pColor = m_MeshDataVector[dwMeshIndex].ColorFactor;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::GetTimeTableAlphaPointer(DWORD dwMeshIndex, TTimeEventTableFloat ** pTimeEventAlpha)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return FALSE;
|
||||
|
||||
*pTimeEventAlpha = &m_MeshDataVector[dwMeshIndex].TimeEventAlpha;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CEffectMeshScript::isMeshAnimationLoop()
|
||||
{
|
||||
return m_isMeshAnimationLoop;
|
||||
}
|
||||
int CEffectMeshScript::GetMeshAnimationLoopCount()
|
||||
{
|
||||
return m_iMeshAnimationLoopCount;
|
||||
}
|
||||
float CEffectMeshScript::GetMeshAnimationFrameDelay()
|
||||
{
|
||||
return m_fMeshAnimationFrameDelay;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::isTextureAnimationLoop(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0.0f;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].bTextureAnimationLoopEnable;
|
||||
}
|
||||
float CEffectMeshScript::GetTextureAnimationFrameDelay(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0.0f;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].fTextureAnimationFrameDelay;
|
||||
}
|
||||
|
||||
DWORD CEffectMeshScript::GetTextureAnimationStartFrame(DWORD dwMeshIndex)
|
||||
{
|
||||
if (!CheckMeshIndex(dwMeshIndex))
|
||||
return 0;
|
||||
|
||||
return m_MeshDataVector[dwMeshIndex].dwTextureAnimationStartFrame;
|
||||
}
|
||||
|
||||
BOOL CEffectMeshScript::OnLoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (rTextFileLoader.GetTokenString("meshfilename", &m_strMeshFileName))
|
||||
{
|
||||
if (!IsGlobalFileName(m_strMeshFileName.c_str()))
|
||||
{
|
||||
m_strMeshFileName = GetOnlyPathName(rTextFileLoader.GetFileName()) + m_strMeshFileName;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenInteger("meshanimationloopenable", &m_isMeshAnimationLoop))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenInteger("meshanimationloopcount", &m_iMeshAnimationLoopCount))
|
||||
{
|
||||
m_iMeshAnimationLoopCount = 0;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenFloat("meshanimationframedelay", &m_fMeshAnimationFrameDelay))
|
||||
return FALSE;
|
||||
|
||||
DWORD dwMeshElementCount;
|
||||
if (!rTextFileLoader.GetTokenDoubleWord("meshelementcount", &dwMeshElementCount))
|
||||
return FALSE;
|
||||
|
||||
m_MeshDataVector.clear();
|
||||
m_MeshDataVector.resize(dwMeshElementCount);
|
||||
for (DWORD i = 0; i < m_MeshDataVector.size(); ++i)
|
||||
{
|
||||
CTextFileLoader::CGotoChild GotoChild(&rTextFileLoader, i);
|
||||
|
||||
TMeshData & rMeshData = m_MeshDataVector[i];
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("billboardtype", &rMeshData.byBillboardType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenBoolean("blendingenable", &rMeshData.bBlendingEnable))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenByte("blendingsrctype", &rMeshData.byBlendingSrcType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenByte("blendingdesttype", &rMeshData.byBlendingDestType))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("textureanimationloopenable", &rMeshData.bTextureAnimationLoopEnable))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenFloat("textureanimationframedelay", &rMeshData.fTextureAnimationFrameDelay))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenDoubleWord("textureanimationstartframe", &rMeshData.dwTextureAnimationStartFrame))
|
||||
{
|
||||
rMeshData.dwTextureAnimationStartFrame = 0;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("coloroperationtype", &rMeshData.byColorOperationType))
|
||||
{
|
||||
rMeshData.byColorOperationType = D3DTOP_MODULATE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenColor("colorfactor", &rMeshData.ColorFactor))
|
||||
{
|
||||
rMeshData.ColorFactor = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventalpha", &rMeshData.TimeEventAlpha))
|
||||
{
|
||||
rMeshData.TimeEventAlpha.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool CEffectMeshScript::OnIsData()
|
||||
{
|
||||
if (0 == m_strMeshFileName.length())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectMeshScript::OnClear()
|
||||
{
|
||||
m_isMeshAnimationLoop = false;
|
||||
m_iMeshAnimationLoopCount = 0;
|
||||
m_fMeshAnimationFrameDelay = 0.02f;
|
||||
|
||||
m_MeshDataVector.clear();
|
||||
m_strMeshFileName = "";
|
||||
}
|
||||
|
||||
CEffectMeshScript::CEffectMeshScript()
|
||||
{
|
||||
}
|
||||
CEffectMeshScript::~CEffectMeshScript()
|
||||
{
|
||||
}
|
157
src/EffectLib/EffectMesh.h
Normal file
157
src/EffectLib/EffectMesh.h
Normal file
@ -0,0 +1,157 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
#include "../eterlib/Resource.h"
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "Type.h"
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
class CEffectMesh : public CResource
|
||||
{
|
||||
public:
|
||||
typedef struct SEffectFrameData
|
||||
{
|
||||
BYTE byChangedFrame;
|
||||
float fVisibility;
|
||||
DWORD dwVertexCount;
|
||||
DWORD dwTextureVertexCount;
|
||||
DWORD dwIndexCount;
|
||||
std::vector<TPTVertex> PDTVertexVector;
|
||||
} TEffectFrameData;
|
||||
|
||||
typedef struct SEffectMeshData
|
||||
{
|
||||
char szObjectName[32];
|
||||
char szDiffuseMapFileName[128];
|
||||
|
||||
std::vector<TEffectFrameData> EffectFrameDataVector;
|
||||
std::vector<CGraphicImage*> pImageVector;
|
||||
|
||||
static SEffectMeshData* New();
|
||||
static void Delete(SEffectMeshData* pkData);
|
||||
|
||||
static void DestroySystem();
|
||||
|
||||
static CDynamicPool<SEffectMeshData> ms_kPool;
|
||||
} TEffectMeshData;
|
||||
|
||||
// About Resource Code
|
||||
public:
|
||||
typedef CRef<CEffectMesh> TRef;
|
||||
|
||||
public:
|
||||
static TType Type();
|
||||
|
||||
public:
|
||||
CEffectMesh(const char * c_szFileName);
|
||||
virtual ~CEffectMesh();
|
||||
|
||||
DWORD GetFrameCount();
|
||||
DWORD GetMeshCount();
|
||||
TEffectMeshData * GetMeshDataPointer(DWORD dwMeshIndex);
|
||||
|
||||
std::vector<CGraphicImage*>* GetTextureVectorPointer(DWORD dwMeshIndex);
|
||||
std::vector<CGraphicImage*>& GetTextureVectorReference(DWORD dwMeshIndex);
|
||||
|
||||
// Exceptional function for tool
|
||||
BOOL GetMeshElementPointer(DWORD dwMeshIndex, TEffectMeshData ** ppMeshData);
|
||||
|
||||
protected:
|
||||
bool OnLoad(int iSize, const void * c_pvBuf);
|
||||
|
||||
void OnClear();
|
||||
bool OnIsEmpty() const;
|
||||
bool OnIsType(TType type);
|
||||
|
||||
BOOL __LoadData_Ver001(int iSize, const BYTE * c_pbBuf);
|
||||
BOOL __LoadData_Ver002(int iSize, const BYTE * c_pbBuf);
|
||||
|
||||
protected:
|
||||
int m_iGeomCount;
|
||||
int m_iFrameCount;
|
||||
std::vector<TEffectMeshData *> m_pEffectMeshDataVector;
|
||||
|
||||
bool m_isData;
|
||||
};
|
||||
|
||||
class CEffectMeshScript : public CEffectElementBase
|
||||
{
|
||||
public:
|
||||
typedef struct SMeshData
|
||||
{
|
||||
BYTE byBillboardType;
|
||||
|
||||
BOOL bBlendingEnable;
|
||||
BYTE byBlendingSrcType;
|
||||
BYTE byBlendingDestType;
|
||||
BOOL bTextureAlphaEnable;
|
||||
|
||||
BYTE byColorOperationType;
|
||||
D3DXCOLOR ColorFactor;
|
||||
|
||||
BOOL bTextureAnimationLoopEnable;
|
||||
float fTextureAnimationFrameDelay;
|
||||
|
||||
DWORD dwTextureAnimationStartFrame;
|
||||
|
||||
TTimeEventTableFloat TimeEventAlpha;
|
||||
|
||||
SMeshData()
|
||||
{
|
||||
TimeEventAlpha.clear();
|
||||
}
|
||||
} TMeshData;
|
||||
typedef std::vector<TMeshData> TMeshDataVector;
|
||||
|
||||
public:
|
||||
CEffectMeshScript();
|
||||
virtual ~CEffectMeshScript();
|
||||
|
||||
const char * GetMeshFileName();
|
||||
|
||||
void ReserveMeshData(DWORD dwMeshCount);
|
||||
bool CheckMeshIndex(DWORD dwMeshIndex);
|
||||
bool GetMeshDataPointer(DWORD dwMeshIndex, TMeshData ** ppMeshData);
|
||||
int GetMeshDataCount();
|
||||
|
||||
int GetBillboardType(DWORD dwMeshIndex);
|
||||
BOOL isBlendingEnable(DWORD dwMeshIndex);
|
||||
BYTE GetBlendingSrcType(DWORD dwMeshIndex);
|
||||
BYTE GetBlendingDestType(DWORD dwMeshIndex);
|
||||
BOOL isTextureAlphaEnable(DWORD dwMeshIndex);
|
||||
BOOL GetColorOperationType(DWORD dwMeshIndex, BYTE * pbyType);
|
||||
BOOL GetColorFactor(DWORD dwMeshIndex, D3DXCOLOR * pColor);
|
||||
BOOL GetTimeTableAlphaPointer(DWORD dwMeshIndex, TTimeEventTableFloat ** pTimeEventAlpha);
|
||||
|
||||
BOOL isMeshAnimationLoop();
|
||||
BOOL GetMeshAnimationLoopCount();
|
||||
float GetMeshAnimationFrameDelay();
|
||||
BOOL isTextureAnimationLoop(DWORD dwMeshIndex);
|
||||
float GetTextureAnimationFrameDelay(DWORD dwMeshIndex);
|
||||
DWORD GetTextureAnimationStartFrame(DWORD dwMeshIndex);
|
||||
|
||||
protected:
|
||||
void OnClear();
|
||||
bool OnIsData();
|
||||
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
protected:
|
||||
BOOL m_isMeshAnimationLoop;
|
||||
int m_iMeshAnimationLoopCount;
|
||||
float m_fMeshAnimationFrameDelay;
|
||||
TMeshDataVector m_MeshDataVector;
|
||||
|
||||
std::string m_strMeshFileName;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectMeshScript* New();
|
||||
static void Delete(CEffectMeshScript* pkData);
|
||||
|
||||
static CDynamicPool<CEffectMeshScript> ms_kPool;
|
||||
};
|
271
src/EffectLib/EffectMeshInstance.cpp
Normal file
271
src/EffectLib/EffectMeshInstance.cpp
Normal file
@ -0,0 +1,271 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
#include "../eterLib/ResourceManager.h"
|
||||
#include "EffectMeshInstance.h"
|
||||
#include "../eterlib/GrpMath.h"
|
||||
|
||||
CDynamicPool<CEffectMeshInstance> CEffectMeshInstance::ms_kPool;
|
||||
|
||||
void CEffectMeshInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CEffectMeshInstance* CEffectMeshInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::Delete(CEffectMeshInstance* pkMeshInstance)
|
||||
{
|
||||
pkMeshInstance->Destroy();
|
||||
ms_kPool.Free(pkMeshInstance);
|
||||
}
|
||||
|
||||
BOOL CEffectMeshInstance::isActive()
|
||||
{
|
||||
if (!CEffectElementBaseInstance::isActive())
|
||||
return FALSE;
|
||||
|
||||
if (!m_MeshFrameController.isActive())
|
||||
return FALSE;
|
||||
|
||||
for (DWORD j = 0; j < m_TextureInstanceVector.size(); ++j)
|
||||
{
|
||||
int iCurrentFrame = m_MeshFrameController.GetCurrentFrame();
|
||||
if (m_TextureInstanceVector[j].TextureFrameController.isActive(iCurrentFrame))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool CEffectMeshInstance::OnUpdate(float fElapsedTime)
|
||||
{
|
||||
if (!isActive())
|
||||
return false;
|
||||
|
||||
if (m_MeshFrameController.isActive())
|
||||
m_MeshFrameController.Update(fElapsedTime);
|
||||
|
||||
for (DWORD j = 0; j < m_TextureInstanceVector.size(); ++j)
|
||||
{
|
||||
int iCurrentFrame = m_MeshFrameController.GetCurrentFrame();
|
||||
if (m_TextureInstanceVector[j].TextureFrameController.isActive(iCurrentFrame))
|
||||
m_TextureInstanceVector[j].TextureFrameController.Update(fElapsedTime);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnRender()
|
||||
{
|
||||
if (!isActive())
|
||||
return;
|
||||
|
||||
CEffectMesh * pEffectMesh = m_roMesh.GetPointer();
|
||||
|
||||
for (DWORD i = 0; i < pEffectMesh->GetMeshCount(); ++i)
|
||||
{
|
||||
assert(i < m_TextureInstanceVector.size());
|
||||
|
||||
CFrameController & rTextureFrameController = m_TextureInstanceVector[i].TextureFrameController;
|
||||
if (!rTextureFrameController.isActive(m_MeshFrameController.GetCurrentFrame()))
|
||||
continue;
|
||||
|
||||
int iBillboardType = m_pMeshScript->GetBillboardType(i);
|
||||
|
||||
D3DXMATRIX m_matWorld;
|
||||
D3DXMatrixIdentity(&m_matWorld);
|
||||
|
||||
switch(iBillboardType)
|
||||
{
|
||||
case MESH_BILLBOARD_TYPE_ALL:
|
||||
{
|
||||
D3DXMATRIX matTemp;
|
||||
D3DXMatrixRotationX(&matTemp, 90.0f);
|
||||
D3DXMatrixInverse(&m_matWorld, NULL, &CScreen::GetViewMatrix());
|
||||
|
||||
m_matWorld = matTemp * m_matWorld;
|
||||
}
|
||||
break;
|
||||
|
||||
case MESH_BILLBOARD_TYPE_Y:
|
||||
{
|
||||
D3DXMATRIX matTemp;
|
||||
D3DXMatrixIdentity(&matTemp);
|
||||
|
||||
D3DXMatrixInverse(&matTemp, NULL, &CScreen::GetViewMatrix());
|
||||
m_matWorld._11 = matTemp._11;
|
||||
m_matWorld._12 = matTemp._12;
|
||||
m_matWorld._21 = matTemp._21;
|
||||
m_matWorld._22 = matTemp._22;
|
||||
}
|
||||
break;
|
||||
|
||||
case MESH_BILLBOARD_TYPE_MOVE:
|
||||
{
|
||||
D3DXVECTOR3 Position;
|
||||
m_pMeshScript->GetPosition(m_fLocalTime, Position);
|
||||
D3DXVECTOR3 LastPosition;
|
||||
m_pMeshScript->GetPosition(m_fLocalTime-CTimer::Instance().GetElapsedSecond(), LastPosition);
|
||||
Position -= LastPosition;
|
||||
if (D3DXVec3LengthSq(&Position)>0.001f)
|
||||
{
|
||||
D3DXVec3Normalize(&Position,&Position);
|
||||
D3DXQUATERNION q = SafeRotationNormalizedArc(D3DXVECTOR3(0.0f,-1.0f,0.0f),Position);
|
||||
D3DXMatrixRotationQuaternion(&m_matWorld,&q);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!m_pMeshScript->isBlendingEnable(i))
|
||||
{
|
||||
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
int iBlendingSrcType = m_pMeshScript->GetBlendingSrcType(i);
|
||||
int iBlendingDestType = m_pMeshScript->GetBlendingDestType(i);
|
||||
STATEMANAGER.SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, iBlendingSrcType);
|
||||
STATEMANAGER.SetRenderState(D3DRS_DESTBLEND, iBlendingDestType);
|
||||
}
|
||||
|
||||
D3DXVECTOR3 Position;
|
||||
m_pMeshScript->GetPosition(m_fLocalTime, Position);
|
||||
m_matWorld._41 = Position.x;
|
||||
m_matWorld._42 = Position.y;
|
||||
m_matWorld._43 = Position.z;
|
||||
m_matWorld = m_matWorld * *mc_pmatLocal;
|
||||
STATEMANAGER.SetTransform(D3DTS_WORLD, &m_matWorld);
|
||||
|
||||
BYTE byType;
|
||||
D3DXCOLOR Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
if (m_pMeshScript->GetColorOperationType(i, &byType))
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, byType);
|
||||
m_pMeshScript->GetColorFactor(i, &Color);
|
||||
|
||||
TTimeEventTableFloat * TableAlpha;
|
||||
|
||||
float fAlpha = 1.0f;
|
||||
if (m_pMeshScript->GetTimeTableAlphaPointer(i, &TableAlpha) && !TableAlpha->empty())
|
||||
GetTimeEventBlendValue(m_fLocalTime,*TableAlpha, &fAlpha);
|
||||
|
||||
// Render //
|
||||
CEffectMesh::TEffectMeshData * pMeshData = pEffectMesh->GetMeshDataPointer(i);
|
||||
|
||||
assert(m_MeshFrameController.GetCurrentFrame() < pMeshData->EffectFrameDataVector.size());
|
||||
CEffectMesh::TEffectFrameData & rFrameData = pMeshData->EffectFrameDataVector[m_MeshFrameController.GetCurrentFrame()];
|
||||
|
||||
DWORD dwcurTextureFrame = rTextureFrameController.GetCurrentFrame();
|
||||
if (dwcurTextureFrame < m_TextureInstanceVector[i].TextureInstanceVector.size())
|
||||
{
|
||||
CGraphicImageInstance * pImageInstance = m_TextureInstanceVector[i].TextureInstanceVector[dwcurTextureFrame];
|
||||
STATEMANAGER.SetTexture(0, pImageInstance->GetTexturePointer()->GetD3DTexture());
|
||||
}
|
||||
|
||||
Color.a = fAlpha * rFrameData.fVisibility;
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, DWORD(Color));
|
||||
STATEMANAGER.SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1);
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLELIST,
|
||||
rFrameData.dwIndexCount/3,
|
||||
&rFrameData.PDTVertexVector[0],
|
||||
sizeof(TPTVertex));
|
||||
// Render //
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
CEffectMeshScript * pMesh = (CEffectMeshScript *)pElement;
|
||||
m_pMeshScript = pMesh;
|
||||
|
||||
const char * c_szMeshFileName = pMesh->GetMeshFileName();
|
||||
|
||||
m_pEffectMesh = (CEffectMesh *) CResourceManager::Instance().GetResourcePointer(c_szMeshFileName);
|
||||
|
||||
if (!m_pEffectMesh)
|
||||
return;
|
||||
|
||||
m_roMesh.SetPointer(m_pEffectMesh);
|
||||
|
||||
m_MeshFrameController.Clear();
|
||||
m_MeshFrameController.SetMaxFrame(m_roMesh.GetPointer()->GetFrameCount());
|
||||
m_MeshFrameController.SetFrameTime(pMesh->GetMeshAnimationFrameDelay());
|
||||
m_MeshFrameController.SetLoopFlag(pMesh->isMeshAnimationLoop());
|
||||
m_MeshFrameController.SetLoopCount(pMesh->GetMeshAnimationLoopCount());
|
||||
m_MeshFrameController.SetStartFrame(0);
|
||||
|
||||
m_TextureInstanceVector.clear();
|
||||
m_TextureInstanceVector.resize(m_pEffectMesh->GetMeshCount());
|
||||
for (DWORD j = 0; j < m_TextureInstanceVector.size(); ++j)
|
||||
{
|
||||
CEffectMeshScript::TMeshData * pMeshData;
|
||||
if (!m_pMeshScript->GetMeshDataPointer(j, &pMeshData))
|
||||
continue;
|
||||
|
||||
CEffectMesh* pkEftMesh=m_roMesh.GetPointer();
|
||||
|
||||
if (!pkEftMesh)
|
||||
continue;
|
||||
|
||||
std::vector<CGraphicImage*>* pTextureVector = pkEftMesh->GetTextureVectorPointer(j);
|
||||
if (!pTextureVector)
|
||||
continue;
|
||||
|
||||
std::vector<CGraphicImage*>& rTextureVector = *pTextureVector;
|
||||
|
||||
CFrameController & rFrameController = m_TextureInstanceVector[j].TextureFrameController;
|
||||
rFrameController.Clear();
|
||||
rFrameController.SetMaxFrame(rTextureVector.size());
|
||||
rFrameController.SetFrameTime(pMeshData->fTextureAnimationFrameDelay);
|
||||
rFrameController.SetLoopFlag(pMeshData->bTextureAnimationLoopEnable);
|
||||
rFrameController.SetStartFrame(pMeshData->dwTextureAnimationStartFrame);
|
||||
|
||||
std::vector<CGraphicImageInstance*> & rImageInstanceVector = m_TextureInstanceVector[j].TextureInstanceVector;
|
||||
rImageInstanceVector.clear();
|
||||
rImageInstanceVector.reserve(rTextureVector.size());
|
||||
for (std::vector<CGraphicImage*>::iterator itor = rTextureVector.begin(); itor != rTextureVector.end(); ++itor)
|
||||
{
|
||||
CGraphicImage * pImage = *itor;
|
||||
CGraphicImageInstance * pImageInstance = CGraphicImageInstance::ms_kPool.Alloc();
|
||||
pImageInstance->SetImagePointer(pImage);
|
||||
rImageInstanceVector.push_back(pImageInstance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEffectMeshInstance_DeleteImageInstance(CGraphicImageInstance * pkInstance)
|
||||
{
|
||||
CGraphicImageInstance::ms_kPool.Free(pkInstance);
|
||||
}
|
||||
|
||||
void CEffectMeshInstance_DeleteTextureInstance(CEffectMeshInstance::TTextureInstance & rkInstance)
|
||||
{
|
||||
std::vector<CGraphicImageInstance*> & rVector = rkInstance.TextureInstanceVector;
|
||||
for_each(rVector.begin(), rVector.end(), CEffectMeshInstance_DeleteImageInstance);
|
||||
rVector.clear();
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnInitialize()
|
||||
{
|
||||
}
|
||||
|
||||
void CEffectMeshInstance::OnDestroy()
|
||||
{
|
||||
for_each(m_TextureInstanceVector.begin(), m_TextureInstanceVector.end(), CEffectMeshInstance_DeleteTextureInstance);
|
||||
m_TextureInstanceVector.clear();
|
||||
m_roMesh.SetPointer(NULL);
|
||||
}
|
||||
|
||||
CEffectMeshInstance::CEffectMeshInstance()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CEffectMeshInstance::~CEffectMeshInstance()
|
||||
{
|
||||
Destroy();
|
||||
}
|
50
src/EffectLib/EffectMeshInstance.h
Normal file
50
src/EffectLib/EffectMeshInstance.h
Normal file
@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "FrameController.h"
|
||||
#include "EffectMesh.h"
|
||||
|
||||
class CEffectMeshInstance : public CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
// NOTE : Mesh <20><><EFBFBD><EFBFBD> <20>ؽ<EFBFBD><D8BD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD><CFBD>̴<EFBFBD>.
|
||||
typedef struct STextureInstance
|
||||
{
|
||||
CFrameController TextureFrameController;
|
||||
std::vector<CGraphicImageInstance*> TextureInstanceVector;
|
||||
} TTextureInstance;
|
||||
|
||||
public:
|
||||
CEffectMeshInstance();
|
||||
virtual ~CEffectMeshInstance();
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CEffectMeshInstance* New();
|
||||
static void Delete(CEffectMeshInstance* pkMeshInstance);
|
||||
|
||||
static CDynamicPool<CEffectMeshInstance> ms_kPool;
|
||||
|
||||
protected:
|
||||
void OnSetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void OnInitialize();
|
||||
void OnDestroy();
|
||||
|
||||
bool OnUpdate(float fElapsedTime);
|
||||
void OnRender();
|
||||
|
||||
BOOL isActive();
|
||||
|
||||
protected:
|
||||
CEffectMeshScript * m_pMeshScript;
|
||||
CEffectMesh * m_pEffectMesh;
|
||||
|
||||
CFrameController m_MeshFrameController;
|
||||
std::vector<TTextureInstance> m_TextureInstanceVector;
|
||||
|
||||
CEffectMesh::TRef m_roMesh;
|
||||
};
|
39
src/EffectLib/EffectUpdateDecorator.cpp
Normal file
39
src/EffectLib/EffectUpdateDecorator.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
#include "stdafx.h"
|
||||
#include "EffectUpdateDecorator.h"
|
||||
#include "ParticleInstance.h"
|
||||
namespace NEffectUpdateDecorator
|
||||
{
|
||||
|
||||
CBaseDecorator* CAirResistanceDecorator::__Clone(CParticleInstance* pfi, CParticleInstance* pi)
|
||||
{
|
||||
pi->m_fAirResistance = pfi->m_fAirResistance;
|
||||
return new CAirResistanceDecorator;
|
||||
}
|
||||
|
||||
void CAirResistanceDecorator::__Excute(const CDecoratorData & d)
|
||||
{
|
||||
d.pInstance->m_v3Velocity *= 1.0f-d.pInstance->m_fAirResistance;
|
||||
}
|
||||
CBaseDecorator* CGravityDecorator::__Clone(CParticleInstance* pfi, CParticleInstance* pi)
|
||||
{
|
||||
pi->m_fGravity = pfi->m_fGravity;
|
||||
return new CGravityDecorator;
|
||||
}
|
||||
|
||||
void CGravityDecorator::__Excute(const CDecoratorData& d)
|
||||
{
|
||||
d.pInstance->m_v3Velocity.z -= d.pInstance->m_fGravity * d.fElapsedTime;
|
||||
}
|
||||
|
||||
CBaseDecorator* CRotationDecorator::__Clone(CParticleInstance* pfi, CParticleInstance* pi)
|
||||
{
|
||||
pi->m_fRotationSpeed = pfi->m_fRotationSpeed;
|
||||
return new CRotationDecorator;
|
||||
}
|
||||
|
||||
void CRotationDecorator::__Excute(const CDecoratorData& d)
|
||||
{
|
||||
d.pInstance->m_fRotation += d.pInstance->m_fRotationSpeed * d.fElapsedTime;
|
||||
}
|
||||
|
||||
}
|
282
src/EffectLib/EffectUpdateDecorator.h
Normal file
282
src/EffectLib/EffectUpdateDecorator.h
Normal file
@ -0,0 +1,282 @@
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
#include "../eterbase/Random.h"
|
||||
#include "../eterlib/Pool.h"
|
||||
class CParticleInstance;
|
||||
|
||||
namespace NEffectUpdateDecorator
|
||||
{
|
||||
class CDecoratorData
|
||||
{
|
||||
public:
|
||||
float fTime;
|
||||
float fElapsedTime;
|
||||
CParticleInstance * pInstance;
|
||||
CDecoratorData(float fTime, float fElapsedTime, CParticleInstance * pInstance)
|
||||
: fTime(fTime), fElapsedTime(fElapsedTime), pInstance(pInstance)
|
||||
{}
|
||||
};
|
||||
class CBaseDecorator
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
public:
|
||||
CBaseDecorator() :m_NextDecorator(0), m_PrevDecorator(0) {}
|
||||
virtual ~CBaseDecorator(){}
|
||||
|
||||
void Excute(const CDecoratorData & d)
|
||||
{
|
||||
CBaseDecorator* pd = this;
|
||||
while(pd)
|
||||
{
|
||||
CBaseDecorator* pNextDecorator = pd->m_NextDecorator;
|
||||
pd->__Excute(d);
|
||||
pd = pNextDecorator;
|
||||
}
|
||||
}
|
||||
CBaseDecorator * AddChainFront(CBaseDecorator * pd)
|
||||
{
|
||||
pd->m_NextDecorator = this;
|
||||
m_PrevDecorator = pd;
|
||||
return pd;
|
||||
}
|
||||
void DeleteThis()
|
||||
{
|
||||
//return;
|
||||
if (m_NextDecorator)
|
||||
m_NextDecorator->DeleteThis();
|
||||
delete this;
|
||||
}
|
||||
CBaseDecorator * Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance)
|
||||
{
|
||||
CBaseDecorator * pNewDecorator = __Clone(pFirstInstance, pInstance);
|
||||
CBaseDecorator * pSrc = this;
|
||||
CBaseDecorator * pDest = pNewDecorator;
|
||||
while (pSrc->m_NextDecorator)
|
||||
{
|
||||
pDest->m_NextDecorator = pSrc->m_NextDecorator->__Clone(pFirstInstance, pInstance);
|
||||
pDest->m_NextDecorator->m_PrevDecorator = pDest;
|
||||
|
||||
pSrc = pSrc->m_NextDecorator;
|
||||
pDest = pDest->m_NextDecorator;
|
||||
}
|
||||
return pNewDecorator;
|
||||
}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData & d) = 0;
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance) = 0;
|
||||
void RemoveMe()
|
||||
{
|
||||
m_PrevDecorator->m_NextDecorator = m_NextDecorator;
|
||||
m_NextDecorator->m_PrevDecorator=m_PrevDecorator;
|
||||
delete this;
|
||||
}
|
||||
CBaseDecorator * m_NextDecorator;
|
||||
CBaseDecorator * m_PrevDecorator;
|
||||
};
|
||||
|
||||
class CHeaderDecorator : public CBaseDecorator, public CPooledObject<CHeaderDecorator>
|
||||
{
|
||||
public:
|
||||
CHeaderDecorator() {}
|
||||
virtual ~CHeaderDecorator() {}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData&) {}
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance*, CParticleInstance*) { return new CHeaderDecorator; }
|
||||
};
|
||||
|
||||
class CNullDecorator : public CBaseDecorator, public CPooledObject<CNullDecorator>
|
||||
{
|
||||
public:
|
||||
CNullDecorator(){}
|
||||
virtual ~CNullDecorator(){}
|
||||
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData & d) {}
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance*, CParticleInstance* ) { return new CNullDecorator; }
|
||||
};
|
||||
|
||||
template <class T> class CTimeEventDecorator : public CBaseDecorator, public CPooledObject<CTimeEventDecorator<T> >
|
||||
{
|
||||
public:
|
||||
typedef CTimeEvent<T> TTimeEventType;
|
||||
typedef std::vector<TTimeEventType> TTimeEventContainerType;
|
||||
CTimeEventDecorator(const TTimeEventContainerType& TimeEventContainer, T * pValue = 0)
|
||||
: it_start(TimeEventContainer.begin()),
|
||||
it_cur(TimeEventContainer.begin()),
|
||||
it_next(TimeEventContainer.begin()),
|
||||
it_end(TimeEventContainer.end()),
|
||||
pData(pValue)
|
||||
{
|
||||
if (it_start == it_end)
|
||||
*pValue = T();
|
||||
else
|
||||
++it_next;
|
||||
}
|
||||
virtual ~CTimeEventDecorator() {}
|
||||
|
||||
void SetData( T * pValue ) { pData = pValue; }
|
||||
|
||||
protected:
|
||||
//CTimeEventDecorator(CTimeEventDecorator<T>& ted, CParticleInstance * pFirstInstance, CParticleInstance * pInstance);
|
||||
CTimeEventDecorator(CTimeEventDecorator<T>& ted, CParticleInstance* pFirstInstance, CParticleInstance* pInstance)
|
||||
: it_start(ted.it_start),
|
||||
it_end(ted.it_end),
|
||||
it_cur(ted.it_cur),
|
||||
it_next(ted.it_next),
|
||||
pData((T*)( (unsigned char*)ted.pData - (DWORD)pFirstInstance + (DWORD)pInstance))
|
||||
{
|
||||
if (it_start == it_end)
|
||||
*pData = T();
|
||||
}
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pFirstInstance, CParticleInstance* pInstance) { return new CTimeEventDecorator(*this, pFirstInstance, pInstance); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
if (it_start==it_end)
|
||||
{
|
||||
RemoveMe();
|
||||
}
|
||||
else if (it_cur->m_fTime>d.fTime)
|
||||
{
|
||||
*pData = it_cur->m_Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (it_next!=it_end && it_next->m_fTime<=d.fTime)
|
||||
++it_cur, ++it_next;
|
||||
if (it_next == it_end)
|
||||
{
|
||||
// setting value
|
||||
*pData = it_cur->m_Value;
|
||||
|
||||
RemoveMe();
|
||||
}
|
||||
else
|
||||
{
|
||||
float length = it_next->m_fTime - it_cur->m_fTime;
|
||||
//*pData = it_cur->m_Value + (it_next->m_Value - it_cur->m_Value)*(d.fTime-it_cur->m_fTime)/length;
|
||||
*pData = it_cur->m_Value*(1-(d.fTime-it_cur->m_fTime)/length) ;
|
||||
*pData += it_next->m_Value * ((d.fTime-it_cur->m_fTime)/length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typename TTimeEventContainerType::const_iterator it_start;
|
||||
typename TTimeEventContainerType::const_iterator it_end;
|
||||
typename TTimeEventContainerType::const_iterator it_cur;
|
||||
typename TTimeEventContainerType::const_iterator it_next;
|
||||
T * pData;
|
||||
};
|
||||
|
||||
typedef CTimeEventDecorator<float> CScaleValueDecorator;
|
||||
typedef CTimeEventDecorator<float> CColorValueDecorator;
|
||||
typedef CTimeEventDecorator<DWORDCOLOR> CColorAllDecorator;
|
||||
typedef CTimeEventDecorator<float> CAirResistanceValueDecorator;
|
||||
typedef CTimeEventDecorator<float> CGravityValueDecorator;
|
||||
typedef CTimeEventDecorator<float> CRotationSpeedValueDecorator;
|
||||
|
||||
class CTextureAnimationCWDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationCWDecorator>
|
||||
{
|
||||
public:
|
||||
CTextureAnimationCWDecorator(float fFrameTime, DWORD n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
|
||||
virtual ~CTextureAnimationCWDecorator(){}
|
||||
protected:
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationCWDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
fLastFrameTime -= d.fElapsedTime;
|
||||
while (fLastFrameTime<0.0f)
|
||||
{
|
||||
fLastFrameTime += fFrameTime;
|
||||
if (++(*pIdx) >= n)
|
||||
*pIdx = 0;
|
||||
}
|
||||
}
|
||||
DWORD n;
|
||||
float fLastFrameTime;
|
||||
float fFrameTime;
|
||||
BYTE* pIdx;
|
||||
|
||||
};
|
||||
class CTextureAnimationCCWDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationCCWDecorator>
|
||||
{
|
||||
public:
|
||||
CTextureAnimationCCWDecorator(float fFrameTime, BYTE n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
|
||||
virtual ~CTextureAnimationCCWDecorator(){}
|
||||
protected:
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationCCWDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
fLastFrameTime -= d.fElapsedTime;
|
||||
while (fLastFrameTime<0.0f)
|
||||
{
|
||||
fLastFrameTime += fFrameTime;
|
||||
|
||||
if (--(*pIdx) >= n && n != 0) // Because variable is unsigned..
|
||||
*pIdx = BYTE(n - 1);
|
||||
}
|
||||
}
|
||||
BYTE n;
|
||||
float fLastFrameTime;
|
||||
float fFrameTime;
|
||||
BYTE* pIdx;
|
||||
|
||||
};
|
||||
class CTextureAnimationRandomDecorator : public CBaseDecorator, public CPooledObject<CTextureAnimationRandomDecorator>
|
||||
{
|
||||
public:
|
||||
CTextureAnimationRandomDecorator(float fFrameTime, BYTE n, BYTE * pIdx) :n(n),pIdx(pIdx),fFrameTime(fFrameTime),fLastFrameTime(fFrameTime){}
|
||||
virtual ~CTextureAnimationRandomDecorator(){}
|
||||
protected:
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) { return new CTextureAnimationRandomDecorator(fFrameTime,n,(BYTE*)((unsigned char*)pi+((BYTE*)pIdx-(BYTE*)pfi))); }
|
||||
virtual void __Excute(const CDecoratorData & d)
|
||||
{
|
||||
fLastFrameTime -= d.fElapsedTime;
|
||||
if (fLastFrameTime<0.0f && n!=0)
|
||||
{
|
||||
*pIdx = (BYTE)random_range(0,n-1);
|
||||
}
|
||||
while (fLastFrameTime<0.0f)
|
||||
fLastFrameTime += fFrameTime;
|
||||
}
|
||||
BYTE n;
|
||||
float fLastFrameTime;
|
||||
float fFrameTime;
|
||||
BYTE* pIdx;
|
||||
|
||||
};
|
||||
|
||||
class CAirResistanceDecorator : public CBaseDecorator, public CPooledObject<CAirResistanceDecorator>
|
||||
{
|
||||
public:
|
||||
CAirResistanceDecorator(){}
|
||||
virtual ~CAirResistanceDecorator(){}
|
||||
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData & d);
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi);
|
||||
};
|
||||
|
||||
class CGravityDecorator : public CBaseDecorator, public CPooledObject<CGravityDecorator>
|
||||
{
|
||||
public:
|
||||
CGravityDecorator(){}
|
||||
virtual ~CGravityDecorator(){}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData& d);
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi);
|
||||
};
|
||||
|
||||
class CRotationDecorator : public CBaseDecorator, public CPooledObject<CRotationDecorator>
|
||||
{
|
||||
public:
|
||||
CRotationDecorator(){}
|
||||
virtual ~CRotationDecorator()
|
||||
{
|
||||
}
|
||||
protected:
|
||||
virtual void __Excute(const CDecoratorData& d);
|
||||
virtual CBaseDecorator* __Clone(CParticleInstance* pfi, CParticleInstance* pi) ;
|
||||
};
|
||||
|
||||
}
|
102
src/EffectLib/EmitterProperty.cpp
Normal file
102
src/EffectLib/EmitterProperty.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EmitterProperty.h"
|
||||
|
||||
BYTE CEmitterProperty::GetEmitterShape()
|
||||
{
|
||||
return m_byEmitterShape;
|
||||
}
|
||||
BYTE CEmitterProperty::GetEmitterAdvancedType()
|
||||
{
|
||||
return m_byEmitterAdvancedType;
|
||||
}
|
||||
BOOL CEmitterProperty::isEmitFromEdge()
|
||||
{
|
||||
return m_bEmitFromEdgeFlag;
|
||||
}
|
||||
|
||||
void CEmitterProperty::GetEmittingSize(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingSize, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingSize, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingAngularVelocity(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingAngularVelocity, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingAngularVelocity, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingDirectionX(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingDirectionX, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingDirectionX, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingDirectionY(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingDirectionY, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingDirectionY, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingDirectionZ(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingDirectionZ, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingDirectionZ, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmittingVelocity(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmittingVelocity, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmittingVelocity, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetEmissionCountPerSecond(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventEmissionCountPerSecond, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventEmissionCountPerSecond, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetParticleLifeTime(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventLifeTime, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventLifeTime, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetParticleSizeX(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventSizeX, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventSizeX, pfValue);
|
||||
}
|
||||
void CEmitterProperty::GetParticleSizeY(float fTime, float * pfValue)
|
||||
{
|
||||
//GetTimeEventBlendValue<TTimeEventTableFloat, float>(fTime, m_TimeEventSizeY, pfValue);
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventSizeY, pfValue);
|
||||
}
|
||||
|
||||
void CEmitterProperty::Clear()
|
||||
{
|
||||
m_dwMaxEmissionCount = 0;
|
||||
|
||||
m_fCycleLength = 0.0f;
|
||||
m_bCycleLoopFlag = FALSE;
|
||||
m_iLoopCount = 0;
|
||||
|
||||
m_byEmitterShape = EMITTER_SHAPE_POINT;
|
||||
m_byEmitterAdvancedType = EMITTER_ADVANCED_TYPE_FREE;
|
||||
m_bEmitFromEdgeFlag = FALSE;
|
||||
m_v3EmittingSize = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
m_fEmittingRadius = 0.0f;
|
||||
|
||||
m_v3EmittingDirection = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
m_TimeEventEmittingSize.clear();
|
||||
m_TimeEventEmittingDirectionX.clear();
|
||||
m_TimeEventEmittingDirectionY.clear();
|
||||
m_TimeEventEmittingDirectionZ.clear();
|
||||
m_TimeEventEmittingVelocity.clear();
|
||||
m_TimeEventEmissionCountPerSecond.clear();
|
||||
m_TimeEventLifeTime.clear();
|
||||
m_TimeEventSizeX.clear();
|
||||
m_TimeEventSizeY.clear();
|
||||
m_TimeEventEmittingAngularVelocity.clear();
|
||||
}
|
||||
|
||||
CEmitterProperty::CEmitterProperty()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
CEmitterProperty::~CEmitterProperty()
|
||||
{
|
||||
}
|
95
src/EffectLib/EmitterProperty.h
Normal file
95
src/EffectLib/EmitterProperty.h
Normal file
@ -0,0 +1,95 @@
|
||||
#pragma once
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
class CEmitterProperty
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
friend class CParticleSystemInstance;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
EMITTER_SHAPE_POINT,
|
||||
EMITTER_SHAPE_ELLIPSE,
|
||||
EMITTER_SHAPE_SQUARE,
|
||||
EMITTER_SHAPE_SPHERE,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
EMITTER_ADVANCED_TYPE_FREE,
|
||||
EMITTER_ADVANCED_TYPE_OUTER,
|
||||
EMITTER_ADVANCED_TYPE_INNER,
|
||||
};
|
||||
|
||||
public:
|
||||
CEmitterProperty();
|
||||
virtual ~CEmitterProperty();
|
||||
|
||||
void Clear();
|
||||
|
||||
DWORD GetMaxEmissionCount()
|
||||
{
|
||||
return m_dwMaxEmissionCount;
|
||||
}
|
||||
|
||||
float GetCycleLength()
|
||||
{
|
||||
return m_fCycleLength;
|
||||
}
|
||||
|
||||
BOOL isCycleLoop()
|
||||
{
|
||||
return m_bCycleLoopFlag;
|
||||
}
|
||||
|
||||
int GetLoopCount()
|
||||
{
|
||||
return m_iLoopCount;
|
||||
}
|
||||
|
||||
|
||||
BYTE GetEmitterShape();
|
||||
BYTE GetEmitterAdvancedType();
|
||||
BOOL isEmitFromEdge();
|
||||
|
||||
void GetEmittingSize(float fTime, float * pfValue);
|
||||
void GetEmittingAngularVelocity(float fTime, float * pfValue);
|
||||
|
||||
void GetEmittingDirectionX(float fTime, float * pfValue);
|
||||
void GetEmittingDirectionY(float fTime, float * pfValue);
|
||||
void GetEmittingDirectionZ(float fTime, float * pfValue);
|
||||
void GetEmittingVelocity(float fTime, float * pfValue);
|
||||
void GetEmissionCountPerSecond(float fTime, float * pfValue);
|
||||
void GetParticleLifeTime(float fTime, float * pfValue);
|
||||
void GetParticleSizeX(float fTime, float * pfValue);
|
||||
void GetParticleSizeY(float fTime, float * pfValue);
|
||||
|
||||
/////
|
||||
|
||||
DWORD m_dwMaxEmissionCount;
|
||||
|
||||
float m_fCycleLength;
|
||||
BOOL m_bCycleLoopFlag;
|
||||
int m_iLoopCount;
|
||||
|
||||
BYTE m_byEmitterShape;
|
||||
BYTE m_byEmitterAdvancedType;
|
||||
BOOL m_bEmitFromEdgeFlag;
|
||||
D3DXVECTOR3 m_v3EmittingSize;
|
||||
float m_fEmittingRadius;
|
||||
|
||||
D3DXVECTOR3 m_v3EmittingDirection;
|
||||
|
||||
//TTimeEventTableFloat m_TimeEventEmittingRadius;
|
||||
TTimeEventTableFloat m_TimeEventEmittingSize;
|
||||
TTimeEventTableFloat m_TimeEventEmittingAngularVelocity;
|
||||
TTimeEventTableFloat m_TimeEventEmittingDirectionX;
|
||||
TTimeEventTableFloat m_TimeEventEmittingDirectionY;
|
||||
TTimeEventTableFloat m_TimeEventEmittingDirectionZ;
|
||||
TTimeEventTableFloat m_TimeEventEmittingVelocity;
|
||||
TTimeEventTableFloat m_TimeEventEmissionCountPerSecond;
|
||||
TTimeEventTableFloat m_TimeEventLifeTime;
|
||||
TTimeEventTableFloat m_TimeEventSizeX;
|
||||
TTimeEventTableFloat m_TimeEventSizeY;
|
||||
};
|
106
src/EffectLib/FrameController.cpp
Normal file
106
src/EffectLib/FrameController.cpp
Normal file
@ -0,0 +1,106 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FrameController.h"
|
||||
|
||||
void CFrameController::Update(float fElapsedTime)
|
||||
{
|
||||
m_fLastFrameTime -= fElapsedTime;
|
||||
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
if (m_fLastFrameTime < 0.0f)
|
||||
{
|
||||
m_fLastFrameTime += m_fFrameTime;
|
||||
++m_dwcurFrame;
|
||||
|
||||
if (m_dwcurFrame >= m_dwMaxFrame)
|
||||
{
|
||||
if (m_isLoop && --m_iLoopCount!=0)
|
||||
{
|
||||
if (m_iLoopCount<0)
|
||||
m_iLoopCount = 0;
|
||||
m_dwcurFrame = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iLoopCount = 1;
|
||||
m_dwcurFrame = 0;
|
||||
m_isActive = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CFrameController::SetCurrentFrame(DWORD dwFrame)
|
||||
{
|
||||
m_dwcurFrame = dwFrame;
|
||||
}
|
||||
|
||||
BYTE CFrameController::GetCurrentFrame()
|
||||
{
|
||||
return m_dwcurFrame;
|
||||
}
|
||||
|
||||
void CFrameController::SetMaxFrame(DWORD dwMaxFrame)
|
||||
{
|
||||
m_dwMaxFrame = dwMaxFrame;
|
||||
}
|
||||
void CFrameController::SetFrameTime(float fTime)
|
||||
{
|
||||
m_fFrameTime = fTime;
|
||||
m_fLastFrameTime = fTime;
|
||||
}
|
||||
void CFrameController::SetStartFrame(DWORD dwStartFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
}
|
||||
|
||||
void CFrameController::SetLoopFlag(BOOL bFlag)
|
||||
{
|
||||
m_isLoop = bFlag;
|
||||
}
|
||||
|
||||
void CFrameController::SetLoopCount(int iLoopCount)
|
||||
{
|
||||
m_iLoopCount = iLoopCount;
|
||||
}
|
||||
|
||||
void CFrameController::SetActive(BOOL bFlag)
|
||||
{
|
||||
m_isActive = bFlag;
|
||||
}
|
||||
|
||||
BOOL CFrameController::isActive(DWORD dwMainFrame)
|
||||
{
|
||||
if (dwMainFrame < m_dwStartFrame)
|
||||
return FALSE;
|
||||
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
void CFrameController::Clear()
|
||||
{
|
||||
m_isActive = TRUE;
|
||||
m_dwcurFrame = 0;
|
||||
m_fLastFrameTime = 0.0f;
|
||||
}
|
||||
|
||||
CFrameController::CFrameController()
|
||||
{
|
||||
m_isActive = TRUE;
|
||||
m_dwcurFrame = 0;
|
||||
m_fLastFrameTime = 0.0f;
|
||||
|
||||
m_isLoop = FALSE;
|
||||
m_dwMaxFrame = 0;
|
||||
m_fFrameTime = 0.0f;
|
||||
m_dwStartFrame = 0;
|
||||
}
|
||||
CFrameController::~CFrameController()
|
||||
{
|
||||
}
|
38
src/EffectLib/FrameController.h
Normal file
38
src/EffectLib/FrameController.h
Normal file
@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
class CFrameController
|
||||
{
|
||||
public:
|
||||
CFrameController();
|
||||
virtual ~CFrameController();
|
||||
|
||||
void Clear();
|
||||
|
||||
void Update(float fElapsedTime);
|
||||
|
||||
void SetCurrentFrame(DWORD dwFrame);
|
||||
BYTE GetCurrentFrame();
|
||||
|
||||
void SetMaxFrame(DWORD dwMaxFrame);
|
||||
void SetFrameTime(float fTime);
|
||||
void SetStartFrame(DWORD dwStartFrame);
|
||||
void SetLoopFlag(BOOL bFlag);
|
||||
void SetLoopCount(int iLoopCount);
|
||||
|
||||
void SetActive(BOOL bFlag);
|
||||
BOOL isActive(DWORD dwMainFrame = 0);
|
||||
|
||||
protected:
|
||||
// Dynamic
|
||||
BOOL m_isActive;
|
||||
DWORD m_dwcurFrame;
|
||||
float m_fLastFrameTime;
|
||||
|
||||
int m_iLoopCount;
|
||||
|
||||
// Static
|
||||
BOOL m_isLoop;
|
||||
DWORD m_dwMaxFrame;
|
||||
float m_fFrameTime;
|
||||
DWORD m_dwStartFrame;
|
||||
};
|
513
src/EffectLib/ParticleInstance.cpp
Normal file
513
src/EffectLib/ParticleInstance.cpp
Normal file
@ -0,0 +1,513 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ParticleInstance.h"
|
||||
#include "ParticleProperty.h"
|
||||
|
||||
#include "../eterBase/Random.h"
|
||||
#include "../eterLib/Camera.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
|
||||
CDynamicPool<CParticleInstance> CParticleInstance::ms_kPool;
|
||||
|
||||
using namespace NEffectUpdateDecorator;
|
||||
|
||||
void CParticleInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CParticleInstance* CParticleInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CParticleInstance::DeleteThis()
|
||||
{
|
||||
Destroy();
|
||||
|
||||
ms_kPool.Free(this);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//CDynamicPool<CRayParticleInstance> CRayParticleInstance::ms_kPool;
|
||||
|
||||
/*void CRayParticleInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CRayParticleInstance* CRayParticleInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CRayParticleInstance::DeleteThis()
|
||||
{
|
||||
#ifdef RAY_TO_AFTERIMAGE
|
||||
m_PositionList.clear();
|
||||
#else
|
||||
m_bStart = false;
|
||||
#endif
|
||||
ms_kPool.Free(this);
|
||||
}
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float CParticleInstance::GetRadiusApproximation()
|
||||
{
|
||||
return m_v2HalfSize.y*m_v2Scale.y + m_v2HalfSize.x*m_v2Scale.x;
|
||||
}
|
||||
/*
|
||||
D3DXVECTOR3 CBaseParticleInstance::GetCenterApproximation()
|
||||
{
|
||||
return D3DXVECTOR3(
|
||||
m_v3Position.x + mc_pmatLocal._41,
|
||||
m_v3Position.y + mc_pmatLocal._42,
|
||||
m_v3Position.z + mc_pmatLocal._43
|
||||
);
|
||||
}*/
|
||||
|
||||
|
||||
BOOL CParticleInstance::Update(float fElapsedTime, float fAngle)
|
||||
{
|
||||
m_fLastLifeTime -= fElapsedTime;
|
||||
if (m_fLastLifeTime < 0.0f)
|
||||
return FALSE;
|
||||
|
||||
float fLifePercentage = (m_fLifeTime - m_fLastLifeTime) / m_fLifeTime;
|
||||
|
||||
m_pDecorator->Excute(CDecoratorData(fLifePercentage,fElapsedTime,this));
|
||||
|
||||
m_v3LastPosition = m_v3Position;
|
||||
m_v3Position += m_v3Velocity * fElapsedTime;
|
||||
|
||||
if (fAngle)
|
||||
{
|
||||
if (m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
float fCos, fSin;
|
||||
fAngle = D3DXToRadian(fAngle);
|
||||
fCos = cos(fAngle);
|
||||
fSin = sin(fAngle);
|
||||
|
||||
float rx = m_v3Position.x - m_v3StartPosition.x;
|
||||
float ry = m_v3Position.y - m_v3StartPosition.y;
|
||||
|
||||
m_v3Position.x = fCos * rx + fSin * ry + m_v3StartPosition.x;
|
||||
m_v3Position.y = - fSin * rx + fCos * ry + m_v3StartPosition.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXQUATERNION q,qc;
|
||||
D3DXQuaternionRotationAxis(&q,&m_pParticleProperty->m_v3ZAxis,D3DXToRadian(fAngle));
|
||||
D3DXQuaternionConjugate(&qc,&q);
|
||||
|
||||
D3DXQUATERNION qr(
|
||||
m_v3Position.x-m_v3StartPosition.x,
|
||||
m_v3Position.y-m_v3StartPosition.y,
|
||||
m_v3Position.z-m_v3StartPosition.z,
|
||||
0.0f);
|
||||
D3DXQuaternionMultiply(&qr,&q,&qr);
|
||||
D3DXQuaternionMultiply(&qr,&qr,&qc);
|
||||
|
||||
m_v3Position.x = qr.x;
|
||||
m_v3Position.y = qr.y;
|
||||
m_v3Position.z = qr.z;
|
||||
|
||||
m_v3Position += m_v3StartPosition;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CParticleInstance::Transform(const D3DXMATRIX * c_matLocal)
|
||||
{
|
||||
#ifdef WORLD_EDITOR
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, m_Color);
|
||||
#else
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, m_dcColor);
|
||||
#endif
|
||||
|
||||
/////
|
||||
|
||||
D3DXVECTOR3 v3Up;
|
||||
D3DXVECTOR3 v3Cross;
|
||||
|
||||
if (!m_pParticleProperty->m_bStretchFlag)
|
||||
{
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3Up = pCurrentCamera->GetUp();
|
||||
const D3DXVECTOR3 & c_rv3Cross = pCurrentCamera->GetCross();
|
||||
|
||||
D3DXVECTOR3 v3Rotation;
|
||||
|
||||
switch(m_pParticleProperty->m_byBillboardType) {
|
||||
case BILLBOARD_TYPE_LIE:
|
||||
{
|
||||
float fCos = cosf(D3DXToRadian(m_fRotation)), fSin = sinf(D3DXToRadian(m_fRotation));
|
||||
v3Up.x = fCos;
|
||||
v3Up.y = -fSin;
|
||||
v3Up.z = 0;
|
||||
v3Cross.x = fSin;
|
||||
v3Cross.y = fCos;
|
||||
v3Cross.z = 0;
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_2FACE:
|
||||
case BILLBOARD_TYPE_3FACE:
|
||||
// using setting with y, and local rotation at render
|
||||
case BILLBOARD_TYPE_Y:
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
//v3Up = D3DXVECTOR3(cosf(D3DXToRadian(m_fRotation)),0.0f,-sinf(D3DXToRadian(m_fRotation)));
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
if (v3Up.x * c_rv3View.y - v3Up.y * c_rv3View.x<0)
|
||||
v3Up*=-1;
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &D3DXVECTOR3(c_rv3View.x,c_rv3View.y,0));
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
if (m_fRotation)
|
||||
{
|
||||
float fCos = -sinf(D3DXToRadian(m_fRotation)); // + 90
|
||||
float fSin = cosf(D3DXToRadian(m_fRotation));
|
||||
|
||||
D3DXVECTOR3 v3Temp = v3Up * fCos - v3Cross * fSin;
|
||||
v3Cross = v3Cross * fCos + v3Up * fSin;
|
||||
v3Up = v3Temp;
|
||||
}
|
||||
|
||||
//D3DXVECTOR3 v3Rotation;
|
||||
//D3DXVec3Cross(&v3Rotation, &v3Up, &v3Cross);
|
||||
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_ALL:
|
||||
default:
|
||||
{
|
||||
// NOTE : Rotation Routine. Camera<72><61> Up Vector<6F><72> Cross Vector <20><>ü<EFBFBD><C3BC> View Vector <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// Rotation <20><>Ų<EFBFBD><C5B2>.
|
||||
// FIXME : <20>ݵ<EFBFBD><DDB5><EFBFBD> <20><><EFBFBD><EFBFBD>ȭ <20><> <20><>!
|
||||
if (m_fRotation==0.0f)
|
||||
{
|
||||
v3Up = -c_rv3Cross;
|
||||
v3Cross = c_rv3Up;
|
||||
}
|
||||
else
|
||||
{
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXQUATERNION q,qc;
|
||||
D3DXQuaternionRotationAxis(&q, &c_rv3View, D3DXToRadian(m_fRotation));
|
||||
D3DXQuaternionConjugate(&qc, &q);
|
||||
|
||||
{
|
||||
D3DXQUATERNION qr(-c_rv3Cross.x, -c_rv3Cross.y, -c_rv3Cross.z, 0);
|
||||
D3DXQuaternionMultiply(&qr,&qc,&qr);
|
||||
D3DXQuaternionMultiply(&qr,&qr,&q);
|
||||
v3Up.x = qr.x;
|
||||
v3Up.y = qr.y;
|
||||
v3Up.z = qr.z;
|
||||
}
|
||||
{
|
||||
D3DXQUATERNION qr(c_rv3Up.x, c_rv3Up.y, c_rv3Up.z, 0);
|
||||
D3DXQuaternionMultiply(&qr,&qc,&qr);
|
||||
D3DXQuaternionMultiply(&qr,&qr,&q);
|
||||
v3Cross.x = qr.x;
|
||||
v3Cross.y = qr.y;
|
||||
v3Cross.z = qr.z;
|
||||
}
|
||||
|
||||
}
|
||||
//D3DXMATRIX matRotation;
|
||||
|
||||
//D3DXMatrixRotationAxis(&matRotation, &c_rv3View, D3DXToRadian(m_fRotation));
|
||||
|
||||
//D3DXVec3TransformCoord(&v3Up, &(-c_rv3Cross), &matRotation);
|
||||
//D3DXVec3TransformCoord(&v3Cross, &c_rv3Up, &matRotation);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
v3Up = m_v3Position - m_v3LastPosition;
|
||||
|
||||
if (c_matLocal)
|
||||
{
|
||||
//if (!m_pParticleProperty->m_bAttachFlag)
|
||||
D3DXVec3TransformNormal(&v3Up, &v3Up, c_matLocal);
|
||||
}
|
||||
|
||||
// NOTE: <20>ӵ<EFBFBD><D3B5><EFBFBD> <20><><EFBFBD>̿<EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> : log(velocity)<29><>ŭ <20>þ<C3BE><EEB3AD>.
|
||||
float length = D3DXVec3Length(&v3Up);
|
||||
if (length == 0.0f)
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
}
|
||||
else
|
||||
v3Up *=(1+log(1+length))/length;
|
||||
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &c_rv3View);
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
}
|
||||
|
||||
v3Cross = -(m_v2HalfSize.x*m_v2Scale.x) * v3Cross;
|
||||
v3Up = (m_v2HalfSize.y*m_v2Scale.y) * v3Up;
|
||||
|
||||
if (c_matLocal && m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
D3DXVec3TransformCoord(&v3Position, &m_v3Position, c_matLocal);
|
||||
m_ParticleMesh[0].position = v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = v3Position + v3Up - v3Cross;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ParticleMesh[0].position = m_v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = m_v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = m_v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = m_v3Position + v3Up - v3Cross;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CParticleInstance::Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation)
|
||||
{
|
||||
#ifdef WORLD_EDITOR
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, m_Color);
|
||||
#else
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, (DWORD)m_dcColor);
|
||||
#endif
|
||||
|
||||
/////
|
||||
|
||||
D3DXVECTOR3 v3Up;
|
||||
D3DXVECTOR3 v3Cross;
|
||||
|
||||
if (!m_pParticleProperty->m_bStretchFlag)
|
||||
{
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3Up = pCurrentCamera->GetUp();
|
||||
const D3DXVECTOR3 & c_rv3Cross = pCurrentCamera->GetCross();
|
||||
|
||||
D3DXVECTOR3 v3Rotation;
|
||||
|
||||
switch(m_pParticleProperty->m_byBillboardType) {
|
||||
case BILLBOARD_TYPE_LIE:
|
||||
{
|
||||
float fCos = cosf(D3DXToRadian(m_fRotation)), fSin = sinf(D3DXToRadian(m_fRotation));
|
||||
v3Up.x = fCos;
|
||||
v3Up.y = -fSin;
|
||||
v3Up.z = 0;
|
||||
|
||||
v3Cross.x = fSin;
|
||||
v3Cross.y = fCos;
|
||||
v3Cross.z = 0;
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_2FACE:
|
||||
case BILLBOARD_TYPE_3FACE:
|
||||
// using setting with y, and local rotation at render
|
||||
case BILLBOARD_TYPE_Y:
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
//v3Up = D3DXVECTOR3(cosf(D3DXToRadian(m_fRotation)),0.0f,-sinf(D3DXToRadian(m_fRotation)));
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
if (v3Up.x * c_rv3View.y - v3Up.y * c_rv3View.x<0)
|
||||
v3Up*=-1;
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &D3DXVECTOR3(c_rv3View.x,c_rv3View.y,0));
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
if (m_fRotation)
|
||||
{
|
||||
float fCos = -sinf(D3DXToRadian(m_fRotation)); // + 90
|
||||
float fSin = cosf(D3DXToRadian(m_fRotation));
|
||||
|
||||
D3DXVECTOR3 v3Temp = v3Up * fCos - v3Cross * fSin;
|
||||
v3Cross = v3Cross * fCos + v3Up * fSin;
|
||||
v3Up = v3Temp;
|
||||
}
|
||||
|
||||
//D3DXVECTOR3 v3Rotation;
|
||||
//D3DXVec3Cross(&v3Rotation, &v3Up, &v3Cross);
|
||||
|
||||
}
|
||||
break;
|
||||
case BILLBOARD_TYPE_ALL:
|
||||
default:
|
||||
{
|
||||
// NOTE : Rotation Routine. Camera<72><61> Up Vector<6F><72> Cross Vector <20><>ü<EFBFBD><C3BC> View Vector <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// Rotation <20><>Ų<EFBFBD><C5B2>.
|
||||
// FIXME : <20>ݵ<EFBFBD><DDB5><EFBFBD> <20><><EFBFBD><EFBFBD>ȭ <20><> <20><>!
|
||||
if (m_fRotation==0.0f)
|
||||
{
|
||||
v3Up = -c_rv3Cross;
|
||||
v3Cross = c_rv3Up;
|
||||
}
|
||||
else
|
||||
{
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXMATRIX matRotation;
|
||||
|
||||
D3DXMatrixRotationAxis(&matRotation, &c_rv3View, D3DXToRadian(m_fRotation));
|
||||
D3DXVec3TransformCoord(&v3Up, &(-c_rv3Cross), &matRotation);
|
||||
D3DXVec3TransformCoord(&v3Cross, &c_rv3Up, &matRotation);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
v3Up = m_v3Position - m_v3LastPosition;
|
||||
|
||||
if (c_matLocal)
|
||||
{
|
||||
//if (!m_pParticleProperty->m_bAttachFlag)
|
||||
D3DXVec3TransformNormal(&v3Up, &v3Up, c_matLocal);
|
||||
}
|
||||
|
||||
// NOTE: <20>ӵ<EFBFBD><D3B5><EFBFBD> <20><><EFBFBD>̿<EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD> : log(velocity)<29><>ŭ <20>þ<C3BE><EEB3AD>.
|
||||
float length = D3DXVec3Length(&v3Up);
|
||||
if (length == 0.0f)
|
||||
{
|
||||
v3Up = D3DXVECTOR3(0.0f,0.0f,1.0f);
|
||||
}
|
||||
else
|
||||
v3Up *=(1+log(1+length))/length;
|
||||
//D3DXVec3Normalize(&v3Up,&v3Up);
|
||||
//v3Up *= 1+log(1+length);
|
||||
|
||||
CCamera * pCurrentCamera = CCameraManager::Instance().GetCurrentCamera();
|
||||
const D3DXVECTOR3 & c_rv3View = pCurrentCamera->GetView();
|
||||
D3DXVec3Cross(&v3Cross, &v3Up, &c_rv3View);
|
||||
D3DXVec3Normalize(&v3Cross, &v3Cross);
|
||||
|
||||
}
|
||||
|
||||
if (c_fZRotation)
|
||||
{
|
||||
float x, y;
|
||||
float fCos = cosf(c_fZRotation);
|
||||
float fSin = sinf(c_fZRotation);
|
||||
|
||||
x = v3Up.x;
|
||||
y = v3Up.y;
|
||||
v3Up.x = x * fCos - y * fSin;
|
||||
v3Up.y = y * fCos + x * fSin;
|
||||
|
||||
x = v3Cross.x;
|
||||
y = v3Cross.y;
|
||||
v3Cross.x = x * fCos - y * fSin;
|
||||
v3Cross.y = y * fCos + x * fSin;
|
||||
}
|
||||
|
||||
v3Cross = -(m_v2HalfSize.x*m_v2Scale.x) * v3Cross;
|
||||
v3Up = (m_v2HalfSize.y*m_v2Scale.y) * v3Up;
|
||||
|
||||
if (c_matLocal && m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVECTOR3 v3Position;
|
||||
D3DXVec3TransformCoord(&v3Position, &m_v3Position, c_matLocal);
|
||||
m_ParticleMesh[0].position = v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = v3Position + v3Up - v3Cross;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ParticleMesh[0].position = m_v3Position - v3Up + v3Cross;
|
||||
m_ParticleMesh[1].position = m_v3Position - v3Up - v3Cross;
|
||||
m_ParticleMesh[2].position = m_v3Position + v3Up + v3Cross;
|
||||
m_ParticleMesh[3].position = m_v3Position + v3Up - v3Cross;
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleInstance::Destroy()
|
||||
{
|
||||
if (m_pDecorator)
|
||||
m_pDecorator->DeleteThis();
|
||||
|
||||
__Initialize();
|
||||
|
||||
}
|
||||
|
||||
void CParticleInstance::__Initialize()
|
||||
{
|
||||
//*
|
||||
m_pDecorator=NULL;
|
||||
|
||||
m_v3Position = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
m_v3LastPosition = m_v3Position;
|
||||
m_v3Velocity = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
m_v2Scale = D3DXVECTOR2(1.0f, 1.0f);
|
||||
#ifdef WORLD_EDITOR
|
||||
m_Color = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
#else
|
||||
m_dcColor.m_dwColor = 0xffffffff;
|
||||
#endif
|
||||
|
||||
m_byFrameIndex = 0;
|
||||
m_ParticleMesh[0].texCoord = D3DXVECTOR2(0.0f, 1.0f);
|
||||
m_ParticleMesh[1].texCoord = D3DXVECTOR2(0.0f, 0.0f);
|
||||
m_ParticleMesh[2].texCoord = D3DXVECTOR2(1.0f, 1.0f);
|
||||
m_ParticleMesh[3].texCoord = D3DXVECTOR2(1.0f, 0.0f);
|
||||
}
|
||||
|
||||
CParticleInstance::CParticleInstance()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
CParticleInstance::~CParticleInstance()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
/*CRayParticleInstance::CRayParticleInstance()
|
||||
{
|
||||
#ifdef RAY_TO_AFTERIMAGE
|
||||
int i;
|
||||
for(i=0;i<RAY_VERTEX_COUNT*2;i+=2)
|
||||
{
|
||||
m_ParticleMesh[i].texCoord = D3DXVECTOR2(i+0.0f, 1.0f);
|
||||
m_ParticleMesh[i+1].texCoord = D3DXVECTOR2(i+1.0f, 0.0f);
|
||||
}
|
||||
#else
|
||||
m_ParticleMesh[0].texCoord = D3DXVECTOR2(0.0f, 1.0f);
|
||||
m_ParticleMesh[1].texCoord = D3DXVECTOR2(0.0f, 0.0f);
|
||||
m_ParticleMesh[2].texCoord = D3DXVECTOR2(0.5f, 1.0f);
|
||||
m_ParticleMesh[3].texCoord = D3DXVECTOR2(0.5f, 0.0f);
|
||||
m_ParticleMesh[4].texCoord = D3DXVECTOR2(1.0f, 1.0f);
|
||||
m_ParticleMesh[5].texCoord = D3DXVECTOR2(1.0f, 0.0f);
|
||||
|
||||
m_bStart = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
CRayParticleInstance::~CRayParticleInstance()
|
||||
{
|
||||
}*/
|
||||
|
||||
|
||||
TPTVertex * CParticleInstance::GetParticleMeshPointer()
|
||||
{
|
||||
return m_ParticleMesh;
|
||||
}
|
||||
|
||||
/*TPTVertex * CRayParticleInstance::GetParticleMeshPointer()
|
||||
{
|
||||
return m_ParticleMesh;
|
||||
}
|
||||
|
||||
void CRayParticleInstance::Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation)
|
||||
{
|
||||
assert(false && "NOT_REACHED");
|
||||
}*/
|
91
src/EffectLib/ParticleInstance.h
Normal file
91
src/EffectLib/ParticleInstance.h
Normal file
@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterlib/GrpBase.h"
|
||||
#include "../eterLib/Pool.h"
|
||||
#include "EffectUpdateDecorator.h"
|
||||
class CParticleProperty;
|
||||
class CEmitterProperty;
|
||||
|
||||
class CParticleInstance
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
friend class CParticleSystemInstance;
|
||||
|
||||
friend class NEffectUpdateDecorator::CBaseDecorator;
|
||||
friend class NEffectUpdateDecorator::CAirResistanceDecorator;
|
||||
friend class NEffectUpdateDecorator::CGravityDecorator;
|
||||
friend class NEffectUpdateDecorator::CRotationDecorator;
|
||||
|
||||
public:
|
||||
CParticleInstance();
|
||||
~CParticleInstance();
|
||||
|
||||
float GetRadiusApproximation();
|
||||
|
||||
BOOL Update(float fElapsedTime, float fAngle);
|
||||
//virtual void Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation)=0;
|
||||
//virtual void Transform(const D3DXMATRIX * c_matLocal = NULL)=0;
|
||||
|
||||
//virtual TPTVertex * GetParticleMeshPointer() = 0;
|
||||
|
||||
//__forceinline float GetLifePercentage()
|
||||
//{
|
||||
// return m_fLifePercentage;
|
||||
//return (m_fLifeTime - m_fLastLifeTime) / m_fLifeTime;
|
||||
//}
|
||||
|
||||
//virtual void DeleteThis() = 0;
|
||||
|
||||
protected:
|
||||
//float m_fLifePercentage;
|
||||
D3DXVECTOR3 m_v3StartPosition;
|
||||
|
||||
D3DXVECTOR3 m_v3Position;
|
||||
D3DXVECTOR3 m_v3LastPosition;
|
||||
D3DXVECTOR3 m_v3Velocity;
|
||||
|
||||
D3DXVECTOR2 m_v2HalfSize;
|
||||
D3DXVECTOR2 m_v2Scale;
|
||||
|
||||
float m_fRotation;
|
||||
#ifdef WORLD_EDITOR
|
||||
D3DXCOLOR m_Color;
|
||||
#else
|
||||
DWORDCOLOR m_dcColor;
|
||||
#endif
|
||||
|
||||
BYTE m_byTextureAnimationType;
|
||||
float m_fLastFrameTime;
|
||||
BYTE m_byFrameIndex;
|
||||
|
||||
float m_fLifeTime;
|
||||
float m_fLastLifeTime;
|
||||
|
||||
CParticleProperty * m_pParticleProperty;
|
||||
CEmitterProperty * m_pEmitterProperty;
|
||||
|
||||
float m_fAirResistance;
|
||||
float m_fRotationSpeed;
|
||||
float m_fGravity;
|
||||
|
||||
NEffectUpdateDecorator::CBaseDecorator * m_pDecorator;
|
||||
public:
|
||||
static CParticleInstance* New();
|
||||
static void DestroySystem();
|
||||
|
||||
void Transform(const D3DXMATRIX * c_matLocal=NULL);
|
||||
void Transform(const D3DXMATRIX * c_matLocal, const float c_fZRotation);
|
||||
|
||||
TPTVertex * GetParticleMeshPointer();
|
||||
|
||||
void DeleteThis();
|
||||
|
||||
void Destroy();
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
TPTVertex m_ParticleMesh[4];
|
||||
public:
|
||||
static CDynamicPool<CParticleInstance> ms_kPool;
|
||||
|
||||
};
|
121
src/EffectLib/ParticleProperty.cpp
Normal file
121
src/EffectLib/ParticleProperty.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ParticleProperty.h"
|
||||
#include "../eterlib/ResourceManager.h"
|
||||
|
||||
void CParticleProperty::InsertTexture(const char * c_szFileName)
|
||||
{
|
||||
CGraphicImage * pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(c_szFileName);
|
||||
|
||||
m_ImageVector.push_back(pImage);
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TextureNameVector.push_back(c_szFileName);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CParticleProperty::SetTexture(const char * c_szFileName)
|
||||
{
|
||||
if (m_ImageVector.size() > 1)
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
m_ImageVector.clear();
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TextureNameVector.clear();
|
||||
#endif
|
||||
InsertTexture(c_szFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CParticleProperty::Clear()
|
||||
{
|
||||
m_byRotationType = 0;
|
||||
m_fRotationSpeed = 0.0f;
|
||||
m_wRotationRandomStartingBegin = 0;
|
||||
m_wRotationRandomStartingEnd = 0;
|
||||
|
||||
m_bAttachFlag = FALSE;
|
||||
m_bStretchFlag = FALSE;
|
||||
|
||||
m_bySrcBlendType = D3DBLEND_SRCALPHA;
|
||||
m_byDestBlendType = D3DBLEND_ONE;
|
||||
m_byColorOperationType = D3DTOP_MODULATE;
|
||||
|
||||
m_byBillboardType = BILLBOARD_TYPE_NONE;
|
||||
|
||||
m_byTexAniType = TEXTURE_ANIMATION_TYPE_NONE;
|
||||
m_fTexAniDelay = 0.05f;
|
||||
m_bTexAniRandomStartFrameFlag = FALSE;
|
||||
|
||||
//m_fGravity = 0.0f;
|
||||
//m_fAirResistance = 0.0f;
|
||||
|
||||
m_TimeEventGravity.clear();
|
||||
m_TimeEventAirResistance.clear();
|
||||
|
||||
m_TimeEventScaleX.clear();
|
||||
m_TimeEventScaleY.clear();
|
||||
//m_TimeEventScaleXY.clear();
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TimeEventColorRed.clear();
|
||||
m_TimeEventColorGreen.clear();
|
||||
m_TimeEventColorBlue.clear();
|
||||
m_TimeEventAlpha.clear();
|
||||
m_TextureNameVector.clear();
|
||||
#else
|
||||
m_TimeEventColor.clear();
|
||||
#endif
|
||||
m_TimeEventRotation.clear();
|
||||
|
||||
m_ImageVector.clear();
|
||||
}
|
||||
|
||||
CParticleProperty::CParticleProperty()
|
||||
{
|
||||
}
|
||||
CParticleProperty::~CParticleProperty()
|
||||
{
|
||||
}
|
||||
|
||||
CParticleProperty & CParticleProperty::operator = ( const CParticleProperty& c_ParticleProperty )
|
||||
{
|
||||
m_byTexAniType = c_ParticleProperty.m_byTexAniType;
|
||||
m_fTexAniDelay = c_ParticleProperty.m_fTexAniDelay;
|
||||
m_bTexAniRandomStartFrameFlag = c_ParticleProperty.m_bTexAniRandomStartFrameFlag;
|
||||
|
||||
m_bySrcBlendType = c_ParticleProperty.m_bySrcBlendType;
|
||||
m_byDestBlendType = c_ParticleProperty.m_byDestBlendType;
|
||||
m_byColorOperationType = c_ParticleProperty.m_byColorOperationType;
|
||||
|
||||
m_byBillboardType = c_ParticleProperty.m_byBillboardType;
|
||||
|
||||
m_byRotationType = c_ParticleProperty.m_byRotationType;
|
||||
m_fRotationSpeed = c_ParticleProperty.m_fRotationSpeed;
|
||||
m_wRotationRandomStartingBegin = c_ParticleProperty.m_wRotationRandomStartingBegin;
|
||||
m_wRotationRandomStartingEnd = c_ParticleProperty.m_wRotationRandomStartingEnd;
|
||||
|
||||
m_bAttachFlag = c_ParticleProperty.m_bAttachFlag;
|
||||
m_bStretchFlag = c_ParticleProperty.m_bStretchFlag;
|
||||
|
||||
m_TimeEventGravity = c_ParticleProperty.m_TimeEventGravity;
|
||||
m_TimeEventAirResistance = c_ParticleProperty.m_TimeEventAirResistance;
|
||||
|
||||
m_TimeEventScaleX = c_ParticleProperty.m_TimeEventScaleX;
|
||||
m_TimeEventScaleY = c_ParticleProperty.m_TimeEventScaleY;
|
||||
|
||||
#ifdef WORLD_EDITOR
|
||||
m_TimeEventColorRed = c_ParticleProperty.m_TimeEventColorRed;
|
||||
m_TimeEventColorGreen = c_ParticleProperty.m_TimeEventColorGreen;
|
||||
m_TimeEventColorBlue = c_ParticleProperty.m_TimeEventColorBlue;
|
||||
m_TimeEventAlpha = c_ParticleProperty.m_TimeEventAlpha;
|
||||
|
||||
m_TextureNameVector = c_ParticleProperty.m_TextureNameVector;
|
||||
#else
|
||||
m_TimeEventColor = c_ParticleProperty.m_TimeEventColor;
|
||||
#endif
|
||||
m_TimeEventRotation = c_ParticleProperty.m_TimeEventRotation;
|
||||
|
||||
m_ImageVector = c_ParticleProperty.m_ImageVector;
|
||||
|
||||
return *this;
|
||||
}
|
96
src/EffectLib/ParticleProperty.h
Normal file
96
src/EffectLib/ParticleProperty.h
Normal file
@ -0,0 +1,96 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
|
||||
#include "Type.h"
|
||||
|
||||
class CParticleProperty
|
||||
{
|
||||
friend class CParticleSystemData;
|
||||
friend class CParticleSystemInstance;
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ROTATION_TYPE_NONE,
|
||||
ROTATION_TYPE_TIME_EVENT,
|
||||
ROTATION_TYPE_CW,
|
||||
ROTATION_TYPE_CCW,
|
||||
ROTATION_TYPE_RANDOM_DIRECTION,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TEXTURE_ANIMATION_TYPE_NONE,
|
||||
TEXTURE_ANIMATION_TYPE_CW,
|
||||
TEXTURE_ANIMATION_TYPE_CCW,
|
||||
TEXTURE_ANIMATION_TYPE_RANDOM_FRAME,
|
||||
TEXTURE_ANIMATION_TYPE_RANDOM_DIRECTION,
|
||||
};
|
||||
|
||||
public:
|
||||
CParticleProperty();
|
||||
virtual ~CParticleProperty();
|
||||
|
||||
void Clear();
|
||||
|
||||
void InsertTexture(const char * c_szFileName);
|
||||
bool SetTexture(const char * c_szFileName);
|
||||
|
||||
__forceinline BYTE GetTextureAnimationType()
|
||||
{
|
||||
return m_byTexAniType;
|
||||
}
|
||||
|
||||
__forceinline DWORD GetTextureAnimationFrameCount()
|
||||
{
|
||||
return m_ImageVector.size();
|
||||
}
|
||||
|
||||
__forceinline float GetTextureAnimationFrameDelay()
|
||||
{
|
||||
return m_fTexAniDelay;
|
||||
}
|
||||
|
||||
|
||||
BYTE m_byTexAniType;
|
||||
float m_fTexAniDelay;
|
||||
BOOL m_bTexAniRandomStartFrameFlag;
|
||||
|
||||
BYTE m_bySrcBlendType;
|
||||
BYTE m_byDestBlendType;
|
||||
BYTE m_byColorOperationType;
|
||||
BYTE m_byBillboardType;
|
||||
|
||||
BYTE m_byRotationType;
|
||||
float m_fRotationSpeed;
|
||||
WORD m_wRotationRandomStartingBegin;
|
||||
WORD m_wRotationRandomStartingEnd;
|
||||
|
||||
BOOL m_bAttachFlag;
|
||||
BOOL m_bStretchFlag;
|
||||
|
||||
TTimeEventTableFloat m_TimeEventGravity;
|
||||
TTimeEventTableFloat m_TimeEventAirResistance;
|
||||
|
||||
TTimeEventTableFloat m_TimeEventScaleX;
|
||||
TTimeEventTableFloat m_TimeEventScaleY;
|
||||
#ifdef WORLD_EDITOR
|
||||
TTimeEventTableFloat m_TimeEventColorRed;
|
||||
TTimeEventTableFloat m_TimeEventColorGreen;
|
||||
TTimeEventTableFloat m_TimeEventColorBlue;
|
||||
TTimeEventTableFloat m_TimeEventAlpha;
|
||||
|
||||
std::vector<std::string> m_TextureNameVector;
|
||||
#else
|
||||
TTimeEventTableColor m_TimeEventColor;
|
||||
#endif
|
||||
TTimeEventTableFloat m_TimeEventRotation;
|
||||
|
||||
std::vector<CGraphicImage*> m_ImageVector;
|
||||
|
||||
CParticleProperty & operator = ( const CParticleProperty& c_ParticleProperty );
|
||||
|
||||
// pre-transformed variables
|
||||
D3DXVECTOR3 m_v3ZAxis;
|
||||
};
|
424
src/EffectLib/ParticleSystemData.cpp
Normal file
424
src/EffectLib/ParticleSystemData.cpp
Normal file
@ -0,0 +1,424 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ParticleSystemData.h"
|
||||
#include "EffectUpdateDecorator.h"
|
||||
#include "ParticleInstance.h"
|
||||
|
||||
CDynamicPool<CParticleSystemData> CParticleSystemData::ms_kPool;
|
||||
|
||||
void CParticleSystemData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CParticleSystemData* CParticleSystemData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CParticleSystemData::Delete(CParticleSystemData* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
CEmitterProperty * CParticleSystemData::GetEmitterPropertyPointer()
|
||||
{
|
||||
return &m_EmitterProperty;
|
||||
}
|
||||
CParticleProperty * CParticleSystemData::GetParticlePropertyPointer()
|
||||
{
|
||||
return &m_ParticleProperty;
|
||||
}
|
||||
|
||||
BOOL CParticleSystemData::OnLoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
{
|
||||
CTextFileLoader::CGotoChild GotoChild(&rTextFileLoader, "emitterproperty");
|
||||
|
||||
if (!rTextFileLoader.GetTokenDoubleWord("maxemissioncount", &m_EmitterProperty.m_dwMaxEmissionCount))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("cyclelength", &m_EmitterProperty.m_fCycleLength))
|
||||
{
|
||||
m_EmitterProperty.m_fCycleLength = 0.05f;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenBoolean("cycleloopenable", &m_EmitterProperty.m_bCycleLoopFlag))
|
||||
{
|
||||
m_EmitterProperty.m_bCycleLoopFlag = FALSE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenInteger("loopcount",&m_EmitterProperty.m_iLoopCount))
|
||||
{
|
||||
m_EmitterProperty.m_iLoopCount = 0;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("emittershape", &m_EmitterProperty.m_byEmitterShape))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("emitteradvancedtype", &m_EmitterProperty.m_byEmitterAdvancedType))
|
||||
{
|
||||
m_EmitterProperty.m_byEmitterShape = CEmitterProperty::EMITTER_ADVANCED_TYPE_FREE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenPosition("emittingsize", &m_EmitterProperty.m_v3EmittingSize))
|
||||
{
|
||||
m_EmitterProperty.m_v3EmittingSize = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenFloat("emittingradius", &m_EmitterProperty.m_fEmittingRadius))
|
||||
{
|
||||
m_EmitterProperty.m_fEmittingRadius = 0.0f;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("emitteremitfromedgeflag", &m_EmitterProperty.m_bEmitFromEdgeFlag))
|
||||
{
|
||||
m_EmitterProperty.m_bEmitFromEdgeFlag = FALSE;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenPosition("emittingdirection", &m_EmitterProperty.m_v3EmittingDirection))
|
||||
{
|
||||
m_EmitterProperty.m_v3EmittingDirection = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingsize", &m_EmitterProperty.m_TimeEventEmittingSize))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingSize.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingSize.push_back(TimeEventFloat);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingangularvelocity", &m_EmitterProperty.m_TimeEventEmittingAngularVelocity))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingAngularVelocity.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingAngularVelocity.push_back(TimeEventFloat);
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingdirectionx", &m_EmitterProperty.m_TimeEventEmittingDirectionX))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionX.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionX.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingdirectiony", &m_EmitterProperty.m_TimeEventEmittingDirectionY))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionY.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionY.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingdirectionz", &m_EmitterProperty.m_TimeEventEmittingDirectionZ))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionZ.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingDirectionZ.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemittingvelocity", &m_EmitterProperty.m_TimeEventEmittingVelocity))
|
||||
{
|
||||
m_EmitterProperty.m_TimeEventEmittingVelocity.clear();
|
||||
TTimeEventTypeFloat TimeEventFloat;
|
||||
TimeEventFloat.m_fTime = 0.0f;
|
||||
TimeEventFloat.m_Value = 0.0f;
|
||||
m_EmitterProperty.m_TimeEventEmittingVelocity.push_back(TimeEventFloat);
|
||||
}
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventemissioncountpersecond", &m_EmitterProperty.m_TimeEventEmissionCountPerSecond))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventlifetime", &m_EmitterProperty.m_TimeEventLifeTime))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventsizex", &m_EmitterProperty.m_TimeEventSizeX))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventsizey", &m_EmitterProperty.m_TimeEventSizeY))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
{
|
||||
CTextFileLoader::CGotoChild GotoChild(&rTextFileLoader, "particleproperty");
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("srcblendtype", &m_ParticleProperty.m_bySrcBlendType))
|
||||
{
|
||||
m_ParticleProperty.m_bySrcBlendType = D3DBLEND_SRCALPHA;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenByte("destblendtype", &m_ParticleProperty.m_byDestBlendType))
|
||||
{
|
||||
m_ParticleProperty.m_byDestBlendType = D3DBLEND_ONE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenByte("coloroperationtype", &m_ParticleProperty.m_byColorOperationType))
|
||||
{
|
||||
m_ParticleProperty.m_byColorOperationType = D3DTOP_MODULATE;
|
||||
}
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("billboardtype", &m_ParticleProperty.m_byBillboardType))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("rotationtype", &m_ParticleProperty.m_byRotationType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenFloat("rotationspeed", &m_ParticleProperty.m_fRotationSpeed))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenWord("rotationrandomstartingbegin", &m_ParticleProperty.m_wRotationRandomStartingBegin))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenWord("rotationrandomstartingend", &m_ParticleProperty.m_wRotationRandomStartingEnd))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("attachenable", &m_ParticleProperty.m_bAttachFlag))
|
||||
{
|
||||
m_ParticleProperty.m_bAttachFlag = FALSE;
|
||||
}
|
||||
if (!rTextFileLoader.GetTokenBoolean("stretchenable", &m_ParticleProperty.m_bStretchFlag))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenByte("texanitype", &m_ParticleProperty.m_byTexAniType))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenFloat("texanidelay", &m_ParticleProperty.m_fTexAniDelay))
|
||||
return FALSE;
|
||||
if (!rTextFileLoader.GetTokenBoolean("texanirandomstartframeenable", &m_ParticleProperty.m_bTexAniRandomStartFrameFlag))
|
||||
return FALSE;
|
||||
|
||||
float fGravity;
|
||||
|
||||
if (rTextFileLoader.GetTokenFloat("gravity", &fGravity))
|
||||
{
|
||||
TTimeEventTypeFloat f;
|
||||
f.m_fTime = 0.0f;
|
||||
f.m_Value = fGravity;
|
||||
m_ParticleProperty.m_TimeEventGravity.push_back(f);
|
||||
}
|
||||
else if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventgravity", &m_ParticleProperty.m_TimeEventGravity))
|
||||
{
|
||||
m_ParticleProperty.m_TimeEventGravity.clear();
|
||||
}
|
||||
|
||||
float fAirResistance;
|
||||
if (rTextFileLoader.GetTokenFloat("airresistance", &fAirResistance))
|
||||
{
|
||||
TTimeEventTypeFloat f;
|
||||
f.m_fTime = 0.0f;
|
||||
f.m_Value = fAirResistance;
|
||||
m_ParticleProperty.m_TimeEventAirResistance.push_back(f);
|
||||
}
|
||||
else if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventairresistance", &m_ParticleProperty.m_TimeEventAirResistance))
|
||||
{
|
||||
m_ParticleProperty.m_TimeEventAirResistance.clear();
|
||||
}
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventscalex", &m_ParticleProperty.m_TimeEventScaleX))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventscaley", &m_ParticleProperty.m_TimeEventScaleY))
|
||||
return FALSE;
|
||||
|
||||
#ifdef WORLD_EDITOR
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorred", &m_ParticleProperty.m_TimeEventColorRed))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorgreen", &m_ParticleProperty.m_TimeEventColorGreen))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorblue", &m_ParticleProperty.m_TimeEventColorBlue))
|
||||
return FALSE;
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventalpha", &m_ParticleProperty.m_TimeEventAlpha))
|
||||
return FALSE;
|
||||
#else
|
||||
TTimeEventTableFloat TimeEventR;
|
||||
TTimeEventTableFloat TimeEventB;
|
||||
TTimeEventTableFloat TimeEventG;
|
||||
TTimeEventTableFloat TimeEventA;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorred", &TimeEventR))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorgreen", &TimeEventG))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventcolorblue", &TimeEventB))
|
||||
return FALSE;
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventalpha", &TimeEventA))
|
||||
return FALSE;
|
||||
|
||||
m_ParticleProperty.m_TimeEventColor.clear();
|
||||
{
|
||||
std::set<float> times;
|
||||
int i;
|
||||
for(i=0;i<TimeEventR.size();i++)
|
||||
times.insert(TimeEventR[i].m_fTime);
|
||||
for(i=0;i<TimeEventG.size();i++)
|
||||
times.insert(TimeEventG[i].m_fTime);
|
||||
for(i=0;i<TimeEventB.size();i++)
|
||||
times.insert(TimeEventB[i].m_fTime);
|
||||
for(i=0;i<TimeEventA.size();i++)
|
||||
times.insert(TimeEventA[i].m_fTime);
|
||||
std::set<float>::iterator it;
|
||||
for(it = times.begin(); it != times.end(); ++it)
|
||||
{
|
||||
float fTime = *it;
|
||||
float fR, fG, fB, fA;
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventR, &fR);
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventG, &fG);
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventB, &fB);
|
||||
GetTimeEventBlendValue<float>(fTime, TimeEventA, &fA);
|
||||
TTimeEventTypeColor t;
|
||||
t.m_fTime = fTime;
|
||||
D3DXCOLOR c;
|
||||
c.r = fR;
|
||||
c.g = fG;
|
||||
c.b = fB;
|
||||
c.a = fA;
|
||||
t.m_Value.m_dwColor = /*(DWORD)*/ (DWORD)c;
|
||||
m_ParticleProperty.m_TimeEventColor.push_back(t);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader, "timeeventrotation", &m_ParticleProperty.m_TimeEventRotation))
|
||||
return FALSE;
|
||||
|
||||
CTokenVector * pTextureVector;
|
||||
|
||||
if (!rTextFileLoader.GetTokenVector("texturefiles", &pTextureVector))
|
||||
return FALSE;
|
||||
|
||||
for (DWORD i = 0; i < pTextureVector->size(); ++i)
|
||||
{
|
||||
std::string strTextureFileName = pTextureVector->at(i).c_str();
|
||||
|
||||
if (!IsGlobalFileName(strTextureFileName.c_str()))
|
||||
strTextureFileName = GetOnlyPathName(rTextFileLoader.GetFileName()) + strTextureFileName;
|
||||
|
||||
m_ParticleProperty.InsertTexture(strTextureFileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CParticleSystemData::ChangeTexture(const char * c_szFileName)
|
||||
{
|
||||
m_ParticleProperty.SetTexture(c_szFileName);
|
||||
}
|
||||
|
||||
void CParticleSystemData::OnClear()
|
||||
{
|
||||
m_EmitterProperty.Clear();
|
||||
m_ParticleProperty.Clear();
|
||||
}
|
||||
|
||||
bool CParticleSystemData::OnIsData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CParticleSystemData::BuildDecorator(CParticleInstance * pInstance)
|
||||
{
|
||||
using namespace NEffectUpdateDecorator;
|
||||
|
||||
pInstance->m_pDecorator = new CNullDecorator;
|
||||
|
||||
//////
|
||||
|
||||
if (m_ParticleProperty.m_TimeEventAirResistance.size()>1)
|
||||
{
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(new CAirResistanceDecorator);
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CAirResistanceValueDecorator(m_ParticleProperty.m_TimeEventAirResistance, &pInstance->m_fAirResistance)
|
||||
);
|
||||
}
|
||||
else if (m_ParticleProperty.m_TimeEventAirResistance.size()==1)
|
||||
{
|
||||
pInstance->m_fAirResistance = m_ParticleProperty.m_TimeEventAirResistance[0].m_Value;
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(new CAirResistanceDecorator);
|
||||
}
|
||||
|
||||
if (m_ParticleProperty.m_TimeEventGravity.size() > 1)
|
||||
{
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(new CGravityDecorator);
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CGravityValueDecorator(m_ParticleProperty.m_TimeEventGravity, &pInstance->m_fGravity)
|
||||
);
|
||||
}
|
||||
else if (m_ParticleProperty.m_TimeEventGravity.size() == 1)
|
||||
{
|
||||
pInstance->m_fGravity = m_ParticleProperty.m_TimeEventGravity[0].m_Value;
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(new CGravityDecorator);
|
||||
}
|
||||
#ifdef WORLD_EDITOR
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventColorRed, &pInstance->m_Color.r));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventColorGreen, &pInstance->m_Color.g));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventColorBlue, &pInstance->m_Color.b));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorValueDecorator(m_ParticleProperty.m_TimeEventAlpha, &pInstance->m_Color.a));
|
||||
#else
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CColorAllDecorator(m_ParticleProperty.m_TimeEventColor, &pInstance->m_dcColor));
|
||||
#endif
|
||||
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CScaleValueDecorator(m_ParticleProperty.m_TimeEventScaleX, &pInstance->m_v2Scale.x));
|
||||
pInstance->m_pDecorator = pInstance->m_pDecorator->AddChainFront(
|
||||
new CScaleValueDecorator(m_ParticleProperty.m_TimeEventScaleY, &pInstance->m_v2Scale.y));
|
||||
|
||||
if (m_ParticleProperty.GetTextureAnimationFrameCount()>1 &&m_ParticleProperty.GetTextureAnimationFrameDelay()>1e-6)
|
||||
{
|
||||
switch (pInstance->m_byTextureAnimationType)
|
||||
{
|
||||
case CParticleProperty::TEXTURE_ANIMATION_TYPE_CW:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CTextureAnimationCWDecorator(m_ParticleProperty.GetTextureAnimationFrameDelay(), m_ParticleProperty.GetTextureAnimationFrameCount(), &pInstance->m_byFrameIndex));
|
||||
break;
|
||||
case CParticleProperty::TEXTURE_ANIMATION_TYPE_CCW:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CTextureAnimationCCWDecorator(m_ParticleProperty.GetTextureAnimationFrameDelay(), m_ParticleProperty.GetTextureAnimationFrameCount(), &pInstance->m_byFrameIndex));
|
||||
break;
|
||||
case CParticleProperty::TEXTURE_ANIMATION_TYPE_RANDOM_FRAME:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CTextureAnimationRandomDecorator(m_ParticleProperty.GetTextureAnimationFrameDelay(), m_ParticleProperty.GetTextureAnimationFrameCount(), &pInstance->m_byFrameIndex));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE byRotationType = m_ParticleProperty.m_byRotationType;
|
||||
|
||||
if (m_ParticleProperty.m_fRotationSpeed==0.0f && byRotationType!=CParticleProperty::ROTATION_TYPE_TIME_EVENT)
|
||||
{
|
||||
byRotationType = CParticleProperty::ROTATION_TYPE_NONE;
|
||||
}
|
||||
else if (byRotationType==CParticleProperty::ROTATION_TYPE_RANDOM_DIRECTION)
|
||||
{
|
||||
byRotationType = (random()&1)?CParticleProperty::ROTATION_TYPE_CW:CParticleProperty::ROTATION_TYPE_CCW;
|
||||
}
|
||||
|
||||
switch(byRotationType)
|
||||
{
|
||||
case CParticleProperty::ROTATION_TYPE_TIME_EVENT:
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationDecorator());
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationSpeedValueDecorator(m_ParticleProperty.m_TimeEventRotation,&pInstance->m_fRotationSpeed));
|
||||
break;
|
||||
|
||||
case CParticleProperty::ROTATION_TYPE_CW:
|
||||
pInstance->m_fRotationSpeed = m_ParticleProperty.m_fRotationSpeed;
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationDecorator());
|
||||
break;
|
||||
|
||||
case CParticleProperty::ROTATION_TYPE_CCW:
|
||||
pInstance->m_fRotationSpeed = - m_ParticleProperty.m_fRotationSpeed;
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(
|
||||
new CRotationDecorator());
|
||||
break;
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
pInstance->m_pDecorator=pInstance->m_pDecorator->AddChainFront(new CHeaderDecorator);
|
||||
}
|
||||
|
||||
CParticleSystemData::CParticleSystemData()
|
||||
{
|
||||
}
|
||||
CParticleSystemData::~CParticleSystemData()
|
||||
{
|
||||
}
|
41
src/EffectLib/ParticleSystemData.h
Normal file
41
src/EffectLib/ParticleSystemData.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "EffectElementBase.h"
|
||||
#include "EmitterProperty.h"
|
||||
#include "ParticleProperty.h"
|
||||
//#include "ParticleInstance.h"
|
||||
|
||||
class CParticleInstance;
|
||||
|
||||
class CParticleSystemData : public CEffectElementBase
|
||||
{
|
||||
public:
|
||||
virtual ~CParticleSystemData();
|
||||
CParticleSystemData();
|
||||
|
||||
CEmitterProperty * GetEmitterPropertyPointer();
|
||||
CParticleProperty * GetParticlePropertyPointer();
|
||||
|
||||
void ChangeTexture(const char * c_szFileName);
|
||||
|
||||
void BuildDecorator(CParticleInstance * pInstance);
|
||||
protected:
|
||||
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
void OnClear();
|
||||
bool OnIsData();
|
||||
|
||||
|
||||
CEmitterProperty m_EmitterProperty;
|
||||
CParticleProperty m_ParticleProperty;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CParticleSystemData* New();
|
||||
static void Delete(CParticleSystemData* pkData);
|
||||
|
||||
static CDynamicPool<CParticleSystemData> ms_kPool;
|
||||
};
|
519
src/EffectLib/ParticleSystemInstance.cpp
Normal file
519
src/EffectLib/ParticleSystemInstance.cpp
Normal file
@ -0,0 +1,519 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../eterBase/Random.h"
|
||||
#include "../eterLib/StateManager.h"
|
||||
#include "ParticleSystemData.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
#include "ParticleInstance.h"
|
||||
|
||||
CDynamicPool<CParticleSystemInstance> CParticleSystemInstance::ms_kPool;
|
||||
|
||||
using namespace NEffectUpdateDecorator;
|
||||
|
||||
void CParticleSystemInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
|
||||
CParticleInstance::DestroySystem();
|
||||
//CRayParticleInstance::DestroySystem();
|
||||
}
|
||||
|
||||
CParticleSystemInstance* CParticleSystemInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::Delete(CParticleSystemInstance* pkPSInst)
|
||||
{
|
||||
pkPSInst->Destroy();
|
||||
ms_kPool.Free(pkPSInst);
|
||||
}
|
||||
|
||||
|
||||
|
||||
DWORD CParticleSystemInstance::GetEmissionCount()
|
||||
{
|
||||
return m_dwCurrentEmissionCount;
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::CreateParticles(float fElapsedTime)
|
||||
{
|
||||
float fEmissionCount;
|
||||
m_pEmitterProperty->GetEmissionCountPerSecond(m_fLocalTime, &fEmissionCount);
|
||||
|
||||
float fCreatingValue = fEmissionCount * (fElapsedTime / 1.0f) + m_fEmissionResidue;
|
||||
int iCreatingCount = int(fCreatingValue);
|
||||
m_fEmissionResidue = fCreatingValue - iCreatingCount;
|
||||
|
||||
int icurEmissionCount = GetEmissionCount();
|
||||
int iMaxEmissionCount = int(m_pEmitterProperty->GetMaxEmissionCount());
|
||||
int iNextEmissionCount = int(icurEmissionCount + iCreatingCount);
|
||||
iCreatingCount -= max(0, iNextEmissionCount - iMaxEmissionCount);
|
||||
|
||||
float fLifeTime = 0.0f;
|
||||
float fEmittingSize = 0.0f;
|
||||
D3DXVECTOR3 _v3TimePosition;
|
||||
D3DXVECTOR3 _v3Velocity;
|
||||
float fVelocity = 0.0f;
|
||||
D3DXVECTOR2 v2HalfSize;
|
||||
float fLieRotation = 0;
|
||||
if (iCreatingCount)
|
||||
{
|
||||
m_pEmitterProperty->GetParticleLifeTime(m_fLocalTime, &fLifeTime);
|
||||
if (fLifeTime==0.0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_pEmitterProperty->GetEmittingSize(m_fLocalTime, &fEmittingSize);
|
||||
|
||||
m_pData->GetPosition(m_fLocalTime, _v3TimePosition);
|
||||
|
||||
m_pEmitterProperty->GetEmittingDirectionX(m_fLocalTime, &_v3Velocity.x);
|
||||
m_pEmitterProperty->GetEmittingDirectionY(m_fLocalTime, &_v3Velocity.y);
|
||||
m_pEmitterProperty->GetEmittingDirectionZ(m_fLocalTime, &_v3Velocity.z);
|
||||
|
||||
m_pEmitterProperty->GetEmittingVelocity(m_fLocalTime, &fVelocity);
|
||||
|
||||
m_pEmitterProperty->GetParticleSizeX(m_fLocalTime, &v2HalfSize.x);
|
||||
m_pEmitterProperty->GetParticleSizeY(m_fLocalTime, &v2HalfSize.y);
|
||||
|
||||
if (BILLBOARD_TYPE_LIE == m_pParticleProperty->m_byBillboardType && mc_pmatLocal)
|
||||
{
|
||||
float fsx = mc_pmatLocal->_32;
|
||||
float fcx = sqrtf(1.0f - fsx * fsx);
|
||||
|
||||
if (fcx >= 0.00001f)
|
||||
fLieRotation = D3DXToDegree(atan2f(-mc_pmatLocal->_12, mc_pmatLocal->_22));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CParticleInstance * pFirstInstance = 0;
|
||||
|
||||
for (int i = 0; i < iCreatingCount; ++i)
|
||||
{
|
||||
CParticleInstance * pInstance;
|
||||
|
||||
pInstance = CParticleInstance::New();
|
||||
pInstance->m_pParticleProperty = m_pParticleProperty;
|
||||
pInstance->m_pEmitterProperty = m_pEmitterProperty;
|
||||
|
||||
// LifeTime
|
||||
pInstance->m_fLifeTime = fLifeTime;
|
||||
pInstance->m_fLastLifeTime = fLifeTime;
|
||||
|
||||
// Position
|
||||
switch (m_pEmitterProperty->GetEmitterShape())
|
||||
{
|
||||
case CEmitterProperty::EMITTER_SHAPE_POINT:
|
||||
pInstance->m_v3Position.x = 0.0f;
|
||||
pInstance->m_v3Position.y = 0.0f;
|
||||
pInstance->m_v3Position.z = 0.0f;
|
||||
break;
|
||||
|
||||
case CEmitterProperty::EMITTER_SHAPE_ELLIPSE:
|
||||
pInstance->m_v3Position.x = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.y = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.z = 0.0f;
|
||||
D3DXVec3Normalize(&pInstance->m_v3Position, &pInstance->m_v3Position);
|
||||
|
||||
if (m_pEmitterProperty->isEmitFromEdge())
|
||||
{
|
||||
pInstance->m_v3Position *= (m_pEmitterProperty->m_fEmittingRadius + fEmittingSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_v3Position *= (frandom(0.0f, m_pEmitterProperty->m_fEmittingRadius) + fEmittingSize);
|
||||
}
|
||||
break;
|
||||
|
||||
case CEmitterProperty::EMITTER_SHAPE_SQUARE:
|
||||
pInstance->m_v3Position.x = (frandom(-m_pEmitterProperty->m_v3EmittingSize.x/2.0f, m_pEmitterProperty->m_v3EmittingSize.x/2.0f) + fEmittingSize);
|
||||
pInstance->m_v3Position.y = (frandom(-m_pEmitterProperty->m_v3EmittingSize.y/2.0f, m_pEmitterProperty->m_v3EmittingSize.y/2.0f) + fEmittingSize);
|
||||
pInstance->m_v3Position.z = (frandom(-m_pEmitterProperty->m_v3EmittingSize.z/2.0f, m_pEmitterProperty->m_v3EmittingSize.z/2.0f) + fEmittingSize);
|
||||
break;
|
||||
|
||||
case CEmitterProperty::EMITTER_SHAPE_SPHERE:
|
||||
pInstance->m_v3Position.x = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.y = frandom(-500.0f, 500.0f);
|
||||
pInstance->m_v3Position.z = frandom(-500.0f, 500.0f);
|
||||
D3DXVec3Normalize(&pInstance->m_v3Position, &pInstance->m_v3Position);
|
||||
|
||||
if (m_pEmitterProperty->isEmitFromEdge())
|
||||
{
|
||||
pInstance->m_v3Position *= (m_pEmitterProperty->m_fEmittingRadius + fEmittingSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_v3Position *= (frandom(0.0f, m_pEmitterProperty->m_fEmittingRadius) + fEmittingSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Position
|
||||
D3DXVECTOR3 v3TimePosition=_v3TimePosition;
|
||||
|
||||
pInstance->m_v3Position += v3TimePosition;
|
||||
|
||||
if (mc_pmatLocal && !m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVec3TransformCoord(&pInstance->m_v3Position,&pInstance->m_v3Position,mc_pmatLocal);
|
||||
D3DXVec3TransformCoord(&v3TimePosition, &v3TimePosition, mc_pmatLocal);
|
||||
}
|
||||
pInstance->m_v3StartPosition = v3TimePosition;
|
||||
// NOTE : Update<74><65> ȣ<><C8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʰ<EFBFBD> Rendering <20>DZ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> length<74><68> 0<><30> <20>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD>.
|
||||
// Velocity<74><79> <20><><EFBFBD><EFBFBD> <20><> <20><EFBFBD>ŭ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ <20><><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD> <20>ٲ<EFBFBD><D9B2><EFBFBD> - [levites]
|
||||
//pInstance->m_v3LastPosition = pInstance->m_v3Position;
|
||||
|
||||
// Direction & Velocity
|
||||
pInstance->m_v3Velocity.x = 0.0f;
|
||||
pInstance->m_v3Velocity.y = 0.0f;
|
||||
pInstance->m_v3Velocity.z = 0.0f;
|
||||
|
||||
if (CEmitterProperty::EMITTER_ADVANCED_TYPE_INNER == m_pEmitterProperty->GetEmitterAdvancedType())
|
||||
{
|
||||
D3DXVec3Normalize(&pInstance->m_v3Velocity, &(pInstance->m_v3Position-v3TimePosition));
|
||||
pInstance->m_v3Velocity *= -100.0f;
|
||||
}
|
||||
else if (CEmitterProperty::EMITTER_ADVANCED_TYPE_OUTER == m_pEmitterProperty->GetEmitterAdvancedType())
|
||||
{
|
||||
if (m_pEmitterProperty->GetEmitterShape() == CEmitterProperty::EMITTER_SHAPE_POINT)
|
||||
{
|
||||
pInstance->m_v3Velocity.x = frandom(-100.0f, 100.0f);
|
||||
pInstance->m_v3Velocity.y = frandom(-100.0f, 100.0f);
|
||||
pInstance->m_v3Velocity.z = frandom(-100.0f, 100.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXVec3Normalize(&pInstance->m_v3Velocity, &(pInstance->m_v3Position-v3TimePosition));
|
||||
pInstance->m_v3Velocity *= 100.0f;
|
||||
}
|
||||
}
|
||||
|
||||
D3DXVECTOR3 v3Velocity = _v3Velocity;
|
||||
if (mc_pmatLocal && !m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVec3TransformNormal(&v3Velocity, &v3Velocity, mc_pmatLocal);
|
||||
}
|
||||
|
||||
pInstance->m_v3Velocity += v3Velocity;
|
||||
if (m_pEmitterProperty->m_v3EmittingDirection.x > 0.0f)
|
||||
pInstance->m_v3Velocity.x += frandom(-m_pEmitterProperty->m_v3EmittingDirection.x/2.0f, m_pEmitterProperty->m_v3EmittingDirection.x/2.0f) * 1000.0f;
|
||||
if (m_pEmitterProperty->m_v3EmittingDirection.y > 0.0f)
|
||||
pInstance->m_v3Velocity.y += frandom(-m_pEmitterProperty->m_v3EmittingDirection.y/2.0f, m_pEmitterProperty->m_v3EmittingDirection.y/2.0f) * 1000.0f;
|
||||
if (m_pEmitterProperty->m_v3EmittingDirection.z > 0.0f)
|
||||
pInstance->m_v3Velocity.z += frandom(-m_pEmitterProperty->m_v3EmittingDirection.z/2.0f, m_pEmitterProperty->m_v3EmittingDirection.z/2.0f) * 1000.0f;
|
||||
|
||||
pInstance->m_v3Velocity *= fVelocity;
|
||||
|
||||
// Size
|
||||
pInstance->m_v2HalfSize = v2HalfSize;
|
||||
|
||||
// Rotation
|
||||
pInstance->m_fRotation = m_pParticleProperty->m_wRotationRandomStartingBegin;
|
||||
pInstance->m_fRotation = frandom(m_pParticleProperty->m_wRotationRandomStartingBegin,m_pParticleProperty->m_wRotationRandomStartingEnd);
|
||||
// Rotation - Lie <20><> <20><><EFBFBD><EFBFBD> LocalMatrix <20><> Rotation <20><><EFBFBD><EFBFBD> Random <20><> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
// <20>Ź<EFBFBD> <20><> <20>ʿ<EFBFBD><CABF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ȭ<EFBFBD><C8AD> <20>ʿ<EFBFBD>. - [levites]
|
||||
if (BILLBOARD_TYPE_LIE == m_pParticleProperty->m_byBillboardType && mc_pmatLocal)
|
||||
{
|
||||
pInstance->m_fRotation += fLieRotation;
|
||||
}
|
||||
|
||||
// Texture Animation
|
||||
pInstance->m_byFrameIndex = 0;
|
||||
pInstance->m_byTextureAnimationType = m_pParticleProperty->GetTextureAnimationType();
|
||||
|
||||
if (m_pParticleProperty->GetTextureAnimationFrameCount() > 1)
|
||||
{
|
||||
if (CParticleProperty::TEXTURE_ANIMATION_TYPE_RANDOM_DIRECTION == m_pParticleProperty->GetTextureAnimationType())
|
||||
{
|
||||
if (random() & 1)
|
||||
{
|
||||
pInstance->m_byFrameIndex = 0;
|
||||
pInstance->m_byTextureAnimationType = CParticleProperty::TEXTURE_ANIMATION_TYPE_CW;
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_byFrameIndex = m_pParticleProperty->GetTextureAnimationFrameCount() - 1;
|
||||
pInstance->m_byTextureAnimationType = CParticleProperty::TEXTURE_ANIMATION_TYPE_CCW;
|
||||
}
|
||||
}
|
||||
if (m_pParticleProperty->m_bTexAniRandomStartFrameFlag)
|
||||
{
|
||||
pInstance->m_byFrameIndex = random_range(0,m_pParticleProperty->GetTextureAnimationFrameCount()-1);
|
||||
}
|
||||
}
|
||||
|
||||
// Simple Update
|
||||
{
|
||||
pInstance->m_v3LastPosition = pInstance->m_v3Position - (pInstance->m_v3Velocity * fElapsedTime);
|
||||
pInstance->m_v2Scale.x = m_pParticleProperty->m_TimeEventScaleX.front().m_Value;
|
||||
pInstance->m_v2Scale.y= m_pParticleProperty->m_TimeEventScaleY.front().m_Value;
|
||||
//pInstance->m_v2Scale = m_pParticleProperty->m_TimeEventScaleXY.front().m_Value;
|
||||
#ifdef WORLD_EDITOR
|
||||
pInstance->m_Color.r = m_pParticleProperty->m_TimeEventColorRed.front().m_Value;
|
||||
pInstance->m_Color.g = m_pParticleProperty->m_TimeEventColorGreen.front().m_Value;
|
||||
pInstance->m_Color.b = m_pParticleProperty->m_TimeEventColorBlue.front().m_Value;
|
||||
pInstance->m_Color.a = m_pParticleProperty->m_TimeEventAlpha.front().m_Value;
|
||||
#else
|
||||
pInstance->m_dcColor = m_pParticleProperty->m_TimeEventColor.front().m_Value;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!pFirstInstance)
|
||||
{
|
||||
m_pData->BuildDecorator(pInstance);
|
||||
pFirstInstance = pInstance;
|
||||
}
|
||||
else
|
||||
{
|
||||
pInstance->m_pDecorator = pFirstInstance->m_pDecorator->Clone(pFirstInstance,pInstance);
|
||||
}
|
||||
|
||||
m_ParticleInstanceListVector[pInstance->m_byFrameIndex].push_back(pInstance);
|
||||
m_dwCurrentEmissionCount++;
|
||||
}
|
||||
}
|
||||
|
||||
bool CParticleSystemInstance::OnUpdate(float fElapsedTime)
|
||||
{
|
||||
bool bMakeParticle = true;
|
||||
|
||||
/////
|
||||
|
||||
if (m_fLocalTime >= m_pEmitterProperty->GetCycleLength())
|
||||
{
|
||||
if (m_pEmitterProperty->isCycleLoop() && --m_iLoopCount!=0)
|
||||
{
|
||||
if (m_iLoopCount<0)
|
||||
m_iLoopCount = 0;
|
||||
m_fLocalTime = m_fLocalTime - m_pEmitterProperty->GetCycleLength();
|
||||
}
|
||||
else
|
||||
{
|
||||
bMakeParticle = false;
|
||||
m_iLoopCount=1;
|
||||
if (GetEmissionCount()==0)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/////
|
||||
|
||||
int dwFrameIndex;
|
||||
int dwFrameCount = m_pParticleProperty->GetTextureAnimationFrameCount();
|
||||
|
||||
float fAngularVelocity;
|
||||
m_pEmitterProperty->GetEmittingAngularVelocity(m_fLocalTime,&fAngularVelocity);
|
||||
|
||||
if (fAngularVelocity && !m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
D3DXVec3TransformNormal(&m_pParticleProperty->m_v3ZAxis,&D3DXVECTOR3(0.0f,0.0f,1.0f),mc_pmatLocal);
|
||||
}
|
||||
|
||||
for (dwFrameIndex = 0; dwFrameIndex < dwFrameCount; dwFrameIndex++)
|
||||
{
|
||||
TParticleInstanceList::iterator itor = m_ParticleInstanceListVector[dwFrameIndex].begin();
|
||||
for (; itor != m_ParticleInstanceListVector[dwFrameIndex].end();)
|
||||
{
|
||||
CParticleInstance * pInstance = *itor;
|
||||
|
||||
if (!pInstance->Update(fElapsedTime,fAngularVelocity))
|
||||
{
|
||||
pInstance->DeleteThis();
|
||||
|
||||
itor = m_ParticleInstanceListVector[dwFrameIndex].erase(itor);
|
||||
m_dwCurrentEmissionCount--;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pInstance->m_byFrameIndex != dwFrameIndex)
|
||||
{
|
||||
m_ParticleInstanceListVector[dwFrameCount+pInstance->m_byFrameIndex].push_back(*itor);
|
||||
itor = m_ParticleInstanceListVector[dwFrameIndex].erase(itor);
|
||||
}
|
||||
else
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isActive() && bMakeParticle)
|
||||
CreateParticles(fElapsedTime);
|
||||
|
||||
for (dwFrameIndex = 0; dwFrameIndex < dwFrameCount; ++dwFrameIndex)
|
||||
{
|
||||
m_ParticleInstanceListVector[dwFrameIndex].splice(m_ParticleInstanceListVector[dwFrameIndex].end(),m_ParticleInstanceListVector[dwFrameIndex+dwFrameCount]);
|
||||
m_ParticleInstanceListVector[dwFrameIndex+dwFrameCount].clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace NParticleRenderer
|
||||
{
|
||||
struct TwoSideRenderer
|
||||
{
|
||||
const D3DXMATRIX * pmat;
|
||||
TwoSideRenderer(const D3DXMATRIX * pmat=NULL)
|
||||
: pmat(pmat)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat,D3DXToRadian(-30.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
|
||||
pInstance->Transform(pmat,D3DXToRadian(+30.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
|
||||
struct ThreeSideRenderer
|
||||
{
|
||||
const D3DXMATRIX * pmat;
|
||||
ThreeSideRenderer(const D3DXMATRIX * pmat=NULL)
|
||||
: pmat(pmat)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat);
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
pInstance->Transform(pmat,D3DXToRadian(-60.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
pInstance->Transform(pmat,D3DXToRadian(+60.0f));
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
|
||||
struct NormalRenderer
|
||||
{
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform();
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
struct AttachRenderer
|
||||
{
|
||||
const D3DXMATRIX* pmat;
|
||||
AttachRenderer(const D3DXMATRIX * pmat)
|
||||
: pmat(pmat)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator () (CParticleInstance * pInstance)
|
||||
{
|
||||
pInstance->Transform(pmat);
|
||||
STATEMANAGER.DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pInstance->GetParticleMeshPointer(), sizeof(TPTVertex));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnRender()
|
||||
{
|
||||
CScreen::Identity();
|
||||
STATEMANAGER.SetRenderState(D3DRS_SRCBLEND, m_pParticleProperty->m_bySrcBlendType);
|
||||
STATEMANAGER.SetRenderState(D3DRS_DESTBLEND, m_pParticleProperty->m_byDestBlendType);
|
||||
STATEMANAGER.SetTextureStageState(0,D3DTSS_COLOROP,m_pParticleProperty->m_byColorOperationType);
|
||||
if (m_pParticleProperty->m_byBillboardType < BILLBOARD_TYPE_2FACE)
|
||||
{
|
||||
if (!m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::NormalRenderer());
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::AttachRenderer(mc_pmatLocal));
|
||||
}
|
||||
}
|
||||
else if (m_pParticleProperty->m_byBillboardType == BILLBOARD_TYPE_2FACE)
|
||||
{
|
||||
if (!m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::TwoSideRenderer());
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::TwoSideRenderer(mc_pmatLocal));
|
||||
}
|
||||
}
|
||||
else if (m_pParticleProperty->m_byBillboardType == BILLBOARD_TYPE_3FACE)
|
||||
{
|
||||
if (!m_pParticleProperty->m_bAttachFlag)
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::ThreeSideRenderer());
|
||||
}
|
||||
else
|
||||
{
|
||||
ForEachParticleRendering(NParticleRenderer::ThreeSideRenderer(mc_pmatLocal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
m_pData = (CParticleSystemData *)pElement;
|
||||
|
||||
m_dwCurrentEmissionCount = 0;
|
||||
m_pParticleProperty = m_pData->GetParticlePropertyPointer();
|
||||
m_pEmitterProperty = m_pData->GetEmitterPropertyPointer();
|
||||
m_iLoopCount = m_pEmitterProperty->GetLoopCount();
|
||||
m_ParticleInstanceListVector.resize(m_pParticleProperty->GetTextureAnimationFrameCount()*2+2);
|
||||
|
||||
/////
|
||||
|
||||
assert(m_kVct_pkImgInst.empty());
|
||||
m_kVct_pkImgInst.reserve(m_pParticleProperty->m_ImageVector.size());
|
||||
for (DWORD i = 0; i < m_pParticleProperty->m_ImageVector.size(); ++i)
|
||||
{
|
||||
CGraphicImage * pImage = m_pParticleProperty->m_ImageVector[i];
|
||||
|
||||
CGraphicImageInstance* pkImgInstNew = CGraphicImageInstance::New();
|
||||
pkImgInstNew->SetImagePointer(pImage);
|
||||
m_kVct_pkImgInst.push_back(pkImgInstNew);
|
||||
}
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnInitialize()
|
||||
{
|
||||
m_dwCurrentEmissionCount = 0;
|
||||
m_iLoopCount = 0;
|
||||
m_fEmissionResidue = 0.0f;
|
||||
}
|
||||
|
||||
void CParticleSystemInstance::OnDestroy()
|
||||
{
|
||||
// 2004. 3. 1. myevan. <20><>ƼŬ <20><><EFBFBD><EFBFBD> <20><>ƾ
|
||||
TParticleInstanceListVector::iterator i;
|
||||
for(i = m_ParticleInstanceListVector.begin(); i!=m_ParticleInstanceListVector.end(); ++i)
|
||||
{
|
||||
TParticleInstanceList& rkLst_kParticleInst=*i;
|
||||
|
||||
TParticleInstanceList::iterator j;
|
||||
for(j = rkLst_kParticleInst.begin(); j!=rkLst_kParticleInst.end(); ++j)
|
||||
{
|
||||
CParticleInstance* pkParticleInst=*j;
|
||||
pkParticleInst->DeleteThis();
|
||||
}
|
||||
|
||||
rkLst_kParticleInst.clear();
|
||||
}
|
||||
m_ParticleInstanceListVector.clear();
|
||||
|
||||
std::for_each(m_kVct_pkImgInst.begin(), m_kVct_pkImgInst.end(), CGraphicImageInstance::Delete);
|
||||
m_kVct_pkImgInst.clear();
|
||||
}
|
||||
|
||||
CParticleSystemInstance::CParticleSystemInstance()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CParticleSystemInstance::~CParticleSystemInstance()
|
||||
{
|
||||
assert(m_ParticleInstanceListVector.empty());
|
||||
assert(m_kVct_pkImgInst.empty());
|
||||
}
|
85
src/EffectLib/ParticleSystemInstance.h
Normal file
85
src/EffectLib/ParticleSystemInstance.h
Normal file
@ -0,0 +1,85 @@
|
||||
#pragma once
|
||||
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "ParticleInstance.h"
|
||||
#include "ParticleProperty.h"
|
||||
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "../eterLib/GrpImageInstance.h"
|
||||
#include "EmitterProperty.h"
|
||||
|
||||
class CParticleSystemInstance : public CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CParticleSystemInstance* New();
|
||||
static void Delete(CParticleSystemInstance* pkData);
|
||||
|
||||
static CDynamicPool<CParticleSystemInstance> ms_kPool;
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
inline void ForEachParticleRendering(T & FunObj)
|
||||
{
|
||||
DWORD dwFrameIndex;
|
||||
for(dwFrameIndex=0; dwFrameIndex<m_kVct_pkImgInst.size(); dwFrameIndex++)
|
||||
{
|
||||
STATEMANAGER.SetTexture(0, m_kVct_pkImgInst[dwFrameIndex]->GetTextureReference().GetD3DTexture());
|
||||
TParticleInstanceList::iterator itor = m_ParticleInstanceListVector[dwFrameIndex].begin();
|
||||
for (; itor != m_ParticleInstanceListVector[dwFrameIndex].end(); ++itor)
|
||||
{
|
||||
if (!InFrustum(*itor))
|
||||
return;
|
||||
FunObj(*itor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CParticleSystemInstance();
|
||||
virtual ~CParticleSystemInstance();
|
||||
|
||||
void OnSetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void CreateParticles(float fElapsedTime);
|
||||
|
||||
inline bool InFrustum(CParticleInstance * pInstance)
|
||||
{
|
||||
if (m_pParticleProperty->m_bAttachFlag)
|
||||
return CScreen::GetFrustum().ViewVolumeTest(Vector3d(
|
||||
pInstance->m_v3Position.x + mc_pmatLocal->_41,
|
||||
pInstance->m_v3Position.y + mc_pmatLocal->_42,
|
||||
pInstance->m_v3Position.z + mc_pmatLocal->_43
|
||||
),pInstance->GetRadiusApproximation())!=VS_OUTSIDE;
|
||||
else
|
||||
return CScreen::GetFrustum().ViewVolumeTest(Vector3d(pInstance->m_v3Position.x,pInstance->m_v3Position.y,pInstance->m_v3Position.z),pInstance->GetRadiusApproximation())!=VS_OUTSIDE;
|
||||
}
|
||||
|
||||
DWORD GetEmissionCount();
|
||||
|
||||
protected:
|
||||
void OnInitialize();
|
||||
void OnDestroy();
|
||||
|
||||
bool OnUpdate(float fElapsedTime);
|
||||
void OnRender();
|
||||
|
||||
protected:
|
||||
float m_fEmissionResidue;
|
||||
|
||||
DWORD m_dwCurrentEmissionCount;
|
||||
int m_iLoopCount;
|
||||
|
||||
typedef std::list<CParticleInstance*> TParticleInstanceList;
|
||||
typedef std::vector<TParticleInstanceList> TParticleInstanceListVector;
|
||||
TParticleInstanceListVector m_ParticleInstanceListVector;
|
||||
|
||||
typedef std::vector<CGraphicImageInstance*> TImageInstanceVector;
|
||||
TImageInstanceVector m_kVct_pkImgInst;
|
||||
|
||||
CParticleSystemData * m_pData;
|
||||
|
||||
CParticleProperty * m_pParticleProperty;
|
||||
CEmitterProperty * m_pEmitterProperty;
|
||||
};
|
164
src/EffectLib/SimpleLightData.cpp
Normal file
164
src/EffectLib/SimpleLightData.cpp
Normal file
@ -0,0 +1,164 @@
|
||||
#include "StdAfx.h"
|
||||
#include "SimpleLightData.h"
|
||||
|
||||
CDynamicPool<CLightData> CLightData::ms_kPool;
|
||||
|
||||
void CLightData::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CLightData* CLightData::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CLightData::Delete(CLightData* pkData)
|
||||
{
|
||||
pkData->Clear();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CLightData::OnClear()
|
||||
{
|
||||
m_fMaxRange = 300.0f;
|
||||
|
||||
m_TimeEventTableRange.clear();
|
||||
|
||||
m_cAmbient.r = 0.5f;
|
||||
m_cAmbient.g = 0.5f;
|
||||
m_cAmbient.b = 0.5f;
|
||||
m_cAmbient.a = 1.0f;
|
||||
m_cDiffuse.r = 0.0f;
|
||||
m_cDiffuse.g = 0.0f;
|
||||
m_cDiffuse.b = 0.0f;
|
||||
m_cDiffuse.a = 1.0f;
|
||||
|
||||
m_fDuration = 1.0f;
|
||||
|
||||
m_fAttenuation0 = 0.0f;
|
||||
m_fAttenuation1 = 0.1f;
|
||||
m_fAttenuation2 = 0.0f;
|
||||
|
||||
m_bLoopFlag = false;
|
||||
m_iLoopCount = 0;
|
||||
}
|
||||
void CLightData::GetRange(float fTime, float& rRange)
|
||||
{
|
||||
if (m_TimeEventTableRange.empty())
|
||||
{
|
||||
rRange = 1.0f * m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
GetTimeEventBlendValue(fTime, m_TimeEventTableRange, &rRange);
|
||||
rRange *= m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
return;
|
||||
/*
|
||||
float vecLastRange = m_TimeEventTableRange[0].m_Value;
|
||||
|
||||
for (DWORD dwIndex = 0; dwIndex < m_TimeEventTableRange.size(); ++dwIndex)
|
||||
{
|
||||
if(fTime < m_TimeEventTableRange[dwIndex].m_fTime)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (dwIndex >= m_TimeEventTableRange.size())
|
||||
{
|
||||
rRange = m_TimeEventTableRange[m_TimeEventTableRange.size()-1].m_Value * m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
TTimeEventTypeFloat & rEffectRange = m_TimeEventTableRange[dwIndex];
|
||||
TTimeEventTypeFloat & rPrevEffectRange = m_TimeEventTableRange[dwIndex-1];
|
||||
|
||||
float Head = fabs(rEffectRange.m_fTime - fTime) / fabs(rEffectRange.m_fTime - rPrevEffectRange.m_fTime);
|
||||
float Tail = 1.0f - fabs(rEffectRange.m_fTime - fTime) / fabs(rEffectRange.m_fTime - rPrevEffectRange.m_fTime);
|
||||
rRange = ((rPrevEffectRange.m_Value*Head) + (rEffectRange.m_Value*Tail) )*m_fMaxRange;
|
||||
if (rRange<0.0f)
|
||||
rRange = 0.0f;
|
||||
*/
|
||||
}
|
||||
|
||||
bool CLightData::OnIsData()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CLightData::OnLoadScript(CTextFileLoader & rTextFileLoader)
|
||||
{
|
||||
if (!rTextFileLoader.GetTokenFloat("duration",&m_fDuration))
|
||||
m_fDuration = 1.0f;
|
||||
|
||||
if (!rTextFileLoader.GetTokenBoolean("loopflag",&m_bLoopFlag))
|
||||
m_bLoopFlag = false;
|
||||
|
||||
if (!rTextFileLoader.GetTokenInteger("loopcount",&m_iLoopCount))
|
||||
m_iLoopCount = 0;
|
||||
|
||||
if (!rTextFileLoader.GetTokenColor("ambientcolor",&m_cAmbient))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenColor("diffusecolor",&m_cDiffuse))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("maxrange",&m_fMaxRange))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("attenuation0",&m_fAttenuation0))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("attenuation1",&m_fAttenuation1))
|
||||
return FALSE;
|
||||
|
||||
if (!rTextFileLoader.GetTokenFloat("attenuation2",&m_fAttenuation2))
|
||||
return FALSE;
|
||||
|
||||
if (!GetTokenTimeEventFloat(rTextFileLoader,"timeeventrange",&m_TimeEventTableRange))
|
||||
{
|
||||
m_TimeEventTableRange.clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CLightData::CLightData()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
CLightData::~CLightData()
|
||||
{
|
||||
}
|
||||
|
||||
float CLightData::GetDuration()
|
||||
{
|
||||
return m_fDuration;
|
||||
}
|
||||
void CLightData::InitializeLight(D3DLIGHT8& light)
|
||||
{
|
||||
light.Type = D3DLIGHT_POINT;
|
||||
|
||||
light.Ambient = m_cAmbient;
|
||||
light.Diffuse = m_cDiffuse;
|
||||
light.Attenuation0 = m_fAttenuation0;
|
||||
light.Attenuation1 = m_fAttenuation1;
|
||||
light.Attenuation2 = m_fAttenuation2;
|
||||
|
||||
|
||||
D3DXVECTOR3 position;
|
||||
GetPosition( 0.0f, position);
|
||||
light.Position = position;
|
||||
|
||||
GetRange(0.0f, light.Range);
|
||||
}
|
57
src/EffectLib/SimpleLightData.h
Normal file
57
src/EffectLib/SimpleLightData.h
Normal file
@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "Type.h"
|
||||
#include "EffectElementBase.h"
|
||||
|
||||
class CLightData : public CEffectElementBase
|
||||
{
|
||||
friend class CLightInstance;
|
||||
public:
|
||||
CLightData();
|
||||
virtual ~CLightData();
|
||||
|
||||
void GetRange(float fTime, float& rRange);
|
||||
float GetDuration();
|
||||
BOOL isLoop()
|
||||
{
|
||||
return m_bLoopFlag;
|
||||
}
|
||||
int GetLoopCount()
|
||||
{
|
||||
return m_iLoopCount;
|
||||
}
|
||||
void InitializeLight(D3DLIGHT8& light);
|
||||
|
||||
protected:
|
||||
void OnClear();
|
||||
bool OnIsData();
|
||||
|
||||
BOOL OnLoadScript(CTextFileLoader & rTextFileLoader);
|
||||
|
||||
protected:
|
||||
float m_fMaxRange;
|
||||
float m_fDuration;
|
||||
TTimeEventTableFloat m_TimeEventTableRange;
|
||||
|
||||
D3DXCOLOR m_cAmbient;
|
||||
D3DXCOLOR m_cDiffuse;
|
||||
|
||||
BOOL m_bLoopFlag;
|
||||
int m_iLoopCount;
|
||||
|
||||
float m_fAttenuation0;
|
||||
float m_fAttenuation1;
|
||||
float m_fAttenuation2;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CLightData* New();
|
||||
static void Delete(CLightData* pkData);
|
||||
|
||||
static CDynamicPool<CLightData> ms_kPool;
|
||||
};
|
138
src/EffectLib/SimpleLightInstance.cpp
Normal file
138
src/EffectLib/SimpleLightInstance.cpp
Normal file
@ -0,0 +1,138 @@
|
||||
#include "Stdafx.h"
|
||||
#include "../eterLib/GrpLightManager.h"
|
||||
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
CDynamicPool<CLightInstance> CLightInstance::ms_kPool;
|
||||
|
||||
void CLightInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
||||
|
||||
CLightInstance* CLightInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CLightInstance::Delete(CLightInstance* pkData)
|
||||
{
|
||||
pkData->Destroy();
|
||||
ms_kPool.Free(pkData);
|
||||
}
|
||||
|
||||
void CLightInstance::OnSetDataPointer(CEffectElementBase * pElement)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_pData = ((CLightData*)pElement);
|
||||
|
||||
m_iLoopCount = m_pData->GetLoopCount();
|
||||
|
||||
D3DLIGHT8 Light;
|
||||
m_pData->InitializeLight(Light);
|
||||
CLightManager::Instance().RegisterLight(LIGHT_TYPE_DYNAMIC, &m_LightID, Light);
|
||||
}
|
||||
|
||||
bool CLightInstance::OnUpdate(float fElapsedTime)
|
||||
{
|
||||
if (!isActive())
|
||||
{
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_fLocalTime >= m_pData->GetDuration())
|
||||
{
|
||||
if (m_pData->isLoop() && --m_iLoopCount!=0)
|
||||
{
|
||||
if (m_iLoopCount<0)
|
||||
m_iLoopCount = 0;
|
||||
m_fLocalTime -= m_pData->GetDuration();
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy();
|
||||
m_iLoopCount = 1;
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (!m_pData->isLoop())
|
||||
{
|
||||
OnClear();
|
||||
return false;
|
||||
}
|
||||
m_fLocalTime -= m_pData->GetDuration();
|
||||
*/
|
||||
}
|
||||
|
||||
CLight * pLight = CLightManager::Instance().GetLight(m_LightID);
|
||||
|
||||
if (pLight)
|
||||
{
|
||||
pLight->SetAmbientColor(m_pData->m_cAmbient.r, m_pData->m_cAmbient.g, m_pData->m_cAmbient.b, m_pData->m_cAmbient.a);
|
||||
pLight->SetDiffuseColor(m_pData->m_cDiffuse.r, m_pData->m_cDiffuse.g, m_pData->m_cDiffuse.b, m_pData->m_cDiffuse.a);
|
||||
|
||||
/*if (m_pData->m_TimeEventTableRange.size()
|
||||
&& m_fLocalTime>=m_pData->GetDuration()*m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime)
|
||||
{
|
||||
while(m_dwRangeIndex<m_pData->m_TimeEventTableRange.size()
|
||||
&& m_fLocalTime>=m_pData->GetDuration()*m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime)
|
||||
m_dwRangeIndex++;
|
||||
float fLastTime;
|
||||
float fLastRange=m_pData->m_TimeEventTableRange[m_pData->m_TimeEventTableRange.size()-1].m_Value;
|
||||
if (m_dwRangeIndex == m_pData->m_TimeEventTableRange.size())
|
||||
fLastTime = 1.0f;
|
||||
else
|
||||
{
|
||||
fLastTime = m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime;
|
||||
fLastRange = m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_Value;
|
||||
}
|
||||
m_dwRangeIndex--;
|
||||
pLight->BlendRange(fLastRange*m_pData->m_fMaxRange,
|
||||
(fLastTime-m_pData->m_TimeEventTableRange[m_dwRangeIndex].m_fTime)*m_pData->GetDuration());
|
||||
m_dwRangeIndex++;
|
||||
}*/
|
||||
|
||||
float fRange;
|
||||
m_pData->GetRange(m_fLocalTime, fRange);
|
||||
pLight->SetRange(fRange);
|
||||
|
||||
D3DXVECTOR3 pos;
|
||||
m_pData->GetPosition(m_fLocalTime,pos);
|
||||
D3DXVec3TransformCoord(&pos,&pos,mc_pmatLocal);
|
||||
pLight->SetPosition(pos.x,pos.y,pos.z);
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLightInstance::OnRender()
|
||||
{
|
||||
//OnUpdate(0);
|
||||
}
|
||||
|
||||
void CLightInstance::OnInitialize()
|
||||
{
|
||||
m_LightID = 0;
|
||||
m_dwRangeIndex = 0;
|
||||
}
|
||||
|
||||
void CLightInstance::OnDestroy()
|
||||
{
|
||||
if (m_LightID)
|
||||
{
|
||||
CLightManager::Instance().DeleteLight(m_LightID);
|
||||
}
|
||||
}
|
||||
|
||||
CLightInstance::CLightInstance()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CLightInstance::~CLightInstance()
|
||||
{
|
||||
Destroy();
|
||||
}
|
39
src/EffectLib/SimpleLightInstance.h
Normal file
39
src/EffectLib/SimpleLightInstance.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterLib/GrpScreen.h"
|
||||
|
||||
#include "EffectElementBaseInstance.h"
|
||||
#include "SimpleLightData.h"
|
||||
|
||||
class CLightInstance : public CEffectElementBaseInstance
|
||||
{
|
||||
public:
|
||||
friend class CLightData;
|
||||
|
||||
CLightInstance();
|
||||
virtual ~CLightInstance();
|
||||
|
||||
protected:
|
||||
|
||||
void OnSetDataPointer(CEffectElementBase * pElement);
|
||||
|
||||
void OnInitialize();
|
||||
void OnDestroy();
|
||||
|
||||
bool OnUpdate(float fElapsedTime);
|
||||
void OnRender();
|
||||
|
||||
DWORD m_LightID;
|
||||
CLightData * m_pData;
|
||||
DWORD m_dwRangeIndex;
|
||||
|
||||
DWORD m_iLoopCount;
|
||||
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CLightInstance* New();
|
||||
static void Delete(CLightInstance* pkData);
|
||||
|
||||
static CDynamicPool<CLightInstance> ms_kPool;
|
||||
};
|
2
src/EffectLib/StdAfx.cpp
Normal file
2
src/EffectLib/StdAfx.cpp
Normal file
@ -0,0 +1,2 @@
|
||||
#include "StdAfx.h"
|
||||
|
40
src/EffectLib/StdAfx.h
Normal file
40
src/EffectLib/StdAfx.h
Normal file
@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
|
||||
//#include <crtdbg.h>
|
||||
|
||||
#include "../eterBase/StdAfx.h"
|
||||
|
||||
#include "../eterBase/Utils.h"
|
||||
#include "../eterBase/Timer.h"
|
||||
#include "../eterBase/CRC32.h"
|
||||
#include "../eterBase/Debug.h"
|
||||
|
||||
#include "../eterLib/StdAfx.h"
|
||||
#include "../eterLib/TextFileLoader.h"
|
||||
|
||||
#include "../milesLib/StdAfx.h"
|
||||
|
||||
/*
|
||||
#include "FrameController.h"
|
||||
|
||||
#include "EffectElementBase.h"
|
||||
#include "EffectElementBaseInstance.h"
|
||||
|
||||
#include "ParticleProperty.h"
|
||||
#include "ParticleInstance.h"
|
||||
#include "EmitterProperty.h"
|
||||
|
||||
#include "ParticleSystemData.h"
|
||||
#include "ParticleSystemInstance.h"
|
||||
|
||||
#include "EffectMesh.h"
|
||||
#include "EffectMeshInstance.h"
|
||||
|
||||
#include "SimpleLightData.h"
|
||||
#include "SimpleLightInstance.h"
|
||||
|
||||
#include "EffectData.h"
|
||||
#include "EffectInstance.h"
|
||||
|
||||
#include "EffectManager.h"
|
||||
*/
|
38
src/EffectLib/Type.cpp
Normal file
38
src/EffectLib/Type.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Type.h"
|
||||
|
||||
BOOL GetTokenTimeEventFloat(CTextFileLoader & rTextFileLoader, const char * c_szKey, TTimeEventTableFloat * pTimeEventTableFloat)
|
||||
{
|
||||
CTokenVector * pTokenVector;
|
||||
if (!rTextFileLoader.GetTokenVector(c_szKey, &pTokenVector))
|
||||
return FALSE;
|
||||
|
||||
pTimeEventTableFloat->clear();
|
||||
pTimeEventTableFloat->resize(pTokenVector->size() / 2);
|
||||
|
||||
DWORD dwIndex = 0;
|
||||
for (DWORD i = 0; i < pTokenVector->size(); i+=2, ++dwIndex)
|
||||
{
|
||||
pTimeEventTableFloat->at(dwIndex).m_fTime = atof(pTokenVector->at(i).c_str());
|
||||
pTimeEventTableFloat->at(dwIndex).m_Value = atof(pTokenVector->at(i+1).c_str());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void InsertItemTimeEventFloat(TTimeEventTableFloat * pTable, float fTime, float fValue)
|
||||
{
|
||||
TTimeEventTableFloat::iterator itor = pTable->begin();
|
||||
for (; itor != pTable->end(); ++itor)
|
||||
{
|
||||
TTimeEventTypeFloat & rTimeEvent = *itor;
|
||||
if (rTimeEvent.m_fTime > fTime)
|
||||
break;
|
||||
}
|
||||
|
||||
TTimeEventTypeFloat TimeEvent;
|
||||
TimeEvent.m_fTime = fTime;
|
||||
TimeEvent.m_Value = fValue;
|
||||
|
||||
pTable->insert(itor, TimeEvent);
|
||||
}
|
283
src/EffectLib/Type.h
Normal file
283
src/EffectLib/Type.h
Normal file
@ -0,0 +1,283 @@
|
||||
#pragma once
|
||||
|
||||
#define Clamp(x, min, max) x = (x<min ? min : x<max ? x : max);
|
||||
#define GRAVITY D3DXVECTOR3(0.0f, 0.0f, -9.8f)
|
||||
|
||||
#define MAX_FRAME 20
|
||||
#define MAX_TEXTURE 20
|
||||
|
||||
typedef struct _FVF_POINT
|
||||
{
|
||||
float x, y, z;
|
||||
} FVF_POINT;
|
||||
|
||||
#ifndef D3DFVF_POINT
|
||||
#define D3DFVF_POINT (D3DFVF_XYZ)
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _FVF_PT
|
||||
{
|
||||
float x, y, z;
|
||||
float tu, tv;
|
||||
} FVF_PT;
|
||||
|
||||
#ifndef D3DFVF_PT
|
||||
#define D3DFVF_PT (D3DFVF_XYZ|D3DFVF_TEX1)
|
||||
#endif
|
||||
|
||||
typedef struct _FVF_PDT
|
||||
{
|
||||
float x, y, z;
|
||||
DWORD color;
|
||||
float tu, tv;
|
||||
} FVF_PDT;
|
||||
|
||||
#ifndef D3DFVF_PDT
|
||||
#define D3DFVF_PDT (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
#endif
|
||||
|
||||
inline FVF_PDT _FVF_PDT(float x, float y, float z, DWORD dif, float u, float v)
|
||||
{
|
||||
FVF_PDT result;
|
||||
result.x = x; result.y = y; result.z = z; result.color = dif; result.tu = u; result.tv = v;
|
||||
return result;
|
||||
}
|
||||
|
||||
enum EEffectType
|
||||
{
|
||||
EFFECT_TYPE_PARTICLE = 1,
|
||||
EFFECT_TYPE_ANIMATION_TEXTURE = 2,
|
||||
EFFECT_TYPE_MESH = 3,
|
||||
EFFECT_TYPE_SIMPLE_LIGHT = 4,
|
||||
};
|
||||
|
||||
|
||||
|
||||
enum EMeshBillBoardType
|
||||
{
|
||||
MESH_BILLBOARD_TYPE_NONE,
|
||||
|
||||
MESH_BILLBOARD_TYPE_ALL,
|
||||
MESH_BILLBOARD_TYPE_Y,
|
||||
|
||||
MESH_BILLBOARD_TYPE_MOVE
|
||||
};
|
||||
|
||||
enum EBillBoardType
|
||||
{
|
||||
BILLBOARD_TYPE_NONE,
|
||||
|
||||
BILLBOARD_TYPE_ALL,
|
||||
BILLBOARD_TYPE_Y,
|
||||
|
||||
BILLBOARD_TYPE_LIE, // <20>ٴڿ<D9B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
BILLBOARD_TYPE_2FACE, // / and \
|
||||
BILLBOARD_TYPE_3FACE, // / and \ and -
|
||||
|
||||
//BILLBOARD_TYPE_RAY, // <20>ܻ<EFBFBD>
|
||||
|
||||
};
|
||||
|
||||
enum EMovingType
|
||||
{
|
||||
MOVING_TYPE_DIRECT,
|
||||
MOVING_TYPE_BEZIER_CURVE,
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
typedef struct SEffectPosition
|
||||
{
|
||||
float m_fTime;
|
||||
|
||||
D3DXVECTOR3 m_vecPosition;
|
||||
|
||||
// For Bezier Curve
|
||||
int m_iMovingType;
|
||||
D3DXVECTOR3 m_vecControlPoint;
|
||||
|
||||
} TEffectPosition;
|
||||
|
||||
inline bool operator < (const SEffectPosition & lhs, const SEffectPosition & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs.m_fTime;
|
||||
}
|
||||
inline bool operator < (const float & lhs, const SEffectPosition & rhs)
|
||||
{
|
||||
return lhs < rhs.m_fTime;
|
||||
}
|
||||
inline bool operator < (const SEffectPosition & lhs, const float & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
class CTimeEvent
|
||||
{
|
||||
public:
|
||||
CTimeEvent(){}
|
||||
~CTimeEvent(){}
|
||||
|
||||
float m_fTime;
|
||||
T m_Value;
|
||||
};
|
||||
#define AG_MASK 0xff00ff00
|
||||
#define RB_MASK 0x00ff00ff
|
||||
|
||||
struct DWORDCOLOR
|
||||
{
|
||||
DWORD m_dwColor;
|
||||
|
||||
DWORDCOLOR()
|
||||
{
|
||||
}
|
||||
DWORDCOLOR(const DWORDCOLOR& r)
|
||||
: m_dwColor(r.m_dwColor)
|
||||
{}
|
||||
|
||||
DWORDCOLOR& operator = (const DWORDCOLOR& r)
|
||||
{
|
||||
m_dwColor = r.m_dwColor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
DWORDCOLOR& operator *= (float f)
|
||||
{
|
||||
DWORD idx = DWORD(f * 256);
|
||||
m_dwColor =
|
||||
(((DWORD)(((m_dwColor & AG_MASK)>>8) * idx)) & AG_MASK)
|
||||
+((DWORD)(((m_dwColor & RB_MASK) * idx)>>8) & RB_MASK);
|
||||
//m_dwColor =
|
||||
// ((DWORD)((m_dwColor & AG_MASK) * f) & AG_MASK)
|
||||
// +((DWORD)((m_dwColor & RB_MASK) * f) & RB_MASK);
|
||||
return *this;
|
||||
}
|
||||
DWORDCOLOR& operator += (const DWORDCOLOR& r)
|
||||
{
|
||||
m_dwColor += r.m_dwColor;
|
||||
return *this;
|
||||
}
|
||||
operator DWORD()
|
||||
{
|
||||
return m_dwColor;
|
||||
}
|
||||
};
|
||||
#undef AG_MASK
|
||||
#undef RB_MASK
|
||||
|
||||
inline DWORDCOLOR operator * (DWORDCOLOR dc, float f)
|
||||
{
|
||||
DWORDCOLOR tmp(dc);
|
||||
tmp *= f;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
inline DWORDCOLOR operator * (float f, DWORDCOLOR dc)
|
||||
{
|
||||
DWORDCOLOR tmp(dc);
|
||||
tmp *= f;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__forceinline bool operator < (const CTimeEvent<T> & lhs, const CTimeEvent<T> & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs.m_fTime;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__forceinline bool operator < (const CTimeEvent<T> & lhs, const float & rhs)
|
||||
{
|
||||
return lhs.m_fTime < rhs;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
__forceinline bool operator < (const float & lhs, const CTimeEvent<T> & rhs)
|
||||
{
|
||||
return lhs < rhs.m_fTime;
|
||||
}
|
||||
|
||||
typedef CTimeEvent<char> TTimeEventTypeCharacter;
|
||||
typedef CTimeEvent<short> TTimeEventTypeShort;
|
||||
typedef CTimeEvent<float> TTimeEventTypeFloat;
|
||||
typedef CTimeEvent<WORD> TTimeEventTypeWord;
|
||||
typedef CTimeEvent<DWORD> TTimeEventTypeDoubleWord;
|
||||
typedef CTimeEvent<DWORDCOLOR> TTimeEventTypeColor;
|
||||
typedef CTimeEvent<D3DXVECTOR2> TTimeEventTypeVector2;
|
||||
typedef CTimeEvent<D3DXVECTOR3> TTimeEventTypeVector3;
|
||||
|
||||
typedef std::vector<float> TTimeEventTable;
|
||||
typedef std::vector<TEffectPosition> TTimeEventTablePosition;
|
||||
typedef std::vector<TTimeEventTypeCharacter> TTimeEventTableCharacter;
|
||||
typedef std::vector<TTimeEventTypeShort> TTimeEventTableShort;
|
||||
typedef std::vector<TTimeEventTypeFloat> TTimeEventTableFloat;
|
||||
typedef std::vector<TTimeEventTypeWord> TTimeEventTableWord;
|
||||
typedef std::vector<TTimeEventTypeDoubleWord> TTimeEventTableDoubleWord;
|
||||
typedef std::vector<TTimeEventTypeColor> TTimeEventTableColor;
|
||||
typedef std::vector<TTimeEventTypeVector2> TTimeEventTableVector2;
|
||||
typedef std::vector<TTimeEventTypeVector3> TTimeEventTableVector3;
|
||||
|
||||
|
||||
// NOTE : TimeEventValue <20>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ѱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ƾ<EFBFBD> <20>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ۼ<EFBFBD> <20>߽<EFBFBD><DFBD>ϴ<EFBFBD>. - [levites]
|
||||
|
||||
template <typename T>
|
||||
__forceinline void GetTimeEventBlendValue(float fElapsedTime, std::vector<CTimeEvent<T> >& rVector, T * pReturnValue)
|
||||
{
|
||||
if (rVector.empty())
|
||||
{
|
||||
*pReturnValue = T();
|
||||
return;
|
||||
}
|
||||
|
||||
if(rVector.begin()+1==rVector.end())
|
||||
{
|
||||
*pReturnValue = rVector.front().m_Value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fElapsedTime < rVector.front().m_fTime)
|
||||
{
|
||||
*pReturnValue = rVector.front().m_Value;
|
||||
return;
|
||||
}
|
||||
|
||||
if (fElapsedTime > rVector.back().m_fTime)
|
||||
{
|
||||
*pReturnValue = rVector.back().m_Value;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef typename std::vector<CTimeEvent<T> >::iterator iterator;
|
||||
|
||||
std::pair<iterator, iterator> result = std::equal_range(rVector.begin(), rVector.end(), fElapsedTime);
|
||||
|
||||
if (result.first != result.second)
|
||||
*pReturnValue = result.first->m_Value;
|
||||
else
|
||||
{
|
||||
--result.first;
|
||||
float Head = (result.second->m_fTime - fElapsedTime) / (result.second->m_fTime - result.first->m_fTime);
|
||||
*pReturnValue = T((result.first->m_Value-result.second->m_Value)*Head+(result.second->m_Value));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extern BOOL GetTokenTimeEventFloat(CTextFileLoader & rTextFileLoader, const char * c_szKey, TTimeEventTableFloat * pTimeEventTableFloat);
|
||||
//extern void InsertItemTimeEventFloat(TTimeEventTableFloat * pTable, float fTime, float fValue);
|
||||
|
||||
template <typename T>
|
||||
void InsertItemTimeEvent(std::vector<CTimeEvent<T> > * pTable, float fTime, T fValue)
|
||||
{
|
||||
typedef std::vector<CTimeEvent<T> >::iterator iterator;
|
||||
|
||||
iterator itor = std::lower_bound(pTable->begin(), pTable->end(), fTime);
|
||||
|
||||
CTimeEvent<T> TimeEvent;
|
||||
TimeEvent.m_fTime = fTime;
|
||||
TimeEvent.m_Value = fValue;
|
||||
|
||||
pTable->insert(itor, TimeEvent);
|
||||
}
|
299
src/EterBase/CPostIt.cpp
Normal file
299
src/EterBase/CPostIt.cpp
Normal file
@ -0,0 +1,299 @@
|
||||
#include "StdAfx.h"
|
||||
#include "CPostIt.h"
|
||||
#include "../eterBase/utils.h"
|
||||
|
||||
class _CPostItMemoryBlock
|
||||
{
|
||||
public:
|
||||
_CPostItMemoryBlock( void );
|
||||
~_CPostItMemoryBlock( void );
|
||||
|
||||
BOOL Assign( HANDLE hBlock );
|
||||
HANDLE CreateHandle( void );
|
||||
BOOL DestroyHandle( void );
|
||||
|
||||
LPSTR Find( LPCSTR lpszKeyName );
|
||||
BOOL Put( LPCSTR lpBuffer );
|
||||
BOOL Put( LPCSTR lpszKeyName, LPCSTR lpBuffer );
|
||||
BOOL Get( LPCSTR lpszKeyName, LPSTR lpBuffer, DWORD nSize );
|
||||
|
||||
protected:
|
||||
typedef std::list<CHAR *> StrList;
|
||||
typedef StrList::iterator StrListItr;
|
||||
|
||||
HANDLE m_hHandle;
|
||||
StrList m_StrList;
|
||||
};
|
||||
|
||||
CPostIt::CPostIt( LPCSTR szAppName ) : m_pMemoryBlock(NULL), m_bModified(FALSE)
|
||||
{
|
||||
Init( szAppName );
|
||||
}
|
||||
|
||||
CPostIt::~CPostIt( void )
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
BOOL CPostIt::Init( LPCSTR szAppName )
|
||||
{
|
||||
if( szAppName == NULL || !*szAppName ) {
|
||||
strcpy( m_szClipFormatName, "YMCF" );
|
||||
} else {
|
||||
strcpy( m_szClipFormatName, "YMCF_" );
|
||||
strcat( m_szClipFormatName, szAppName );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CPostIt::CopyTo( CPostIt *pPostIt, LPCSTR lpszKeyName )
|
||||
{
|
||||
if( m_pMemoryBlock == NULL )
|
||||
return FALSE;
|
||||
LPSTR szText = m_pMemoryBlock->Find( lpszKeyName );
|
||||
if( szText == NULL )
|
||||
return FALSE;
|
||||
return pPostIt->Set( szText );
|
||||
}
|
||||
|
||||
BOOL CPostIt::Flush( void )
|
||||
{
|
||||
if( m_bModified == FALSE )
|
||||
return FALSE;
|
||||
if( m_pMemoryBlock == NULL )
|
||||
return FALSE;
|
||||
UINT uDGPFormat;
|
||||
|
||||
uDGPFormat = ::RegisterClipboardFormatA( m_szClipFormatName );
|
||||
if( ::OpenClipboard( NULL ) == FALSE )
|
||||
return FALSE;
|
||||
if( ::SetClipboardData( uDGPFormat, m_pMemoryBlock->CreateHandle() ) == NULL ) {
|
||||
// DWORD dwLastError = ::GetLastError();
|
||||
m_pMemoryBlock->DestroyHandle();
|
||||
::CloseClipboard();
|
||||
m_bModified = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
::CloseClipboard();
|
||||
m_bModified = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CPostIt::Empty( void )
|
||||
{
|
||||
SAFE_DELETE( m_pMemoryBlock );
|
||||
|
||||
UINT uDGPFormat;
|
||||
|
||||
uDGPFormat = ::RegisterClipboardFormatA( m_szClipFormatName );
|
||||
if( ::OpenClipboard( NULL ) == FALSE )
|
||||
return;
|
||||
HANDLE hClipboardMemory = ::GetClipboardData( uDGPFormat );
|
||||
if( hClipboardMemory ) {
|
||||
// ::GlobalFree( hClipboardMemory );
|
||||
::SetClipboardData( uDGPFormat, NULL );
|
||||
}
|
||||
::CloseClipboard();
|
||||
|
||||
m_bModified = FALSE;
|
||||
}
|
||||
|
||||
void CPostIt::Destroy( void )
|
||||
{
|
||||
Flush();
|
||||
SAFE_DELETE( m_pMemoryBlock );
|
||||
}
|
||||
|
||||
BOOL CPostIt::Set( LPCSTR lpszKeyName, LPCSTR lpBuffer )
|
||||
{
|
||||
if( m_pMemoryBlock == NULL )
|
||||
m_pMemoryBlock = new _CPostItMemoryBlock;
|
||||
m_pMemoryBlock->Put( lpszKeyName, lpBuffer );
|
||||
m_bModified = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CPostIt::Set( LPCSTR lpszKeyName, DWORD dwValue )
|
||||
{
|
||||
CHAR szValue[12];
|
||||
|
||||
_snprintf( szValue, 12, "%d", dwValue );
|
||||
return Set( lpszKeyName, szValue );
|
||||
}
|
||||
|
||||
BOOL CPostIt::Set( LPCSTR lpBuffer )
|
||||
{
|
||||
if( lpBuffer == NULL )
|
||||
return FALSE;
|
||||
if( m_pMemoryBlock == NULL )
|
||||
m_pMemoryBlock = new _CPostItMemoryBlock;
|
||||
m_pMemoryBlock->Put( lpBuffer );
|
||||
m_bModified = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CPostIt::Get( LPCSTR lpszKeyName, LPSTR lpBuffer, DWORD nSize )
|
||||
{
|
||||
if( m_pMemoryBlock == NULL ) {
|
||||
UINT uDGPFormat;
|
||||
|
||||
uDGPFormat = ::RegisterClipboardFormatA( m_szClipFormatName );
|
||||
if( ::OpenClipboard( NULL ) == FALSE )
|
||||
return FALSE;
|
||||
|
||||
HANDLE hClipboardMemory = ::GetClipboardData( uDGPFormat );
|
||||
|
||||
if( hClipboardMemory == NULL ) {
|
||||
::CloseClipboard();
|
||||
return FALSE;
|
||||
}
|
||||
m_pMemoryBlock = new _CPostItMemoryBlock;
|
||||
m_pMemoryBlock->Assign( hClipboardMemory );
|
||||
|
||||
::CloseClipboard();
|
||||
}
|
||||
|
||||
return m_pMemoryBlock->Get( lpszKeyName, lpBuffer, nSize );
|
||||
}
|
||||
|
||||
_CPostItMemoryBlock::_CPostItMemoryBlock( void ) : m_hHandle( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
_CPostItMemoryBlock::~_CPostItMemoryBlock( void )
|
||||
{
|
||||
for( StrListItr itr = m_StrList.begin(); itr != m_StrList.end(); ) {
|
||||
LPSTR lpszText = *itr;
|
||||
SAFE_DELETE_ARRAY( lpszText );
|
||||
itr = m_StrList.erase( itr );
|
||||
}
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Assign( HANDLE hBlock )
|
||||
{
|
||||
if( hBlock == NULL || hBlock == INVALID_HANDLE_VALUE )
|
||||
return FALSE;
|
||||
LPBYTE lpBuffer = (LPBYTE) ::GlobalLock( hBlock );
|
||||
|
||||
if( lpBuffer == NULL )
|
||||
return FALSE;
|
||||
DWORD dwCount = *((LPDWORD) lpBuffer); lpBuffer += sizeof( DWORD );
|
||||
for( DWORD dwI=0; dwI < dwCount; dwI++ ) {
|
||||
WORD wLen = *((LPWORD) lpBuffer); lpBuffer += sizeof( WORD );
|
||||
|
||||
LPSTR lpszText = new CHAR[ wLen + 1 ];
|
||||
::CopyMemory( lpszText, lpBuffer, wLen );
|
||||
lpszText[ wLen ] = '\0';
|
||||
|
||||
lpBuffer += wLen;
|
||||
|
||||
Put( lpszText );
|
||||
}
|
||||
::GlobalUnlock( hBlock );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HANDLE _CPostItMemoryBlock::CreateHandle( void )
|
||||
{
|
||||
if( m_StrList.size() == 0 )
|
||||
return INVALID_HANDLE_VALUE;
|
||||
DWORD dwBlockSize = sizeof( DWORD );
|
||||
StrListItr itr;
|
||||
|
||||
// Calculation for Memory Block Size
|
||||
for( itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
dwBlockSize += sizeof( WORD );
|
||||
dwBlockSize += (DWORD) strlen( *itr );
|
||||
}
|
||||
|
||||
HANDLE hBlock = ::GlobalAlloc( GMEM_ZEROINIT | GMEM_MOVEABLE, dwBlockSize );
|
||||
if( hBlock == NULL )
|
||||
return INVALID_HANDLE_VALUE;
|
||||
LPBYTE lpBuffer = (LPBYTE) ::GlobalLock( hBlock );
|
||||
if( lpBuffer == NULL ) {
|
||||
::GlobalFree( hBlock );
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
*((LPDWORD) lpBuffer) = (DWORD) m_StrList.size(); lpBuffer += sizeof( DWORD );
|
||||
for( itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
*((LPWORD) lpBuffer) = (WORD) strlen( *itr ); lpBuffer += sizeof( WORD );
|
||||
::CopyMemory( lpBuffer, *itr, strlen( *itr ) ); lpBuffer += strlen( *itr );
|
||||
}
|
||||
::GlobalUnlock( hBlock );
|
||||
|
||||
m_hHandle = hBlock;
|
||||
return hBlock;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::DestroyHandle( void )
|
||||
{
|
||||
::GlobalFree( m_hHandle );
|
||||
m_hHandle = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LPSTR _CPostItMemoryBlock::Find( LPCSTR lpszKeyName )
|
||||
{
|
||||
for( StrListItr itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
LPSTR lpszText = *itr;
|
||||
|
||||
if( _strnicmp( lpszText, lpszKeyName, strlen( lpszKeyName ) ) != 0 )
|
||||
continue;
|
||||
if( *(lpszText + strlen( lpszKeyName )) != '=' )
|
||||
continue;
|
||||
return lpszText;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Put( LPCSTR lpszKeyName, LPCSTR lpBuffer )
|
||||
{
|
||||
LPSTR lpszText;
|
||||
|
||||
if( (lpszText = Find( lpszKeyName )) != NULL ) {
|
||||
for( StrListItr itr = m_StrList.begin(); itr != m_StrList.end(); ++itr ) {
|
||||
if( lpszText == *itr ) {
|
||||
SAFE_DELETE_ARRAY( lpszText );
|
||||
m_StrList.erase( itr );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( lpBuffer == NULL || !*lpBuffer )
|
||||
return TRUE;
|
||||
size_t nStrLen = strlen( lpszKeyName ) + 1 /* '=' */ + strlen( lpBuffer );
|
||||
lpszText = new CHAR[ nStrLen + 1 ];
|
||||
::CopyMemory( lpszText, lpszKeyName, strlen( lpszKeyName ) );
|
||||
*(lpszText + strlen( lpszKeyName )) = '=';
|
||||
::CopyMemory( lpszText + strlen( lpszKeyName ) + 1, lpBuffer, strlen( lpBuffer ) );
|
||||
*(lpszText + nStrLen) = '\0';
|
||||
|
||||
m_StrList.push_back( lpszText );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Put( LPCSTR lpBuffer )
|
||||
{
|
||||
LPSTR lpszText;
|
||||
|
||||
if( lpBuffer == NULL || !*lpBuffer )
|
||||
return TRUE;
|
||||
size_t nStrLen = strlen( lpBuffer );
|
||||
lpszText = new CHAR[ nStrLen + 1 ];
|
||||
::CopyMemory( lpszText, lpBuffer, nStrLen );
|
||||
*(lpszText + nStrLen) = '\0';
|
||||
|
||||
m_StrList.push_back( lpszText );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL _CPostItMemoryBlock::Get( LPCSTR lpszKeyName, LPSTR lpBuffer, DWORD nSize )
|
||||
{
|
||||
LPSTR lpszText = Find( lpszKeyName );
|
||||
if( lpszText == NULL )
|
||||
return FALSE;
|
||||
lpszText += (strlen( lpszKeyName ) + 1);
|
||||
::ZeroMemory( lpBuffer, nSize );
|
||||
strncpy( lpBuffer, lpszText, (nSize < strlen( lpszText )) ? nSize : strlen( lpszText ) );
|
||||
return TRUE;
|
||||
}
|
80
src/EterBase/CPostIt.h
Normal file
80
src/EterBase/CPostIt.h
Normal file
@ -0,0 +1,80 @@
|
||||
#ifndef _EL_CPOSTIT_H_
|
||||
#define _EL_CPOSTIT_H_
|
||||
|
||||
// _CPostItMemoryBlock is defined in CPostIt.cpp
|
||||
class _CPostItMemoryBlock;
|
||||
|
||||
/**
|
||||
* @class CPostIt
|
||||
* @brief <09><><EFBFBD>ӷ<EFBFBD>ó<EFBFBD><C3B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD>̾<EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> Ŭ<><C5AC><EFBFBD>̾<EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
*/
|
||||
class CPostIt
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief CPostIt constructor
|
||||
* @param [in] szAppName : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD><EEB0A3>.
|
||||
*/
|
||||
explicit CPostIt( LPCSTR szAppName );
|
||||
|
||||
/**
|
||||
* @brief CPostIt destructor
|
||||
*/
|
||||
~CPostIt( void );
|
||||
|
||||
/**
|
||||
* @brief CPostIt class<73><73><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD>忡 <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
*/
|
||||
BOOL Flush( void );
|
||||
|
||||
/**
|
||||
* @brief CPostIt class<73><73><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ <20><> Ŭ<><C5AC><EFBFBD><EFBFBD><EFBFBD>忡 <20>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
*/
|
||||
void Empty( void );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20>о<EFBFBD><D0BE>´<EFBFBD>.
|
||||
* @param [in] lpszKeyName : <20>ҷ<EFBFBD><D2B7><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> Ű. "KEY" <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ´<D6B4>.
|
||||
* @param [in] lpszData : <20>ҷ<EFBFBD><D2B7><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20><><EFBFBD><EFBFBD>
|
||||
* @param [in] nSize : lpszData <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
*/
|
||||
BOOL Get( LPCSTR lpszKeyName, LPSTR lpszData, DWORD nSize );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20>ִ´<D6B4>.
|
||||
* @param [in] lpBuffer : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ. "KEY=DATA" <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ´<D6B4>.
|
||||
*/
|
||||
BOOL Set( LPCSTR lpszData );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20>ִ´<D6B4>.
|
||||
* @param [in] lpszKeyName : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> Ű. "KEY" <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ´<D6B4>.
|
||||
* @param [in] lpszData : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ. "DATA" <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ´<D6B4>.
|
||||
*/
|
||||
BOOL Set( LPCSTR lpszKeyName, LPCSTR lpszData );
|
||||
|
||||
/**
|
||||
* @brief <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ(DWORD)<29><> <20>ִ´<D6B4>.
|
||||
* @param [in] lpBuffer : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ. "KEY=DATA" <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ<EFBFBD><C5B8> <20>ִ´<D6B4>.
|
||||
* @param [in] dwValue : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ÿ. (DWORD)
|
||||
*/
|
||||
BOOL Set( LPCSTR lpszKeyName, DWORD dwValue );
|
||||
|
||||
/**
|
||||
* @brief CPostIt class<73><73> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. (Ŭ<><C5AC><EFBFBD><EFBFBD> constructor<6F><72> <20≯<EFBFBD> <20><><EFBFBD>ڰ<EFBFBD> <20>ֱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20≯<EFBFBD><CCB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>)
|
||||
* @param [in] pPostIt : Destination class
|
||||
* @param [in] lpszKeyName : Destination class's new app-name
|
||||
*/
|
||||
BOOL CopyTo( CPostIt *pPostIt, LPCSTR lpszKeyName );
|
||||
|
||||
protected:
|
||||
BOOL Init( LPCSTR szAppName );
|
||||
void Destroy( void );
|
||||
|
||||
protected:
|
||||
BOOL m_bModified;
|
||||
CHAR m_szClipFormatName[_MAX_PATH];
|
||||
_CPostItMemoryBlock* m_pMemoryBlock;
|
||||
};
|
||||
|
||||
#endif /* _EL_CPOSTIT_H_ */
|
211
src/EterBase/CRC32.cpp
Normal file
211
src/EterBase/CRC32.cpp
Normal file
@ -0,0 +1,211 @@
|
||||
#include "StdAfx.h"
|
||||
#include "CRC32.h"
|
||||
|
||||
static unsigned long CRCTable[256] =
|
||||
{
|
||||
0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,
|
||||
0xE963A535,0x9E6495A3,0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,
|
||||
0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,0x1DB71064,0x6AB020F2,
|
||||
0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,
|
||||
0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,
|
||||
0xFA0F3D63,0x8D080DF5,0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,
|
||||
0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,0x35B5A8FA,0x42B2986C,
|
||||
0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
|
||||
0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,
|
||||
0xCFBA9599,0xB8BDA50F,0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,
|
||||
0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,0x76DC4190,0x01DB7106,
|
||||
0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,
|
||||
0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,
|
||||
0x91646C97,0xE6635C01,0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,
|
||||
0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,0x65B0D9C6,0x12B7E950,
|
||||
0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
|
||||
0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,
|
||||
0xA4D1C46D,0xD3D6F4FB,0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,
|
||||
0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,0x5005713C,0x270241AA,
|
||||
0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,
|
||||
0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,
|
||||
0xB7BD5C3B,0xC0BA6CAD,0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,
|
||||
0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,0xE3630B12,0x94643B84,
|
||||
0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
|
||||
0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,
|
||||
0x196C3671,0x6E6B06E7,0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,
|
||||
0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,0xD6D6A3E8,0xA1D1937E,
|
||||
0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,
|
||||
0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,
|
||||
0x316E8EEF,0x4669BE79,0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,
|
||||
0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,0xC5BA3BBE,0xB2BD0B28,
|
||||
0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
|
||||
0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,
|
||||
0x72076785,0x05005713,0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,
|
||||
0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,0x86D3D2D4,0xF1D4E242,
|
||||
0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,
|
||||
0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,
|
||||
0x616BFFD3,0x166CCF45,0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,
|
||||
0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,0xAED16A4A,0xD9D65ADC,
|
||||
0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
|
||||
0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,
|
||||
0x54DE5729,0x23D967BF,0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,
|
||||
0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D
|
||||
};
|
||||
|
||||
#define DO1(buf, i) crc = CRCTable[(crc ^ buf[i]) & 0xff] ^ (crc >> 8)
|
||||
#define DO2(buf, i) DO1(buf, i); DO1(buf, i + 1);
|
||||
#define DO4(buf, i) DO2(buf, i); DO2(buf, i + 2);
|
||||
#define DO8(buf, i) DO4(buf, i); DO4(buf, i + 4);
|
||||
#define DO16(buf, i) DO8(buf, i); DO8(buf, i + 8);
|
||||
|
||||
DWORD GetCRC32(const char * buf, size_t len)
|
||||
{
|
||||
DWORD crc = 0xffffffff;
|
||||
|
||||
if (len >= 16)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO16(buf, 0);
|
||||
|
||||
buf += 16;
|
||||
len -= 16;
|
||||
} while (len >= 16);
|
||||
}
|
||||
|
||||
if (len != 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO1(buf, 0);
|
||||
++buf;
|
||||
--len;
|
||||
} while (len > 0);
|
||||
}
|
||||
|
||||
crc ^= 0xffffffff;
|
||||
return crc;
|
||||
}
|
||||
|
||||
#ifndef UPPER
|
||||
#define UPPER(c) (((c)>='a' && (c) <= 'z') ? ((c)+('A'-'a')) : (c))
|
||||
#endif
|
||||
|
||||
#define DO1CI(buf, i) crc = CRCTable[(crc ^ UPPER(buf[i])) & 0xff] ^ (crc >> 8)
|
||||
#define DO2CI(buf, i) DO1CI(buf, i); DO1CI(buf, i + 1);
|
||||
#define DO4CI(buf, i) DO2CI(buf, i); DO2CI(buf, i + 2);
|
||||
#define DO8CI(buf, i) DO4CI(buf, i); DO4CI(buf, i + 4);
|
||||
#define DO16CI(buf, i) DO8CI(buf, i); DO8CI(buf, i + 8);
|
||||
|
||||
DWORD GetCaseCRC32(const char * buf, size_t len)
|
||||
{
|
||||
DWORD crc = 0xffffffff;
|
||||
|
||||
if (16 <= len)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO16CI(buf, 0);
|
||||
|
||||
buf += 16;
|
||||
len -= 16;
|
||||
} while (len >= 16);
|
||||
}
|
||||
|
||||
if (0 != len)
|
||||
{
|
||||
do
|
||||
{
|
||||
DO1CI(buf, 0);
|
||||
|
||||
++buf;
|
||||
--len;
|
||||
} while (len > 0);
|
||||
}
|
||||
|
||||
crc ^= 0xffffffff;
|
||||
return crc;
|
||||
}
|
||||
|
||||
DWORD GetHFILECRC32(HANDLE hFile)
|
||||
{
|
||||
DWORD dwRetCRC32=0;
|
||||
|
||||
DWORD dwFileSize = GetFileSize(hFile, NULL);
|
||||
|
||||
DWORD dataOffset=0;
|
||||
DWORD mapSize=dwFileSize;
|
||||
|
||||
SYSTEM_INFO SysInfo;
|
||||
GetSystemInfo(&SysInfo);
|
||||
|
||||
DWORD dwSysGran = SysInfo.dwAllocationGranularity;
|
||||
DWORD dwFileMapStart = (dataOffset / dwSysGran) * dwSysGran;
|
||||
DWORD dwMapViewSize = (dataOffset % dwSysGran) + mapSize;
|
||||
//INT iViewDelta = dataOffset - dwFileMapStart;
|
||||
|
||||
HANDLE hFM = CreateFileMapping(hFile, // handle
|
||||
NULL, // security
|
||||
PAGE_READONLY, // flProtect
|
||||
0, // high
|
||||
dataOffset + mapSize, // low
|
||||
NULL); // name
|
||||
if (hFM)
|
||||
{
|
||||
LPVOID lpMapData = MapViewOfFile(hFM,
|
||||
FILE_MAP_READ,
|
||||
0,
|
||||
dwFileMapStart,
|
||||
dwMapViewSize);
|
||||
|
||||
dwRetCRC32=GetCRC32((const char*)lpMapData, dwFileSize);
|
||||
|
||||
|
||||
if (lpMapData)
|
||||
{
|
||||
|
||||
UnmapViewOfFile(lpMapData);
|
||||
}
|
||||
|
||||
CloseHandle(hFM);
|
||||
}
|
||||
|
||||
return dwRetCRC32;
|
||||
}
|
||||
|
||||
DWORD GetFileCRC32(const char* c_szFileName)
|
||||
{
|
||||
HANDLE hFile = CreateFile(c_szFileName, // name of the file
|
||||
GENERIC_READ, // desired access
|
||||
FILE_SHARE_READ, // share mode
|
||||
NULL, // security attributes
|
||||
OPEN_EXISTING, // creation disposition
|
||||
FILE_ATTRIBUTE_NORMAL, // flags and attr
|
||||
NULL); // template file
|
||||
|
||||
if (INVALID_HANDLE_VALUE == hFile)
|
||||
return 0;
|
||||
|
||||
|
||||
DWORD dwRetCRC32=GetHFILECRC32(hFile);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return dwRetCRC32;
|
||||
}
|
||||
|
||||
DWORD GetFileSize(const char* c_szFileName)
|
||||
{
|
||||
HANDLE hFile = CreateFile(c_szFileName, // name of the file
|
||||
GENERIC_READ, // desired access
|
||||
FILE_SHARE_READ, // share mode
|
||||
NULL, // security attributes
|
||||
OPEN_EXISTING, // creation disposition
|
||||
FILE_ATTRIBUTE_NORMAL, // flags and attr
|
||||
NULL); // template file
|
||||
|
||||
if (INVALID_HANDLE_VALUE == hFile)
|
||||
return 0;
|
||||
|
||||
DWORD dwSize = GetFileSize(hFile, NULL);
|
||||
|
||||
CloseHandle(hFile);
|
||||
|
||||
return dwSize;
|
||||
}
|
12
src/EterBase/CRC32.h
Normal file
12
src/EterBase/CRC32.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __INC_CRC32_H__
|
||||
#define __INC_CRC32_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
DWORD GetCRC32(const char* buffer, size_t count);
|
||||
DWORD GetCaseCRC32(const char * buf, size_t len);
|
||||
DWORD GetHFILECRC32(HANDLE hFile);
|
||||
DWORD GetFileCRC32(const char* c_szFileName);
|
||||
DWORD GetFileSize(const char* c_szFileName);
|
||||
|
||||
#endif
|
326
src/EterBase/Debug.cpp
Normal file
326
src/EterBase/Debug.cpp
Normal file
@ -0,0 +1,326 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include "Debug.h"
|
||||
#include "Singleton.h"
|
||||
#include "Timer.h"
|
||||
|
||||
const DWORD DEBUG_STRING_MAX_LEN = 1024;
|
||||
|
||||
static int isLogFile = false;
|
||||
HWND g_PopupHwnd = NULL;
|
||||
|
||||
class CLogFile : public CSingleton<CLogFile>
|
||||
{
|
||||
public:
|
||||
CLogFile() : m_fp(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~CLogFile()
|
||||
{
|
||||
if (m_fp)
|
||||
fclose(m_fp);
|
||||
|
||||
m_fp = NULL;
|
||||
}
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
m_fp = fopen("log.txt", "w");
|
||||
}
|
||||
|
||||
void Write(const char * c_pszMsg)
|
||||
{
|
||||
if (!m_fp)
|
||||
return;
|
||||
|
||||
time_t ct = time(0);
|
||||
struct tm ctm = *localtime(&ct);
|
||||
|
||||
fprintf(m_fp, "%02d%02d %02d:%02d:%05d :: %s",
|
||||
ctm.tm_mon + 1,
|
||||
ctm.tm_mday,
|
||||
ctm.tm_hour,
|
||||
ctm.tm_min,
|
||||
ELTimer_GetMSec() % 60000,
|
||||
c_pszMsg);
|
||||
|
||||
fflush(m_fp);
|
||||
}
|
||||
|
||||
protected:
|
||||
FILE * m_fp;
|
||||
};
|
||||
|
||||
static CLogFile gs_logfile;
|
||||
|
||||
static UINT gs_uLevel=0;
|
||||
|
||||
void SetLogLevel(UINT uLevel)
|
||||
{
|
||||
gs_uLevel=uLevel;
|
||||
}
|
||||
|
||||
void Log(UINT uLevel, const char* c_szMsg)
|
||||
{
|
||||
if (uLevel>=gs_uLevel)
|
||||
Trace(c_szMsg);
|
||||
}
|
||||
|
||||
void Logn(UINT uLevel, const char* c_szMsg)
|
||||
{
|
||||
if (uLevel>=gs_uLevel)
|
||||
Tracen(c_szMsg);
|
||||
}
|
||||
|
||||
void Logf(UINT uLevel, const char* c_szFormat, ...)
|
||||
{
|
||||
if (uLevel<gs_uLevel)
|
||||
return;
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
void Lognf(UINT uLevel, const char* c_szFormat, ...)
|
||||
{
|
||||
if (uLevel<gs_uLevel)
|
||||
return;
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+2];
|
||||
int len = _vsnprintf(szBuf, sizeof(szBuf)-1, c_szFormat, args);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
szBuf[len] = '\n';
|
||||
szBuf[len + 1] = '\0';
|
||||
}
|
||||
va_end(args);
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
puts(szBuf);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
|
||||
void Trace(const char * c_szMsg)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(c_szMsg);
|
||||
printf("%s", c_szMsg);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(c_szMsg);
|
||||
}
|
||||
|
||||
void Tracen(const char* c_szMsg)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
_snprintf(szBuf, sizeof(szBuf), "%s\n", c_szMsg);
|
||||
OutputDebugString(szBuf);
|
||||
puts(c_szMsg);
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
|
||||
puts(c_szMsg);
|
||||
putc('\n', stdout);
|
||||
#else
|
||||
if (isLogFile)
|
||||
{
|
||||
LogFile(c_szMsg);
|
||||
LogFile("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tracenf(const char* c_szFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+2];
|
||||
int len = _vsnprintf(szBuf, sizeof(szBuf)-1, c_szFormat, args);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
szBuf[len] = '\n';
|
||||
szBuf[len + 1] = '\0';
|
||||
}
|
||||
va_end(args);
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
printf("%s", szBuf);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
void Tracef(const char* c_szFormat, ...)
|
||||
{
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
}
|
||||
|
||||
void TraceError(const char* c_szFormat, ...)
|
||||
{
|
||||
#ifndef _DISTRIBUTE
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+2];
|
||||
|
||||
strncpy(szBuf, "SYSERR: ", DEBUG_STRING_MAX_LEN);
|
||||
int len = strlen(szBuf);
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
len = _vsnprintf(szBuf + len, sizeof(szBuf) - (len + 1), c_szFormat, args) + len;
|
||||
va_end(args);
|
||||
|
||||
szBuf[len] = '\n';
|
||||
szBuf[len + 1] = '\0';
|
||||
|
||||
time_t ct = time(0);
|
||||
struct tm ctm = *localtime(&ct);
|
||||
|
||||
fprintf(stderr, "%02d%02d %02d:%02d:%05d :: %s",
|
||||
ctm.tm_mon + 1,
|
||||
ctm.tm_mday,
|
||||
ctm.tm_hour,
|
||||
ctm.tm_min,
|
||||
ELTimer_GetMSec() % 60000,
|
||||
szBuf + 8);
|
||||
fflush(stderr);
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void TraceErrorWithoutEnter(const char* c_szFormat, ...)
|
||||
{
|
||||
#ifndef _DISTRIBUTE
|
||||
|
||||
char szBuf[DEBUG_STRING_MAX_LEN];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
|
||||
time_t ct = time(0);
|
||||
struct tm ctm = *localtime(&ct);
|
||||
|
||||
fprintf(stderr, "%02d%02d %02d:%02d:%05d :: %s",
|
||||
ctm.tm_mon + 1,
|
||||
ctm.tm_mday,
|
||||
ctm.tm_hour,
|
||||
ctm.tm_min,
|
||||
ELTimer_GetMSec() % 60000,
|
||||
szBuf + 8);
|
||||
fflush(stderr);
|
||||
|
||||
#ifdef _DEBUG
|
||||
OutputDebugString(szBuf);
|
||||
fputs(szBuf, stdout);
|
||||
#endif
|
||||
|
||||
if (isLogFile)
|
||||
LogFile(szBuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
void LogBoxf(const char* c_szFormat, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
|
||||
char szBuf[2048];
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
|
||||
LogBox(szBuf);
|
||||
}
|
||||
|
||||
void LogBox(const char* c_szMsg, const char * c_szCaption, HWND hWnd)
|
||||
{
|
||||
if (!hWnd)
|
||||
hWnd = g_PopupHwnd;
|
||||
|
||||
MessageBox(hWnd, c_szMsg, c_szCaption ? c_szCaption : "LOG", MB_OK);
|
||||
Tracen(c_szMsg);
|
||||
}
|
||||
|
||||
void LogFile(const char * c_szMsg)
|
||||
{
|
||||
CLogFile::Instance().Write(c_szMsg);
|
||||
}
|
||||
|
||||
void LogFilef(const char * c_szMessage, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, c_szMessage);
|
||||
char szBuf[DEBUG_STRING_MAX_LEN+1];
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szMessage, args);
|
||||
|
||||
CLogFile::Instance().Write(szBuf);
|
||||
}
|
||||
|
||||
void OpenLogFile(bool bUseLogFIle)
|
||||
{
|
||||
#ifndef _DISTRIBUTE
|
||||
freopen("syserr.txt", "w", stderr);
|
||||
|
||||
if (bUseLogFIle)
|
||||
{
|
||||
isLogFile = true;
|
||||
CLogFile::Instance().Initialize();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenConsoleWindow()
|
||||
{
|
||||
AllocConsole();
|
||||
|
||||
freopen("CONOUT$", "a", stdout);
|
||||
freopen("CONIN$", "r", stdin);
|
||||
}
|
40
src/EterBase/Debug.h
Normal file
40
src/EterBase/Debug.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef __INC_ETERLIB_DEBUG_H__
|
||||
#define __INC_ETERLIB_DEBUG_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
extern void SetLogLevel(UINT uLevel);
|
||||
extern void Log(UINT uLevel, const char* c_szMsg);
|
||||
extern void Logn(UINT uLevel, const char* c_szMsg);
|
||||
extern void Logf(UINT uLevel, const char* c_szFormat, ...);
|
||||
extern void Lognf(UINT uLevel, const char* c_szFormat, ...);
|
||||
|
||||
extern void Trace(const char* c_szMsg);
|
||||
extern void Tracen(const char* c_szMsg);
|
||||
extern void Tracenf(const char* c_szFormat, ...);
|
||||
extern void Tracef(const char* c_szFormat, ...);
|
||||
extern void TraceError(const char* c_szFormat, ...);
|
||||
extern void TraceErrorWithoutEnter(const char* c_szFormat, ...);
|
||||
|
||||
extern void LogBox(const char* c_szMsg, const char * c_szCaption = NULL, HWND hWnd = NULL);
|
||||
extern void LogBoxf(const char* c_szMsg, ...);
|
||||
|
||||
extern void LogFile(const char* c_szMsg);
|
||||
extern void LogFilef(const char * c_szMessage, ...);
|
||||
extern void OpenConsoleWindow(void);
|
||||
extern void CloseConsoleWindow();
|
||||
extern void SetupLog(void);
|
||||
|
||||
extern void OpenLogFile(bool bUseLogFile = true);
|
||||
extern void CloseLogFile();
|
||||
|
||||
extern HWND g_PopupHwnd;
|
||||
|
||||
#define CHECK_RETURN(flag, string) \
|
||||
if (flag) \
|
||||
{ \
|
||||
LogBox(string); \
|
||||
return; \
|
||||
} \
|
||||
|
||||
#endif
|
367
src/EterBase/EterBase.vcxproj
Normal file
367
src/EterBase/EterBase.vcxproj
Normal file
@ -0,0 +1,367 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Distribute|Win32">
|
||||
<Configuration>Distribute</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="MfcDebug|Win32">
|
||||
<Configuration>MfcDebug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="MfcRelease|Win32">
|
||||
<Configuration>MfcRelease</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="VTune|Win32">
|
||||
<Configuration>VTune</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<ProjectName>EterBase</ProjectName>
|
||||
<ProjectGuid>{678C47DC-B3EF-460E-A932-56F3208FC65E}</ProjectGuid>
|
||||
<RootNamespace>EterBase</RootNamespace>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>17.0.32203.90</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeaderOutputFile>.\Debug/eterBase.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Debug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
<IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>../../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>.\Distribute/eterBase.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\Distribute/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Distribute/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Distribute/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>$(SolutionDir)Extern\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeaderOutputFile>.\MfcRelease/eterBase.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\MfcRelease/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\MfcRelease/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\MfcRelease/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\MfcRelease\eterBase.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeaderOutputFile>.\MfcDebug/eterBase.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\MfcDebug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\MfcDebug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\MfcDebug/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\MfcDebug\eterBase.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>.\Release/eterBase.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Release/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Release/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalOptions>/Gs %(AdditionalOptions)</AdditionalOptions>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>.\VTune/eterBase.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\VTune/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\VTune/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\VTune/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\VTune\eterBase.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>../../extern/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CPostIt.cpp" />
|
||||
<ClCompile Include="CRC32.cpp" />
|
||||
<ClCompile Include="Debug.cpp" />
|
||||
<ClCompile Include="error.cpp" />
|
||||
<ClCompile Include="FileBase.cpp" />
|
||||
<ClCompile Include="FileDir.cpp" />
|
||||
<ClCompile Include="FileLoader.cpp" />
|
||||
<ClCompile Include="lzo.cpp" />
|
||||
<ClCompile Include="MappedFile.cpp" />
|
||||
<ClCompile Include="poly\Base.cpp" />
|
||||
<ClCompile Include="poly\Poly.cpp" />
|
||||
<ClCompile Include="poly\Symbol.cpp" />
|
||||
<ClCompile Include="poly\SymTable.cpp" />
|
||||
<ClCompile Include="Random.cpp" />
|
||||
<ClCompile Include="StdAfx.cpp" />
|
||||
<ClCompile Include="Stl.cpp" />
|
||||
<ClCompile Include="tea.cpp" />
|
||||
<ClCompile Include="TempFile.cpp" />
|
||||
<ClCompile Include="Timer.cpp" />
|
||||
<ClCompile Include="Utils.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CPostIt.h" />
|
||||
<ClInclude Include="CRC32.h" />
|
||||
<ClInclude Include="Debug.h" />
|
||||
<ClInclude Include="error.h" />
|
||||
<ClInclude Include="FileBase.h" />
|
||||
<ClInclude Include="FileDir.h" />
|
||||
<ClInclude Include="FileLoader.h" />
|
||||
<ClInclude Include="Filename.h" />
|
||||
<ClInclude Include="lzo.h" />
|
||||
<ClInclude Include="MappedFile.h" />
|
||||
<ClInclude Include="poly\Base.h" />
|
||||
<ClInclude Include="poly\Poly.h" />
|
||||
<ClInclude Include="poly\Symbol.h" />
|
||||
<ClInclude Include="poly\SymTable.h" />
|
||||
<ClInclude Include="Random.h" />
|
||||
<ClInclude Include="ServiceDefs.h" />
|
||||
<ClInclude Include="Singleton.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
<ClInclude Include="Stl.h" />
|
||||
<ClInclude Include="tea.h" />
|
||||
<ClInclude Include="TempFile.h" />
|
||||
<ClInclude Include="Timer.h" />
|
||||
<ClInclude Include="Utils.h" />
|
||||
<ClInclude Include="vk.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
147
src/EterBase/EterBase.vcxproj.filters
Normal file
147
src/EterBase/EterBase.vcxproj.filters
Normal file
@ -0,0 +1,147 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Poly">
|
||||
<UniqueIdentifier>{9bcae2cc-8267-44b5-ab62-a9883ac6d669}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Code">
|
||||
<UniqueIdentifier>{4b55a5df-b2f4-4801-969c-73611f757946}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="poly\Base.cpp">
|
||||
<Filter>Poly</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="poly\Poly.cpp">
|
||||
<Filter>Poly</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="poly\Symbol.cpp">
|
||||
<Filter>Poly</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="poly\SymTable.cpp">
|
||||
<Filter>Poly</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CPostIt.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CRC32.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Debug.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="error.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileBase.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileDir.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="FileLoader.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lzo.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MappedFile.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Random.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Stl.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="tea.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="TempFile.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Timer.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Utils.cpp">
|
||||
<Filter>Code</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="poly\Base.h">
|
||||
<Filter>Poly</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="poly\Poly.h">
|
||||
<Filter>Poly</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="poly\Symbol.h">
|
||||
<Filter>Poly</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="poly\SymTable.h">
|
||||
<Filter>Poly</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CPostIt.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CRC32.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Debug.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="error.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileBase.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileDir.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="FileLoader.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Filename.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="lzo.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MappedFile.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Random.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ServiceDefs.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Singleton.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Stl.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="tea.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="TempFile.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Timer.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Utils.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="vk.h">
|
||||
<Filter>Code</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
115
src/EterBase/FileBase.cpp
Normal file
115
src/EterBase/FileBase.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FileBase.h"
|
||||
|
||||
CFileBase::CFileBase() : m_hFile(NULL), m_dwSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
CFileBase::~CFileBase()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
char * CFileBase::GetFileName()
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
void CFileBase::Destroy()
|
||||
{
|
||||
Close();
|
||||
m_dwSize = 0;
|
||||
}
|
||||
|
||||
void CFileBase::Close()
|
||||
{
|
||||
if (m_hFile)
|
||||
{
|
||||
CloseHandle(m_hFile);
|
||||
m_hFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CFileBase::Create(const char* filename, EFileMode mode)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
strncpy(m_filename, filename, MAX_PATH);
|
||||
|
||||
DWORD dwMode, dwShareMode = FILE_SHARE_READ;
|
||||
|
||||
if (mode == FILEMODE_WRITE)
|
||||
{
|
||||
dwMode = GENERIC_READ | GENERIC_WRITE;
|
||||
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
|
||||
}
|
||||
else
|
||||
dwMode = GENERIC_READ;
|
||||
|
||||
m_hFile = CreateFile(filename, // name of the file
|
||||
dwMode, // desired access
|
||||
dwShareMode, // share mode
|
||||
NULL, // security attributes
|
||||
mode == FILEMODE_READ ? OPEN_EXISTING : OPEN_ALWAYS, // creation disposition
|
||||
FILE_ATTRIBUTE_NORMAL, // flags and attr
|
||||
NULL); // template file
|
||||
|
||||
if (m_hFile != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
m_dwSize = GetFileSize(m_hFile, NULL);
|
||||
m_mode = mode;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* char buf[256];
|
||||
GetCurrentDirectory(256, buf);
|
||||
DWORD dwErr = GetLastError();*/
|
||||
m_hFile = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD CFileBase::Size()
|
||||
{
|
||||
return (m_dwSize);
|
||||
}
|
||||
|
||||
void CFileBase::SeekCur(DWORD size)
|
||||
{
|
||||
SetFilePointer(m_hFile, size, NULL, FILE_CURRENT);
|
||||
}
|
||||
|
||||
void CFileBase::Seek(DWORD offset)
|
||||
{
|
||||
if (offset > m_dwSize)
|
||||
offset = m_dwSize;
|
||||
|
||||
SetFilePointer(m_hFile, offset, NULL, FILE_BEGIN);
|
||||
}
|
||||
|
||||
DWORD CFileBase::GetPosition()
|
||||
{
|
||||
return SetFilePointer(m_hFile, 0, NULL, FILE_CURRENT);
|
||||
}
|
||||
|
||||
BOOL CFileBase::Write(const void* src, int bytes)
|
||||
{
|
||||
DWORD dwUseless;
|
||||
BOOL ret = WriteFile(m_hFile, src, bytes, &dwUseless, NULL);
|
||||
|
||||
if (!ret)
|
||||
return false;
|
||||
|
||||
m_dwSize = GetFileSize(m_hFile, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CFileBase::Read(void* dest, int bytes)
|
||||
{
|
||||
DWORD dwUseless;
|
||||
return ReadFile(m_hFile, dest, bytes, &dwUseless, NULL);
|
||||
}
|
||||
|
||||
BOOL CFileBase::IsNull()
|
||||
{
|
||||
return !m_hFile ? true : false;
|
||||
}
|
40
src/EterBase/FileBase.h
Normal file
40
src/EterBase/FileBase.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef __INC_ETERBASE_FILEBASE_H__
|
||||
#define __INC_ETERBASE_FILEBASE_H__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class CFileBase
|
||||
{
|
||||
public:
|
||||
enum EFileMode
|
||||
{
|
||||
FILEMODE_READ = (1 << 0),
|
||||
FILEMODE_WRITE = (1 << 1)
|
||||
};
|
||||
|
||||
CFileBase();
|
||||
virtual ~CFileBase();
|
||||
|
||||
void Destroy();
|
||||
void Close();
|
||||
|
||||
BOOL Create(const char* filename, EFileMode mode);
|
||||
DWORD Size();
|
||||
void SeekCur(DWORD size);
|
||||
void Seek(DWORD offset);
|
||||
DWORD GetPosition();
|
||||
|
||||
virtual BOOL Write(const void* src, int bytes);
|
||||
BOOL Read(void* dest, int bytes);
|
||||
|
||||
char* GetFileName();
|
||||
BOOL IsNull();
|
||||
|
||||
protected:
|
||||
int m_mode;
|
||||
char m_filename[MAX_PATH+1];
|
||||
HANDLE m_hFile;
|
||||
DWORD m_dwSize;
|
||||
};
|
||||
|
||||
#endif
|
105
src/EterBase/FileDir.cpp
Normal file
105
src/EterBase/FileDir.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FileDir.h"
|
||||
#include <string>
|
||||
|
||||
CDir::CDir()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CDir::~CDir()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CDir::Destroy()
|
||||
{
|
||||
if (m_hFind)
|
||||
FindClose(m_hFind);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
bool CDir::Create(const char * c_szFilter, const char* c_szPath, BOOL bCheckedExtension)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
std::string stPath = c_szPath;
|
||||
|
||||
if (stPath.length())
|
||||
{
|
||||
char end = stPath[stPath.length() - 1];
|
||||
|
||||
if (end != '\\')
|
||||
stPath+='\\';
|
||||
}
|
||||
|
||||
std::string stQuery;
|
||||
stQuery += stPath;
|
||||
stQuery += "*.*";
|
||||
|
||||
m_wfd.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
|
||||
m_hFind = FindFirstFile(stQuery.c_str(), &m_wfd);
|
||||
|
||||
if (m_hFind == INVALID_HANDLE_VALUE)
|
||||
return true;
|
||||
|
||||
do
|
||||
{
|
||||
if (*m_wfd.cFileName == '.')
|
||||
continue;
|
||||
|
||||
if (IsFolder())
|
||||
{
|
||||
if (!OnFolder(c_szFilter, stPath.c_str(), m_wfd.cFileName))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char * c_szExtension = strchr(m_wfd.cFileName, '.');
|
||||
if (!c_szExtension)
|
||||
continue;
|
||||
|
||||
// NOTE : <20>ӽ<EFBFBD> <20><><EFBFBD><EFBFBD> - [levites]
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TRUE <20><><EFBFBD>·<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> CDir<69><72> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Extension<6F><6E> "wav", "gr2" <20>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ְԲ<D6B0> <20>Ѵ<EFBFBD>. - [levites]
|
||||
if (bCheckedExtension)
|
||||
{
|
||||
std::string strFilter = c_szFilter;
|
||||
int iPos = strFilter.find_first_of(';', 0);
|
||||
if (iPos > 0)
|
||||
{
|
||||
std::string strFirstFilter = std::string(c_szFilter).substr(0, iPos);
|
||||
std::string strSecondFilter = std::string(c_szFilter).substr(iPos+1, strlen(c_szFilter));
|
||||
if (0 != strFirstFilter.compare(c_szExtension+1) && 0 != strSecondFilter.compare(c_szExtension+1))
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 != stricmp(c_szExtension+1, c_szFilter))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!OnFile(stPath.c_str(), m_wfd.cFileName))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
while (FindNextFile(m_hFind, &m_wfd));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDir::IsFolder()
|
||||
{
|
||||
if (m_wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CDir::Initialize()
|
||||
{
|
||||
memset(&m_wfd, 0, sizeof(m_wfd));
|
||||
m_hFind = NULL;
|
||||
}
|
30
src/EterBase/FileDir.h
Normal file
30
src/EterBase/FileDir.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __ETER_FILE_DIR__
|
||||
#define __ETER_FILE_DIR__
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class CDir
|
||||
{
|
||||
public:
|
||||
CDir();
|
||||
virtual ~CDir();
|
||||
|
||||
void Destroy();
|
||||
bool Create(const char* c_szFilter, const char* c_szPath="", BOOL bCheckedExtension = FALSE);
|
||||
|
||||
protected:
|
||||
virtual bool OnFolder(const char* c_szFilter, const char* c_szPath, const char* c_szName) = 0;
|
||||
virtual bool OnFile(const char* c_szPath, const char* c_szName) = 0;
|
||||
|
||||
protected:
|
||||
bool IsFolder();
|
||||
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
WIN32_FIND_DATA m_wfd;
|
||||
HANDLE m_hFind;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
288
src/EterBase/FileLoader.cpp
Normal file
288
src/EterBase/FileLoader.cpp
Normal file
@ -0,0 +1,288 @@
|
||||
#include "StdAfx.h"
|
||||
#include "FileLoader.h"
|
||||
#include <assert.h>
|
||||
|
||||
CMemoryTextFileLoader::CMemoryTextFileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
CMemoryTextFileLoader::~CMemoryTextFileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
bool CMemoryTextFileLoader::SplitLineByTab(DWORD dwLine, CTokenVector* pstTokenVector)
|
||||
{
|
||||
pstTokenVector->reserve(10);
|
||||
pstTokenVector->clear();
|
||||
|
||||
const std::string & c_rstLine = GetLineString(dwLine);
|
||||
const int c_iLineLength = c_rstLine.length();
|
||||
|
||||
if (0 == c_iLineLength)
|
||||
return false;
|
||||
|
||||
int basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = c_rstLine.find_first_of("\t", basePos);
|
||||
|
||||
pstTokenVector->push_back(c_rstLine.substr(basePos, beginPos-basePos));
|
||||
|
||||
basePos = beginPos+1;
|
||||
} while (basePos < c_iLineLength && basePos > 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CMemoryTextFileLoader::SplitLine2(DWORD dwLine, CTokenVector* pstTokenVector, const char * c_szDelimeter)
|
||||
{
|
||||
pstTokenVector->reserve(10);
|
||||
pstTokenVector->clear();
|
||||
|
||||
std::string stToken;
|
||||
const std::string & c_rstLine = GetLineString(dwLine);
|
||||
|
||||
DWORD basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = c_rstLine.find_first_not_of(c_szDelimeter, basePos);
|
||||
|
||||
if (beginPos < 0)
|
||||
return -1;
|
||||
|
||||
int endPos;
|
||||
|
||||
if (c_rstLine[beginPos] == '"')
|
||||
{
|
||||
++beginPos;
|
||||
endPos = c_rstLine.find_first_of("\"", beginPos);
|
||||
|
||||
if (endPos < 0)
|
||||
return -2;
|
||||
|
||||
basePos = endPos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
endPos = c_rstLine.find_first_of(c_szDelimeter, beginPos);
|
||||
basePos = endPos;
|
||||
}
|
||||
|
||||
pstTokenVector->push_back(c_rstLine.substr(beginPos, endPos - beginPos));
|
||||
|
||||
// <20>߰<EFBFBD> <20>ڵ<EFBFBD>. <20>ǵڿ<C7B5> <20><><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD>츦 üũ<C3BC>Ѵ<EFBFBD>. - [levites]
|
||||
if (int(c_rstLine.find_first_not_of(c_szDelimeter, basePos)) < 0)
|
||||
break;
|
||||
} while (basePos < c_rstLine.length());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CMemoryTextFileLoader::SplitLine(DWORD dwLine, CTokenVector* pstTokenVector, const char * c_szDelimeter)
|
||||
{
|
||||
pstTokenVector->reserve(10);
|
||||
pstTokenVector->clear();
|
||||
|
||||
std::string stToken;
|
||||
const std::string & c_rstLine = GetLineString(dwLine);
|
||||
|
||||
DWORD basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = c_rstLine.find_first_not_of(c_szDelimeter, basePos);
|
||||
if (beginPos < 0)
|
||||
return false;
|
||||
|
||||
int endPos;
|
||||
|
||||
if (c_rstLine[beginPos] == '"')
|
||||
{
|
||||
++beginPos;
|
||||
endPos = c_rstLine.find_first_of("\"", beginPos);
|
||||
|
||||
if (endPos < 0)
|
||||
return false;
|
||||
|
||||
basePos = endPos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
endPos = c_rstLine.find_first_of(c_szDelimeter, beginPos);
|
||||
basePos = endPos;
|
||||
}
|
||||
|
||||
pstTokenVector->push_back(c_rstLine.substr(beginPos, endPos - beginPos));
|
||||
|
||||
// <20>߰<EFBFBD> <20>ڵ<EFBFBD>. <20>ǵڿ<C7B5> <20><><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20><><EFBFBD>츦 üũ<C3BC>Ѵ<EFBFBD>. - [levites]
|
||||
if (int(c_rstLine.find_first_not_of(c_szDelimeter, basePos)) < 0)
|
||||
break;
|
||||
} while (basePos < c_rstLine.length());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
DWORD CMemoryTextFileLoader::GetLineCount()
|
||||
{
|
||||
return m_stLineVector.size();
|
||||
}
|
||||
|
||||
bool CMemoryTextFileLoader::CheckLineIndex(DWORD dwLine)
|
||||
{
|
||||
if (dwLine >= m_stLineVector.size())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::string & CMemoryTextFileLoader::GetLineString(DWORD dwLine)
|
||||
{
|
||||
assert(CheckLineIndex(dwLine));
|
||||
return m_stLineVector[dwLine];
|
||||
}
|
||||
|
||||
void CMemoryTextFileLoader::Bind(int bufSize, const void* c_pvBuf)
|
||||
{
|
||||
m_stLineVector.reserve(128);
|
||||
m_stLineVector.clear();
|
||||
|
||||
const char * c_pcBuf = (const char *)c_pvBuf;
|
||||
std::string stLine;
|
||||
int pos = 0;
|
||||
|
||||
while (pos < bufSize)
|
||||
{
|
||||
const char c = c_pcBuf[pos++];
|
||||
|
||||
if ('\n' == c || '\r' == c)
|
||||
{
|
||||
if (pos < bufSize)
|
||||
if ('\n' == c_pcBuf[pos] || '\r' == c_pcBuf[pos])
|
||||
++pos;
|
||||
|
||||
m_stLineVector.push_back(stLine);
|
||||
stLine = "";
|
||||
}
|
||||
else if (c < 0)
|
||||
{
|
||||
stLine.append(c_pcBuf + (pos-1), 2);
|
||||
++pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
stLine += c;
|
||||
}
|
||||
}
|
||||
|
||||
m_stLineVector.push_back(stLine);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int CMemoryFileLoader::GetSize()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
int CMemoryFileLoader::GetPosition()
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
bool CMemoryFileLoader::IsReadableSize(int size)
|
||||
{
|
||||
if (m_pos + size > m_size)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMemoryFileLoader::Read(int size, void* pvDst)
|
||||
{
|
||||
if (!IsReadableSize(size))
|
||||
return false;
|
||||
|
||||
memcpy(pvDst, GetCurrentPositionPointer(), size);
|
||||
m_pos += size;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* CMemoryFileLoader::GetCurrentPositionPointer()
|
||||
{
|
||||
assert(m_pcBase != NULL);
|
||||
return (m_pcBase + m_pos);
|
||||
}
|
||||
|
||||
CMemoryFileLoader::CMemoryFileLoader(int size, const void* c_pvMemoryFile)
|
||||
{
|
||||
assert(c_pvMemoryFile != NULL);
|
||||
|
||||
m_pos = 0;
|
||||
m_size = size;
|
||||
m_pcBase = (const char *) c_pvMemoryFile;
|
||||
}
|
||||
|
||||
CMemoryFileLoader::~CMemoryFileLoader()
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
int CDiskFileLoader::GetSize()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
bool CDiskFileLoader::Read(int size, void* pvDst)
|
||||
{
|
||||
assert(m_fp != NULL);
|
||||
|
||||
int ret = fread(pvDst, size, 1, m_fp);
|
||||
|
||||
if (ret <= 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDiskFileLoader::Open(const char* c_szFileName)
|
||||
{
|
||||
Close();
|
||||
|
||||
if (!c_szFileName[0])
|
||||
return false;
|
||||
|
||||
m_fp = fopen(c_szFileName, "rb");
|
||||
|
||||
if (!m_fp)
|
||||
return false;
|
||||
|
||||
fseek(m_fp, 0, SEEK_END);
|
||||
m_size = ftell(m_fp);
|
||||
fseek(m_fp, 0, SEEK_SET);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDiskFileLoader::Close()
|
||||
{
|
||||
if (m_fp)
|
||||
fclose(m_fp);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void CDiskFileLoader::Initialize()
|
||||
{
|
||||
m_fp = NULL;
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
CDiskFileLoader::CDiskFileLoader()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CDiskFileLoader::~CDiskFileLoader()
|
||||
{
|
||||
Close();
|
||||
}
|
71
src/EterBase/FileLoader.h
Normal file
71
src/EterBase/FileLoader.h
Normal file
@ -0,0 +1,71 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4786) // character 255 <20>Ѿ<D1BE>°<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "Stl.h"
|
||||
|
||||
class CMemoryTextFileLoader
|
||||
{
|
||||
public:
|
||||
CMemoryTextFileLoader();
|
||||
virtual ~CMemoryTextFileLoader();
|
||||
|
||||
void Bind(int bufSize, const void* c_pvBuf);
|
||||
DWORD GetLineCount();
|
||||
bool CheckLineIndex(DWORD dwLine);
|
||||
bool SplitLine(DWORD dwLine, CTokenVector * pstTokenVector, const char * c_szDelimeter = " \t");
|
||||
int SplitLine2(DWORD dwLine, CTokenVector * pstTokenVector, const char * c_szDelimeter = " \t");
|
||||
bool SplitLineByTab(DWORD dwLine, CTokenVector* pstTokenVector);
|
||||
const std::string & GetLineString(DWORD dwLine);
|
||||
|
||||
protected:
|
||||
std::vector<std::string> m_stLineVector;
|
||||
};
|
||||
|
||||
class CMemoryFileLoader
|
||||
{
|
||||
public:
|
||||
CMemoryFileLoader(int size, const void * c_pvMemoryFile);
|
||||
virtual ~CMemoryFileLoader();
|
||||
|
||||
bool Read(int size, void* pvDst);
|
||||
|
||||
int GetPosition();
|
||||
int GetSize();
|
||||
|
||||
protected:
|
||||
bool IsReadableSize(int size);
|
||||
const char * GetCurrentPositionPointer();
|
||||
|
||||
protected:
|
||||
const char * m_pcBase;
|
||||
int m_size;
|
||||
int m_pos;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
class CDiskFileLoader
|
||||
{
|
||||
public:
|
||||
CDiskFileLoader();
|
||||
virtual ~CDiskFileLoader();
|
||||
|
||||
void Close();
|
||||
bool Open(const char * c_szFileName);
|
||||
bool Read(int size, void * pvDst);
|
||||
|
||||
int GetSize();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
protected:
|
||||
FILE * m_fp;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
typedef std::map<std::string, std::string> TStringMap;
|
254
src/EterBase/Filename.h
Normal file
254
src/EterBase/Filename.h
Normal file
@ -0,0 +1,254 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilename Class
|
||||
//
|
||||
// (c) 2003 IDV, Inc.
|
||||
//
|
||||
// *** INTERACTIVE DATA VISUALIZATION (IDV) PROPRIETARY INFORMATION ***
|
||||
//
|
||||
// This software is supplied under the terms of a license agreement or
|
||||
// nondisclosure agreement with Interactive Data Visualization and may
|
||||
// not be copied or disclosed except in accordance with the terms of
|
||||
// that agreement.
|
||||
//
|
||||
// Copyright (c) 2001-2003 IDV, Inc.
|
||||
// All Rights Reserved.
|
||||
//
|
||||
// IDV, Inc.
|
||||
// 1233 Washington St. Suite 610
|
||||
// Columbia, SC 29201
|
||||
// Voice: (803) 799-1699
|
||||
// Fax: (803) 931-0320
|
||||
// Web: http://www.idvinc.com
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilename Class
|
||||
|
||||
//class CFilename
|
||||
//{
|
||||
// public:
|
||||
// CFilename() { }
|
||||
// CFilename(const char* pFilename) { m_sRaw = pFilename; }
|
||||
// CFilename(std::string strFilename) { m_sRaw = strFilename; }
|
||||
//
|
||||
// virtual ~CFilename() {}
|
||||
//
|
||||
// operator const string() const { return m_sRaw; }
|
||||
// operator string&() { return m_sRaw; }
|
||||
// CFilename& operator =(const CFilename& r) { m_sRaw = r.m_sRaw; return *this; }
|
||||
// bool operator ==(const CFilename& r) const { return m_sRaw == r.m_sRaw; }
|
||||
// CFilename operator +(const CFilename& r) const { return CFilename(m_sRaw + r.m_sRaw); }
|
||||
// CFilename& operator +=(const CFilename& r) { m_sRaw += r.m_sRaw; return *this; }
|
||||
// const char& operator[](size_t nIdx) const { return m_sRaw[nIdx]; }
|
||||
// const char* c_str() const { return m_sRaw.c_str(); }
|
||||
// size_t find(const char* pcszSrc) const { return m_sRaw.find(pcszSrc); }
|
||||
// bool empty() const { return m_sRaw.empty(); }
|
||||
// size_t size() const { return m_sRaw.size(); }
|
||||
// size_t length() const { return m_sRaw.length(); }
|
||||
//
|
||||
// string& GetString() { return m_sRaw; }
|
||||
//
|
||||
// void ChangeDosPath()
|
||||
// {
|
||||
// size_t nLength = m_sRaw.length();
|
||||
//
|
||||
// for (size_t i = 0; i < nLength; ++i)
|
||||
// {
|
||||
// if (m_sRaw.at(i) == '/')
|
||||
// m_sRaw.at(i) = '\\';
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void StringPath()
|
||||
// {
|
||||
// size_t nLength = m_sRaw.length();
|
||||
//
|
||||
// for (size_t i = 0; i<nLength; ++i)
|
||||
// {
|
||||
// if (m_sRaw.at(i) == '\\')
|
||||
// m_sRaw.at(i) = '/';
|
||||
// else
|
||||
// m_sRaw.at(i) = (char)tolower(m_sRaw.at(i));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// CFilename GetName(void); // if filename is "/idv/code/file.cpp", it returns "file"
|
||||
// CFilename GetExtension(void); // if filename is "/idv/code/file.cpp", it returns "cpp"
|
||||
// CFilename GetPath(void); // if filename is "/idv/code/file.cpp", it returns "/idv/code"
|
||||
// CFilename NoExtension(void); // if filename is "/idv/code/file.cpp", it returns "/idv/code/file"
|
||||
// CFilename NoPath(void); // if filename is "/idv/code/file.cpp", it returns "file.cpp"
|
||||
// string m_sRaw;
|
||||
//};
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFileNameHelper Class
|
||||
|
||||
class CFileNameHelper
|
||||
{
|
||||
public:
|
||||
static void ChangeDosPath(std::string& str) {
|
||||
size_t nLength = str.length();
|
||||
|
||||
for (size_t i = 0; i < nLength; ++i)
|
||||
{
|
||||
if (str.at(i) == '/')
|
||||
str.at(i) = '\\';
|
||||
}
|
||||
}
|
||||
|
||||
static void StringPath(std::string& str) {
|
||||
size_t nLength = str.length();
|
||||
|
||||
for (size_t i = 0; i<nLength; ++i)
|
||||
{
|
||||
if (str.at(i) == '\\')
|
||||
str.at(i) = '/';
|
||||
else
|
||||
str.at(i) = (char)tolower(str.at(i));
|
||||
}
|
||||
}
|
||||
|
||||
static std::string GetName(std::string& str); // if filename is "/idv/code/file.cpp", it returns "file"
|
||||
static std::string GetExtension(std::string& str); // if filename is "/idv/code/file.cpp", it returns "cpp"
|
||||
static std::string GetPath(std::string& str); // if filename is "/idv/code/file.cpp", it returns "/idv/code"
|
||||
static std::string NoExtension(std::string& str); // if filename is "/idv/code/file.cpp", it returns "/idv/code/file"
|
||||
static std::string NoPath(std::string& str); // if filename is "/idv/code/file.cpp", it returns "file.cpp"
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFileNameHelper::GetExtension
|
||||
|
||||
inline std::string CFileNameHelper::GetName(std::string& str)
|
||||
{
|
||||
std::string strName;
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
size_t iExtensionStartPos = nLength - 1;
|
||||
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (str[i] == '.')
|
||||
{
|
||||
iExtensionStartPos = i;
|
||||
}
|
||||
|
||||
if (str[i] == '/')
|
||||
{
|
||||
strName = std::string(str.c_str() + i + 1);
|
||||
strName.resize(iExtensionStartPos - i - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return strName;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::GetExtension
|
||||
|
||||
inline std::string CFileNameHelper::GetExtension(std::string& str)
|
||||
{
|
||||
std::string strExtension;
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
for (size_t i = nLength - 1; i > 0 && str[i] != '/'; i--)
|
||||
if (str[i] == '.')
|
||||
{
|
||||
strExtension = std::string(str.c_str( ) + i + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strExtension;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::GetPath
|
||||
|
||||
inline std::string CFileNameHelper::GetPath(std::string& str)
|
||||
{
|
||||
char szPath[1024];
|
||||
szPath[0] = '\0';
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (str[i] == '/' || str[i] == '\\')
|
||||
{
|
||||
for (size_t j = 0; j < i + 1; j++)
|
||||
szPath[j] = str[j];
|
||||
szPath[i+1] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 == i)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return szPath;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::NoExtension
|
||||
|
||||
inline std::string CFileNameHelper::NoExtension(std::string& str)
|
||||
{
|
||||
std::size_t npos = str.find_last_of('.');
|
||||
|
||||
if (std::string::npos != npos)
|
||||
return std::string(str, 0, npos);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CFilenameHelper::NoPath
|
||||
|
||||
inline std::string CFileNameHelper::NoPath(std::string& str)
|
||||
{
|
||||
char szPath[1024];
|
||||
szPath[0] = '\0';
|
||||
|
||||
size_t nLength = str.length();
|
||||
|
||||
if (nLength > 0)
|
||||
{
|
||||
strcpy(szPath, str.c_str());
|
||||
|
||||
for (size_t i = nLength - 1; i > 0; i--)
|
||||
{
|
||||
if (str[i] == '/' || str[i] == '\\')
|
||||
{
|
||||
int k = 0;
|
||||
for (size_t j = i + 1; j < nLength; j++, k++)
|
||||
szPath[k] = str[j];
|
||||
szPath[k] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if (0 == i)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return szPath;
|
||||
}
|
259
src/EterBase/MappedFile.cpp
Normal file
259
src/EterBase/MappedFile.cpp
Normal file
@ -0,0 +1,259 @@
|
||||
#include "StdAfx.h"
|
||||
#include "MappedFile.h"
|
||||
#include "Debug.h"
|
||||
|
||||
CMappedFile::CMappedFile() :
|
||||
m_hFM(NULL),
|
||||
m_lpMapData(NULL),
|
||||
m_dataOffset(0),
|
||||
m_mapSize(0),
|
||||
m_seekPosition(0),
|
||||
m_pLZObj(NULL),
|
||||
m_pbBufLinkData(NULL),
|
||||
m_dwBufLinkSize(0),
|
||||
m_pbAppendResultDataBlock(NULL),
|
||||
m_dwAppendResultDataSize(0)
|
||||
{
|
||||
}
|
||||
|
||||
CMappedFile::~CMappedFile()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
BOOL CMappedFile::Create(const char * filename)
|
||||
{
|
||||
Destroy();
|
||||
return CFileBase::Create(filename, FILEMODE_READ);
|
||||
}
|
||||
|
||||
BOOL CMappedFile::Create(const char * filename, const void** dest, int offset, int size)
|
||||
{
|
||||
if (!CMappedFile::Create(filename))
|
||||
return NULL;
|
||||
|
||||
int ret = Map(dest, offset, size);
|
||||
return (ret) > 0;
|
||||
}
|
||||
|
||||
LPCVOID CMappedFile::Get()
|
||||
{
|
||||
return m_lpData;
|
||||
}
|
||||
|
||||
void CMappedFile::Link(DWORD dwBufSize, const void* c_pvBufData)
|
||||
{
|
||||
m_dwBufLinkSize=dwBufSize;
|
||||
m_pbBufLinkData=(BYTE*)c_pvBufData;
|
||||
}
|
||||
|
||||
void CMappedFile::BindLZObject(CLZObject * pLZObj)
|
||||
{
|
||||
assert(m_pLZObj == NULL);
|
||||
m_pLZObj = pLZObj;
|
||||
|
||||
Link(m_pLZObj->GetSize(), m_pLZObj->GetBuffer());
|
||||
}
|
||||
|
||||
void CMappedFile::BindLZObjectWithBufferedSize(CLZObject * pLZObj)
|
||||
{
|
||||
assert(m_pLZObj == NULL);
|
||||
m_pLZObj = pLZObj;
|
||||
|
||||
Link(m_pLZObj->GetBufferSize(), m_pLZObj->GetBuffer());
|
||||
}
|
||||
|
||||
BYTE* CMappedFile::AppendDataBlock( const void* pBlock, DWORD dwBlockSize )
|
||||
{
|
||||
if( m_pbAppendResultDataBlock )
|
||||
{
|
||||
delete []m_pbAppendResultDataBlock;
|
||||
}
|
||||
|
||||
//realloc
|
||||
m_dwAppendResultDataSize = m_dwBufLinkSize+dwBlockSize;
|
||||
m_pbAppendResultDataBlock = new BYTE[m_dwAppendResultDataSize];
|
||||
|
||||
memcpy(m_pbAppendResultDataBlock, m_pbBufLinkData, m_dwBufLinkSize );
|
||||
memcpy(m_pbAppendResultDataBlock + m_dwBufLinkSize, pBlock, dwBlockSize );
|
||||
|
||||
//redirect
|
||||
Link(m_dwAppendResultDataSize, m_pbAppendResultDataBlock);
|
||||
|
||||
return m_pbAppendResultDataBlock;
|
||||
}
|
||||
|
||||
void CMappedFile::Destroy()
|
||||
{
|
||||
if (m_pLZObj) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ȴ<EFBFBD>
|
||||
{
|
||||
delete m_pLZObj;
|
||||
m_pLZObj = NULL;
|
||||
}
|
||||
|
||||
if (NULL != m_lpMapData)
|
||||
{
|
||||
Unmap(m_lpMapData);
|
||||
m_lpMapData = NULL;
|
||||
}
|
||||
|
||||
if (NULL != m_hFM)
|
||||
{
|
||||
CloseHandle(m_hFM);
|
||||
m_hFM = NULL;
|
||||
}
|
||||
|
||||
if( m_pbAppendResultDataBlock )
|
||||
{
|
||||
delete []m_pbAppendResultDataBlock;
|
||||
m_pbAppendResultDataBlock = NULL;
|
||||
}
|
||||
|
||||
m_dwAppendResultDataSize = 0;
|
||||
|
||||
m_pbBufLinkData = NULL;
|
||||
m_dwBufLinkSize = 0;
|
||||
|
||||
m_seekPosition = 0;
|
||||
m_dataOffset = 0;
|
||||
m_mapSize = 0;
|
||||
|
||||
CFileBase::Destroy();
|
||||
}
|
||||
|
||||
int CMappedFile::Seek(DWORD offset, int iSeekType)
|
||||
{
|
||||
switch (iSeekType)
|
||||
{
|
||||
case SEEK_TYPE_BEGIN:
|
||||
if (offset > m_dwSize)
|
||||
offset = m_dwSize;
|
||||
|
||||
m_seekPosition = offset;
|
||||
break;
|
||||
|
||||
case SEEK_TYPE_CURRENT:
|
||||
m_seekPosition = min(m_seekPosition + offset, Size());
|
||||
break;
|
||||
|
||||
case SEEK_TYPE_END:
|
||||
m_seekPosition = max(0, Size() - offset);
|
||||
break;
|
||||
}
|
||||
|
||||
return m_seekPosition;
|
||||
}
|
||||
|
||||
// 2004.09.16.myevan.MemoryMappedFile 98/ME <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> üũ
|
||||
//DWORD g_dwCount=0;
|
||||
|
||||
int CMappedFile::Map(const void **dest, int offset, int size)
|
||||
{
|
||||
m_dataOffset = offset;
|
||||
|
||||
if (size == 0)
|
||||
m_mapSize = m_dwSize;
|
||||
else
|
||||
m_mapSize = size;
|
||||
|
||||
if (m_dataOffset + m_mapSize > m_dwSize)
|
||||
return NULL;
|
||||
|
||||
SYSTEM_INFO SysInfo;
|
||||
GetSystemInfo(&SysInfo);
|
||||
DWORD dwSysGran = SysInfo.dwAllocationGranularity;
|
||||
DWORD dwFileMapStart = (m_dataOffset / dwSysGran) * dwSysGran;
|
||||
DWORD dwMapViewSize = (m_dataOffset % dwSysGran) + m_mapSize;
|
||||
INT iViewDelta = m_dataOffset - dwFileMapStart;
|
||||
|
||||
|
||||
m_hFM = CreateFileMapping(m_hFile, // handle
|
||||
NULL, // security
|
||||
PAGE_READONLY, // flProtect
|
||||
0, // high
|
||||
m_dataOffset + m_mapSize, // low
|
||||
NULL); // name
|
||||
|
||||
if (!m_hFM)
|
||||
{
|
||||
OutputDebugString("CMappedFile::Map !m_hFM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_lpMapData = MapViewOfFile(m_hFM,
|
||||
FILE_MAP_READ,
|
||||
0,
|
||||
dwFileMapStart,
|
||||
dwMapViewSize);
|
||||
|
||||
if (!m_lpMapData) // Success
|
||||
{
|
||||
TraceError("CMappedFile::Map !m_lpMapData %lu", GetLastError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 2004.09.16.myevan.MemoryMappedFile 98/ME <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> üũ
|
||||
//g_dwCount++;
|
||||
//Tracenf("MAPFILE %d", g_dwCount);
|
||||
|
||||
m_lpData = (char*) m_lpMapData + iViewDelta;
|
||||
*dest = (char*) m_lpData;
|
||||
m_seekPosition = 0;
|
||||
|
||||
Link(m_mapSize, m_lpData);
|
||||
|
||||
return (m_mapSize);
|
||||
}
|
||||
|
||||
BYTE * CMappedFile::GetCurrentSeekPoint()
|
||||
{
|
||||
return m_pbBufLinkData+m_seekPosition;
|
||||
//return m_pLZObj ? m_pLZObj->GetBuffer() + m_seekPosition : (BYTE *) m_lpData + m_seekPosition;
|
||||
}
|
||||
|
||||
|
||||
DWORD CMappedFile::Size()
|
||||
{
|
||||
return m_dwBufLinkSize;
|
||||
/*
|
||||
if (m_pLZObj)
|
||||
return m_pLZObj->GetSize();
|
||||
|
||||
return (m_mapSize);
|
||||
*/
|
||||
}
|
||||
|
||||
DWORD CMappedFile::GetPosition()
|
||||
{
|
||||
return m_dataOffset;
|
||||
}
|
||||
|
||||
BOOL CMappedFile::Read(void * dest, int bytes)
|
||||
{
|
||||
if (m_seekPosition + bytes > Size())
|
||||
return FALSE;
|
||||
|
||||
memcpy(dest, GetCurrentSeekPoint(), bytes);
|
||||
m_seekPosition += bytes;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
DWORD CMappedFile::GetSeekPosition(void)
|
||||
{
|
||||
return m_seekPosition;
|
||||
}
|
||||
|
||||
void CMappedFile::Unmap(LPCVOID data)
|
||||
{
|
||||
if (UnmapViewOfFile(data))
|
||||
{
|
||||
// 2004.09.16.myevan.MemoryMappedFile 98/ME <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> üũ
|
||||
//g_dwCount--;
|
||||
//Tracenf("UNMAPFILE %d", g_dwCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceError("CMappedFile::Unmap - Error");
|
||||
}
|
||||
m_lpData = NULL;
|
||||
}
|
59
src/EterBase/MappedFile.h
Normal file
59
src/EterBase/MappedFile.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef __INC_MAPPEDFILE_H__
|
||||
#define __INC_MAPPEDFILE_H__
|
||||
|
||||
#include "lzo.h"
|
||||
#include "FileBase.h"
|
||||
|
||||
class CMappedFile : public CFileBase
|
||||
{
|
||||
public:
|
||||
enum ESeekType
|
||||
{
|
||||
SEEK_TYPE_BEGIN,
|
||||
SEEK_TYPE_CURRENT,
|
||||
SEEK_TYPE_END
|
||||
};
|
||||
|
||||
public:
|
||||
CMappedFile();
|
||||
virtual ~CMappedFile();
|
||||
|
||||
void Link(DWORD dwBufSize, const void* c_pvBufData);
|
||||
|
||||
BOOL Create(const char* filename);
|
||||
BOOL Create(const char* filename, const void** dest, int offset, int size);
|
||||
LPCVOID Get();
|
||||
void Destroy();
|
||||
int Seek(DWORD offset, int iSeekType = SEEK_TYPE_BEGIN);
|
||||
int Map(const void **dest, int offset=0, int size=0);
|
||||
DWORD Size();
|
||||
DWORD GetPosition();
|
||||
BOOL Read(void* dest, int bytes);
|
||||
DWORD GetSeekPosition();
|
||||
void BindLZObject(CLZObject * pLZObj);
|
||||
void BindLZObjectWithBufferedSize(CLZObject * pLZObj);
|
||||
BYTE* AppendDataBlock( const void* pBlock, DWORD dwBlockSize );
|
||||
|
||||
BYTE * GetCurrentSeekPoint();
|
||||
|
||||
private:
|
||||
void Unmap(LPCVOID data);
|
||||
|
||||
private:
|
||||
BYTE* m_pbBufLinkData;
|
||||
DWORD m_dwBufLinkSize;
|
||||
|
||||
BYTE* m_pbAppendResultDataBlock;
|
||||
DWORD m_dwAppendResultDataSize;
|
||||
|
||||
DWORD m_seekPosition;
|
||||
HANDLE m_hFM;
|
||||
DWORD m_dataOffset;
|
||||
DWORD m_mapSize;
|
||||
LPVOID m_lpMapData;
|
||||
LPVOID m_lpData;
|
||||
|
||||
CLZObject * m_pLZObj;
|
||||
};
|
||||
|
||||
#endif
|
27
src/EterBase/Poly/Base.cpp
Normal file
27
src/EterBase/Poly/Base.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "../StdAfx.h"
|
||||
#include "Base.h"
|
||||
|
||||
CBase::CBase()
|
||||
{
|
||||
id = 0;
|
||||
}
|
||||
|
||||
CBase::~CBase()
|
||||
{
|
||||
}
|
||||
|
||||
bool CBase::isNumber()
|
||||
{
|
||||
return (id & MID_NUMBER) != 0 ? true : false;
|
||||
}
|
||||
|
||||
bool CBase::isVar()
|
||||
{
|
||||
return (id & MID_VARIABLE) != 0 ? true : false;
|
||||
}
|
||||
|
||||
bool CBase::isSymbol()
|
||||
{
|
||||
return (id & MID_SYMBOL) != 0 ? true : false;
|
||||
}
|
||||
|
25
src/EterBase/Poly/Base.h
Normal file
25
src/EterBase/Poly/Base.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __POLY_BASE_H__
|
||||
#define __POLY_BASE_H__
|
||||
|
||||
#define MID_UNKNOWN 0
|
||||
#define MID_NUMBER 256
|
||||
#define MID_VARIABLE 512
|
||||
#define MID_SYMBOL 1024
|
||||
|
||||
#define MID_LONG MID_NUMBER + 1
|
||||
#define MID_SQRT MID_NUMBER + 2
|
||||
#define MID_FRACTION MID_NUMBER + 3
|
||||
|
||||
class CBase
|
||||
{
|
||||
public:
|
||||
bool isSymbol();
|
||||
bool isVar();
|
||||
bool isNumber();
|
||||
int id;
|
||||
CBase();
|
||||
virtual ~CBase();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
622
src/EterBase/Poly/Poly.cpp
Normal file
622
src/EterBase/Poly/Poly.cpp
Normal file
@ -0,0 +1,622 @@
|
||||
#include "../StdAfx.h"
|
||||
#include <string>
|
||||
#include <assert.h>
|
||||
|
||||
#include "Poly.h"
|
||||
#include <cmath>
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
|
||||
using namespace std;
|
||||
|
||||
double _random()
|
||||
{
|
||||
return rand() / (RAND_MAX + 1.0);
|
||||
}
|
||||
|
||||
void CPoly::SetRandom(int iRandomType)
|
||||
{
|
||||
m_iRandomType = iRandomType;
|
||||
}
|
||||
|
||||
int CPoly::my_irandom(double start, double end)
|
||||
{
|
||||
switch (m_iRandomType)
|
||||
{
|
||||
case RANDOM_TYPE_FORCE_MIN:
|
||||
return int(start);
|
||||
break;
|
||||
case RANDOM_TYPE_FORCE_MAX:
|
||||
return int(end);
|
||||
break;
|
||||
}
|
||||
|
||||
// Make range as inclusive-exclusive
|
||||
int is = int(start + 0.5);
|
||||
int ie = int(end - start + 0.5) + 1;
|
||||
|
||||
return int(_random() * ie + is);
|
||||
}
|
||||
|
||||
double CPoly::my_frandom(double start, double end)
|
||||
{
|
||||
return _random() * (end - start) + start;
|
||||
}
|
||||
|
||||
CPoly::CPoly()
|
||||
{
|
||||
m_iRandomType = RANDOM_TYPE_FREELY;
|
||||
uiLookPos = 0;
|
||||
ErrorOccur = true;
|
||||
lSymbol.clear();
|
||||
STSize = 0;
|
||||
MathSymbolCount = 0;
|
||||
lSymbol.reserve(50);
|
||||
init();
|
||||
}
|
||||
|
||||
CPoly::~CPoly()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void CPoly::SetStr(const string & str)
|
||||
{
|
||||
strData = str;
|
||||
}
|
||||
|
||||
float CPoly::Eval()
|
||||
{
|
||||
int stNow;
|
||||
double save[POLY_MAXSTACK],t;
|
||||
int iSp=0;
|
||||
if (ErrorOccur)
|
||||
{
|
||||
/*THROW(new CEvalException("Evaluate Error"));*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
//TEST
|
||||
//list<int>::iterator pos = tokenBase.begin();
|
||||
//list<double>::iterator posn = numBase.begin();
|
||||
vector<int>::iterator pos = tokenBase.begin();
|
||||
vector<double>::iterator posn = numBase.begin();
|
||||
while (pos != tokenBase.end())
|
||||
{
|
||||
|
||||
stNow=*pos;
|
||||
++pos;
|
||||
switch (stNow)
|
||||
{
|
||||
case POLY_NUM:
|
||||
save[iSp++]=*posn++; break;
|
||||
case POLY_ID:
|
||||
save[iSp++]=
|
||||
lSymbol[ *pos ]->dVal;
|
||||
pos++;
|
||||
break;
|
||||
//case '+':
|
||||
case POLY_PLU:
|
||||
iSp--;
|
||||
save[iSp-1]+=save[iSp]; break;
|
||||
//case '-':
|
||||
case POLY_MIN:
|
||||
iSp--;
|
||||
save[iSp-1]-=save[iSp]; break;
|
||||
//case '*':
|
||||
case POLY_MUL:
|
||||
iSp--;
|
||||
save[iSp-1]*=save[iSp]; break;
|
||||
//case '%':
|
||||
case POLY_MOD:
|
||||
iSp--;
|
||||
if (save[iSp]==0)
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=fmod(save[iSp-1],save[iSp]); break;
|
||||
//case '/':
|
||||
case POLY_DIV:
|
||||
iSp--;
|
||||
if (save[iSp]==0)
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]/=save[iSp]; break;
|
||||
//case '^':
|
||||
case POLY_POW:
|
||||
iSp--;
|
||||
save[iSp-1]=pow(save[iSp-1],save[iSp]); break;
|
||||
case POLY_ROOT:
|
||||
if (save[iSp-1]<0)
|
||||
{
|
||||
//THROW(new CEvalException("Negative in root"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=sqrt(save[iSp-1]); break;
|
||||
case POLY_COS:
|
||||
save[iSp-1]=cos(save[iSp-1]); break;
|
||||
case POLY_SIN:
|
||||
save[iSp-1]=sin(save[iSp-1]); break;
|
||||
case POLY_TAN:
|
||||
if (!(t=cos(save[iSp-1])))
|
||||
{
|
||||
//THROW (new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=tan(save[iSp-1]); break;
|
||||
case POLY_CSC:
|
||||
if (!(t=sin(save[iSp-1])))
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=1/t; break;
|
||||
case POLY_SEC:
|
||||
if (!(t=cos(save[iSp-1])))
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=1/t; break;
|
||||
case POLY_COT:
|
||||
if (!(t=sin(save[iSp-1])))
|
||||
{
|
||||
//THROW(new CEvalException("Divide by 0"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=cos(save[iSp-1])/t; break;
|
||||
case POLY_LN:
|
||||
if (save[iSp-1]<=0)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=log(save[iSp-1]); break;
|
||||
case POLY_LOG10:
|
||||
if (save[iSp-1]<=0)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
save[iSp-1]=log10(save[iSp-1]); break;
|
||||
case POLY_LOG:
|
||||
if (save[iSp-1]<=0)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
if (save[iSp-2]<=0 || save[iSp-2]==1)
|
||||
{
|
||||
//THROW( new CEvalException("Call Log with minus number"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
save[iSp-2]=log(save[iSp-1])/log(save[iSp-2]);
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_ABS:
|
||||
save[iSp-1]=fabs(save[iSp-1]);
|
||||
break;
|
||||
case POLY_FLOOR:
|
||||
save[iSp-1]=floor(save[iSp-1]);
|
||||
break;
|
||||
case POLY_IRAND:
|
||||
save[iSp-2]=my_irandom(save[iSp-2],save[iSp-1]);
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_FRAND:
|
||||
save[iSp-2]=my_frandom(save[iSp-2],save[iSp-1]);
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_MINF:
|
||||
save[iSp-2]=(save[iSp-2]<save[iSp-1])?save[iSp-2]:save[iSp-1];
|
||||
iSp--;
|
||||
break;
|
||||
case POLY_MAXF:
|
||||
save[iSp-2]=(save[iSp-2]>save[iSp-1])?save[iSp-2]:save[iSp-1];
|
||||
iSp--;
|
||||
break;
|
||||
/*case POLY_MOD:
|
||||
save[iSp-2]=fmod(save[iSp-2],save[iSp-1]);
|
||||
iSp--;
|
||||
break;*/
|
||||
default:
|
||||
return 0;
|
||||
//THROW(new CEvalException("Token Error"));
|
||||
}
|
||||
}
|
||||
return float(save[iSp-1]);
|
||||
}
|
||||
|
||||
int CPoly::Analyze(const char * pszStr)
|
||||
{
|
||||
if (pszStr)
|
||||
SetStr(pszStr);
|
||||
|
||||
if (0 == strData.length())
|
||||
return true;
|
||||
|
||||
//DisposeList();
|
||||
ErrorOccur = false;
|
||||
uiLookPos = 0;
|
||||
iLookAhead = lexan();
|
||||
|
||||
expr();
|
||||
|
||||
if (tokenBase.empty())
|
||||
{
|
||||
//THROW(new CParseException("No Data"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return !ErrorOccur;
|
||||
}
|
||||
|
||||
void CPoly::Clear()
|
||||
{
|
||||
int i;
|
||||
//while (!tokenBase.IsEmpty()) listBase.RemoveTail();
|
||||
//while (!numBase.IsEmpty()) numBase.RemoveTail();
|
||||
tokenBase.clear();
|
||||
numBase.clear();
|
||||
|
||||
for (i = 0;i < STSize; ++i)
|
||||
{
|
||||
if (lSymbol[i]) delete lSymbol[i];
|
||||
lSymbol[i]=NULL;
|
||||
}
|
||||
//lSymbol.FreeExtra();
|
||||
lSymbol.clear();
|
||||
SymbolIndex.clear();
|
||||
STSize=0;
|
||||
MathSymbolCount=0;
|
||||
}
|
||||
|
||||
void CPoly::expr()
|
||||
{
|
||||
int t;
|
||||
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
uiLookPos--;
|
||||
iLookAhead = POLY_NUM;
|
||||
iNumToken = iToken = 0;
|
||||
|
||||
}
|
||||
|
||||
term();
|
||||
|
||||
while (!ErrorOccur)
|
||||
{
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '+':
|
||||
case '-':
|
||||
t=iLookAhead;
|
||||
match(t);
|
||||
term();
|
||||
emit(t,POLY_NONE);
|
||||
continue;
|
||||
case POLY_EOS: case ')': case ',': return;
|
||||
default:
|
||||
error();
|
||||
//THROW( new CParseException("Error Parsing"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::error()
|
||||
{
|
||||
iErrorPos=uiLookPos;
|
||||
ErrorOccur=true;
|
||||
}
|
||||
|
||||
int CPoly::lexan()
|
||||
{
|
||||
int t;
|
||||
double tt;
|
||||
|
||||
while (uiLookPos < strData.size())
|
||||
{
|
||||
if (strData[uiLookPos] == ' ' || strData[uiLookPos] == '\t')
|
||||
;
|
||||
else if (isdigit(strData[uiLookPos]))
|
||||
{
|
||||
t = 0;
|
||||
for (;uiLookPos<strData.size();uiLookPos++)
|
||||
{
|
||||
if (isdigit(strData[uiLookPos]))
|
||||
t = t * 10 + strData[uiLookPos] - '0';
|
||||
else
|
||||
break;
|
||||
}
|
||||
iToken=t;
|
||||
tt=0.1;
|
||||
iNumToken=0;
|
||||
if (uiLookPos<strData.size() && strData[uiLookPos]=='.')
|
||||
{
|
||||
uiLookPos++;
|
||||
for (;uiLookPos<strData.size();uiLookPos++,tt*=0.1)
|
||||
{
|
||||
if (isdigit(strData[uiLookPos]))
|
||||
iNumToken+=tt*(strData[uiLookPos]-'0');
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
iNumToken+=iToken;
|
||||
return POLY_NUM;
|
||||
}
|
||||
else if (isalpha(strData[uiLookPos]))
|
||||
{
|
||||
string localSymbol("");
|
||||
while (uiLookPos<strData.size() && isalpha(strData[uiLookPos]))
|
||||
{
|
||||
localSymbol+=strData[uiLookPos];
|
||||
uiLookPos++;
|
||||
}
|
||||
iToken= find(localSymbol);
|
||||
if (iToken==-1)
|
||||
{
|
||||
iToken=insert(localSymbol,POLY_ID);
|
||||
}
|
||||
return lSymbol[(/*FindIndex*/(iToken))]->token;
|
||||
}
|
||||
else
|
||||
{
|
||||
iToken=0;
|
||||
return strData[uiLookPos++];
|
||||
}
|
||||
uiLookPos++;
|
||||
}
|
||||
return POLY_EOS;
|
||||
}
|
||||
|
||||
void CPoly::term()
|
||||
{
|
||||
int t;
|
||||
factor();
|
||||
while (!ErrorOccur)
|
||||
{
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '*':
|
||||
case '/':
|
||||
case '%':
|
||||
t=iLookAhead;
|
||||
match(t);
|
||||
factor();
|
||||
emit(t,POLY_NONE);
|
||||
continue;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::factor()
|
||||
{
|
||||
int t;
|
||||
expo();
|
||||
while (!ErrorOccur)
|
||||
{
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '^':
|
||||
t=iLookAhead;
|
||||
match(t);
|
||||
expo();
|
||||
emit(t,POLY_NONE);
|
||||
continue;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::expo()
|
||||
{
|
||||
int t;
|
||||
switch (iLookAhead)
|
||||
{
|
||||
case '(':
|
||||
match('('); expr(); match(')'); break;
|
||||
case POLY_NUM:
|
||||
emit(POLY_NUM, iToken); match(POLY_NUM); break;
|
||||
case POLY_ID:
|
||||
emit(POLY_ID,(int)/*FindIndex*/(iToken)); match(POLY_ID); break;
|
||||
case POLY_ROOT:
|
||||
case POLY_SIN:
|
||||
case POLY_COT:
|
||||
case POLY_TAN:
|
||||
case POLY_CSC:
|
||||
case POLY_SEC:
|
||||
case POLY_LN:
|
||||
case POLY_LOG10:
|
||||
case POLY_COS:
|
||||
case POLY_ABS:
|
||||
case POLY_FLOOR:
|
||||
t=iLookAhead;
|
||||
match(iLookAhead); match('('); expr(); match(')'); emit(t,iToken);
|
||||
break;
|
||||
case POLY_LOG:
|
||||
case POLY_MINF:
|
||||
case POLY_MAXF:
|
||||
case POLY_IRAND:
|
||||
case POLY_FRAND:
|
||||
case POLY_MOD:
|
||||
t=iLookAhead;
|
||||
match(iLookAhead); match('('); expr(); match(','); expr(); match(')'); emit(t,iToken);
|
||||
break;
|
||||
case POLY_EOS:
|
||||
break;
|
||||
default:
|
||||
error();
|
||||
//THROW( new CParseException("Error Parsing"));
|
||||
}
|
||||
}
|
||||
|
||||
void CPoly::match(int t)
|
||||
{
|
||||
if (iLookAhead==t) iLookAhead=lexan(); else error();
|
||||
}
|
||||
|
||||
void CPoly::emit(int t, int tval)
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case '+':
|
||||
tokenBase.push_back(POLY_PLU);
|
||||
break;
|
||||
case '-':
|
||||
tokenBase.push_back(POLY_MIN);
|
||||
break;
|
||||
case '*':
|
||||
tokenBase.push_back(POLY_MUL);
|
||||
break;
|
||||
case '/':
|
||||
tokenBase.push_back(POLY_DIV);
|
||||
break;
|
||||
case '%':
|
||||
tokenBase.push_back(POLY_MOD);
|
||||
break;
|
||||
case '^':
|
||||
tokenBase.push_back(POLY_POW);
|
||||
break;
|
||||
case POLY_ROOT:
|
||||
case POLY_SIN:
|
||||
case POLY_TAN:
|
||||
case POLY_COT:
|
||||
case POLY_COS:
|
||||
case POLY_CSC:
|
||||
case POLY_SEC:
|
||||
case POLY_LOG:
|
||||
case POLY_LN:
|
||||
case POLY_LOG10:
|
||||
case POLY_ABS:
|
||||
case POLY_MINF:
|
||||
case POLY_MAXF:
|
||||
case POLY_IRAND:
|
||||
case POLY_FRAND:
|
||||
case POLY_MOD:
|
||||
case POLY_FLOOR:
|
||||
tokenBase.push_back(t);
|
||||
break;
|
||||
case POLY_NUM:
|
||||
tokenBase.push_back(t);
|
||||
numBase.push_back(iNumToken);
|
||||
break;
|
||||
case POLY_ID:
|
||||
tokenBase.push_back(t);
|
||||
tokenBase.push_back(tval); break;
|
||||
default:
|
||||
error();
|
||||
Clear();
|
||||
//THROW( new CParseException("Error Parsing"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int CPoly::find(const string & s)
|
||||
{
|
||||
int l, m, r;
|
||||
|
||||
l = 0;
|
||||
r = STSize - 1;
|
||||
|
||||
while (l <= r)
|
||||
{
|
||||
m = (l + r) >> 1;
|
||||
|
||||
if (lSymbol[SymbolIndex[m]]->strlex == s)
|
||||
return SymbolIndex[m];
|
||||
else if (lSymbol[SymbolIndex[m]]->strlex < s)
|
||||
l = m + 1;
|
||||
else
|
||||
r = m - 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int CPoly::insert(const string & s, int tok)
|
||||
{
|
||||
int i;
|
||||
bool bAdded=false;
|
||||
|
||||
lSymbol.push_back(new CSymTable(tok,s));
|
||||
for (i=0;i<STSize;i++)
|
||||
{
|
||||
if (s<lSymbol[SymbolIndex[i]]->strlex)
|
||||
{
|
||||
SymbolIndex.insert(SymbolIndex.begin()+i,STSize);
|
||||
bAdded=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bAdded)
|
||||
{
|
||||
//SymbolIndex.SetAtGrow(STSize,STSize);
|
||||
SymbolIndex.push_back(STSize);
|
||||
}
|
||||
STSize++;
|
||||
return STSize-1;
|
||||
}
|
||||
|
||||
int CPoly::SetVar(const string & strName, double dVar)
|
||||
{
|
||||
|
||||
if (ErrorOccur) return false;
|
||||
int index=find(strName);
|
||||
if (index==-1) return false;
|
||||
CSymTable* stVar = lSymbol[(/*FindIndex*/(index))];
|
||||
stVar->dVal=dVar;
|
||||
return true;
|
||||
}
|
||||
|
||||
int CPoly::GetVarCount()
|
||||
{
|
||||
return lSymbol.size() - MathSymbolCount;
|
||||
}
|
||||
|
||||
const char * CPoly::GetVarName(unsigned int dwIndex)
|
||||
{
|
||||
assert(dwIndex + MathSymbolCount < lSymbol.size());
|
||||
return lSymbol[dwIndex + MathSymbolCount]->strlex.c_str();
|
||||
}
|
||||
|
||||
void CPoly::init()
|
||||
{
|
||||
insert("min",POLY_MINF);
|
||||
insert("max",POLY_MAXF);
|
||||
insert("number", POLY_IRAND);
|
||||
insert("irandom", POLY_IRAND);
|
||||
insert("irand", POLY_IRAND);
|
||||
insert("frandom",POLY_FRAND);
|
||||
insert("frand",POLY_FRAND);
|
||||
insert("rt",POLY_ROOT);
|
||||
insert("sqrt",POLY_ROOT);
|
||||
insert("cos",POLY_COS);
|
||||
insert("sin",POLY_SIN);
|
||||
insert("tan",POLY_TAN);
|
||||
insert("cot",POLY_COT);
|
||||
insert("csc",POLY_CSC);
|
||||
insert("cosec",POLY_COSEC);
|
||||
insert("sec",POLY_SEC);
|
||||
insert("pi",POLY_PI);
|
||||
SetVar("pi",3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068);
|
||||
insert("e",POLY_EXP);
|
||||
SetVar("e",2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427);
|
||||
insert("log",POLY_LOG);
|
||||
insert("ln",POLY_LN);
|
||||
insert("log10",POLY_LOG10);
|
||||
insert("abs",POLY_ABS);
|
||||
insert("mod",POLY_MOD);
|
||||
insert("floor",POLY_FLOOR);
|
||||
MathSymbolCount = STSize;
|
||||
}
|
106
src/EterBase/Poly/Poly.h
Normal file
106
src/EterBase/Poly/Poly.h
Normal file
@ -0,0 +1,106 @@
|
||||
#ifndef __POLY_POLY_H__
|
||||
#define __POLY_POLY_H__
|
||||
|
||||
#include "SymTable.h"
|
||||
|
||||
#pragma warning ( push, 3 )
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#pragma warning ( pop )
|
||||
|
||||
#define POLY_MAXVALUE 0
|
||||
#define POLY_NONE POLY_MAXVALUE
|
||||
#define POLY_ROOT POLY_MAXVALUE + 1
|
||||
#define POLY_MUL POLY_MAXVALUE + 2
|
||||
#define POLY_PLU POLY_MAXVALUE + 3
|
||||
#define POLY_POW POLY_MAXVALUE + 4
|
||||
#define POLY_MIN POLY_MAXVALUE + 5
|
||||
#define POLY_DIV POLY_MAXVALUE + 6
|
||||
#define POLY_OPEN POLY_MAXVALUE + 7
|
||||
#define POLY_CLOSE POLY_MAXVALUE + 8
|
||||
#define POLY_NUM POLY_MAXVALUE + 9
|
||||
#define POLY_ID POLY_MAXVALUE + 10
|
||||
#define POLY_EOS POLY_MAXVALUE + 11
|
||||
#define POLY_COS POLY_MAXVALUE + 12
|
||||
#define POLY_SIN POLY_MAXVALUE + 13
|
||||
#define POLY_TAN POLY_MAXVALUE + 14
|
||||
#define POLY_COSEC POLY_MAXVALUE + 15
|
||||
#define POLY_CSC POLY_COSEC
|
||||
#define POLY_SEC POLY_MAXVALUE + 16
|
||||
#define POLY_COT POLY_MAXVALUE + 17
|
||||
#define POLY_PI POLY_ID
|
||||
#define POLY_EXP POLY_ID
|
||||
#define POLY_LOG POLY_MAXVALUE + 18
|
||||
#define POLY_LN POLY_MAXVALUE + 19
|
||||
#define POLY_LOG10 POLY_MAXVALUE + 20
|
||||
|
||||
#define POLY_ABS POLY_MAXVALUE + 21
|
||||
#define POLY_MINF POLY_MAXVALUE + 22
|
||||
#define POLY_MAXF POLY_MAXVALUE + 23
|
||||
#define POLY_IRAND POLY_MAXVALUE + 24
|
||||
#define POLY_FRAND POLY_MAXVALUE + 25
|
||||
#define POLY_MOD POLY_MAXVALUE + 26
|
||||
#define POLY_FLOOR POLY_MAXVALUE + 27
|
||||
|
||||
#define POLY_MAXSTACK 100
|
||||
|
||||
class CPoly
|
||||
{
|
||||
public:
|
||||
enum ERandomType
|
||||
{
|
||||
RANDOM_TYPE_FREELY,
|
||||
RANDOM_TYPE_FORCE_MIN,
|
||||
RANDOM_TYPE_FORCE_MAX,
|
||||
};
|
||||
|
||||
public:
|
||||
CPoly();
|
||||
virtual ~CPoly();
|
||||
|
||||
int Analyze(const char * pszStr = NULL);
|
||||
float Eval();
|
||||
void SetRandom(int iRandomType);
|
||||
void SetStr(const std::string & str);
|
||||
int SetVar(const std::string & strName, double dVar);
|
||||
int GetVarCount();
|
||||
const char * GetVarName(unsigned int dwIndex);
|
||||
void Clear();
|
||||
|
||||
protected:
|
||||
int my_irandom(double start, double end);
|
||||
double my_frandom(double start, double end);
|
||||
|
||||
void init();
|
||||
int insert(const std::string & s, int tok);
|
||||
int find(const std::string & s);
|
||||
void emit(int t,int tval);
|
||||
void match(int t);
|
||||
void expo();
|
||||
void factor();
|
||||
void term();
|
||||
int iToken;
|
||||
double iNumToken;
|
||||
int iLookAhead;
|
||||
int lexan();
|
||||
int iErrorPos;
|
||||
void error();
|
||||
void expr();
|
||||
bool ErrorOccur;
|
||||
unsigned int uiLookPos;
|
||||
|
||||
// NOTE: list is slight faster than vector, why?!
|
||||
std::vector<int> tokenBase;
|
||||
std::vector<double> numBase;
|
||||
std::vector<CSymTable *> lSymbol;
|
||||
std::vector<int> SymbolIndex;
|
||||
int STSize;
|
||||
int MathSymbolCount;
|
||||
std::string strData;
|
||||
int m_iRandomType;
|
||||
};
|
||||
|
||||
#endif
|
13
src/EterBase/Poly/SymTable.cpp
Normal file
13
src/EterBase/Poly/SymTable.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "../StdAfx.h"
|
||||
#include "SymTable.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
CSymTable::CSymTable(int aTok, string aStr) : dVal(0), token(aTok), strlex(aStr)
|
||||
{
|
||||
}
|
||||
|
||||
CSymTable::~CSymTable()
|
||||
{
|
||||
}
|
||||
|
17
src/EterBase/Poly/SymTable.h
Normal file
17
src/EterBase/Poly/SymTable.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __POLY_SYMTABLE_H__
|
||||
#define __POLY_SYMTABLE_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
class CSymTable
|
||||
{
|
||||
public:
|
||||
CSymTable(int aTok, std::string aStr);
|
||||
virtual ~CSymTable();
|
||||
|
||||
double dVal;
|
||||
int token;
|
||||
std::string strlex;
|
||||
};
|
||||
|
||||
#endif
|
50
src/EterBase/Poly/Symbol.cpp
Normal file
50
src/EterBase/Poly/Symbol.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "../StdAfx.h"
|
||||
#include "Symbol.h"
|
||||
|
||||
CSymbol::CSymbol()
|
||||
{
|
||||
id = MID_SYMBOL;
|
||||
iType = ST_UNKNOWN;
|
||||
}
|
||||
|
||||
CSymbol::~CSymbol()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CSymbol::Equal(CSymbol dif)
|
||||
{
|
||||
if (dif.iType/10 == iType/10) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CSymbol::Less(CSymbol dif)
|
||||
{
|
||||
if (dif.iType/10 > iType/10) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
int CSymbol::GetType()
|
||||
{
|
||||
return iType;
|
||||
}
|
||||
|
||||
void CSymbol::SetType(int Type)
|
||||
{
|
||||
iType=Type;
|
||||
}
|
||||
|
||||
int CSymbol::issymbol(int ch)
|
||||
{
|
||||
switch(ch)
|
||||
{
|
||||
case SY_PLUS : return ST_PLUS;
|
||||
case SY_MINUS : return ST_MINUS;
|
||||
case SY_MULTIPLY: return ST_MULTIPLY;
|
||||
case SY_DIVIDE : return SY_DIVIDE;
|
||||
case SY_CARET : return SY_CARET;
|
||||
case SY_OPEN : return SY_OPEN;
|
||||
case SY_CLOSE : return ST_CLOSE;
|
||||
}
|
||||
return 0;
|
||||
}
|
39
src/EterBase/Poly/Symbol.h
Normal file
39
src/EterBase/Poly/Symbol.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef __POLY_SYMBOL_H__
|
||||
#define __POLY_SYMBOL_H__
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
#define ST_UNKNOWN 0
|
||||
#define ST_PLUS 11
|
||||
#define ST_MINUS 12
|
||||
#define ST_MULTIPLY 23
|
||||
#define ST_DIVIDE 24
|
||||
#define ST_CARET 35
|
||||
#define ST_OPEN 06
|
||||
#define ST_CLOSE 07
|
||||
|
||||
#define SY_PLUS '+'
|
||||
#define SY_MINUS '-'
|
||||
#define SY_MULTIPLY '*'
|
||||
#define SY_DIVIDE '/'
|
||||
#define SY_CARET '^'
|
||||
#define SY_OPEN '('
|
||||
#define SY_CLOSE ')'
|
||||
|
||||
class CSymbol : public CBase
|
||||
{
|
||||
private:
|
||||
int iType;
|
||||
|
||||
public:
|
||||
CSymbol();
|
||||
virtual ~CSymbol();
|
||||
|
||||
static int issymbol(int ch);
|
||||
void SetType(int Type);
|
||||
int GetType();
|
||||
bool Equal(CSymbol dif);
|
||||
bool Less(CSymbol dif);
|
||||
};
|
||||
|
||||
#endif
|
48
src/EterBase/Random.cpp
Normal file
48
src/EterBase/Random.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static unsigned long randseed = 1;
|
||||
|
||||
void srandom(unsigned long seed)
|
||||
{
|
||||
randseed = seed;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pseudo-random number generator for randomizing the profiling clock,
|
||||
* and whatever else we might use it for. The result is uniform on
|
||||
* [0, 2^31 - 1].
|
||||
*/
|
||||
unsigned long random()
|
||||
{
|
||||
register long x, hi, lo, t;
|
||||
|
||||
/*
|
||||
* Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
|
||||
* From "Random number generators: good ones are hard to find",
|
||||
* Park and Miller, Communications of the ACM, vol. 31, no. 10,
|
||||
* October 1988, p. 1195.
|
||||
*/
|
||||
x = randseed;
|
||||
hi = x / 127773;
|
||||
lo = x % 127773;
|
||||
t = 16807 * lo - 2836 * hi;
|
||||
if (t <= 0)
|
||||
t += 0x7fffffff;
|
||||
randseed = t;
|
||||
return (t);
|
||||
}
|
||||
|
||||
|
||||
float frandom(float flLow, float flHigh)
|
||||
{
|
||||
float fl = float(random()) / float(2147483648.0f); // float in [0,1)
|
||||
return (fl * (flHigh - flLow)) + flLow; // float in [low,high)
|
||||
}
|
||||
|
||||
long random_range(long from, long to)
|
||||
{
|
||||
assert(from <= to);
|
||||
return ((random() % (to - from + 1)) + from);
|
||||
}
|
9
src/EterBase/Random.h
Normal file
9
src/EterBase/Random.h
Normal file
@ -0,0 +1,9 @@
|
||||
#ifndef __INC_ETERBASE_RANDOM_H__
|
||||
#define __INC_ETERBASE_RANDOM_H__
|
||||
|
||||
extern void srandom(unsigned long seed);
|
||||
extern unsigned long random();
|
||||
extern float frandom(float flLow, float flHigh);
|
||||
extern long random_range(long from, long to);
|
||||
|
||||
#endif
|
4
src/EterBase/ServiceDefs.h
Normal file
4
src/EterBase/ServiceDefs.h
Normal file
@ -0,0 +1,4 @@
|
||||
#ifndef _EL_SERVICEDEFS_H_
|
||||
#define _EL_SERVICEDEFS_H_
|
||||
|
||||
#endif //_EL_SERVICEDEFS_H_
|
85
src/EterBase/Singleton.h
Normal file
85
src/EterBase/Singleton.h
Normal file
@ -0,0 +1,85 @@
|
||||
#ifndef __INC_ETERLIB_SINGLETON_H__
|
||||
#define __INC_ETERLIB_SINGLETON_H__
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
template <typename T> class CSingleton
|
||||
{
|
||||
static T * ms_singleton;
|
||||
|
||||
public:
|
||||
CSingleton()
|
||||
{
|
||||
assert(!ms_singleton);
|
||||
int offset = (int) (T*) 1 - (int) (CSingleton <T>*) (T*) 1;
|
||||
ms_singleton = (T*) ((int) this + offset);
|
||||
}
|
||||
|
||||
virtual ~CSingleton()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
ms_singleton = 0;
|
||||
}
|
||||
|
||||
__forceinline static T & Instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T * InstancePtr()
|
||||
{
|
||||
return (ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T & instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> T * CSingleton <T>::ms_singleton = 0;
|
||||
|
||||
//
|
||||
// singleton for non-hungarian
|
||||
//
|
||||
template <typename T> class singleton
|
||||
{
|
||||
static T * ms_singleton;
|
||||
|
||||
public:
|
||||
singleton()
|
||||
{
|
||||
assert(!ms_singleton);
|
||||
int offset = (int) (T*) 1 - (int) (singleton <T>*) (T*) 1;
|
||||
ms_singleton = (T*) ((int) this + offset);
|
||||
}
|
||||
|
||||
virtual ~singleton()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
ms_singleton = 0;
|
||||
}
|
||||
|
||||
__forceinline static T & Instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T * InstancePtr()
|
||||
{
|
||||
return (ms_singleton);
|
||||
}
|
||||
|
||||
__forceinline static T & instance()
|
||||
{
|
||||
assert(ms_singleton);
|
||||
return (*ms_singleton);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T> T * singleton <T>::ms_singleton = 0;
|
||||
|
||||
#endif
|
6
src/EterBase/StdAfx.cpp
Normal file
6
src/EterBase/StdAfx.cpp
Normal file
@ -0,0 +1,6 @@
|
||||
// stdafx.cpp : source file that includes just the standard includes
|
||||
// eterBase.pch will be the pre-compiled header
|
||||
// stdafx.obj will contain the pre-compiled type information
|
||||
|
||||
#include "stdafx.h"
|
||||
|
55
src/EterBase/StdAfx.h
Normal file
55
src/EterBase/StdAfx.h
Normal file
@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#ifndef _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#pragma warning(disable:4710) // not inlined
|
||||
#pragma warning(disable:4786) // character 255 <20>Ѿ<D1BE>°<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
#pragma warning(disable:4244) // type conversion possible lose of data
|
||||
|
||||
#include <windows.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#pragma warning ( disable : 4201 )
|
||||
#include <mmsystem.h>
|
||||
#pragma warning ( default : 4201 )
|
||||
#include <imagehlp.h>
|
||||
#include <time.h>
|
||||
|
||||
#pragma warning ( push, 3 )
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
#pragma warning ( pop )
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
#define stricmp _stricmp
|
||||
#define strnicmp _strnicmp
|
||||
#define strupt _strupr
|
||||
#define strcmpi _strcmpi
|
||||
#define fileno _fileno
|
||||
//#define access _access_s
|
||||
//#define _access _access_s
|
||||
#define atoi _atoi64
|
||||
#endif
|
||||
|
||||
// Armadillo nanomite protection
|
||||
#if !defined(NANOBEGIN) && !defined(NANOEND)
|
||||
#ifdef _DEBUG
|
||||
#define NANOBEGIN
|
||||
#define NANOEND
|
||||
#else
|
||||
#include <armadillo/SecuredSections.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "vk.h"
|
||||
#include "filename.h"
|
||||
#include "ServiceDefs.h"
|
92
src/EterBase/Stl.cpp
Normal file
92
src/EterBase/Stl.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
#include "StdAfx.h"
|
||||
#include "stl.h"
|
||||
|
||||
static std::list<std::string> s_stList;
|
||||
|
||||
char korean_tolower(const char c)
|
||||
{
|
||||
char ret = c;
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
ret = c - 'A' + 'a';
|
||||
|
||||
assert(ret == tolower(c));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string& stl_static_string(const char * c_sz)
|
||||
{
|
||||
std::string str;
|
||||
str.assign(c_sz);
|
||||
|
||||
s_stList.push_back(str);
|
||||
return s_stList.back();
|
||||
}
|
||||
|
||||
void stl_lowers(std::string& rstRet)
|
||||
{
|
||||
for (size_t i = 0; i < rstRet.length(); ++i)
|
||||
rstRet[i] = korean_tolower(rstRet[i]);
|
||||
}
|
||||
|
||||
int split_string(const std::string& input, const std::string& delimiter, std::vector<std::string>& results, bool includeEmpties)
|
||||
{
|
||||
int iPos = 0;
|
||||
int newPos = -1;
|
||||
UINT sizeS2 = delimiter.size();
|
||||
UINT isize = input.size();
|
||||
|
||||
if ((isize == 0) || (sizeS2 == 0))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<int> positions;
|
||||
|
||||
newPos = input.find(delimiter, 0);
|
||||
|
||||
if (newPos < 0)
|
||||
return 0;
|
||||
|
||||
int numFound = 0;
|
||||
|
||||
while (newPos >= iPos)
|
||||
{
|
||||
numFound++;
|
||||
positions.push_back(newPos);
|
||||
iPos = newPos;
|
||||
newPos = input.find(delimiter, iPos+sizeS2);
|
||||
}
|
||||
|
||||
if (numFound == 0)
|
||||
return 0;
|
||||
|
||||
for (UINT i = 0; i <= positions.size(); ++i)
|
||||
{
|
||||
std::string s("");
|
||||
if (i == 0)
|
||||
{
|
||||
s = input.substr(i, positions[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT offset = positions[i-1] + sizeS2;
|
||||
|
||||
if (offset < isize)
|
||||
{
|
||||
if (i == positions.size())
|
||||
{
|
||||
s = input.substr(offset);
|
||||
}
|
||||
else if (i > 0)
|
||||
{
|
||||
s = input.substr(positions[i-1] + sizeS2, positions[i] - positions[i-1] - sizeS2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (includeEmpties || (s.size() > 0))
|
||||
{
|
||||
results.push_back(s);
|
||||
}
|
||||
}
|
||||
return numFound;
|
||||
}
|
496
src/EterBase/Stl.h
Normal file
496
src/EterBase/Stl.h
Normal file
@ -0,0 +1,496 @@
|
||||
#ifndef __INC_ETERBASE_STL_H__
|
||||
#define __INC_ETERBASE_STL_H__
|
||||
|
||||
#pragma warning(disable:4786) // identifier was truncated to '255' characters in the browser information
|
||||
#pragma warning(disable:4018) // signed <-> unsigned mismatch
|
||||
#pragma warning(disable:4503) // decorated name length exceeded, name was truncated
|
||||
#pragma warning(disable:4018) // '<' : signed/unsigned mismatch
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#pragma warning ( push, 3 )
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include <deque>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <functional>
|
||||
#include <SSTREAM>
|
||||
|
||||
#pragma warning ( pop )
|
||||
|
||||
extern char korean_tolower(const char c);
|
||||
extern std::string& stl_static_string(const char* c_sz);
|
||||
extern void stl_lowers(std::string& rstRet);
|
||||
extern int split_string(const std::string & input, const std::string & delimiter, std::vector<std::string>& results, bool includeEmpties);
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <class _Ty>
|
||||
class void_mem_fun_t
|
||||
: public unary_function<_Ty *, void> {
|
||||
public:
|
||||
explicit void_mem_fun_t(void (_Ty::*_Pm)())
|
||||
: _Ptr(_Pm) {}
|
||||
void operator()(_Ty *_P) const
|
||||
{((_P->*_Ptr)()); }
|
||||
private:
|
||||
void (_Ty::*_Ptr)();
|
||||
};
|
||||
template<class _Ty> inline
|
||||
void_mem_fun_t<_Ty> void_mem_fun(void (_Ty::*_Pm)())
|
||||
{return (void_mem_fun_t<_Ty>(_Pm)); }
|
||||
|
||||
template<class _Ty>
|
||||
class void_mem_fun_ref_t : public unary_function<_Ty, void> {
|
||||
public:
|
||||
explicit void_mem_fun_ref_t(void (_Ty::*_Pm)())
|
||||
: _Ptr(_Pm) {}
|
||||
void operator()(_Ty& _X) const
|
||||
{return ((_X.*_Ptr)()); }
|
||||
private:
|
||||
void (_Ty::*_Ptr)();
|
||||
};
|
||||
|
||||
template<class _Ty> inline
|
||||
void_mem_fun_ref_t<_Ty> void_mem_fun_ref(void (_Ty::*_Pm)())
|
||||
{return (void_mem_fun_ref_t< _Ty>(_Pm)); }
|
||||
|
||||
|
||||
// TEMPLATE CLASS mem_fun1_t
|
||||
template<class _R, class _Ty, class _A>
|
||||
class void_mem_fun1_t : public binary_function<_Ty *, _A, _R> {
|
||||
public:
|
||||
explicit void_mem_fun1_t(_R (_Ty::*_Pm)(_A))
|
||||
: _Ptr(_Pm) {}
|
||||
_R operator()(_Ty *_P, _A _Arg) const
|
||||
{return ((_P->*_Ptr)(_Arg)); }
|
||||
private:
|
||||
_R (_Ty::*_Ptr)(_A);
|
||||
};
|
||||
// TEMPLATE FUNCTION mem_fun1
|
||||
template<class _R, class _Ty, class _A> inline
|
||||
void_mem_fun1_t<_R, _Ty, _A> void_mem_fun1(_R (_Ty::*_Pm)(_A))
|
||||
{return (void_mem_fun1_t<_R, _Ty, _A>(_Pm)); }
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct stl_sz_less
|
||||
{
|
||||
bool operator() (char * const & left, char * const & right) const
|
||||
{
|
||||
return (strcmp(left, right) < 0);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename TContainer>
|
||||
inline void stl_wipe(TContainer& container)
|
||||
{
|
||||
for (TContainer::iterator i = container.begin(); i != container.end(); ++i)
|
||||
{
|
||||
delete *i;
|
||||
*i = NULL;
|
||||
}
|
||||
|
||||
container.clear();
|
||||
}
|
||||
|
||||
template<typename TString>
|
||||
inline int hex2dec(TString szhex)
|
||||
{
|
||||
int hex0 = toupper(szhex[0]);
|
||||
int hex1 = toupper(szhex[1]);
|
||||
|
||||
return (hex1 >= 'A' ? hex1 - 'A' + 10 : hex1 - '0') +
|
||||
(hex0 >= 'A' ? hex0 - 'A' + 10 : hex0 - '0') * 16;
|
||||
}
|
||||
|
||||
template<typename TString>
|
||||
inline unsigned long htmlColorStringToARGB(TString str)
|
||||
{
|
||||
unsigned long alp = hex2dec(str);
|
||||
unsigned long red = hex2dec(str + 2);
|
||||
unsigned long green = hex2dec(str + 4);
|
||||
unsigned long blue = hex2dec(str + 6);
|
||||
return (alp << 24 | red << 16 | green << 8 | blue);
|
||||
}
|
||||
|
||||
template<typename TContainer>
|
||||
inline void stl_wipe_second(TContainer& container)
|
||||
{
|
||||
for (TContainer::iterator i = container.begin(); i != container.end(); ++i)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
container.clear();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void safe_release(T& rpObject)
|
||||
{
|
||||
if (!rpObject)
|
||||
return;
|
||||
|
||||
rpObject->Release();
|
||||
rpObject = NULL;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteVectorItem(std::vector<T> * pVector, unsigned long dwIndex)
|
||||
{
|
||||
if (dwIndex >= pVector->size())
|
||||
{
|
||||
assert(!"Wrong index to delete!");
|
||||
return;
|
||||
}
|
||||
if (1 == pVector->size())
|
||||
{
|
||||
pVector->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<T>::iterator itor = pVector->begin();
|
||||
for (unsigned long i = 0; i < dwIndex; ++i)
|
||||
++itor;
|
||||
|
||||
pVector->erase(itor);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteVectorItem(T * pVector, unsigned long dwStartIndex, unsigned long dwEndIndex)
|
||||
{
|
||||
if (dwStartIndex >= pVector->size())
|
||||
{
|
||||
assert(!"Wrong start index to delete!");
|
||||
return;
|
||||
}
|
||||
if (dwEndIndex >= pVector->size())
|
||||
{
|
||||
assert(!"Wrong end index to delete!");
|
||||
return;
|
||||
}
|
||||
|
||||
T::iterator itorStart = pVector->begin();
|
||||
for (unsigned long i = 0; i < dwStartIndex; ++i)
|
||||
++itorStart;
|
||||
T::iterator itorEnd = pVector->begin();
|
||||
for (unsigned long j = 0; j < dwEndIndex; ++j)
|
||||
++itorEnd;
|
||||
|
||||
pVector->erase(itorStart, itorEnd);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteVectorItem(std::vector<T> * pVector, T pItem)
|
||||
{
|
||||
std::vector<T>::iterator itor = pVector->begin();
|
||||
for (; itor != pVector->end(); ++itor)
|
||||
{
|
||||
if (pItem == *itor)
|
||||
{
|
||||
if (1 == pVector->size())
|
||||
{
|
||||
pVector->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
pVector->erase(itor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void DeleteListItem(std::list<T> * pList, T pItem)
|
||||
{
|
||||
std::list<T>::iterator itor = pList->begin();
|
||||
for (; itor != pList->end(); ++itor)
|
||||
{
|
||||
if (pItem == *itor)
|
||||
{
|
||||
if (1 == pList->size())
|
||||
{
|
||||
pList->clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
pList->erase(itor);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename F>
|
||||
void stl_vector_qsort(std::vector<T>& rdataVector, F comp)
|
||||
{
|
||||
if (rdataVector.empty()) return;
|
||||
qsort(&rdataVector[0], rdataVector.size(), sizeof(T), comp);
|
||||
}
|
||||
|
||||
template<typename TData>
|
||||
class stl_stack_pool
|
||||
{
|
||||
public:
|
||||
stl_stack_pool()
|
||||
{
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
stl_stack_pool(int capacity)
|
||||
{
|
||||
m_pos = 0;
|
||||
initialize(capacity);
|
||||
}
|
||||
|
||||
virtual ~stl_stack_pool()
|
||||
{
|
||||
}
|
||||
|
||||
void initialize(int capacity)
|
||||
{
|
||||
m_dataVector.clear();
|
||||
m_dataVector.resize(capacity);
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
TData * alloc()
|
||||
{
|
||||
assert(!m_dataVector.empty() && "stl_stack_pool::alloc you MUST run stl_stack_pool::initialize");
|
||||
|
||||
int max = m_dataVector.size();
|
||||
|
||||
if (m_pos >= max)
|
||||
{
|
||||
assert(!"stl_stack_pool::alloc OUT of memory");
|
||||
m_pos = 0;
|
||||
}
|
||||
|
||||
return &m_dataVector[m_pos++];
|
||||
}
|
||||
|
||||
TData* base()
|
||||
{
|
||||
return &m_dataVector[0];
|
||||
}
|
||||
|
||||
int size()
|
||||
{
|
||||
return m_pos;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_pos;
|
||||
|
||||
std::vector<TData> m_dataVector;
|
||||
};
|
||||
|
||||
template<typename TData, typename THandle=int>
|
||||
class stl_circle_pool
|
||||
{
|
||||
public:
|
||||
typedef bool TFlag;
|
||||
|
||||
public:
|
||||
stl_circle_pool()
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
virtual ~stl_circle_pool()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
void destroy()
|
||||
{
|
||||
if (m_datas)
|
||||
{
|
||||
delete [] m_datas;
|
||||
m_datas=NULL;
|
||||
}
|
||||
if (m_flags)
|
||||
{
|
||||
delete [] m_flags;
|
||||
m_flags=NULL;
|
||||
}
|
||||
}
|
||||
void create(int size)
|
||||
{
|
||||
destroy();
|
||||
|
||||
initialize();
|
||||
|
||||
m_size=size;
|
||||
m_datas=new TData[m_size];
|
||||
m_flags=new TFlag[m_size];
|
||||
|
||||
for (int i=0; i<m_size; ++i)
|
||||
m_flags[i]=false;
|
||||
}
|
||||
THandle alloc()
|
||||
{
|
||||
THandle max=m_size;
|
||||
|
||||
THandle loop=max;
|
||||
while (loop--)
|
||||
{
|
||||
int cur=m_pos%max;++m_pos;
|
||||
if (!m_flags[cur])
|
||||
{
|
||||
m_flags[cur]=true;
|
||||
return cur;
|
||||
}
|
||||
}
|
||||
|
||||
assert(!"Out of Memory");
|
||||
|
||||
return 0;
|
||||
}
|
||||
void free(THandle handle)
|
||||
{
|
||||
assert(check(handle) && "Out of RANGE");
|
||||
m_flags[handle]=false;
|
||||
}
|
||||
inline bool check(THandle handle)
|
||||
{
|
||||
if (handle>=m_size) return false;
|
||||
return true;
|
||||
}
|
||||
inline int size()
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
inline TData& refer(THandle handle)
|
||||
{
|
||||
assert(check(handle) && "Out of RANGE");
|
||||
return m_datas[handle];
|
||||
}
|
||||
|
||||
protected:
|
||||
void initialize()
|
||||
{
|
||||
m_datas=NULL;
|
||||
m_flags=NULL;
|
||||
m_pos=0;
|
||||
m_size=0;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
TData* m_datas;
|
||||
TFlag* m_flags;
|
||||
|
||||
THandle m_size;
|
||||
|
||||
THandle m_pos;
|
||||
|
||||
};
|
||||
|
||||
typedef std::vector<std::string> CTokenVector;
|
||||
typedef std::map<std::string, std::string> CTokenMap;
|
||||
typedef std::map<std::string, CTokenVector> CTokenVectorMap;
|
||||
|
||||
//class CTokenVector : public std::vector<std::string>
|
||||
//{
|
||||
// public:
|
||||
// CTokenVector() : std::vector<std::string> ()
|
||||
// {
|
||||
// }
|
||||
// virtual ~CTokenVector()
|
||||
// {
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//class CTokenMap : public std::map<std::string, std::string>
|
||||
//{
|
||||
// public:
|
||||
// CTokenMap() : std::map<std::string, std::string>()
|
||||
// {
|
||||
// }
|
||||
// virtual ~CTokenMap()
|
||||
// {
|
||||
// }
|
||||
//};
|
||||
//
|
||||
//class CTokenVectorMap : public std::map<std::string, CTokenVector>
|
||||
//{
|
||||
// public:
|
||||
// CTokenVectorMap() : std::map<std::string, CTokenVector>()
|
||||
// {
|
||||
// }
|
||||
// virtual ~CTokenVectorMap()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
//};
|
||||
|
||||
|
||||
/*
|
||||
template <typename T1, typename T2>
|
||||
class CMapIterator
|
||||
{
|
||||
public:
|
||||
typedef std::map<T1, T2> TMapType;
|
||||
|
||||
public:
|
||||
CMapIterator(TMapType & rMap)
|
||||
{
|
||||
m_it = rMap.begin();
|
||||
m_itEnd = rMap.end();
|
||||
}
|
||||
|
||||
inline T2 operator * () { return m_it->second; }
|
||||
|
||||
inline bool operator ++()
|
||||
{
|
||||
if (m_itEnd == m_it)
|
||||
return false;
|
||||
|
||||
++m_it;
|
||||
return m_itEnd != m_it;
|
||||
}
|
||||
|
||||
inline T1 GetFirst() { return m_it->first; }
|
||||
inline T2 GetSecond() { return m_it->second; }
|
||||
|
||||
private:
|
||||
TMapType::iterator m_it;
|
||||
TMapType::iterator m_itEnd;
|
||||
};
|
||||
*/
|
||||
|
||||
struct stringhash
|
||||
{
|
||||
size_t GetHash(const std::string & str) const
|
||||
{
|
||||
const unsigned char * s = (const unsigned char*) str.c_str();
|
||||
const unsigned char * end = s + str.size();
|
||||
size_t h = 0;
|
||||
|
||||
while (s < end)
|
||||
{
|
||||
h *= 16777619;
|
||||
h ^= (unsigned char) *(unsigned char *) (s++);
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
size_t operator () (const std::string & str) const
|
||||
{
|
||||
return GetHash(str);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
21
src/EterBase/TempFile.cpp
Normal file
21
src/EterBase/TempFile.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "StdAfx.h"
|
||||
#include "TempFile.h"
|
||||
#include "Utils.h"
|
||||
#include "Debug.h"
|
||||
|
||||
CTempFile::~CTempFile()
|
||||
{
|
||||
Destroy();
|
||||
DeleteFile(m_szFileName);
|
||||
}
|
||||
|
||||
CTempFile::CTempFile(const char * c_pszPrefix)
|
||||
{
|
||||
strncpy(m_szFileName, CreateTempFileName(c_pszPrefix), MAX_PATH);
|
||||
|
||||
if (!Create(m_szFileName, CFileBase::FILEMODE_WRITE))
|
||||
{
|
||||
TraceError("CTempFile::CTempFile cannot create temporary file. (filename: %s)", m_szFileName);
|
||||
return;
|
||||
}
|
||||
}
|
16
src/EterBase/TempFile.h
Normal file
16
src/EterBase/TempFile.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __INC_ETERBASE_TEMPFILE_H__
|
||||
#define __INC_ETERBASE_TEMPFILE_H__
|
||||
|
||||
#include "FileBase.h"
|
||||
|
||||
class CTempFile : public CFileBase
|
||||
{
|
||||
public:
|
||||
CTempFile(const char * c_pszPrefix = NULL);
|
||||
virtual ~CTempFile();
|
||||
|
||||
protected:
|
||||
char m_szFileName[MAX_PATH+1];
|
||||
};
|
||||
|
||||
#endif
|
156
src/EterBase/Timer.cpp
Normal file
156
src/EterBase/Timer.cpp
Normal file
@ -0,0 +1,156 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Timer.h"
|
||||
|
||||
static LARGE_INTEGER gs_liTickCountPerSec;
|
||||
static DWORD gs_dwBaseTime=0;
|
||||
static DWORD gs_dwServerTime=0;
|
||||
static DWORD gs_dwClientTime=0;
|
||||
static DWORD gs_dwFrameTime=0;
|
||||
|
||||
#pragma comment(lib, "winmm.lib")
|
||||
|
||||
BOOL ELTimer_Init()
|
||||
{
|
||||
/*
|
||||
gs_liTickCountPerSec.QuadPart=0;
|
||||
|
||||
if (!QueryPerformanceFrequency(&gs_liTickCountPerSec))
|
||||
return 0;
|
||||
|
||||
LARGE_INTEGER liTickCount;
|
||||
QueryPerformanceCounter(&liTickCount);
|
||||
gs_dwBaseTime= (liTickCount.QuadPart*1000 / gs_liTickCountPerSec.QuadPart);
|
||||
*/
|
||||
gs_dwBaseTime = timeGetTime();
|
||||
return 1;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetMSec()
|
||||
{
|
||||
//assert(gs_dwBaseTime!=0 && "ELTimer_Init <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD><CFBC><EFBFBD>");
|
||||
//LARGE_INTEGER liTickCount;
|
||||
//QueryPerformanceCounter(&liTickCount);
|
||||
return timeGetTime() - gs_dwBaseTime; //(liTickCount.QuadPart*1000 / gs_liTickCountPerSec.QuadPart)-gs_dwBaseTime;
|
||||
}
|
||||
|
||||
VOID ELTimer_SetServerMSec(DWORD dwServerTime)
|
||||
{
|
||||
NANOBEGIN
|
||||
if (0 != dwServerTime) // nanomite<74><65> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> if
|
||||
{
|
||||
gs_dwServerTime = dwServerTime;
|
||||
gs_dwClientTime = CTimer::instance().GetCurrentMillisecond();
|
||||
}
|
||||
NANOEND
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetServerMSec()
|
||||
{
|
||||
return CTimer::instance().GetCurrentMillisecond() - gs_dwClientTime + gs_dwServerTime;
|
||||
//return ELTimer_GetMSec() - gs_dwClientTime + gs_dwServerTime;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetFrameMSec()
|
||||
{
|
||||
return gs_dwFrameTime;
|
||||
}
|
||||
|
||||
DWORD ELTimer_GetServerFrameMSec()
|
||||
{
|
||||
return ELTimer_GetFrameMSec() - gs_dwClientTime + gs_dwServerTime;
|
||||
}
|
||||
|
||||
VOID ELTimer_SetFrameMSec()
|
||||
{
|
||||
gs_dwFrameTime = ELTimer_GetMSec();
|
||||
}
|
||||
|
||||
CTimer::CTimer()
|
||||
{
|
||||
ELTimer_Init();
|
||||
|
||||
NANOBEGIN
|
||||
if (this) // nanomite<74><65> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> if
|
||||
{
|
||||
m_dwCurrentTime = 0;
|
||||
m_bUseRealTime = true;
|
||||
m_index = 0;
|
||||
|
||||
m_dwElapsedTime = 0;
|
||||
|
||||
m_fCurrentTime = 0.0f;
|
||||
}
|
||||
NANOEND
|
||||
}
|
||||
|
||||
CTimer::~CTimer()
|
||||
{
|
||||
}
|
||||
|
||||
void CTimer::SetBaseTime()
|
||||
{
|
||||
m_dwCurrentTime = 0;
|
||||
}
|
||||
|
||||
void CTimer::Advance()
|
||||
{
|
||||
if (!m_bUseRealTime)
|
||||
{
|
||||
++m_index;
|
||||
|
||||
if (m_index == 1)
|
||||
m_index = -1;
|
||||
|
||||
m_dwCurrentTime += 16 + (m_index & 1);
|
||||
m_fCurrentTime = m_dwCurrentTime / 1000.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD currentTime = ELTimer_GetMSec();
|
||||
|
||||
if (m_dwCurrentTime == 0)
|
||||
m_dwCurrentTime = currentTime;
|
||||
|
||||
m_dwElapsedTime = currentTime - m_dwCurrentTime;
|
||||
m_dwCurrentTime = currentTime;
|
||||
}
|
||||
}
|
||||
|
||||
void CTimer::Adjust(int iTimeGap)
|
||||
{
|
||||
m_dwCurrentTime += iTimeGap;
|
||||
}
|
||||
|
||||
float CTimer::GetCurrentSecond()
|
||||
{
|
||||
if (m_bUseRealTime)
|
||||
return ELTimer_GetMSec() / 1000.0f;
|
||||
|
||||
return m_fCurrentTime;
|
||||
}
|
||||
|
||||
DWORD CTimer::GetCurrentMillisecond()
|
||||
{
|
||||
if (m_bUseRealTime)
|
||||
return ELTimer_GetMSec();
|
||||
|
||||
return m_dwCurrentTime;
|
||||
}
|
||||
|
||||
float CTimer::GetElapsedSecond()
|
||||
{
|
||||
return GetElapsedMilliecond() / 1000.0f;
|
||||
}
|
||||
|
||||
DWORD CTimer::GetElapsedMilliecond()
|
||||
{
|
||||
if (!m_bUseRealTime)
|
||||
return 16 + (m_index & 1);
|
||||
|
||||
return m_dwElapsedTime;
|
||||
}
|
||||
|
||||
void CTimer::UseCustomTime()
|
||||
{
|
||||
m_bUseRealTime = false;
|
||||
}
|
41
src/EterBase/Timer.h
Normal file
41
src/EterBase/Timer.h
Normal file
@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
#include "Singleton.h"
|
||||
|
||||
class CTimer : public CSingleton<CTimer>
|
||||
{
|
||||
public:
|
||||
CTimer();
|
||||
virtual ~CTimer();
|
||||
|
||||
void Advance();
|
||||
void Adjust(int iTimeGap);
|
||||
void SetBaseTime();
|
||||
|
||||
float GetCurrentSecond();
|
||||
DWORD GetCurrentMillisecond();
|
||||
|
||||
float GetElapsedSecond();
|
||||
DWORD GetElapsedMilliecond();
|
||||
|
||||
void UseCustomTime();
|
||||
|
||||
protected:
|
||||
bool m_bUseRealTime;
|
||||
DWORD m_dwBaseTime;
|
||||
DWORD m_dwCurrentTime;
|
||||
float m_fCurrentTime;
|
||||
DWORD m_dwElapsedTime;
|
||||
int m_index;
|
||||
};
|
||||
|
||||
BOOL ELTimer_Init();
|
||||
|
||||
DWORD ELTimer_GetMSec();
|
||||
|
||||
VOID ELTimer_SetServerMSec(DWORD dwServerTime);
|
||||
DWORD ELTimer_GetServerMSec();
|
||||
|
||||
VOID ELTimer_SetFrameMSec();
|
||||
DWORD ELTimer_GetFrameMSec();
|
676
src/EterBase/Utils.cpp
Normal file
676
src/EterBase/Utils.cpp
Normal file
@ -0,0 +1,676 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
#include "Utils.h"
|
||||
#include "filedir.h"
|
||||
|
||||
char korean_tolower(const char c);
|
||||
|
||||
const char * CreateTempFileName(const char * c_pszPrefix)
|
||||
{
|
||||
char szTempPath[MAX_PATH + 1];
|
||||
static char szTempName[MAX_PATH + 1];
|
||||
|
||||
GetTempPath(MAX_PATH, szTempPath);
|
||||
|
||||
GetTempFileName(szTempPath, // directory for temp files
|
||||
c_pszPrefix ? c_pszPrefix : "etb", // temp file name prefix
|
||||
c_pszPrefix ? true : false, // create unique name
|
||||
szTempName); // buffer for name
|
||||
|
||||
return (szTempName);
|
||||
}
|
||||
|
||||
void GetFilePathNameExtension(const char * c_szFile, int len, std::string * pstPath, std::string * pstName, std::string * pstExt)
|
||||
{
|
||||
assert(pstPath != NULL);
|
||||
assert(pstName != NULL);
|
||||
assert(pstExt != NULL);
|
||||
|
||||
int ext = len;
|
||||
int pos = len;
|
||||
|
||||
while (pos > 0)
|
||||
{
|
||||
--pos;
|
||||
char c = c_szFile[pos];
|
||||
|
||||
if (ext == len && c == '.')
|
||||
{
|
||||
ext = pos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c == '/' || c == '\\')
|
||||
break;
|
||||
}
|
||||
|
||||
while (pos > 0)
|
||||
{
|
||||
--pos;
|
||||
char c = c_szFile[pos];
|
||||
|
||||
if (c == '/' || c == '\\')
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos)
|
||||
{
|
||||
++pos;
|
||||
pstPath->append(c_szFile, pos);
|
||||
}
|
||||
|
||||
if (ext > pos)
|
||||
pstName->append(c_szFile + pos, ext - pos);
|
||||
|
||||
++ext;
|
||||
|
||||
if (len > ext)
|
||||
pstExt->append(c_szFile + ext, len - ext);
|
||||
}
|
||||
|
||||
void GetFileExtension(const char* c_szFile, int len, std::string* pstExt)
|
||||
{
|
||||
int ext = len;
|
||||
int pos = len;
|
||||
while (pos > 0)
|
||||
{
|
||||
--pos;
|
||||
char c=c_szFile[pos];
|
||||
if (ext==len && c=='.')
|
||||
{
|
||||
ext=pos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c=='/') break;
|
||||
else if (c=='\\') break;
|
||||
}
|
||||
|
||||
++ext;
|
||||
if (len>ext)
|
||||
pstExt->append(c_szFile+ext, len-ext);
|
||||
}
|
||||
|
||||
void GetFileNameParts(const char* c_szFile, int len, char* pszPath, char* pszName, char* pszExt)
|
||||
{
|
||||
assert(pszPath!=NULL);
|
||||
assert(pszName!=NULL);
|
||||
assert(pszExt!=NULL);
|
||||
|
||||
int ext=len;
|
||||
int pos=len;
|
||||
while (pos>0)
|
||||
{
|
||||
--pos;
|
||||
char c=c_szFile[pos];
|
||||
if (ext==len && c=='.')
|
||||
{
|
||||
ext=pos;
|
||||
break;
|
||||
}
|
||||
|
||||
if (c=='/') break;
|
||||
else if (c=='\\') break;
|
||||
}
|
||||
|
||||
while (pos>0)
|
||||
{
|
||||
--pos;
|
||||
char c=c_szFile[pos];
|
||||
|
||||
if (c=='/') break;
|
||||
else if (c=='\\') break;
|
||||
}
|
||||
|
||||
if (pos)
|
||||
{
|
||||
++pos;
|
||||
for (int i = 0; i < pos; ++i)
|
||||
{
|
||||
pszPath[i] = c_szFile[i];
|
||||
}
|
||||
pszPath[pos] = '\0';
|
||||
}
|
||||
|
||||
if (ext>pos)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = pos; i < ext; ++i)
|
||||
{
|
||||
pszName[count++] = c_szFile[i];
|
||||
}
|
||||
pszName[count] = '\0';
|
||||
}
|
||||
|
||||
++ext;
|
||||
if (len > ext)
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = ext; i < len; ++i)
|
||||
{
|
||||
pszExt[count++] = c_szFile[i];
|
||||
}
|
||||
pszExt[count] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void GetOldIndexingName(char * szName, int Index)
|
||||
{
|
||||
int dec, sign;
|
||||
char Temp[512];
|
||||
|
||||
strcpy(Temp, _ecvt(Index, 256, &dec, &sign));
|
||||
Temp[dec] = '\0';
|
||||
|
||||
strcat(szName, Temp);
|
||||
}
|
||||
|
||||
void GetIndexingName(char * szName, DWORD Index)
|
||||
{
|
||||
sprintf(szName + strlen(szName), "%u", Index);
|
||||
}
|
||||
|
||||
void GetOnlyFileName(const char * sz_Name, std::string & strFileName)
|
||||
{
|
||||
strFileName = "";
|
||||
|
||||
int i;
|
||||
for (i=strlen(sz_Name)-1; i>=0; --i)
|
||||
{
|
||||
if ('\\' == sz_Name[i] || '/' == sz_Name[i])
|
||||
{
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == -1)
|
||||
i = 0;
|
||||
|
||||
for (size_t j = i; j < strlen(sz_Name); ++j)
|
||||
{
|
||||
strFileName += sz_Name[j];
|
||||
}
|
||||
|
||||
strFileName += "\0";
|
||||
}
|
||||
|
||||
void GetExceptionPathName(const char * sz_Name, std::string & OnlyFileName)
|
||||
{
|
||||
GetOnlyFileName(sz_Name, OnlyFileName);
|
||||
}
|
||||
|
||||
void GetOnlyPathName(const char * sz_Name, std::string & OnlyPathName)
|
||||
{
|
||||
int i;
|
||||
for (i = strlen(sz_Name) - 1; i >= 0; --i)
|
||||
{
|
||||
if ('\\' == sz_Name[i] || '/' == sz_Name[i])
|
||||
{
|
||||
++i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == -1)
|
||||
i = 0;
|
||||
|
||||
OnlyPathName.reserve(strlen(sz_Name));
|
||||
OnlyPathName = "";
|
||||
|
||||
for (int j=0; j<i; ++j)
|
||||
{
|
||||
OnlyPathName += sz_Name[j];
|
||||
}
|
||||
OnlyPathName += "\0";
|
||||
}
|
||||
|
||||
const char * GetOnlyPathName(const char * c_szName)
|
||||
{
|
||||
static std::string strPathName;
|
||||
GetOnlyPathName(c_szName, strPathName);
|
||||
|
||||
return strPathName.c_str();
|
||||
}
|
||||
|
||||
bool GetLocalFileName(const char * c_szGlobalPath, const char * c_szFullPathFileName, std::string * pstrLocalFileName)
|
||||
{
|
||||
std::string strLocalFileName;
|
||||
|
||||
std::string strGlobalPath;
|
||||
std::string strFullPathFileName;
|
||||
StringPath(c_szGlobalPath, strGlobalPath);
|
||||
StringPath(c_szFullPathFileName, strFullPathFileName);
|
||||
|
||||
if (strGlobalPath.length() >= strFullPathFileName.length())
|
||||
return false;
|
||||
|
||||
DWORD length = min(strGlobalPath.length(), strFullPathFileName.length());
|
||||
for (DWORD dwPos = 0; dwPos < length; ++dwPos)
|
||||
{
|
||||
if (strGlobalPath[dwPos] != strFullPathFileName[dwPos])
|
||||
return false;
|
||||
}
|
||||
|
||||
*pstrLocalFileName = &c_szFullPathFileName[length];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetWorkingFolder(std::string & strFileName)
|
||||
{
|
||||
char buf[128+1];
|
||||
_getcwd(buf, 128);
|
||||
strcat(buf, "/");
|
||||
strFileName = buf;
|
||||
}
|
||||
|
||||
void StringLowers(char * String)
|
||||
{
|
||||
for (DWORD i = 0; i < strlen(String); ++i)
|
||||
{
|
||||
String[i] = korean_tolower(String[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(std::string & rString)
|
||||
{
|
||||
for (DWORD i = 0; i < rString.length(); ++i)
|
||||
{
|
||||
if (rString[i] == '\\')
|
||||
rString[i] = '/';
|
||||
else
|
||||
rString[i] = korean_tolower(rString[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(char * pString)
|
||||
{
|
||||
for (DWORD i = 0; i < strlen(pString); ++i)
|
||||
{
|
||||
if (pString[i] == '\\')
|
||||
pString[i] = '/';
|
||||
else
|
||||
pString[i] = korean_tolower(pString[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(const char * c_szSrc, char * szDest)
|
||||
{
|
||||
for (DWORD i = 0; i < strlen(c_szSrc); ++i)
|
||||
{
|
||||
if (c_szSrc[i] == '\\')
|
||||
szDest[i] = '/';
|
||||
else
|
||||
szDest[i] = korean_tolower(c_szSrc[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void StringPath(const char * c_szSrc, std::string & rString)
|
||||
{
|
||||
rString = "";
|
||||
rString.resize(strlen(c_szSrc));
|
||||
|
||||
for (DWORD i = 0; i < strlen(c_szSrc); ++i)
|
||||
{
|
||||
if (c_szSrc[i] == '\\')
|
||||
rString[i] = '/';
|
||||
else
|
||||
rString[i] = korean_tolower(c_szSrc[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#define ishprint(x) ((((x) & 0xE0) > 0x90) || isprint(x))
|
||||
|
||||
void PrintAsciiData(const void* void_data, int bytes)
|
||||
{
|
||||
int i, j, k;
|
||||
const unsigned char* p;
|
||||
const unsigned char* data;
|
||||
|
||||
data = (const unsigned char*) void_data;
|
||||
|
||||
fprintf(stdout, "------------------------------------------------------------------\n");
|
||||
j = bytes;
|
||||
while (1)
|
||||
{
|
||||
k = j >= 16 ? 16 : j;
|
||||
|
||||
p = data;
|
||||
for (i = 0; i < 16; ++i)
|
||||
{
|
||||
if (i >= k)
|
||||
fprintf(stdout, " ");
|
||||
else
|
||||
fprintf(stdout, "%02x ", *p);
|
||||
p++;
|
||||
}
|
||||
|
||||
fprintf(stdout, "| ");
|
||||
|
||||
p = data;
|
||||
for (i = 0; i < k; ++i)
|
||||
{
|
||||
if (i >= k)
|
||||
fprintf(stdout, " ");
|
||||
else
|
||||
fprintf(stdout, "%c", ishprint(*p) ? *p : '.');
|
||||
p++;
|
||||
}
|
||||
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
j -= 16;
|
||||
data += 16;
|
||||
|
||||
if (j <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stdout, "------------------------------------------------------------------\n");
|
||||
}
|
||||
|
||||
int MIN(int a, int b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
int MAX(int a, int b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
int MINMAX(int min, int value, int max)
|
||||
{
|
||||
if (max < min)
|
||||
return MAX(min, value);
|
||||
|
||||
register int tv;
|
||||
tv = (min > value ? min : value);
|
||||
return (max < tv) ? max : tv;
|
||||
}
|
||||
|
||||
float fMIN(float a, float b)
|
||||
{
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
float fMAX(float a, float b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
float fMINMAX(float min, float value, float max)
|
||||
{
|
||||
register float tv;
|
||||
|
||||
tv = (min > value ? min : value);
|
||||
return (max < tv) ? max : tv;
|
||||
}
|
||||
|
||||
bool IsFile(const char* filename)
|
||||
{
|
||||
return _access(filename, 0) == 0 ? true : false;
|
||||
}
|
||||
|
||||
bool IsGlobalFileName(const char * c_szFileName)
|
||||
{
|
||||
return strchr(c_szFileName, ':') != NULL;
|
||||
}
|
||||
|
||||
void MyCreateDirectory(const char* path)
|
||||
{
|
||||
if (!path || !*path)
|
||||
return;
|
||||
|
||||
char * dir;
|
||||
const char * p;
|
||||
|
||||
if (strlen(path) >= 3)
|
||||
{
|
||||
if (*(path + 1) == ':') // C:, D: <20><><EFBFBD><EFBFBD> <20><><EFBFBD>츦 üũ
|
||||
path += 3;
|
||||
}
|
||||
|
||||
p = path;
|
||||
|
||||
int len = strlen(path) + 1;
|
||||
dir = new char[len];
|
||||
|
||||
while (*p)
|
||||
{
|
||||
if (*p == '/' || *p == '\\')
|
||||
{
|
||||
memset(dir, 0, len);
|
||||
strncpy(dir, path, p - path);
|
||||
CreateDirectory(dir, NULL);
|
||||
}
|
||||
|
||||
++p;
|
||||
}
|
||||
|
||||
delete [] dir;
|
||||
}
|
||||
|
||||
class CDirRemover : public CDir
|
||||
{
|
||||
public:
|
||||
CDirRemover()
|
||||
{
|
||||
}
|
||||
virtual ~CDirRemover()
|
||||
{
|
||||
}
|
||||
|
||||
bool OnFolder(const char* c_szFilter, const char* c_szPathName, const char* c_szFileName)
|
||||
{
|
||||
std::string strFullPathName;
|
||||
strFullPathName = c_szPathName;
|
||||
strFullPathName += c_szFileName;
|
||||
|
||||
CDirRemover remover;
|
||||
remover.Create(c_szFilter, strFullPathName.c_str());
|
||||
|
||||
std::string strWorkingFolder;
|
||||
GetWorkingFolder(strWorkingFolder);
|
||||
strWorkingFolder += strFullPathName;
|
||||
strWorkingFolder += "/";
|
||||
StringPath(strWorkingFolder);
|
||||
ms_strDirectoryDeque.push_back(strWorkingFolder);
|
||||
return true;
|
||||
}
|
||||
bool OnFile(const char* c_szPathName, const char* c_szFileName)
|
||||
{
|
||||
std::string strFullPathName;
|
||||
strFullPathName = c_szPathName;
|
||||
strFullPathName += c_szFileName;
|
||||
_chmod(strFullPathName.c_str(), _S_IWRITE);
|
||||
DeleteFile(strFullPathName.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
static void RemoveAllDirectory()
|
||||
{
|
||||
for (std::deque<std::string>::iterator itor = ms_strDirectoryDeque.begin(); itor != ms_strDirectoryDeque.end(); ++itor)
|
||||
{
|
||||
const std::string & c_rstrDirectory = *itor;
|
||||
RemoveDirectory(c_rstrDirectory.c_str());
|
||||
}
|
||||
|
||||
ms_strDirectoryDeque.clear();
|
||||
}
|
||||
|
||||
protected:
|
||||
static std::deque<std::string> ms_strDirectoryDeque;
|
||||
};
|
||||
|
||||
std::deque<std::string> CDirRemover::ms_strDirectoryDeque;
|
||||
|
||||
void RemoveAllDirectory(const char * c_szDirectoryName)
|
||||
{
|
||||
{
|
||||
CDirRemover remover;
|
||||
remover.Create("*.*", c_szDirectoryName);
|
||||
CDirRemover::RemoveAllDirectory();
|
||||
}
|
||||
RemoveDirectory(c_szDirectoryName);
|
||||
}
|
||||
|
||||
void StringExceptCharacter(std::string * pstrString, const char * c_szCharacter)
|
||||
{
|
||||
int icurPos = 0;
|
||||
int iNextPos = 0;
|
||||
|
||||
while((iNextPos = pstrString->find_first_of(c_szCharacter, icurPos)) >= 0)
|
||||
{
|
||||
std::string strFront = pstrString->substr(icurPos, iNextPos - icurPos);
|
||||
std::string strBack = pstrString->substr(iNextPos+1, pstrString->length() - iNextPos - 1);
|
||||
*pstrString = strFront + strBack;
|
||||
}
|
||||
}
|
||||
|
||||
bool SplitLine(const char * c_szLine, const char * c_szDelimeter, std::vector<std::string> * pkVec_strToken)
|
||||
{
|
||||
pkVec_strToken->reserve(10);
|
||||
pkVec_strToken->clear();
|
||||
|
||||
std::string strLine = c_szLine;
|
||||
|
||||
DWORD basePos = 0;
|
||||
|
||||
do
|
||||
{
|
||||
int beginPos = strLine.find_first_not_of(c_szDelimeter, basePos);
|
||||
if (beginPos < 0)
|
||||
return false;
|
||||
|
||||
int endPos;
|
||||
|
||||
if (strLine[beginPos] == '"')
|
||||
{
|
||||
++beginPos;
|
||||
endPos = strLine.find_first_of("\"", beginPos);
|
||||
|
||||
if (endPos < 0)
|
||||
return false;
|
||||
|
||||
basePos = endPos + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
endPos = strLine.find_first_of(c_szDelimeter, beginPos);
|
||||
basePos = endPos;
|
||||
}
|
||||
|
||||
pkVec_strToken->push_back(strLine.substr(beginPos, endPos - beginPos));
|
||||
} while (basePos < strLine.length());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetExcutedFileName(std::string & r_str)
|
||||
{
|
||||
char szPath[MAX_PATH+1];
|
||||
|
||||
GetModuleFileName(NULL, szPath, MAX_PATH);
|
||||
szPath[MAX_PATH] = '\0';
|
||||
|
||||
r_str = szPath;
|
||||
}
|
||||
|
||||
const char * _getf(const char* c_szFormat, ...)
|
||||
{
|
||||
static char szBuf[256];
|
||||
|
||||
va_list args;
|
||||
va_start(args, c_szFormat);
|
||||
_vsnprintf(szBuf, sizeof(szBuf), c_szFormat, args);
|
||||
va_end(args);
|
||||
|
||||
return szBuf;
|
||||
}
|
||||
|
||||
PCHAR* CommandLineToArgv( PCHAR CmdLine, int* _argc )
|
||||
{
|
||||
PCHAR* argv;
|
||||
PCHAR _argv;
|
||||
ULONG len;
|
||||
ULONG argc;
|
||||
CHAR a;
|
||||
ULONG i, j;
|
||||
|
||||
BOOLEAN in_QM;
|
||||
BOOLEAN in_TEXT;
|
||||
BOOLEAN in_SPACE;
|
||||
|
||||
len = strlen(CmdLine);
|
||||
i = ((len+2)/2)*sizeof(PVOID) + sizeof(PVOID);
|
||||
|
||||
argv = (PCHAR*)GlobalAlloc(GMEM_FIXED,
|
||||
i + (len+2)*sizeof(CHAR));
|
||||
|
||||
_argv = (PCHAR)(((PUCHAR)argv)+i);
|
||||
|
||||
argc = 0;
|
||||
argv[argc] = _argv;
|
||||
in_QM = FALSE;
|
||||
in_TEXT = FALSE;
|
||||
in_SPACE = TRUE;
|
||||
i = 0;
|
||||
j = 0;
|
||||
|
||||
while( a = CmdLine[i] ) {
|
||||
if(in_QM) {
|
||||
if(a == '\"') {
|
||||
in_QM = FALSE;
|
||||
} else {
|
||||
_argv[j] = a;
|
||||
j++;
|
||||
}
|
||||
} else {
|
||||
switch(a) {
|
||||
case '\"':
|
||||
in_QM = TRUE;
|
||||
in_TEXT = TRUE;
|
||||
if(in_SPACE) {
|
||||
argv[argc] = _argv+j;
|
||||
argc++;
|
||||
}
|
||||
in_SPACE = FALSE;
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
if(in_TEXT) {
|
||||
_argv[j] = '\0';
|
||||
j++;
|
||||
}
|
||||
in_TEXT = FALSE;
|
||||
in_SPACE = TRUE;
|
||||
break;
|
||||
default:
|
||||
in_TEXT = TRUE;
|
||||
if(in_SPACE) {
|
||||
argv[argc] = _argv+j;
|
||||
argc++;
|
||||
}
|
||||
_argv[j] = a;
|
||||
j++;
|
||||
in_SPACE = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
_argv[j] = '\0';
|
||||
argv[argc] = NULL;
|
||||
|
||||
(*_argc) = argc;
|
||||
return argv;
|
||||
}
|
218
src/EterBase/Utils.h
Normal file
218
src/EterBase/Utils.h
Normal file
@ -0,0 +1,218 @@
|
||||
#ifndef __INC_ETER2_ETERBASE_UTILS_H__
|
||||
#define __INC_ETER2_ETERBASE_UTILS_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#ifndef SAFE_DELETE
|
||||
#define SAFE_DELETE(p) { if (p) { delete (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_DELETE_ARRAY
|
||||
#define SAFE_DELETE_ARRAY(p) { if (p) { delete[] (p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_RELEASE
|
||||
#define SAFE_RELEASE(p) { if (p) { (p)->Release(); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_FREE_GLOBAL
|
||||
#define SAFE_FREE_GLOBAL(p) { if (p) { ::GlobalFree(p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_FREE_LIBRARY
|
||||
#define SAFE_FREE_LIBRARY(p) { if (p) { ::FreeLibrary(p); (p) = NULL; } }
|
||||
#endif
|
||||
|
||||
#define AssertLog(str) TraceError(str); assert(!str)
|
||||
|
||||
#ifndef MAKEFOURCC
|
||||
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
|
||||
((DWORD)(BYTE) (ch0 ) | ((DWORD)(BYTE) (ch1) << 8) | \
|
||||
((DWORD)(BYTE) (ch2) << 16) | ((DWORD)(BYTE) (ch3) << 24))
|
||||
#endif // defined(MAKEFOURCC)
|
||||
|
||||
#ifndef IS_SET
|
||||
#define IS_SET(flag,bit) ((flag) & (bit))
|
||||
#endif
|
||||
|
||||
#ifndef SET_BIT
|
||||
#define SET_BIT(var,bit) ((var) |= (bit))
|
||||
#endif
|
||||
|
||||
#ifndef REMOVE_BIT
|
||||
#define REMOVE_BIT(var,bit) ((var) &= ~(bit))
|
||||
#endif
|
||||
|
||||
#ifndef TOGGLE_BIT
|
||||
#define TOGGLE_BIT(var,bit) ((var) = (var) ^ (bit))
|
||||
#endif
|
||||
|
||||
extern const char * CreateTempFileName(const char * c_pszPrefix = NULL);
|
||||
extern void GetFilePathNameExtension(const char* c_szFile, int len, std::string* pstPath, std::string* pstName, std::string* pstExt);
|
||||
extern void GetFileExtension(const char* c_szFile, int len, std::string* pstExt);
|
||||
extern void GetFileNameParts(const char* c_szFile, int len, char* pszPath, char* pszName, char* pszExt);
|
||||
extern void GetOldIndexingName(char * szName, int Index);
|
||||
extern void GetIndexingName(char * szName, DWORD Index);
|
||||
extern void stl_lowers(std::string& rstRet);
|
||||
extern void GetOnlyFileName(const char * sz_Name, std::string & strFileName);
|
||||
extern void GetOnlyPathName(const char * sz_Name, std::string & OnlyPathName);
|
||||
extern const char * GetOnlyPathName(const char * c_szName);
|
||||
bool GetLocalFileName(const char * c_szGlobalPath, const char * c_szFullPathFileName, std::string * pstrLocalFileName);
|
||||
extern void GetExceptionPathName(const char * sz_Name, std::string & OnlyFileName);
|
||||
extern void GetWorkingFolder(std::string & strFileName);
|
||||
extern void StringLowers(char * pString);
|
||||
extern void StringPath(std::string & rString);
|
||||
extern void StringPath(char * pString); // <20><><EFBFBD><EFBFBD> <20>ҹ<EFBFBD><D2B9>ڷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, \<5C><> /<2F><> <20>ٲ۴<D9B2>.
|
||||
extern void StringPath(const char * c_szSrc, char * szDest); // <20><><EFBFBD><EFBFBD> <20>ҹ<EFBFBD><D2B9>ڷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, \<5C><> /<2F><> <20>ٲ۴<D9B2>.
|
||||
extern void StringPath(const char * c_szSrc, std::string & rString); // <20><><EFBFBD><EFBFBD> <20>ҹ<EFBFBD><D2B9>ڷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, \<5C><> /<2F><> <20>ٲ۴<D9B2>.
|
||||
extern void PrintAsciiData(const void* data, int bytes);
|
||||
bool IsFile(const char* filename);
|
||||
bool IsGlobalFileName(const char * c_szFileName);
|
||||
int MIN(int a, int b);
|
||||
int MAX(int a, int b);
|
||||
int MINMAX(int min, int value, int max);
|
||||
float fMIN(float a, float b);
|
||||
float fMAX(float a, float b);
|
||||
float fMINMAX(float min, float value, float max);
|
||||
void MyCreateDirectory(const char* path);
|
||||
void RemoveAllDirectory(const char * c_szDirectoryName);
|
||||
bool SplitLine(const char * c_szLine, const char * c_szDelimeter, std::vector<std::string> * pkVec_strToken);
|
||||
const char * _getf(const char* c_szFormat, ...);
|
||||
PCHAR* CommandLineToArgv( PCHAR CmdLine, int* _argc );
|
||||
|
||||
template<typename T>
|
||||
T EL_DegreeToRadian(T degree)
|
||||
{
|
||||
const T PI = T(3.141592);
|
||||
return T(PI*degree/180.0f);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void ELPlainCoord_GetRotatedPixelPosition(T centerX, T centerY, T distance, T rotDegree, T* pdstX, T* pdstY)
|
||||
{
|
||||
T rotRadian=EL_DegreeToRadian(rotDegree);
|
||||
*pdstX=centerX+distance*T(sin((double)rotRadian));
|
||||
*pdstY=centerY+distance*T(cos((double)rotRadian));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T EL_SignedDegreeToUnsignedDegree(T fSrc)
|
||||
{
|
||||
if (fSrc<0.0f)
|
||||
return T(360.0+T(fmod(fSrc, 360.0)));
|
||||
|
||||
return T(fmod(fSrc, 360.0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T ELRightCoord_ConvertToPlainCoordDegree(T srcDegree)
|
||||
{
|
||||
return T(fmod(450.0 - srcDegree, 360.0));
|
||||
}
|
||||
|
||||
template<typename C>
|
||||
void string_join(const std::string& sep, const C& container, std::string* ret)
|
||||
{
|
||||
unsigned int capacity = sep.length() * container.size() - 1;
|
||||
|
||||
// calculate string sequence
|
||||
{
|
||||
for (C::const_iterator i = container.begin(); i != container.end(); ++i)
|
||||
capacity += (*i).length();
|
||||
}
|
||||
|
||||
std::string buf;
|
||||
buf.reserve(capacity);
|
||||
|
||||
// join strings
|
||||
{
|
||||
C::const_iterator cur = container.begin();
|
||||
C::const_iterator end = container.end();
|
||||
--end;
|
||||
|
||||
while (cur != end)
|
||||
{
|
||||
buf.append(*cur++);
|
||||
buf.append(sep);
|
||||
}
|
||||
buf.append(*cur);
|
||||
}
|
||||
|
||||
swap(*ret, buf);
|
||||
}
|
||||
|
||||
__forceinline int htoi(const wchar_t *s, int size)
|
||||
{
|
||||
const wchar_t *t = s;
|
||||
int x = 0, y = 1;
|
||||
s += size;
|
||||
|
||||
while (t <= --s)
|
||||
{
|
||||
if (L'0' <= *s && *s <= L'9')
|
||||
x += y * (*s - L'0');
|
||||
else if (L'a' <= *s && *s <= L'f')
|
||||
x += y * (*s - L'a' + 10);
|
||||
else if (L'A' <= *s && *s <= L'F')
|
||||
x += y * (10 + *s - L'A');
|
||||
else
|
||||
return -1; /* invalid input! */
|
||||
y <<= 4;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
__forceinline int htoi(const char *s, int size)
|
||||
{
|
||||
const char *t = s;
|
||||
int x = 0, y = 1;
|
||||
s += size;
|
||||
|
||||
while (t <= --s)
|
||||
{
|
||||
if ('0' <= *s && *s <= '9')
|
||||
x += y * (*s - '0');
|
||||
else if ('a' <= *s && *s <= 'f')
|
||||
x += y * (*s - 'a' + 10);
|
||||
else if ('A' <= *s && *s <= 'F')
|
||||
x += y * (10 + *s - 'A');
|
||||
else
|
||||
return -1; /* invalid input! */
|
||||
y <<= 4;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
__forceinline int htoi(const char *s)
|
||||
{
|
||||
const char *t = s;
|
||||
int x = 0, y = 1;
|
||||
s += strlen(s);
|
||||
|
||||
while (t <= --s)
|
||||
{
|
||||
if ('0' <= *s && *s <= '9')
|
||||
x += y * (*s - '0');
|
||||
else if ('a' <= *s && *s <= 'f')
|
||||
x += y * (*s - 'a' + 10);
|
||||
else if ('A' <= *s && *s <= 'F')
|
||||
x += y * (10 + *s - 'A');
|
||||
else
|
||||
return -1; /* invalid input! */
|
||||
y <<= 4;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
typedef std::vector<std::string> TTokenVector;
|
||||
|
||||
void StringExceptCharacter(std::string * pstrString, const char * c_szCharacter);
|
||||
|
||||
extern void GetExcutedFileName(std::string & r_str);
|
||||
|
||||
#endif
|
208
src/EterBase/error.cpp
Normal file
208
src/EterBase/error.cpp
Normal file
@ -0,0 +1,208 @@
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <winsock.h>
|
||||
#include <imagehlp.h>
|
||||
|
||||
FILE * fException;
|
||||
|
||||
/*
|
||||
static char __msg[4000], __cmsg[4000];
|
||||
static int __idx;
|
||||
CLZObject __l;
|
||||
*/
|
||||
/*
|
||||
typedef BOOL
|
||||
(CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
|
||||
__in PCSTR ModuleName,
|
||||
__in ULONG ModuleBase,
|
||||
__in ULONG ModuleSize,
|
||||
__in_opt PVOID UserContext
|
||||
);
|
||||
*/
|
||||
#if _MSC_VER >= 1400
|
||||
BOOL CALLBACK EnumerateLoadedModulesProc(PCSTR ModuleName, ULONG ModuleBase, ULONG ModuleSize, PVOID UserContext)
|
||||
#else
|
||||
BOOL CALLBACK EnumerateLoadedModulesProc(PSTR ModuleName, ULONG ModuleBase, ULONG ModuleSize, PVOID UserContext)
|
||||
#endif
|
||||
{
|
||||
DWORD offset = *((DWORD*)UserContext);
|
||||
|
||||
if (offset >= ModuleBase && offset <= ModuleBase + ModuleSize)
|
||||
{
|
||||
fprintf(fException, "%s", ModuleName);
|
||||
//__idx += sprintf(__msg+__idx, "%s", ModuleName);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LONG __stdcall EterExceptionFilter(_EXCEPTION_POINTERS* pExceptionInfo)
|
||||
{
|
||||
HANDLE hProcess = GetCurrentProcess();
|
||||
HANDLE hThread = GetCurrentThread();
|
||||
|
||||
fException = fopen("ErrorLog.txt", "wt");
|
||||
if (fException)
|
||||
{
|
||||
char module_name[256];
|
||||
time_t module_time;
|
||||
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
|
||||
GetModuleFileName(hModule, module_name, sizeof(module_name));
|
||||
module_time = (time_t)GetTimestampForLoadedLibrary(hModule);
|
||||
|
||||
fprintf(fException, "Module Name: %s\n", module_name);
|
||||
fprintf(fException, "Time Stamp: 0x%08x - %s\n", module_time, ctime(&module_time));
|
||||
fprintf(fException, "\n");
|
||||
fprintf(fException, "Exception Type: 0x%08x\n", pExceptionInfo->ExceptionRecord->ExceptionCode);
|
||||
fprintf(fException, "\n");
|
||||
|
||||
/*
|
||||
{
|
||||
__idx+=sprintf(__msg+__idx,"Module Name: %s\n", module_name);
|
||||
__idx+=sprintf(__msg+__idx, "Time Stamp: 0x%08x - %s\n", module_time, ctime(&module_time));
|
||||
__idx+=sprintf(__msg+__idx, "\n");
|
||||
__idx+=sprintf(__msg+__idx, "Exception Type: 0x%08x\n", pExceptionInfo->ExceptionRecord->ExceptionCode);
|
||||
__idx+=sprintf(__msg+__idx, "\n");
|
||||
}
|
||||
*/
|
||||
|
||||
CONTEXT& context = *pExceptionInfo->ContextRecord;
|
||||
|
||||
fprintf(fException, "eax: 0x%08x\tebx: 0x%08x\n", context.Eax, context.Ebx);
|
||||
fprintf(fException, "ecx: 0x%08x\tedx: 0x%08x\n", context.Ecx, context.Edx);
|
||||
fprintf(fException, "esi: 0x%08x\tedi: 0x%08x\n", context.Esi, context.Edi);
|
||||
fprintf(fException, "ebp: 0x%08x\tesp: 0x%08x\n", context.Ebp, context.Esp);
|
||||
fprintf(fException, "\n");
|
||||
/*
|
||||
{
|
||||
__idx+=sprintf(__msg+__idx, "eax: 0x%08x\tebx: 0x%08x\n", context.Eax, context.Ebx);
|
||||
__idx+=sprintf(__msg+__idx, "ecx: 0x%08x\tedx: 0x%08x\n", context.Ecx, context.Edx);
|
||||
__idx+=sprintf(__msg+__idx, "esi: 0x%08x\tedi: 0x%08x\n", context.Esi, context.Edi);
|
||||
__idx+=sprintf(__msg+__idx, "ebp: 0x%08x\tesp: 0x%08x\n", context.Ebp, context.Esp);
|
||||
__idx+=sprintf(__msg+__idx, "\n");
|
||||
}
|
||||
*/
|
||||
|
||||
STACKFRAME stackFrame = {0,};
|
||||
stackFrame.AddrPC.Offset = context.Eip;
|
||||
stackFrame.AddrPC.Mode = AddrModeFlat;
|
||||
stackFrame.AddrStack.Offset = context.Esp;
|
||||
stackFrame.AddrStack.Mode = AddrModeFlat;
|
||||
stackFrame.AddrFrame.Offset = context.Ebp;
|
||||
stackFrame.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
for (int i=0; i < 512 && stackFrame.AddrPC.Offset; ++i)
|
||||
{
|
||||
if (StackWalk(IMAGE_FILE_MACHINE_I386, hProcess, hThread, &stackFrame, &context, NULL, NULL, NULL, NULL) != FALSE)
|
||||
{
|
||||
fprintf(fException, "0x%08x\t", stackFrame.AddrPC.Offset);
|
||||
//__idx+=sprintf(__msg+__idx, "0x%08x\t", stackFrame.AddrPC.Offset);
|
||||
EnumerateLoadedModules(hProcess, (PENUMLOADED_MODULES_CALLBACK) EnumerateLoadedModulesProc, &stackFrame.AddrPC.Offset);
|
||||
fprintf(fException, "\n");
|
||||
|
||||
//__idx+=sprintf(__msg+__idx, "\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(fException, "\n");
|
||||
//__idx+=sprintf(__msg+__idx, "\n");
|
||||
|
||||
|
||||
/*
|
||||
BYTE* stack = (BYTE*)(context.Esp);
|
||||
fprintf(fException, "stack %08x - %08x\n", context.Esp, context.Esp+1024);
|
||||
//__idx+=sprintf(__msg+__idx, "stack %08x - %08x\n", context.Esp, context.Esp+1024);
|
||||
|
||||
for(i=0; i<16; ++i)
|
||||
{
|
||||
fprintf(fException, "%08X : ", context.Esp+i*16);
|
||||
//__idx+=sprintf(__msg+__idx, "%08X : ", context.Esp+i*16);
|
||||
for(int j=0; j<16; ++j)
|
||||
{
|
||||
fprintf(fException, "%02X ", stack[i*16+j]);
|
||||
//__idx+=sprintf(__msg+__idx, "%02X ", stack[i*16+j]);
|
||||
}
|
||||
fprintf(fException, "\n");
|
||||
//__idx+=sprintf(__msg+__idx, "\n");
|
||||
}
|
||||
fprintf(fException, "\n");
|
||||
//__idx+=sprintf(__msg+__idx, "\n");
|
||||
*/
|
||||
|
||||
fflush(fException);
|
||||
|
||||
fclose(fException);
|
||||
fException = NULL;
|
||||
|
||||
//WinExec()
|
||||
/*CreateProcess("cmd.exe",NULL,NULL,NULL,FALSE,
|
||||
CREATE_NEW_PROCESS_GROUP|DETACHED_PROCESS,NULL,NULL,NULL,NULL);
|
||||
MessageBox(NULL,"<22><><EFBFBD><EFBFBD> <20><><EFBFBD> ġ<><C4A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD><DFBB>Ͽ<EFBFBD><CFBF><EFBFBD><EFBFBD>ϴ<EFBFBD>.\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.\n<><6E><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ðڽ<C3B0><DABD>ϱ<EFBFBD>?","<22><><EFBFBD><EFBFBD> <20><EFBFBD>!",MB_YESNO);*/
|
||||
|
||||
/*
|
||||
__l.BeginCompressInBuffer(__msg,__idx,__cmsg);
|
||||
if (__l.Compress())
|
||||
{
|
||||
//fprintf(fException,"Compress printing\n");
|
||||
// send this to server
|
||||
SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
ioctlsocket(s,FIONBIO,0);
|
||||
|
||||
if (s==INVALID_SOCKET)
|
||||
{
|
||||
//fprintf(fException,"INVALID %X\n",WSAGetLastError());
|
||||
}
|
||||
|
||||
sockaddr_in sa;
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_port = htons(19294);
|
||||
sa.sin_addr.s_addr = inet_addr("147.46.127.42");
|
||||
if (connect(s,(sockaddr*)&sa,sizeof(sa)))
|
||||
{
|
||||
//fprintf(fException,"%X\n",WSAGetLastError());
|
||||
}
|
||||
|
||||
int total = 0;
|
||||
int ret=0;
|
||||
while(1)
|
||||
{
|
||||
//ret = send(s,(char*)__msg+total,__idx-total,0);
|
||||
ret = send(s,(char*)__l.GetBuffer()+total,__l.GetSize()-total,0);
|
||||
//fprintf(fException,"send %d\n",ret);
|
||||
if (ret<0)
|
||||
{
|
||||
//fprintf(fException,"%X\n",WSAGetLastError());
|
||||
break;
|
||||
}
|
||||
total+=ret;
|
||||
if (total>=__idx)
|
||||
//if (total>=__l.GetSize())
|
||||
break;
|
||||
}
|
||||
//__l.GetBuffer();
|
||||
Sleep(500);
|
||||
closesocket(s);
|
||||
}*/
|
||||
|
||||
WinExec("errorlog.exe",SW_SHOW);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
void SetEterExceptionHandler()
|
||||
{
|
||||
SetUnhandledExceptionFilter(EterExceptionFilter);
|
||||
}
|
2
src/EterBase/error.h
Normal file
2
src/EterBase/error.h
Normal file
@ -0,0 +1,2 @@
|
||||
#pragma once
|
||||
extern void SetEterExceptionHandler();
|
410
src/EterBase/lzo.cpp
Normal file
410
src/EterBase/lzo.cpp
Normal file
@ -0,0 +1,410 @@
|
||||
#include "StdAfx.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lzo.h"
|
||||
#include "tea.h"
|
||||
#include "debug.h"
|
||||
|
||||
#define dbg_printf
|
||||
|
||||
static class LZOFreeMemoryMgr
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
REUSING_CAPACITY = 64*1024,
|
||||
};
|
||||
public:
|
||||
~LZOFreeMemoryMgr()
|
||||
{
|
||||
std::vector<BYTE*>::iterator i;
|
||||
for (i = m_freeVector.begin(); i != m_freeVector.end(); ++i)
|
||||
delete *i;
|
||||
|
||||
m_freeVector.clear();
|
||||
}
|
||||
BYTE* Alloc(unsigned capacity)
|
||||
{
|
||||
assert(capacity > 0);
|
||||
if (capacity < REUSING_CAPACITY)
|
||||
{
|
||||
if (!m_freeVector.empty())
|
||||
{
|
||||
BYTE* freeMem = m_freeVector.back();
|
||||
m_freeVector.pop_back();
|
||||
|
||||
dbg_printf("lzo.reuse_alloc\t%p(%d) free\n", freeMem, capacity);
|
||||
return freeMem;
|
||||
}
|
||||
BYTE* newMem = new BYTE[REUSING_CAPACITY];
|
||||
dbg_printf("lzo.reuse_alloc\t%p(%d) real\n", newMem, capacity);
|
||||
return newMem;
|
||||
}
|
||||
BYTE* newMem = new BYTE[capacity];
|
||||
dbg_printf("lzo.real_alloc\t%p(%d)\n", newMem, capacity);
|
||||
return newMem;
|
||||
}
|
||||
void Free(BYTE* ptr, unsigned capacity)
|
||||
{
|
||||
assert(ptr != NULL);
|
||||
assert(capacity > 0);
|
||||
if (capacity < REUSING_CAPACITY)
|
||||
{
|
||||
dbg_printf("lzo.reuse_free\t%p(%d)\n", ptr, capacity);
|
||||
m_freeVector.push_back(ptr);
|
||||
return;
|
||||
}
|
||||
|
||||
dbg_printf("lzo.real_free\t%p(%d)\n", ptr, capacity);
|
||||
delete [] ptr;
|
||||
}
|
||||
private:
|
||||
std::vector<BYTE*> m_freeVector;
|
||||
} gs_freeMemMgr;
|
||||
|
||||
|
||||
|
||||
DWORD CLZObject::ms_dwFourCC = MAKEFOURCC('M', 'C', 'O', 'Z');
|
||||
|
||||
CLZObject::CLZObject()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void CLZObject::Initialize()
|
||||
{
|
||||
m_bInBuffer = false;
|
||||
m_pbBuffer = NULL;
|
||||
m_dwBufferSize = 0;
|
||||
|
||||
m_pHeader = NULL;
|
||||
m_pbIn = NULL;
|
||||
m_bCompressed = false;
|
||||
}
|
||||
|
||||
void CLZObject::Clear()
|
||||
{
|
||||
if (m_pbBuffer && !m_bInBuffer)
|
||||
gs_freeMemMgr.Free(m_pbBuffer, m_dwBufferSize);
|
||||
|
||||
if (m_dwBufferSize > 0)
|
||||
{
|
||||
dbg_printf("lzo.free %d\n", m_dwBufferSize);
|
||||
}
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CLZObject::~CLZObject()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
DWORD CLZObject::GetSize()
|
||||
{
|
||||
assert(m_pHeader);
|
||||
|
||||
if (m_bCompressed)
|
||||
{
|
||||
if (m_pHeader->dwEncryptSize)
|
||||
return sizeof(THeader) + sizeof(DWORD) + m_pHeader->dwEncryptSize;
|
||||
else
|
||||
return sizeof(THeader) + sizeof(DWORD) + m_pHeader->dwCompressedSize;
|
||||
}
|
||||
else
|
||||
return m_pHeader->dwRealSize;
|
||||
}
|
||||
|
||||
void CLZObject::BeginCompress(const void * pvIn, UINT uiInLen)
|
||||
{
|
||||
m_pbIn = (const BYTE *) pvIn;
|
||||
|
||||
// sizeof(SHeader) +
|
||||
// <20><>ȣȭ<C8A3><C8AD> <20><><EFBFBD><EFBFBD> fourCC 4<><34><EFBFBD><EFBFBD>Ʈ
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD> <20>ִ<EFBFBD> <20>뷮 +
|
||||
// <20><>ȣȭ<C8A3><C8AD> <20><><EFBFBD><EFBFBD> 8 <20><><EFBFBD><EFBFBD>Ʈ
|
||||
m_dwBufferSize = sizeof(THeader) + sizeof(DWORD) + (uiInLen + uiInLen / 64 + 16 + 3) + 8;
|
||||
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(m_dwBufferSize);
|
||||
memset(m_pbBuffer, 0, m_dwBufferSize);
|
||||
|
||||
m_pHeader = (THeader *) m_pbBuffer;
|
||||
m_pHeader->dwFourCC = ms_dwFourCC;
|
||||
m_pHeader->dwEncryptSize = m_pHeader->dwCompressedSize = m_pHeader->dwRealSize = 0;
|
||||
m_pHeader->dwRealSize = uiInLen;
|
||||
}
|
||||
|
||||
void CLZObject::BeginCompressInBuffer(const void * pvIn, UINT uiInLen, void * /*pvOut*/)
|
||||
{
|
||||
m_pbIn = (const BYTE *) pvIn;
|
||||
|
||||
// sizeof(SHeader) +
|
||||
// <20><>ȣȭ<C8A3><C8AD> <20><><EFBFBD><EFBFBD> fourCC 4<><34><EFBFBD><EFBFBD>Ʈ
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD> <20>ִ<EFBFBD> <20>뷮 +
|
||||
// <20><>ȣȭ<C8A3><C8AD> <20><><EFBFBD><EFBFBD> 8 <20><><EFBFBD><EFBFBD>Ʈ
|
||||
m_dwBufferSize = sizeof(THeader) + sizeof(DWORD) + (uiInLen + uiInLen / 64 + 16 + 3) + 8;
|
||||
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(m_dwBufferSize);
|
||||
memset(m_pbBuffer, 0, m_dwBufferSize);
|
||||
|
||||
m_pHeader = (THeader *) m_pbBuffer;
|
||||
m_pHeader->dwFourCC = ms_dwFourCC;
|
||||
m_pHeader->dwEncryptSize = m_pHeader->dwCompressedSize = m_pHeader->dwRealSize = 0;
|
||||
m_pHeader->dwRealSize = uiInLen;
|
||||
m_bInBuffer = true;
|
||||
}
|
||||
|
||||
bool CLZObject::Compress()
|
||||
{
|
||||
UINT iOutLen;
|
||||
BYTE * pbBuffer;
|
||||
|
||||
pbBuffer = m_pbBuffer + sizeof(THeader);
|
||||
*(DWORD *) pbBuffer = ms_dwFourCC;
|
||||
pbBuffer += sizeof(DWORD);
|
||||
|
||||
#if defined( LZO1X_999_MEM_COMPRESS )
|
||||
int r = lzo1x_999_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, (lzo_uint*) &iOutLen, CLZO::Instance().GetWorkMemory());
|
||||
#else
|
||||
int r = lzo1x_1_compress((BYTE *) m_pbIn, m_pHeader->dwRealSize, pbBuffer, (lzo_uint*) &iOutLen, CLZO::Instance().GetWorkMemory());
|
||||
#endif
|
||||
|
||||
if (LZO_E_OK != r)
|
||||
{
|
||||
TraceError("LZO: lzo1x_999_compress failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pHeader->dwCompressedSize = iOutLen;
|
||||
m_bCompressed = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLZObject::BeginDecompress(const void * pvIn)
|
||||
{
|
||||
THeader * pHeader = (THeader *) pvIn;
|
||||
|
||||
if (pHeader->dwFourCC != ms_dwFourCC)
|
||||
{
|
||||
TraceError("LZObject: not a valid data");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_pHeader = pHeader;
|
||||
m_pbIn = (const BYTE *) pvIn + (sizeof(THeader) + sizeof(DWORD));
|
||||
|
||||
/*
|
||||
static unsigned sum = 0;
|
||||
static unsigned count = 0;
|
||||
sum += pHeader->dwRealSize;
|
||||
count++;
|
||||
printf("decompress cur: %d, ave: %d\n", pHeader->dwRealSize, sum/count);
|
||||
*/
|
||||
m_dwBufferSize = pHeader->dwRealSize;
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(m_dwBufferSize);
|
||||
memset(m_pbBuffer, 0, pHeader->dwRealSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
class DecryptBuffer
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
LOCAL_BUF_SIZE = 8 * 1024,
|
||||
};
|
||||
public:
|
||||
DecryptBuffer(unsigned size)
|
||||
{
|
||||
static unsigned count = 0;
|
||||
static unsigned sum = 0;
|
||||
static unsigned maxSize = 0;
|
||||
|
||||
sum += size;
|
||||
count++;
|
||||
|
||||
maxSize = max(size, maxSize);
|
||||
if (size >= LOCAL_BUF_SIZE)
|
||||
{
|
||||
m_buf = new char[size];
|
||||
dbg_printf("DecryptBuffer - AllocHeap %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count);
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_printf("DecryptBuffer - AllocStack %d max(%d) ave(%d)\n", size, maxSize/1024, sum/count);
|
||||
m_buf = m_local_buf;
|
||||
}
|
||||
}
|
||||
~DecryptBuffer()
|
||||
{
|
||||
if (m_local_buf != m_buf)
|
||||
{
|
||||
dbg_printf("DecruptBuffer - FreeHeap\n");
|
||||
delete [] m_buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_printf("DecruptBuffer - FreeStack\n");
|
||||
}
|
||||
}
|
||||
void* GetBufferPtr()
|
||||
{
|
||||
return m_buf;
|
||||
}
|
||||
|
||||
private:
|
||||
char* m_buf;
|
||||
char m_local_buf[LOCAL_BUF_SIZE];
|
||||
};
|
||||
|
||||
bool CLZObject::Decompress(DWORD * pdwKey)
|
||||
{
|
||||
UINT uiSize;
|
||||
int r;
|
||||
|
||||
if (m_pHeader->dwEncryptSize)
|
||||
{
|
||||
DecryptBuffer buf(m_pHeader->dwEncryptSize);
|
||||
|
||||
BYTE* pbDecryptedBuffer = (BYTE*)buf.GetBufferPtr();
|
||||
|
||||
__Decrypt(pdwKey, pbDecryptedBuffer);
|
||||
|
||||
if (*(DWORD *) pbDecryptedBuffer != ms_dwFourCC)
|
||||
{
|
||||
TraceError("LZObject: key incorrect");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (LZO_E_OK != (r = lzo1x_decompress(pbDecryptedBuffer + sizeof(DWORD), m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
|
||||
{
|
||||
TraceError("LZObject: Decompress failed(decrypt) ret %d\n", r);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uiSize = m_pHeader->dwRealSize;
|
||||
|
||||
//if (LZO_E_OK != (r = lzo1x_decompress_safe(m_pbIn, m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
|
||||
if (LZO_E_OK != (r = lzo1x_decompress(m_pbIn, m_pHeader->dwCompressedSize, m_pbBuffer, (lzo_uint*) &uiSize, NULL)))
|
||||
{
|
||||
TraceError("LZObject: Decompress failed : ret %d, CompressedSize %d\n", r, m_pHeader->dwCompressedSize);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (uiSize != m_pHeader->dwRealSize)
|
||||
{
|
||||
TraceError("LZObject: Size differs");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLZObject::Encrypt(DWORD * pdwKey)
|
||||
{
|
||||
if (!m_bCompressed)
|
||||
{
|
||||
assert(!"not compressed yet");
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE * pbBuffer = m_pbBuffer + sizeof(THeader);
|
||||
m_pHeader->dwEncryptSize = tea_encrypt((DWORD *) pbBuffer, (const DWORD *) pbBuffer, pdwKey, m_pHeader->dwCompressedSize + 19);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CLZObject::__Decrypt(DWORD * key, BYTE* data)
|
||||
{
|
||||
assert(m_pbBuffer);
|
||||
|
||||
tea_decrypt((DWORD *) data, (const DWORD *) (m_pbIn - sizeof(DWORD)), key, m_pHeader->dwEncryptSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CLZObject::AllocBuffer(DWORD dwSrcSize)
|
||||
{
|
||||
if (m_pbBuffer && !m_bInBuffer)
|
||||
gs_freeMemMgr.Free(m_pbBuffer, m_dwBufferSize);
|
||||
|
||||
m_pbBuffer = gs_freeMemMgr.Alloc(dwSrcSize);
|
||||
m_dwBufferSize = dwSrcSize;
|
||||
}
|
||||
/*
|
||||
void CLZObject::CopyBuffer(const char* pbSrc, DWORD dwSrcSize)
|
||||
{
|
||||
AllocBuffer(dwSrcSize);
|
||||
memcpy(m_pbBuffer, pbSrc, dwSrcSize);
|
||||
}
|
||||
*/
|
||||
|
||||
CLZO::CLZO() : m_pWorkMem(NULL)
|
||||
{
|
||||
if (lzo_init() != LZO_E_OK)
|
||||
{
|
||||
TraceError("LZO: cannot initialize");
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined( LZO1X_999_MEM_COMPRESS )
|
||||
m_pWorkMem = (BYTE *) malloc(LZO1X_999_MEM_COMPRESS);
|
||||
#else
|
||||
m_pWorkMem = (BYTE *) malloc(LZO1X_1_MEM_COMPRESS);
|
||||
#endif
|
||||
|
||||
if (NULL == m_pWorkMem)
|
||||
{
|
||||
TraceError("LZO: cannot alloc memory");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CLZO::~CLZO()
|
||||
{
|
||||
if (m_pWorkMem)
|
||||
{
|
||||
free(m_pWorkMem);
|
||||
m_pWorkMem = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool CLZO::CompressMemory(CLZObject & rObj, const void * pIn, UINT uiInLen)
|
||||
{
|
||||
rObj.BeginCompress(pIn, uiInLen);
|
||||
return rObj.Compress();
|
||||
}
|
||||
|
||||
bool CLZO::CompressEncryptedMemory(CLZObject & rObj, const void * pIn, UINT uiInLen, DWORD * pdwKey)
|
||||
{
|
||||
rObj.BeginCompress(pIn, uiInLen);
|
||||
|
||||
if (rObj.Compress())
|
||||
{
|
||||
if (rObj.Encrypt(pdwKey))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CLZO::Decompress(CLZObject & rObj, const BYTE * pbBuf, DWORD * pdwKey)
|
||||
{
|
||||
if (!rObj.BeginDecompress(pbBuf))
|
||||
return false;
|
||||
|
||||
if (!rObj.Decompress(pdwKey))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
BYTE * CLZO::GetWorkMemory()
|
||||
{
|
||||
return m_pWorkMem;
|
||||
}
|
||||
|
74
src/EterBase/lzo.h
Normal file
74
src/EterBase/lzo.h
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef __INC_METIN_II_371GNFBQOCJ_LZO_H__
|
||||
#define __INC_METIN_II_371GNFBQOCJ_LZO_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <lzo/lzo1x.h>
|
||||
#include "Singleton.h"
|
||||
|
||||
class CLZObject
|
||||
{
|
||||
public:
|
||||
#pragma pack(4)
|
||||
typedef struct SHeader
|
||||
{
|
||||
DWORD dwFourCC;
|
||||
DWORD dwEncryptSize; // <20><>ȣȭ<C8A3><C8AD> ũ<><C5A9>
|
||||
DWORD dwCompressedSize; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
DWORD dwRealSize; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<><C5A9>
|
||||
} THeader;
|
||||
#pragma pack()
|
||||
|
||||
CLZObject();
|
||||
~CLZObject();
|
||||
|
||||
void Clear();
|
||||
|
||||
void BeginCompress(const void * pvIn, UINT uiInLen);
|
||||
void BeginCompressInBuffer(const void * pvIn, UINT uiInLen, void * pvOut);
|
||||
bool Compress();
|
||||
|
||||
bool BeginDecompress(const void * pvIn);
|
||||
bool Decompress(DWORD * pdwKey = NULL);
|
||||
|
||||
bool Encrypt(DWORD * pdwKey);
|
||||
bool __Decrypt(DWORD * key, BYTE* data);
|
||||
|
||||
const THeader & GetHeader() { return *m_pHeader; }
|
||||
BYTE * GetBuffer() { return m_pbBuffer; }
|
||||
DWORD GetSize();
|
||||
void AllocBuffer(DWORD dwSize);
|
||||
DWORD GetBufferSize() { return m_dwBufferSize; }
|
||||
//void CopyBuffer(const char* pbSrc, DWORD dwSrcSize);
|
||||
|
||||
private:
|
||||
void Initialize();
|
||||
|
||||
BYTE * m_pbBuffer;
|
||||
DWORD m_dwBufferSize;
|
||||
|
||||
THeader * m_pHeader;
|
||||
const BYTE * m_pbIn;
|
||||
bool m_bCompressed;
|
||||
|
||||
bool m_bInBuffer;
|
||||
|
||||
public:
|
||||
static DWORD ms_dwFourCC;
|
||||
};
|
||||
|
||||
class CLZO : public CSingleton<CLZO>
|
||||
{
|
||||
public:
|
||||
CLZO();
|
||||
virtual ~CLZO();
|
||||
|
||||
bool CompressMemory(CLZObject & rObj, const void * pIn, UINT uiInLen);
|
||||
bool CompressEncryptedMemory(CLZObject & rObj, const void * pIn, UINT uiInLen, DWORD * pdwKey);
|
||||
bool Decompress(CLZObject & rObj, const BYTE * pbBuf, DWORD * pdwKey = NULL);
|
||||
BYTE * GetWorkMemory();
|
||||
|
||||
private:
|
||||
BYTE * m_pWorkMem;
|
||||
};
|
||||
|
||||
#endif
|
101
src/EterBase/tea.cpp
Normal file
101
src/EterBase/tea.cpp
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Filename: tea.c
|
||||
* Description: TEA <20><>ȣȭ <20><><EFBFBD><EFBFBD>
|
||||
*
|
||||
* Author: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (aka. <20><><EFBFBD><EFBFBD>, Cronan), <20>ۿ<EFBFBD><DBBF><EFBFBD> (aka. myevan, <20><><EFBFBD>ڷ<EFBFBD>)
|
||||
*/
|
||||
#include "StdAfx.h"
|
||||
#include "tea.h"
|
||||
#include <memory.h>
|
||||
|
||||
/*
|
||||
* TEA Encryption Module Instruction
|
||||
* Edited by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> aka. <20><><EFBFBD><EFBFBD>, Cronan
|
||||
*
|
||||
* void tea_code(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
|
||||
* void tea_decode(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
|
||||
* 8<><38><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><>ȣ/<2F><>ȣȭ <20>Ҷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD>. key <20><> 16 <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
* sz, sy <20><> 8<><38><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
*
|
||||
* int tea_decrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
* int tea_encrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
* <20>Ѳ<EFBFBD><D1B2><EFBFBD><EFBFBD><EFBFBD> 8 <20><><EFBFBD><EFBFBD>Ʈ <20>̻<EFBFBD><CCBB><EFBFBD> <20><>ȣ/<2F><>ȣȭ <20>Ҷ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>. <20><><EFBFBD><EFBFBD> size <20><>
|
||||
* 8<><38> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴϸ<C6B4> 8<><38> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ũ<>⸦ "<22>÷<EFBFBD><C3B7><EFBFBD>" <20><>ȣȭ <20>Ѵ<EFBFBD>.
|
||||
*
|
||||
* ex. tea_code(pdwSrc[1], pdwSrc[0], pdwKey, pdwDest);
|
||||
* tea_decrypt(pdwDest, pdwSrc, pdwKey, nSize);
|
||||
*/
|
||||
|
||||
#define TEA_ROUND 32 // 32 <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>, <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
#define DELTA 0x9E3779B9 // DELTA <20><> <20>ٲ<EFBFBD><D9B2><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
|
||||
void tea_code(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
|
||||
{
|
||||
register unsigned long y = sy, z = sz, sum = 0;
|
||||
unsigned long n = TEA_ROUND;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
y += ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
|
||||
sum += DELTA;
|
||||
z += ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
|
||||
}
|
||||
|
||||
*(dest++) = y;
|
||||
*dest = z;
|
||||
}
|
||||
|
||||
void tea_decode(const unsigned long sz, const unsigned long sy, const unsigned long *key, unsigned long *dest)
|
||||
{
|
||||
#pragma warning(disable:4307)
|
||||
register unsigned long y = sy, z = sz, sum = DELTA * TEA_ROUND;
|
||||
#pragma warning(default:4307)
|
||||
|
||||
unsigned long n = TEA_ROUND;
|
||||
|
||||
while (n-- > 0)
|
||||
{
|
||||
z -= ((y << 4 ^ y >> 5) + y) ^ (sum + key[sum >> 11 & 3]);
|
||||
sum -= DELTA;
|
||||
y -= ((z << 4 ^ z >> 5) + z) ^ (sum + key[sum & 3]);
|
||||
}
|
||||
|
||||
*(dest++) = y;
|
||||
*dest = z;
|
||||
}
|
||||
|
||||
int tea_encrypt(unsigned long *dest, const unsigned long *src, const unsigned long * key, int size)
|
||||
{
|
||||
int i;
|
||||
int resize;
|
||||
|
||||
if (size % 8 != 0)
|
||||
{
|
||||
resize = size + 8 - (size % 8);
|
||||
memset((char *) src + size, 0, resize - size);
|
||||
}
|
||||
else
|
||||
resize = size;
|
||||
|
||||
for (i = 0; i < resize >> 3; i++, dest += 2, src += 2)
|
||||
tea_code(*(src + 1), *src, key, dest);
|
||||
|
||||
return (resize);
|
||||
}
|
||||
|
||||
int tea_decrypt(unsigned long *dest, const unsigned long *src, const unsigned long * key, int size)
|
||||
{
|
||||
int i;
|
||||
int resize;
|
||||
|
||||
if (size % 8 != 0)
|
||||
resize = size + 8 - (size % 8);
|
||||
else
|
||||
resize = size;
|
||||
|
||||
for (i = 0; i < resize >> 3; i++, dest += 2, src += 2)
|
||||
tea_decode(*(src + 1), *src, key, dest);
|
||||
|
||||
return (resize);
|
||||
}
|
||||
|
19
src/EterBase/tea.h
Normal file
19
src/EterBase/tea.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* TEA is a 64-bit symmetric block cipher with a 128-bit key, developed
|
||||
by David J. Wheeler and Roger M. Needham, and described in their
|
||||
paper at <URL:http://www.cl.cam.ac.uk/ftp/users/djw3/tea.ps>.
|
||||
|
||||
This implementation is based on their code in
|
||||
<URL:http://www.cl.cam.ac.uk/ftp/users/djw3/xtea.ps> */
|
||||
|
||||
#define TEA_KEY_LENGTH 16
|
||||
|
||||
int tea_encrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
int tea_decrypt(unsigned long *dest, const unsigned long *src, const unsigned long *key, int size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
45
src/EterBase/vk.h
Normal file
45
src/EterBase/vk.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef __VK_H__
|
||||
#define __VK_H__
|
||||
#ifndef VK_0
|
||||
#define VK_0 0x30
|
||||
#define VK_1 0x31
|
||||
#define VK_2 0x32
|
||||
#define VK_3 0x33
|
||||
#define VK_4 0x34
|
||||
#define VK_5 0x35
|
||||
#define VK_6 0x36
|
||||
#define VK_7 0x37
|
||||
#define VK_8 0x38
|
||||
#define VK_9 0x39
|
||||
#endif
|
||||
|
||||
#ifndef VK_A
|
||||
#define VK_A 0x41
|
||||
#define VK_B 0x42
|
||||
#define VK_C 0x43
|
||||
#define VK_D 0x44
|
||||
#define VK_E 0x45
|
||||
#define VK_F 0x46
|
||||
#define VK_G 0x47
|
||||
#define VK_H 0x48
|
||||
#define VK_I 0x49
|
||||
#define VK_J 0x4A
|
||||
#define VK_K 0x4B
|
||||
#define VK_L 0x4C
|
||||
#define VK_M 0x4D
|
||||
#define VK_N 0x4E
|
||||
#define VK_O 0x4F
|
||||
#define VK_P 0x50
|
||||
#define VK_Q 0x51
|
||||
#define VK_R 0x52
|
||||
#define VK_S 0x53
|
||||
#define VK_T 0x54
|
||||
#define VK_U 0x55
|
||||
#define VK_V 0x56
|
||||
#define VK_W 0x57
|
||||
#define VK_X 0x58
|
||||
#define VK_Y 0x59
|
||||
#define VK_Z 0x5A
|
||||
#endif
|
||||
|
||||
#endif
|
522
src/EterGrnLib/EterGrnLib.vcxproj
Normal file
522
src/EterGrnLib/EterGrnLib.vcxproj
Normal file
@ -0,0 +1,522 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Distribute|Win32">
|
||||
<Configuration>Distribute</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="MfcDebug|Win32">
|
||||
<Configuration>MfcDebug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="MfcRelease|Win32">
|
||||
<Configuration>MfcRelease</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="VTune|Win32">
|
||||
<Configuration>VTune</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<ProjectName>EterGrnLib</ProjectName>
|
||||
<ProjectGuid>{E1FF7630-628F-4AD0-BF66-F14D86A04035}</ProjectGuid>
|
||||
<RootNamespace>EterGrnLib</RootNamespace>
|
||||
<SccProjectName>SAK</SccProjectName>
|
||||
<SccAuxPath>SAK</SccAuxPath>
|
||||
<SccLocalPath>SAK</SccLocalPath>
|
||||
<SccProvider>SAK</SccProvider>
|
||||
<Keyword>MFCProj</Keyword>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>Static</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>17.0.32203.90</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<VcpkgUseStatic>true</VcpkgUseStatic>
|
||||
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\Debug/eterGrnLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Debug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
<IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>.\Distribute/eterGrnLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\Distribute/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Distribute/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Distribute/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\MfcRelease/eterGrnLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\MfcRelease/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\MfcRelease/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\MfcRelease/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\MfcRelease\eterGrnLib.lib</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalOptions>/Gs %(AdditionalOptions)</AdditionalOptions>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>.\VTune/eterGrnLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerOutput>All</AssemblerOutput>
|
||||
<AssemblerListingLocation>.\VTune/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\VTune/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\VTune/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\VTune\eterGrnLib.lib</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<RuntimeTypeInfo>true</RuntimeTypeInfo>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeaderOutputFile>.\MfcDebug/eterGrnLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\MfcDebug/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\MfcDebug/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\MfcDebug/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<OutputFile>.\MfcDebug\eterGrnLib.lib</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MinSpace</Optimization>
|
||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeaderOutputFile>.\Release/eterGrnLib.pch</PrecompiledHeaderOutputFile>
|
||||
<AssemblerListingLocation>.\Release/</AssemblerListingLocation>
|
||||
<ObjectFileName>.\Release/</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
|
||||
<BrowseInformation />
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<CompileAs>Default</CompileAs>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<Culture>0x0412</Culture>
|
||||
</ResourceCompile>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LODController.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Material.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Mesh.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Model.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceCollisionDetection.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceModel.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceMotion.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceRender.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceUpdate.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Motion.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">stdafx.h</PrecompiledHeaderFile>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Create</PrecompiledHeader>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">Create</PrecompiledHeader>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">stdafx.h</PrecompiledHeaderFile>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">stdafx.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Thing.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ThingInstance.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp">
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">MaxSpeed</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Disabled</Optimization>
|
||||
<BasicRuntimeChecks Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">EnableFastChecks</BasicRuntimeChecks>
|
||||
<BrowseInformation Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">true</BrowseInformation>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">MinSpace</Optimization>
|
||||
<Optimization Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">MinSpace</Optimization>
|
||||
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="LODController.h" />
|
||||
<ClInclude Include="Material.h" />
|
||||
<ClInclude Include="Mesh.h" />
|
||||
<ClInclude Include="Model.h" />
|
||||
<ClInclude Include="ModelInstance.h" />
|
||||
<ClInclude Include="Motion.h" />
|
||||
<ClInclude Include="StdAfx.h" />
|
||||
<ClInclude Include="Thing.h" />
|
||||
<ClInclude Include="ThingInstance.h" />
|
||||
<ClInclude Include="Util.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
92
src/EterGrnLib/EterGrnLib.vcxproj.filters
Normal file
92
src/EterGrnLib/EterGrnLib.vcxproj.filters
Normal file
@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{6576bcac-5f4b-45be-9028-0bc5d24f98a7}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{09cf94e2-767a-4df6-8be0-a19454507cf1}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="LODController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Material.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Mesh.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Model.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceCollisionDetection.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceModel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceMotion.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceRender.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ModelInstanceUpdate.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Motion.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StdAfx.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Thing.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ThingInstance.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Util.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="LODController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Material.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Mesh.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Model.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ModelInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Motion.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StdAfx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Thing.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ThingInstance.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Util.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
695
src/EterGrnLib/LODController.cpp
Normal file
695
src/EterGrnLib/LODController.cpp
Normal file
@ -0,0 +1,695 @@
|
||||
#include "StdAfx.h"
|
||||
#include "LODController.h"
|
||||
|
||||
static float LODHEIGHT_ACTOR = 500.0f;
|
||||
static float LODDISTANCE_ACTOR = 5000.0f;
|
||||
static float LODDISTANCE_BUILDING = 25000.0f;
|
||||
|
||||
static const float c_fNearLodScale = 3.0f;
|
||||
static const float c_fFarLodScale = 25.0f;
|
||||
static const float LOD_APPLY_MAX = 2000.0f;
|
||||
static const float LOD_APPLY_MIN = 500.0f;
|
||||
|
||||
bool ms_isMinLODModeEnable=false;
|
||||
|
||||
enum
|
||||
{
|
||||
SHARED_VB_500 = 0,
|
||||
SHARED_VB_1000 = 1,
|
||||
SHARED_VB_1500 = 2,
|
||||
SHARED_VB_2000 = 3,
|
||||
SHARED_VB_2500 = 4,
|
||||
SHARED_VB_3000 = 5,
|
||||
SHARED_VB_3500 = 6,
|
||||
SHARED_VB_4000 = 7,
|
||||
SHARED_VB_NUM = 9,
|
||||
};
|
||||
|
||||
static std::vector<CGraphicVertexBuffer*> gs_vbs[SHARED_VB_NUM];
|
||||
|
||||
static CGraphicVertexBuffer gs_emptyVB;
|
||||
|
||||
#include <time.h>
|
||||
|
||||
static CGraphicVertexBuffer* __AllocDeformVertexBuffer(unsigned deformableVertexCount)
|
||||
{
|
||||
if (deformableVertexCount == 0)
|
||||
return &gs_emptyVB;
|
||||
|
||||
unsigned capacity = (((deformableVertexCount-1) / 500) + 1) * 500;
|
||||
unsigned index = (deformableVertexCount-1) / 500;
|
||||
if (index < SHARED_VB_NUM)
|
||||
{
|
||||
std::vector<CGraphicVertexBuffer*>& vbs = gs_vbs[index];
|
||||
if (!vbs.empty())
|
||||
{
|
||||
//TraceError("REUSE %d(%d)", capacity, deformableVertexCount);
|
||||
|
||||
CGraphicVertexBuffer* pkRetVB = vbs.back();
|
||||
vbs.pop_back();
|
||||
return pkRetVB;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static time_t base = time(NULL);
|
||||
//TraceError("NEW %8d: %d(%d)", time(NULL) - base, capacity, deformableVertexCount);
|
||||
|
||||
CGraphicVertexBuffer* pkNewVB = new CGraphicVertexBuffer;
|
||||
|
||||
if (!pkNewVB->Create(
|
||||
capacity,
|
||||
D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1,
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DPOOL_MANAGED))
|
||||
{
|
||||
TraceError("NEW_ERROR %8d: %d(%d)", time(NULL) - base, capacity, deformableVertexCount);
|
||||
}
|
||||
|
||||
return pkNewVB;
|
||||
}
|
||||
|
||||
void __FreeDeformVertexBuffer(CGraphicVertexBuffer* pkDelVB)
|
||||
{
|
||||
if (pkDelVB)
|
||||
{
|
||||
if (pkDelVB == &gs_emptyVB)
|
||||
return;
|
||||
|
||||
unsigned index = (pkDelVB->GetVertexCount() - 1) / 500;
|
||||
if (index < SHARED_VB_NUM)
|
||||
{
|
||||
gs_vbs[index].push_back(pkDelVB);
|
||||
}
|
||||
else
|
||||
{
|
||||
pkDelVB->Destroy();
|
||||
delete pkDelVB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __ReserveSharedVertexBuffers(unsigned index, unsigned count)
|
||||
{
|
||||
NANOBEGIN
|
||||
if (index >= SHARED_VB_NUM)
|
||||
return;
|
||||
|
||||
unsigned capacity = (index + 1) * 500;
|
||||
|
||||
for (unsigned i = 0; i != count; ++i)
|
||||
{
|
||||
CGraphicVertexBuffer* pkNewVB = new CGraphicVertexBuffer;
|
||||
pkNewVB->Create(
|
||||
capacity,
|
||||
D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1,
|
||||
D3DUSAGE_WRITEONLY,
|
||||
D3DPOOL_MANAGED);
|
||||
gs_vbs[index].push_back(pkNewVB);
|
||||
}
|
||||
NANOEND
|
||||
}
|
||||
|
||||
void GrannyCreateSharedDeformBuffer()
|
||||
{
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_500, 40);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_1000, 20);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_1500, 20);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_2000, 40);
|
||||
__ReserveSharedVertexBuffers(SHARED_VB_3000, 20);
|
||||
}
|
||||
|
||||
void GrannyDestroySharedDeformBuffer()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
TraceError("granny_shared_vbs:");
|
||||
#endif
|
||||
for (int i = 0; i != SHARED_VB_NUM; ++i)
|
||||
{
|
||||
std::vector<CGraphicVertexBuffer*>& vbs = gs_vbs[i];
|
||||
#ifdef _DEBUG
|
||||
TraceError("\t%d: %d", i, vbs.size());
|
||||
#endif
|
||||
|
||||
std::vector<CGraphicVertexBuffer*>::iterator v;
|
||||
for (v = vbs.begin(); v != vbs.end(); ++v)
|
||||
{
|
||||
CGraphicVertexBuffer* pkEachVB = (*v);
|
||||
pkEachVB->Destroy();
|
||||
delete pkEachVB;
|
||||
}
|
||||
vbs.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMinLODMode(bool isEnable)
|
||||
{
|
||||
ms_isMinLODModeEnable=isEnable;
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->SetMaterialImagePointer(c_szImageName, pImage);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->SetMaterialData(c_szImageName, c_rkMaterialData);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->SetSpecularInfo(c_szMtrlName, bEnable, fPower);
|
||||
}
|
||||
}
|
||||
|
||||
CGrannyLODController::CGrannyLODController() :
|
||||
m_pCurrentModelInstance(NULL),
|
||||
m_bLODLevel(0),
|
||||
m_pAttachedParentModel(NULL),
|
||||
m_fLODDistance(0.0f),
|
||||
m_dwLODAniFPS(CGrannyModelInstance::ANIFPS_MAX),
|
||||
m_pkSharedDeformableVertexBuffer(NULL)
|
||||
/////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
CGrannyLODController::~CGrannyLODController()
|
||||
{
|
||||
__FreeDeformVertexBuffer(m_pkSharedDeformableVertexBuffer);
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
void CGrannyLODController::Clear()
|
||||
{
|
||||
if (m_pAttachedParentModel)
|
||||
{
|
||||
m_pAttachedParentModel->DetachModelInstance(this);
|
||||
}
|
||||
|
||||
m_pCurrentModelInstance = NULL;
|
||||
m_pAttachedParentModel = NULL;
|
||||
|
||||
std::for_each(m_que_pkModelInst.begin(), m_que_pkModelInst.end(), CGrannyModelInstance::Delete);
|
||||
m_que_pkModelInst.clear();
|
||||
|
||||
std::vector<TAttachingModelData>::iterator itor = m_AttachedModelDataVector.begin();
|
||||
for (; m_AttachedModelDataVector.end() != itor; ++itor)
|
||||
{
|
||||
TAttachingModelData & rData = *itor;
|
||||
rData.pkLODController->m_pAttachedParentModel = NULL;
|
||||
}
|
||||
|
||||
m_AttachedModelDataVector.clear();
|
||||
}
|
||||
|
||||
void CGrannyLODController::AddModel(CGraphicThing * pThing, int iSrcModel, CGrannyLODController * pSkelLODController)
|
||||
{
|
||||
if (!pThing)
|
||||
return;
|
||||
|
||||
if (pSkelLODController && pSkelLODController->m_que_pkModelInst.empty())
|
||||
{
|
||||
assert(!"EMPTY SKELETON(CANNON LINK)");
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pThing->GetReferenceCount()>=1);
|
||||
|
||||
pThing->AddReference();
|
||||
|
||||
if (pThing->GetModelCount() <= iSrcModel)
|
||||
{
|
||||
pThing->Release();
|
||||
return;
|
||||
}
|
||||
CGrannyModel * pModel = pThing->GetModelPointer(iSrcModel);
|
||||
if (!pModel)
|
||||
{
|
||||
pThing->Release();
|
||||
return;
|
||||
}
|
||||
|
||||
CGrannyModelInstance * pModelInstance = CGrannyModelInstance::New();
|
||||
|
||||
__ReserveSharedDeformableVertexBuffer(pModel->GetDeformVertexCount());
|
||||
|
||||
if (pSkelLODController)
|
||||
{
|
||||
pModelInstance->SetLinkedModelPointer(pModel, m_pkSharedDeformableVertexBuffer, &pSkelLODController->m_pCurrentModelInstance);
|
||||
}
|
||||
else
|
||||
{
|
||||
pModelInstance->SetLinkedModelPointer(pModel, m_pkSharedDeformableVertexBuffer, NULL);
|
||||
}
|
||||
|
||||
// END_OF_WORK
|
||||
|
||||
if (!m_pCurrentModelInstance)
|
||||
{
|
||||
m_pCurrentModelInstance = pModelInstance;
|
||||
pModelInstance->DeformNoSkin(&ms_matIdentity);
|
||||
|
||||
D3DXVECTOR3 vtMin, vtMax;
|
||||
pModelInstance->GetBoundBox(&vtMin, &vtMax);
|
||||
|
||||
float fSize = 0.0f;
|
||||
fSize = fMAX(fSize, fabs(vtMin.x - vtMax.x));
|
||||
fSize = fMAX(fSize, fabs(vtMin.y - vtMax.y));
|
||||
fSize = fMAX(fSize, fabs(vtMin.z - vtMax.z));
|
||||
|
||||
if (fSize<LODHEIGHT_ACTOR)
|
||||
SetLODLimits(0.0f, LODDISTANCE_ACTOR);
|
||||
else
|
||||
//
|
||||
SetLODLimits(0.0f, LODDISTANCE_BUILDING);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME : CModelInstance::m_pgrnWorldPose<73><65> Update<74><65><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴµ<CFB4>,
|
||||
// Deform<72><6D> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> NULL <20>Դϴ<D4B4>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ٲ<EFBFBD><D9B2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.. - [levites]
|
||||
pModelInstance->DeformNoSkin(&ms_matIdentity);
|
||||
}
|
||||
|
||||
pThing->Release();
|
||||
|
||||
m_que_pkModelInst.push_front(pModelInstance);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CGrannyLODController::__ReserveSharedDeformableVertexBuffer(DWORD deformableVertexCount)
|
||||
{
|
||||
if (m_pkSharedDeformableVertexBuffer &&
|
||||
m_pkSharedDeformableVertexBuffer->GetVertexCount() >= deformableVertexCount)
|
||||
return;
|
||||
|
||||
__FreeDeformVertexBuffer(m_pkSharedDeformableVertexBuffer);
|
||||
|
||||
m_pkSharedDeformableVertexBuffer = __AllocDeformVertexBuffer(deformableVertexCount);
|
||||
}
|
||||
|
||||
void CGrannyLODController::AttachModelInstance(CGrannyLODController * pSrcLODController, const char * c_szBoneName)
|
||||
{
|
||||
CGrannyModelInstance * pSrcInstance = pSrcLODController->GetModelInstance();
|
||||
if (!pSrcInstance)
|
||||
return;
|
||||
|
||||
CGrannyModelInstance * pDestInstance = GetModelInstance();
|
||||
if (pDestInstance)
|
||||
{
|
||||
pSrcInstance->SetParentModelInstance(pDestInstance, c_szBoneName);
|
||||
}
|
||||
|
||||
if (!pSrcLODController->GetModelInstance())
|
||||
return;
|
||||
|
||||
// Link Parent Data
|
||||
pSrcLODController->m_pAttachedParentModel = this;
|
||||
|
||||
// Link Child Data
|
||||
std::vector<TAttachingModelData>::iterator itor = m_AttachedModelDataVector.begin();
|
||||
for (; m_AttachedModelDataVector.end() != itor;)
|
||||
{
|
||||
TAttachingModelData & rData = *itor;
|
||||
if (pSrcLODController == rData.pkLODController)
|
||||
{
|
||||
itor = m_AttachedModelDataVector.erase(itor);
|
||||
}
|
||||
else
|
||||
{
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
TAttachingModelData AttachingModelData;
|
||||
AttachingModelData.pkLODController = pSrcLODController;
|
||||
AttachingModelData.strBoneName = c_szBoneName;
|
||||
m_AttachedModelDataVector.push_back(AttachingModelData);
|
||||
}
|
||||
|
||||
void CGrannyLODController::DetachModelInstance(CGrannyLODController * pSrcLODController)
|
||||
{
|
||||
CGrannyModelInstance * pSrcInstance = pSrcLODController->GetModelInstance();
|
||||
if (!pSrcInstance)
|
||||
return;
|
||||
|
||||
CGrannyModelInstance * pDestInstance = GetModelInstance();
|
||||
if (pDestInstance)
|
||||
{
|
||||
pSrcInstance->SetParentModelInstance(NULL, 0);
|
||||
}
|
||||
|
||||
// if (!pSrcLODController->GetModelInstance())
|
||||
// return;
|
||||
|
||||
// Unlink Child Data
|
||||
std::vector<TAttachingModelData>::iterator itor = m_AttachedModelDataVector.begin();
|
||||
for (; m_AttachedModelDataVector.end() != itor;)
|
||||
{
|
||||
TAttachingModelData & rData = *itor;
|
||||
if (pSrcLODController == rData.pkLODController)
|
||||
{
|
||||
itor = m_AttachedModelDataVector.erase(itor);
|
||||
}
|
||||
else
|
||||
{
|
||||
++itor;
|
||||
}
|
||||
}
|
||||
|
||||
// Unlink Parent Data
|
||||
pSrcLODController->m_pAttachedParentModel = NULL;
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetLODLimits(float /*fNearLOD*/, float fFarLOD)
|
||||
{
|
||||
m_fLODDistance = fFarLOD;
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetLODLevel(BYTE bLodLevel)
|
||||
{
|
||||
assert(m_que_pkModelInst.size() > 0);
|
||||
|
||||
if (m_que_pkModelInst.size() > 0)
|
||||
m_bLODLevel = (BYTE) MIN(m_que_pkModelInst.size() - 1, bLodLevel);
|
||||
}
|
||||
|
||||
void CGrannyLODController::CreateDeviceObjects()
|
||||
{
|
||||
std::for_each(m_que_pkModelInst.begin(),
|
||||
m_que_pkModelInst.end(),
|
||||
CGrannyModelInstance::FCreateDeviceObjects());
|
||||
}
|
||||
|
||||
void CGrannyLODController::DestroyDeviceObjects()
|
||||
{
|
||||
std::for_each(m_que_pkModelInst.begin(),
|
||||
m_que_pkModelInst.end(),
|
||||
CGrannyModelInstance::FDestroyDeviceObjects());
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderWithOneTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
|
||||
//#define CHECK_LOD
|
||||
#ifdef CHECK_LOD
|
||||
if (m_que_pkModelInst.size() > 0 && m_pCurrentModelInstance == m_que_pkModelInst[0])
|
||||
m_pCurrentModelInstance->RenderWithoutTexture();
|
||||
|
||||
if (m_que_pkModelInst.size() > 1 && m_pCurrentModelInstance == m_que_pkModelInst[1])
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
|
||||
if (m_que_pkModelInst.size() > 2 && m_pCurrentModelInstance == m_que_pkModelInst[2])
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
|
||||
if (m_que_pkModelInst.size() > 3 && m_pCurrentModelInstance == m_que_pkModelInst[3])
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
|
||||
#else
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
#endif
|
||||
}
|
||||
|
||||
void CGrannyLODController::BlendRenderWithOneTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->BlendRenderWithOneTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderWithTwoTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->RenderWithTwoTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::BlendRenderWithTwoTexture()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->BlendRenderWithTwoTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::Update(float fElapsedTime, float fDistanceFromCenter, float fDistanceFromCamera)
|
||||
{
|
||||
UpdateLODLevel(fDistanceFromCenter, fDistanceFromCamera);
|
||||
UpdateTime(fElapsedTime);
|
||||
}
|
||||
|
||||
void CGrannyLODController::UpdateLODLevel(float fDistanceFromCenter, float fDistanceFromCamera)
|
||||
{
|
||||
if (m_que_pkModelInst.size()<=1)
|
||||
return;
|
||||
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
|
||||
|
||||
if (fDistanceFromCenter > LOD_APPLY_MIN) // <20>߽<EFBFBD> LOD <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
{
|
||||
// ī<><EFBFBD><DEB6><EFBFBD><EFBFBD><EFBFBD> <20>־<EFBFBD><D6BE><EFBFBD> <20><><EFBFBD><EFBFBD> fLODRate<74><65> <20>۾<EFBFBD><DBBE><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 3<><33> LOD<4F><44> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.. <20><><EFBFBD><EFBFBD> <20>հ<EFBFBD> 0, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ڰ<EFBFBD> Ŀ<><C4BF><EFBFBD><EFBFBD>
|
||||
|
||||
// 100fps 50fps 33fps 25fps 20fps
|
||||
// 10ms 20ms 30ms 40ms 50ms
|
||||
float fLODFactor = fMINMAX(0.0f, (m_fLODDistance-fDistanceFromCamera), m_fLODDistance);
|
||||
|
||||
if (m_fLODDistance>0.0f)
|
||||
m_dwLODAniFPS = (DWORD) ((CGrannyModelInstance::ANIFPS_MAX - CGrannyModelInstance::ANIFPS_MIN) * fLODFactor / m_fLODDistance + CGrannyModelInstance::ANIFPS_MIN);
|
||||
else
|
||||
m_dwLODAniFPS = CGrannyModelInstance::ANIFPS_MIN;
|
||||
|
||||
assert(m_dwLODAniFPS > 0);
|
||||
m_dwLODAniFPS /= 10;
|
||||
m_dwLODAniFPS *= 10;
|
||||
|
||||
float fLODStep = m_fLODDistance / m_que_pkModelInst.size();
|
||||
BYTE bLODLevel = BYTE(fLODFactor / fLODStep);
|
||||
|
||||
if (m_fLODDistance <= 5000.0f)
|
||||
{
|
||||
if (fDistanceFromCamera < 500.0f)
|
||||
{
|
||||
bLODLevel = 0;
|
||||
}
|
||||
else if (fDistanceFromCamera < 1500.0f)
|
||||
{
|
||||
bLODLevel = 1;
|
||||
}
|
||||
else if (fDistanceFromCamera < 2500.0f)
|
||||
{
|
||||
bLODLevel = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
bLODLevel = 3;
|
||||
}
|
||||
|
||||
bLODLevel = (BYTE) (m_que_pkModelInst.size() - min(bLODLevel, m_que_pkModelInst.size()) - 1);
|
||||
}
|
||||
|
||||
if (ms_isMinLODModeEnable)
|
||||
bLODLevel=0;
|
||||
|
||||
SetLODLevel(bLODLevel);
|
||||
|
||||
if (m_pCurrentModelInstance != m_que_pkModelInst[m_bLODLevel])
|
||||
{
|
||||
SetCurrentModelInstance(m_que_pkModelInst[m_bLODLevel]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_dwLODAniFPS=CGrannyModelInstance::ANIFPS_MAX;
|
||||
|
||||
if (!m_que_pkModelInst.empty())
|
||||
{
|
||||
if (m_pCurrentModelInstance != m_que_pkModelInst.back())
|
||||
{
|
||||
SetCurrentModelInstance(m_que_pkModelInst.back());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::UpdateTime(float fElapsedTime)
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
|
||||
m_pCurrentModelInstance->Update(m_dwLODAniFPS);
|
||||
|
||||
//DWORD t3=timeGetTime();
|
||||
m_pCurrentModelInstance->UpdateLocalTime(fElapsedTime);
|
||||
|
||||
//DWORD t4=timeGetTime();
|
||||
|
||||
#ifdef __PERFORMANCE_CHECKER__
|
||||
{
|
||||
static FILE* fp=fopen("perf_lod_update.txt", "w");
|
||||
|
||||
if (t4-t1>3)
|
||||
{
|
||||
fprintf(fp, "LOD.Total %d (Time %f)\n", t4-t1, timeGetTime()/1000.0f);
|
||||
fprintf(fp, "LOD.SMI %d\n", t2-t1);
|
||||
fprintf(fp, "LOD.UP %d\n", t3-t2);
|
||||
fprintf(fp, "LOD.UL %d\n", t4-t3);
|
||||
fprintf(fp, "-------------------------------- \n");
|
||||
fflush(fp);
|
||||
}
|
||||
fflush(fp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetCurrentModelInstance(CGrannyModelInstance * pgrnModelInstance)
|
||||
{
|
||||
// Copy Motion
|
||||
pgrnModelInstance->CopyMotion(m_pCurrentModelInstance, true);
|
||||
m_pCurrentModelInstance = pgrnModelInstance;
|
||||
|
||||
// Change children attaching link
|
||||
RefreshAttachedModelInstance();
|
||||
|
||||
// Change parent attaching link
|
||||
if (m_pAttachedParentModel)
|
||||
{
|
||||
m_pAttachedParentModel->RefreshAttachedModelInstance();
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::RefreshAttachedModelInstance()
|
||||
{
|
||||
if (!m_pCurrentModelInstance)
|
||||
return;
|
||||
|
||||
for (DWORD i = 0; i < m_AttachedModelDataVector.size(); ++i)
|
||||
{
|
||||
TAttachingModelData & rModelData = m_AttachedModelDataVector[i];
|
||||
|
||||
CGrannyModelInstance * pSrcInstance = rModelData.pkLODController->GetModelInstance();
|
||||
if (!pSrcInstance)
|
||||
{
|
||||
Tracenf("CGrannyLODController::RefreshAttachedModelInstance : m_AttachedModelDataVector[%d]->pkLODController->GetModelIntance()==NULL", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
pSrcInstance->SetParentModelInstance(m_pCurrentModelInstance, rModelData.strBoneName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::UpdateSkeleton(const D3DXMATRIX * c_pWorldMatrix, float fElapsedTime)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->UpdateSkeleton(c_pWorldMatrix, fElapsedTime);
|
||||
}
|
||||
|
||||
void CGrannyLODController::DeformAll(const D3DXMATRIX * c_pWorldMatrix)
|
||||
{
|
||||
std::deque<CGrannyModelInstance *>::iterator i;
|
||||
for (i=m_que_pkModelInst.begin(); i!=m_que_pkModelInst.end(); ++i)
|
||||
{
|
||||
CGrannyModelInstance* pkModelInst=(*i);
|
||||
pkModelInst->Deform(c_pWorldMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyLODController::DeformNoSkin(const D3DXMATRIX * c_pWorldMatrix)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->DeformNoSkin(c_pWorldMatrix);
|
||||
}
|
||||
|
||||
void CGrannyLODController::Deform(const D3DXMATRIX * c_pWorldMatrix)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->Deform(c_pWorldMatrix);
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderToShadowMap()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->RenderWithoutTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::RenderShadow()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->RenderWithOneTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::ReloadTexture()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->ReloadTexture();
|
||||
}
|
||||
|
||||
void CGrannyLODController::GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->GetBoundBox(vtMin, vtMax);
|
||||
}
|
||||
|
||||
bool CGrannyLODController::Intersect(const D3DXMATRIX * c_pMatrix, float * u, float * v, float * t)
|
||||
{
|
||||
if (!m_pCurrentModelInstance)
|
||||
return false;
|
||||
return m_pCurrentModelInstance->Intersect(c_pMatrix, u, v, t);
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetLocalTime(float fLocalTime)
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->SetLocalTime(fLocalTime);
|
||||
}
|
||||
|
||||
void CGrannyLODController::ResetLocalTime()
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->ResetLocalTime();
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMotionPointer(const CGrannyMotion * c_pMotion, float fBlendTime, int iLoopCount, float speedRatio)
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->SetMotionPointer(c_pMotion, fBlendTime, iLoopCount, speedRatio);
|
||||
}
|
||||
|
||||
void CGrannyLODController::ChangeMotionPointer(const CGrannyMotion * c_pMotion, int iLoopCount, float speedRatio)
|
||||
{
|
||||
assert(m_pCurrentModelInstance != NULL);
|
||||
m_pCurrentModelInstance->ChangeMotionPointer(c_pMotion, iLoopCount, speedRatio);
|
||||
}
|
||||
|
||||
void CGrannyLODController::SetMotionAtEnd()
|
||||
{
|
||||
if (m_pCurrentModelInstance)
|
||||
m_pCurrentModelInstance->SetMotionAtEnd();
|
||||
}
|
||||
|
||||
BOOL CGrannyLODController::isModelInstance()
|
||||
{
|
||||
if (!m_pCurrentModelInstance)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CGrannyModelInstance * CGrannyLODController::GetModelInstance()
|
||||
{
|
||||
return m_pCurrentModelInstance;
|
||||
}
|
304
src/EterGrnLib/LODController.h
Normal file
304
src/EterGrnLib/LODController.h
Normal file
@ -0,0 +1,304 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
|
||||
#include <deque>
|
||||
#include "Thing.h"
|
||||
#include "ModelInstance.h"
|
||||
|
||||
class CGrannyLODController : public CGraphicBase
|
||||
{
|
||||
public:
|
||||
static void SetMinLODMode(bool isEnable);
|
||||
|
||||
public:
|
||||
struct FSetLocalTime
|
||||
{
|
||||
float fLocalTime;
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
pController->SetLocalTime(fLocalTime);
|
||||
}
|
||||
};
|
||||
|
||||
struct FUpdateTime
|
||||
{
|
||||
float fElapsedTime;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->UpdateTime(fElapsedTime);
|
||||
}
|
||||
};
|
||||
|
||||
struct FUpdateLODLevel
|
||||
{
|
||||
float fDistanceFromCenter;
|
||||
float fDistanceFromCamera;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->UpdateLODLevel(fDistanceFromCenter, fDistanceFromCamera);
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderWithOneTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderWithOneTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBlendRenderWithOneTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->BlendRenderWithOneTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderWithTwoTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderWithTwoTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBlendRenderWithTwoTexture
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->BlendRenderWithTwoTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderToShadowMap
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderToShadowMap();
|
||||
}
|
||||
};
|
||||
|
||||
struct FRenderShadow
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->RenderShadow();
|
||||
}
|
||||
};
|
||||
|
||||
struct FDeform
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->Deform(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
struct FDeformNoSkin
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DeformNoSkin(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
struct FDeformAll
|
||||
{
|
||||
const D3DXMATRIX * mc_pWorldMatrix;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DeformAll(mc_pWorldMatrix);
|
||||
}
|
||||
};
|
||||
|
||||
struct FCreateDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->CreateDeviceObjects();
|
||||
}
|
||||
};
|
||||
|
||||
struct FDestroyDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->DestroyDeviceObjects();
|
||||
}
|
||||
};
|
||||
|
||||
struct FBoundBox
|
||||
{
|
||||
D3DXVECTOR3* m_vtMin;
|
||||
D3DXVECTOR3* m_vtMax;
|
||||
|
||||
FBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax)
|
||||
{
|
||||
m_vtMin = vtMin;
|
||||
m_vtMax = vtMax;
|
||||
}
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->GetBoundBox(m_vtMin, m_vtMax);
|
||||
}
|
||||
};
|
||||
|
||||
struct FResetLocalTime
|
||||
{
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ResetLocalTime();
|
||||
}
|
||||
};
|
||||
|
||||
struct FReloadTexture
|
||||
{
|
||||
void operator () (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ReloadTexture();
|
||||
}
|
||||
};
|
||||
|
||||
struct FSetMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
float m_speedRatio;
|
||||
float m_blendTime;
|
||||
int m_loopCount;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->SetMotionPointer(m_pMotion, m_blendTime, m_loopCount, m_speedRatio);
|
||||
}
|
||||
};
|
||||
|
||||
struct FChangeMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
float m_speedRatio;
|
||||
int m_loopCount;
|
||||
|
||||
void operator() (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->ChangeMotionPointer(m_pMotion, m_loopCount, m_speedRatio);
|
||||
}
|
||||
};
|
||||
|
||||
struct FEndStopMotionPointer
|
||||
{
|
||||
const CGrannyMotion * m_pMotion;
|
||||
|
||||
void operator () (CGrannyLODController * pController)
|
||||
{
|
||||
if (pController->isModelInstance())
|
||||
pController->SetMotionAtEnd();
|
||||
}
|
||||
};
|
||||
|
||||
CGrannyLODController();
|
||||
virtual ~CGrannyLODController();
|
||||
|
||||
void Clear();
|
||||
|
||||
void CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
void AddModel(CGraphicThing * pThing, int iSrcModel, CGrannyLODController * pSkelLODController=NULL);
|
||||
void AttachModelInstance(CGrannyLODController * pSrcLODController, const char * c_szBoneName);
|
||||
void DetachModelInstance(CGrannyLODController * pSrcLODController);
|
||||
void SetLODLimits(float fNearLOD, float fFarLOD);
|
||||
void SetLODLevel(BYTE bLODLevel);
|
||||
BYTE GetLODLevel() { return m_bLODLevel; }
|
||||
void SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
void RenderWithOneTexture();
|
||||
void RenderWithTwoTexture();
|
||||
void BlendRenderWithOneTexture();
|
||||
void BlendRenderWithTwoTexture();
|
||||
|
||||
void Update(float fElapsedTime, float fDistanceFromCenter, float fDistanceFromCamera);
|
||||
void UpdateLODLevel(float fDistanceFromCenter, float fDistanceFromCamera);
|
||||
void UpdateTime(float fElapsedTime);
|
||||
|
||||
void UpdateSkeleton(const D3DXMATRIX * c_pWorldMatrix, float fElapsedTime);
|
||||
void Deform(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformNoSkin(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformAll(const D3DXMATRIX * c_pWorldMatrix);
|
||||
|
||||
void RenderToShadowMap();
|
||||
void RenderShadow();
|
||||
void ReloadTexture();
|
||||
|
||||
void GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3 * vtMax);
|
||||
bool Intersect(const D3DXMATRIX * c_pMatrix, float * u, float * v, float * t);
|
||||
|
||||
void SetLocalTime(float fLocalTime);
|
||||
void ResetLocalTime();
|
||||
|
||||
void SetMotionPointer(const CGrannyMotion * c_pMotion, float fBlendTime, int iLoopCount, float speedRatio);
|
||||
void ChangeMotionPointer(const CGrannyMotion * c_pMotion, int iLoopCount, float speedRatio);
|
||||
void SetMotionAtEnd();
|
||||
|
||||
BOOL isModelInstance();
|
||||
CGrannyModelInstance* GetModelInstance();
|
||||
bool HaveBlendThing() { return 0 != GetModelInstance() ? GetModelInstance()->HaveBlendThing() : false; } // NOTE: GetModelInstance() == 0<><30> <20><> Ŭ<><C5AC> ũ<><C5A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(2012. 05. 07)
|
||||
|
||||
protected:
|
||||
void SetCurrentModelInstance(CGrannyModelInstance * pgrnModelInstance);
|
||||
void RefreshAttachedModelInstance();
|
||||
|
||||
void __ReserveSharedDeformableVertexBuffer(DWORD deformableVertexCount);
|
||||
|
||||
protected:
|
||||
float m_fLODDistance;
|
||||
DWORD m_dwLODAniFPS;
|
||||
|
||||
//// Attaching Link Data
|
||||
// Data of Parent Side
|
||||
typedef struct SAttachingModelData
|
||||
{
|
||||
CGrannyLODController * pkLODController;
|
||||
std::string strBoneName;
|
||||
} TAttachingModelData;
|
||||
|
||||
std::vector<TAttachingModelData> m_AttachedModelDataVector;
|
||||
// Data of Child Side
|
||||
CGrannyLODController * m_pAttachedParentModel;
|
||||
|
||||
BYTE m_bLODLevel;
|
||||
CGrannyModelInstance * m_pCurrentModelInstance;
|
||||
|
||||
// WORK
|
||||
std::deque<CGrannyModelInstance *> m_que_pkModelInst;
|
||||
|
||||
CGraphicVertexBuffer* m_pkSharedDeformableVertexBuffer;
|
||||
// END_OF_WORK
|
||||
};
|
560
src/EterGrnLib/Material.cpp
Normal file
560
src/EterGrnLib/Material.cpp
Normal file
@ -0,0 +1,560 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Material.h"
|
||||
#include "Mesh.h"
|
||||
#include "../eterbase/Filename.h"
|
||||
#include "../eterlib/ResourceManager.h"
|
||||
#include "../eterlib/StateManager.h"
|
||||
#include "../eterlib/GrpScreen.h"
|
||||
|
||||
CGraphicImageInstance CGrannyMaterial::ms_akSphereMapInstance[SPHEREMAP_NUM];
|
||||
|
||||
D3DXVECTOR3 CGrannyMaterial::ms_v3SpecularTrans(0.0f, 0.0f, 0.0f);
|
||||
D3DXMATRIX CGrannyMaterial::ms_matSpecular;
|
||||
|
||||
D3DXCOLOR g_fSpecularColor = D3DXCOLOR(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
void CGrannyMaterial::TranslateSpecularMatrix(float fAddX, float fAddY, float fAddZ)
|
||||
{
|
||||
static float SPECULAR_TRANSLATE_MAX = 1000000.0f;
|
||||
|
||||
ms_v3SpecularTrans.x+=fAddX;
|
||||
ms_v3SpecularTrans.y+=fAddY;
|
||||
ms_v3SpecularTrans.z+=fAddZ;
|
||||
|
||||
if (ms_v3SpecularTrans.x>=SPECULAR_TRANSLATE_MAX)
|
||||
ms_v3SpecularTrans.x=0.0f;
|
||||
|
||||
if (ms_v3SpecularTrans.y>=SPECULAR_TRANSLATE_MAX)
|
||||
ms_v3SpecularTrans.y=0.0f;
|
||||
|
||||
if (ms_v3SpecularTrans.z>=SPECULAR_TRANSLATE_MAX)
|
||||
ms_v3SpecularTrans.z=0.0f;
|
||||
|
||||
D3DXMatrixTranslation(&ms_matSpecular,
|
||||
ms_v3SpecularTrans.x,
|
||||
ms_v3SpecularTrans.y,
|
||||
ms_v3SpecularTrans.z
|
||||
);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::ApplyRenderState()
|
||||
{
|
||||
assert(m_pfnApplyRenderState!=NULL && "CGrannyMaterial::SaveRenderState");
|
||||
(this->*m_pfnApplyRenderState)();
|
||||
}
|
||||
|
||||
void CGrannyMaterial::RestoreRenderState()
|
||||
{
|
||||
assert(m_pfnRestoreRenderState!=NULL && "CGrannyMaterial::RestoreRenderState");
|
||||
(this->*m_pfnRestoreRenderState)();
|
||||
}
|
||||
|
||||
void CGrannyMaterial::Copy(CGrannyMaterial& rkMtrl)
|
||||
{
|
||||
m_pgrnMaterial = rkMtrl.m_pgrnMaterial;
|
||||
m_roImage[0] = rkMtrl.m_roImage[0];
|
||||
m_roImage[1] = rkMtrl.m_roImage[1];
|
||||
m_eType = rkMtrl.m_eType;
|
||||
}
|
||||
|
||||
CGrannyMaterial::CGrannyMaterial()
|
||||
{
|
||||
m_bTwoSideRender = false;
|
||||
m_dwLastCullRenderStateForTwoSideRendering = D3DCULL_CW;
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CGrannyMaterial::~CGrannyMaterial()
|
||||
{
|
||||
}
|
||||
|
||||
CGrannyMaterial::EType CGrannyMaterial::GetType() const
|
||||
{
|
||||
return m_eType;
|
||||
}
|
||||
|
||||
void CGrannyMaterial::SetImagePointer(int iStage, CGraphicImage* pImage)
|
||||
{
|
||||
assert(iStage<2 && "CGrannyMaterial::SetImagePointer");
|
||||
m_roImage[iStage]=pImage;
|
||||
}
|
||||
|
||||
bool CGrannyMaterial::IsIn(const char* c_szImageName, int* piStage)
|
||||
{
|
||||
std::string strImageName = c_szImageName;
|
||||
CFileNameHelper::StringPath(strImageName);
|
||||
|
||||
granny_texture * pgrnDiffuseTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyDiffuseColorTexture);
|
||||
if (pgrnDiffuseTexture)
|
||||
{
|
||||
std::string strDiffuseFileName = pgrnDiffuseTexture->FromFileName;
|
||||
CFileNameHelper::StringPath(strDiffuseFileName);
|
||||
if (strDiffuseFileName == strImageName)
|
||||
{
|
||||
*piStage=0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
granny_texture * pgrnOpacityTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyOpacityTexture);
|
||||
if (pgrnOpacityTexture)
|
||||
{
|
||||
std::string strOpacityFileName = pgrnOpacityTexture->FromFileName;
|
||||
CFileNameHelper::StringPath(strOpacityFileName);
|
||||
if (strOpacityFileName == strImageName)
|
||||
{
|
||||
*piStage=1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CGrannyMaterial::SetSpecularInfo(BOOL bFlag, float fPower, BYTE uSphereMapIndex)
|
||||
{
|
||||
m_fSpecularPower = fPower;
|
||||
m_bSphereMapIndex = uSphereMapIndex;
|
||||
m_bSpecularEnable = bFlag;
|
||||
|
||||
if (bFlag)
|
||||
{
|
||||
m_pfnApplyRenderState = &CGrannyMaterial::__ApplySpecularRenderState;
|
||||
m_pfnRestoreRenderState = &CGrannyMaterial::__RestoreSpecularRenderState;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pfnApplyRenderState = &CGrannyMaterial::__ApplyDiffuseRenderState;
|
||||
m_pfnRestoreRenderState = &CGrannyMaterial::__RestoreDiffuseRenderState;
|
||||
}
|
||||
}
|
||||
|
||||
bool CGrannyMaterial::IsEqual(granny_material* pgrnMaterial) const
|
||||
{
|
||||
if (m_pgrnMaterial==pgrnMaterial)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LPDIRECT3DTEXTURE8 CGrannyMaterial::GetD3DTexture(int iStage) const
|
||||
{
|
||||
const CGraphicImage::TRef & ratImage = m_roImage[iStage];
|
||||
|
||||
if (ratImage.IsNull())
|
||||
return NULL;
|
||||
|
||||
CGraphicImage * pImage = ratImage.GetPointer();
|
||||
const CGraphicTexture * pTexture = pImage->GetTexturePointer();
|
||||
return pTexture->GetD3DTexture();
|
||||
}
|
||||
|
||||
CGraphicImage * CGrannyMaterial::GetImagePointer(int iStage) const
|
||||
{
|
||||
const CGraphicImage::TRef & ratImage = m_roImage[iStage];
|
||||
|
||||
if (ratImage.IsNull())
|
||||
return NULL;
|
||||
|
||||
CGraphicImage * pImage = ratImage.GetPointer();
|
||||
return pImage;
|
||||
}
|
||||
|
||||
const CGraphicTexture* CGrannyMaterial::GetDiffuseTexture() const
|
||||
{
|
||||
if (m_roImage[0].IsNull())
|
||||
return NULL;
|
||||
|
||||
return m_roImage[0].GetPointer()->GetTexturePointer();
|
||||
}
|
||||
|
||||
const CGraphicTexture* CGrannyMaterial::GetOpacityTexture() const
|
||||
{
|
||||
if (m_roImage[1].IsNull())
|
||||
return NULL;
|
||||
|
||||
return m_roImage[1].GetPointer()->GetTexturePointer();
|
||||
}
|
||||
|
||||
BOOL CGrannyMaterial::__IsSpecularEnable() const
|
||||
{
|
||||
return m_bSpecularEnable;
|
||||
}
|
||||
|
||||
float CGrannyMaterial::__GetSpecularPower() const
|
||||
{
|
||||
return m_fSpecularPower;
|
||||
}
|
||||
|
||||
extern const std::string& GetModelLocalPath();
|
||||
|
||||
CGraphicImage* CGrannyMaterial::__GetImagePointer(const char* fileName)
|
||||
{
|
||||
assert(*fileName != '\0');
|
||||
|
||||
CResourceManager& rkResMgr = CResourceManager::Instance();
|
||||
|
||||
// SUPPORT_LOCAL_TEXTURE
|
||||
int fileName_len = strlen(fileName);
|
||||
if (fileName_len > 2 && fileName[1] != ':')
|
||||
{
|
||||
char localFileName[256];
|
||||
const std::string& modelLocalPath = GetModelLocalPath();
|
||||
|
||||
int localFileName_len = modelLocalPath.length() + 1 + fileName_len;
|
||||
if (localFileName_len < sizeof(localFileName) - 1)
|
||||
{
|
||||
_snprintf(localFileName, sizeof(localFileName), "%s%s", GetModelLocalPath().c_str(), fileName);
|
||||
CResource* pResource = rkResMgr.GetResourcePointer(localFileName);
|
||||
return static_cast<CGraphicImage*>(pResource);
|
||||
}
|
||||
}
|
||||
// END_OF_SUPPORT_LOCAL_TEXTURE
|
||||
|
||||
|
||||
CResource* pResource = rkResMgr.GetResourcePointer(fileName);
|
||||
return static_cast<CGraphicImage*>(pResource);
|
||||
}
|
||||
|
||||
bool CGrannyMaterial::CreateFromGrannyMaterialPointer(granny_material * pgrnMaterial)
|
||||
{
|
||||
m_pgrnMaterial = pgrnMaterial;
|
||||
|
||||
granny_texture * pgrnDiffuseTexture = NULL;
|
||||
granny_texture * pgrnOpacityTexture = NULL;
|
||||
|
||||
if (pgrnMaterial)
|
||||
{
|
||||
if (pgrnMaterial->MapCount > 1 && !strnicmp(pgrnMaterial->Name, "Blend", 5))
|
||||
{
|
||||
pgrnDiffuseTexture = GrannyGetMaterialTextureByType(pgrnMaterial->Maps[0].Material, GrannyDiffuseColorTexture);
|
||||
pgrnOpacityTexture = GrannyGetMaterialTextureByType(pgrnMaterial->Maps[1].Material, GrannyDiffuseColorTexture);
|
||||
}
|
||||
else
|
||||
{
|
||||
pgrnDiffuseTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyDiffuseColorTexture);
|
||||
pgrnOpacityTexture = GrannyGetMaterialTextureByType(m_pgrnMaterial, GrannyOpacityTexture);
|
||||
}
|
||||
|
||||
// Two-Side <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD> <20><> <20>˻<EFBFBD>
|
||||
{
|
||||
granny_int32 twoSided = 0;
|
||||
granny_data_type_definition TwoSidedFieldType[] =
|
||||
{
|
||||
{GrannyInt32Member, "Two-sided"},
|
||||
{GrannyEndMember},
|
||||
};
|
||||
|
||||
granny_variant twoSideResult = GrannyFindMatchingMember(pgrnMaterial->ExtendedData.Type, pgrnMaterial->ExtendedData.Object, "Two-sided");
|
||||
|
||||
if (NULL != twoSideResult.Type)
|
||||
GrannyConvertSingleObject(twoSideResult.Type, twoSideResult.Object, TwoSidedFieldType, &twoSided);
|
||||
|
||||
m_bTwoSideRender = 1 == twoSided;
|
||||
}
|
||||
}
|
||||
|
||||
if (pgrnDiffuseTexture)
|
||||
m_roImage[0].SetPointer(__GetImagePointer(pgrnDiffuseTexture->FromFileName));
|
||||
|
||||
if (pgrnOpacityTexture)
|
||||
m_roImage[1].SetPointer(__GetImagePointer(pgrnOpacityTexture->FromFileName));
|
||||
|
||||
// <20><><EFBFBD>۽<EFBFBD>Ƽ<EFBFBD><C6BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><EFBFBD>
|
||||
if (!m_roImage[1].IsNull())
|
||||
m_eType = TYPE_BLEND_PNT;
|
||||
else
|
||||
m_eType = TYPE_DIFFUSE_PNT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyMaterial::Initialize()
|
||||
{
|
||||
m_roImage[0] = NULL;
|
||||
m_roImage[1] = NULL;
|
||||
|
||||
SetSpecularInfo(FALSE, 0.0f, 0);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__ApplyDiffuseRenderState()
|
||||
{
|
||||
STATEMANAGER.SetTexture(0, GetD3DTexture(0));
|
||||
|
||||
if (m_bTwoSideRender)
|
||||
{
|
||||
// -_-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>μ<EFBFBD><CEBC><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>... Save & Restore <20>ϸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>δ<EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Save & Restore <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>.
|
||||
m_dwLastCullRenderStateForTwoSideRendering = STATEMANAGER.GetRenderState(D3DRS_CULLMODE);
|
||||
STATEMANAGER.SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__RestoreDiffuseRenderState()
|
||||
{
|
||||
if (m_bTwoSideRender)
|
||||
{
|
||||
STATEMANAGER.SetRenderState(D3DRS_CULLMODE, m_dwLastCullRenderStateForTwoSideRendering);
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__ApplySpecularRenderState()
|
||||
{
|
||||
if (TRUE == STATEMANAGER.GetRenderState(D3DRS_ALPHABLENDENABLE))
|
||||
{
|
||||
__ApplyDiffuseRenderState();
|
||||
return;
|
||||
}
|
||||
|
||||
CGraphicTexture* pkTexture=ms_akSphereMapInstance[m_bSphereMapIndex].GetTexturePointer();
|
||||
|
||||
STATEMANAGER.SetTexture(0, GetD3DTexture(0));
|
||||
|
||||
if (pkTexture)
|
||||
STATEMANAGER.SetTexture(1, pkTexture->GetD3DTexture());
|
||||
else
|
||||
STATEMANAGER.SetTexture(1, NULL);
|
||||
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, D3DXCOLOR(g_fSpecularColor.r, g_fSpecularColor.g, g_fSpecularColor.b, __GetSpecularPower()));
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
|
||||
STATEMANAGER.SaveTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATEALPHA_ADDCOLOR);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
|
||||
STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &ms_matSpecular);
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP);
|
||||
STATEMANAGER.SaveTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::__RestoreSpecularRenderState()
|
||||
{
|
||||
if (TRUE == STATEMANAGER.GetRenderState(D3DRS_ALPHABLENDENABLE))
|
||||
{
|
||||
__RestoreDiffuseRenderState();
|
||||
return;
|
||||
}
|
||||
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS);
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSU);
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_ADDRESSV);
|
||||
|
||||
STATEMANAGER.RestoreTextureStageState(1, D3DTSS_TEXCOORDINDEX);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG1);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLORARG2);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_COLOROP);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG1);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAARG2);
|
||||
STATEMANAGER.RestoreTextureStageState(0, D3DTSS_ALPHAOP);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::CreateSphereMap(UINT uMapIndex, const char* c_szSphereMapImageFileName)
|
||||
{
|
||||
CResourceManager& rkResMgr = CResourceManager::Instance();
|
||||
CGraphicImage * pImage = (CGraphicImage *)rkResMgr.GetResourcePointer(c_szSphereMapImageFileName);
|
||||
ms_akSphereMapInstance[uMapIndex].SetImagePointer(pImage);
|
||||
}
|
||||
|
||||
void CGrannyMaterial::DestroySphereMap()
|
||||
{
|
||||
for (UINT uMapIndex=0; uMapIndex<SPHEREMAP_NUM; ++uMapIndex)
|
||||
ms_akSphereMapInstance[uMapIndex].Destroy();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CGrannyMaterialPalette::CGrannyMaterialPalette()
|
||||
{
|
||||
}
|
||||
|
||||
CGrannyMaterialPalette::~CGrannyMaterialPalette()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::Copy(const CGrannyMaterialPalette& rkMtrlPalSrc)
|
||||
{
|
||||
m_mtrlVector=rkMtrlPalSrc.m_mtrlVector;
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::Clear()
|
||||
{
|
||||
m_mtrlVector.clear();
|
||||
}
|
||||
|
||||
CGrannyMaterial& CGrannyMaterialPalette::GetMaterialRef(DWORD mtrlIndex)
|
||||
{
|
||||
assert(mtrlIndex<m_mtrlVector.size());
|
||||
return *m_mtrlVector[mtrlIndex].GetPointer();
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage)
|
||||
{
|
||||
DWORD size=m_mtrlVector.size();
|
||||
DWORD i;
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
|
||||
int iStage;
|
||||
if (roMtrl->IsIn(c_szImageName, &iStage))
|
||||
{
|
||||
CGrannyMaterial* pkNewMtrl=new CGrannyMaterial;
|
||||
pkNewMtrl->Copy(*roMtrl.GetPointer());
|
||||
pkNewMtrl->SetImagePointer(iStage, pImage);
|
||||
roMtrl=pkNewMtrl;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::SetMaterialData(const char* c_szMtrlName, const SMaterialData& c_rkMaterialData)
|
||||
{
|
||||
if (c_szMtrlName)
|
||||
{
|
||||
std::vector<CGrannyMaterial::TRef>::iterator i;
|
||||
for (i=m_mtrlVector.begin(); i!=m_mtrlVector.end(); ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=*i;
|
||||
|
||||
int iStage;
|
||||
if (roMtrl->IsIn(c_szMtrlName, &iStage))
|
||||
{
|
||||
CGrannyMaterial* pkNewMtrl=new CGrannyMaterial;
|
||||
pkNewMtrl->Copy(*roMtrl.GetPointer());
|
||||
pkNewMtrl->SetImagePointer(iStage, c_rkMaterialData.pImage);
|
||||
pkNewMtrl->SetSpecularInfo(c_rkMaterialData.isSpecularEnable, c_rkMaterialData.fSpecularPower, c_rkMaterialData.bSphereMapIndex);
|
||||
roMtrl=pkNewMtrl;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<CGrannyMaterial::TRef>::iterator i;
|
||||
for (i=m_mtrlVector.begin(); i!=m_mtrlVector.end(); ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=*i;
|
||||
roMtrl->SetSpecularInfo(c_rkMaterialData.isSpecularEnable, c_rkMaterialData.fSpecularPower, c_rkMaterialData.bSphereMapIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGrannyMaterialPalette::SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower)
|
||||
{
|
||||
DWORD size=m_mtrlVector.size();
|
||||
DWORD i;
|
||||
if (c_szMtrlName)
|
||||
{
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
|
||||
int iStage;
|
||||
if (roMtrl->IsIn(c_szMtrlName, &iStage))
|
||||
{
|
||||
roMtrl->SetSpecularInfo(bEnable, fPower, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
roMtrl->SetSpecularInfo(bEnable, fPower, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CGrannyMaterialPalette::RegisterMaterial(granny_material* pgrnMaterial)
|
||||
{
|
||||
DWORD size=m_mtrlVector.size();
|
||||
DWORD i;
|
||||
for (i=0; i<size; ++i)
|
||||
{
|
||||
CGrannyMaterial::TRef& roMtrl=m_mtrlVector[i];
|
||||
if (roMtrl->IsEqual(pgrnMaterial))
|
||||
return i;
|
||||
}
|
||||
|
||||
CGrannyMaterial* pkNewMtrl=new CGrannyMaterial;
|
||||
pkNewMtrl->CreateFromGrannyMaterialPointer(pgrnMaterial);
|
||||
m_mtrlVector.push_back(pkNewMtrl);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
DWORD CGrannyMaterialPalette::GetMaterialCount() const
|
||||
{
|
||||
return m_mtrlVector.size();
|
||||
}
|
||||
|
||||
/*
|
||||
void CActorInstance::BeginSpecularRender()
|
||||
{
|
||||
// NOTE - Blending<6E>ؼ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD> Specular<61><72> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ű<EFBFBD><C5B0> <20>ʴ´<CAB4> - [levites]
|
||||
STATEMANAGER.SaveRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
|
||||
STATEMANAGER.SetRenderState(D3DRS_TEXTUREFACTOR, D3DXCOLOR(1.0f, 1.0f, 1.0f, m_AddColor.r));
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR);
|
||||
STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATEALPHA_ADDCOLOR);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
|
||||
// STATEMANAGER.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
// STATEMANAGER.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
|
||||
// STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
|
||||
// STATEMANAGER.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
//
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_TEXTURE);
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATEALPHA_ADDCOLOR);
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
|
||||
|
||||
// D3DXMATRIX texMatrix;
|
||||
// GetSphereMatrix(&texMatrix);
|
||||
// STATEMANAGER.SetTransform(D3DTS_TEXTURE1, &texMatrix);
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2);
|
||||
|
||||
// Type 1
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
|
||||
// // Type 2
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL);
|
||||
}
|
||||
|
||||
void CActorInstance::EndSpecularRender()
|
||||
{
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE);
|
||||
// STATEMANAGER.SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
STATEMANAGER.SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
}
|
||||
*/
|
120
src/EterGrnLib/Material.h
Normal file
120
src/EterGrnLib/Material.h
Normal file
@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
#include <granny.h>
|
||||
#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
#include "../eterlib/ReferenceObject.h"
|
||||
#include "../eterlib/Ref.h"
|
||||
#include "../eterlib/GrpImageInstance.h"
|
||||
#include "Util.h"
|
||||
|
||||
class CGrannyMaterial : public CReferenceObject
|
||||
{
|
||||
public:
|
||||
typedef CRef<CGrannyMaterial> TRef;
|
||||
|
||||
static void CreateSphereMap(UINT uMapIndex, const char* c_szSphereMapImageFileName);
|
||||
static void DestroySphereMap();
|
||||
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
TYPE_DIFFUSE_PNT,
|
||||
TYPE_BLEND_PNT,
|
||||
TYPE_MAX_NUM
|
||||
};
|
||||
|
||||
public:
|
||||
static void TranslateSpecularMatrix(float fAddX, float fAddY, float fAddZ);
|
||||
|
||||
private:
|
||||
static D3DXMATRIX ms_matSpecular;
|
||||
static D3DXVECTOR3 ms_v3SpecularTrans;
|
||||
|
||||
public:
|
||||
CGrannyMaterial();
|
||||
virtual ~CGrannyMaterial();
|
||||
|
||||
void Destroy();
|
||||
void Copy(CGrannyMaterial& rkMtrl);
|
||||
bool IsEqual(granny_material * pgrnMaterial) const;
|
||||
bool IsIn(const char* c_szImageName, int* iStage);
|
||||
void SetSpecularInfo(BOOL bFlag, float fPower, BYTE uSphereMapIndex);
|
||||
|
||||
void ApplyRenderState();
|
||||
void RestoreRenderState();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
public:
|
||||
bool CreateFromGrannyMaterialPointer(granny_material* pgrnMaterial);
|
||||
void SetImagePointer(int iStage, CGraphicImage* pImage);
|
||||
|
||||
CGrannyMaterial::EType GetType() const;
|
||||
CGraphicImage * GetImagePointer(int iStage) const;
|
||||
|
||||
const CGraphicTexture * GetDiffuseTexture() const;
|
||||
const CGraphicTexture * GetOpacityTexture() const;
|
||||
|
||||
LPDIRECT3DTEXTURE8 GetD3DTexture(int iStage) const;
|
||||
|
||||
bool IsTwoSided() const { return m_bTwoSideRender; }
|
||||
|
||||
|
||||
protected:
|
||||
CGraphicImage * __GetImagePointer(const char * c_szFileName);
|
||||
|
||||
BOOL __IsSpecularEnable() const;
|
||||
float __GetSpecularPower() const;
|
||||
|
||||
void __ApplyDiffuseRenderState();
|
||||
void __RestoreDiffuseRenderState();
|
||||
void __ApplySpecularRenderState();
|
||||
void __RestoreSpecularRenderState();
|
||||
|
||||
protected:
|
||||
granny_material * m_pgrnMaterial;
|
||||
CGraphicImage::TRef m_roImage[2];
|
||||
EType m_eType;
|
||||
|
||||
float m_fSpecularPower;
|
||||
BOOL m_bSpecularEnable;
|
||||
bool m_bTwoSideRender;
|
||||
DWORD m_dwLastCullRenderStateForTwoSideRendering;
|
||||
BYTE m_bSphereMapIndex;
|
||||
|
||||
|
||||
void (CGrannyMaterial::*m_pfnApplyRenderState)();
|
||||
void (CGrannyMaterial::*m_pfnRestoreRenderState)();
|
||||
|
||||
private:
|
||||
enum
|
||||
{
|
||||
SPHEREMAP_NUM = 10,
|
||||
};
|
||||
static CGraphicImageInstance ms_akSphereMapInstance[SPHEREMAP_NUM];
|
||||
};
|
||||
|
||||
class CGrannyMaterialPalette
|
||||
{
|
||||
public:
|
||||
CGrannyMaterialPalette();
|
||||
virtual ~CGrannyMaterialPalette();
|
||||
|
||||
void Clear();
|
||||
void Copy(const CGrannyMaterialPalette& rkMtrlPalSrc);
|
||||
|
||||
DWORD RegisterMaterial(granny_material* pgrnMaterial);
|
||||
void SetMaterialImagePointer(const char* c_szMtrlName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szMtrlName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
CGrannyMaterial& GetMaterialRef(DWORD mtrlIndex);
|
||||
|
||||
DWORD GetMaterialCount() const;
|
||||
|
||||
protected:
|
||||
std::vector<CGrannyMaterial::TRef> m_mtrlVector;
|
||||
};
|
311
src/EterGrnLib/Mesh.cpp
Normal file
311
src/EterGrnLib/Mesh.cpp
Normal file
@ -0,0 +1,311 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Mesh.h"
|
||||
#include "Model.h"
|
||||
#include "Material.h"
|
||||
|
||||
granny_data_type_definition GrannyPNT3322VertexType[5] =
|
||||
{
|
||||
{GrannyReal32Member, GrannyVertexPositionName, 0, 3},
|
||||
{GrannyReal32Member, GrannyVertexNormalName, 0, 3},
|
||||
{GrannyReal32Member, GrannyVertexTextureCoordinatesName"0", 0, 2},
|
||||
{GrannyReal32Member, GrannyVertexTextureCoordinatesName"1", 0, 2},
|
||||
{GrannyEndMember}
|
||||
};
|
||||
|
||||
void CGrannyMesh::LoadIndices(void * dstBaseIndices)
|
||||
{
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
TIndex * dstIndices = ((TIndex *)dstBaseIndices) + m_idxBasePos;
|
||||
GrannyCopyMeshIndices(pgrnMesh, sizeof(TIndex), dstIndices);
|
||||
}
|
||||
|
||||
void CGrannyMesh::LoadPNTVertices(void * dstBaseVertices)
|
||||
{
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
if (!GrannyMeshIsRigid(pgrnMesh))
|
||||
return;
|
||||
|
||||
TPNTVertex * dstVertices = ((TPNTVertex *)dstBaseVertices) + m_vtxBasePos;
|
||||
GrannyCopyMeshVertices(pgrnMesh, m_pgrnMeshType, dstVertices);
|
||||
}
|
||||
|
||||
void CGrannyMesh::NEW_LoadVertices(void * dstBaseVertices)
|
||||
{
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
if (!GrannyMeshIsRigid(pgrnMesh))
|
||||
return;
|
||||
|
||||
TPNTVertex * dstVertices = ((TPNTVertex *)dstBaseVertices) + m_vtxBasePos;
|
||||
GrannyCopyMeshVertices(pgrnMesh, m_pgrnMeshType, dstVertices);
|
||||
}
|
||||
|
||||
void CGrannyMesh::DeformPNTVertices(void * dstBaseVertices, D3DXMATRIX * boneMatrices, granny_mesh_binding* pgrnMeshBinding) const
|
||||
{
|
||||
assert(dstBaseVertices != NULL);
|
||||
assert(boneMatrices != NULL);
|
||||
assert(m_pgrnMeshDeformer != NULL);
|
||||
|
||||
const granny_mesh * pgrnMesh = GetGrannyMeshPointer();
|
||||
|
||||
TPNTVertex * srcVertices = (TPNTVertex *) GrannyGetMeshVertices(pgrnMesh);
|
||||
TPNTVertex * dstVertices = ((TPNTVertex *) dstBaseVertices) + m_vtxBasePos;
|
||||
|
||||
int vtxCount = GrannyGetMeshVertexCount(pgrnMesh);
|
||||
|
||||
// WORK
|
||||
int * boneIndices = GrannyGetMeshBindingToBoneIndices(pgrnMeshBinding);
|
||||
// END_OF_WORK
|
||||
|
||||
GrannyDeformVertices(
|
||||
m_pgrnMeshDeformer,
|
||||
boneIndices,
|
||||
(float *)boneMatrices,
|
||||
vtxCount,
|
||||
srcVertices,
|
||||
dstVertices);
|
||||
}
|
||||
|
||||
bool CGrannyMesh::CanDeformPNTVertices() const
|
||||
{
|
||||
return m_canDeformPNTVertex;
|
||||
}
|
||||
|
||||
const granny_mesh * CGrannyMesh::GetGrannyMeshPointer() const
|
||||
{
|
||||
return m_pgrnMesh;
|
||||
}
|
||||
|
||||
const CGrannyMesh::TTriGroupNode * CGrannyMesh::GetTriGroupNodeList(CGrannyMaterial::EType eMtrlType) const
|
||||
{
|
||||
return m_triGroupNodeLists[eMtrlType];
|
||||
}
|
||||
|
||||
int CGrannyMesh::GetVertexCount() const
|
||||
{
|
||||
assert(m_pgrnMesh!=NULL);
|
||||
return GrannyGetMeshVertexCount(m_pgrnMesh);
|
||||
}
|
||||
|
||||
int CGrannyMesh::GetVertexBasePosition() const
|
||||
{
|
||||
return m_vtxBasePos;
|
||||
}
|
||||
|
||||
int CGrannyMesh::GetIndexBasePosition() const
|
||||
{
|
||||
return m_idxBasePos;
|
||||
}
|
||||
|
||||
// WORK
|
||||
int * CGrannyMesh::GetDefaultBoneIndices() const
|
||||
{
|
||||
return GrannyGetMeshBindingToBoneIndices(m_pgrnMeshBindingTemp);
|
||||
}
|
||||
// END_OF_WORK
|
||||
|
||||
bool CGrannyMesh::IsEmpty() const
|
||||
{
|
||||
if (m_pgrnMesh)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyMesh::CreateFromGrannyMeshPointer(granny_skeleton * pgrnSkeleton, granny_mesh * pgrnMesh, int vtxBasePos, int idxBasePos, CGrannyMaterialPalette& rkMtrlPal)
|
||||
{
|
||||
assert(IsEmpty());
|
||||
|
||||
m_pgrnMesh = pgrnMesh;
|
||||
m_vtxBasePos = vtxBasePos;
|
||||
m_idxBasePos = idxBasePos;
|
||||
|
||||
if (m_pgrnMesh->BoneBindingCount < 0)
|
||||
return true;
|
||||
|
||||
// WORK
|
||||
m_pgrnMeshBindingTemp = GrannyNewMeshBinding(m_pgrnMesh, pgrnSkeleton, pgrnSkeleton);
|
||||
// END_OF_WORK
|
||||
|
||||
if (!GrannyMeshIsRigid(m_pgrnMesh))
|
||||
{
|
||||
m_canDeformPNTVertex = true;
|
||||
|
||||
granny_data_type_definition * pgrnInputType = GrannyGetMeshVertexType(m_pgrnMesh);
|
||||
granny_data_type_definition * pgrnOutputType = m_pgrnMeshType;
|
||||
|
||||
m_pgrnMeshDeformer = GrannyNewMeshDeformer(pgrnInputType, pgrnOutputType, GrannyDeformPositionNormal);
|
||||
assert(m_pgrnMeshDeformer != NULL && "Cannot create mesh deformer");
|
||||
}
|
||||
|
||||
// Two Side Mesh
|
||||
if (!strncmp(m_pgrnMesh->Name, "2x", 2))
|
||||
m_isTwoSide = true;
|
||||
|
||||
if (!LoadMaterials(rkMtrlPal))
|
||||
return false;
|
||||
|
||||
if (!LoadTriGroupNodeList(rkMtrlPal))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyMesh::LoadTriGroupNodeList(CGrannyMaterialPalette& rkMtrlPal)
|
||||
{
|
||||
assert(m_pgrnMesh != NULL);
|
||||
assert(m_triGroupNodes == NULL);
|
||||
|
||||
int mtrlCount = m_pgrnMesh->MaterialBindingCount;
|
||||
if (mtrlCount <= 0) // õ<><C3B5> <20><><EFBFBD><EFBFBD> 2<><32> ũ<><C5A9><EFBFBD><EFBFBD> <20><EFBFBD>
|
||||
return true;
|
||||
|
||||
int GroupNodeCount = GrannyGetMeshTriangleGroupCount(m_pgrnMesh);
|
||||
if (GroupNodeCount <= 0)
|
||||
return true;
|
||||
|
||||
m_triGroupNodes = new TTriGroupNode[GroupNodeCount];
|
||||
|
||||
const granny_tri_material_group * c_pgrnTriGroups = GrannyGetMeshTriangleGroups(m_pgrnMesh);
|
||||
|
||||
for (int g = 0; g < GroupNodeCount; ++g)
|
||||
{
|
||||
const granny_tri_material_group & c_rgrnTriGroup = c_pgrnTriGroups[g];
|
||||
TTriGroupNode * pTriGroupNode = m_triGroupNodes + g;
|
||||
|
||||
pTriGroupNode->idxPos = m_idxBasePos + c_rgrnTriGroup.TriFirst * 3;
|
||||
pTriGroupNode->triCount = c_rgrnTriGroup.TriCount;
|
||||
|
||||
int iMtrl = c_rgrnTriGroup.MaterialIndex;
|
||||
if (iMtrl < 0 || iMtrl >= mtrlCount)
|
||||
{
|
||||
pTriGroupNode->mtrlIndex=0;//m_mtrlIndexVector[iMtrl];
|
||||
}
|
||||
else
|
||||
{
|
||||
pTriGroupNode->mtrlIndex=m_mtrlIndexVector[iMtrl];
|
||||
}
|
||||
|
||||
const CGrannyMaterial& rkMtrl=rkMtrlPal.GetMaterialRef(pTriGroupNode->mtrlIndex);
|
||||
pTriGroupNode->pNextTriGroupNode = m_triGroupNodeLists[rkMtrl.GetType()];
|
||||
m_triGroupNodeLists[rkMtrl.GetType()] = pTriGroupNode;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyMesh::RebuildTriGroupNodeList()
|
||||
{
|
||||
assert(!"CGrannyMesh::RebuildTriGroupNodeList() - <20><> <20><><EFBFBD><EFBFBD><EFBFBD>带 <20>ϴ°<CFB4>- -?");
|
||||
/*
|
||||
int mtrlCount = m_pgrnMesh->MaterialBindingCount;
|
||||
int GroupNodeCount = GrannyGetMeshTriangleGroupCount(m_pgrnMesh);
|
||||
|
||||
if (GroupNodeCount <= 0)
|
||||
return;
|
||||
|
||||
const granny_tri_material_group * c_pgrnTriGroups = GrannyGetMeshTriangleGroups(m_pgrnMesh);
|
||||
|
||||
for (int g = 0; g < GroupNodeCount; ++g)
|
||||
{
|
||||
const granny_tri_material_group& c_rgrnTriGroup = c_pgrnTriGroups[g];
|
||||
TTriGroupNode * pTriGroupNode = m_triGroupNodes + g;
|
||||
|
||||
int iMtrl = c_rgrnTriGroup.MaterialIndex;
|
||||
|
||||
if (iMtrl >= 0 && iMtrl < mtrlCount)
|
||||
{
|
||||
CGrannyMaterial & rMtrl = m_mtrls[iMtrl];
|
||||
|
||||
pTriGroupNode->lpd3dTextures[0] = rMtrl.GetD3DTexture(0);
|
||||
pTriGroupNode->lpd3dTextures[1] = rMtrl.GetD3DTexture(1);
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bool CGrannyMesh::LoadMaterials(CGrannyMaterialPalette& rkMtrlPal)
|
||||
{
|
||||
assert(m_pgrnMesh != NULL);
|
||||
|
||||
if (m_pgrnMesh->MaterialBindingCount <= 0)
|
||||
return true;
|
||||
|
||||
int mtrlCount = m_pgrnMesh->MaterialBindingCount;
|
||||
bool bHaveBlendThing = false;
|
||||
|
||||
for (int m = 0; m < mtrlCount; ++m)
|
||||
{
|
||||
granny_material* pgrnMaterial = m_pgrnMesh->MaterialBindings[m].Material;
|
||||
DWORD mtrlIndex=rkMtrlPal.RegisterMaterial(pgrnMaterial);
|
||||
m_mtrlIndexVector.push_back(mtrlIndex);
|
||||
bHaveBlendThing |= rkMtrlPal.GetMaterialRef(mtrlIndex).GetType() == CGrannyMaterial::TYPE_BLEND_PNT;
|
||||
}
|
||||
m_bHaveBlendThing = bHaveBlendThing;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyMesh::IsTwoSide() const
|
||||
{
|
||||
return m_isTwoSide;
|
||||
}
|
||||
|
||||
void CGrannyMesh::SetPNT2Mesh()
|
||||
{
|
||||
m_pgrnMeshType = GrannyPNT3322VertexType;
|
||||
}
|
||||
|
||||
void CGrannyMesh::Destroy()
|
||||
{
|
||||
if (m_triGroupNodes)
|
||||
delete [] m_triGroupNodes;
|
||||
|
||||
m_mtrlIndexVector.clear();
|
||||
|
||||
// WORK
|
||||
if (m_pgrnMeshBindingTemp)
|
||||
GrannyFreeMeshBinding(m_pgrnMeshBindingTemp);
|
||||
// END_OF_WORK
|
||||
|
||||
if (m_pgrnMeshDeformer)
|
||||
GrannyFreeMeshDeformer(m_pgrnMeshDeformer);
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
void CGrannyMesh::Initialize()
|
||||
{
|
||||
for (int r = 0; r < CGrannyMaterial::TYPE_MAX_NUM; ++r)
|
||||
m_triGroupNodeLists[r] = NULL;
|
||||
|
||||
m_pgrnMeshType = GrannyPNT332VertexType;
|
||||
m_pgrnMesh = NULL;
|
||||
// WORK
|
||||
m_pgrnMeshBindingTemp = NULL;
|
||||
// END_OF_WORK
|
||||
m_pgrnMeshDeformer = NULL;
|
||||
|
||||
m_triGroupNodes = NULL;
|
||||
|
||||
m_vtxBasePos = 0;
|
||||
m_idxBasePos = 0;
|
||||
|
||||
m_canDeformPNTVertex = false;
|
||||
m_isTwoSide = false;
|
||||
m_bHaveBlendThing = false;
|
||||
}
|
||||
|
||||
CGrannyMesh::CGrannyMesh()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CGrannyMesh::~CGrannyMesh()
|
||||
{
|
||||
Destroy();
|
||||
}
|
98
src/EterGrnLib/Mesh.h
Normal file
98
src/EterGrnLib/Mesh.h
Normal file
@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
|
||||
#include "Material.h"
|
||||
|
||||
extern granny_data_type_definition GrannyPNT3322VertexType[5];
|
||||
|
||||
struct granny_pnt3322_vertex
|
||||
{
|
||||
granny_real32 Position[3];
|
||||
granny_real32 Normal[3];
|
||||
granny_real32 UV0[2];
|
||||
granny_real32 UV1[2];
|
||||
};
|
||||
|
||||
class CGrannyMesh
|
||||
{
|
||||
public:
|
||||
enum EType
|
||||
{
|
||||
TYPE_RIGID,
|
||||
TYPE_DEFORM,
|
||||
TYPE_MAX_NUM
|
||||
};
|
||||
|
||||
typedef struct STriGroupNode
|
||||
{
|
||||
STriGroupNode * pNextTriGroupNode;
|
||||
int idxPos;
|
||||
int triCount;
|
||||
DWORD mtrlIndex;
|
||||
} TTriGroupNode;
|
||||
|
||||
public:
|
||||
CGrannyMesh();
|
||||
virtual ~CGrannyMesh();
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool CreateFromGrannyMeshPointer(granny_skeleton* pgrnSkeleton, granny_mesh* pgrnMesh, int vtxBasePos, int idxBasePos, CGrannyMaterialPalette& rkMtrlPal);
|
||||
void LoadIndices(void* dstBaseIndices);
|
||||
void LoadPNTVertices(void* dstBaseVertices);
|
||||
void NEW_LoadVertices(void* dstBaseVertices);
|
||||
void Destroy();
|
||||
|
||||
void SetPNT2Mesh();
|
||||
|
||||
void DeformPNTVertices(void* dstBaseVertices, D3DXMATRIX* boneMatrices, granny_mesh_binding* pgrnMeshBinding) const;
|
||||
bool CanDeformPNTVertices() const;
|
||||
bool IsTwoSide() const;
|
||||
|
||||
int GetVertexCount() const;
|
||||
|
||||
// WORK
|
||||
int * GetDefaultBoneIndices() const;
|
||||
// END_OF_WORK
|
||||
|
||||
int GetVertexBasePosition() const;
|
||||
int GetIndexBasePosition() const;
|
||||
|
||||
const granny_mesh * GetGrannyMeshPointer() const;
|
||||
const CGrannyMesh::TTriGroupNode * GetTriGroupNodeList(CGrannyMaterial::EType eMtrlType) const;
|
||||
|
||||
void RebuildTriGroupNodeList();
|
||||
void ReloadMaterials();
|
||||
|
||||
protected:
|
||||
void Initialize();
|
||||
|
||||
bool LoadMaterials(CGrannyMaterialPalette& rkMtrlPal);
|
||||
bool LoadTriGroupNodeList(CGrannyMaterialPalette& rkMtrlPal);
|
||||
|
||||
protected:
|
||||
// Granny Mesh Data
|
||||
granny_data_type_definition * m_pgrnMeshType;
|
||||
granny_mesh * m_pgrnMesh;
|
||||
|
||||
// WORK
|
||||
granny_mesh_binding * m_pgrnMeshBindingTemp;
|
||||
// END_OF_WORK
|
||||
|
||||
granny_mesh_deformer * m_pgrnMeshDeformer;
|
||||
|
||||
// Granny Material Data
|
||||
std::vector<DWORD> m_mtrlIndexVector;
|
||||
|
||||
// TriGroups Data
|
||||
TTriGroupNode * m_triGroupNodes;
|
||||
TTriGroupNode * m_triGroupNodeLists[CGrannyMaterial::TYPE_MAX_NUM];
|
||||
|
||||
int m_vtxBasePos;
|
||||
int m_idxBasePos;
|
||||
|
||||
bool m_canDeformPNTVertex;
|
||||
bool m_isTwoSide;
|
||||
private:
|
||||
bool m_bHaveBlendThing;
|
||||
public:
|
||||
bool HaveBlendThing() { return m_bHaveBlendThing; }
|
||||
};
|
419
src/EterGrnLib/Model.cpp
Normal file
419
src/EterGrnLib/Model.cpp
Normal file
@ -0,0 +1,419 @@
|
||||
#include "StdAfx.h"
|
||||
#include "Model.h"
|
||||
#include "Mesh.h"
|
||||
|
||||
const CGrannyMaterialPalette& CGrannyModel::GetMaterialPalette() const
|
||||
{
|
||||
return m_kMtrlPal;
|
||||
}
|
||||
|
||||
const CGrannyModel::TMeshNode* CGrannyModel::GetMeshNodeList(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType) const
|
||||
{
|
||||
return m_meshNodeLists[eMeshType][eMtrlType];
|
||||
}
|
||||
|
||||
CGrannyMesh * CGrannyModel::GetMeshPointer(int iMesh)
|
||||
{
|
||||
assert(CheckMeshIndex(iMesh));
|
||||
assert(m_meshs != NULL);
|
||||
|
||||
return m_meshs + iMesh;
|
||||
}
|
||||
|
||||
const CGrannyMesh* CGrannyModel::GetMeshPointer(int iMesh) const
|
||||
{
|
||||
assert(CheckMeshIndex(iMesh));
|
||||
assert(m_meshs != NULL);
|
||||
|
||||
return m_meshs + iMesh;
|
||||
}
|
||||
|
||||
bool CGrannyModel::CanDeformPNTVertices() const
|
||||
{
|
||||
return m_canDeformPNVertices;
|
||||
}
|
||||
|
||||
void CGrannyModel::DeformPNTVertices(void * dstBaseVertices, D3DXMATRIX * boneMatrices, const std::vector<granny_mesh_binding*>& c_rvct_pgrnMeshBinding) const
|
||||
{
|
||||
int meshCount = GetMeshCount();
|
||||
|
||||
for (int iMesh = 0; iMesh < meshCount; ++iMesh)
|
||||
{
|
||||
assert(iMesh < c_rvct_pgrnMeshBinding.size());
|
||||
|
||||
CGrannyMesh & rMesh = m_meshs[iMesh];
|
||||
if (rMesh.CanDeformPNTVertices())
|
||||
rMesh.DeformPNTVertices(dstBaseVertices, boneMatrices, c_rvct_pgrnMeshBinding[iMesh]);
|
||||
}
|
||||
}
|
||||
|
||||
int CGrannyModel::GetRigidVertexCount() const
|
||||
{
|
||||
return m_rigidVtxCount;
|
||||
}
|
||||
|
||||
int CGrannyModel::GetDeformVertexCount() const
|
||||
{
|
||||
return m_deformVtxCount;
|
||||
}
|
||||
|
||||
int CGrannyModel::GetVertexCount() const
|
||||
{
|
||||
return m_vtxCount;
|
||||
}
|
||||
|
||||
int CGrannyModel::GetMeshCount() const
|
||||
{
|
||||
return m_pgrnModel ? m_pgrnModel->MeshBindingCount : 0;
|
||||
}
|
||||
|
||||
granny_model* CGrannyModel::GetGrannyModelPointer()
|
||||
{
|
||||
return m_pgrnModel;
|
||||
}
|
||||
|
||||
LPDIRECT3DINDEXBUFFER8 CGrannyModel::GetD3DIndexBuffer() const
|
||||
{
|
||||
return m_idxBuf.GetD3DIndexBuffer();
|
||||
}
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 CGrannyModel::GetPNTD3DVertexBuffer() const
|
||||
{
|
||||
return m_pntVtxBuf.GetD3DVertexBuffer();
|
||||
}
|
||||
|
||||
bool CGrannyModel::LockVertices(void** indicies, void** vertices) const
|
||||
{
|
||||
if (!m_idxBuf.Lock(indicies))
|
||||
return false;
|
||||
|
||||
if (!m_pntVtxBuf.Lock(vertices))
|
||||
{
|
||||
m_idxBuf.Unlock();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyModel::UnlockVertices() const
|
||||
{
|
||||
m_idxBuf.Unlock();
|
||||
m_pntVtxBuf.Unlock();
|
||||
}
|
||||
|
||||
bool CGrannyModel::LoadPNTVertices()
|
||||
{
|
||||
if (m_rigidVtxCount <= 0)
|
||||
return true;
|
||||
|
||||
assert(m_meshs != NULL);
|
||||
|
||||
if (!m_pntVtxBuf.Create(m_rigidVtxCount, m_dwFvF, D3DUSAGE_WRITEONLY, D3DPOOL_MANAGED))
|
||||
return false;
|
||||
|
||||
void* vertices;
|
||||
if (!m_pntVtxBuf.Lock(&vertices))
|
||||
return false;
|
||||
|
||||
for (int m = 0; m < m_pgrnModel->MeshBindingCount; ++m)
|
||||
{
|
||||
CGrannyMesh& rMesh = m_meshs[m];
|
||||
rMesh.LoadPNTVertices(vertices);
|
||||
}
|
||||
|
||||
m_pntVtxBuf.Unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyModel::LoadIndices()
|
||||
{
|
||||
//assert(m_idxCount > 0);
|
||||
if (m_idxCount <= 0)
|
||||
return true;
|
||||
|
||||
if (!m_idxBuf.Create(m_idxCount, D3DFMT_INDEX16))
|
||||
return false;
|
||||
|
||||
void * indices;
|
||||
|
||||
if (!m_idxBuf.Lock((void**)&indices))
|
||||
return false;
|
||||
|
||||
for (int m = 0; m < m_pgrnModel->MeshBindingCount; ++m)
|
||||
{
|
||||
CGrannyMesh& rMesh = m_meshs[m];
|
||||
rMesh.LoadIndices(indices);
|
||||
}
|
||||
|
||||
m_idxBuf.Unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyModel::LoadMeshs()
|
||||
{
|
||||
assert(m_meshs == NULL);
|
||||
assert(m_pgrnModel != NULL);
|
||||
|
||||
if (m_pgrnModel->MeshBindingCount <= 0) // <20><EFBFBD><DEBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
return true;
|
||||
|
||||
granny_skeleton * pgrnSkeleton = m_pgrnModel->Skeleton;
|
||||
|
||||
int vtxRigidPos = 0;
|
||||
int vtxDeformPos = 0;
|
||||
int vtxPos = 0;
|
||||
int idxPos = 0;
|
||||
|
||||
int diffusePNTMeshNodeCount = 0;
|
||||
int blendPNTMeshNodeCount = 0;
|
||||
int blendPNT2MeshNodeCount = 0;
|
||||
|
||||
int meshCount = GetMeshCount();
|
||||
m_meshs = new CGrannyMesh[meshCount];
|
||||
|
||||
m_dwFvF = 0;
|
||||
|
||||
for (int m = 0; m < meshCount; ++m)
|
||||
{
|
||||
CGrannyMesh& rMesh = m_meshs[m];
|
||||
granny_mesh* pgrnMesh = m_pgrnModel->MeshBindings[m].Mesh;
|
||||
|
||||
if (GrannyMeshIsRigid(pgrnMesh))
|
||||
{
|
||||
if (!rMesh.CreateFromGrannyMeshPointer(pgrnSkeleton, pgrnMesh, vtxRigidPos, idxPos, m_kMtrlPal))
|
||||
return false;
|
||||
|
||||
vtxRigidPos += GrannyGetMeshVertexCount(pgrnMesh);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!rMesh.CreateFromGrannyMeshPointer(pgrnSkeleton, pgrnMesh, vtxDeformPos, idxPos, m_kMtrlPal))
|
||||
return false;
|
||||
|
||||
vtxDeformPos += GrannyGetMeshVertexCount(pgrnMesh);
|
||||
m_canDeformPNVertices |= rMesh.CanDeformPNTVertices();
|
||||
}
|
||||
m_bHaveBlendThing |= rMesh.HaveBlendThing();
|
||||
|
||||
granny_int32x grni32xTypeCount = GrannyGetTotalTypeSize(pgrnMesh->PrimaryVertexData->VertexType) / 32;
|
||||
int i = 0;
|
||||
while (i < grni32xTypeCount)
|
||||
{
|
||||
if (NULL == pgrnMesh->PrimaryVertexData->VertexType[i].Name || 0 == strlen(pgrnMesh->PrimaryVertexData->VertexType[i].Name))
|
||||
{
|
||||
++i;
|
||||
continue;
|
||||
}
|
||||
if ( 0 == strcmp(pgrnMesh->PrimaryVertexData->VertexType[i].Name, GrannyVertexPositionName) )
|
||||
m_dwFvF |= D3DFVF_XYZ;
|
||||
else if ( 0 == strcmp(pgrnMesh->PrimaryVertexData->VertexType[i].Name, GrannyVertexNormalName) )
|
||||
m_dwFvF |= D3DFVF_NORMAL;
|
||||
else if ( 0 == strcmp(pgrnMesh->PrimaryVertexData->VertexType[i].Name, GrannyVertexTextureCoordinatesName"0") )
|
||||
m_dwFvF |= D3DFVF_TEX1;
|
||||
else if ( 0 == strcmp(pgrnMesh->PrimaryVertexData->VertexType[i].Name, GrannyVertexTextureCoordinatesName"1") )
|
||||
m_dwFvF |= D3DFVF_TEX2;
|
||||
++i;
|
||||
}
|
||||
|
||||
vtxPos += GrannyGetMeshVertexCount(pgrnMesh);
|
||||
idxPos += GrannyGetMeshIndexCount(pgrnMesh);
|
||||
|
||||
if (rMesh.GetTriGroupNodeList(CGrannyMaterial::TYPE_DIFFUSE_PNT))
|
||||
++diffusePNTMeshNodeCount;
|
||||
|
||||
if (rMesh.GetTriGroupNodeList(CGrannyMaterial::TYPE_BLEND_PNT))
|
||||
++blendPNTMeshNodeCount;
|
||||
}
|
||||
|
||||
m_meshNodeCapacity = diffusePNTMeshNodeCount + blendPNTMeshNodeCount + blendPNT2MeshNodeCount;
|
||||
m_meshNodes = new TMeshNode[m_meshNodeCapacity];
|
||||
|
||||
for (int n = 0; n < meshCount; ++n)
|
||||
{
|
||||
CGrannyMesh& rMesh = m_meshs[n];
|
||||
granny_mesh* pgrnMesh = m_pgrnModel->MeshBindings[n].Mesh;
|
||||
|
||||
CGrannyMesh::EType eMeshType = GrannyMeshIsRigid(pgrnMesh) ? CGrannyMesh::TYPE_RIGID : CGrannyMesh::TYPE_DEFORM;
|
||||
|
||||
if (rMesh.GetTriGroupNodeList(CGrannyMaterial::TYPE_DIFFUSE_PNT))
|
||||
AppendMeshNode(eMeshType, CGrannyMaterial::TYPE_DIFFUSE_PNT, n);
|
||||
|
||||
if (rMesh.GetTriGroupNodeList(CGrannyMaterial::TYPE_BLEND_PNT))
|
||||
AppendMeshNode(eMeshType, CGrannyMaterial::TYPE_BLEND_PNT, n);
|
||||
}
|
||||
|
||||
// For Dungeon Block
|
||||
if ((D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1|D3DFVF_TEX2) == m_dwFvF)
|
||||
{
|
||||
for (int n = 0; n < meshCount; ++n)
|
||||
{
|
||||
CGrannyMesh& rMesh = m_meshs[n];
|
||||
rMesh.SetPNT2Mesh();
|
||||
}
|
||||
}
|
||||
|
||||
m_rigidVtxCount = vtxRigidPos;
|
||||
m_deformVtxCount = vtxDeformPos;
|
||||
|
||||
m_vtxCount = vtxPos;
|
||||
m_idxCount = idxPos;
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL CGrannyModel::CheckMeshIndex(int iIndex) const
|
||||
{
|
||||
if (iIndex < 0)
|
||||
return FALSE;
|
||||
if (iIndex >= m_meshNodeSize)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CGrannyModel::AppendMeshNode(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType, int iMesh)
|
||||
{
|
||||
assert(m_meshNodeSize < m_meshNodeCapacity);
|
||||
|
||||
TMeshNode& rMeshNode = m_meshNodes[m_meshNodeSize++];
|
||||
|
||||
rMeshNode.iMesh = iMesh;
|
||||
rMeshNode.pMesh = m_meshs + iMesh;
|
||||
rMeshNode.pNextMeshNode = m_meshNodeLists[eMeshType][eMtrlType];
|
||||
m_meshNodeLists[eMeshType][eMtrlType] = &rMeshNode;
|
||||
}
|
||||
|
||||
bool CGrannyModel::CreateFromGrannyModelPointer(granny_model* pgrnModel)
|
||||
{
|
||||
assert(IsEmpty());
|
||||
|
||||
m_pgrnModel = pgrnModel;
|
||||
|
||||
if (!LoadMeshs())
|
||||
return false;
|
||||
|
||||
if (!__LoadVertices())
|
||||
return false;
|
||||
|
||||
if (!LoadIndices())
|
||||
return false;
|
||||
|
||||
AddReference();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int CGrannyModel::GetIdxCount()
|
||||
{
|
||||
return m_idxCount;
|
||||
}
|
||||
|
||||
bool CGrannyModel::CreateDeviceObjects()
|
||||
{
|
||||
if (m_rigidVtxCount > 0)
|
||||
if (!m_pntVtxBuf.CreateDeviceObjects())
|
||||
return false;
|
||||
|
||||
if (m_idxCount > 0)
|
||||
if (!m_idxBuf.CreateDeviceObjects())
|
||||
return false;
|
||||
|
||||
int meshCount = GetMeshCount();
|
||||
|
||||
for (int i = 0; i < meshCount; ++i)
|
||||
{
|
||||
CGrannyMesh& rMesh = m_meshs[i];
|
||||
rMesh.RebuildTriGroupNodeList();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyModel::DestroyDeviceObjects()
|
||||
{
|
||||
m_pntVtxBuf.DestroyDeviceObjects();
|
||||
m_idxBuf.DestroyDeviceObjects();
|
||||
}
|
||||
|
||||
bool CGrannyModel::IsEmpty() const
|
||||
{
|
||||
if (m_pgrnModel)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyModel::Destroy()
|
||||
{
|
||||
m_kMtrlPal.Clear();
|
||||
|
||||
if (m_meshNodes)
|
||||
delete [] m_meshNodes;
|
||||
|
||||
if (m_meshs)
|
||||
delete [] m_meshs;
|
||||
|
||||
m_pntVtxBuf.Destroy();
|
||||
m_idxBuf.Destroy();
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
bool CGrannyModel::__LoadVertices()
|
||||
{
|
||||
if (m_rigidVtxCount <= 0)
|
||||
return true;
|
||||
|
||||
assert(m_meshs != NULL);
|
||||
|
||||
// assert((m_dwFvF & (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)) == m_dwFvF);
|
||||
|
||||
// if (!m_pntVtxBuf.Create(m_rigidVtxCount, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1, D3DUSAGE_WRITEONLY, D3DPOOL_MANAGED))
|
||||
if (!m_pntVtxBuf.Create(m_rigidVtxCount, m_dwFvF, D3DUSAGE_WRITEONLY, D3DPOOL_MANAGED))
|
||||
return false;
|
||||
|
||||
void* vertices;
|
||||
if (!m_pntVtxBuf.Lock(&vertices))
|
||||
return false;
|
||||
|
||||
for (int m = 0; m < m_pgrnModel->MeshBindingCount; ++m)
|
||||
{
|
||||
CGrannyMesh& rMesh = m_meshs[m];
|
||||
rMesh.NEW_LoadVertices(vertices);
|
||||
}
|
||||
|
||||
m_pntVtxBuf.Unlock();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyModel::Initialize()
|
||||
{
|
||||
memset(m_meshNodeLists, 0, sizeof(m_meshNodeLists));
|
||||
|
||||
m_pgrnModel = NULL;
|
||||
m_meshs = NULL;
|
||||
m_meshNodes = NULL;
|
||||
|
||||
m_meshNodeSize = 0;
|
||||
m_meshNodeCapacity = 0;
|
||||
|
||||
m_rigidVtxCount = 0;
|
||||
m_deformVtxCount = 0;
|
||||
m_vtxCount = 0;
|
||||
m_idxCount = 0;
|
||||
|
||||
m_canDeformPNVertices = false;
|
||||
|
||||
m_dwFvF = 0;
|
||||
m_bHaveBlendThing = false;
|
||||
}
|
||||
|
||||
CGrannyModel::CGrannyModel()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
CGrannyModel::~CGrannyModel()
|
||||
{
|
||||
Destroy();
|
||||
}
|
98
src/EterGrnLib/Model.h
Normal file
98
src/EterGrnLib/Model.h
Normal file
@ -0,0 +1,98 @@
|
||||
#pragma once
|
||||
|
||||
#include "../eterlib/GrpVertexBuffer.h"
|
||||
#include "../eterlib/GrpIndexBuffer.h"
|
||||
|
||||
#include "Mesh.h"
|
||||
|
||||
class CGrannyModel : public CReferenceObject
|
||||
{
|
||||
public:
|
||||
typedef struct SMeshNode
|
||||
{
|
||||
int iMesh;
|
||||
const CGrannyMesh * pMesh;
|
||||
SMeshNode * pNextMeshNode;
|
||||
} TMeshNode;
|
||||
|
||||
public:
|
||||
CGrannyModel();
|
||||
virtual ~CGrannyModel();
|
||||
|
||||
bool IsEmpty() const;
|
||||
bool CreateFromGrannyModelPointer(granny_model* pgrnModel);
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
void Destroy();
|
||||
|
||||
int GetRigidVertexCount() const;
|
||||
int GetDeformVertexCount() const;
|
||||
int GetVertexCount() const;
|
||||
|
||||
bool CanDeformPNTVertices() const;
|
||||
void DeformPNTVertices(void* dstBaseVertices, D3DXMATRIX* boneMatrices, const std::vector<granny_mesh_binding*>& c_rvct_pgrnMeshBinding) const;
|
||||
|
||||
int GetIdxCount();
|
||||
int GetMeshCount() const;
|
||||
CGrannyMesh * GetMeshPointer(int iMesh);
|
||||
granny_model * GetGrannyModelPointer();
|
||||
const CGrannyMesh* GetMeshPointer(int iMesh) const;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 GetPNTD3DVertexBuffer() const;
|
||||
LPDIRECT3DINDEXBUFFER8 GetD3DIndexBuffer() const;
|
||||
|
||||
const CGrannyModel::TMeshNode* GetMeshNodeList(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType) const;
|
||||
|
||||
bool LockVertices(void** indicies, void** vertices) const;
|
||||
void UnlockVertices() const;
|
||||
|
||||
const CGrannyMaterialPalette& GetMaterialPalette() const;
|
||||
|
||||
protected:
|
||||
bool LoadMeshs();
|
||||
bool LoadPNTVertices();
|
||||
bool LoadIndices();
|
||||
void Initialize();
|
||||
|
||||
BOOL CheckMeshIndex(int iIndex) const;
|
||||
void AppendMeshNode(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType, int iMesh);
|
||||
|
||||
protected:
|
||||
// Granny Data
|
||||
granny_model * m_pgrnModel;
|
||||
|
||||
// Static Data
|
||||
CGrannyMesh * m_meshs;
|
||||
|
||||
CGraphicVertexBuffer m_pntVtxBuf; // for rigid mesh
|
||||
CGraphicIndexBuffer m_idxBuf;
|
||||
|
||||
TMeshNode * m_meshNodes;
|
||||
TMeshNode * m_meshNodeLists[CGrannyMesh::TYPE_MAX_NUM][CGrannyMaterial::TYPE_MAX_NUM];
|
||||
|
||||
int m_deformVtxCount;
|
||||
int m_rigidVtxCount;
|
||||
int m_vtxCount;
|
||||
int m_idxCount;
|
||||
|
||||
int m_meshNodeSize;
|
||||
int m_meshNodeCapacity;
|
||||
|
||||
bool m_canDeformPNVertices;
|
||||
|
||||
CGrannyMaterialPalette m_kMtrlPal;
|
||||
private:
|
||||
bool m_bHaveBlendThing;
|
||||
public:
|
||||
bool HaveBlendThing() { return m_bHaveBlendThing; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// New members to support PNT2 type models
|
||||
protected:
|
||||
bool __LoadVertices();
|
||||
protected:
|
||||
DWORD m_dwFvF;
|
||||
// New members to support PNT2 type models
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
};
|
140
src/EterGrnLib/ModelInstance.cpp
Normal file
140
src/EterGrnLib/ModelInstance.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
#include "StdAfx.h"
|
||||
#include "ModelInstance.h"
|
||||
#include "Model.h"
|
||||
#include "../EterLib/ResourceManager.h"
|
||||
|
||||
|
||||
CGrannyModel* CGrannyModelInstance::GetModel()
|
||||
{
|
||||
return m_pModel;
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage)
|
||||
{
|
||||
m_kMtrlPal.SetMaterialImagePointer(c_szImageName, pImage);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData)
|
||||
{
|
||||
m_kMtrlPal.SetMaterialData(c_szImageName, c_rkMaterialData);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower)
|
||||
{
|
||||
m_kMtrlPal.SetSpecularInfo(c_szMtrlName, bEnable, fPower);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetLocalTime(float fLocalTime)
|
||||
{
|
||||
m_fLocalTime = fLocalTime;
|
||||
}
|
||||
|
||||
int CGrannyModelInstance::ResetLocalTime()
|
||||
{
|
||||
m_fLocalTime = 0.0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float CGrannyModelInstance::GetLocalTime()
|
||||
{
|
||||
return m_fLocalTime;
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, const char * c_szBoneName)
|
||||
{
|
||||
int iBoneIndex;
|
||||
if (!c_pParentModelInstance->GetBoneIndexByName(c_szBoneName, &iBoneIndex))
|
||||
return;
|
||||
|
||||
SetParentModelInstance(c_pParentModelInstance, iBoneIndex);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, int iBone)
|
||||
{
|
||||
mc_pParentInstance = c_pParentModelInstance;
|
||||
m_iParentBoneIndex = iBone;
|
||||
}
|
||||
|
||||
bool CGrannyModelInstance::IsEmpty()
|
||||
{
|
||||
if (m_pModel)
|
||||
{
|
||||
// NO_MESH_BUG_FIX
|
||||
if (!m_meshMatrices)
|
||||
return true;
|
||||
// END_OF_NO_MESH_BUG_FIX
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CGrannyModelInstance::CreateDeviceObjects()
|
||||
{
|
||||
__CreateDynamicVertexBuffer();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::DestroyDeviceObjects()
|
||||
{
|
||||
__DestroyDynamicVertexBuffer();
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::__Initialize()
|
||||
{
|
||||
if (m_pModel)
|
||||
{
|
||||
m_pModel->Release();
|
||||
}
|
||||
m_pModel = NULL;
|
||||
mc_pParentInstance = NULL;
|
||||
m_iParentBoneIndex = 0;
|
||||
|
||||
m_pgrnModelInstance = NULL;
|
||||
|
||||
// WORK
|
||||
m_pgrnWorldPoseReal = NULL;
|
||||
// END_OF_WORK
|
||||
|
||||
// TEST
|
||||
// m_pgrnWorldPose = NULL;
|
||||
m_ppkSkeletonInst = NULL;
|
||||
// END_OF_TEST
|
||||
|
||||
m_meshMatrices = NULL;
|
||||
m_pgrnCtrl = NULL;
|
||||
m_pgrnAni = NULL;
|
||||
|
||||
m_dwOldUpdateFrame=0;
|
||||
|
||||
}
|
||||
|
||||
CGrannyModelInstance::CGrannyModelInstance()
|
||||
{
|
||||
m_pModel = NULL;
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
CGrannyModelInstance::~CGrannyModelInstance()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
CDynamicPool<CGrannyModelInstance> CGrannyModelInstance::ms_kPool;
|
||||
|
||||
CGrannyModelInstance* CGrannyModelInstance::New()
|
||||
{
|
||||
return ms_kPool.Alloc();
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::Delete(CGrannyModelInstance* pkInst)
|
||||
{
|
||||
pkInst->Clear();
|
||||
ms_kPool.Free(pkInst);
|
||||
}
|
||||
|
||||
void CGrannyModelInstance::DestroySystem()
|
||||
{
|
||||
ms_kPool.Destroy();
|
||||
}
|
202
src/EterGrnLib/ModelInstance.h
Normal file
202
src/EterGrnLib/ModelInstance.h
Normal file
@ -0,0 +1,202 @@
|
||||
#pragma once
|
||||
|
||||
//#define CACHE_DEFORMED_VERTEX
|
||||
#include "../eterlib/GrpImage.h"
|
||||
#include "../eterlib/GrpCollisionObject.h"
|
||||
|
||||
#include "Model.h"
|
||||
#include "Motion.h"
|
||||
|
||||
class CGrannyModelInstance : public CGraphicCollisionObject
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ANIFPS_MIN = 30,
|
||||
ANIFPS_MAX = 120,
|
||||
};
|
||||
public:
|
||||
static void DestroySystem();
|
||||
|
||||
static CGrannyModelInstance* New();
|
||||
static void Delete(CGrannyModelInstance* pkInst);
|
||||
|
||||
static CDynamicPool<CGrannyModelInstance> ms_kPool;
|
||||
|
||||
public:
|
||||
struct FCreateDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyModelInstance * pModelInstance)
|
||||
{pModelInstance->CreateDeviceObjects();}
|
||||
};
|
||||
|
||||
struct FDestroyDeviceObjects
|
||||
{
|
||||
void operator() (CGrannyModelInstance * pModelInstance)
|
||||
{pModelInstance->DestroyDeviceObjects();}
|
||||
};
|
||||
|
||||
public:
|
||||
CGrannyModelInstance();
|
||||
virtual ~CGrannyModelInstance();
|
||||
|
||||
bool IsEmpty();
|
||||
void Clear();
|
||||
|
||||
bool CreateDeviceObjects();
|
||||
void DestroyDeviceObjects();
|
||||
|
||||
// Update & Render
|
||||
void Update(DWORD dwAniFPS);
|
||||
void UpdateLocalTime(float fElapsedTime);
|
||||
void UpdateTransform(D3DXMATRIX * pMatrix, float fSecondsElapsed);
|
||||
|
||||
void UpdateSkeleton(const D3DXMATRIX * c_pWorldMatrix, float fLocalTime);
|
||||
void DeformNoSkin(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void Deform(const D3DXMATRIX * c_pWorldMatrix);
|
||||
|
||||
// FIXME : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѱ<EFBFBD><D1B0><EFBFBD> 2<><32><EFBFBD><EFBFBD> <20>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̱ <20>̷<EFBFBD>
|
||||
// <20>Ҿ<EFBFBD><D2BE><EFBFBD><EFBFBD><EFBFBD> <20><>Ű<EFBFBD><C5B0><EFBFBD>簡 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>ñ<EFBFBD><C3B1><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD> <20>ؽ<EFBFBD><D8BD><EFBFBD> <20><><EFBFBD><EFBFBD>) + (ȿ<><C8BF><EFBFBD><EFBFBD> <20>ؽ<EFBFBD><D8BD><EFBFBD>)
|
||||
// <20>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD> <20>ڵ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̷<EFBFBD><CCB7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʳ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>. - [levites]
|
||||
// NOTE : <20><><EFBFBD>ο<EFBFBD> if<69><66><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>Ű<EFBFBD><C5B0> <20><><EFBFBD>ٴ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD> <20>̷<EFBFBD><CCB7><EFBFBD> <20>Լ<EFBFBD> <20><> <20><>ü<EFBFBD><C3BC> <20>и<EFBFBD>
|
||||
// <20><>Ű<EFBFBD><C5B0> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ս<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>鿡<EFBFBD><E9BFA1><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>. - [levites]
|
||||
// NOTE : <20>ǹ<EFBFBD><C7B9><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> OneTexture. ij<><C4B3><EFBFBD>ʹ<EFBFBD> <20><><EFBFBD>쿡 <20><><EFBFBD><EFBFBD> TwoTexture.
|
||||
void RenderWithOneTexture();
|
||||
void RenderWithTwoTexture();
|
||||
void BlendRenderWithOneTexture();
|
||||
void BlendRenderWithTwoTexture();
|
||||
void RenderWithoutTexture();
|
||||
|
||||
// Model
|
||||
CGrannyModel* GetModel();
|
||||
void SetMaterialImagePointer(const char* c_szImageName, CGraphicImage* pImage);
|
||||
void SetMaterialData(const char* c_szImageName, const SMaterialData& c_rkMaterialData);
|
||||
void SetSpecularInfo(const char* c_szMtrlName, BOOL bEnable, float fPower);
|
||||
|
||||
void SetMainModelPointer(CGrannyModel* pkModel, CGraphicVertexBuffer* pkSharedDefromableVertexBuffer);
|
||||
void SetLinkedModelPointer(CGrannyModel* pkModel, CGraphicVertexBuffer* pkSharedDefromableVertexBuffer, CGrannyModelInstance** ppkSkeletonInst);
|
||||
|
||||
// Motion
|
||||
void SetMotionPointer(const CGrannyMotion* pMotion, float blendTime=0.0f, int loopCount=0, float speedRatio=1.0f);
|
||||
void ChangeMotionPointer(const CGrannyMotion* pMotion, int loopCount=0, float speedRatio=1.0f);
|
||||
void SetMotionAtEnd();
|
||||
bool IsMotionPlaying();
|
||||
|
||||
void CopyMotion(CGrannyModelInstance * pModelInstance, bool bIsFreeSourceControl=false);
|
||||
|
||||
// Time
|
||||
void SetLocalTime(float fLocalTime);
|
||||
int ResetLocalTime();
|
||||
float GetLocalTime();
|
||||
float GetNextTime();
|
||||
|
||||
// WORK
|
||||
DWORD GetDeformableVertexCount();
|
||||
DWORD GetVertexCount();
|
||||
|
||||
// END_OF_WORK
|
||||
|
||||
// Bone & Attaching
|
||||
const float * GetBoneMatrixPointer(int iBone) const;
|
||||
const float * GetCompositeBoneMatrixPointer(int iBone) const;
|
||||
bool GetMeshMatrixPointer(int iMesh, const D3DXMATRIX ** c_ppMatrix) const;
|
||||
bool GetBoneIndexByName(const char * c_szBoneName, int * pBoneIndex) const;
|
||||
void SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, const char * c_szBoneName);
|
||||
void SetParentModelInstance(const CGrannyModelInstance* c_pParentModelInstance, int iBone);
|
||||
|
||||
// Collision Detection
|
||||
bool Intersect(const D3DXMATRIX * c_pMatrix, float * pu, float * pv, float * pt);
|
||||
void MakeBoundBox(TBoundBox* pBoundBox, const float* mat, const float* OBBMin, const float* OBBMax, D3DXVECTOR3* vtMin, D3DXVECTOR3* vtMax);
|
||||
void GetBoundBox(D3DXVECTOR3 * vtMin, D3DXVECTOR3* vtMax);
|
||||
|
||||
// Reload Texture
|
||||
void ReloadTexture();
|
||||
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
|
||||
void __DestroyModelInstance();
|
||||
void __DestroyMeshMatrices();
|
||||
void __DestroyDynamicVertexBuffer();
|
||||
|
||||
|
||||
void __CreateModelInstance();
|
||||
void __CreateMeshMatrices();
|
||||
void __CreateDynamicVertexBuffer();
|
||||
|
||||
// WORK
|
||||
void __DestroyWorldPose();
|
||||
void __CreateWorldPose(CGrannyModelInstance* pkSrcModelInst);
|
||||
|
||||
bool __CreateMeshBindingVector(CGrannyModelInstance* pkDstModelInst);
|
||||
void __DestroyMeshBindingVector();
|
||||
|
||||
int* __GetMeshBoneIndices(unsigned int iMeshBinding) const;
|
||||
|
||||
bool __IsDeformableVertexBuffer();
|
||||
void __SetSharedDeformableVertexBuffer(CGraphicVertexBuffer* pkSharedDeformableVertexBuffer);
|
||||
|
||||
IDirect3DVertexBuffer8* __GetDeformableD3DVertexBufferPtr();
|
||||
CGraphicVertexBuffer& __GetDeformableVertexBufferRef();
|
||||
|
||||
granny_world_pose* __GetWorldPosePtr() const;
|
||||
// END_OF_WORK
|
||||
|
||||
|
||||
// Update & Render
|
||||
void UpdateWorldPose();
|
||||
void UpdateWorldMatrices(const D3DXMATRIX * c_pWorldMatrix);
|
||||
void DeformPNTVertices(void * pvDest);
|
||||
|
||||
void RenderMeshNodeListWithOneTexture(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType);
|
||||
void RenderMeshNodeListWithTwoTexture(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType);
|
||||
void RenderMeshNodeListWithoutTexture(CGrannyMesh::EType eMeshType, CGrannyMaterial::EType eMtrlType);
|
||||
|
||||
protected:
|
||||
// Static Data
|
||||
CGrannyModel * m_pModel;
|
||||
|
||||
// Granny Data
|
||||
granny_model_instance * m_pgrnModelInstance;
|
||||
|
||||
//granny_world_pose * m_pgrnWorldPose; // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
granny_control * m_pgrnCtrl;
|
||||
granny_animation * m_pgrnAni;
|
||||
|
||||
// Meshes' Transform Data
|
||||
D3DXMATRIX * m_meshMatrices;
|
||||
|
||||
|
||||
// Attaching Data
|
||||
const CGrannyModelInstance * mc_pParentInstance;
|
||||
int m_iParentBoneIndex;
|
||||
|
||||
// Game Data
|
||||
float m_fLocalTime;
|
||||
float m_fSecondsElapsed;
|
||||
|
||||
DWORD m_dwOldUpdateFrame;
|
||||
|
||||
CGrannyMaterialPalette m_kMtrlPal;
|
||||
|
||||
// WORK
|
||||
granny_world_pose* m_pgrnWorldPoseReal; // <20><><EFBFBD><EFBFBD> <20><DEB8> <20><><EFBFBD> <20>Ҵ<EFBFBD>
|
||||
std::vector<granny_mesh_binding*> m_vct_pgrnMeshBinding;
|
||||
|
||||
// Dynamic Vertex Buffer
|
||||
CGraphicVertexBuffer* m_pkSharedDeformableVertexBuffer;
|
||||
CGraphicVertexBuffer m_kLocalDeformableVertexBuffer;
|
||||
bool m_isDeformableVertexBuffer;
|
||||
// END_OF_WORK
|
||||
|
||||
// TEST
|
||||
CGrannyModelInstance** m_ppkSkeletonInst;
|
||||
// END_OF_TEST
|
||||
#ifdef _TEST
|
||||
D3DXMATRIX TEST_matWorld;
|
||||
#endif
|
||||
public:
|
||||
bool HaveBlendThing() { return m_pModel->HaveBlendThing(); }
|
||||
};
|
267
src/EterGrnLib/ModelInstanceCollisionDetection.cpp
Normal file
267
src/EterGrnLib/ModelInstanceCollisionDetection.cpp
Normal file
@ -0,0 +1,267 @@
|
||||
#include "Stdafx.h"
|
||||
#include "ModelInstance.h"
|
||||
#include "Model.h"
|
||||
|
||||
void CGrannyModelInstance::MakeBoundBox(TBoundBox* pBoundBox,
|
||||
const float* mat,
|
||||
const float* OBBMin,
|
||||
const float* OBBMax,
|
||||
D3DXVECTOR3* vtMin,
|
||||
D3DXVECTOR3* vtMax)
|
||||
{
|
||||
pBoundBox->sx = OBBMin[0] * mat[0] + OBBMin[1] * mat[4] + OBBMin[2] * mat[8] + mat[12];
|
||||
pBoundBox->sy = OBBMin[0] * mat[1] + OBBMin[1] * mat[5] + OBBMin[2] * mat[9] + mat[13];
|
||||
pBoundBox->sz = OBBMin[0] * mat[2] + OBBMin[1] * mat[6] + OBBMin[2] * mat[10] + mat[14];
|
||||
|
||||
pBoundBox->ex = OBBMax[0] * mat[0] + OBBMax[1] * mat[4] + OBBMax[2] * mat[8] + mat[12];
|
||||
pBoundBox->ey = OBBMax[0] * mat[1] + OBBMax[1] * mat[5] + OBBMax[2] * mat[9] + mat[13];
|
||||
pBoundBox->ez = OBBMax[0] * mat[2] + OBBMax[1] * mat[6] + OBBMax[2] * mat[10] + mat[14];
|
||||
|
||||
vtMin->x = min(vtMin->x, pBoundBox->sx);
|
||||
vtMin->x = min(vtMin->x, pBoundBox->ex);
|
||||
vtMin->y = min(vtMin->y, pBoundBox->sy);
|
||||
vtMin->y = min(vtMin->y, pBoundBox->ey);
|
||||
vtMin->z = min(vtMin->z, pBoundBox->sz);
|
||||
vtMin->z = min(vtMin->z, pBoundBox->ez);
|
||||
|
||||
vtMax->x = max(vtMax->x, pBoundBox->sx);
|
||||
vtMax->x = max(vtMax->x, pBoundBox->ex);
|
||||
vtMax->y = max(vtMax->y, pBoundBox->sy);
|
||||
vtMax->y = max(vtMax->y, pBoundBox->ey);
|
||||
vtMax->z = max(vtMax->z, pBoundBox->sz);
|
||||
vtMax->z = max(vtMax->z, pBoundBox->ez);
|
||||
}
|
||||
|
||||
bool CGrannyModelInstance::Intersect(const D3DXMATRIX * c_pMatrix,
|
||||
float * /*pu*/, float * /*pv*/, float * pt)
|
||||
{
|
||||
if (!m_pgrnModelInstance)
|
||||
return false;
|
||||
|
||||
float u, v, t;
|
||||
bool ret = false;
|
||||
*pt = 100000000.0f;
|
||||
|
||||
float max = 10000000.0f;
|
||||
D3DXVECTOR3 vtMin, vtMax;
|
||||
vtMin.x = vtMin.y = vtMin.z = max;
|
||||
vtMax.x = vtMax.y = vtMax.z = -max;
|
||||
|
||||
static stl_stack_pool<TBoundBox> s_boundBoxPool(1024);
|
||||
s_boundBoxPool.clear();
|
||||
|
||||
int meshCount = m_pModel->GetMeshCount();
|
||||
|
||||
for (int m = 0; m < meshCount; ++m)
|
||||
{
|
||||
//const CGrannyMesh * pMesh = m_pModel->GetMeshPointer(m);
|
||||
const granny_mesh * pgrnMesh = m_pModel->GetGrannyModelPointer()->MeshBindings[m].Mesh;
|
||||
|
||||
for (int b = 0; b < pgrnMesh->BoneBindingCount; ++b)
|
||||
{
|
||||
const granny_bone_binding& rgrnBoneBinding = pgrnMesh->BoneBindings[b];
|
||||
|
||||
TBoundBox * pBoundBox = s_boundBoxPool.alloc();
|
||||
|
||||
// WORK
|
||||
float * Transform = GrannyGetWorldPose4x4(__GetWorldPosePtr(), __GetMeshBoneIndices(m)[b]);
|
||||
// END_OF_WORK
|
||||
|
||||
MakeBoundBox(pBoundBox,
|
||||
Transform,
|
||||
rgrnBoneBinding.OBBMin,
|
||||
rgrnBoneBinding.OBBMax,
|
||||
&vtMin,
|
||||
&vtMax);
|
||||
|
||||
pBoundBox->meshIndex = m;
|
||||
pBoundBox->boneIndex = b;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IntersectCube(c_pMatrix,
|
||||
vtMin.x, vtMin.y, vtMin.z,
|
||||
vtMax.x, vtMax.y, vtMax.z,
|
||||
ms_vtPickRayOrig, ms_vtPickRayDir,
|
||||
&u, &v, &t))
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
/*
|
||||
TBoundBox* boundBoxs = s_boundBoxPool.base();
|
||||
for (int i = 0; i < s_boundBoxPool.size(); ++i)
|
||||
{
|
||||
TBoundBox& rcurBoundBox=boundBoxs[i];
|
||||
|
||||
if (!IntersectBoundBox(c_pMatrix, rcurBoundBox, &u, &v, &t))
|
||||
continue;
|
||||
|
||||
granny_matrix_4x4* pgrnMatCompositeBuffer = GrannyGetWorldPoseComposite4x4Array(m_pgrnWorldPose);
|
||||
const CGrannyMesh* c_pMesh = m_pModel->GetMeshPointer(rcurBoundBox.meshIndex);
|
||||
const granny_mesh* c_pgrnMesh = c_pMesh->GetGrannyMeshPointer();
|
||||
|
||||
if (!GrannyMeshIsRigid(c_pgrnMesh))
|
||||
{
|
||||
//continue;
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DXMATRIX matMesh;
|
||||
int* toBoneIndices = c_pMesh->GetBoneIndices();
|
||||
D3DXMatrixMultiply(&matMesh, (D3DXMATRIX*) pgrnMatCompositeBuffer[toBoneIndices[0]], c_pMatrix);
|
||||
|
||||
granny_tri_material_group* pgrnTriGroups = GrannyGetMeshTriangleGroups(c_pgrnMesh);
|
||||
int mtrlCount = c_pMesh->GetGrannyMeshPointer()->MaterialBindingCount;
|
||||
int vtxCount = GrannyGetMeshVertexCount(c_pgrnMesh);
|
||||
int groupCount = GrannyGetMeshTriangleGroupCount(c_pgrnMesh);
|
||||
|
||||
TIndex* modelIndices;
|
||||
TPNTVertex* modelVertices;
|
||||
|
||||
if (m_pModel->LockVertices((void**)&modelIndices, (void**)&modelVertices))
|
||||
{
|
||||
TIndex* meshIndices = modelIndices + c_pMesh->GetIndexBasePosition();
|
||||
TPNTVertex* meshVertices = modelVertices + c_pMesh->GetVertexBasePosition();
|
||||
|
||||
for (int i = 0; i < groupCount; ++i)
|
||||
{
|
||||
granny_tri_material_group& rgrnTriGroup = pgrnTriGroups[i];
|
||||
|
||||
if (rgrnTriGroup.MaterialIndex < 0 || rgrnTriGroup.MaterialIndex >= mtrlCount)
|
||||
continue;
|
||||
|
||||
if (IntersectMesh(&matMesh,
|
||||
meshVertices,
|
||||
sizeof(TPNTVertex),
|
||||
vtxCount,
|
||||
meshIndices,
|
||||
GrannyGetMeshIndexCount(c_pgrnMesh),
|
||||
ms_vtPickRayOrig,
|
||||
ms_vtPickRayDir,
|
||||
&u, &v, &t))
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_pModel->UnlockVertices();
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
*pu = u;
|
||||
*pv = v;
|
||||
*pt = -t;
|
||||
|
||||
if (c_szModelName)
|
||||
{
|
||||
if (!strncmp(c_pgrnMesh->Name, c_szModelName, strlen(c_szModelName)))
|
||||
return ret;
|
||||
|
||||
ret = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return (ret);
|
||||
*/
|
||||
}
|
||||
|
||||
#include "../EterBase/Timer.h"
|
||||
|
||||
void CGrannyModelInstance::GetBoundBox(D3DXVECTOR3* vtMin, D3DXVECTOR3* vtMax)
|
||||
{
|
||||
if (!m_pgrnModelInstance)
|
||||
return;
|
||||
|
||||
TBoundBox BoundBox;
|
||||
|
||||
vtMin->x = vtMin->y = vtMin->z = +100000.0f;
|
||||
vtMax->x = vtMax->y = vtMax->z = -100000.0f;
|
||||
|
||||
int meshCount = m_pModel->GetMeshCount();
|
||||
for (int m = 0; m < meshCount; ++m)
|
||||
{
|
||||
//const CGrannyMesh* pMesh = m_pModel->GetMeshPointer(m);
|
||||
const granny_mesh* pgrnMesh = m_pModel->GetGrannyModelPointer()->MeshBindings[m].Mesh;
|
||||
|
||||
// WORK
|
||||
int* boneIndices = __GetMeshBoneIndices(m);
|
||||
// END_OF_WORK
|
||||
for (int b = 0; b < pgrnMesh->BoneBindingCount; ++b)
|
||||
{
|
||||
const granny_bone_binding& rgrnBoneBinding = pgrnMesh->BoneBindings[b];
|
||||
|
||||
MakeBoundBox(&BoundBox,
|
||||
GrannyGetWorldPose4x4(__GetWorldPosePtr(), boneIndices[b]),
|
||||
rgrnBoneBinding.OBBMin, rgrnBoneBinding.OBBMax, vtMin, vtMax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CGrannyModelInstance::GetMeshMatrixPointer(int iMesh, const D3DXMATRIX ** c_ppMatrix) const
|
||||
{
|
||||
if (!m_pgrnModelInstance)
|
||||
return false;
|
||||
|
||||
int meshCount = m_pModel->GetMeshCount();
|
||||
|
||||
if (meshCount <= 0)
|
||||
return false;
|
||||
|
||||
// WORK
|
||||
//const CGrannyMesh * pMesh = m_pModel->GetMeshPointer(iMesh);
|
||||
*c_ppMatrix = (D3DXMATRIX *)GrannyGetWorldPose4x4(__GetWorldPosePtr(), __GetMeshBoneIndices(iMesh)[0]);
|
||||
// END_OF_WORK
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
void CGraphicThingInstance::DrawBoundBox()
|
||||
{
|
||||
if (!mc_pMeshVector)
|
||||
return;
|
||||
|
||||
if (!m_pgrnWorldPose)
|
||||
return;
|
||||
|
||||
D3DXVECTOR3 vtMin;
|
||||
D3DXVECTOR3 vtMax;
|
||||
|
||||
SetDiffuseColor(0.0f, 1.0f, 0.0f);
|
||||
// ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٿ<EFBFBD><D9BF><EFBFBD> <20>ڽ<EFBFBD>
|
||||
//GetBoundBox(&vtMin, &vtMax);
|
||||
//DrawLineCube(vtMin.x, vtMin.y, vtMin.z, vtMax.x, vtMax.y, vtMax.z);
|
||||
//const CThing::TMeshVector& rmeshVector=mc_pModel->meshVector;
|
||||
ms_lpd3dMatStack->LoadMatrix(&m_Matrix);
|
||||
|
||||
for (size_t m=0; m<mc_pMeshVector->size(); ++m)
|
||||
{
|
||||
const CThing::TMesh& rmesh=mc_pMeshVector->at(m);
|
||||
|
||||
for (int b=0; b<rmesh.pgrnMesh->BoneBindingCount; ++b)
|
||||
{
|
||||
granny_bone_binding& rgrnBoneBinding=rmesh.pgrnMesh->BoneBindings[b];
|
||||
|
||||
int* toBoneIndices=GrannyGetMeshBindingToBoneIndices(rmesh.pgrnMeshBinding);
|
||||
|
||||
D3DXMATRIX* pmat=(D3DXMATRIX*)GrannyGetWorldPose4x4(m_pgrnWorldPose, toBoneIndices[b]);
|
||||
|
||||
D3DXVec3TransformCoord(&vtMin, &D3DXVECTOR3(rgrnBoneBinding.OBBMin), pmat);
|
||||
D3DXVec3TransformCoord(&vtMax, &D3DXVECTOR3(rgrnBoneBinding.OBBMax), pmat);
|
||||
|
||||
DrawLineCube(vtMin.x, vtMin.y, vtMin.z, vtMax.x, vtMax.y, vtMax.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user