Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
275
Engine/Caldron/Caldron.vcproj
Normal file
275
Engine/Caldron/Caldron.vcproj
Normal file
@@ -0,0 +1,275 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="Caldron"
|
||||
ProjectGUID="{F65430A6-D6C5-4EDA-A035-6E9B615E434B}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../Client/CharacterActionControl/;"../Zalla3D Base Class";../Effect;./;"../Zalla3D Scene Class";../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Caldron.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../Client/CharacterActionControl/;"../Zalla3D Base Class";../Effect;./;"../Zalla3D Scene Class";../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Caldron.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_NoGD|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../Client/CharacterActionControl/;"../Zalla3D Base Class";../Effect;./;"../Zalla3D Scene Class";../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Caldron.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../../Client/CharacterActionControl/;"../Zalla3D Base Class";../Effect;./;"../Zalla3D Scene Class";../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Caldron.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../../Client/CharacterActionControl/;"../Zalla3D Base Class";../Effect;./;"../Zalla3D Scene Class";../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Caldron.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="<22>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\Src\Base\BaseCacheMgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\Caldron.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\CaldronByteDataObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Scene\D3DBufferPools.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\LoadedObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\ResourceLoader.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\Src\Base\BaseCacheMgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\CaldronByteDataObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Scene\D3DBufferPools.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\LoadedObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\ResourceLoader.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Base\ThreadQueue.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
203
Engine/Caldron/Caldron.vcxproj
Normal file
203
Engine/Caldron/Caldron.vcxproj
Normal file
@@ -0,0 +1,203 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug_MY|Win32">
|
||||
<Configuration>Debug_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_MY|Win32">
|
||||
<Configuration>Release_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_NoGD|Win32">
|
||||
<Configuration>Release_NoGD</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{F65430A6-D6C5-4EDA-A035-6E9B615E434B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</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" />
|
||||
</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" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../../Client/CharacterActionControl/;../Zalla3D Base Class;../Effect;./;../Zalla3D Scene Class;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Caldron.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../../Client/CharacterActionControl/;../Zalla3D Base Class;../Effect;./;../Zalla3D Scene Class;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Caldron.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../../Client/CharacterActionControl/;../Zalla3D Base Class;../Effect;./;../Zalla3D Scene Class;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Caldron.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../../Client/CharacterActionControl/;../Zalla3D Base Class;../Effect;./;../Zalla3D Scene Class;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Caldron.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../../Client/CharacterActionControl/;../Zalla3D Base Class;../Effect;./;../Zalla3D Scene Class;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Caldron.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Src\Base\BaseCacheMgr.cpp" />
|
||||
<ClCompile Include="Src\Base\Caldron.cpp" />
|
||||
<ClCompile Include="Src\Base\CaldronByteDataObj.cpp" />
|
||||
<ClCompile Include="Src\Scene\D3DBufferPools.cpp" />
|
||||
<ClCompile Include="Src\Base\LoadedObj.cpp" />
|
||||
<ClCompile Include="Src\Base\ResourceLoader.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Src\Base\BaseCacheMgr.h" />
|
||||
<ClInclude Include="Src\Base\CaldronByteDataObj.h" />
|
||||
<ClInclude Include="Src\Scene\D3DBufferPools.h" />
|
||||
<ClInclude Include="Src\Base\LoadedObj.h" />
|
||||
<ClInclude Include="Src\Base\ResourceLoader.h" />
|
||||
<ClInclude Include="Src\Base\ThreadQueue.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MemoryManager\MemoryManager.vcxproj">
|
||||
<Project>{b6bdd524-1dde-4a65-aed7-9ee4bc86a05d}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
60
Engine/Caldron/Caldron.vcxproj.filters
Normal file
60
Engine/Caldron/Caldron.vcxproj.filters
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="소스 파일">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="헤더 파일">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="리소스 파일">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Src\Base\BaseCacheMgr.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\Base\Caldron.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\Base\CaldronByteDataObj.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\Scene\D3DBufferPools.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\Base\LoadedObj.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\Base\ResourceLoader.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Src\Base\BaseCacheMgr.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\Base\CaldronByteDataObj.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\Scene\D3DBufferPools.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\Base\LoadedObj.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\Base\ResourceLoader.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Src\Base\ThreadQueue.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
265
Engine/Caldron/Include/Caldron.h
Normal file
265
Engine/Caldron/Include/Caldron.h
Normal file
@@ -0,0 +1,265 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* Caldron Engine <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine <20><> <20>̿<EFBFBD><CCBF>ϴ°<CFB4><C2B0><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰԵǴ<D4B5> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD>: 2003.10.23
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD>: yundi ( 2003.10.23)
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#pragma once
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4251)
|
||||
#pragma warning(disable:4503)
|
||||
|
||||
#include <algorithm>
|
||||
//#include <d3d9.h>
|
||||
#include <d3dx8.h>
|
||||
#include <tchar.h>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <math.h>
|
||||
#include <process.h>
|
||||
#include <mmsystem.h>
|
||||
//#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
// epsilon <20><><EFBFBD><EFBFBD>
|
||||
extern const float MIN_EPSILON;
|
||||
extern const float MAX_EPSILON;
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
const float FLOAT_RAD = 0.0174532925f; // radian <20><>
|
||||
extern const float FLOAT_PI; // pi
|
||||
extern const float FLOAT_2PI;
|
||||
extern const float FLOAT_PI2;
|
||||
|
||||
extern const int MAX_STRINGSIZE;
|
||||
const int MAX_RELOADING = 3; // Resource Loader <20><><EFBFBD><EFBFBD> Object <20>ε<EFBFBD> <20><><EFBFBD>н<EFBFBD> <20>ִ<EFBFBD> Reloading <20>õ<EFBFBD> Ƚ<><C8BD>
|
||||
|
||||
#define FLOAT_TO_INT(fValue) (*(int *)&(fValue))
|
||||
#define IS_SIGNBIT(fValue) (FLOAT_TO_INT(fValue) & 0x80000000)
|
||||
#define FRAND (((rand()%10000)-5000)/5000.0f)
|
||||
|
||||
// template function <20><><EFBFBD><EFBFBD>
|
||||
template<class _T>
|
||||
inline void SafeDelete( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class _T>
|
||||
inline void SafeDeleteA( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete[] (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class _T>
|
||||
inline void SafeRelease( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
ptr->Release();
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline bool Succeeded( HRESULT hr )
|
||||
{
|
||||
return (hr >= 0);
|
||||
}
|
||||
|
||||
inline bool Failed( HRESULT hr )
|
||||
{
|
||||
return (hr < 0);
|
||||
}
|
||||
|
||||
inline bool IsZero(float fValue)
|
||||
{
|
||||
if((fValue > -(MIN_EPSILON)) && (fValue < MIN_EPSILON))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
inline float Def2Rad( float fDeg )
|
||||
{
|
||||
return fDeg*FLOAT_PI/180;
|
||||
}
|
||||
|
||||
// CProfileMgr <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
inline void ProfileGetTicks(_int64 * ticks)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
push edx;
|
||||
push ecx;
|
||||
mov ecx,ticks;
|
||||
_emit 0Fh
|
||||
_emit 31h
|
||||
mov [ecx],eax;
|
||||
mov [ecx+4],edx;
|
||||
pop ecx;
|
||||
pop edx;
|
||||
}
|
||||
}
|
||||
|
||||
inline float ProfileGetTickRate(void)
|
||||
{
|
||||
static float _CPUFrequency = -1.0f;
|
||||
|
||||
if (_CPUFrequency == -1.0f) {
|
||||
__int64 curr_rate = 0;
|
||||
::QueryPerformanceFrequency ((LARGE_INTEGER *)&curr_rate);
|
||||
_CPUFrequency = (float)curr_rate;
|
||||
}
|
||||
|
||||
return _CPUFrequency;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CBitset
|
||||
* <20><><EFBFBD><EFBFBD> : Bitset.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> Bitset Class
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2003.10.24
|
||||
* History : wizardbug ( 2003.10.24)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
class CBitset {
|
||||
protected:
|
||||
|
||||
unsigned int *m_pBits; // Bit Set ptr
|
||||
int m_iBitSize; // Bit Set Size
|
||||
|
||||
public:
|
||||
CBitset() {
|
||||
m_pBits = NULL;
|
||||
m_iBitSize = 0;
|
||||
}
|
||||
~CBitset() {
|
||||
if(m_pBits)
|
||||
{
|
||||
delete[] m_pBits;
|
||||
m_pBits = NULL;
|
||||
}
|
||||
}
|
||||
void ResizeBits(int iNewCount) {
|
||||
|
||||
m_iBitSize = iNewCount / 32 + 1; // Get Inteager Size
|
||||
if(m_pBits) {
|
||||
delete[] m_pBits;
|
||||
m_pBits = NULL;
|
||||
}
|
||||
m_pBits = new unsigned int[m_iBitSize]; // Allocate Bits
|
||||
ClearBits();
|
||||
|
||||
}
|
||||
void ClearBits() { // Clear All Bits
|
||||
memset(m_pBits,0,sizeof(unsigned int) * m_iBitSize);
|
||||
|
||||
}
|
||||
void ClearOneBit(int index) {
|
||||
|
||||
m_pBits[ index >> 5 ] &= ~( 1 << ( index & 31 ) );
|
||||
}
|
||||
void SetBit(int index) { // Set Bit
|
||||
m_pBits[ index >> 5 ] |= ( 1 << ( index & 31 ) );
|
||||
|
||||
}
|
||||
bool GetBit(int index) { // Return Bit's Setting : return true or false
|
||||
|
||||
return (m_pBits[ index >> 5 ] & ( 1 << (index & 31 ) )) ? true : false;
|
||||
|
||||
}
|
||||
};
|
||||
/********************************************************************** */
|
||||
template <class _T>
|
||||
class CUpdateCounter
|
||||
{
|
||||
public :
|
||||
CUpdateCounter(int n, int range=1)
|
||||
{
|
||||
m_cnt = new _T [n];
|
||||
m_cnt_num = n;
|
||||
|
||||
m_mask = range - 1;
|
||||
m_current = 0;
|
||||
|
||||
m_step = m_cnt_num / ((1<<(8*sizeof(_T))) / range - 1) + 1;
|
||||
m_clear = 0;
|
||||
|
||||
memset(m_cnt, 0, sizeof(_T) * m_cnt_num);
|
||||
|
||||
Clear();
|
||||
}
|
||||
|
||||
~CUpdateCounter()
|
||||
{
|
||||
delete [] m_cnt;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
ClearBlock();
|
||||
|
||||
m_current += (m_mask+1);
|
||||
}
|
||||
|
||||
void Update(int cnt, int v=0) {
|
||||
m_cnt[cnt] = m_current + v;
|
||||
}
|
||||
|
||||
int GetValue(int cnt) {
|
||||
return m_cnt[cnt] - m_current;
|
||||
}
|
||||
|
||||
bool IsUpdated(int cnt) {
|
||||
return (_T)(m_cnt[cnt] - m_current) <= m_mask ? true : false; }
|
||||
|
||||
private :
|
||||
void ClearBlock()
|
||||
{
|
||||
int len = m_cnt_num - m_clear > m_step ? m_step : m_cnt_num - m_clear, i;
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
m_cnt[m_clear] = m_current;
|
||||
|
||||
for(i=1; i<len; i+=i)
|
||||
memcpy(&m_cnt[m_clear+i], &m_cnt[m_clear], (len-i > i ? i : len-i) * sizeof(*m_cnt));
|
||||
}
|
||||
|
||||
m_clear = m_clear + len >= m_cnt_num ? 0 : m_clear + len;
|
||||
}
|
||||
|
||||
_T * m_cnt, m_current, m_mask;
|
||||
int m_cnt_num, m_step, m_clear;
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
}
|
||||
21
Engine/Caldron/ReadMe.txt
Normal file
21
Engine/Caldron/ReadMe.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
========================================================================
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺귯<CCBA><EAB7AF> : Caldron <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
========================================================================
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><> Caldron <20><><EFBFBD>̺귯<CCBA><EAB7AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.
|
||||
|
||||
|
||||
Caldron.vcproj
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>縦 <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC++ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>⺻ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
<20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Visual C++<2B><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>ɿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
<EFBFBD><EFBFBD>Ÿ <20><><EFBFBD><EFBFBD>:
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> "TODO:" <20>ּ<EFBFBD><D6BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD> <20>߰<EFBFBD><DFB0>ϰų<CFB0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>ϴ<EFBFBD>
|
||||
<EFBFBD>ҽ<EFBFBD> <20>ڵ<EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
60
Engine/Caldron/Src/Base/BaseCacheMgr.cpp
Normal file
60
Engine/Caldron/Src/Base/BaseCacheMgr.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* CBaseCacheMgr , CCacheObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : BaseCacheMgr.cpp
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron<6F><6E><EFBFBD><EFBFBD> <20><><EFBFBD>ο<EFBFBD><CEBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD> CacheMgr<67><72><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> class
|
||||
* history :
|
||||
2004.01.16 wizardbug
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#include "BaseCacheMgr.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
namespace Caldron {namespace Base {
|
||||
/*template < class T >
|
||||
T *CBaseCacheMgr<T>::LoadData(const char *strFileName)
|
||||
{
|
||||
T *pNode = new T;
|
||||
strcpy(pNode->m_strName,strFileName);
|
||||
CSceneManager::m_pNewMeshObjectContainer->AddObj(Base::CResourceLoaderObj(strFileName,pNode));
|
||||
|
||||
unsigned long DataID = GetHashID(strFileName);
|
||||
Base::CACHEITER itr = m_CacheTable.find(DataID);
|
||||
|
||||
if(itr == m_CacheTable.end())
|
||||
{
|
||||
|
||||
Base::CCacheObj *pObj = new Base::CCacheObj(pNode);
|
||||
|
||||
m_CacheTable.insert(Base::CACHETABLEOBJ(DataID,pObj));
|
||||
m_iCachesNum++;
|
||||
}
|
||||
else
|
||||
{// map <20>ȿ<EFBFBD> <20>Ȱ<EFBFBD><C8B0><EFBFBD> Hash Index <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
((*itr).second)->Add_Back(pNode);
|
||||
}
|
||||
|
||||
return pNode;
|
||||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
template < class T >
|
||||
unsigned long CBaseCacheMgr<T>::GetHashID(const char *strFileName)
|
||||
{
|
||||
unsigned long ulHashId = 0;
|
||||
|
||||
int iLength = (int)strlen(strFileName);
|
||||
|
||||
for(int i=0;i < iLength; i++) {
|
||||
ulHashId += (( i + 1) * strFileName[i]);
|
||||
}
|
||||
return ulHashId;
|
||||
|
||||
}
|
||||
*/
|
||||
}}
|
||||
264
Engine/Caldron/Src/Base/BaseCacheMgr.h
Normal file
264
Engine/Caldron/Src/Base/BaseCacheMgr.h
Normal file
@@ -0,0 +1,264 @@
|
||||
|
||||
#if !defined(AFX_BASECACHEMGR_H__C53D076B_14CF_47B5_B21C_F7EF3477C7EA__INCLUDED_)
|
||||
#define AFX_BASECACHEMGR_H__C53D076B_14CF_47B5_B21C_F7EF3477C7EA__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#pragma warning( disable : 4786 )
|
||||
#include "../../include/Caldron.h"
|
||||
#include "./LoadedObj.h"
|
||||
#include "./ResourceLoader.h"
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
/* *********************************************************************
|
||||
|
||||
* CCacheObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : BaseCacheMgr.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron<6F><6E><EFBFBD><EFBFBD> <20><><EFBFBD>ο<EFBFBD><CEBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> CacheMgr<67><72><EFBFBD><EFBFBD> data <20><> <20>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* history :
|
||||
2004.01.16 wizardbug
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
class CCacheObj {
|
||||
public:
|
||||
std::vector<CLoadedObj *> m_lstDatas;
|
||||
int m_iDatasNum;
|
||||
CCacheObj() : m_iDatasNum(0)
|
||||
{
|
||||
m_lstDatas.clear();
|
||||
}
|
||||
CCacheObj(CLoadedObj *pObj) : m_iDatasNum(0)
|
||||
{
|
||||
m_lstDatas.clear();
|
||||
m_lstDatas.push_back(pObj);
|
||||
pObj->m_iReferenceCount++;
|
||||
m_iDatasNum++;
|
||||
}
|
||||
void Add_Back(CLoadedObj *pObj)
|
||||
{
|
||||
m_lstDatas.push_back(pObj);
|
||||
pObj->m_iReferenceCount++;
|
||||
m_iDatasNum++;
|
||||
}
|
||||
void Remove(int iNum)
|
||||
{
|
||||
if(m_iDatasNum <= iNum)
|
||||
return;
|
||||
if(m_lstDatas[iNum] && m_lstDatas[iNum]->m_bLoaded)
|
||||
{
|
||||
if(!(--m_lstDatas[iNum]->m_iReferenceCount))
|
||||
{
|
||||
SafeDelete(m_lstDatas[iNum]);
|
||||
m_lstDatas.erase(m_lstDatas.begin() + iNum);
|
||||
m_iDatasNum--;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void AddRef(int iNum)
|
||||
{
|
||||
if(m_iDatasNum <= iNum)
|
||||
return;
|
||||
if(m_lstDatas[iNum])
|
||||
{
|
||||
m_lstDatas[iNum]->m_iReferenceCount++;
|
||||
}
|
||||
}
|
||||
~CCacheObj() {
|
||||
if(m_iDatasNum > 0)
|
||||
{
|
||||
for(int i=0;i < m_iDatasNum; i++)
|
||||
{
|
||||
if(m_lstDatas[i])
|
||||
{
|
||||
SafeDelete(m_lstDatas[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
m_iDatasNum = 0;
|
||||
m_lstDatas.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
typedef std::map<unsigned long , CCacheObj *> CACHETABLE;
|
||||
typedef CACHETABLE::value_type CACHETABLEOBJ;
|
||||
typedef CACHETABLE::iterator CACHEITER;
|
||||
/* *********************************************************************
|
||||
|
||||
* CBaseCacheMgr
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : BaseCacheMgr.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron<6F><6E><EFBFBD><EFBFBD> <20><><EFBFBD>ο<EFBFBD><CEBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> <20><><EFBFBD><EFBFBD> CacheMgr<67><72><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> class
|
||||
* history :
|
||||
2004.01.16 wizardbug
|
||||
|
||||
********************************************************************** */
|
||||
const int DEFAULT_MAXCACHENUM = 100;
|
||||
template <class T>
|
||||
class CBaseCacheMgr
|
||||
{
|
||||
protected:
|
||||
|
||||
unsigned long GetHashID(const char *strFileName)
|
||||
{
|
||||
unsigned long ulHashId = 0;
|
||||
|
||||
int iLength = (int)strlen(strFileName);
|
||||
|
||||
for(int i=0;i < iLength; i++) {
|
||||
ulHashId += (( i + 1) * strFileName[i]);
|
||||
}
|
||||
return ulHashId;
|
||||
|
||||
|
||||
}
|
||||
|
||||
CACHETABLE m_CacheTable;
|
||||
int m_iCachesNum;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
CBaseCacheMgr(): m_iCachesNum(0)
|
||||
{
|
||||
m_CacheTable.clear();
|
||||
}
|
||||
virtual ~CBaseCacheMgr()
|
||||
{
|
||||
//if(m_iCachesNum > 0)
|
||||
//{
|
||||
for(CACHEITER Itr = m_CacheTable.begin(); Itr != m_CacheTable.end();)
|
||||
{
|
||||
if(Itr->second != NULL)
|
||||
{
|
||||
SafeDelete(Itr->second);
|
||||
}
|
||||
|
||||
Itr++;
|
||||
}
|
||||
m_CacheTable.clear();
|
||||
m_iCachesNum = 0;
|
||||
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
void DeleteAllData()
|
||||
{
|
||||
// if(m_iCachesNum > 0)
|
||||
// {
|
||||
for(CACHEITER Itr = m_CacheTable.begin(); Itr != m_CacheTable.end();)
|
||||
{
|
||||
if(Itr->second != NULL)
|
||||
{
|
||||
SafeDelete(Itr->second);
|
||||
}
|
||||
|
||||
Itr++;
|
||||
}
|
||||
m_CacheTable.clear();
|
||||
m_iCachesNum = 0;
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
void DeleteData(const char *strFileName)
|
||||
{
|
||||
|
||||
unsigned long DataID = GetHashID(strFileName);
|
||||
|
||||
Base::CACHEITER itr = m_CacheTable.find(DataID);
|
||||
|
||||
if(itr != m_CacheTable.end())
|
||||
{
|
||||
if((*itr).second != NULL)
|
||||
{
|
||||
for(int iNum = 0; iNum < (*itr).second->m_iDatasNum; iNum++)
|
||||
{
|
||||
if(!strcmp((*itr).second->m_lstDatas[iNum]->m_strName,strFileName))
|
||||
{
|
||||
((*itr).second)->Remove(iNum);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
T *GetData(const char *strFileName)
|
||||
{
|
||||
unsigned long DataID = GetHashID(strFileName);
|
||||
|
||||
Base::CACHEITER itr = m_CacheTable.find(DataID);
|
||||
|
||||
if(itr == m_CacheTable.end())
|
||||
{
|
||||
return LoadData(strFileName);
|
||||
}
|
||||
else // Table <20>ȿ<EFBFBD> <20>̹<EFBFBD> texture <20><> <20>ε<EFBFBD><CEB5>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
if((*itr).second != NULL)
|
||||
{
|
||||
for(int iNum = 0; iNum < (*itr).second->m_iDatasNum; iNum++)
|
||||
{
|
||||
if(!strcmp((*itr).second->m_lstDatas[iNum]->m_strName,strFileName))
|
||||
{
|
||||
(*itr).second->AddRef(iNum);
|
||||
return (T *)((*itr).second->m_lstDatas[iNum]);
|
||||
}
|
||||
}
|
||||
return LoadData(strFileName); // Table <20><> obj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϴ<EFBFBD> obj <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
|
||||
}
|
||||
T *LoadData(const char *strFileName)
|
||||
{
|
||||
T *pNode = new T;
|
||||
strcpy(pNode->m_strName,strFileName);
|
||||
CResourceLoader::AddObj(pNode);
|
||||
|
||||
unsigned long DataID = GetHashID(strFileName);
|
||||
Base::CACHEITER itr = m_CacheTable.find(DataID);
|
||||
|
||||
if(itr == m_CacheTable.end())
|
||||
{
|
||||
|
||||
Base::CCacheObj *pObj = new Base::CCacheObj(pNode);
|
||||
m_CacheTable.insert(Base::CACHETABLEOBJ(DataID,pObj));
|
||||
m_iCachesNum++;
|
||||
}
|
||||
else
|
||||
{// map <20>ȿ<EFBFBD> <20>Ȱ<EFBFBD><C8B0><EFBFBD> Hash Index <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
((*itr).second)->Add_Back(pNode);
|
||||
}
|
||||
|
||||
|
||||
return pNode;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// virtual void *GetData(const char *strFileName) = 0;
|
||||
// virtual void *LoadData(const char *strFileName) = 0;
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // !defined(AFX_BASECACHEMGR_H__C53D076B_14CF_47B5_B21C_F7EF3477C7EA__INCLUDED_)
|
||||
124
Engine/Caldron/Src/Base/ByteDataObj.cpp
Normal file
124
Engine/Caldron/Src/Base/ByteDataObj.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CByteDataObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ByteDataObj.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceMgr <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>̴<EFBFBD> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20>⺻ <20><><EFBFBD><EFBFBD>.
|
||||
CLoadedObj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> obj <20><><EFBFBD><EFBFBD> Load <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD> <20>˸<EFBFBD><CBB8><EFBFBD> <20><><EFBFBD>·<EFBFBD> <20><>ȯ <20>ε<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
#include "ByteDataObj.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CByteDataObj::CByteDataObj()
|
||||
{
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
|
||||
CByteDataObj::~CByteDataObj()
|
||||
{
|
||||
if(m_pBytes)
|
||||
{
|
||||
delete[] m_pBytes;
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
}
|
||||
unsigned char *CByteDataObj::GetReadPtr()
|
||||
{
|
||||
if((m_lReadPos >= m_lSize) || (m_pBytes == NULL))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_pBytes[m_lReadPos]);
|
||||
|
||||
}
|
||||
bool CByteDataObj::LoadByte(char *strFileName,long lOffset)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
long lFileSize = 0;
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,0,SEEK_END);
|
||||
m_lSize = ftell(fp);
|
||||
if(m_lSize <= 0)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
// Offset <20><><EFBFBD><EFBFBD>
|
||||
if(m_lSize > lOffset)
|
||||
m_lSize -= lOffset;
|
||||
else
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
m_pBytes = new unsigned char[m_lSize];
|
||||
if(m_pBytes == NULL)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,lOffset,SEEK_SET);
|
||||
if(fread((unsigned char *)m_pBytes,sizeof(unsigned char),m_lSize,fp) != m_lSize)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
long CByteDataObj::Read(void *ptr,size_t UnitSize,int iNum)
|
||||
{
|
||||
if(ptr == NULL)
|
||||
return -1;
|
||||
long lCurrentReaded = ((long)(UnitSize) * iNum) / UINT_SIZE;
|
||||
if(m_lSize >= lCurrentReaded + m_lReadPos)
|
||||
{
|
||||
memcpy(ptr,&(m_pBytes[m_lReadPos]), (size_t)(UINT_SIZE * lCurrentReaded));
|
||||
m_lReadPos += lCurrentReaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
|
||||
}
|
||||
return m_lReadPos;
|
||||
|
||||
}
|
||||
}}
|
||||
55
Engine/Caldron/Src/Base/ByteDataObj.h
Normal file
55
Engine/Caldron/Src/Base/ByteDataObj.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// ByteDataObj.h: interface for the CByteDataObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_)
|
||||
#define AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
const long UINT_SIZE = (long)sizeof(unsigned char);
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CByteDataObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ByteDataObj.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceMgr <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>̴<EFBFBD> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20>⺻ <20><><EFBFBD><EFBFBD>.
|
||||
CLoadedObj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> obj <20><><EFBFBD><EFBFBD> Load <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD> <20>˸<EFBFBD><CBB8><EFBFBD> <20><><EFBFBD>·<EFBFBD> <20><>ȯ <20>ε<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
class CByteDataObj
|
||||
{
|
||||
public:
|
||||
CByteDataObj();
|
||||
virtual ~CByteDataObj();
|
||||
|
||||
bool LoadByte(char *strFileName,long lOffset = 0 );
|
||||
long GetByteSize() { return m_lSize; }
|
||||
long GetReadPos() { return m_lReadPos;}
|
||||
void SetReadPos(long lPos) { m_lReadPos = lPos;}
|
||||
unsigned char *GetReadPtr();
|
||||
long Read(void *ptr,size_t UnitSize,int iNum);
|
||||
|
||||
unsigned char *m_pBytes;
|
||||
long m_lSize;
|
||||
long m_lReadPos;
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // !defined(AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_)
|
||||
27
Engine/Caldron/Src/Base/Caldron.cpp
Normal file
27
Engine/Caldron/Src/Base/Caldron.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
/* *********************************************************************
|
||||
#include "GMMemory.h"
|
||||
|
||||
* Caldron Engine <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron namespace<63><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2003.10.23
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : yundi ( 2003.10.23)
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> :
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
//const float FLOAT_RAD = 0.0174532925f;
|
||||
extern const float FLOAT_PI2 = 1.57079632679f;
|
||||
extern const float FLOAT_PI = 3.14159265358979323846f;
|
||||
extern const float FLOAT_2PI = 6.28318530717958647692f;
|
||||
|
||||
extern const float MIN_EPSILON = 1.0e-4f;
|
||||
extern const float MAX_EPSILON = 1.0e+10f;
|
||||
extern const int MAX_STRINGSIZE = 40;
|
||||
// const int MAX_RELOADING = 3;
|
||||
|
||||
|
||||
}
|
||||
125
Engine/Caldron/Src/Base/CaldronByteDataObj.cpp
Normal file
125
Engine/Caldron/Src/Base/CaldronByteDataObj.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CByteDataObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ByteDataObj.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceMgr <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>̴<EFBFBD> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20>⺻ <20><><EFBFBD><EFBFBD>.
|
||||
CLoadedObj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> obj <20><><EFBFBD><EFBFBD> Load <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD> <20>˸<EFBFBD><CBB8><EFBFBD> <20><><EFBFBD>·<EFBFBD> <20><>ȯ <20>ε<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
#include "CaldronByteDataObj.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "GMMemory.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CCaldronByteDataObj::CCaldronByteDataObj()
|
||||
{
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
|
||||
CCaldronByteDataObj::~CCaldronByteDataObj()
|
||||
{
|
||||
if(m_pBytes)
|
||||
{
|
||||
delete[] m_pBytes;
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
}
|
||||
unsigned char *CCaldronByteDataObj::GetReadPtr()
|
||||
{
|
||||
if((m_lReadPos >= m_lSize) || (m_pBytes == NULL))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_pBytes[m_lReadPos]);
|
||||
|
||||
}
|
||||
bool CCaldronByteDataObj::LoadByte(char *strFileName,long lOffset)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
long lFileSize = 0;
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,0,SEEK_END);
|
||||
m_lSize = ftell(fp);
|
||||
if(m_lSize <= 0)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
// Offset <20><><EFBFBD><EFBFBD>
|
||||
if(m_lSize > lOffset)
|
||||
m_lSize -= lOffset;
|
||||
else
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
m_pBytes = new unsigned char[m_lSize];
|
||||
if(m_pBytes == NULL)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,lOffset,SEEK_SET);
|
||||
if(fread((unsigned char *)m_pBytes,sizeof(unsigned char),m_lSize,fp) != m_lSize)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
long CCaldronByteDataObj::Read(void *ptr,size_t UnitSize,int iNum)
|
||||
{
|
||||
if(ptr == NULL)
|
||||
return -1;
|
||||
long lCurrentReaded = ((long)(UnitSize) * iNum) / UINT_SIZE;
|
||||
if(m_lSize >= lCurrentReaded + m_lReadPos)
|
||||
{
|
||||
memcpy(ptr,&(m_pBytes[m_lReadPos]), (size_t)(UINT_SIZE * lCurrentReaded));
|
||||
m_lReadPos += lCurrentReaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
|
||||
}
|
||||
return m_lReadPos;
|
||||
|
||||
}
|
||||
}}
|
||||
55
Engine/Caldron/Src/Base/CaldronByteDataObj.h
Normal file
55
Engine/Caldron/Src/Base/CaldronByteDataObj.h
Normal file
@@ -0,0 +1,55 @@
|
||||
// ByteDataObj.h: interface for the CByteDataObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_)
|
||||
#define AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
const long UINT_SIZE = (long)sizeof(unsigned char);
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CByteDataObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ByteDataObj.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceMgr <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>̴<EFBFBD> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20>⺻ <20><><EFBFBD><EFBFBD>.
|
||||
CLoadedObj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> obj <20><><EFBFBD><EFBFBD> Load <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD> <20>˸<EFBFBD><CBB8><EFBFBD> <20><><EFBFBD>·<EFBFBD> <20><>ȯ <20>ε<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
class CCaldronByteDataObj
|
||||
{
|
||||
public:
|
||||
CCaldronByteDataObj();
|
||||
virtual ~CCaldronByteDataObj();
|
||||
|
||||
bool LoadByte(char *strFileName,long lOffset = 0 );
|
||||
long GetByteSize() { return m_lSize; }
|
||||
long GetReadPos() { return m_lReadPos;}
|
||||
void SetReadPos(long lPos) { m_lReadPos = lPos;}
|
||||
unsigned char *GetReadPtr();
|
||||
long Read(void *ptr,size_t UnitSize,int iNum);
|
||||
|
||||
unsigned char *m_pBytes;
|
||||
long m_lSize;
|
||||
long m_lReadPos;
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif // !defined(AFX_BYTEDATAOBJ_H__A71C88C6_A81A_4696_9922_802A8B1C119A__INCLUDED_)
|
||||
25
Engine/Caldron/Src/Base/LoadedObj.cpp
Normal file
25
Engine/Caldron/Src/Base/LoadedObj.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// LoadedObj.cpp: implementation of the CLoadedObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
#pragma warning( disable : 4786 )
|
||||
#include <include/Caldron.h>
|
||||
#include "./CaldronByteDataObj.h"
|
||||
#include "LoadedObj.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
namespace Caldron { namespace Base {
|
||||
CLoadedObj::CLoadedObj(const char *strFileName) : m_bLoaded(false),m_iReloadingCount(0),m_pByteDataObj(0)
|
||||
{
|
||||
strcpy(m_strName,strFileName);
|
||||
}
|
||||
CLoadedObj::~CLoadedObj()
|
||||
{
|
||||
SafeDelete(m_pByteDataObj);
|
||||
m_pByteDataObj = 0;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
54
Engine/Caldron/Src/Base/LoadedObj.h
Normal file
54
Engine/Caldron/Src/Base/LoadedObj.h
Normal file
@@ -0,0 +1,54 @@
|
||||
// LoadedObj.h: interface for the CLoadedObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_LOADEDOBJ_H__7BBE3A5F_6665_4F40_AA4D_82BACEBC32D3__INCLUDED_)
|
||||
#define AFX_LOADEDOBJ_H__7BBE3A5F_6665_4F40_AA4D_82BACEBC32D3__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
#include "./CaldronByteDataObj.h"
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CLoadedObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : LoadedObj.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceMgr <20><> <20>̿<EFBFBD><CCBF><EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ҽ<EFBFBD> obj <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> class
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
class CLoadedObj
|
||||
{
|
||||
public:
|
||||
CLoadedObj() : m_bLoaded(false),m_iReloadingCount(0),m_pByteDataObj(0),m_bFirst(0),m_iReferenceCount(0)
|
||||
{}
|
||||
CLoadedObj(const char *strFileName);
|
||||
virtual ~CLoadedObj();
|
||||
virtual bool Load(CCaldronByteDataObj *) = 0;
|
||||
virtual bool PostLoad() = 0;
|
||||
//virtual bool Unload() = 0;
|
||||
bool m_bLoaded;
|
||||
bool m_bFirst;
|
||||
char m_strName[256];
|
||||
int m_iReloadingCount; // ReLoading Ƚ<><C8BD>.
|
||||
unsigned int m_iReferenceCount;
|
||||
CCaldronByteDataObj *m_pByteDataObj;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endif // !defined(AFX_LOADEDOBJ_H__7BBE3A5F_6665_4F40_AA4D_82BACEBC32D3__INCLUDED_)
|
||||
319
Engine/Caldron/Src/Base/LogMgr.cpp
Normal file
319
Engine/Caldron/Src/Base/LogMgr.cpp
Normal file
@@ -0,0 +1,319 @@
|
||||
/* *********************************************************************
|
||||
|
||||
* CLogMgr
|
||||
* <20><><EFBFBD><EFBFBD> : LogMgr.cpp
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> <20><EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD>ϴ<EFBFBD> Log System
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2003.10.23
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : wizardbug ( 2003.10.23)
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> :
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
#include "./LogMgr.h"
|
||||
#include "./Console.h"
|
||||
#include "../Scene/MainSceneMgr.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// static <20>Լ<EFBFBD>, <20><><EFBFBD><EFBFBD>
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
Caldron::Base::CLogMgr *Caldron::Base::CLogMgr::ms_pInstance = NULL;
|
||||
|
||||
/*
|
||||
Caldron::Base::CLogMgr *Caldron::Base::CLogMgr::_GetInstance();
|
||||
void Caldron::Base::CLogMgr::_LogMessage(const char *,...);
|
||||
void Caldron::Base::CLogMgr::_LogError(const char *,...);
|
||||
void Caldron::Base::CLogMgr::_SetOutDevice(Caldron::LOG_OUTDEVICES iDevice);
|
||||
void Caldron::Base::CLogMgr::_SetOutMessageFlag(Caldron::LOG_MESSAGES iMessage,bool bFlag);
|
||||
void Caldron::Base::CLogMgr::_Close();
|
||||
*/
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Caldron::Base::CLogMgr::CLogMgr() : m_pLogFile(0), m_iOutDevice(Caldron::LOG_FILEOUT),m_bBufferEmpty(true)
|
||||
{
|
||||
|
||||
|
||||
m_pBitFlag = new CBitset;
|
||||
|
||||
if(m_pBitFlag != NULL)
|
||||
{
|
||||
|
||||
m_pBitFlag->ResizeBits(Caldron::LOG_MESSAGES_NUM);
|
||||
m_pBitFlag->ClearBits();
|
||||
|
||||
for(int i = 0; i < Caldron::LOG_MESSAGES_NUM; i++ )
|
||||
{
|
||||
m_pBitFlag->SetBit(i);
|
||||
}
|
||||
}
|
||||
|
||||
memset((char *)m_pLogBuffer,sizeof(char),2560);
|
||||
memset((char *)m_pLogFileName,sizeof(char),256);
|
||||
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::ValueRelease()
|
||||
{
|
||||
|
||||
if(m_pLogFile != NULL)
|
||||
{
|
||||
fclose(m_pLogFile);
|
||||
m_pLogFile = NULL;
|
||||
}
|
||||
Caldron::SafeDelete(m_pBitFlag);
|
||||
m_pBitFlag = NULL;
|
||||
|
||||
}
|
||||
Caldron::Base::CLogMgr::~CLogMgr()
|
||||
{
|
||||
}
|
||||
|
||||
void Caldron::Base::CLogMgr::_Close()
|
||||
{
|
||||
if(ms_pInstance != NULL)
|
||||
{
|
||||
ms_pInstance->ValueRelease();
|
||||
Caldron::SafeDelete(ms_pInstance);
|
||||
ms_pInstance = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Caldron::Base::CLogMgr *Caldron::Base::CLogMgr::_GetInstance()
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
ms_pInstance = new Caldron::Base::CLogMgr;
|
||||
ms_pInstance->WriteFirstRunLog();
|
||||
|
||||
}
|
||||
|
||||
return ms_pInstance;
|
||||
|
||||
}
|
||||
|
||||
void Caldron::Base::CLogMgr::_SetOutDevice(Caldron::LOG_OUTDEVICES iDevice)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
switch(iDevice)
|
||||
{
|
||||
|
||||
case LOG_FILEOUT:
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->m_iOutDevice = iDevice;
|
||||
break;
|
||||
default:
|
||||
_LogError("CLogMgr::SetOutDevice() | <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ<EFBFBD> Device<63><65> <20><><EFBFBD><EFBFBD><EFBFBD>ϼ̽<CFBC><CCBD>ϴ<EFBFBD>.");
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_SetOutMessageFlag(Caldron::LOG_MESSAGES iMessage,bool bFlag)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
if(ms_pInstance->m_pBitFlag != NULL) {
|
||||
if(bFlag == true)
|
||||
{
|
||||
ms_pInstance->m_pBitFlag->SetBit(iMessage);
|
||||
ms_pInstance->_LogMessage("======= %s Bit On =======",LOG_LABEL[iMessage]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ms_pInstance->_LogMessage("======= %s Bit Off =======",LOG_LABEL[iMessage]);
|
||||
ms_pInstance->m_pBitFlag->ClearOneBit(iMessage);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_LogMessage(const char *pFormat,...)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
if((ms_pInstance->m_pBitFlag != NULL) && (!ms_pInstance->m_pBitFlag->GetBit(Caldron::LOG_MESSAGE)))
|
||||
return;
|
||||
|
||||
/*
|
||||
// Checking <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD>
|
||||
char *pCheckptr = (char *)pFormat;
|
||||
int iFCount = 0; // % Count
|
||||
|
||||
while((*pCheckptr) != '\0')
|
||||
{
|
||||
if((*pCheckptr) == '%')
|
||||
iFCount++;
|
||||
pCheckptr++;
|
||||
|
||||
}
|
||||
|
||||
int iExist = 0;
|
||||
int iVaCount = 0;
|
||||
va_list ap;
|
||||
|
||||
va_start( ap, pFormat );
|
||||
while( iExist != -1 )
|
||||
{
|
||||
iVaCount++;
|
||||
iExist = va_arg( ap, char);
|
||||
}
|
||||
va_end( ap );
|
||||
if( iFCount != iVaCount )
|
||||
return;
|
||||
// Checking <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD>
|
||||
*/
|
||||
va_list ap;
|
||||
va_start(ap, pFormat);
|
||||
vsprintf(ms_pInstance->m_pLogBuffer, pFormat, ap);
|
||||
va_end(ap);
|
||||
ms_pInstance->m_bBufferEmpty = false;
|
||||
|
||||
switch(ms_pInstance->m_iOutDevice)
|
||||
{
|
||||
case LOG_FILEOUT:
|
||||
ms_pInstance->WriteBufferToFile(LOG_MESSAGE);
|
||||
break;
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
ms_pInstance->WriteBufferToConsole(LOG_MESSAGE);
|
||||
break;
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->WriteBufferToMessageBox(LOG_MESSAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_LogError(const char *pFormat,...)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
if((ms_pInstance->m_pBitFlag != NULL) && (!ms_pInstance->m_pBitFlag->GetBit(Caldron::LOG_ERROR)))
|
||||
return;
|
||||
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, pFormat);
|
||||
vsprintf(ms_pInstance->m_pLogBuffer, pFormat, ap);
|
||||
va_end(ap);
|
||||
ms_pInstance->m_bBufferEmpty = false;
|
||||
|
||||
switch(ms_pInstance->m_iOutDevice)
|
||||
{
|
||||
case LOG_FILEOUT:
|
||||
ms_pInstance->WriteBufferToFile(LOG_ERROR);
|
||||
break;
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
ms_pInstance->WriteBufferToConsole(LOG_ERROR);
|
||||
break;
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->WriteBufferToMessageBox(LOG_ERROR);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::_LogNoHeader(const char *pFormat,...)
|
||||
{
|
||||
if(ms_pInstance == NULL)
|
||||
{
|
||||
_GetInstance(); // CLogMgr <20><><EFBFBD><EFBFBD>
|
||||
}
|
||||
|
||||
if((ms_pInstance->m_pBitFlag != NULL) && (!ms_pInstance->m_pBitFlag->GetBit(Caldron::LOG_NOHEADER)))
|
||||
return;
|
||||
|
||||
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, pFormat);
|
||||
vsprintf(ms_pInstance->m_pLogBuffer, pFormat, ap);
|
||||
va_end(ap);
|
||||
ms_pInstance->m_bBufferEmpty = false;
|
||||
|
||||
switch(ms_pInstance->m_iOutDevice)
|
||||
{
|
||||
case LOG_FILEOUT:
|
||||
ms_pInstance->WriteBufferToFile(LOG_NOHEADER);
|
||||
break;
|
||||
case LOG_CONSOLEOUT: // Console
|
||||
ms_pInstance->WriteBufferToConsole(LOG_NOHEADER);
|
||||
break;
|
||||
case LOG_MESSAGEBOXOUT: // Window Message Box
|
||||
ms_pInstance->WriteBufferToMessageBox(LOG_NOHEADER);
|
||||
break;
|
||||
}
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteFirstRunLog()
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
char *pDate = asctime(localtime(&t));
|
||||
|
||||
if(m_pLogFile == NULL)
|
||||
{
|
||||
m_pLogFile = fopen(Caldron::Base::LOG_FILENAME,"at+");
|
||||
}
|
||||
if(m_pLogFile != NULL)
|
||||
{
|
||||
fprintf(m_pLogFile,"\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
|
||||
fprintf(m_pLogFile,"!!!!!!! Below Logs, Application Last Run !!!!!!! %s",pDate);
|
||||
fprintf(m_pLogFile,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n");
|
||||
fclose(m_pLogFile);
|
||||
}
|
||||
|
||||
m_pLogFile = NULL;
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteBufferToFile(Caldron::LOG_MESSAGES iMessage)
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
char *pDate = asctime(localtime(&t));
|
||||
|
||||
if(m_pLogFile == NULL)
|
||||
{
|
||||
m_pLogFile = fopen(Caldron::Base::LOG_FILENAME,"at+");
|
||||
}
|
||||
if(m_pLogFile != NULL)
|
||||
{
|
||||
if(iMessage == LOG_NOHEADER)
|
||||
{
|
||||
fprintf(m_pLogFile,"%s",m_pLogBuffer);
|
||||
}
|
||||
else
|
||||
fprintf(m_pLogFile,"%s %s | %s",LOG_LABEL[iMessage],m_pLogBuffer,pDate);
|
||||
fclose(m_pLogFile);
|
||||
}
|
||||
|
||||
m_pLogFile = NULL;
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteBufferToConsole(Caldron::LOG_MESSAGES iMessage)
|
||||
{
|
||||
if(iMessage == LOG_NOHEADER)
|
||||
{
|
||||
Caldron::Scene::CMainSceneMgr::_GetConsole()->AddText("%s",m_pLogBuffer);
|
||||
}
|
||||
else
|
||||
Caldron::Scene::CMainSceneMgr::_GetConsole()->AddText("%s %s",LOG_LABEL[iMessage],m_pLogBuffer);
|
||||
|
||||
}
|
||||
void Caldron::Base::CLogMgr::WriteBufferToMessageBox(Caldron::LOG_MESSAGES iMessage)
|
||||
{
|
||||
|
||||
MessageBox(NULL,m_pLogBuffer,LOG_LABEL[iMessage],MB_OK);
|
||||
|
||||
}
|
||||
96
Engine/Caldron/Src/Base/LogMgr.h
Normal file
96
Engine/Caldron/Src/Base/LogMgr.h
Normal file
@@ -0,0 +1,96 @@
|
||||
// WBLogSystem.h: interface for the WBLogSystem class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_WBLOGSYSTEM_H__3836C71D_3ABD_4A3D_99E8_385123E4F17C__INCLUDED_)
|
||||
#define AFX_WBLOGSYSTEM_H__3836C71D_3ABD_4A3D_99E8_385123E4F17C__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CLogMgr
|
||||
* <20><><EFBFBD><EFBFBD> : LogMgr.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> <20><EFBFBD><DEBC><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ó<><C3B3><EFBFBD>ϴ<EFBFBD> Log System
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2003.10.23
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : wizardbug ( 2003.10.23)
|
||||
* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> :
|
||||
|
||||
********************************************************************** */
|
||||
#include <time.h>
|
||||
#include "../../include/Caldron.h"
|
||||
|
||||
|
||||
//#define __LOG_WRITE__ // __LOG_WRITE__ <20><> define <20><><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD> Log <20><> <20><><EFBFBD>µȴ<C2B5>.
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
// <20>ܺη<DCBA> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> Enum.
|
||||
enum LOG_MESSAGES
|
||||
{
|
||||
LOG_MESSAGE, // <20>Ϲ<EFBFBD> Log Message
|
||||
LOG_ERROR, // Error Log Message
|
||||
LOG_NOHEADER, // Header <20><><EFBFBD><EFBFBD> <20><EFBFBD><DEBC><EFBFBD>.
|
||||
LOG_MESSAGES_NUM,
|
||||
};
|
||||
|
||||
enum LOG_OUTDEVICES
|
||||
{
|
||||
LOG_FILEOUT, // Log File
|
||||
LOG_CONSOLEOUT, // Console
|
||||
LOG_MESSAGEBOXOUT, // Window Message Box
|
||||
LOG_OUTDEVICES_NUM,
|
||||
};
|
||||
|
||||
namespace Base
|
||||
{
|
||||
|
||||
const char * const LOG_LABEL[3] = {
|
||||
" LOG[ MESSAGE ] | ",
|
||||
" LOG[ ERROR ] | ",
|
||||
""
|
||||
|
||||
};
|
||||
const char LOG_FILENAME[] = "Caldron.log";
|
||||
|
||||
class CLogMgr
|
||||
{
|
||||
private:
|
||||
static CLogMgr *ms_pInstance;
|
||||
FILE *m_pLogFile;
|
||||
Caldron::LOG_OUTDEVICES m_iOutDevice;
|
||||
|
||||
char m_pLogBuffer[2560]; // Log Buffer
|
||||
char m_pLogFileName[256];
|
||||
|
||||
bool m_bBufferEmpty;
|
||||
CBitset *m_pBitFlag;
|
||||
|
||||
|
||||
protected:
|
||||
CLogMgr();
|
||||
|
||||
void WriteBufferToFile(Caldron::LOG_MESSAGES);
|
||||
void WriteBufferToConsole(Caldron::LOG_MESSAGES);
|
||||
void WriteBufferToMessageBox(Caldron::LOG_MESSAGES);
|
||||
void WriteFirstRunLog();
|
||||
public:
|
||||
~CLogMgr();
|
||||
void ValueRelease();
|
||||
|
||||
static void _SetOutDevice(Caldron::LOG_OUTDEVICES iDevice);
|
||||
static CLogMgr * _GetInstance();
|
||||
static void _LogMessage(const char *,...);
|
||||
static void _LogError(const char *,...);
|
||||
static void _LogNoHeader(const char *,...);
|
||||
|
||||
static void _SetOutMessageFlag(Caldron::LOG_MESSAGES iMessage,bool bFlag);
|
||||
static void _Close();
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
#endif // !defined(AFX_WBLOGSYSTEM_H__3836C71D_3ABD_4A3D_99E8_385123E4F17C__INCLUDED_)
|
||||
425
Engine/Caldron/Src/Base/ResourceLoader.cpp
Normal file
425
Engine/Caldron/Src/Base/ResourceLoader.cpp
Normal file
@@ -0,0 +1,425 @@
|
||||
#pragma warning( disable : 4786 )
|
||||
|
||||
#include "../../include/Caldron.h"
|
||||
#include "./LoadedObj.h"
|
||||
|
||||
#include "ResourceLoader.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
namespace Caldron {namespace Base {
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoaderObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ResourceLoader.cpp
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceLoader <20><><EFBFBD><EFBFBD> Load Queue<75><65> <20><><EFBFBD> resource <20><><EFBFBD><EFBFBD>
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
/*
|
||||
CResourceLoaderObj::CResourceLoaderObj()
|
||||
{
|
||||
m_pObj = NULL;
|
||||
m_State = RLOBJSTATE_READY;
|
||||
}
|
||||
CResourceLoaderObj::CResourceLoaderObj(const char *strFileName,CLoadedObj *pObj)
|
||||
{
|
||||
strcpy(m_strFileName,strFileName);
|
||||
m_pObj = pObj;
|
||||
m_pObj->m_bLoaded = false;
|
||||
m_State = RLOBJSTATE_READY;
|
||||
}
|
||||
CResourceLoaderObj::~CResourceLoaderObj()
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoader
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ResourceLoader.cpp
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> ResourceLoader,
|
||||
thread<61><64> <20>и<EFBFBD><D0B8>Ͽ<EFBFBD> <20><EFBFBD> <20><>ƾ <20><> <20>ε<EFBFBD><CEB5><EFBFBD>ƾ<EFBFBD><C6BE> <20>и<EFBFBD> <20>Ͽ<EFBFBD><CFBF><EFBFBD>.
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
CThreadQueue<CLoadedObj *> CResourceLoader::m_ReadyQueue(g_iMaxLoaderQueue);
|
||||
|
||||
DWORD WINAPI LoaderThreadProc(LPVOID lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->LoaderFunc();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
DWORD WINAPI ProcessThreadProc(LPVOID lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->ProcessFunc();
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void CResourceLoader::StartLoader()
|
||||
{
|
||||
if(!m_LoaderHandle)
|
||||
{
|
||||
if((m_LoaderHandle = CreateThread(NULL,0,LoaderThreadProc,(LPVOID)this,0,&m_LoaderThreadID)) == NULL) {
|
||||
//CLogMgr::_LogError("CResourceLoader::Loading() : Create Loader Thread Failed");
|
||||
|
||||
}
|
||||
}
|
||||
if(!m_ProcessHandle)
|
||||
{
|
||||
if((m_ProcessHandle = CreateThread(NULL,0,ProcessThreadProc,(LPVOID)this,0,&m_ProcessThreadID)) == NULL) {
|
||||
//CLogMgr::_LogError("CResourceLoader::Loading() : Create Process Thread Failed");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void CResourceLoader::LoaderFunc()
|
||||
{
|
||||
CLoadedObj *pObj = NULL;
|
||||
while( m_ReadyQueue.RemoveFront(pObj))
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
if(pObj->m_pByteDataObj)
|
||||
delete pObj->m_pByteDataObj;
|
||||
|
||||
pObj->m_pByteDataObj = new CCaldronByteDataObj;
|
||||
|
||||
if(!(pObj->m_pByteDataObj->LoadByte(pObj->m_strName)))
|
||||
{
|
||||
pObj->m_bLoaded = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Queue.PushBack(pObj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CResourceLoader::ProcessFunc()
|
||||
{
|
||||
|
||||
CLoadedObj *pObj = NULL;
|
||||
while( m_Queue.RemoveFront(pObj))
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
if(!pObj->Load(pObj->m_pByteDataObj))
|
||||
{ // <20>ε<EFBFBD> <20><><EFBFBD>нÿ<D0BD> <20>ٽ<EFBFBD> queue<75><65> <20>־ ReLoading <20>õ<EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
if(pObj->m_iReloadingCount < Caldron::MAX_RELOADING) {
|
||||
pObj->m_bLoaded = false;
|
||||
m_Queue.PushBack(pObj);
|
||||
//CLogMgr::_LogError("CResourceLoader::ProcessFunc: Load fail, Reloading.");
|
||||
pObj->m_iReloadingCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_bLoaded = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ResultQueue.PushBack(pObj);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//CLogMgr::_LogError("CResourceLoader::ProcessFunc: Obj Ptr is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CResourceLoader::ProcessAllData()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
Sleep(2000);
|
||||
if(!m_ReadyQueue.GetQueueSize() &&
|
||||
!m_Queue.GetQueueSize())
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_ResultQueue.GetQueueSize())
|
||||
{
|
||||
int iProcess = m_ResultQueue.GetQueueSize();
|
||||
CLoadedObj *pObj = NULL;
|
||||
|
||||
while(iProcess)
|
||||
{
|
||||
if(m_ResultQueue.RemoveFront(pObj))
|
||||
{
|
||||
pObj->PostLoad();
|
||||
SafeDelete(pObj->m_pByteDataObj);
|
||||
pObj->m_pByteDataObj = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
iProcess--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CResourceLoader::Process()
|
||||
{
|
||||
if(m_ResultQueue.GetQueueSize())
|
||||
{
|
||||
int iProcess = (m_ResultQueue.GetQueueSize() > g_iMaxProcessNums) ? g_iMaxProcessNums : m_ResultQueue.GetQueueSize();
|
||||
CLoadedObj *pObj = NULL;
|
||||
|
||||
while(iProcess)
|
||||
{
|
||||
if(m_ResultQueue.RemoveFront(pObj))
|
||||
{
|
||||
pObj->PostLoad();
|
||||
SafeDelete(pObj->m_pByteDataObj);
|
||||
pObj->m_pByteDataObj = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
iProcess--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CResourceLoader::Clear()
|
||||
{
|
||||
ProcessAllData();
|
||||
m_ReadyQueue.ClearQueue();
|
||||
m_Queue.ClearQueue();
|
||||
m_ResultQueue.ClearQueue();
|
||||
|
||||
}
|
||||
/*
|
||||
class CResourceLoader
|
||||
{
|
||||
public:
|
||||
CResourceLoader();
|
||||
virtual ~CResourceLoader();
|
||||
void StartLoader();
|
||||
int AddObj(CResourceLoaderObj *);
|
||||
protected:
|
||||
void LoaderFunc();
|
||||
void ProcessFunc();
|
||||
DWORD m_dwWait;
|
||||
|
||||
CThreadQueue<CResourceLoaderObj *>m_lstObj;
|
||||
CThreadQueue<CResourceLoaderObj *>m_Queue;
|
||||
|
||||
CCriticalSectionQueue<CLoadedObj *>m_ResultQueue;
|
||||
|
||||
unsigned long m_LoaderThreadID;
|
||||
unsigned long m_ProcessThreadID;
|
||||
|
||||
HANDLE m_LoaderHandle;
|
||||
HANDLE m_ProcessHandle;
|
||||
|
||||
|
||||
};
|
||||
|
||||
CResourceLoader::CResourceLoader() : m_Queue(g_iMaxLoaderQueue)
|
||||
{
|
||||
m_bLoading = false;
|
||||
|
||||
m_dwWait = 0;
|
||||
m_lstObj.clear();
|
||||
m_lstReady.clear();
|
||||
InitializeCriticalSection(&m_ObjCriticalSection);
|
||||
m_LoaderThreadID = m_ProcessThreadID = 0;
|
||||
m_EndEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
m_LoaderHandle = 0;
|
||||
m_ProcessHandle = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
CResourceLoader::~CResourceLoader()
|
||||
{
|
||||
DeleteCriticalSection(&m_ObjCriticalSection);
|
||||
CloseHandle(m_EndEvent);
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
|
||||
}
|
||||
void CResourceLoader::Loading()
|
||||
{
|
||||
m_bLoading = true;
|
||||
// Event <20>ʱ<EFBFBD>ȭ
|
||||
ResetEvent(m_EndEvent);
|
||||
if((m_LoaderHandle = CreateThread(NULL,0,LoaderThreadProc,(LPVOID)this,0,&m_LoaderThreadID)) == NULL) {
|
||||
CLogMgr::_LogError("CResourceLoader::Loading() : Create Loader Thread Failed");
|
||||
|
||||
}
|
||||
if((m_ProcessHandle = CreateThread(NULL,0,ProcessThreadProc,(LPVOID)this,0,&m_ProcessThreadID)) == NULL) {
|
||||
CLogMgr::_LogError("CResourceLoader::Loading() : Create Process Thread Failed");
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CResourceLoader::WaitFinished()
|
||||
{
|
||||
return WaitForMultipleObjects(1, &m_EndEvent, FALSE, m_dwWait);
|
||||
}
|
||||
int CResourceLoader::FinishPercent() {
|
||||
return 0;
|
||||
}
|
||||
void CResourceLoader::LoaderFunc()
|
||||
{
|
||||
for(int iIndex = 0; iIndex < GetObjNum(); iIndex++)
|
||||
{
|
||||
CResourceLoaderObj *pObj = &m_lstObj[iIndex];
|
||||
if(!(pObj->m_ByteData.LoadByte(pObj->m_strFileName)))
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_FAILED;
|
||||
if(pObj->m_pObj)
|
||||
pObj->m_pObj->m_bLoaded = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_LOADING;
|
||||
m_Queue.PushBack(pObj);
|
||||
}
|
||||
}
|
||||
m_Queue.Terminate();
|
||||
}
|
||||
void CResourceLoader::ProcessFunc()
|
||||
{
|
||||
CResourceLoaderObj *pObj = NULL;
|
||||
while( m_Queue.RemoveFront(pObj))
|
||||
{
|
||||
if((pObj) && (pObj->m_pObj))
|
||||
{
|
||||
if(!pObj->m_pObj->Load(&(pObj->m_ByteData)))
|
||||
{ // <20>ε<EFBFBD> <20><><EFBFBD>нÿ<D0BD> <20>ٽ<EFBFBD> queue<75><65> <20>־ ReLoading <20>õ<EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
if(pObj->m_pObj->m_iReloadingCount < Caldron::MAX_RELOADING) {
|
||||
pObj->m_State = RLOBJSTATE_LOADING;
|
||||
pObj->m_pObj->m_bLoaded = false;
|
||||
m_Queue.PushBack(pObj);
|
||||
CLogMgr::_LogError("CResourceLoader::ProcessFunc: Load fail, Reloading.");
|
||||
pObj->m_pObj->m_iReloadingCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_FAILED;
|
||||
pObj->m_pObj->m_bLoaded = true;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->m_State = RLOBJSTATE_LOADED;
|
||||
pObj->m_pObj->m_bLoaded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMgr::_LogError("CResourceLoader::ProcessFunc: Obj Ptr is NULL");
|
||||
}
|
||||
}
|
||||
SetEvent(m_EndEvent);
|
||||
}
|
||||
int CResourceLoader::AddObj(CResourceLoaderObj &Obj)
|
||||
{
|
||||
if(!m_bLoading) {
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
m_lstObj.push_back(Obj);
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
return (int)(m_lstObj.size());
|
||||
}
|
||||
else {
|
||||
m_lstReady.push_back(Obj);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
CResourceLoaderObj CResourceLoader::GetObj(int iIndex)
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
CResourceLoaderObj Obj = m_lstObj[iIndex];
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
return Obj;
|
||||
}
|
||||
void CResourceLoader::SetObj(int iIndex,CResourceLoaderObj &Obj)
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
m_lstObj[iIndex] = Obj;
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
}
|
||||
int CResourceLoader::GetObjNum()
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
int iNum = (int)m_lstObj.size();
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
return iNum;
|
||||
}
|
||||
void CResourceLoader::ClearAllObj()
|
||||
{
|
||||
EnterCriticalSection(&m_ObjCriticalSection);
|
||||
m_lstObj.clear();
|
||||
LeaveCriticalSection(&m_ObjCriticalSection);
|
||||
|
||||
}
|
||||
CResourceLoaderObjState CResourceLoader::GetObjState(int iIndex)
|
||||
{
|
||||
return m_lstObj[iIndex].m_State;
|
||||
}
|
||||
bool CResourceLoader::Finished()
|
||||
{
|
||||
if(WaitFinished() != (WAIT_OBJECT_0))
|
||||
return false;
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
m_LoaderHandle = m_ProcessHandle = 0;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
void CResourceLoader::Process() {
|
||||
if((m_bLoading == true) && WaitFinished() == (WAIT_OBJECT_0))
|
||||
{
|
||||
m_bLoading = false;
|
||||
ClearAllObj();
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
m_LoaderHandle = m_ProcessHandle = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((m_lstObj.size() > 0 )&& (m_bLoading == false))
|
||||
Loading();
|
||||
return;
|
||||
}
|
||||
if(m_lstReady.size() > 0 && !m_bLoading)
|
||||
{
|
||||
|
||||
// Ready ť<><C5A5> <20><><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20>͵<EFBFBD><CDB5><EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>ѱ<EFBFBD><D1B1><EFBFBD>
|
||||
m_lstObj.reserve(m_lstReady.size());
|
||||
std::copy(m_lstReady.begin(),m_lstReady.end(),std::back_inserter(m_lstObj));
|
||||
|
||||
m_lstReady.clear();
|
||||
Loading();
|
||||
}
|
||||
|
||||
}*/
|
||||
}}
|
||||
163
Engine/Caldron/Src/Base/ResourceLoader.h
Normal file
163
Engine/Caldron/Src/Base/ResourceLoader.h
Normal file
@@ -0,0 +1,163 @@
|
||||
// ResourceLoader.h: interface for the CResourceLoader class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_RESOURCELOADER_H__16578E31_424F_4D74_9304_44BEC2BE6F95__INCLUDED_)
|
||||
#define AFX_RESOURCELOADER_H__16578E31_424F_4D74_9304_44BEC2BE6F95__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
#include "./LoadedObj.h"
|
||||
#include "./CaldronByteDataObj.h"
|
||||
#include "./ThreadQueue.h"
|
||||
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoaderObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ResourceLoader.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceLoader <20><><EFBFBD><EFBFBD> Load Queue<75><65> <20><><EFBFBD> resource <20><><EFBFBD><EFBFBD>
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
enum CResourceLoaderObjState {
|
||||
RLOBJSTATE_READY = 0,
|
||||
RLOBJSTATE_LOADING,
|
||||
RLOBJSTATE_LOADED,
|
||||
RLOBJSTATE_FAILED,
|
||||
|
||||
};
|
||||
const int g_iMaxLoaderQueue = 100000;
|
||||
const int g_iMaxResultQueue = 200000;
|
||||
const int g_iMaxProcessNums = 10;
|
||||
|
||||
/*
|
||||
class CResourceLoaderObj {
|
||||
public:
|
||||
|
||||
CResourceLoaderObj();
|
||||
CResourceLoaderObj(const char *strFileName,CLoadedObj *pObj);
|
||||
|
||||
virtual ~CResourceLoaderObj();
|
||||
|
||||
CResourceLoaderObjState m_State;
|
||||
// CByteDataObj m_ByteData;
|
||||
char m_strFileName[40];
|
||||
CLoadedObj *m_pObj;
|
||||
|
||||
};
|
||||
*/
|
||||
/* *********************************************************************
|
||||
|
||||
* CResourceLoader
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ResourceLoader.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> ResourceLoader
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
class CResourceLoader
|
||||
{
|
||||
protected:
|
||||
|
||||
static CThreadQueue<CLoadedObj *>m_ReadyQueue;
|
||||
CThreadQueue<CLoadedObj *>m_Queue;
|
||||
|
||||
CCriticalSectionQueue<CLoadedObj *>m_ResultQueue;
|
||||
|
||||
unsigned long m_LoaderThreadID;
|
||||
unsigned long m_ProcessThreadID;
|
||||
|
||||
HANDLE m_LoaderHandle;
|
||||
HANDLE m_ProcessHandle;
|
||||
|
||||
public:
|
||||
CResourceLoader() :/*m_ReadyQueue(g_iMaxLoaderQueue),*/m_Queue(g_iMaxLoaderQueue),m_ResultQueue(g_iMaxResultQueue),
|
||||
m_LoaderThreadID(0),m_ProcessThreadID(0),
|
||||
m_LoaderHandle(0),m_ProcessHandle(0)
|
||||
{}
|
||||
virtual ~CResourceLoader()
|
||||
{
|
||||
Clear();
|
||||
CloseHandle(m_LoaderHandle);
|
||||
CloseHandle(m_ProcessHandle);
|
||||
|
||||
}
|
||||
void StartLoader();
|
||||
static void AddObj(CLoadedObj *pAddObj)
|
||||
{
|
||||
m_ReadyQueue.PushBack(pAddObj);
|
||||
}
|
||||
void LoaderFunc();
|
||||
void ProcessFunc();
|
||||
void Process();
|
||||
void ProcessAllData();
|
||||
|
||||
void Clear();
|
||||
|
||||
|
||||
};
|
||||
/*
|
||||
class CResourceLoader
|
||||
{
|
||||
public:
|
||||
CResourceLoader();
|
||||
virtual ~CResourceLoader();
|
||||
int FinishPercent();
|
||||
// <20><><EFBFBD><EFBFBD> queue<75>ȿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> obj <20><><EFBFBD><EFBFBD> <20>ε<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ƾ
|
||||
void Loading();
|
||||
|
||||
void ClearAllObj();
|
||||
int AddObj(CResourceLoaderObj &);
|
||||
void SetObj(int iIndex,CResourceLoaderObj &);
|
||||
|
||||
int GetObjNum();
|
||||
CResourceLoaderObj GetObj(int iIndex);
|
||||
// <20><><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
CResourceLoaderObjState GetObjState(int iIndex);
|
||||
|
||||
DWORD WaitFinished();
|
||||
// <20><><EFBFBD>μ<EFBFBD><CEBC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>忡<EFBFBD><E5BFA1> ȣ<><C8A3>
|
||||
void ProcessFunc();
|
||||
// <20>δ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>忡<EFBFBD><E5BFA1> ȣ<><C8A3>
|
||||
void LoaderFunc();
|
||||
bool Finished();
|
||||
void Process();
|
||||
|
||||
protected:
|
||||
// Loading Thread ȣ<><C8A3><EFBFBD><EFBFBD> <20><><EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD> <20>ð<EFBFBD>
|
||||
// 0 : <20><><EFBFBD>ٷ<EFBFBD> return, INFINIT : Loading <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ٸ<EFBFBD>. (default : 0)
|
||||
DWORD m_dwWait;
|
||||
std::vector<CResourceLoaderObj> m_lstObj;
|
||||
std::vector<CResourceLoaderObj> m_lstReady;
|
||||
|
||||
CThreadQueue<CResourceLoaderObj *>m_Queue;
|
||||
|
||||
CRITICAL_SECTION m_ObjCriticalSection;
|
||||
|
||||
unsigned long m_LoaderThreadID;
|
||||
unsigned long m_ProcessThreadID;
|
||||
|
||||
HANDLE m_EndEvent;
|
||||
HANDLE m_LoaderHandle;
|
||||
HANDLE m_ProcessHandle;
|
||||
|
||||
bool m_bLoading;
|
||||
};
|
||||
*/
|
||||
}}
|
||||
|
||||
#endif // !defined(AFX_RESOURCELOADER_H__16578E31_424F_4D74_9304_44BEC2BE6F95__INCLUDED_)
|
||||
181
Engine/Caldron/Src/Base/ThreadQueue.h
Normal file
181
Engine/Caldron/Src/Base/ThreadQueue.h
Normal file
@@ -0,0 +1,181 @@
|
||||
// ThreadQueue.h: interface for the CThreadQueue class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_THREADQUEUE_H__D6165646_A901_43B4_BABC_5237337D0BFD__INCLUDED_)
|
||||
#define AFX_THREADQUEUE_H__D6165646_A901_43B4_BABC_5237337D0BFD__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "../../include/Caldron.h"
|
||||
//#include "./LogMgr.h"
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CThreadQueue
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ThreadQueue.cpp
|
||||
* <20><><EFBFBD><EFBFBD> :
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.09
|
||||
* history :
|
||||
wizardbug ( 2004.01.09)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
enum CALDRONTHREADEVENT_ID {
|
||||
CALDRONTHREAD_SEMAPHORE = 0,
|
||||
CALDRONTHREAD_TERMINATE,
|
||||
};
|
||||
template<class T>
|
||||
class CThreadQueue
|
||||
{
|
||||
public:
|
||||
CThreadQueue(int iMaxQueueSize)
|
||||
{
|
||||
InitializeCriticalSection(&m_CriticalSection);
|
||||
m_Handle[CALDRONTHREAD_SEMAPHORE] = CreateSemaphore(NULL,0,iMaxQueueSize,NULL);
|
||||
m_Handle[CALDRONTHREAD_TERMINATE] = CreateEvent(NULL,TRUE,FALSE,NULL);
|
||||
|
||||
}
|
||||
virtual ~CThreadQueue()
|
||||
{
|
||||
ClearQueue();
|
||||
DeleteCriticalSection(&m_CriticalSection);
|
||||
CloseHandle(m_Handle[CALDRONTHREAD_SEMAPHORE]);
|
||||
CloseHandle(m_Handle[CALDRONTHREAD_TERMINATE]);
|
||||
}
|
||||
bool PushBack(T Obj)
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
m_Queue.push(Obj);
|
||||
|
||||
// semaphore count <20><><EFBFBD><EFBFBD>
|
||||
bool bResult = (ReleaseSemaphore(m_Handle[CALDRONTHREAD_SEMAPHORE],1,NULL) != 0);
|
||||
if(!bResult)
|
||||
{
|
||||
m_Queue.pop(); // pop()<29><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD> remove <20><>Ų<EFBFBD><C5B2>.
|
||||
//CLogMgr::_LogError("CThreadQueue::PushBack() : Queue is Full~!");
|
||||
MessageBox(NULL,"Queue Full","ThreadQueue",MB_OK);
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return bResult;
|
||||
}
|
||||
void ClearQueue()
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
while(m_Queue.size())
|
||||
{
|
||||
m_Queue.pop();
|
||||
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
|
||||
}
|
||||
|
||||
bool RemoveFront(T &Obj)
|
||||
{
|
||||
bool bResult = false;
|
||||
// Semarphore <20><> <20><><EFBFBD><EFBFBD> <20><>ŭ Return <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EEB0A3>
|
||||
CALDRONTHREADEVENT_ID ReturnID = (CALDRONTHREADEVENT_ID)WaitForMultipleObjects(2,m_Handle,FALSE,INFINITE);
|
||||
|
||||
if(ReturnID == CALDRONTHREAD_SEMAPHORE)
|
||||
{
|
||||
bResult = true;
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
if(m_Queue.size())
|
||||
{
|
||||
Obj = m_Queue.front();
|
||||
m_Queue.pop(); // pop()<29><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD> remove <20><>Ų<EFBFBD><C5B2>.
|
||||
}
|
||||
else
|
||||
{
|
||||
//CLogMgr::_LogError("CThreadQueue::RemoveFront() : Queue is Empty~!");
|
||||
bResult = false;
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return bResult;
|
||||
}
|
||||
return bResult;
|
||||
}
|
||||
void Terminate()
|
||||
{
|
||||
SetEvent(m_Handle[CALDRONTHREAD_TERMINATE]);
|
||||
}
|
||||
void UnTerminate()
|
||||
{
|
||||
ResetEvent(m_Handle[CALDRONTHREAD_TERMINATE]);
|
||||
}
|
||||
int GetQueueSize()
|
||||
{
|
||||
return (int)m_Queue.size();
|
||||
}
|
||||
protected:
|
||||
|
||||
HANDLE m_Handle[2];
|
||||
CRITICAL_SECTION m_CriticalSection;
|
||||
std::queue<T> m_Queue;
|
||||
|
||||
};
|
||||
template<class T>
|
||||
class CCriticalSectionQueue
|
||||
{
|
||||
public:
|
||||
CCriticalSectionQueue(int iMaxQueueSize)
|
||||
{
|
||||
InitializeCriticalSection(&m_CriticalSection);
|
||||
|
||||
}
|
||||
virtual ~CCriticalSectionQueue()
|
||||
{
|
||||
ClearQueue();
|
||||
DeleteCriticalSection(&m_CriticalSection);
|
||||
}
|
||||
void ClearQueue()
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
while(m_Queue.size())
|
||||
{
|
||||
m_Queue.pop();
|
||||
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
|
||||
}
|
||||
void PushBack(T Obj)
|
||||
{
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
m_Queue.push(Obj);
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
}
|
||||
bool RemoveFront(T &Obj)
|
||||
{
|
||||
bool bReturn = false;
|
||||
EnterCriticalSection(&m_CriticalSection);
|
||||
if(m_Queue.size())
|
||||
{
|
||||
Obj = m_Queue.front();
|
||||
m_Queue.pop(); // pop()<29><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٷ<EFBFBD><D9B7><EFBFBD><EFBFBD><EFBFBD> remove <20><>Ų<EFBFBD><C5B2>.
|
||||
bReturn = true;
|
||||
}
|
||||
LeaveCriticalSection(&m_CriticalSection);
|
||||
return bReturn;
|
||||
|
||||
}
|
||||
int GetQueueSize()
|
||||
{
|
||||
return (int)m_Queue.size();
|
||||
}
|
||||
protected:
|
||||
CRITICAL_SECTION m_CriticalSection;
|
||||
std::queue<T> m_Queue;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif // !defined(AFX_THREADQUEUE_H__D6165646_A901_43B4_BABC_5237337D0BFD__INCLUDED_)
|
||||
613
Engine/Caldron/Src/Scene/D3DBufferPools.cpp
Normal file
613
Engine/Caldron/Src/Scene/D3DBufferPools.cpp
Normal file
@@ -0,0 +1,613 @@
|
||||
#include "./d3dbufferpools.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
using namespace Caldron::Scene;
|
||||
|
||||
void CD3DBufferObj::CreateBuffer(int iType,unsigned int uiSize,DWORD dwDecl,LPDIRECT3DRESOURCE8 lpBuffer)
|
||||
{
|
||||
m_iBufferObjType = iType;
|
||||
m_uiBufferSize = uiSize;
|
||||
m_dwValue = dwDecl;
|
||||
|
||||
m_pBuffers = lpBuffer;
|
||||
|
||||
}
|
||||
void CD3DBufferObj::NullBuffer()
|
||||
{
|
||||
SafeRelease(m_pBuffers);
|
||||
m_pBuffers = NULL;
|
||||
m_iBufferObjType = 0;
|
||||
m_uiBufferSize = 0;
|
||||
m_dwValue = 0;
|
||||
|
||||
|
||||
}
|
||||
CD3DBufferPools::CD3DBufferPools(void)
|
||||
{
|
||||
for(int i = 0; i < D3DBUFFER_SIZENUM - 1; i++ )
|
||||
{
|
||||
m_DVertexBufferNums[i] = 0;
|
||||
m_DIndexBufferNums[i] = 0;
|
||||
}
|
||||
|
||||
m_DCustomVertexBufferPools.clear();
|
||||
m_DCustomIndexBufferPools.clear();
|
||||
m_DIndexBufferNums[D3DBUFFER_SIZENUM - 1] = 0;
|
||||
m_DVertexBufferNums[D3DBUFFER_SIZENUM - 1] = 0;
|
||||
|
||||
for(int i = 0; i < D3DBUFFER_SIZENUM - 1; i++ )
|
||||
{
|
||||
m_SVertexBufferNums[i] = 0;
|
||||
m_SIndexBufferNums[i] = 0;
|
||||
}
|
||||
|
||||
m_SCustomVertexBufferPools.clear();
|
||||
m_SCustomIndexBufferPools.clear();
|
||||
m_SIndexBufferNums[D3DBUFFER_SIZENUM - 1] = 0;
|
||||
m_SVertexBufferNums[D3DBUFFER_SIZENUM - 1] = 0;
|
||||
}
|
||||
|
||||
CD3DBufferPools::~CD3DBufferPools(void)
|
||||
{
|
||||
// Dynamic Buffer Clear
|
||||
for(int i = 0; i < D3DBUFFER_SIZENUM - 1; i++ )
|
||||
{
|
||||
while(!m_DVertexBufferPools[i].empty())
|
||||
{
|
||||
CD3DBufferObj *pObj = m_DVertexBufferPools[i].front();
|
||||
m_DVertexBufferPools[i].pop();
|
||||
if(pObj)
|
||||
{
|
||||
pObj->NullBuffer();
|
||||
SafeDelete(pObj);
|
||||
|
||||
}
|
||||
}
|
||||
while(!m_DIndexBufferPools[i].empty())
|
||||
{
|
||||
CD3DBufferObj *pObj = m_DIndexBufferPools[i].front();
|
||||
m_DIndexBufferPools[i].pop();
|
||||
if(pObj)
|
||||
{
|
||||
pObj->NullBuffer();
|
||||
SafeDelete(pObj);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
m_DVertexBufferNums[i] = 0;
|
||||
m_DIndexBufferNums[i] = 0;
|
||||
}
|
||||
|
||||
for(int i = 0; i < (int)m_DVertexBufferNums[D3DBUFFER_SIZENUM - 1]; i++ )
|
||||
{
|
||||
if(m_DCustomVertexBufferPools[i])
|
||||
{
|
||||
m_DCustomVertexBufferPools[i]->NullBuffer();
|
||||
SafeDelete(m_DCustomVertexBufferPools[i]);
|
||||
m_DCustomVertexBufferPools[i] = NULL;
|
||||
}
|
||||
}
|
||||
m_DCustomVertexBufferPools.clear();
|
||||
|
||||
for(int i = 0; i < (int)m_DIndexBufferNums[D3DBUFFER_SIZENUM - 1]; i++ )
|
||||
{
|
||||
if(m_DCustomIndexBufferPools[i])
|
||||
{
|
||||
m_DCustomIndexBufferPools[i]->NullBuffer();
|
||||
SafeDelete(m_DCustomIndexBufferPools[i]);
|
||||
m_DCustomIndexBufferPools[i] = NULL;
|
||||
}
|
||||
}
|
||||
m_DCustomIndexBufferPools.clear();
|
||||
|
||||
// Static Buffer Clear
|
||||
for(int i = 0; i < D3DBUFFER_SIZENUM - 1; i++ )
|
||||
{
|
||||
while(!m_SVertexBufferPools[i].empty())
|
||||
{
|
||||
CD3DBufferObj *pObj = m_SVertexBufferPools[i].front();
|
||||
m_SVertexBufferPools[i].pop();
|
||||
if(pObj)
|
||||
{
|
||||
pObj->NullBuffer();
|
||||
SafeDelete(pObj);
|
||||
|
||||
}
|
||||
}
|
||||
while(!m_SIndexBufferPools[i].empty())
|
||||
{
|
||||
CD3DBufferObj *pObj = m_SIndexBufferPools[i].front();
|
||||
m_SIndexBufferPools[i].pop();
|
||||
if(pObj)
|
||||
{
|
||||
pObj->NullBuffer();
|
||||
SafeDelete(pObj);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_SVertexBufferNums[i] = 0;
|
||||
m_SIndexBufferNums[i] = 0;
|
||||
}
|
||||
|
||||
for(int i = 0; i < (int)m_SVertexBufferNums[D3DBUFFER_SIZENUM - 1]; i++ )
|
||||
{
|
||||
if(m_SCustomVertexBufferPools[i])
|
||||
{
|
||||
m_SCustomVertexBufferPools[i]->NullBuffer();
|
||||
SafeDelete(m_SCustomVertexBufferPools[i]);
|
||||
m_SCustomVertexBufferPools[i] = NULL;
|
||||
}
|
||||
}
|
||||
m_SCustomVertexBufferPools.clear();
|
||||
|
||||
for(int i = 0; i < (int)m_SIndexBufferNums[D3DBUFFER_SIZENUM - 1]; i++ )
|
||||
{
|
||||
if(m_SCustomIndexBufferPools[i])
|
||||
{
|
||||
m_SCustomIndexBufferPools[i]->NullBuffer();
|
||||
SafeDelete(m_SCustomIndexBufferPools[i]);
|
||||
m_SCustomIndexBufferPools[i] = NULL;
|
||||
}
|
||||
}
|
||||
m_SCustomIndexBufferPools.clear();
|
||||
|
||||
|
||||
}
|
||||
LPDIRECT3DVERTEXBUFFER8 CD3DBufferPools::GetVertexBuffer(unsigned int uiSize,DWORD dwDecl,bool bDynamic)
|
||||
{
|
||||
LPDIRECT3DVERTEXBUFFER8 pReturn = NULL;
|
||||
int i,j;
|
||||
if(bDynamic)
|
||||
{
|
||||
for(i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(uiSize <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_DVertexBufferNums[i])
|
||||
{
|
||||
CD3DBufferObj *pObj = m_DVertexBufferPools[i].front();
|
||||
m_DVertexBufferPools[i].pop();
|
||||
m_DVertexBufferNums[i]--;
|
||||
if(pObj)
|
||||
{
|
||||
pReturn = (LPDIRECT3DVERTEXBUFFER8) pObj->m_pBuffers;
|
||||
SafeDelete(pObj);
|
||||
return pReturn;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return (pReturn = (LPDIRECT3DVERTEXBUFFER8)CreateBuffer(bDynamic,Scene::D3DBUFFEROBJ_VERTEX,i,dwDecl));
|
||||
|
||||
}
|
||||
}
|
||||
// Custom Size
|
||||
if(m_DVertexBufferNums[D3DBUFFER_SIZENUM - 1])
|
||||
{
|
||||
for(j = 0; j < (int)m_DVertexBufferNums[D3DBUFFER_SIZENUM - 1]; j++ )
|
||||
{
|
||||
|
||||
if((m_DCustomVertexBufferPools[j]->m_uiBufferSize) >= uiSize)
|
||||
{
|
||||
pReturn = ((LPDIRECT3DVERTEXBUFFER8)m_DCustomVertexBufferPools[j]->m_pBuffers);
|
||||
SafeDelete(m_DCustomVertexBufferPools[j]);
|
||||
m_DCustomVertexBufferPools.erase(m_DCustomVertexBufferPools.begin() + j);
|
||||
m_DVertexBufferNums[D3DBUFFER_SIZENUM - 1]--;
|
||||
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else //static
|
||||
{
|
||||
for(i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(uiSize <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_SVertexBufferNums[i])
|
||||
{
|
||||
CD3DBufferObj *pObj = m_SVertexBufferPools[i].front();
|
||||
m_SVertexBufferPools[i].pop();
|
||||
m_SVertexBufferNums[i]--;
|
||||
if(pObj)
|
||||
{
|
||||
pReturn = (LPDIRECT3DVERTEXBUFFER8) pObj->m_pBuffers;
|
||||
SafeDelete(pObj);
|
||||
return pReturn;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return (pReturn = (LPDIRECT3DVERTEXBUFFER8)CreateBuffer(bDynamic,Scene::D3DBUFFEROBJ_VERTEX,i,dwDecl));
|
||||
|
||||
}
|
||||
}
|
||||
// Custom Size
|
||||
if(m_SVertexBufferNums[D3DBUFFER_SIZENUM - 1])
|
||||
{
|
||||
for(j = 0; j < (int)m_SVertexBufferNums[D3DBUFFER_SIZENUM - 1]; j++ )
|
||||
{
|
||||
|
||||
if((m_SCustomVertexBufferPools[j]->m_uiBufferSize) >= uiSize)
|
||||
{
|
||||
pReturn = ((LPDIRECT3DVERTEXBUFFER8)m_SCustomVertexBufferPools[j]->m_pBuffers);
|
||||
SafeDelete(m_SCustomVertexBufferPools[j]);
|
||||
m_SCustomVertexBufferPools.erase(m_SCustomVertexBufferPools.begin() + j);
|
||||
m_SVertexBufferNums[D3DBUFFER_SIZENUM - 1]--;
|
||||
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return (pReturn = (LPDIRECT3DVERTEXBUFFER8)CreateBuffer(bDynamic,Scene::D3DBUFFEROBJ_VERTEX,-1,dwDecl,uiSize));
|
||||
|
||||
}
|
||||
|
||||
LPDIRECT3DINDEXBUFFER8 CD3DBufferPools::GetIndexBuffer(unsigned int uiSize,DWORD dwFormat,bool bDynamic)
|
||||
{
|
||||
LPDIRECT3DINDEXBUFFER8 pReturn = NULL;
|
||||
int i,j;
|
||||
if(bDynamic)
|
||||
{
|
||||
for(i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(uiSize <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_DIndexBufferNums[i])
|
||||
{
|
||||
CD3DBufferObj *pObj = m_DIndexBufferPools[i].front();
|
||||
m_DIndexBufferPools[i].pop();
|
||||
m_DIndexBufferNums[i]--;
|
||||
if(pObj)
|
||||
{
|
||||
pReturn = (LPDIRECT3DINDEXBUFFER8) pObj->m_pBuffers;
|
||||
SafeDelete(pObj);
|
||||
return pReturn;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return (pReturn = (LPDIRECT3DINDEXBUFFER8)CreateBuffer(bDynamic,Scene::D3DBUFFEROBJ_INDEX,i,dwFormat));
|
||||
|
||||
}
|
||||
}
|
||||
// Custom Size
|
||||
if(m_DIndexBufferNums[D3DBUFFER_SIZENUM - 1])
|
||||
{
|
||||
for(j = 0; j < (int)m_DIndexBufferNums[D3DBUFFER_SIZENUM - 1]; j++ )
|
||||
{
|
||||
|
||||
if((m_DCustomIndexBufferPools[j]->m_uiBufferSize) >= uiSize)
|
||||
{
|
||||
pReturn = ((LPDIRECT3DINDEXBUFFER8)m_DCustomIndexBufferPools[j]->m_pBuffers);
|
||||
SafeDelete(m_DCustomIndexBufferPools[j]);
|
||||
m_DCustomIndexBufferPools.erase(m_DCustomIndexBufferPools.begin() + j);
|
||||
m_DIndexBufferNums[D3DBUFFER_SIZENUM - 1]--;
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else //Static Buffer
|
||||
{
|
||||
for(i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(uiSize <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_SIndexBufferNums[i])
|
||||
{
|
||||
CD3DBufferObj *pObj = m_SIndexBufferPools[i].front();
|
||||
m_SIndexBufferPools[i].pop();
|
||||
m_SIndexBufferNums[i]--;
|
||||
if(pObj)
|
||||
{
|
||||
pReturn = (LPDIRECT3DINDEXBUFFER8) pObj->m_pBuffers;
|
||||
SafeDelete(pObj);
|
||||
return pReturn;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
return (pReturn = (LPDIRECT3DINDEXBUFFER8)CreateBuffer(bDynamic,Scene::D3DBUFFEROBJ_INDEX,i,dwFormat));
|
||||
|
||||
}
|
||||
}
|
||||
// Custom Size
|
||||
if(m_SIndexBufferNums[D3DBUFFER_SIZENUM - 1])
|
||||
{
|
||||
for(j = 0; j < (int)m_SIndexBufferNums[D3DBUFFER_SIZENUM - 1]; j++ )
|
||||
{
|
||||
|
||||
if((m_SCustomIndexBufferPools[j]->m_uiBufferSize) >= uiSize)
|
||||
{
|
||||
pReturn = ((LPDIRECT3DINDEXBUFFER8)m_SCustomIndexBufferPools[j]->m_pBuffers);
|
||||
SafeDelete(m_SCustomIndexBufferPools[j]);
|
||||
m_SCustomIndexBufferPools.erase(m_SCustomIndexBufferPools.begin() + j);
|
||||
m_SIndexBufferNums[D3DBUFFER_SIZENUM - 1]--;
|
||||
return pReturn;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return (pReturn = (LPDIRECT3DINDEXBUFFER8)CreateBuffer(bDynamic,Scene::D3DBUFFEROBJ_INDEX,-1,dwFormat,uiSize));
|
||||
|
||||
}
|
||||
void CD3DBufferPools::UnRef(unsigned int iType,LPDIRECT3DRESOURCE8 lpBuffer)
|
||||
{
|
||||
// ppuchuu 2004/11/15
|
||||
if( NULL == lpBuffer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// edith 2008.12.12 <20><><EFBFBD><EFBFBD>Ǯ<EFBFBD><C7AE> <20>ִ밳<D6B4><EBB0B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
unsigned int iMaxPoolCount = 100;
|
||||
bool bDynamic = false;
|
||||
|
||||
|
||||
if(iType == Scene::D3DBUFFEROBJ_VERTEX)
|
||||
{
|
||||
D3DVERTEXBUFFER_DESC VertexBufferDesc;
|
||||
((LPDIRECT3DVERTEXBUFFER8)lpBuffer)->GetDesc(&VertexBufferDesc);
|
||||
|
||||
if(VertexBufferDesc.Usage & D3DUSAGE_DYNAMIC)
|
||||
bDynamic = true;
|
||||
|
||||
if(bDynamic)
|
||||
{
|
||||
// <20>ִ밳<D6B4><EBB0B3> <20><><EFBFBD><EFBFBD>.
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(VertexBufferDesc.Size <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_DVertexBufferNums[i] >= iMaxPoolCount)
|
||||
{
|
||||
SafeRelease(lpBuffer);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20>ִ밳<D6B4><EBB0B3> <20><><EFBFBD><EFBFBD>
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(VertexBufferDesc.Size <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_SVertexBufferNums[i] >= iMaxPoolCount)
|
||||
{
|
||||
SafeRelease(lpBuffer);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CD3DBufferObj *pObj = new CD3DBufferObj;
|
||||
pObj->CreateBuffer(iType,VertexBufferDesc.Size,VertexBufferDesc.FVF,lpBuffer);
|
||||
|
||||
if(bDynamic)
|
||||
{
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(pObj->m_uiBufferSize <= ArrBufferSize[i])
|
||||
{
|
||||
m_DVertexBufferPools[i].push(pObj);
|
||||
m_DVertexBufferNums[i]++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_DCustomVertexBufferPools.push_back(pObj);
|
||||
m_DVertexBufferNums[D3DBUFFER_SIZENUM - 1]++;
|
||||
}
|
||||
else // Static Buffer
|
||||
{
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(pObj->m_uiBufferSize <= ArrBufferSize[i])
|
||||
{
|
||||
m_SVertexBufferPools[i].push(pObj);
|
||||
m_SVertexBufferNums[i]++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_SCustomVertexBufferPools.push_back(pObj);
|
||||
m_SVertexBufferNums[D3DBUFFER_SIZENUM - 1]++;
|
||||
}
|
||||
}
|
||||
else if(iType == Scene::D3DBUFFEROBJ_INDEX)
|
||||
{
|
||||
D3DINDEXBUFFER_DESC IndexBufferDesc;
|
||||
((LPDIRECT3DINDEXBUFFER8)lpBuffer)->GetDesc(&IndexBufferDesc);
|
||||
|
||||
if(IndexBufferDesc.Usage & D3DUSAGE_DYNAMIC)
|
||||
bDynamic = true;
|
||||
|
||||
if(bDynamic)
|
||||
{
|
||||
// <20>ִ밳<D6B4><EBB0B3> <20><><EFBFBD><EFBFBD>.
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(IndexBufferDesc.Size <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_DIndexBufferNums[i] >= iMaxPoolCount)
|
||||
{
|
||||
SafeRelease(lpBuffer);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20>ִ밳<D6B4><EBB0B3> <20><><EFBFBD><EFBFBD>
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(IndexBufferDesc.Size <= ArrBufferSize[i])
|
||||
{
|
||||
if(m_SIndexBufferNums[i] >= iMaxPoolCount)
|
||||
{
|
||||
SafeRelease(lpBuffer);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CD3DBufferObj *pObj = new CD3DBufferObj;
|
||||
pObj->CreateBuffer(iType,IndexBufferDesc.Size,IndexBufferDesc.Format,lpBuffer);
|
||||
|
||||
if(bDynamic)
|
||||
{
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(pObj->m_uiBufferSize <= ArrBufferSize[i])
|
||||
{
|
||||
m_DIndexBufferPools[i].push(pObj);
|
||||
m_DIndexBufferNums[i]++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_DCustomIndexBufferPools.push_back(pObj);
|
||||
m_DIndexBufferNums[D3DBUFFER_SIZENUM - 1]++;
|
||||
}
|
||||
else // Static
|
||||
{
|
||||
|
||||
for(int i = 0;i < D3DBUFFER_SIZENUM - 1; i++)
|
||||
{
|
||||
if(pObj->m_uiBufferSize <= ArrBufferSize[i])
|
||||
{
|
||||
m_SIndexBufferPools[i].push(pObj);
|
||||
m_SIndexBufferNums[i]++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_SCustomIndexBufferPools.push_back(pObj);
|
||||
m_SIndexBufferNums[D3DBUFFER_SIZENUM - 1]++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
LPDIRECT3DRESOURCE8 CD3DBufferPools::CreateBuffer(bool bDynamic,unsigned int iType,int iSizeType,DWORD dwValue,unsigned int uiCustomSize)
|
||||
{
|
||||
unsigned int uiSize = 0;
|
||||
|
||||
if(iSizeType >= 0)
|
||||
uiSize = ArrBufferSize[iSizeType];
|
||||
else
|
||||
uiSize = uiCustomSize;
|
||||
|
||||
if(iType == Scene::D3DBUFFEROBJ_VERTEX)
|
||||
{
|
||||
LPDIRECT3DVERTEXBUFFER8 lpVertex;
|
||||
|
||||
if(!bDynamic)
|
||||
{
|
||||
|
||||
// if(Caldron::Failed(CSceneManager::GetDevice()->CreateVertexBuffer(uiSize,D3DUSAGE_WRITEONLY,dwValue,D3DPOOL_DEFAULT,&lpVertex)))
|
||||
if(Caldron::Failed(CSceneManager::GetDevice()->CreateVertexBuffer(uiSize,D3DUSAGE_WRITEONLY,0,D3DPOOL_MANAGED,&lpVertex)))
|
||||
{
|
||||
MessageBox(NULL,"Buffer Create Faile(1)","Error",MB_OK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Caldron::Failed(CSceneManager::GetDevice()->CreateVertexBuffer(uiSize,D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC,0,D3DPOOL_DEFAULT,&lpVertex)))
|
||||
{
|
||||
MessageBox(NULL,"Buffer Create Faile(2)","Error",MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
return lpVertex;
|
||||
|
||||
}
|
||||
else if(iType == Scene::D3DBUFFEROBJ_INDEX)
|
||||
{
|
||||
LPDIRECT3DINDEXBUFFER8 lpIndex;
|
||||
if(!bDynamic)
|
||||
{
|
||||
if(Caldron::Failed(CSceneManager::GetDevice()->CreateIndexBuffer(uiSize,D3DUSAGE_WRITEONLY,(D3DFORMAT)dwValue,D3DPOOL_MANAGED,&lpIndex)))
|
||||
// if(Caldron::Failed(CSceneManager::GetDevice()->CreateIndexBuffer(uiSize,D3DUSAGE_WRITEONLY,(D3DFORMAT)dwValue,D3DPOOL_DEFAULT,&lpIndex)))
|
||||
{
|
||||
MessageBox(NULL,"Buffer Create Faile(3)","Error",MB_OK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(Caldron::Failed(CSceneManager::GetDevice()->CreateIndexBuffer(uiSize,D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC,(D3DFORMAT)dwValue,D3DPOOL_DEFAULT ,&lpIndex)))
|
||||
{
|
||||
MessageBox(NULL,"Buffer Create Faile(4)","Error",MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return lpIndex;
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
void CD3DBufferPools::InitBuffer()
|
||||
{
|
||||
int i,j;
|
||||
|
||||
for( i = 0; i < 8; i++ )
|
||||
{
|
||||
LPDIRECT3DVERTEXBUFFER8 lpVertexBuffer[80];
|
||||
LPDIRECT3DINDEXBUFFER8 lpIndexBuffer[80];
|
||||
|
||||
for( j = 0;j < 80; j++ )
|
||||
{
|
||||
if(j < 15)
|
||||
{
|
||||
lpVertexBuffer[j] = GetVertexBuffer(ArrBufferSize[i] - 10,0,false);
|
||||
lpIndexBuffer[j] = GetIndexBuffer(ArrBufferSize[i] - 10,D3DFMT_INDEX16,false);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpVertexBuffer[j] = GetVertexBuffer(ArrBufferSize[i] - 10,0,true);
|
||||
lpIndexBuffer[j] = GetIndexBuffer(ArrBufferSize[i] - 10,D3DFMT_INDEX16,true);
|
||||
}
|
||||
}
|
||||
for(j = 0;j < 80; j++ )
|
||||
{
|
||||
UnRef(D3DBUFFEROBJ_VERTEX,lpVertexBuffer[j]);
|
||||
UnRef(D3DBUFFEROBJ_INDEX,lpIndexBuffer[j]);
|
||||
lpVertexBuffer[j] = NULL;
|
||||
lpIndexBuffer[j] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < 5; i++ )
|
||||
{
|
||||
LPDIRECT3DVERTEXBUFFER8 lpCustomBuffer[5];
|
||||
lpCustomBuffer[0] = GetVertexBuffer(150000,0,true);
|
||||
lpCustomBuffer[1] = GetVertexBuffer(100000,0,true);
|
||||
lpCustomBuffer[2] = GetVertexBuffer(50000,0,true);
|
||||
lpCustomBuffer[3] = GetVertexBuffer(50000,0,true);
|
||||
lpCustomBuffer[4] = GetVertexBuffer(150000,0,true);
|
||||
for(j = 0; j < 5; j++ )
|
||||
{
|
||||
UnRef(D3DBUFFEROBJ_VERTEX,lpCustomBuffer[j]);
|
||||
lpCustomBuffer[j] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
90
Engine/Caldron/Src/Scene/D3DBufferPools.h
Normal file
90
Engine/Caldron/Src/Scene/D3DBufferPools.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#pragma once
|
||||
#include "../../include/Caldron.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Scene {
|
||||
enum D3DBUFFFEROBJ_TYPE
|
||||
{
|
||||
D3DBUFFEROBJ_VERTEX = 0,
|
||||
D3DBUFFEROBJ_INDEX,
|
||||
D3DBUFFEROBJ_TYPENUM,
|
||||
|
||||
};
|
||||
enum D3DBUFFER_SIZE
|
||||
{
|
||||
D3DBUFFER_SIZE1 = 0, // 100
|
||||
D3DBUFFER_SIZE2 = 1, // 250
|
||||
D3DBUFFER_SIZE3 = 2, // 500
|
||||
D3DBUFFER_SIZE4 = 3, // 1000
|
||||
D3DBUFFER_SIZE5 = 4, // 3000
|
||||
D3DBUFFER_SIZE6 = 5, // 7000
|
||||
D3DBUFFER_SIZE7 = 6, // 10000
|
||||
D3DBUFFER_SIZE8 = 7, // 20000
|
||||
D3DBUFFER_SIZE9 = 8, // Custom Buffer
|
||||
D3DBUFFER_SIZENUM = 9,
|
||||
|
||||
};
|
||||
// edith 2010.01.29 D3D <20><><EFBFBD><EFBFBD> ũ<><C5A9> <20><><EFBFBD><EFBFBD>
|
||||
const unsigned int ArrBufferSize[8] = {
|
||||
100,
|
||||
250,
|
||||
500,
|
||||
1000,
|
||||
3000,
|
||||
7000,
|
||||
10000,
|
||||
20000
|
||||
};
|
||||
class CD3DBufferObj
|
||||
{
|
||||
public:
|
||||
int m_iBufferObjType;
|
||||
LPDIRECT3DRESOURCE8 m_pBuffers;
|
||||
unsigned int m_uiBufferSize;
|
||||
DWORD m_dwValue;
|
||||
|
||||
|
||||
CD3DBufferObj() : m_pBuffers(NULL),m_uiBufferSize(0),m_dwValue(0){}
|
||||
~CD3DBufferObj()
|
||||
{
|
||||
//SafeRelease(m_pBuffers);
|
||||
m_pBuffers = NULL;
|
||||
}
|
||||
void NullBuffer();
|
||||
void CreateBuffer(int iType,unsigned int uiSize,DWORD dwDecl,LPDIRECT3DRESOURCE8 lpBuffer);
|
||||
|
||||
};
|
||||
|
||||
class CD3DBufferPools
|
||||
{
|
||||
public:
|
||||
CD3DBufferPools(void);
|
||||
~CD3DBufferPools(void);
|
||||
void InitBuffer();
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 GetVertexBuffer(unsigned int uiSize,DWORD dwDecl,bool bDynamic = false);
|
||||
LPDIRECT3DINDEXBUFFER8 GetIndexBuffer(unsigned int uiSize,DWORD dwFormat,bool bDynamic = false);
|
||||
void UnRef(unsigned int iType,LPDIRECT3DRESOURCE8 lpBuffer);
|
||||
|
||||
LPDIRECT3DRESOURCE8 CreateBuffer(bool bDynamic,unsigned int iType,int iSizeType,DWORD dwValue,unsigned int uiCustomSize = 0);
|
||||
// Dynamic Buffer
|
||||
std::queue<CD3DBufferObj *> m_DVertexBufferPools[D3DBUFFER_SIZENUM -1];
|
||||
std::vector<CD3DBufferObj *> m_DCustomVertexBufferPools;
|
||||
unsigned int m_DVertexBufferNums[D3DBUFFER_SIZENUM];
|
||||
|
||||
std::queue<CD3DBufferObj *> m_DIndexBufferPools[D3DBUFFER_SIZENUM -1];
|
||||
std::vector<CD3DBufferObj *> m_DCustomIndexBufferPools;
|
||||
unsigned int m_DIndexBufferNums[D3DBUFFER_SIZENUM];
|
||||
// Static Buffer
|
||||
std::queue<CD3DBufferObj *> m_SVertexBufferPools[D3DBUFFER_SIZENUM -1];
|
||||
std::vector<CD3DBufferObj *> m_SCustomVertexBufferPools;
|
||||
unsigned int m_SVertexBufferNums[D3DBUFFER_SIZENUM];
|
||||
|
||||
std::queue<CD3DBufferObj *> m_SIndexBufferPools[D3DBUFFER_SIZENUM -1];
|
||||
std::vector<CD3DBufferObj *> m_SCustomIndexBufferPools;
|
||||
unsigned int m_SIndexBufferNums[D3DBUFFER_SIZENUM];
|
||||
|
||||
};
|
||||
|
||||
|
||||
}}
|
||||
408
Engine/Caldron/Src/Scene/DrawElement.cpp
Normal file
408
Engine/Caldron/Src/Scene/DrawElement.cpp
Normal file
@@ -0,0 +1,408 @@
|
||||
#include "DrawElement.h"
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
namespace Scene
|
||||
{
|
||||
IDirect3DDevice8* CDrawElementMgr::ms_pDevice;
|
||||
|
||||
std::vector< DRAW_ELEMENT > CDrawElementMgr::ms_avecDynamicDrawElement[MAX_DRAW_ELEMENT_LAYER];
|
||||
// std::vector< DRAW_ELEMENT > CDrawElementMgr::ms_avecStaticDrawElement[MAX_DRAW_ELEMENT_LAYER];
|
||||
|
||||
int CDrawElementMgr::ms_nDynamicVertexBufferCount;
|
||||
DWORD CDrawElementMgr::ms_dwDynamicVertexBufferSize;
|
||||
|
||||
int CDrawElementMgr::ms_nDynamicIndexBufferCount;
|
||||
DWORD CDrawElementMgr::ms_dwDynamicIndexBufferSize;
|
||||
|
||||
// int CDrawElementMgr::ms_nStaticVertexBufferCount;
|
||||
// DWORD CDrawElementMgr::ms_dwStaticVertexBufferSize;
|
||||
|
||||
// int CDrawElementMgr::ms_nStaticIndexBufferCount;
|
||||
// DWORD CDrawElementMgr::ms_dwStaticIndexBufferSize;
|
||||
|
||||
// IDirect3DVertexBuffer8** CDrawElementMgr::ms_apDynamicVertexBuffer;
|
||||
// IDirect3DIndexBuffer8** CDrawElementMgr::ms_apDynaicIndexBuffer;
|
||||
IDirect3DVertexBuffer8* CDrawElementMgr::ms_pDynamicVertexBuffer;
|
||||
IDirect3DIndexBuffer8* CDrawElementMgr::ms_pDynamicIndexBuffer;
|
||||
|
||||
std::map< CBaseMesh*, UINT > CDrawElementMgr::ms_mapVBAllocationInfo;
|
||||
std::map< CBaseMesh*, UINT > CDrawElementMgr::ms_mapIBAllocationInfo;
|
||||
int CDrawElementMgr::ms_nVBUsedInByte;
|
||||
int CDrawElementMgr::ms_nIBUsedInByte;
|
||||
|
||||
|
||||
// IDirect3DVertexBuffer8** CDrawElementMgr::ms_apStaticVertexBuffer;
|
||||
// IDirect3DIndexBuffer8** CDrawElementMgr::ms_apStaticIndexBuffer;
|
||||
|
||||
DRAW_ELEMENT CDrawElementMgr::ms_LastTimeDE;
|
||||
|
||||
|
||||
bool CDrawElementMgr::_Init( IDirect3DDevice8* pDevice, DRAW_ELEMENT_MGR_INIT_PARAM* pInitParam )
|
||||
{
|
||||
ms_pDevice = pDevice;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
// dynamic VB <20>Ҵ<EFBFBD>
|
||||
hr = pDevice->CreateVertexBuffer( pInitParam->dwDynamicVertexBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||
0, D3DPOOL_DEFAULT, &ms_pDynamicVertexBuffer );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// dynamic IB <20>Ҵ<EFBFBD>
|
||||
hr = pDevice->CreateIndexBuffer( pInitParam->dwDynamicIndexBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||
D3DFMT_INDEX16, D3DPOOL_DEFAULT, &ms_pDynamicIndexBuffer );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// static VB <20>Ҵ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
// static IB <20>Ҵ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
ms_nDynamicVertexBufferCount = 1;//pInitParam->nDynamicVertexBufferCount;
|
||||
ms_dwDynamicVertexBufferSize = pInitParam->dwDynamicVertexBufferSize;
|
||||
|
||||
ms_nDynamicIndexBufferCount = 1;//pInitParam->nDynamicIndexBufferCount;
|
||||
ms_dwDynamicIndexBufferSize = pInitParam->dwDynamicIndexBufferSize;
|
||||
|
||||
|
||||
// ms_nStaticVertexBufferCount = pInitParam->nStaticVertexBufferCount;
|
||||
// ms_dwStaticVertexBufferSize = pInitParam->dwStaticVertexBufferSize;
|
||||
|
||||
// ms_nStaticIndexBufferCount = pInitParam->nStaticIndexBufferCount;
|
||||
// ms_dwStaticIndexBufferSize = pInitParam->dwStaticIndexBufferSize;
|
||||
|
||||
|
||||
ms_LastTimeDE.pMesh = NULL;
|
||||
ms_LastTimeDE.pTM = NULL;
|
||||
ms_LastTimeDE.pTextureTM = NULL;
|
||||
ms_LastTimeDE.textureSlot.apTexture[0] = NULL;
|
||||
ms_LastTimeDE.textureSlot.nUsed = 1;
|
||||
ms_LastTimeDE.hVertexShader = NULL;
|
||||
ms_LastTimeDE.hPixelShader = NULL;
|
||||
ms_LastTimeDE.pStateSet = NULL;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CDrawElementMgr::_RegisterDrawElement( int nLayer, DRAW_ELEMENT& rDE )
|
||||
{
|
||||
if( nLayer >= MAX_DRAW_ELEMENT_LAYER )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( false == rDE.ValidityCheck() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// D/E <20><> <20><><EFBFBD>ҵ鿡 <20><><EFBFBD><EFBFBD> lock <20><> <20>ʿ<EFBFBD><CABF>ҵ<EFBFBD>.. <20><EFBFBD><D7B7><EFBFBD> <20>̷<EFBFBD><CCB7><EFBFBD> <20>Ϸ<EFBFBD><CFB7><EFBFBD> <20><> <20><><EFBFBD>ҵ<EFBFBD> <20><><EFBFBD><EFBFBD> lockable <20><> <20><>ü<EFBFBD><C3BC> <20>ٲ<EFBFBD><D9B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
rDE.pMesh->Lock();
|
||||
|
||||
ms_avecDynamicDrawElement[nLayer].push_back( rDE );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// bool CDrawElementMgr::_RegisterStaticDrawElement( int nLayer, DRAW_ELEMENT& rDE )
|
||||
// {
|
||||
// //
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dynamic <20>϶<EFBFBD><CFB6><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ٲ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
||||
// //
|
||||
//
|
||||
// if( nLayer >= MAX_DRAW_ELEMENT_LAYER )
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// if( false ==rDE.ValidityCheck() )
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // D/E <20><> <20><><EFBFBD>ҵ鿡 <20><><EFBFBD><EFBFBD> lock <20><> <20>ʿ<EFBFBD><CABF>ҵ<EFBFBD>.. <20><EFBFBD><D7B7><EFBFBD> <20>̷<EFBFBD><CCB7><EFBFBD> <20>Ϸ<EFBFBD><CFB7><EFBFBD> <20><> <20><><EFBFBD>ҵ<EFBFBD> <20><><EFBFBD><EFBFBD> lockable <20><> <20><>ü<EFBFBD><C3BC> <20>ٲ<EFBFBD><D9B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
//
|
||||
// ms_avecDynamicDrawElement[nLayer].push_back( rDE );
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
void CDrawElementMgr::_Process()
|
||||
{
|
||||
VIB_PACKET packet;
|
||||
|
||||
// sort
|
||||
_Sort();
|
||||
|
||||
// optimize
|
||||
_Optimize();
|
||||
|
||||
|
||||
|
||||
for( int i = 0; i < MAX_DRAW_ELEMENT_LAYER; ++i )
|
||||
{
|
||||
// per-layer setting ( ex) Render Target Change )
|
||||
// render target, view matrix, projection matrix <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
|
||||
|
||||
std::vector< DRAW_ELEMENT > & rvecDE = ms_avecDynamicDrawElement[i]; // shortcut to i-th layer of D/E vector
|
||||
|
||||
for( int j = 0; j < rvecDE.size(); ++j )
|
||||
{
|
||||
DRAW_ELEMENT &rCurrentDrawElement = rvecDE[j];
|
||||
|
||||
// mesh data uploading (to VB/IB )
|
||||
_UploadMesh( rCurrentDrawElement, packet );
|
||||
|
||||
// draw primitive(include state setting)
|
||||
_Render( rCurrentDrawElement, packet );
|
||||
|
||||
// unlock D/E related components
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CMesh <20><> Lock/Unlock <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD>
|
||||
rCurrentDrawElement.pMesh->Unlock();
|
||||
}
|
||||
|
||||
// flush D/E list 'cause this is DYNAMIC D/E list
|
||||
rvecDE.clear();
|
||||
}
|
||||
|
||||
ms_pDevice->SetStreamSource( 0, NULL, 0 );
|
||||
ms_pDevice->SetIndices( NULL, 0 );
|
||||
}
|
||||
|
||||
void CDrawElementMgr::_Close()
|
||||
{
|
||||
// VB/IB <20><><EFBFBD><EFBFBD>
|
||||
SafeRelease( ms_pDynamicVertexBuffer );
|
||||
SafeRelease( ms_pDynamicIndexBuffer );
|
||||
}
|
||||
|
||||
// D/E sort comparison processor
|
||||
bool DE_Ascend( DRAW_ELEMENT rDE1, DRAW_ELEMENT rDE2 )
|
||||
{
|
||||
if( rDE1.textureSlot.apTexture[0] > rDE2.textureSlot.apTexture[0] ) return false;
|
||||
if( rDE1.pTM > rDE2.pTM ) return false;
|
||||
if( rDE1.hVertexShader > rDE2.hVertexShader ) return false;
|
||||
if( rDE1.hPixelShader > rDE2.hPixelShader ) return false;
|
||||
if( rDE1.pStateSet > rDE2.pStateSet ) return false;
|
||||
if( rDE1.pMesh > rDE2.pMesh ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CDrawElementMgr::_Sort()
|
||||
{
|
||||
for( int i = 0; i < MAX_DRAW_ELEMENT_LAYER; ++i )
|
||||
{
|
||||
std::stable_sort( ms_avecDynamicDrawElement[i].begin(), ms_avecDynamicDrawElement[i].end(), DE_Ascend );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDrawElementMgr::_Optimize()
|
||||
{
|
||||
// nothing now..
|
||||
}
|
||||
|
||||
|
||||
void CDrawElementMgr::_UploadMesh( DRAW_ELEMENT &rDE, VIB_PACKET &rPacket )
|
||||
{
|
||||
std::map< CBaseMesh*, UINT >::iterator it;
|
||||
BYTE* pByteDataInBuffer = NULL;
|
||||
UINT uSizeInByte; // <20>Ҵ<EFBFBD><D2B4><EFBFBD> mesh data <20><> byte <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
UINT uAllocOffset; // buffer <20><><EFBFBD><EFBFBD> upload <20><> <20><>ġ
|
||||
UINT uRemain; // buffer <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
HRESULT hr;
|
||||
|
||||
// VB <20><><EFBFBD><EFBFBD> <20>̹<EFBFBD> upload <20>Ǿ<EFBFBD><C7BE>ִ<EFBFBD> mesh <20>ΰ<EFBFBD>?
|
||||
it = ms_mapVBAllocationInfo.find( rDE.pMesh );
|
||||
if( it != ms_mapVBAllocationInfo.end() )
|
||||
{
|
||||
// <20><EFBFBD><D7B7>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VIB packet <20><> <20><><EFBFBD><EFBFBD>
|
||||
rPacket.uPositionInVB = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20>ƴϸ<C6B4> <20>Ҵ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DrawPrimitive <20>迭<EFBFBD><E8BFAD> offset <20><><EFBFBD><EFBFBD> <20>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD> vertex <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̹Ƿ<CCB9>
|
||||
// mesh vertex data<74><61> upload <20><> <20><><EFBFBD><EFBFBD> <20><> <20><>ġ<EFBFBD><C4A1> vertex size<7A><65> <20>°<EFBFBD> align
|
||||
// <20><> <20>ش<EFBFBD>.
|
||||
//
|
||||
|
||||
uSizeInByte = rDE.pMesh->GetVertexCount() * rDE.pMesh->GetVertexSize();
|
||||
|
||||
UINT uUsedAlignFixed = (ms_nVBUsedInByte % rDE.pMesh->GetVertexSize() ) ?
|
||||
( ( ms_nVBUsedInByte/rDE.pMesh->GetVertexSize() ) + 1 ) * rDE.pMesh->GetVertexSize() :
|
||||
ms_nVBUsedInByte; // vertex size <20><><EFBFBD>迡 <20><><EFBFBD><EFBFBD> <20>ø<EFBFBD>
|
||||
uRemain = ms_dwDynamicVertexBufferSize - uUsedAlignFixed;
|
||||
|
||||
// Lock VB
|
||||
if( uRemain < uSizeInByte )
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD> -> discard all & reset alloc info
|
||||
uAllocOffset = 0;
|
||||
hr = ms_pDynamicVertexBuffer->Lock( uAllocOffset, uSizeInByte, &pByteDataInBuffer, D3DLOCK_DISCARD );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
return; // Lock <20><><EFBFBD>н<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>..-_-
|
||||
}
|
||||
|
||||
// VB flush, <20>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD> clear
|
||||
ms_mapVBAllocationInfo.clear();
|
||||
ms_nVBUsedInByte = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD> -> <20><> Lock
|
||||
uAllocOffset = uUsedAlignFixed;
|
||||
hr = ms_pDynamicVertexBuffer->Lock( uAllocOffset, uSizeInByte, &pByteDataInBuffer, D3DLOCK_NOOVERWRITE );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
return; // Lock <20><><EFBFBD>н<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>..-_-
|
||||
}
|
||||
}
|
||||
|
||||
// upload, <20>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
rDE.pMesh->UploadVertexData( pByteDataInBuffer );
|
||||
ms_pDynamicVertexBuffer->Unlock();
|
||||
|
||||
ms_mapVBAllocationInfo[rDE.pMesh] = uAllocOffset;
|
||||
ms_nVBUsedInByte = uUsedAlignFixed + uSizeInByte;
|
||||
}
|
||||
|
||||
// indexed mesh <20><> <20>ƴϸ<C6B4> -> <20><><EFBFBD><EFBFBD>
|
||||
if( !( rDE.pMesh->IsIndexed() ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// IB <20><><EFBFBD><EFBFBD> VB <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ݺ<EFBFBD>
|
||||
|
||||
// IB <20><><EFBFBD><EFBFBD> <20>̹<EFBFBD> upload <20>Ǿ<EFBFBD><C7BE>ִ<EFBFBD> mesh <20>ΰ<EFBFBD>?
|
||||
it = ms_mapIBAllocationInfo.find( rDE.pMesh );
|
||||
if( it != ms_mapIBAllocationInfo.end() )
|
||||
{
|
||||
// <20><EFBFBD><D7B7>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VIB packet <20><> <20><><EFBFBD><EFBFBD>
|
||||
rPacket.uPositionInIB = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20>ƴϸ<C6B4> <20>Ҵ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
uSizeInByte = rDE.pMesh->GetIndexCount() * sizeof(WORD);
|
||||
uRemain = ms_dwDynamicIndexBufferSize - ms_nIBUsedInByte;
|
||||
|
||||
// Lock IB
|
||||
if( uRemain < uSizeInByte )
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD> -> discard all & reset alloc info
|
||||
uAllocOffset = 0;
|
||||
hr = ms_pDynamicIndexBuffer->Lock( uAllocOffset, uSizeInByte, &pByteDataInBuffer, D3DLOCK_DISCARD );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
return; // Lock <20><><EFBFBD>н<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>..-_-
|
||||
}
|
||||
|
||||
// IB flush, <20>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD> clear
|
||||
ms_mapIBAllocationInfo.clear();
|
||||
ms_nIBUsedInByte = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҷ<EFBFBD> -> <20><> Lock
|
||||
uAllocOffset = ms_nIBUsedInByte;
|
||||
hr = ms_pDynamicIndexBuffer->Lock( uAllocOffset, uSizeInByte, &pByteDataInBuffer, D3DLOCK_NOOVERWRITE );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
return; // Lock <20><><EFBFBD>н<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>..-_-
|
||||
}
|
||||
}
|
||||
|
||||
// upload, <20>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
rDE.pMesh->UploadIndexData( pByteDataInBuffer );
|
||||
ms_pDynamicIndexBuffer->Unlock();
|
||||
|
||||
ms_mapIBAllocationInfo[rDE.pMesh] = uAllocOffset;
|
||||
ms_nIBUsedInByte += uSizeInByte;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CDrawElementMgr::_Render( DRAW_ELEMENT &rDE, VIB_PACKET &rPacket )
|
||||
{
|
||||
// <20>ӽ<EFBFBD><D3BD>ڵ<EFBFBD>
|
||||
ms_pDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
||||
ms_pDevice->LightEnable( 0, TRUE );
|
||||
|
||||
|
||||
// ms_LastTimeDE <20><> rDE <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20><> <20>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
// rPacket <20><> VB/IB <20><> last time <20><> <20>ٸ<EFBFBD> <20><><EFBFBD><EFBFBD> stream source <20><> <20>ٲ<EFBFBD><D9B2><EFBFBD><EFBFBD><EFBFBD>..<2E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VB/IB <20><> <20>ϳ<EFBFBD><CFB3><EFBFBD><EFBFBD>̹Ƿ<CCB9> <20><><EFBFBD><EFBFBD>
|
||||
// ...<2E>Ϸ<EFBFBD><CFB7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, SSS<53><53> stride <20><> <20>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>ͷ<EFBFBD> <20><><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20>Ź<EFBFBD> <20><><EFBFBD>ִ°<D6B4><C2B0><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>-_-;
|
||||
ms_pDevice->SetStreamSource( 0, ms_pDynamicVertexBuffer, rDE.pMesh->GetVertexSize() );
|
||||
|
||||
ms_pDevice->SetTransform( D3DTS_WORLD, rDE.pTM );
|
||||
|
||||
if( NULL == rDE.hVertexShader )
|
||||
{
|
||||
DWORD dwFVF = rDE.pMesh->GetFVF();
|
||||
ms_pDevice->SetVertexShader( dwFVF );
|
||||
}
|
||||
else
|
||||
{
|
||||
ms_pDevice->SetVertexShader( rDE.hVertexShader );
|
||||
}
|
||||
ms_pDevice->SetPixelShader( rDE.hPixelShader );
|
||||
|
||||
if( NULL == rDE.textureSlot.apTexture[0] )
|
||||
{
|
||||
ms_pDevice->SetTexture( 0, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
ms_pDevice->SetTexture( 0, rDE.textureSlot.apTexture[0]->GetTexture() );
|
||||
}
|
||||
|
||||
|
||||
if( rDE.pMesh->IsIndexed() )
|
||||
{
|
||||
ms_pDevice->SetIndices( ms_pDynamicIndexBuffer, rPacket.uPositionInVB / rDE.pMesh->GetVertexSize() );
|
||||
|
||||
ms_pDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, rDE.pMesh->GetVertexCount(),
|
||||
rPacket.uPositionInIB / sizeof(WORD), rDE.pMesh->GetIndexCount() / 3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
ms_pDevice->DrawPrimitive( D3DPT_TRIANGLELIST, rPacket.uPositionInVB / rDE.pMesh->GetVertexSize(),
|
||||
rDE.pMesh->GetVertexCount()/3 );
|
||||
}
|
||||
|
||||
// last time <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
|
||||
ms_LastTimeDE = rDE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
186
Engine/Caldron/Src/Scene/DrawElement.h
Normal file
186
Engine/Caldron/Src/Scene/DrawElement.h
Normal file
@@ -0,0 +1,186 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning( disable : 4786 )
|
||||
#include "../../include/Caldron.h"
|
||||
|
||||
#include "Mesh.h"
|
||||
//#include "Texture.h"
|
||||
#include "NTexture.h"
|
||||
#include "StateSet.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> dynamic buffer <20><>, VB/IB <20><> 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>θ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
//
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
namespace Scene
|
||||
{
|
||||
const int MAX_DRAW_ELEMENT_LAYER = 5;
|
||||
const int MAX_TEXTURE_SLOT = 8;
|
||||
|
||||
struct TEXTURE_SLOT
|
||||
{
|
||||
//CTexture* apTexture[MAX_TEXTURE_SLOT];
|
||||
CROSSM::CNTexture* apTexture[MAX_TEXTURE_SLOT];
|
||||
int nUsed;
|
||||
|
||||
|
||||
TEXTURE_SLOT()
|
||||
{
|
||||
apTexture[0] = NULL;
|
||||
nUsed = 1;
|
||||
}
|
||||
/*
|
||||
TEXTURE_SLOT( int n, CTexture pt0, CTexture pt1 = NULL, CTexture pt2 = NULL, CTexture pt3 = NULL )
|
||||
{
|
||||
apTexture[0] = pt0;
|
||||
apTexture[1] = pt1;
|
||||
apTexture[2] = pt2;
|
||||
apTexture[3] = pt3;
|
||||
|
||||
nUsed = n;
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
|
||||
struct DRAW_ELEMENT
|
||||
{
|
||||
CBaseMesh* pMesh;
|
||||
D3DMATRIX* pTM;
|
||||
D3DMATRIX* pTextureTM;
|
||||
TEXTURE_SLOT textureSlot;
|
||||
DWORD hVertexShader;
|
||||
DWORD hPixelShader;
|
||||
CStateSet* pStateSet;
|
||||
|
||||
|
||||
|
||||
// VB/IB <20><> upload <20><> <20><>ġ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ͺκ<CDBA> <20>ʿ<EFBFBD>
|
||||
DRAW_ELEMENT() {}
|
||||
|
||||
|
||||
DRAW_ELEMENT( CBaseMesh* _pMesh, D3DMATRIX* _pTM, D3DMATRIX* _pTextureTM, TEXTURE_SLOT* _pTextureSlot, DWORD _hVertexShader, DWORD _hPixelShader, CStateSet* _pStateSet )
|
||||
{
|
||||
pMesh = _pMesh;
|
||||
pTM = _pTM;
|
||||
pTextureTM = _pTextureTM;
|
||||
textureSlot = *_pTextureSlot;
|
||||
hVertexShader = _hVertexShader;
|
||||
hPixelShader = _hPixelShader ;
|
||||
pStateSet = _pStateSet;
|
||||
}
|
||||
|
||||
bool ValidityCheck()
|
||||
{
|
||||
if( NULL == pMesh ) return false;
|
||||
//if( NULL == pTextureSlot ) return false;
|
||||
// VS, PS <20><><EFBFBD><EFBFBD> null <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if( NULL == pStateSet ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct DRAW_ELEMENT_MGR_INIT_PARAM
|
||||
{
|
||||
int nDynamicVertexBufferCount;
|
||||
DWORD dwDynamicVertexBufferSize;
|
||||
|
||||
int nDynamicIndexBufferCount;
|
||||
DWORD dwDynamicIndexBufferSize;
|
||||
|
||||
int nStaticVertexBufferCount;
|
||||
DWORD dwStaticVertexBufferSize;
|
||||
|
||||
int nStaticIndexBufferCount;
|
||||
DWORD dwStaticIndexBufferSize;
|
||||
};
|
||||
|
||||
struct VIB_PACKET
|
||||
{
|
||||
//IDirect3DVertexBuffer8* pVB;
|
||||
//IDirect3DIndexBuffer8* pIB;
|
||||
UINT uPositionInVB;
|
||||
UINT uPositionInIB;
|
||||
|
||||
VIB_PACKET()
|
||||
{
|
||||
uPositionInVB = 0;
|
||||
uPositionInIB = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CDrawElementMgr
|
||||
{
|
||||
public:
|
||||
// <20>ʱ<EFBFBD>ȭ( InitDevice <20><> <20>ʱ<EFBFBD>ȭ)
|
||||
static bool _Init( IDirect3DDevice8* pDevice, DRAW_ELEMENT_MGR_INIT_PARAM* pInitParam );
|
||||
|
||||
// Draw Element <20><><EFBFBD><EFBFBD>
|
||||
static bool _RegisterDrawElement( int nLayer, DRAW_ELEMENT& rDE );
|
||||
|
||||
// Static Draw Element <20><><EFBFBD><EFBFBD>
|
||||
// static bool _RegisterStaticDrawElement( int nLayer, DRAW_ELEMENT& rDE );
|
||||
|
||||
// register <20><> D/E <20><><EFBFBD><EFBFBD> sort <20>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD>ȭ<EFBFBD><C8AD> <20><> DrawPrimitive ȣ<><C8A3>
|
||||
static void _Process();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>( _Init <20><> pair )
|
||||
static void _Close();
|
||||
|
||||
private:
|
||||
static IDirect3DDevice8* ms_pDevice;
|
||||
|
||||
static std::vector< DRAW_ELEMENT > ms_avecDynamicDrawElement[MAX_DRAW_ELEMENT_LAYER];
|
||||
// static std::vector< DRAW_ELEMENT > ms_avecStaticDrawElement[MAX_DRAW_ELEMENT_LAYER];
|
||||
|
||||
static int ms_nDynamicVertexBufferCount;
|
||||
static DWORD ms_dwDynamicVertexBufferSize;
|
||||
|
||||
static int ms_nDynamicIndexBufferCount;
|
||||
static DWORD ms_dwDynamicIndexBufferSize;
|
||||
|
||||
|
||||
// static int ms_nStaticVertexBufferCount;
|
||||
// static DWORD ms_dwStaticVertexBufferSize;
|
||||
|
||||
// static int ms_nStaticIndexBufferCount;
|
||||
// static DWORD ms_dwStaticIndexBufferSize;
|
||||
|
||||
// static IDirect3DVertexBuffer8** ms_apDynamicVertexBuffer;
|
||||
// static IDirect3DIndexBuffer8** ms_apDynaicIndexBuffer;
|
||||
static IDirect3DVertexBuffer8* ms_pDynamicVertexBuffer;
|
||||
static IDirect3DIndexBuffer8* ms_pDynamicIndexBuffer;
|
||||
|
||||
// static IDirect3DVertexBuffer8** ms_apStaticVertexBuffer;
|
||||
// static IDirect3DIndexBuffer8** ms_apStaticIndexBuffer;
|
||||
|
||||
|
||||
static std::map< CBaseMesh*, UINT > ms_mapVBAllocationInfo;
|
||||
static std::map< CBaseMesh*, UINT > ms_mapIBAllocationInfo;
|
||||
static int ms_nVBUsedInByte;
|
||||
static int ms_nIBUsedInByte;
|
||||
|
||||
static DRAW_ELEMENT ms_LastTimeDE;
|
||||
|
||||
|
||||
// Process <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE>
|
||||
static void _Sort();
|
||||
static void _Optimize();
|
||||
static void _UploadMesh( DRAW_ELEMENT &rDE, VIB_PACKET &rPacket );
|
||||
static void _Render( DRAW_ELEMENT &rDE, VIB_PACKET &rPacket );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
192
Engine/Caldron/Src/Scene/Mesh.h
Normal file
192
Engine/Caldron/Src/Scene/Mesh.h
Normal file
@@ -0,0 +1,192 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning( disable : 4786 )
|
||||
#include "../../include/Caldron.h"
|
||||
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
namespace Scene
|
||||
{
|
||||
|
||||
class CBaseMesh
|
||||
{
|
||||
public:
|
||||
CBaseMesh()
|
||||
{
|
||||
m_nLockCount = 0;
|
||||
}
|
||||
|
||||
virtual ~CBaseMesh()
|
||||
{
|
||||
// m_nLockCount <20><> 0<><30> <20>ƴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD><DEBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD>.
|
||||
}
|
||||
|
||||
void Lock()
|
||||
{
|
||||
// thread safe code <20>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
|
||||
++m_nLockCount;
|
||||
}
|
||||
|
||||
void Unlock()
|
||||
{
|
||||
// thread safe code <20>ʿ<EFBFBD><CABF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
|
||||
if( m_nLockCount > 0 )
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD> lock count <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD><DEBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
--m_nLockCount;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsLocked()
|
||||
{
|
||||
return (m_nLockCount>0);
|
||||
}
|
||||
|
||||
// VB <20><> vertex <20><><EFBFBD><EFBFBD> upload <20><> <20><><EFBFBD><EFBFBD>
|
||||
virtual void UploadVertexData( void* p ) = 0;
|
||||
// IB <20><> index <20><><EFBFBD><EFBFBD> upload <20><> <20><><EFBFBD><EFBFBD>
|
||||
virtual void UploadIndexData( void* p ) = 0;
|
||||
|
||||
//
|
||||
virtual int GetVertexCount() = 0;
|
||||
virtual int GetIndexCount() = 0;
|
||||
|
||||
|
||||
virtual int GetVertexSize() = 0;
|
||||
virtual DWORD GetFVF() = 0;
|
||||
|
||||
|
||||
bool IsIndexed()
|
||||
{
|
||||
return m_bIndexed;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
int m_nLockCount;
|
||||
bool m_bIndexed;
|
||||
};
|
||||
|
||||
|
||||
template <class _T>
|
||||
class CMesh : public CBaseMesh
|
||||
{
|
||||
public:
|
||||
CMesh()
|
||||
{
|
||||
}
|
||||
|
||||
~CMesh()
|
||||
{
|
||||
}
|
||||
|
||||
// VB <20><> vertex <20><><EFBFBD><EFBFBD> upload <20><> <20><><EFBFBD><EFBFBD>
|
||||
void UploadVertexData( void* p )
|
||||
{
|
||||
if( 0 == m_vecVertexData.size() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveMemory( p, &(m_vecVertexData[0]), sizeof(_T) * m_vecVertexData.size() );
|
||||
}
|
||||
|
||||
// IB <20><> index <20><><EFBFBD><EFBFBD> upload <20><> <20><><EFBFBD><EFBFBD>
|
||||
void UploadIndexData( void* p )
|
||||
{
|
||||
if( 0 == m_vecIndexData.size() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
MoveMemory( p, &(m_vecIndexData[0]), sizeof(_T) * m_vecIndexData.size() );
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
int GetVertexCount()
|
||||
{
|
||||
return m_vecVertexData.size();
|
||||
}
|
||||
//
|
||||
int GetIndexCount()
|
||||
{
|
||||
return m_vecIndexData.size();
|
||||
}
|
||||
|
||||
|
||||
int GetVertexSize()
|
||||
{
|
||||
return sizeof( _T );
|
||||
}
|
||||
|
||||
DWORD GetFVF()
|
||||
{
|
||||
return _T::GetFVF();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// vertex <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>Ȯ<EFBFBD><C8AE>)
|
||||
void SetVertexCount( int n )
|
||||
{
|
||||
m_vecVertexData.resize( n );
|
||||
}
|
||||
|
||||
// <20>ش<EFBFBD> index <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD> Ȯ<><C8AE>)
|
||||
void SetIndexCount( int n )
|
||||
{
|
||||
m_vecIndexData.resize( n );
|
||||
|
||||
if( 0 == n )
|
||||
{
|
||||
m_bIndexed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bIndexed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
_T* GetVertexWritePtr()
|
||||
{
|
||||
if( IsLocked() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( 0 == m_vecVertexData.size() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_vecVertexData[0]);
|
||||
}
|
||||
|
||||
WORD* GetIndexWritePtr()
|
||||
{
|
||||
if( IsLocked() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( 0 == m_vecIndexData.size() )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_vecIndexData[0]);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::vector< _T > m_vecVertexData;
|
||||
std::vector< WORD > m_vecIndexData;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
Engine/Caldron/Src/Scene/StateSet.cpp
Normal file
11
Engine/Caldron/Src/Scene/StateSet.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "StateSet.h"
|
||||
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
namespace Scene
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
37
Engine/Caldron/Src/Scene/StateSet.h
Normal file
37
Engine/Caldron/Src/Scene/StateSet.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#pragma warning( disable : 4786 )
|
||||
#include "../../include/Caldron.h"
|
||||
|
||||
#include "Mesh.h"
|
||||
#include "Texture.h"
|
||||
|
||||
|
||||
namespace Caldron
|
||||
{
|
||||
namespace Scene
|
||||
{
|
||||
class CStateSet
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
|
||||
class CStateSetMgr
|
||||
{
|
||||
public:
|
||||
// <20>ʱ<EFBFBD>ȭ( InitDevice <20><> <20>ʱ<EFBFBD>ȭ)
|
||||
static bool _Init( IDirect3DDevice8* pDevice );
|
||||
|
||||
// StateSet Manager <20>ܺο<DCBA><CEBF><EFBFBD> d3d device <20><> <20><><EFBFBD><EFBFBD> <20>õ<EFBFBD><C3B5><EFBFBD> state change <20><><EFBFBD><EFBFBD> <20>˻<EFBFBD><CBBB><EFBFBD> device <20><> StateSet Mgr <20><> state<74><65> <20><><EFBFBD><EFBFBD>ȭ
|
||||
static void _GetCurrentDeviceState();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> StateSet <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> D3D Device <20><> <20><><EFBFBD><EFBFBD>
|
||||
static void _ApplyStateSet( CStateSet* pStateSet );
|
||||
|
||||
private:
|
||||
// <20><> state <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
};
|
||||
}
|
||||
}
|
||||
256
Engine/CrossM/CrossM.vcproj
Normal file
256
Engine/CrossM/CrossM.vcproj
Normal file
@@ -0,0 +1,256 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="CrossM"
|
||||
ProjectGUID="{540A7517-D29E-4835-8392-1922B8D53B7B}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CrossM.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CrossM.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_NoGD|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CrossM.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CrossM.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/CrossM.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Math"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\Include\MathConst.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\MathUtil.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Include\MathUtil.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Include\Vector3.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Scene"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\Src\CollisionEllipsoidHelper.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Include\CollisionEllipsoidHelper.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\OctreeCollider.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Include\OctreeCollider.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
193
Engine/CrossM/CrossM.vcxproj
Normal file
193
Engine/CrossM/CrossM.vcxproj
Normal file
@@ -0,0 +1,193 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug_MY|Win32">
|
||||
<Configuration>Debug_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_MY|Win32">
|
||||
<Configuration>Release_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_NoGD|Win32">
|
||||
<Configuration>Release_NoGD</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{540A7517-D29E-4835-8392-1922B8D53B7B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</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" />
|
||||
</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" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>./Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)CrossM.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)CrossM.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)CrossM.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)CrossM.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>./Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)CrossM.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Include\MathConst.h" />
|
||||
<ClInclude Include="Include\MathUtil.h" />
|
||||
<ClInclude Include="Include\Vector3.h" />
|
||||
<ClInclude Include="Include\CollisionEllipsoidHelper.h" />
|
||||
<ClInclude Include="Include\OctreeCollider.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Src\MathUtil.cpp" />
|
||||
<ClCompile Include="Src\CollisionEllipsoidHelper.cpp" />
|
||||
<ClCompile Include="Src\OctreeCollider.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
42
Engine/CrossM/CrossM.vcxproj.filters
Normal file
42
Engine/CrossM/CrossM.vcxproj.filters
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Math">
|
||||
<UniqueIdentifier>{1d328367-6680-4a76-8582-a7986b1ef097}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Scene">
|
||||
<UniqueIdentifier>{a57a23b6-3e84-4fbe-86a4-66cbe049b94b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Include\MathConst.h">
|
||||
<Filter>Math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Include\MathUtil.h">
|
||||
<Filter>Math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Include\Vector3.h">
|
||||
<Filter>Math</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Include\CollisionEllipsoidHelper.h">
|
||||
<Filter>Scene</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Include\OctreeCollider.h">
|
||||
<Filter>Scene</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Src\MathUtil.cpp">
|
||||
<Filter>Math</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\CollisionEllipsoidHelper.cpp">
|
||||
<Filter>Scene</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Src\OctreeCollider.cpp">
|
||||
<Filter>Scene</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
36
Engine/CrossM/Include/CollisionEllipsoidHelper.h
Normal file
36
Engine/CrossM/Include/CollisionEllipsoidHelper.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include "./Vector3.h"
|
||||
|
||||
|
||||
namespace CrossM{
|
||||
namespace Scene{
|
||||
|
||||
class CCollisionEllipsoidHelper{
|
||||
|
||||
public:
|
||||
CCollisionEllipsoidHelper();
|
||||
~CCollisionEllipsoidHelper();
|
||||
|
||||
void SetEllipsoidRadius(const Math::VECTOR3& vRadius);
|
||||
void SetHeightBias(float f);
|
||||
|
||||
// height bias <20><> <20><><EFBFBD>õ<EFBFBD> <20><>, <20><>ġ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ʒ<EFBFBD> <20><> <20><> <20>ƹ<EFBFBD><C6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γ<EFBFBD> <20><> <20><> <20>ִ<EFBFBD>
|
||||
void SetEllipsoidCenter(const Math::VECTOR3& vCenter);
|
||||
void SetPosition(const Math::VECTOR3& vPos);
|
||||
|
||||
const Math::VECTOR3& GetEllipsoidRadius();
|
||||
const Math::VECTOR3& GetEllipsoidCenter();
|
||||
Math::VECTOR3 GetPosition(); // client <20><><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ġ
|
||||
|
||||
|
||||
private:
|
||||
// <20>浹 Ÿ<><C5B8>ü<EFBFBD><C3BC> <20>߽ɰ<DFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Math::VECTOR3 m_vEllipoidCenter;
|
||||
Math::VECTOR3 m_vEllipsoidRaius;
|
||||
|
||||
// client <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF>ϴ<EFBFBD> <20>浹<EFBFBD><E6B5B9><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ÿ<><C5B8>ü <20>߽<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> bias<61><73>
|
||||
float m_fHeightBias;
|
||||
};
|
||||
|
||||
}}
|
||||
9
Engine/CrossM/Include/MathConst.h
Normal file
9
Engine/CrossM/Include/MathConst.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
namespace CrossM{
|
||||
namespace Math{
|
||||
|
||||
const float F_EPSILON = 1.0e-5f;
|
||||
const float F_PI = 3.1415926535f;
|
||||
|
||||
}}
|
||||
84
Engine/CrossM/Include/MathUtil.h
Normal file
84
Engine/CrossM/Include/MathUtil.h
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "./MathConst.h"
|
||||
#include "./Vector3.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CrossM{
|
||||
namespace Math{
|
||||
|
||||
|
||||
inline bool IsEquivalent(const float f1, const float f2, const float fEpsilon = F_EPSILON)
|
||||
{
|
||||
float d = f1 - f2;
|
||||
return (d < fEpsilon && d > -fEpsilon);
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
<09><> v <20><> boxMin, boxMax <20><> <20>ּ<EFBFBD>/<2F>ִ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AABB <20><> <20><><EFBFBD>ԵǴ<D4B5><C7B4><EFBFBD> <20><><EFBFBD>θ<EFBFBD> üũ
|
||||
|
||||
<09><><EFBFBD>Ե<EFBFBD> <20><><EFBFBD><EFBFBD> true, <20><EFBFBD><D7B7><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> false <20><>ȯ
|
||||
*/
|
||||
inline bool IsPointInAABB(const VECTOR3& vPoint, const VECTOR3& vAABBMin , const VECTOR3& vAABBMax)
|
||||
{
|
||||
if (vAABBMin.x <= vPoint.x && vPoint.x < vAABBMax.x &&
|
||||
vAABBMin.y <= vPoint.y && vPoint.y < vAABBMax.y &&
|
||||
vAABBMin.z <= vPoint.z && vPoint.z < vAABBMax.z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
f1Min ~ f1Max <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> f2Min ~ f2Max <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD> üũ
|
||||
<09><>, <20>ݵ<EFBFBD><DDB5><EFBFBD> f1Min <= f1Max, f2Min <= f2Max <20><><EFBFBD><EFBFBD> <20>Ѵ<EFBFBD>
|
||||
*/
|
||||
inline bool IsRangeOverlap(float f1Min, float f1Max, float f2Min, float f2Max)
|
||||
{
|
||||
if (f1Min <= f2Max && f2Min <= f1Max)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> AABB <20>ȿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ<D4B5><C7B4><EFBFBD> <20><><EFBFBD>θ<EFBFBD> Ȯ<><C8AE>
|
||||
bool IsTriangleInAabb(const VECTOR3& vAabbMin, const VECTOR3& vAabbMax, const VECTOR3& vTri0, const VECTOR3& vTri1, const VECTOR3& vTri2);
|
||||
|
||||
// AABB <20><> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> intersection <20><EFBFBD>Ʈ
|
||||
bool CheckAabbTriangleIntersection(const VECTOR3& vAabbMin, const VECTOR3& vAabbMax, const VECTOR3& vTri0, const VECTOR3& vTri1, const VECTOR3& vTri2);
|
||||
|
||||
// AABB <20><> AABB <20><> intersection <20><EFBFBD>Ʈ
|
||||
bool CheckAabbAabbIntersection(const VECTOR3& vAabb1Min, const VECTOR3& vAabb1Max, const VECTOR3& vAabb2Min, const VECTOR3& vAabb2Max);
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2>/Sweeping Sphere <20><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD> <20>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ü
|
||||
struct TriangSweepingSphere
|
||||
{
|
||||
Math::VECTOR3 m_vTri0;
|
||||
Math::VECTOR3 m_vTri1;
|
||||
Math::VECTOR3 m_vTri2;
|
||||
|
||||
Math::VECTOR3 m_vSphereSweepStart;
|
||||
Math::VECTOR3 m_vSphereSweepPath;
|
||||
float m_fSphereRadius;
|
||||
};
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> sweeping sphere <20><> <20>浹 <20><EFBFBD>Ʈ. <20>浹<EFBFBD><E6B5B9> <20><><EFBFBD><EFBFBD> <20>浹<EFBFBD><E6B5B9> <20>Ͼ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȯ<EFBFBD>Ѵ<EFBFBD>
|
||||
bool CheckTriangleSweepingSphereCollision(float &fOutT, VECTOR3& vOutContactPoint, bool& bOutContactInsideTriangle, const TriangSweepingSphere& triAndSphere);
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǾ<D4B5><C7BE>ִ<EFBFBD><D6B4><EFBFBD> Ȯ<><C8AE>
|
||||
bool IsPointInTriangle(const VECTOR3& vPoint, const VECTOR3& vTri0, const VECTOR3& vTri1, const VECTOR3& vTri2);
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
// <20>ӽÿ<D3BD> vector3 <20>迭<EFBFBD><E8BFAD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Լ<EFBFBD>
|
||||
template<class _T>
|
||||
void ConvVector3(CrossM::Math::VECTOR3& v, const _T& vOld)
|
||||
{
|
||||
v.SetValue(vOld.x, vOld.y, vOld.z);
|
||||
}
|
||||
137
Engine/CrossM/Include/OctreeCollider.h
Normal file
137
Engine/CrossM/Include/OctreeCollider.h
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
Collision detection + response <20><> ó<><C3B3><EFBFBD>ϴ<EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
<20>浹 <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> culling <20><> octree <20><> <20>̿<EFBFBD>
|
||||
|
||||
collision detection <20><> response <20>˰<EFBFBD><CBB0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Kasper Fauerby <20><>
|
||||
'Improved Collision detection and Response' <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>ڵ<EFBFBD><DAB5>̴<EFBFBD>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "./Vector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
// forward decl.
|
||||
struct IDirect3DDevice8;
|
||||
|
||||
|
||||
namespace CrossM{
|
||||
namespace Scene{
|
||||
|
||||
struct CollisionTriangleInfo
|
||||
{
|
||||
Math::VECTOR3 m_avVertex[3];
|
||||
// <20>ΰ<EFBFBD><CEB0><EFBFBD> <20><><EFBFBD><EFBFBD>..<2E≯<EFBFBD><CCB8><EFBFBD> <20><> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> id <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. <20><EFBFBD><D7B7><EFBFBD><EFBFBD><EFBFBD> <20>ʿ<EFBFBD><CABF>ҵ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ Ŭ<><C5AC><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>/<2F>Ͽ콺/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ)+<2B><> Ŭ<><C5AC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƮID(<28><> <20>Ͽ콺<CFBF><ECBDBA> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ)
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
|
||||
|
||||
Math::VECTOR3 m_vFaceNormal;
|
||||
};
|
||||
|
||||
// octree <20><> node. <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴ϶<C6B4> <20>ٱ<EFBFBD> <20><><EFBFBD>嵵 <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>ִ<EFBFBD>.
|
||||
// <20>ٿ<EFBFBD><D9BF><EFBFBD> <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ<D4B5> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20>ε<EFBFBD><CEB5><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD>ϵȴ<CFB5>.
|
||||
// (<28><><EFBFBD>迡 <20><>ġ<EFBFBD><C4A1> <20><> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>忡 <20><><EFBFBD>ϵ<EFBFBD>)
|
||||
class COctreeCollisionNode
|
||||
{
|
||||
public:
|
||||
COctreeCollisionNode();
|
||||
~COctreeCollisionNode();
|
||||
|
||||
// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
void ReleaseSubNode();
|
||||
|
||||
// leaf node <20><><EFBFBD><EFBFBD> üũ
|
||||
bool IsLeafNode();
|
||||
|
||||
// <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD>, <20>ڽ<EFBFBD><DABD><EFBFBD> <20><><EFBFBD>忡 <20><><EFBFBD>Ե<EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>л<EFBFBD><D0BB><EFBFBD>Ų<EFBFBD><C5B2>.
|
||||
// <20>ڱ<EFBFBD> <20>ڽ<EFBFBD><DABD><EFBFBD> <20><><EFBFBD>忡<EFBFBD><E5BFA1> <20>ٿ<EFBFBD><D9BF><EFBFBD><EFBFBD>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>õ<EFBFBD> <20><><EFBFBD>¿<EFBFBD><C2BF><EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
void BuildSubNode(
|
||||
const std::vector< CollisionTriangleInfo >& vecTriangle,
|
||||
const size_t nMaximumRecursion, const size_t nMinPolyCount,
|
||||
size_t nCurrentRecursionLevel);
|
||||
|
||||
|
||||
// <20>浹 <20><>ü<EFBFBD><C3BC> swept volume <20><> <20>ɸ<EFBFBD><C9B8><EFBFBD> <20>浹 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> vecCollidableNode <20><> <20><><EFBFBD><EFBFBD>
|
||||
void CollectCollidableNodes(
|
||||
const Math::VECTOR3& vSweptVolumeMin, const Math::VECTOR3& vSweptVolumeMax,
|
||||
std::vector< COctreeCollisionNode* >& vecCollidableNode);
|
||||
|
||||
Math::VECTOR3 m_vBoundingMin;
|
||||
Math::VECTOR3 m_vBoundingMax;
|
||||
std::vector< size_t > m_vecTriangleIndex;
|
||||
|
||||
COctreeCollisionNode* m_apSubNode[8];
|
||||
};
|
||||
|
||||
|
||||
class COctreeCollider
|
||||
{
|
||||
public:
|
||||
COctreeCollider();
|
||||
~COctreeCollider();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Octree Build <20><><EFBFBD><EFBFBD> <20>ҵ<DEBC>
|
||||
|
||||
/*
|
||||
<09>浹 <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
<09>浹 <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ҵ<EFBFBD><D2B4>ǰ<EFBFBD>, octree <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ı<EFBFBD><C4B1>ȴ<EFBFBD>.
|
||||
BuildOctree() <20><> ȣ<><C8A3><EFBFBD>DZ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> COctreeCollider <20><> <20><><EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´<CAB4>
|
||||
*/
|
||||
void SetTriangleCount(unsigned int uiTriangleCount);
|
||||
|
||||
/*
|
||||
<09>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȯ.
|
||||
<09><> <20>ҵ带 ȣ<><C8A3><EFBFBD>ϸ<EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ȱ<EFBFBD><C8B0><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>, octree <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ı<EFBFBD><C4B1>ȴ<EFBFBD>.
|
||||
BuildOctree() <20><> ȣ<><C8A3><EFBFBD>DZ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> COctreeCollider <20><> <20><><EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><DBB5><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´<CAB4>
|
||||
*/
|
||||
void GetTriangleDataPtr(CollisionTriangleInfo*& pTriangleData);
|
||||
|
||||
// <20><><EFBFBD>õ<EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ʷ<EFBFBD> octree <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
bool BuildOctree(const size_t nMaximumRecursion, const size_t nMinPolyCount);
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// <20>浹<EFBFBD><E6B5B9><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20>ҵ<DEBC>
|
||||
|
||||
/*
|
||||
<09>־<EFBFBD><D6BE><EFBFBD> Ÿ<><C5B8>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD> <20><>ġ(prevPos)<29><> <20>̵<EFBFBD><CCB5><EFBFBD> <20><>ġ(nextPos) <20><> <20>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>ͷ<EFBFBD> <20>ѱ<EFBFBD><D1B1><EFBFBD>,
|
||||
<09>浹<EFBFBD><E6B5B9> üũ<C3BC>ϰ<EFBFBD> <20>浹<EFBFBD><E6B5B9> <20>Ͼ<CFBE><EEB3B5> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̵<EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><>ȯ<EFBFBD>Ѵ<EFBFBD>.
|
||||
*/
|
||||
void GetCollisionRespondingPosition(
|
||||
Math::VECTOR3& vRespondingPos,
|
||||
const Math::VECTOR3& vPrevPos, const Math::VECTOR3& vNewPos,
|
||||
const Math::VECTOR3& vEllipsoidRadius,
|
||||
const unsigned int nRecursionLevel = 1);
|
||||
|
||||
|
||||
// <20><EFBFBD>Ʈ<EFBFBD><C6AE> <20>ҵ<DEBC>, <20>浹<EFBFBD><E6B5B9> <20>Ͼ <20><> <20>ִ°<D6B4><C2B0><EFBFBD><EFBFBD><EFBFBD> Ȯ<>ε<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
void RenderCollidableNodeTriangles(IDirect3DDevice8* pDevice);
|
||||
|
||||
|
||||
private:
|
||||
std::vector< CollisionTriangleInfo > m_vecCollisionTriangle;
|
||||
|
||||
Math::VECTOR3 m_vCollisionBoundingMin;
|
||||
Math::VECTOR3 m_vCollisionBoundingMax;
|
||||
|
||||
COctreeCollisionNode m_octreeRootNode;
|
||||
|
||||
|
||||
// <20>ӽÿ<D3BD>, <20>浹<EFBFBD><E6B5B9> <20>Ͼ <20><> <20>ִ°<D6B4><C2B0><EFBFBD><EFBFBD><EFBFBD> Ȯ<>ε<EFBFBD> leaf <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::vector< COctreeCollisionNode* > m_vecpCollidableNode;
|
||||
|
||||
// <20>ӽÿ<D3BD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ؽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::vector< Math::VECTOR3 > m_vecRenderVertex;
|
||||
|
||||
// <20>ӽÿ<D3BD>. <20>浹<EFBFBD><E6B5B9> <20>Ͼ <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD>
|
||||
size_t m_nColTriIndex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
}}
|
||||
216
Engine/CrossM/Include/Vector3.h
Normal file
216
Engine/CrossM/Include/Vector3.h
Normal file
@@ -0,0 +1,216 @@
|
||||
#pragma once
|
||||
|
||||
#include "./MathConst.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
namespace CrossM{
|
||||
namespace Math{
|
||||
|
||||
struct VECTOR3
|
||||
{
|
||||
VECTOR3() {}
|
||||
~VECTOR3() {}
|
||||
|
||||
VECTOR3(const float _x, const float _y, const float _z) : x(_x), y(_y), z(_z) {}
|
||||
|
||||
VECTOR3(const VECTOR3& v) : x(v.x), y(v.y), z(v.z) {}
|
||||
|
||||
void SetValue(const float _x, const float _y, const float _z)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
}
|
||||
|
||||
float x, y, z;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline VECTOR3& SetZeroVector(VECTOR3& v)
|
||||
{
|
||||
v.x = v.y = v.z = 0.0f;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD>Ϳ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
inline VECTOR3& SetValue(VECTOR3& vOut, const float x, const float y, const float z)
|
||||
{
|
||||
vOut.x = x;
|
||||
vOut.y = y;
|
||||
vOut.z = z;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD≯<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
inline float GetLength(const VECTOR3& v)
|
||||
{
|
||||
return sqrtf(v.x*v.x + v.y*v.y + v.z*v.z);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
inline float GetSquaredLength(const VECTOR3& v)
|
||||
{
|
||||
return v.x*v.x + v.y*v.y + v.z*v.z;
|
||||
}
|
||||
|
||||
// Normalize
|
||||
inline VECTOR3& Normalize(VECTOR3& vOut, const VECTOR3& vIn)
|
||||
{
|
||||
float fLen = GetLength(vIn);
|
||||
if (fLen < F_EPSILON)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>̰<EFBFBD> 0<><30> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD> x<><78><EFBFBD><EFBFBD><EFBFBD>⺤<EFBFBD><E2BAA4>
|
||||
SetValue(vOut, 1.0f, 0.0f, 0.0f);
|
||||
return vOut;
|
||||
}
|
||||
|
||||
float fInv = 1.0f / fLen;
|
||||
vOut.x = vIn.x * fInv;
|
||||
vOut.y = vIn.y * fInv;
|
||||
vOut.z = vIn.z * fInv;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
// vOut = -vIn;
|
||||
inline VECTOR3& Negate(VECTOR3& vOut, const VECTOR3& vIn)
|
||||
{
|
||||
vOut.x = -vIn.x;
|
||||
vOut.y = -vIn.y;
|
||||
vOut.z = -vIn.z;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
// vOut = fScale x vIn
|
||||
inline VECTOR3& Scale(VECTOR3& vOut, const VECTOR3& vIn, const float fScale)
|
||||
{
|
||||
vOut.x = vIn.x * fScale;
|
||||
vOut.y = vIn.y * fScale;
|
||||
vOut.z = vIn.z * fScale;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
// vOut = v1 + v2
|
||||
inline VECTOR3& Add(VECTOR3& vOut, const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
vOut.x = v1.x + v2.x;
|
||||
vOut.y = v1.y + v2.y;
|
||||
vOut.z = v1.z + v2.z;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
// vOut = v1 - v2
|
||||
inline VECTOR3& Subtract(VECTOR3& vOut, const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
vOut.x = v1.x - v2.x;
|
||||
vOut.y = v1.y - v2.y;
|
||||
vOut.z = v1.z - v2.z;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
// v1 <20><> v2 <20><> <20><><EFBFBD><EFBFBD>.
|
||||
inline float DotProduct(const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
|
||||
}
|
||||
|
||||
// v1 <20><> v2 <20><> <20><><EFBFBD><EFBFBD>. vOut = v1 x v2
|
||||
inline VECTOR3& CrossProduct(VECTOR3& vOut, const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
VECTOR3 vTmp; // vOut <20><> v1 <20>̳<EFBFBD> v2 <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ӽú<D3BD><C3BA><EFBFBD>
|
||||
|
||||
vTmp.x = v1.y*v2.z - v1.z*v2.y;
|
||||
vTmp.y = v1.z*v2.x - v1.x*v2.z;
|
||||
vTmp.z = v1.x*v2.y - v1.y*v2.x;
|
||||
|
||||
vOut = vTmp;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
// v1 <20><><EFBFBD><EFBFBD> v2 <20><> <20><><EFBFBD><EFBFBD> f<><66>ŭ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ȭ<EFBFBD><C8AD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
inline VECTOR3& Lerp(VECTOR3& vOut, const VECTOR3& v1, const VECTOR3& v2, const float f)
|
||||
{
|
||||
float fRem = 1.0f - f;
|
||||
vOut.x = v1.x*fRem + v2.x*f;
|
||||
vOut.y = v1.y*fRem + v2.y*f;
|
||||
vOut.z = v1.z*fRem + v2.z*f;
|
||||
|
||||
return vOut;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
inline VECTOR3 operator - (const VECTOR3& v)
|
||||
{
|
||||
VECTOR3 vRet;
|
||||
|
||||
return Negate(vRet, v);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
inline VECTOR3 operator + (const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
VECTOR3 vRet;
|
||||
|
||||
return Add(vRet, v1, v2);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
inline VECTOR3 operator - (const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
VECTOR3 vRet;
|
||||
|
||||
return Subtract(vRet, v1, v2);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><>Į<EFBFBD><C4AE><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
|
||||
inline VECTOR3 operator * (const float f, const VECTOR3& v)
|
||||
{
|
||||
VECTOR3 vRet;
|
||||
|
||||
return Scale(vRet, v, f);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><>Į<EFBFBD><C4AE><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><CDB8><EFBFBD>)
|
||||
inline VECTOR3 operator * (const VECTOR3& v, const float f)
|
||||
{
|
||||
VECTOR3 vRet;
|
||||
|
||||
return Scale(vRet, v, f);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><>Į<EFBFBD><C4AE><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
inline VECTOR3 operator / (const VECTOR3& v, const float& f)
|
||||
{
|
||||
VECTOR3 vRet;
|
||||
|
||||
return Scale(vRet, v, 1.0f/f);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
inline float operator * (const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
return DotProduct(v1, v2);
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
inline VECTOR3 operator ^ (const VECTOR3& v1, const VECTOR3& v2)
|
||||
{
|
||||
VECTOR3 vRet;
|
||||
|
||||
return CrossProduct(vRet, v1, v2);
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
21
Engine/CrossM/ReadMe.txt
Normal file
21
Engine/CrossM/ReadMe.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
========================================================================
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺귯<CCBA><EAB7AF> : CrossM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
========================================================================
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><> CrossM <20><><EFBFBD>̺귯<CCBA><EAB7AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.
|
||||
|
||||
|
||||
CrossM.vcproj
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>縦 <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC++ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>⺻ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
<20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Visual C++<2B><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>ɿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
<EFBFBD><EFBFBD>Ÿ <20><><EFBFBD><EFBFBD>:
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> "TODO:" <20>ּ<EFBFBD><D6BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD> <20>߰<EFBFBD><DFB0>ϰų<CFB0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>ϴ<EFBFBD>
|
||||
<EFBFBD>ҽ<EFBFBD> <20>ڵ<EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
56
Engine/CrossM/Src/CollisionEllipsoidHelper.cpp
Normal file
56
Engine/CrossM/Src/CollisionEllipsoidHelper.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "../Include/CollisionEllipsoidHelper.h"
|
||||
|
||||
|
||||
namespace CrossM{
|
||||
namespace Scene{
|
||||
|
||||
CCollisionEllipsoidHelper::CCollisionEllipsoidHelper()
|
||||
{
|
||||
m_vEllipoidCenter.SetValue(0,0,0);
|
||||
m_vEllipsoidRaius.SetValue(1,1,1);
|
||||
|
||||
m_fHeightBias = 0.0f;
|
||||
}
|
||||
|
||||
CCollisionEllipsoidHelper::~CCollisionEllipsoidHelper()
|
||||
{
|
||||
}
|
||||
|
||||
void CCollisionEllipsoidHelper::SetEllipsoidRadius(const Math::VECTOR3& vRadius)
|
||||
{
|
||||
m_vEllipsoidRaius = vRadius;
|
||||
}
|
||||
|
||||
void CCollisionEllipsoidHelper::SetHeightBias(float f)
|
||||
{
|
||||
m_fHeightBias = f;
|
||||
}
|
||||
|
||||
void CCollisionEllipsoidHelper::SetEllipsoidCenter(const Math::VECTOR3& vCenter)
|
||||
{
|
||||
m_vEllipoidCenter = vCenter;
|
||||
}
|
||||
|
||||
void CCollisionEllipsoidHelper::SetPosition(const Math::VECTOR3& vPos)
|
||||
{
|
||||
m_vEllipoidCenter.SetValue(vPos.x, vPos.y-m_fHeightBias, vPos.z);
|
||||
}
|
||||
|
||||
const Math::VECTOR3& CCollisionEllipsoidHelper::GetEllipsoidRadius()
|
||||
{
|
||||
return m_vEllipsoidRaius;
|
||||
}
|
||||
|
||||
const Math::VECTOR3& CCollisionEllipsoidHelper::GetEllipsoidCenter()
|
||||
{
|
||||
return m_vEllipoidCenter;
|
||||
}
|
||||
|
||||
|
||||
Math::VECTOR3 CCollisionEllipsoidHelper::GetPosition()
|
||||
{
|
||||
return Math::VECTOR3(m_vEllipoidCenter.x, m_vEllipoidCenter.y+m_fHeightBias, m_vEllipoidCenter.z);
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
419
Engine/CrossM/Src/MathUtil.cpp
Normal file
419
Engine/CrossM/Src/MathUtil.cpp
Normal file
@@ -0,0 +1,419 @@
|
||||
#include "../Include/MathUtil.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace CrossM{
|
||||
namespace Math{
|
||||
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> AABB <20>ȿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ<D4B5><C7B4><EFBFBD> <20>˻<EFBFBD>
|
||||
bool IsTriangleInAabb(const VECTOR3& vAabbMin, const VECTOR3& vAabbMax, const VECTOR3& vTri0, const VECTOR3& vTri1, const VECTOR3& vTri2)
|
||||
{
|
||||
if (vAabbMin.x <= vTri0.x && vTri0.x <= vAabbMax.x &&
|
||||
vAabbMin.y <= vTri0.y && vTri0.y <= vAabbMax.y &&
|
||||
vAabbMin.z <= vTri0.z && vTri0.z <= vAabbMax.z &&
|
||||
vAabbMin.x <= vTri1.x && vTri1.x <= vAabbMax.x &&
|
||||
vAabbMin.y <= vTri1.y && vTri1.y <= vAabbMax.y &&
|
||||
vAabbMin.z <= vTri1.z && vTri1.z <= vAabbMax.z &&
|
||||
vAabbMin.x <= vTri2.x && vTri2.x <= vAabbMax.x &&
|
||||
vAabbMin.y <= vTri2.y && vTri2.y <= vAabbMax.y &&
|
||||
vAabbMin.z <= vTri2.z && vTri2.z <= vAabbMax.z)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> AABB <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˻<EFBFBD>
|
||||
bool CheckAabbTriangleIntersection(const VECTOR3& vAabbMin, const VECTOR3& vAabbMax, const VECTOR3& vTri0, const VECTOR3& vTri1, const VECTOR3& vTri2)
|
||||
{
|
||||
// Separation of Axes <20><> <20><><EFBFBD><EFBFBD> AABB - triangle intersection test <20><><EFBFBD><EFBFBD>
|
||||
|
||||
// 6 <20> <20><><EFBFBD><EFBFBD> AABB <20><> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> projection <20><> <20><>, <20><><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD> <20><><EFBFBD>θ<EFBFBD> Ȯ<><C8AE><EFBFBD>Ѵ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>°<EFBFBD><C2B0>̰<EFBFBD>, <20><> <20> <20><><EFBFBD>ؼ<EFBFBD><D8BC><EFBFBD><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20>ʴ´ٸ<C2B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ<EFBFBD> <20><><EFBFBD>̴<EFBFBD>
|
||||
|
||||
float fBoxProjectionMin, fBoxProjectionMax;
|
||||
float fTriProjectionMin, fTriProjectionMax;
|
||||
|
||||
// AABB <20><> <20><> <20> <20><><EFBFBD><EFBFBD> projection <20><> <20>˻<EFBFBD>
|
||||
|
||||
// X <20><>
|
||||
fBoxProjectionMin = vAabbMin.x;
|
||||
fBoxProjectionMax = vAabbMax.x;
|
||||
fTriProjectionMin = std::min(vTri0.x, std::min(vTri1.x, vTri2.x));
|
||||
fTriProjectionMax = std::max(vTri0.x, std::max(vTri1.x, vTri2.x));
|
||||
if (false == IsRangeOverlap(fTriProjectionMin, fTriProjectionMax, fBoxProjectionMin, fBoxProjectionMax))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Y <20><>
|
||||
fBoxProjectionMin = vAabbMin.y;
|
||||
fBoxProjectionMax = vAabbMax.y;
|
||||
fTriProjectionMin = std::min(vTri0.y, std::min(vTri1.y, vTri2.y));
|
||||
fTriProjectionMax = std::max(vTri0.y, std::max(vTri1.y, vTri2.y));
|
||||
if (false == IsRangeOverlap(fTriProjectionMin, fTriProjectionMax, fBoxProjectionMin, fBoxProjectionMax))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Z <20><>
|
||||
fBoxProjectionMin = vAabbMin.z;
|
||||
fBoxProjectionMax = vAabbMax.z;
|
||||
fTriProjectionMin = std::min(vTri0.z, std::min(vTri1.z, vTri2.z));
|
||||
fTriProjectionMax = std::max(vTri0.z, std::max(vTri1.z, vTri2.z));
|
||||
if (false == IsRangeOverlap(fTriProjectionMin, fTriProjectionMax, fBoxProjectionMin, fBoxProjectionMax))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><> <20><> <20> <20><><EFBFBD><EFBFBD> projection <20><> <20>˻<EFBFBD>
|
||||
VECTOR3 avAxis[3]; // <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><> <20><EFBFBD>
|
||||
Math::Subtract(avAxis[0], vTri1, vTri0);
|
||||
Math::Subtract(avAxis[1], vTri2, vTri0);
|
||||
Math::Subtract(avAxis[2], vTri2, vTri1);
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> <20><> <20><><EFBFBD><EFBFBD> <20> projection <20><> <20><>
|
||||
float fProjectionTri0, fProjectionTri1, fProjectionTri2;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
VECTOR3& vAxis = avAxis[i];
|
||||
|
||||
// AABB <20><> max/min <20><><EFBFBD><EFBFBD> xyz <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD>/<2F>ּҰ<D6BC><D2B0>̹Ƿ<CCB9>,
|
||||
// axis <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ밪<D6B4><EBB0AA> <20><><EFBFBD>Ϸ<EFBFBD><CFB7><EFBFBD>
|
||||
// x,y,z <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ū <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ϸ<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
// (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> AABB <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> xyz <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD>/<2F>ּҰ<D6BC><D2B0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̹Ƿ<CCB9>,
|
||||
// x,y,z <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>Ƿ<EFBFBD> <20>ִ<EFBFBD>/<2F>ּҸ<D6BC> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD> <20>ص<EFBFBD> <20><><EFBFBD>h <20><> <20>ȿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ<D4B5> <20><><EFBFBD><EFBFBD><EFBFBD>̴<EFBFBD>.)
|
||||
|
||||
fBoxProjectionMin =
|
||||
((vAxis.x > 0) ? vAabbMin.x : vAabbMax.x) * vAxis.x +
|
||||
((vAxis.y > 0) ? vAabbMin.y : vAabbMax.y) * vAxis.y +
|
||||
((vAxis.z > 0) ? vAabbMin.z : vAabbMax.z) * vAxis.z;
|
||||
|
||||
fBoxProjectionMax =
|
||||
((vAxis.x > 0) ? vAabbMax.x : vAabbMin.x) * vAxis.x +
|
||||
((vAxis.y > 0) ? vAabbMax.y : vAabbMin.y) * vAxis.y +
|
||||
((vAxis.z > 0) ? vAabbMax.z : vAabbMin.z) * vAxis.z;
|
||||
|
||||
fProjectionTri0 = Math::DotProduct(vTri0, vAxis);
|
||||
fProjectionTri1 = Math::DotProduct(vTri1, vAxis);
|
||||
fProjectionTri2 = Math::DotProduct(vTri2, vAxis);
|
||||
|
||||
fTriProjectionMin = std::min(fProjectionTri0, std::min(fProjectionTri1, fProjectionTri2));
|
||||
fTriProjectionMax = std::max(fProjectionTri0, std::max(fProjectionTri1, fProjectionTri2));
|
||||
|
||||
if (false == IsRangeOverlap(fTriProjectionMin, fTriProjectionMax, fBoxProjectionMin, fBoxProjectionMax))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// <20><> AABB <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˻<EFBFBD>
|
||||
bool CheckAabbAabbIntersection(const VECTOR3& vAabb1Min, const VECTOR3& vAabb1Max, const VECTOR3& vAabb2Min, const VECTOR3& vAabb2Max)
|
||||
{
|
||||
if (false ==IsRangeOverlap(vAabb1Min.x, vAabb1Max.x, vAabb2Min.x, vAabb2Max.x)) return false;
|
||||
if (false ==IsRangeOverlap(vAabb1Min.y, vAabb1Max.y, vAabb2Min.y, vAabb2Max.y)) return false;
|
||||
if (false ==IsRangeOverlap(vAabb1Min.z, vAabb1Max.z, vAabb2Min.z, vAabb2Max.z)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// CheckTriangleSweepingSphereCollision <20><> <20>μ<EFBFBD> <20>Լ<EFBFBD>.
|
||||
// ax^2 + bx + c <20><> <20><> <20><> min~max <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ظ<EFBFBD> <20><>ȯ<EFBFBD>Ѵ<EFBFBD>. <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>ذ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> false <20><>ȯ
|
||||
static bool GetLowestRootInRange(const float a, const float b, const float c, const float fMinRoot, const float fMaxRoot, float& fRoot)
|
||||
{
|
||||
// <20>Ǽ<EFBFBD><C7BC>ذ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4><EFBFBD> <20>Ǻ<EFBFBD><C7BA><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
float fDeterminant = b*b - 4.0f*a*c;
|
||||
|
||||
// <20>Ǽ<EFBFBD><C7BC>ذ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
||||
if (fDeterminant < 0.0f) return false;
|
||||
|
||||
// <20>ΰ<EFBFBD><CEB0><EFBFBD> <20>ظ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>
|
||||
float fSqrtD = sqrtf(fDeterminant);
|
||||
float r1 = (-b - fSqrtD) / (2*a);
|
||||
float r2 = (-b + fSqrtD) / (2*a);
|
||||
|
||||
// r1 < r2 <20><> ũ<>Ⱑ <20>ǵ<EFBFBD><C7B5><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if (r1 > r2) std::swap(r1, r2);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD>ʺ<EFBFBD><CABA><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ǻ<EFBFBD><C7BA><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD><CFB0><EFBFBD> <20>طμ<D8B7> <20><><EFBFBD><EFBFBD>
|
||||
if (r1 > fMinRoot && r1 < fMaxRoot)
|
||||
{
|
||||
fRoot = r1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, ū <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>˻<EFBFBD><CBBB>Ѵ<EFBFBD>
|
||||
if (r2 > fMinRoot && r2 < fMaxRoot)
|
||||
{
|
||||
fRoot = r2;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool CheckTriangleSweepingSphereCollision(float &fOutT, VECTOR3& vOutContactPoint, bool& bOutContactInsideTriangle, const TriangSweepingSphere& triAndSphere)
|
||||
{
|
||||
// <20>ణ<EFBFBD><E0B0A3> alias
|
||||
const Math::VECTOR3 &vBasePoint = triAndSphere.m_vSphereSweepStart;
|
||||
const Math::VECTOR3 &vTri0 = triAndSphere.m_vTri0;
|
||||
const Math::VECTOR3 &vTri1 = triAndSphere.m_vTri1;
|
||||
const Math::VECTOR3 &vTri2 = triAndSphere.m_vTri2;
|
||||
const Math::VECTOR3 &vPath = triAndSphere.m_vSphereSweepPath;
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><> <20><EFBFBD>
|
||||
Math::VECTOR3 vTriEdge01, vTriEdge02, vTriEdge12;
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD>. <20><><EFBFBD><EFBFBD> plane Ŭ<><C5AC><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><>
|
||||
Math::VECTOR3 vTriPlaneNormal;
|
||||
float fTriPlaneConstant;
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><> <20><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ϰ<EFBFBD>..
|
||||
Math::Subtract(vTriEdge01, vTri1, vTri0);
|
||||
Math::Subtract(vTriEdge02, vTri2, vTri0);
|
||||
Math::Subtract(vTriEdge12, vTri2, vTri1);
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD>Ե<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ķ<EFBFBD><C4B6><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Math::CrossProduct(vTriPlaneNormal, vTriEdge01, vTriEdge02);
|
||||
Math::Normalize(vTriPlaneNormal, vTriPlaneNormal);
|
||||
fTriPlaneConstant = -Math::DotProduct(vTriPlaneNormal, vTri0);
|
||||
|
||||
// sweeping path <20><> <20>浹<EFBFBD><E6B5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
float fNormalDotPath = Math::DotProduct(vTriPlaneNormal, vPath);
|
||||
|
||||
// sphere <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD> üũ<C3BC><C5A9><EFBFBD><EFBFBD>
|
||||
if (fNormalDotPath > 0.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float t0, t1;
|
||||
bool bEmbededInPlane = false;
|
||||
|
||||
float fSignedDistBaseToTriPlane = Math::DotProduct(vTriPlaneNormal, vBasePoint) + fTriPlaneConstant;
|
||||
|
||||
if (0.0f == fNormalDotPath)
|
||||
{
|
||||
// sphere <20><> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
if (fabs(fSignedDistBaseToTriPlane) >= triAndSphere.m_fSphereRadius)
|
||||
{
|
||||
return false; // <20>ﰢ<EFBFBD><EFB0A2><EFBFBD>鿡<EFBFBD><E9BFA1> <20>ָ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>̵<EFBFBD><CCB5><EFBFBD>
|
||||
}
|
||||
else
|
||||
{
|
||||
bEmbededInPlane = true;
|
||||
t0 = 0.0f;
|
||||
t1 = 1.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t0 = (-triAndSphere.m_fSphereRadius-fSignedDistBaseToTriPlane)/fNormalDotPath;
|
||||
t1 = (triAndSphere.m_fSphereRadius-fSignedDistBaseToTriPlane)/fNormalDotPath;
|
||||
|
||||
// t0 < t1 <20><><EFBFBD><EFBFBD> <20><>Ʈ
|
||||
if (t0 > t1)
|
||||
{
|
||||
std::swap(t0, t1);
|
||||
}
|
||||
|
||||
// t <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sphere <20>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʴ<EFBFBD>
|
||||
if (t0 > 1.0f || t1 <0.0f)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// t <20><><EFBFBD><EFBFBD> 0~1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŭ<><C5AC><EFBFBD><EFBFBD>
|
||||
t0 = std::max(t0, 0.0f);
|
||||
t1 = std::min(t1, 1.0f);
|
||||
}
|
||||
|
||||
VECTOR3 vContactPoint;
|
||||
bool bFoundCollision = false;
|
||||
float t = 1.0f;
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD>ο<EFBFBD> üũ
|
||||
if (!bEmbededInPlane)
|
||||
{
|
||||
vContactPoint = vBasePoint + (vPath*t0) - vTriPlaneNormal;
|
||||
|
||||
if (IsPointInTriangle(vContactPoint, vTri0, vTri1, vTri2))
|
||||
{
|
||||
bFoundCollision = true;
|
||||
t = t0;
|
||||
}
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>浹<EFBFBD><E6B5B9><EFBFBD><EFBFBD> ã<><C3A3> <20><><EFBFBD>ߴٸ<DFB4> <20><EFBFBD><F0BCADB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ<EFBFBD><C6AE> <20>ؾ<EFBFBD><D8BE>Ѵ<EFBFBD>
|
||||
if (!bFoundCollision)
|
||||
{
|
||||
float fSQuaredPathLength = GetSquaredLength(vPath);
|
||||
float a, b, c;
|
||||
float newT;
|
||||
float fSquaredRadius = triAndSphere.m_fSphereRadius*triAndSphere.m_fSphereRadius;
|
||||
|
||||
a = fSQuaredPathLength;
|
||||
|
||||
// vTri0
|
||||
b = 2.0f * (DotProduct(vPath, vBasePoint - vTri0));
|
||||
c = (Math::GetSquaredLength(vTri0 - vBasePoint) - fSquaredRadius);
|
||||
if (GetLowestRootInRange(a, b, c, 0.0f, t, newT))
|
||||
{
|
||||
t = newT;
|
||||
bFoundCollision = true;
|
||||
vContactPoint = vTri0;
|
||||
}
|
||||
|
||||
// vTri1
|
||||
if (bFoundCollision)
|
||||
{
|
||||
b = 2.0f * (DotProduct(vPath, vBasePoint - vTri1));
|
||||
c = (Math::GetSquaredLength(vTri1 - vBasePoint) - fSquaredRadius);
|
||||
if (GetLowestRootInRange(a, b, c, 0.0f, t, newT))
|
||||
{
|
||||
t = newT;
|
||||
bFoundCollision = true;
|
||||
vContactPoint = vTri1;
|
||||
}
|
||||
}
|
||||
|
||||
// vTri2
|
||||
if (bFoundCollision)
|
||||
{
|
||||
b = 2.0f * (DotProduct(vPath, vBasePoint - vTri2));
|
||||
c = (Math::GetSquaredLength(vTri2 - vBasePoint) - fSquaredRadius);
|
||||
if (GetLowestRootInRange(a, b, c, 0.0f, t, newT))
|
||||
{
|
||||
t = newT;
|
||||
bFoundCollision = true;
|
||||
vContactPoint = vTri0;
|
||||
}
|
||||
}
|
||||
|
||||
// <20><EFBFBD><F0BCADB8><EFBFBD> <20><><EFBFBD><EFBFBD> <20><EFBFBD>Ʈ
|
||||
VECTOR3 vBaseToVertex;
|
||||
float fEdgeSquaredLength;
|
||||
float fEdgeDotPath;
|
||||
float fEdgeDotBaseToVertex;
|
||||
|
||||
// vTri0 ~ vTri1
|
||||
vBaseToVertex = vTri0 - vBasePoint;
|
||||
fEdgeSquaredLength = GetSquaredLength(vTriEdge01);
|
||||
fEdgeDotPath = DotProduct(vTriEdge01, vPath);
|
||||
fEdgeDotBaseToVertex = DotProduct(vTriEdge01, vBaseToVertex);
|
||||
|
||||
a = fEdgeSquaredLength* -fSQuaredPathLength +
|
||||
fEdgeDotPath*fEdgeDotPath;
|
||||
b = fEdgeSquaredLength* (2.0f*Math::DotProduct(vPath, vBaseToVertex)) -
|
||||
2.0f*fEdgeDotPath*fEdgeDotBaseToVertex;
|
||||
c = (fEdgeSquaredLength* (1.0f - Math::GetSquaredLength(vBaseToVertex)) +
|
||||
fEdgeDotBaseToVertex*fEdgeDotBaseToVertex);
|
||||
|
||||
if (GetLowestRootInRange(a, b, c, 0.0f, t, newT))
|
||||
{
|
||||
float f = (fEdgeDotPath*t - fEdgeDotBaseToVertex) / fEdgeSquaredLength;
|
||||
if (f >= 0.0f && f <= 1.0f)
|
||||
{
|
||||
t = newT;
|
||||
bFoundCollision = true;
|
||||
vContactPoint = vTri0 + vTriEdge01*f;
|
||||
}
|
||||
}
|
||||
|
||||
// vTri0 ~ vTri2
|
||||
vBaseToVertex = vTri0 - vBasePoint;
|
||||
fEdgeSquaredLength = GetSquaredLength(vTriEdge02);
|
||||
fEdgeDotPath = DotProduct(vTriEdge02, vPath);
|
||||
fEdgeDotBaseToVertex = DotProduct(vTriEdge02, vBaseToVertex);
|
||||
|
||||
a = fEdgeSquaredLength* -fSQuaredPathLength +
|
||||
fEdgeDotPath*fEdgeDotPath;
|
||||
b = fEdgeSquaredLength* (2.0f*Math::DotProduct(vPath, vBaseToVertex)) -
|
||||
2.0f*fEdgeDotPath*fEdgeDotBaseToVertex;
|
||||
c = (fEdgeSquaredLength* (1.0f - Math::GetSquaredLength(vBaseToVertex)) +
|
||||
fEdgeDotBaseToVertex*fEdgeDotBaseToVertex);
|
||||
|
||||
if (GetLowestRootInRange(a, b, c, 0.0f, t, newT))
|
||||
{
|
||||
float f = (fEdgeDotPath*t - fEdgeDotBaseToVertex) / fEdgeSquaredLength;
|
||||
if (f >= 0.0f && f <= 1.0f)
|
||||
{
|
||||
t = newT;
|
||||
bFoundCollision = true;
|
||||
vContactPoint = vTri0 + vTriEdge02*f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// vTri1 ~ vTri2
|
||||
vBaseToVertex = vTri1 - vBasePoint;
|
||||
fEdgeSquaredLength = GetSquaredLength(vTriEdge12);
|
||||
fEdgeDotPath = DotProduct(vTriEdge12, vPath);
|
||||
fEdgeDotBaseToVertex = DotProduct(vTriEdge12, vBaseToVertex);
|
||||
|
||||
a = fEdgeSquaredLength* -fSQuaredPathLength +
|
||||
fEdgeDotPath*fEdgeDotPath;
|
||||
b = fEdgeSquaredLength* (2.0f*Math::DotProduct(vPath, vBaseToVertex)) -
|
||||
2.0f*fEdgeDotPath*fEdgeDotBaseToVertex;
|
||||
c = (fEdgeSquaredLength* (1.0f - Math::GetSquaredLength(vBaseToVertex)) +
|
||||
fEdgeDotBaseToVertex*fEdgeDotBaseToVertex);
|
||||
|
||||
if (GetLowestRootInRange(a, b, c, 0.0f, t, newT))
|
||||
{
|
||||
float f = (fEdgeDotPath*t - fEdgeDotBaseToVertex) / fEdgeSquaredLength;
|
||||
if (f >= 0.0f && f <= 1.0f)
|
||||
{
|
||||
t = newT;
|
||||
bFoundCollision = true;
|
||||
vContactPoint = vTri1 + vTriEdge12*f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bFoundCollision)
|
||||
{
|
||||
fOutT = t;
|
||||
vOutContactPoint = vContactPoint;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ<D4B5><C7B4><EFBFBD> Ȯ<><C8AE><EFBFBD>ϴ<EFBFBD> <20>ڵ<EFBFBD>
|
||||
// Fauerby <20><> <20>ۿ<EFBFBD> Keidy <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><>ƾ<EFBFBD>̶<EFBFBD><CCB6><EFBFBD> <20>Ѵ<EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.. <20>ڴ<F0B8A3B0>-_- <20>ϴ<EFBFBD> <20>̿<EFBFBD>
|
||||
bool IsPointInTriangle(const VECTOR3& p, const VECTOR3& vTri0, const VECTOR3& vTri1, const VECTOR3& vTri2)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><> <20>ﰢ<EFBFBD><EFB0A2> <20><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> p <20><> <20><>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD>
|
||||
VECTOR3 vEdge1, vEdge2, pTri;
|
||||
|
||||
Math::Subtract(vEdge1, vTri1, vTri0);
|
||||
Math::Subtract(vEdge2, vTri2, vTri0);
|
||||
Math::Subtract(pTri, p, vTri0);
|
||||
|
||||
float a = Math::DotProduct(vEdge1, vEdge1);
|
||||
float b = Math::DotProduct(vEdge1, vEdge2);
|
||||
float c = Math::DotProduct(vEdge2, vEdge2);
|
||||
float d = Math::DotProduct(pTri, vEdge1);
|
||||
float e = Math::DotProduct(pTri, vEdge2);
|
||||
|
||||
float x = d*c - e*b;
|
||||
float y = e*a - d*b;
|
||||
float z = x + y - (a*c - b*b);
|
||||
|
||||
return ( ((unsigned int&)z) & ~ ( ((unsigned int&)x) | ((unsigned int&)y) ) & 0x80000000) != 0 ? true : false;
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
541
Engine/CrossM/Src/OctreeCollider.cpp
Normal file
541
Engine/CrossM/Src/OctreeCollider.cpp
Normal file
@@ -0,0 +1,541 @@
|
||||
#include "../Include/OctreeCollider.h"
|
||||
#include "../Include/MathUtil.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
|
||||
|
||||
namespace CrossM{
|
||||
namespace Scene{
|
||||
|
||||
|
||||
|
||||
COctreeCollisionNode::COctreeCollisionNode()
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
m_apSubNode[i] = NULL;
|
||||
}
|
||||
|
||||
m_vBoundingMin.SetValue(0,0,0);
|
||||
m_vBoundingMax.SetValue(0,0,0);
|
||||
}
|
||||
|
||||
COctreeCollisionNode::~COctreeCollisionNode()
|
||||
{
|
||||
ReleaseSubNode();
|
||||
}
|
||||
|
||||
void COctreeCollisionNode::ReleaseSubNode()
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (NULL != m_apSubNode[i])
|
||||
{
|
||||
delete m_apSubNode[i];
|
||||
m_apSubNode[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <20>ڽij<DABD><C4B3>尡 <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
bool COctreeCollisionNode::IsLeafNode()
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (NULL != m_apSubNode[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void COctreeCollisionNode::BuildSubNode(
|
||||
const std::vector< CollisionTriangleInfo >& vecTriangle,
|
||||
const size_t nMaximumRecursion, const size_t nMinPolyCount,
|
||||
size_t nCurrentRecursionLevel)
|
||||
{
|
||||
static size_t nProcessedTri = 0;
|
||||
|
||||
unsigned int i, j;
|
||||
|
||||
// recursion level <20><> <20>ʹ<EFBFBD> <20><><EFBFBD>ų<EFBFBD>, <20><><EFBFBD>Ե<EFBFBD> face <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͺ<EFBFBD><CDBA><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD>̻<EFBFBD> sub node <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʴ´<CAB4> (<28><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
if (nCurrentRecursionLevel >= nMaximumRecursion ||
|
||||
m_vecTriangleIndex.size() <= nMinPolyCount)
|
||||
{
|
||||
nProcessedTri += m_vecTriangleIndex.size();
|
||||
printf("\r%d / %d", nProcessedTri, vecTriangle.size());
|
||||
return;
|
||||
}
|
||||
|
||||
// <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> bounding box min/max
|
||||
Math::VECTOR3 aSubNodeBoundingMin[8];
|
||||
Math::VECTOR3 aSubNodeBoundingMax[8];
|
||||
|
||||
Math::VECTOR3 vMedian = (m_vBoundingMin + m_vBoundingMax)/2.0f;
|
||||
|
||||
// <20>ٿ<EFBFBD><D9BF><EFBFBD> <20>ڽ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
if (0 == (i & 1))
|
||||
{
|
||||
aSubNodeBoundingMin[i].x = m_vBoundingMin.x;
|
||||
aSubNodeBoundingMax[i].x = vMedian.x;
|
||||
}
|
||||
else
|
||||
{
|
||||
aSubNodeBoundingMin[i].x = vMedian.x;
|
||||
aSubNodeBoundingMax[i].x = m_vBoundingMax.x;
|
||||
}
|
||||
if (0 == (i & 2))
|
||||
{
|
||||
aSubNodeBoundingMin[i].y = m_vBoundingMin.y;
|
||||
aSubNodeBoundingMax[i].y = vMedian.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
aSubNodeBoundingMin[i].y = vMedian.y;
|
||||
aSubNodeBoundingMax[i].y = m_vBoundingMax.y;
|
||||
}
|
||||
if (0 == (i & 4))
|
||||
{
|
||||
aSubNodeBoundingMin[i].z = m_vBoundingMin.z;
|
||||
aSubNodeBoundingMax[i].z = vMedian.z;
|
||||
}
|
||||
else
|
||||
{
|
||||
aSubNodeBoundingMin[i].z = vMedian.z;
|
||||
aSubNodeBoundingMax[i].z = m_vBoundingMax.z;
|
||||
}
|
||||
}
|
||||
|
||||
// <20>Ѱܹ<D1B0><DCB9><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ϻ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD> <20><> <20><><EFBFBD>忡 <20><><EFBFBD><EFBFBD><EFBFBD>ɰ͵<C9B0><CDB5><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>س<EFBFBD><D8B3><EFBFBD>
|
||||
for (j = 0; j < m_vecTriangleIndex.size(); ++j)
|
||||
{
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> <20><> <20><> <20><><EFBFBD><EFBFBD>
|
||||
const CollisionTriangleInfo &tri = vecTriangle[ m_vecTriangleIndex[j] ];
|
||||
const Math::VECTOR3 &vTri0 = tri.m_avVertex[0];
|
||||
const Math::VECTOR3 &vTri1 = tri.m_avVertex[1];
|
||||
const Math::VECTOR3 &vTri2 = tri.m_avVertex[2];
|
||||
|
||||
// <20><> <20>ڽij<DABD><C4B3><EFBFBD><EFBFBD>鿡 <20><><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ<D4B5><C7B4><EFBFBD> üũ<C3BC>Ѵ<EFBFBD>
|
||||
bool bIncludedInSubNode = false; // <20>ڽ<EFBFBD> <20><><EFBFBD>忡 <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ<D4B5><C7B4><EFBFBD> <20><><EFBFBD>θ<EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
if (Math::IsTriangleInAabb(aSubNodeBoundingMin[i], aSubNodeBoundingMax[i], vTri0, vTri1, vTri2))
|
||||
{
|
||||
// <20><><EFBFBD>尡 <20>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD> <20>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD> <20>Ҵ<EFBFBD>
|
||||
COctreeCollisionNode* &pNode = m_apSubNode[i];
|
||||
if (NULL == pNode)
|
||||
{
|
||||
pNode = new COctreeCollisionNode;
|
||||
pNode->m_vBoundingMin = aSubNodeBoundingMin[i];
|
||||
pNode->m_vBoundingMax = aSubNodeBoundingMax[i];
|
||||
}
|
||||
|
||||
// <20>ڽij<DABD><C4B3>忡 <20>Ѱ<EFBFBD><D1B0><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
pNode->m_vecTriangleIndex.push_back(m_vecTriangleIndex[j]);
|
||||
bIncludedInSubNode = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!bIncludedInSubNode)
|
||||
{
|
||||
// <20><> <20><><EFBFBD>忡 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ԵǴ°<C7B4><C2B0><EFBFBD> <20>ƴ϶<C6B4> <20>ټ<EFBFBD> <20><><EFBFBD>尣<EFBFBD><E5B0A3> <20><>ġ<EFBFBD><C4A1> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD>̹Ƿ<CCB9>,
|
||||
// triangle - AABB intersection <20><EFBFBD>Ʈ<EFBFBD><C6AE> <20>Ѵ<EFBFBD>
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
if (Math::CheckAabbTriangleIntersection(aSubNodeBoundingMin[i], aSubNodeBoundingMax[i], vTri0, vTri1, vTri2))
|
||||
{
|
||||
// <20><><EFBFBD>尡 <20>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD><EFBFBD> <20>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD> <20>Ҵ<EFBFBD>
|
||||
COctreeCollisionNode* &pNode = m_apSubNode[i];
|
||||
if (NULL == pNode)
|
||||
{
|
||||
pNode = new COctreeCollisionNode;
|
||||
pNode->m_vBoundingMin = aSubNodeBoundingMin[i];
|
||||
pNode->m_vBoundingMax = aSubNodeBoundingMax[i];
|
||||
}
|
||||
|
||||
// <20>ڽij<DABD><C4B3>忡 <20>Ѱ<EFBFBD><D1B0><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
pNode->m_vecTriangleIndex.push_back(m_vecTriangleIndex[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> <20>ڽ<EFBFBD> <20><><EFBFBD>忡 <20><><EFBFBD><EFBFBD> <20>Ѱ<EFBFBD><D1B0>־<EFBFBD><D6BE><EFBFBD><EFBFBD>Ƿ<EFBFBD> <20><> <20>̻<EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ʿ䰡 <20><><EFBFBD><EFBFBD>
|
||||
m_vecTriangleIndex.clear();
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20>ڽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BuildSubNode <20><> ȣ<><C8A3><EFBFBD>Ѵ<EFBFBD>
|
||||
for (i = 0; i < 8; ++i)
|
||||
{
|
||||
if (NULL != m_apSubNode[i])
|
||||
{
|
||||
m_apSubNode[i]->BuildSubNode(vecTriangle, nMaximumRecursion, nMinPolyCount, nCurrentRecursionLevel+1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void COctreeCollisionNode::CollectCollidableNodes(
|
||||
const Math::VECTOR3& vSweptVolumeMin, const Math::VECTOR3& vSweptVolumeMax,
|
||||
std::vector< COctreeCollisionNode* >& vecCollidableNode)
|
||||
{
|
||||
if(!Math::CheckAabbAabbIntersection(vSweptVolumeMin, vSweptVolumeMax, m_vBoundingMin, m_vBoundingMax))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsLeafNode())
|
||||
{
|
||||
vecCollidableNode.push_back(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
if (NULL != m_apSubNode[i])
|
||||
{
|
||||
m_apSubNode[i]->CollectCollidableNodes(vSweptVolumeMin, vSweptVolumeMax, vecCollidableNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
COctreeCollider::COctreeCollider()
|
||||
{
|
||||
m_nColTriIndex = 0;
|
||||
}
|
||||
|
||||
COctreeCollider::~COctreeCollider()
|
||||
{
|
||||
}
|
||||
|
||||
void COctreeCollider::SetTriangleCount(unsigned int uiTriangleCount)
|
||||
{
|
||||
m_vecCollisionTriangle.resize(uiTriangleCount);
|
||||
}
|
||||
|
||||
void COctreeCollider::GetTriangleDataPtr(CollisionTriangleInfo*& pTriangleData)
|
||||
{
|
||||
if (m_vecCollisionTriangle.size() > 0)
|
||||
{
|
||||
pTriangleData = &(m_vecCollisionTriangle[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pTriangleData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool COctreeCollider::BuildOctree(const size_t nMaximumRecursion, const size_t nMinPolyCount)
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
if (0 == m_vecCollisionTriangle.size())
|
||||
{
|
||||
m_vCollisionBoundingMin.SetValue(0,0,0);
|
||||
m_vCollisionBoundingMax.SetValue(0,0,0);
|
||||
|
||||
return true; // <20><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͱ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>־ <20>ϴ<EFBFBD><CFB4><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..
|
||||
}
|
||||
|
||||
// <20>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
m_octreeRootNode.ReleaseSubNode();
|
||||
|
||||
// bounding min/max <20><><EFBFBD>ϱ<EFBFBD>
|
||||
m_vCollisionBoundingMin = m_vecCollisionTriangle[0].m_avVertex[0];
|
||||
m_vCollisionBoundingMax = m_vecCollisionTriangle[0].m_avVertex[0];
|
||||
|
||||
for (i = 0; i < m_vecCollisionTriangle.size(); ++i)
|
||||
{
|
||||
for (j = 0; j < 3; ++j)
|
||||
{
|
||||
CrossM::Math::VECTOR3& v = m_vecCollisionTriangle[i].m_avVertex[j];
|
||||
|
||||
if (v.x < m_vCollisionBoundingMin.x) m_vCollisionBoundingMin.x = v.x;
|
||||
if (v.y < m_vCollisionBoundingMin.y) m_vCollisionBoundingMin.y = v.y;
|
||||
if (v.z < m_vCollisionBoundingMin.z) m_vCollisionBoundingMin.z = v.z;
|
||||
|
||||
if (v.x > m_vCollisionBoundingMax.x) m_vCollisionBoundingMax.x = v.x;
|
||||
if (v.y > m_vCollisionBoundingMax.y) m_vCollisionBoundingMax.y = v.y;
|
||||
if (v.z > m_vCollisionBoundingMax.z) m_vCollisionBoundingMax.z = v.z;
|
||||
}
|
||||
}
|
||||
|
||||
// octree root node <20><> <20>ٿ<EFBFBD><D9BF><EFBFBD> <20>ڽ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD>
|
||||
m_octreeRootNode.m_vBoundingMin = m_vCollisionBoundingMin;
|
||||
m_octreeRootNode.m_vBoundingMax = m_vCollisionBoundingMax;
|
||||
|
||||
// octree root node <20><> <20><><EFBFBD>Ե<EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD>(<28><>ü)<29><> <20><><EFBFBD><EFBFBD>
|
||||
m_octreeRootNode.m_vecTriangleIndex.resize(m_vecCollisionTriangle.size());
|
||||
for (i = 0; i < m_octreeRootNode.m_vecTriangleIndex.size(); ++i)
|
||||
{
|
||||
m_octreeRootNode.m_vecTriangleIndex[i] = i;
|
||||
}
|
||||
|
||||
// DWORD dwTime = timeGetTime();
|
||||
// for (i = 0; i < m_vecCollisionTriangle.size(); ++i)
|
||||
// {
|
||||
// CollisionTriangleInfo& tri = m_vecCollisionTriangle[i];
|
||||
// Math::VECTOR3& vTri0 = m_vecCollisionVertex[ tri.m_lIndex[0] ];
|
||||
// Math::VECTOR3& vTri1 = m_vecCollisionVertex[ tri.m_lIndex[1] ];
|
||||
// Math::VECTOR3& vTri2 = m_vecCollisionVertex[ tri.m_lIndex[2] ];
|
||||
//
|
||||
// Math::CheckAabbTriangleIntersection(m_vCollisionBoundingMin, m_vCollisionBoundingMax, vTri0, vTri1, vTri2);
|
||||
// }
|
||||
// DWORD dwElapsed = timeGetTime() - dwTime;
|
||||
//
|
||||
// dwTime = timeGetTime();
|
||||
// for (i = 0; i < m_vecCollisionTriangle.size(); ++i)
|
||||
// {
|
||||
// CollisionTriangleInfo& tri = m_vecCollisionTriangle[i];
|
||||
// Math::VECTOR3& vTri0 = m_vecCollisionVertex[ tri.m_lIndex[0] ];
|
||||
// Math::VECTOR3& vTri1 = m_vecCollisionVertex[ tri.m_lIndex[1] ];
|
||||
// Math::VECTOR3& vTri2 = m_vecCollisionVertex[ tri.m_lIndex[2] ];
|
||||
//
|
||||
// Math::IsTriangleInAabb(m_vCollisionBoundingMin, m_vCollisionBoundingMax, vTri0, vTri1, vTri2);
|
||||
// }
|
||||
// DWORD dwElapsed2 = timeGetTime() - dwTime;
|
||||
|
||||
// <20>Ϻ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
m_octreeRootNode.BuildSubNode(m_vecCollisionTriangle, nMaximumRecursion, nMinPolyCount, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void COctreeCollider::GetCollisionRespondingPosition(
|
||||
Math::VECTOR3& vOutRespondingPos,
|
||||
const Math::VECTOR3& vPrevPos, const Math::VECTOR3& vNewPos,
|
||||
const Math::VECTOR3& vEllipsoidRadius,
|
||||
const unsigned int nRecursionLevel)
|
||||
{
|
||||
size_t i, j, nMinCollisionTriangleIndex;
|
||||
|
||||
// ellipsoid <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŀ<><C4BF><EFBFBD>ϴ<EFBFBD> <20>簢<EFBFBD><E7B0A2>(AABB)<29><> min/max <20><>
|
||||
Math::VECTOR3 vSweptVolumeMin, vSweptVolumeMax;
|
||||
|
||||
vSweptVolumeMin.x = min(vPrevPos.x, vNewPos.x) - vEllipsoidRadius.x;
|
||||
vSweptVolumeMax.x = max(vPrevPos.x, vNewPos.x) + vEllipsoidRadius.x;
|
||||
vSweptVolumeMin.y = min(vPrevPos.y, vNewPos.y) - vEllipsoidRadius.y;
|
||||
vSweptVolumeMax.y = max(vPrevPos.y, vNewPos.y) + vEllipsoidRadius.y;
|
||||
vSweptVolumeMin.z = min(vPrevPos.z, vNewPos.z) - vEllipsoidRadius.z;
|
||||
vSweptVolumeMax.z = max(vPrevPos.z, vNewPos.z) + vEllipsoidRadius.z;
|
||||
|
||||
m_vecpCollidableNode.clear();
|
||||
m_octreeRootNode.CollectCollidableNodes(vSweptVolumeMin, vSweptVolumeMax, m_vecpCollidableNode);
|
||||
|
||||
if (0 == m_vecpCollidableNode.size())
|
||||
{
|
||||
// <20>浹 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ִ<EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
vOutRespondingPos = vNewPos;
|
||||
return;
|
||||
}
|
||||
|
||||
// ellipsoid <20><>ǥ<EFBFBD><C7A5> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>. sweep <20><><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> sweep <20><><EFBFBD>⺤<EFBFBD><E2BAA4>, sweep <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Math::VECTOR3 vESweepStart, vESweepEnd, vESweepPath;
|
||||
float fESweepLength;
|
||||
|
||||
vESweepStart.SetValue(vPrevPos.x/vEllipsoidRadius.x, vPrevPos.y/vEllipsoidRadius.y, vPrevPos.z/vEllipsoidRadius.z);
|
||||
vESweepEnd.SetValue(vNewPos.x/vEllipsoidRadius.x, vNewPos.y/vEllipsoidRadius.y, vNewPos.z/vEllipsoidRadius.z);
|
||||
Math::Subtract(vESweepPath, vESweepEnd, vESweepStart);
|
||||
fESweepLength = Math::GetLength(vESweepPath);
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if (fESweepLength < Math::F_EPSILON)
|
||||
{
|
||||
vOutRespondingPos = vPrevPos;
|
||||
return;
|
||||
}
|
||||
|
||||
// sweeping sphere <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Math::TriangSweepingSphere triAndSphere;
|
||||
triAndSphere.m_vSphereSweepStart = vESweepStart;
|
||||
triAndSphere.m_vSphereSweepPath = vESweepPath;
|
||||
triAndSphere.m_fSphereRadius = 1.0f; // ellipsoid <20><>ǥ<EFBFBD><C7A5><EFBFBD>̹Ƿ<CCB9> <20>浹Ÿ<E6B5B9><C5B8>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD> <20><>ü<EFBFBD><C3BC> <20><>ȯ<EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD>
|
||||
|
||||
bool bCollision = false; // <20><><EFBFBD>õ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>鿡<EFBFBD><E9BFA1> <20>浹<EFBFBD><E6B5B9> <20>Ͼ <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20>ִ<EFBFBD><D6B4><EFBFBD> <20><><EFBFBD>θ<EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>
|
||||
float fMinCollisionDistFactor = 9999.0f;// collision <20><> <20>Ͼ <20><><EFBFBD><EFBFBD> sweeping path <20><> <20><><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// 0 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, 1 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Math::VECTOR3 vMinContactPoint; // fMinCollisionDistFactor <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ǥ. ellipsoid <20><>ǥ<EFBFBD><C7A5><EFBFBD><EFBFBD>
|
||||
bool bMinContactInsideTriangle; // fMinCollisionDistFactor <20><><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><EFBFBD><F0BCADB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴ<EFBFBD>) <20><>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>
|
||||
for (i = 0; i < m_vecpCollidableNode.size(); ++i)
|
||||
{
|
||||
COctreeCollisionNode& node = *(m_vecpCollidableNode[i]);
|
||||
for (j = 0; j < node.m_vecTriangleIndex.size(); ++j)
|
||||
{
|
||||
CollisionTriangleInfo& tri = m_vecCollisionTriangle[ node.m_vecTriangleIndex[j] ];
|
||||
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Math::VECTOR3& vTri0 = tri.m_avVertex[0];
|
||||
Math::VECTOR3& vTri1 = tri.m_avVertex[1];
|
||||
Math::VECTOR3& vTri2 = tri.m_avVertex[2];
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> <20><><EFBFBD><EFBFBD> ellipsoid <20><>ǥ<EFBFBD><C7A5><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><>-
|
||||
triAndSphere.m_vTri0.SetValue(vTri0.x/vEllipsoidRadius.x, vTri0.y/vEllipsoidRadius.y, vTri0.z/vEllipsoidRadius.z);
|
||||
triAndSphere.m_vTri1.SetValue(vTri1.x/vEllipsoidRadius.x, vTri1.y/vEllipsoidRadius.y, vTri1.z/vEllipsoidRadius.z);
|
||||
triAndSphere.m_vTri2.SetValue(vTri2.x/vEllipsoidRadius.x, vTri2.y/vEllipsoidRadius.y, vTri2.z/vEllipsoidRadius.z);
|
||||
|
||||
float fCollisionDistFactor;
|
||||
Math::VECTOR3 vContactPoint;
|
||||
bool bContactInside;
|
||||
// <20>ﰢ<EFBFBD><EFB0A2> - sweeping sphere <20>浹 <20>˻<EFBFBD>
|
||||
if (Math::CheckTriangleSweepingSphereCollision(fCollisionDistFactor, vContactPoint, bContactInside, triAndSphere))
|
||||
{
|
||||
// <20>浹<EFBFBD≯<EFBFBD>
|
||||
bCollision = true;
|
||||
|
||||
if(fCollisionDistFactor < fMinCollisionDistFactor)
|
||||
{
|
||||
vMinContactPoint = vContactPoint;
|
||||
fMinCollisionDistFactor = fCollisionDistFactor;
|
||||
nMinCollisionTriangleIndex = node.m_vecTriangleIndex[j];
|
||||
bMinContactInsideTriangle = bContactInside;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bCollision)
|
||||
{
|
||||
// <20>浹 <20><><EFBFBD><EFBFBD>
|
||||
vOutRespondingPos = vNewPos;
|
||||
return;
|
||||
}
|
||||
|
||||
m_nColTriIndex = nMinCollisionTriangleIndex;
|
||||
|
||||
// collision response phase
|
||||
Math::VECTOR3 vMovedPos; // <20>ϴ<EFBFBD> <20>浹<EFBFBD><E6B5B9> <20>Ͼ<CFBE><EEB3AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5><EFBFBD> <20><>ġ
|
||||
Math::Lerp(vMovedPos, vPrevPos, vNewPos, fMinCollisionDistFactor); // <20>ϴ<EFBFBD> <20>̵<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ġ<EFBFBD><C4A1> <20>Űܳ<C5B0><DCB3><EFBFBD> <20><>..
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5>Ϸ<EFBFBD><CFB7><EFBFBD> <20>Ÿ<EFBFBD><C5B8><EFBFBD> 90% <20>̻<EFBFBD><CCBB><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>߰ų<DFB0>, recursion <20><> 4<><34> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD>.
|
||||
if (fMinCollisionDistFactor > 0.9f || nRecursionLevel >= 4)
|
||||
{
|
||||
vOutRespondingPos = vMovedPos;
|
||||
return;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD><C7A5> ellipsoid <20><>ǥ<EFBFBD>迡<EFBFBD><E8BFA1> <20><><EFBFBD><EFBFBD> <20><>ǥ<EFBFBD><C7A5><EFBFBD><EFBFBD> ȯ<><C8AF>
|
||||
vMinContactPoint.x *= vEllipsoidRadius.x;
|
||||
vMinContactPoint.y *= vEllipsoidRadius.y;
|
||||
vMinContactPoint.z *= vEllipsoidRadius.z;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Math::VECTOR3 vTangentPlaneNormal;
|
||||
if (bMinContactInsideTriangle)
|
||||
{
|
||||
// <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20>浹<EFBFBD><E6B5B9> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> normal <20><> <20>״<EFBFBD><D7B4><EFBFBD> <20>̿<EFBFBD><CCBF>Ѵ<EFBFBD>
|
||||
CollisionTriangleInfo& colTriInfo = m_vecCollisionTriangle[nMinCollisionTriangleIndex];
|
||||
Math::VECTOR3& vCollTri0 = colTriInfo.m_avVertex[0];
|
||||
Math::VECTOR3& vCollTri1 = colTriInfo.m_avVertex[1];
|
||||
Math::VECTOR3& vCollTri2 = colTriInfo.m_avVertex[2];
|
||||
vTangentPlaneNormal = ((vCollTri1 - vCollTri0) ^ (vCollTri2 - vCollTri0));
|
||||
}
|
||||
else
|
||||
{
|
||||
// <20><EFBFBD><F0BCADB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>浹<EFBFBD><E6B5B9> <20><><EFBFBD><EFBFBD>, Ÿ<><C5B8>ü<EFBFBD><C3BC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ϴ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>̿<EFBFBD><CCBF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> normal <20><> <20><><EFBFBD>Ѵ<EFBFBD>
|
||||
Math::Subtract(vTangentPlaneNormal, vMovedPos, vMinContactPoint);
|
||||
vTangentPlaneNormal.x /= (vEllipsoidRadius.x*vEllipsoidRadius.x);
|
||||
vTangentPlaneNormal.y /= (vEllipsoidRadius.y*vEllipsoidRadius.y);
|
||||
vTangentPlaneNormal.z /= (vEllipsoidRadius.z*vEllipsoidRadius.z);
|
||||
Math::Normalize(vTangentPlaneNormal, vTangentPlaneNormal);
|
||||
}
|
||||
Math::Normalize(vTangentPlaneNormal, vTangentPlaneNormal);
|
||||
|
||||
// <20>浹<EFBFBD><E6B5B9> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ϰ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Math::VECTOR3 vRemainder;
|
||||
Math::Subtract(vRemainder, vNewPos, vMovedPos);
|
||||
|
||||
// <20>浹<EFBFBD><E6B5B9> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
float fVanishingComponentFactor = Math::DotProduct(vTangentPlaneNormal, vRemainder);
|
||||
Math::VECTOR3 vVanishingComponent;
|
||||
Math::Scale(vVanishingComponent, vTangentPlaneNormal, fVanishingComponentFactor);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϼ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
Math::Subtract(vRemainder, vRemainder, vVanishingComponent);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>̵<EFBFBD><CCB5><EFBFBD><EFBFBD><EFBFBD>ŭ<EFBFBD><C5AD> <20>̵<EFBFBD><CCB5><EFBFBD> <20><><EFBFBD><EFBFBD> <20>浹üũ <20><><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3>
|
||||
GetCollisionRespondingPosition(vOutRespondingPos, vMovedPos, vMovedPos+vRemainder, vEllipsoidRadius, nRecursionLevel+1);
|
||||
}
|
||||
|
||||
|
||||
void COctreeCollider::RenderCollidableNodeTriangles(IDirect3DDevice8* pDevice)
|
||||
{
|
||||
size_t nRenderTriCount; //j, i, nTriFilled;
|
||||
|
||||
if (0 == m_vecpCollidableNode.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ﰢ<EFBFBD><EFB0A2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
// nRenderTriCount = 0;
|
||||
// for (i = 0; i < m_vecpCollidableNode.size(); ++i)
|
||||
// {
|
||||
// nRenderTriCount += m_vecpCollidableNode[i]->m_vecTriangleIndex.size();
|
||||
// }
|
||||
//
|
||||
// // <20><><EFBFBD>ؽ<EFBFBD> <20><><EFBFBD><EFBFBD> Ȯ<><C8AE>
|
||||
// m_vecRenderVertex.resize(nRenderTriCount*3);
|
||||
//
|
||||
// nTriFilled = 0;
|
||||
// for (i = 0; i < m_vecpCollidableNode.size(); ++i)
|
||||
// {
|
||||
// COctreeCollisionNode& node = *(m_vecpCollidableNode[i]);
|
||||
//
|
||||
// for (j = 0; j < node.m_vecTriangleIndex.size(); ++j)
|
||||
// {
|
||||
// size_t nTriIndex = node.m_vecTriangleIndex[j];
|
||||
// CollisionTriangleInfo& tri = m_vecCollisionTriangle[nTriIndex];
|
||||
//
|
||||
// m_vecRenderVertex[nTriFilled*3] = tri.m_avVertex[0];
|
||||
// m_vecRenderVertex[nTriFilled*3 + 1] = tri.m_avVertex[1];
|
||||
// m_vecRenderVertex[nTriFilled*3 + 2] = tri.m_avVertex[2];
|
||||
// ++nTriFilled;
|
||||
// }
|
||||
// }
|
||||
|
||||
nRenderTriCount = 1; // <20>浹<EFBFBD>ﰢ<EFBFBD><EFB0A2> 1<><31><EFBFBD><EFBFBD>
|
||||
m_vecRenderVertex.resize(nRenderTriCount*3);
|
||||
CollisionTriangleInfo& tri = m_vecCollisionTriangle[m_nColTriIndex];
|
||||
|
||||
m_vecRenderVertex[0] = tri.m_avVertex[0];
|
||||
m_vecRenderVertex[1] = tri.m_avVertex[1];
|
||||
m_vecRenderVertex[2] = tri.m_avVertex[2];
|
||||
|
||||
D3DXMATRIX mTmp;
|
||||
D3DXMatrixIdentity(&mTmp);
|
||||
pDevice->SetTransform(D3DTS_WORLD, &mTmp);
|
||||
|
||||
DWORD dwFillMode, dwZFunc;
|
||||
pDevice->GetRenderState(D3DRS_FILLMODE, &dwFillMode);
|
||||
pDevice->GetRenderState(D3DRS_ZFUNC, &dwZFunc);
|
||||
pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
|
||||
pDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
|
||||
pDevice->SetVertexShader(D3DFVF_XYZ);
|
||||
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, (UINT)nRenderTriCount, &(m_vecRenderVertex[0]), sizeof(Math::VECTOR3));
|
||||
pDevice->SetRenderState(D3DRS_FILLMODE, dwFillMode);
|
||||
pDevice->SetRenderState(D3DRS_ZFUNC, dwZFunc);
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
7065
Engine/Effect/CEffscript.cpp
Normal file
7065
Engine/Effect/CEffscript.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1282
Engine/Effect/CEffscript.h
Normal file
1282
Engine/Effect/CEffscript.h
Normal file
File diff suppressed because it is too large
Load Diff
109
Engine/Effect/CEffscriptDefine.h
Normal file
109
Engine/Effect/CEffscriptDefine.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef __EFFSCRIPTDEFINE_H__
|
||||
#define __EFFSCRIPTDEFINE_H__
|
||||
|
||||
|
||||
#define ESBUF_SIZE 256
|
||||
#define ESEMPTY -1
|
||||
|
||||
#define ESSTART "INDEX"
|
||||
#define ESEND "FIN:"
|
||||
#define ESLIST "LIST:"
|
||||
#define ESLOOP "LOOP:"
|
||||
#define ESPLAY "PLAY:"
|
||||
#define ESSNAP "SNAP:"
|
||||
#define ESFADEOUT "OUT:"
|
||||
#define ESFADEIN "IN:"
|
||||
#define ESSHAKE "SHAKE:"
|
||||
#define ESSOUND "SOUND:"
|
||||
#define ESSUB "SUB:"
|
||||
#define ESCLIGHT "CLIGHT:"
|
||||
#define ESHIT "HIT:"
|
||||
#define ESSLIDE "SLIDE:"
|
||||
#define ESEXT5 "EXT5:"
|
||||
#define ESLIGHTN "LIGHTNING:"
|
||||
#define ESLIGHTN2 "LIGHTNING2:"
|
||||
#define ESLIGHTN3 "LIGHTNING3:"
|
||||
#define ESWHEEL "WHEEL:"
|
||||
#define ESWEAPON "WEAPON:"
|
||||
#define ESBEZIERM "GHOST:"
|
||||
#define ESLIGHT "LIGHT:"
|
||||
#define ESPLAYT "PLAYTIME:"
|
||||
#define ESCHAR "CHARACTER:"
|
||||
#define ESWEAPONL "WEAPONLINE:"
|
||||
|
||||
#define ESPI 3.14159f
|
||||
#define ESHALF_PI (ESPI/2)
|
||||
#define ESGRAVITY 9.806650f
|
||||
|
||||
#define ESEXTLINESIZE 8.0f //line size
|
||||
|
||||
//m_TickFrame deault <20><>
|
||||
#define DEFAULTESTICK 40
|
||||
|
||||
enum EZVALUE {
|
||||
ESNORMAL, // normal effect
|
||||
ESINTERFACE, // interface effect
|
||||
};
|
||||
|
||||
enum EDIR{
|
||||
EUP,
|
||||
ELEFT,
|
||||
ERIGHT,
|
||||
EFRONT,
|
||||
ERAND
|
||||
};
|
||||
enum ECURRENT{ // <20><><EFBFBD>Ͽ<EFBFBD><CFBF><EFBFBD> <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>̴<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
ESS, //start
|
||||
ESE, // end
|
||||
EST, // list
|
||||
ESL, //loop
|
||||
ESP, //play
|
||||
ESFO, //FADE out
|
||||
ESFI, //FADE IN
|
||||
ESSK, // camera shake
|
||||
ESN, // snap
|
||||
ESO, // sound
|
||||
ESB, // Sub
|
||||
ESCL, // CLight
|
||||
ESH, // Hit
|
||||
ESSL, // slide
|
||||
ESE5, //ext5extension
|
||||
ESLN, //lightning
|
||||
ESLN2, //lightning2
|
||||
ESLN3, //lightning3
|
||||
ESW, // wheel
|
||||
ESWP, // Weapon
|
||||
ESBM, // Bezier Middle
|
||||
ESLT, // Light
|
||||
ESPT, // Play Time
|
||||
ESCH, // Character
|
||||
ESWL,
|
||||
};
|
||||
enum EVALUE { // <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..
|
||||
ED, // Delay frame
|
||||
ES, // S effect
|
||||
EM, // M effect
|
||||
EE, // E effect
|
||||
EN, //Snap effect
|
||||
EF, //finish effect
|
||||
};
|
||||
enum EPIVOT { // extension4 <20><> pivot index
|
||||
EHEAD,
|
||||
ENECK,
|
||||
ECHEST,
|
||||
EWAIST,
|
||||
EPELVIS,
|
||||
ER_HAND,
|
||||
ER_FOREARM,
|
||||
ER_UPPERARM,
|
||||
ER_THIGH,
|
||||
ER_CALF,
|
||||
ER_FOOT,
|
||||
EL_HAND,
|
||||
EL_FOREARM,
|
||||
EL_UPPERARM,
|
||||
EL_THIGH,
|
||||
EL_CALF,
|
||||
EL_FOOT,
|
||||
};
|
||||
#endif
|
||||
2607
Engine/Effect/CGemRender.cpp
Normal file
2607
Engine/Effect/CGemRender.cpp
Normal file
File diff suppressed because it is too large
Load Diff
443
Engine/Effect/CGemRender.h
Normal file
443
Engine/Effect/CGemRender.h
Normal file
@@ -0,0 +1,443 @@
|
||||
#ifndef __CGEMRENDER_H__
|
||||
#define __CGEMRENDER_H__
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
|
||||
#define BUF_SIZE 256
|
||||
#define VOT 1.0f
|
||||
#define GEM_HEADER "GemDataFile\n"
|
||||
|
||||
|
||||
class CGemRender {
|
||||
public:
|
||||
void SetClearBuffer(bool b);
|
||||
bool m_bClearBuffer;
|
||||
class GemTexture {
|
||||
public:
|
||||
CTexture *m_Tex;
|
||||
int TexNum;
|
||||
GemTexture() {
|
||||
m_Tex = NULL;
|
||||
TexNum = 0;
|
||||
}
|
||||
~GemTexture() {
|
||||
if(m_Tex) {
|
||||
/* if(TexNum >1)
|
||||
delete[] m_Tex;
|
||||
else*/
|
||||
delete[] m_Tex;
|
||||
}
|
||||
}
|
||||
};
|
||||
class GemSubFace{
|
||||
public:
|
||||
int *sub;
|
||||
int *sub_mat;
|
||||
int sub_num;
|
||||
GemSubFace() {
|
||||
sub = NULL;
|
||||
sub_mat = NULL;
|
||||
sub_num = 0;
|
||||
}
|
||||
~GemSubFace() {
|
||||
delete[] sub;
|
||||
delete[] sub_mat;
|
||||
}
|
||||
};
|
||||
class GemVertex{
|
||||
public:
|
||||
float x,y,z;
|
||||
float nx,ny,nz;
|
||||
float s,t;
|
||||
GemVertex() {
|
||||
x = y = z = 0.0f;
|
||||
nx = ny = nz = 0.0f;
|
||||
s = t = 0.0f;
|
||||
}
|
||||
~GemVertex() {}
|
||||
};
|
||||
class GemRotKey {
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR4 rot;
|
||||
|
||||
GemRotKey() {
|
||||
frame = 0;
|
||||
rot.x = rot.y = rot.z = rot.w = 0.0f;
|
||||
}
|
||||
|
||||
~GemRotKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemPosKey{
|
||||
public:
|
||||
int frame;
|
||||
bool bez;
|
||||
D3DXVECTOR3 pos;
|
||||
D3DXVECTOR3 intan;
|
||||
D3DXVECTOR3 outtan;
|
||||
GemPosKey() {
|
||||
frame = 0;
|
||||
bez = false;
|
||||
pos.x = pos.y = pos.z = 0.0f;
|
||||
intan.x = intan.y = intan.z = 0.0f;
|
||||
outtan.x = outtan.y = outtan.z = 0.0f;
|
||||
}
|
||||
~GemPosKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemScaleKey{
|
||||
public:
|
||||
int frame;
|
||||
D3DXVECTOR3 scale;
|
||||
GemScaleKey() {
|
||||
frame = 0;
|
||||
scale.x = scale.y = scale.z= 1.0f;
|
||||
}
|
||||
~GemScaleKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemVisKey{
|
||||
public:
|
||||
int frame;
|
||||
float vis;
|
||||
GemVisKey(){
|
||||
frame = 0;
|
||||
vis = 1.0f;
|
||||
}
|
||||
~GemVisKey(){
|
||||
}
|
||||
};
|
||||
|
||||
class GemObject {
|
||||
public:
|
||||
char m_Name[BUF_SIZE];
|
||||
char m_ParentName[BUF_SIZE];
|
||||
bool m_bParent;
|
||||
|
||||
D3DXMATRIX m_TmMatrix;
|
||||
|
||||
// vertex info
|
||||
D3DXVECTOR2 *m_Coord;
|
||||
D3DXVECTOR3 *m_CoordFace;
|
||||
|
||||
D3DXVECTOR3 *m_Vert;
|
||||
D3DXVECTOR4 *m_Face;
|
||||
D3DXVECTOR3 *m_Fnormal;
|
||||
D3DXVECTOR3 *m_Normal;
|
||||
int m_MatId;
|
||||
|
||||
int m_Frame;
|
||||
int m_CoordNum;
|
||||
int m_VertexNum;
|
||||
int m_iStartBufferIndex;
|
||||
|
||||
int m_FaceNum;
|
||||
// anikey info
|
||||
int m_RotKeyNum;
|
||||
int m_PosKeyNum;
|
||||
int m_ScaleKeyNum;
|
||||
int m_VisKeyNum;
|
||||
//morphing
|
||||
int m_MorphNum;
|
||||
// <20>߰<EFBFBD><DFB0><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool m_Bil1;
|
||||
bool m_Bil2;
|
||||
bool m_Bil3;
|
||||
// multy uv ani
|
||||
bool m_Multy;
|
||||
bool m_TexAni;
|
||||
bool m_RandAni;
|
||||
bool m_RandStartTexAni; //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ٸ<EFBFBD> <20>ؽ<EFBFBD><D8BD><EFBFBD> <20>ִ<EFBFBD> flag
|
||||
bool m_RandStartSetting; //start <20>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool m_Zenable;
|
||||
bool m_Opacity;
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> texture <20><><EFBFBD><EFBFBD>
|
||||
int m_AniTextureNum;
|
||||
int m_CurrentAniTexture;
|
||||
int m_BeforeAniTexture;
|
||||
|
||||
int m_Red;
|
||||
int m_Green;
|
||||
int m_Blue;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
bool m_bH;
|
||||
// cullmode on flag
|
||||
bool m_bCull;
|
||||
|
||||
float m_AniChangeFrame;
|
||||
//tex ani start frame
|
||||
float m_StartTexAniFrame;
|
||||
|
||||
bool m_Zbuffer;
|
||||
bool m_bDecal;
|
||||
|
||||
GemObject *m_Morph;
|
||||
|
||||
|
||||
|
||||
GemVisKey *m_Vis;
|
||||
GemScaleKey *m_Scale;
|
||||
GemPosKey *m_Pos;
|
||||
GemRotKey *m_Rot;
|
||||
DWORD m_Color;
|
||||
// vertex buffer <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD> vert pointer
|
||||
GemVertex *m_VertexBuffer;
|
||||
bool m_bInterpol;
|
||||
|
||||
GemObject() {
|
||||
|
||||
m_Multy = false;
|
||||
m_RotKeyNum = m_PosKeyNum = m_ScaleKeyNum = m_VisKeyNum = 0;
|
||||
m_Vis = NULL;
|
||||
m_Scale = NULL;
|
||||
m_Pos = NULL;
|
||||
m_Rot = NULL;
|
||||
m_Red = m_Green = m_Blue = 255;
|
||||
m_bH = false;
|
||||
//morphing vertex
|
||||
m_Morph = NULL;
|
||||
m_MorphNum = 0;
|
||||
m_StartTexAniFrame = 0.0f;
|
||||
m_Zbuffer = false;
|
||||
m_Zenable = false;
|
||||
|
||||
m_bCull = false;
|
||||
m_Color = D3DCOLOR_ARGB(255,255,255,255);
|
||||
|
||||
m_MatId = -1;
|
||||
|
||||
m_Frame = -1;
|
||||
m_VertexNum = 0;
|
||||
m_FaceNum = 0;
|
||||
m_CoordNum =0;
|
||||
|
||||
m_Coord = NULL;
|
||||
m_CoordFace = NULL;
|
||||
|
||||
m_Vert = NULL;
|
||||
m_Face = NULL;
|
||||
m_Fnormal = NULL;
|
||||
m_Normal = NULL;
|
||||
m_bParent = false;
|
||||
m_Bil1 = m_Bil2 = m_Bil3 = false;
|
||||
m_TexAni = false;
|
||||
m_RandAni = false;
|
||||
m_RandStartTexAni = false;
|
||||
m_RandStartSetting = false;
|
||||
m_Opacity = false;
|
||||
m_AniChangeFrame = 0.0f;
|
||||
m_AniTextureNum = 0;
|
||||
m_CurrentAniTexture = 0;
|
||||
m_BeforeAniTexture = 0;
|
||||
D3DXMatrixIdentity(&m_TmMatrix);
|
||||
memset(m_Name,0,sizeof(char)*BUF_SIZE);
|
||||
memset(m_ParentName,0,sizeof(char)*BUF_SIZE);
|
||||
m_VertexBuffer = NULL;
|
||||
m_bInterpol = true;
|
||||
m_bDecal = false;
|
||||
m_iStartBufferIndex = 0;
|
||||
|
||||
}
|
||||
~GemObject() {
|
||||
if(m_Scale != NULL)
|
||||
delete[] m_Scale;
|
||||
if(m_Vis != NULL)
|
||||
delete[] m_Vis;
|
||||
if(m_Vert != NULL)
|
||||
delete[] m_Vert;
|
||||
if(m_Face != NULL)
|
||||
delete[] m_Face;
|
||||
if(m_Coord != NULL)
|
||||
delete[] m_Coord;
|
||||
if(m_CoordFace != NULL)
|
||||
delete[] m_CoordFace;
|
||||
if(m_Fnormal != NULL)
|
||||
delete[] m_Fnormal;
|
||||
if(m_Normal != NULL)
|
||||
delete[] m_Normal;
|
||||
if(m_Rot)
|
||||
delete[] m_Rot;
|
||||
if(m_Pos)
|
||||
delete[] m_Pos;
|
||||
if(m_Morph)
|
||||
delete[] m_Morph;
|
||||
if(m_VertexBuffer)
|
||||
delete[] m_VertexBuffer;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class GemMaterial {
|
||||
public:
|
||||
char m_TextureName[BUF_SIZE];
|
||||
int m_SubNum;
|
||||
GemMaterial *m_Sub;
|
||||
GemMaterial() {
|
||||
memset(m_TextureName,0,BUF_SIZE);
|
||||
m_Sub = NULL;
|
||||
m_SubNum = 0;
|
||||
}
|
||||
~GemMaterial() {
|
||||
if(m_SubNum)
|
||||
delete[] m_Sub;
|
||||
}
|
||||
};
|
||||
CGemRender();
|
||||
~CGemRender();
|
||||
|
||||
void SetTransMatrix(D3DXMATRIX m) {m_TrMatrix = m;}
|
||||
bool CheckPosition(D3DXVECTOR3 center,D3DXVECTOR3 user);
|
||||
void SetXrot(float rot) { m_Xrot = rot;}
|
||||
void SetYrot(float rot) { m_Yrot = rot;}
|
||||
void SetZrot(float rot) { m_Zrot = rot;}
|
||||
|
||||
|
||||
void ScaleAni(int object_index,D3DXMATRIX &);
|
||||
void PosAni(int object_index,D3DXMATRIX &);
|
||||
void RotAni(int object_index,D3DXMATRIX &);
|
||||
|
||||
bool LoadGemFile(char *,LPDIRECT3DDEVICE8 ,bool bVisibility = true);
|
||||
bool LoadUvFile(char *);
|
||||
|
||||
bool LoadMorph(int );
|
||||
void MsgPrint(char *);
|
||||
void SetInitBuffer();
|
||||
|
||||
void SetVertexBuffer(int index);
|
||||
void SetDecalBuffer(int index); // Vertex Buffer <20><> <20><><EFBFBD><EFBFBD>
|
||||
void SetDecalBufferInit(int index); // Decal Buffer Init
|
||||
|
||||
void SetStartFrame(float s);
|
||||
|
||||
void SetCash(bool b) { m_bCash = b;}
|
||||
|
||||
void Render();
|
||||
void RenderObject(int object_index);
|
||||
|
||||
void Update();
|
||||
void Update(D3DXVECTOR3 center,D3DXVECTOR3 user);
|
||||
|
||||
void UnUpdate();
|
||||
bool VertexInterpolation(int index);
|
||||
void LoadSubFace(int object_index);
|
||||
void LoadTexture();
|
||||
// set zbuffer cullface all object
|
||||
void SetCullZbuffer(bool );
|
||||
// my effect setting
|
||||
void SetMine(bool t);
|
||||
|
||||
void LoadTexAni(int object_index);
|
||||
bool VisAni(int object_index);
|
||||
void CreateAniTm(int index,D3DXMATRIX &,D3DXMATRIX &);
|
||||
void SetChangeAniFrame(int object_index,float f);
|
||||
void SetStartTexAniFrame(int object_index,float f);
|
||||
int GetMaxFrame() {return (m_EndF / m_UnitF);}
|
||||
// effect scale setting func
|
||||
void SetScale(float x,float y,float z);
|
||||
void SetEffectPos(float x,float y,float z);
|
||||
void SetEffectPos(D3DXVECTOR3 pos);
|
||||
void SetCurrentFrame(float f);
|
||||
void SetCurrentFrame(float f,int *,DWORD *,bool *,bool update = false);
|
||||
|
||||
void SetSrcBlend(DWORD s) {m_SrcBlend = s;}
|
||||
void SetDstBlend(DWORD d) {m_DstBlend = d;}
|
||||
void SetBlend(DWORD s,DWORD d) { m_SrcBlend = s; m_DstBlend = d;}
|
||||
void SetColor(int object_index,int r,int g,int b);
|
||||
void SetNullTexture(bool b) {m_bNullTexture = b;}
|
||||
void SetPickObject(int index);
|
||||
void SetVot(float v) {m_Vot = v;}
|
||||
void SetLoop(bool b) {m_bLoop = b;}
|
||||
int GetObjectNum() {return m_ObjectNum;}
|
||||
void SetStartTexAni(bool b) {m_bTexAni = b;}
|
||||
void SetAxis(D3DXMATRIX & );
|
||||
void GetAxis(float ,float ,float ,float );
|
||||
void GetAxis(D3DXQUATERNION tmp) {m_AxisSet = true; m_Axis = tmp;}
|
||||
// ANI MESH USE
|
||||
void SetRandAni(bool b) {m_RandAni = b;}
|
||||
void SetRandAniMax(float s) {m_RandAniMax = s;}
|
||||
void SetRandAniMin(float s) {m_RandAniMin = s;}
|
||||
void SetSwitchAni(bool b) {m_SwitchAni = b;}
|
||||
void SetAniRad(float r) {m_AniRad = r;}
|
||||
// light <20><><EFBFBD><EFBFBD> mesh
|
||||
void SetLight(bool b) {m_bLight = b;}
|
||||
char *GetFileName() {return m_FileName;}
|
||||
|
||||
FILE *m_GemFile;
|
||||
//multy uv
|
||||
int m_bMulty;
|
||||
|
||||
int m_StartF;
|
||||
int m_EndF;
|
||||
int m_UnitF;
|
||||
int m_ObjectNum;
|
||||
int m_PickObject;
|
||||
|
||||
int m_MatNum;
|
||||
bool m_bNullTexture;
|
||||
bool m_bLoop;
|
||||
bool m_bCash;
|
||||
|
||||
bool m_bTexAni;
|
||||
bool m_Mine;
|
||||
bool m_bDecal;
|
||||
|
||||
DWORD m_SrcBlend,m_DstBlend;
|
||||
|
||||
float m_CurrentF;
|
||||
LPDIRECT3DDEVICE8 m_Device;
|
||||
D3DXMATRIX m_Scale;
|
||||
D3DXMATRIX m_TrMatrix;
|
||||
D3DXVECTOR3 m_Pos;
|
||||
D3DXQUATERNION global;
|
||||
D3DXQUATERNION m_Axis;
|
||||
bool m_AxisSet;
|
||||
//ANI MESH
|
||||
float m_Xrot,m_Yrot,m_Zrot;
|
||||
bool m_RandAni;
|
||||
float m_RandAniMax;
|
||||
float m_RandAniMin;
|
||||
float m_AniRad;
|
||||
bool m_SwitchAni;
|
||||
bool m_StartSwitch;
|
||||
GemMaterial *m_Mtl;
|
||||
|
||||
|
||||
GemObject *m_Object;
|
||||
GemSubFace *m_Sub;
|
||||
|
||||
// LPDIRECT3DVERTEXBUFFER8 *m_ObjectVertex;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertexBuffer;
|
||||
int m_iTotalVertexNums;
|
||||
bool m_bDynamic;
|
||||
VOID *m_VertexLockPtr;
|
||||
|
||||
|
||||
GemTexture *m_Texture;
|
||||
GemTexture *m_TexAni;
|
||||
|
||||
int m_TexNum;
|
||||
float m_Vot;
|
||||
|
||||
//// vertex buffer <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20>ʿ<EFBFBD><CABF><EFBFBD> vert pointer
|
||||
//GemVertex *m_Vert;
|
||||
int VbufferNum;
|
||||
// multy uv ani
|
||||
CGemRender *m_Multy;
|
||||
bool m_bLight;
|
||||
char m_FileName[256];
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
1444
Engine/Effect/CLightning.cpp
Normal file
1444
Engine/Effect/CLightning.cpp
Normal file
File diff suppressed because it is too large
Load Diff
202
Engine/Effect/CLightning.h
Normal file
202
Engine/Effect/CLightning.h
Normal file
@@ -0,0 +1,202 @@
|
||||
#ifndef __CLIGHTNING_H__
|
||||
#define __CLIGHTNING_H__
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
|
||||
#define LIGHTHALFWIDTH 10.0f
|
||||
// lightning <20><> ǥ<><C7A5> <20>ϴ<EFBFBD> plane <20><><EFBFBD><EFBFBD>
|
||||
enum PLANE {
|
||||
LPLANE_ONE, // one plane
|
||||
LPLANE_CROSS, //<2F><><EFBFBD><EFBFBD> plane
|
||||
LPLANE_X, // X<><58> plane
|
||||
};
|
||||
enum LIGHTNINGVALUE { // <20><EFBFBD><EEB6B2><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> : 0 <20><><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE>, <20><><EFBFBD><EFBFBD>, 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
|
||||
LV_LIGHTNING,
|
||||
LV_BEZIER,
|
||||
|
||||
};
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CLightning {
|
||||
public:
|
||||
class CLightVertex {
|
||||
public:
|
||||
float x,y,z;
|
||||
DWORD color;
|
||||
float s,t;
|
||||
CLightVertex() {
|
||||
x = y = z = 0.0f;
|
||||
color = D3DCOLOR_ARGB(255,255,255,255);
|
||||
s = t = 0.0f;
|
||||
}
|
||||
~CLightVertex() {}
|
||||
|
||||
};
|
||||
class CBezierInfo { // Bezier Line <20><><EFBFBD><EFBFBD> Data
|
||||
public:
|
||||
float m_fControl;
|
||||
float m_fControlHeight;
|
||||
float m_fSpeed;
|
||||
float m_fAccel;
|
||||
float m_fStartEndLength;
|
||||
float m_fFade;
|
||||
float m_fLimitLength;
|
||||
float m_ft;
|
||||
int m_iAxis;
|
||||
int m_iEndSpeed;
|
||||
int m_iEndAccel;
|
||||
int m_iUvMode;
|
||||
|
||||
CBezierInfo() {
|
||||
|
||||
m_fControl = 0.5;
|
||||
m_fControlHeight = 30.0f;
|
||||
m_fSpeed = 0.0f;
|
||||
m_fAccel = 0.0f;
|
||||
m_fStartEndLength = 0.0f;
|
||||
m_fFade = 0.0f;
|
||||
m_fLimitLength = 0.0f;
|
||||
m_ft = 0.05f;
|
||||
m_iAxis = 0;
|
||||
|
||||
m_iEndSpeed = 0;
|
||||
m_iEndAccel = 0;
|
||||
m_iUvMode = 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
// Bezier Point List
|
||||
vector<D3DXVECTOR3> m_BezierPointList;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
D3DXVECTOR3 *m_PointList;
|
||||
int m_EndCount;
|
||||
|
||||
int m_PointNum;
|
||||
// <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> width
|
||||
float m_QuadHalfWidth;
|
||||
// insert <20><> point
|
||||
int m_InsertCount;
|
||||
// render <20><> count
|
||||
int m_RenderCount;
|
||||
int m_MaxRenderCount;
|
||||
|
||||
LPDIRECT3DDEVICE8 m_Device;
|
||||
//<2F><><EFBFBD><EFBFBD> <20>÷<EFBFBD>
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_Vert;
|
||||
// <20><><EFBFBD><EFBFBD> <20>÷<EFBFBD>
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_VerticalVert;
|
||||
// <20><><EFBFBD><EFBFBD> <20>÷<EFBFBD> 2
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_VerticalVert2;
|
||||
int m_VertNum;
|
||||
CTexture *m_Texture;
|
||||
int m_TexNum;
|
||||
//shake value <20>ּ<EFBFBD>ġ
|
||||
float m_ShakeMin;
|
||||
//shake value <20>ִ<EFBFBD>ġ
|
||||
float m_ShakeMax;
|
||||
|
||||
DWORD m_Color;
|
||||
float m_Alpha;
|
||||
|
||||
bool m_bFadeOut;
|
||||
float m_FadeSpeed;
|
||||
// uv ani <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ġ
|
||||
float m_UvAni;
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD>Ǵ<EFBFBD> uv <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
float m_UnitUv;
|
||||
// <20><><EFBFBD><EFBFBD>, 1<><31> <20>÷<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
int m_PlaneValue;
|
||||
// <20><><EFBFBD><EFBFBD>Ʈ end setting
|
||||
bool m_bSetEndEffect;
|
||||
// <20>پ<EFBFBD><D9BE><EFBFBD><EFBFBD><EFBFBD> <20>ӵ<EFBFBD>
|
||||
int m_EndUnit;
|
||||
|
||||
int m_LightningValue;
|
||||
|
||||
// Bezier Value
|
||||
CBezierInfo m_Bezier;
|
||||
bool m_bCrash; // <20>浹<EFBFBD><E6B5B9> light beam <20>ΰ<EFBFBD>?
|
||||
bool m_bEndInput;
|
||||
|
||||
int m_iAlpha; // <20>浹<EFBFBD><E6B5B9> light beam alpha value
|
||||
|
||||
CLightVertex *tmp_Vertex;
|
||||
CLightVertex *tmp_Vertex2;
|
||||
CLightVertex *tmp_Vertex3;
|
||||
|
||||
|
||||
CLightning(LPDIRECT3DDEVICE8 );
|
||||
CLightning(int ,LPDIRECT3DDEVICE8 );
|
||||
CLightning();
|
||||
|
||||
~CLightning();
|
||||
//wheel<65><6C> <20><><EFBFBD>õǾ<C3B5> <20>ִ<EFBFBD> esf <20><><EFBFBD><EFBFBD> wheel <20><> <20><><EFBFBD>̻<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> setting
|
||||
// render2<72><32> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>
|
||||
void SetEffectEnd(bool s,int end) {m_bSetEndEffect = s; m_EndUnit = end;}
|
||||
|
||||
void SetUnitUv(float s) {m_UnitUv = s;}
|
||||
|
||||
void SetSize(float s) {m_QuadHalfWidth = s;}
|
||||
|
||||
void SetDevice(LPDIRECT3DDEVICE8 device) {m_Device = device;}
|
||||
|
||||
void SetShakeValue(float smin,float smax) {m_ShakeMin = smin;
|
||||
m_ShakeMax = smax;}
|
||||
|
||||
void CreateList(int );
|
||||
void DeleteList();
|
||||
|
||||
void InsertPoint(float ,float ,float );
|
||||
void InsertPoint(D3DXVECTOR3 );
|
||||
void InsertEmptyPoint(float ,float ,float );
|
||||
void SetStartPoint(float ,float ,float );
|
||||
void SetVertNum(int n) {m_VertNum = n;}
|
||||
void SetFadeStart(bool t) {m_bFadeOut = t;}
|
||||
void SetFadeSpeed(float s) { m_FadeSpeed = s;}
|
||||
bool GetEnd();
|
||||
void SetEnd();
|
||||
void SetEndPoint(float ,float ,float );
|
||||
void SetRandPoint();
|
||||
bool SetBezierPoint(); //Bezier Curve Point Setting
|
||||
|
||||
void SetColor(DWORD c) {m_Color = c;}
|
||||
void SetColor();
|
||||
void SetPlaneValue(int k) { m_PlaneValue = k;}
|
||||
|
||||
void CreateTexture(int );
|
||||
void SetTexture(int ,char *);
|
||||
|
||||
void CreateVertexBuffer();
|
||||
void SetVertexBuffer(int ,int wheelvalue = 0 );
|
||||
void SetBezierBuffer(int ,int wheelvalue = 0 );
|
||||
|
||||
void Render(int blendmode);
|
||||
void SetCrash(bool b) { m_bCrash = b;} // Crash Check Setting Func
|
||||
|
||||
// wheel (<28><><EFBFBD><EFBFBD> <20><EFBFBD><D7B8><EFBFBD> <20><>ƾ)
|
||||
void Render2(int blendmode);
|
||||
|
||||
bool UpdateLightning(D3DXVECTOR3 &pos,bool bCrash);
|
||||
|
||||
void SetLightningValue(int t) { m_LightningValue = t;}
|
||||
void SetBezierControl(float control,float height,float speed,float accel,float length,
|
||||
float fade,float limitlength,int axis,int endspeed,int endaccel,int uv);
|
||||
|
||||
D3DXVECTOR3 GetBezierLastPos();
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
65
Engine/Effect/EffAseDefine.h
Normal file
65
Engine/Effect/EffAseDefine.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/************************
|
||||
ase label define
|
||||
**************************/
|
||||
|
||||
|
||||
|
||||
#ifndef __EFFASEDEFINE_H__
|
||||
|
||||
#define __EFFASEDEFINE_H__
|
||||
|
||||
#define OBJECT "*GEOMOBJECT" // An object tag for new objects
|
||||
#define LIGHT_OBJECT "*LIGHTOBJECT"
|
||||
#define NODE_NAME "*NODE_NAME"
|
||||
#define NODE_PARENT "*NODE_PARENT"
|
||||
#define NODE_TM "*NODE_TM"
|
||||
#define TM_ROW0 "*TM_ROW0"
|
||||
#define TM_ROW1 "*TM_ROW1"
|
||||
#define TM_ROW2 "*TM_ROW2"
|
||||
#define TM_ROW3 "*TM_ROW3"
|
||||
#define TM_POS "*TM_POS"
|
||||
#define TM_ROTAXIS "*TM_ROTAXIS"
|
||||
#define TM_ROTANGLE "*TM_ROTANGLE"
|
||||
#define TM_SCALE "*TM_SCALE"
|
||||
#define TM_SCALEAXIS "*TM_SCALEAXIS"
|
||||
#define TM_SCALEAXISANG "*TM_SCALEAXISANG"
|
||||
|
||||
#define BLOCK_START "{"
|
||||
#define BLOCK_END "}"
|
||||
|
||||
#define NUM_VERTEX "*MESH_NUMVERTEX" // The number of vertices tag
|
||||
#define NUM_FACES "*MESH_NUMFACES" // The number of faces tag
|
||||
#define NUM_TVERTEX "*MESH_NUMTVERTEX" // The number of texture coordinates
|
||||
#define VERTEX "*MESH_VERTEX" // The list of vertices tag
|
||||
#define FACE "*MESH_FACE" // The list of faces tag
|
||||
#define NORMALS "*MESH_NORMALS" // The list of normals tag (If you want)
|
||||
#define FACE_NORMAL "*MESH_FACENORMAL" // The face normal for the current index
|
||||
#define NVERTEX "*MESH_VERTEXNORMAL" // The list of vertex normals
|
||||
#define TVERTEX "*MESH_TVERT" // The texture coordinate index tag
|
||||
#define TFACE "*MESH_TFACE" // The vertex index tag
|
||||
#define TEXTURE "*BITMAP" // The file name for the object's texture map
|
||||
#define UTILE "*UVW_U_TILING" // The U tiling ratio tag
|
||||
#define VTILE "*UVW_V_TILING" // The V tiling ratio tag
|
||||
#define UOFFSET "*UVW_U_OFFSET" // The U tile offset tag
|
||||
#define VOFFSET "*UVW_V_OFFSET" // The V tile offset tag
|
||||
#define MATERIAL_ID "*MATERIAL_REF" // The material ID tag
|
||||
#define MATERIAL_COUNT "*MATERIAL_COUNT" // The material count tag
|
||||
#define MATERIAL "*MATERIAL" // The material tag
|
||||
#define MATERIAL_NAME "*MATERIAL_NAME" // The material name tag
|
||||
#define MATERIAL_COLOR "*MATERIAL_DIFFUSE" // The material color tag
|
||||
|
||||
#define TM_ANIMATION "*TM_ANIMATION"
|
||||
#define CONTROL_ROT_TCB "*CONTROL_ROT_TCB"
|
||||
#define CONTROL_TCB_ROT_KEY "*CONTROL_TCB_ROT_KEY"
|
||||
#define CONTROL_POS_BEZIER "*CONTROL_POS_BEZIER"
|
||||
#define CONTROL_BEZIER_POS_KEY "*CONTROL_BEZIER_POS_KEY"
|
||||
#define CONTROL_SCALE_BEZIER "*CONTROL_SCALE_BEZIER"
|
||||
#define CONTROL_BEZIER_SCALE_KEY "*CONTROL_BEZIER_SCALE_KEY"
|
||||
///////////////////////////////////
|
||||
// mesh ani value
|
||||
//////////////////////////////////
|
||||
#define MESH_ANIMATION "*MESH_ANIMATION"
|
||||
// use check ani frame num.
|
||||
#define MESH_TIMEVALUE "*TIMEVALUE"
|
||||
|
||||
#endif
|
||||
9
Engine/Effect/EffDebugLog.cpp
Normal file
9
Engine/Effect/EffDebugLog.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "EffDebugLog.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
void WriteDebug(char *strErr) {
|
||||
char *strDebugFile = "EffectErr.txt";
|
||||
FILE *fp = fopen(strDebugFile,"at+");
|
||||
fprintf(fp,"File Not Found : %s\n",strErr);
|
||||
fclose(fp);
|
||||
}
|
||||
8
Engine/Effect/EffDebugLog.h
Normal file
8
Engine/Effect/EffDebugLog.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef __EFFDEBUGLOG__H__
|
||||
#define __EFFDEBUGLOG__H__
|
||||
|
||||
#include "stdio.h"
|
||||
|
||||
void WriteDebug(char *strErr);
|
||||
|
||||
#endif
|
||||
1231
Engine/Effect/EffMeshloader.cpp
Normal file
1231
Engine/Effect/EffMeshloader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
232
Engine/Effect/EffMeshloader.h
Normal file
232
Engine/Effect/EffMeshloader.h
Normal file
@@ -0,0 +1,232 @@
|
||||
#ifndef __EFFECTMESH_H__
|
||||
#define __EFFECTMESH_H__
|
||||
|
||||
#define BUF_SIZE 256
|
||||
|
||||
#include <vector>
|
||||
#include "EffAseDefine.h"
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
|
||||
#define EFF_FILE "GEMDatafile"
|
||||
#define VOT 1.0f
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
class CEffectMesh {
|
||||
public:
|
||||
CEffectMesh();
|
||||
~CEffectMesh();
|
||||
|
||||
|
||||
bool LoadWadfile(char *filename,LPDIRECT3DDEVICE8 );
|
||||
float Render(LPDIRECT3DDEVICE8 ,D3DXVECTOR3 );
|
||||
D3DXMATRIX RotateObject(LPDIRECT3DDEVICE8 ,int object_index,float frame,D3DXMATRIX *w);
|
||||
D3DXMATRIX TranslateObject(LPDIRECT3DDEVICE8 d_device,int object_index,float frame,D3DXMATRIX *w);
|
||||
D3DXMATRIX ScaleObject(LPDIRECT3DDEVICE8 ,int object_index,float frame,D3DXMATRIX *w);
|
||||
int vertex_interpolation(int object_index,float now_frame);
|
||||
void Change_Vertexbuffer(int object_index);
|
||||
void SetObjectColor(int obj_num,int r,int g,int b,int a);
|
||||
void Create_Vertex(int i,LPDIRECT3DDEVICE8 );
|
||||
void CreateTexture(LPDIRECT3DDEVICE8 device);
|
||||
void CreateAniTexture(LPDIRECT3DDEVICE8 device,int obj_num);
|
||||
void LoadSubface(int object_index);
|
||||
void SetTexAniFrame(int object_index,float frame);
|
||||
void SetStartTexAni(int object_index,float frame);
|
||||
void StartTexAni(bool b) {m_texanistart = b;}
|
||||
void SetPickColor(int object_index,int r,int g,int b,int a);
|
||||
//picking <20>Ǿ<EFBFBD><C7BE>ִ<EFBFBD> object <20><> index
|
||||
void SetPickNum(int n) {pick_index = n;}
|
||||
void SetNullTexture(bool b) {m_NullTexture = b;}
|
||||
float UpdateMesh();
|
||||
|
||||
void SetFrame(float f);
|
||||
|
||||
void SetColor(int r,int g,int b,int a) {Color = D3DCOLOR_ARGB(a,r,g,b);}
|
||||
// alpha : 0~255
|
||||
float GetMaxframe() {return max_frame;}
|
||||
int GetObjectNum(){return Model.object_num;}
|
||||
void SetAlpha(int );
|
||||
void SetLoop(bool b) {m_Loop = b; }
|
||||
void StartAni(bool b) {m_Start = b;}
|
||||
void SetBlend(DWORD s,DWORD d) {SrcBlend = s; DstBlend = d;}
|
||||
|
||||
bool GetStart() {return m_Start;}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
void SetVot(float n) {vot = n;}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// in class
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class WadFace {
|
||||
public:
|
||||
vector<int> sub;
|
||||
int sub_num;
|
||||
};
|
||||
class WadTexture {
|
||||
public:
|
||||
vector<LPDIRECT3DTEXTURE8 *> tex;
|
||||
int tex_num;
|
||||
};
|
||||
class custom_vertex{
|
||||
public:
|
||||
float x,y,z;
|
||||
float nx,ny,nz;
|
||||
float s,t;
|
||||
};
|
||||
class custom_vertex2{
|
||||
public:
|
||||
float x,y,z;
|
||||
};
|
||||
|
||||
class AseFace{
|
||||
public:
|
||||
int vertex_index[4];
|
||||
int coord_index[3];
|
||||
};
|
||||
class AseMaterial{
|
||||
public:
|
||||
char texture_name[255];
|
||||
char texture_file[255];
|
||||
BYTE color[3];
|
||||
// standard ot multy/sub
|
||||
int mat_class;
|
||||
AseMaterial *sub;
|
||||
int sub_num;
|
||||
float fcolor[3];
|
||||
int tex_id;
|
||||
float u_tile;
|
||||
float v_tile;
|
||||
float u_offset;
|
||||
float v_offset;
|
||||
};
|
||||
class AseRotKey{
|
||||
public:
|
||||
int frame_num;
|
||||
float x,y,z,w;
|
||||
};
|
||||
class AsePosKey{
|
||||
public:
|
||||
int frame_num;
|
||||
float x,y,z;
|
||||
};
|
||||
class AseScaleKey{
|
||||
public:
|
||||
int frame_num;
|
||||
float x,y,z;
|
||||
};
|
||||
class AseMorphObject{
|
||||
public:
|
||||
D3DXVECTOR3 *vertex;
|
||||
D3DXVECTOR2 *texcoord;
|
||||
D3DXVECTOR3 *normal;
|
||||
AseFace *face;
|
||||
int keynum;
|
||||
};
|
||||
|
||||
class AseObject{
|
||||
public:
|
||||
int material_id;
|
||||
int vertex_num;
|
||||
int face_num;
|
||||
int texcoord_num;
|
||||
bool btexture;
|
||||
bool bmorph;
|
||||
//bilboard mesh
|
||||
bool bBil;
|
||||
// bilboard2 mesh
|
||||
bool bBil2;
|
||||
// texture change ani.
|
||||
bool bTexani;
|
||||
// morphing <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool bMorphStart;
|
||||
// texture random change ani.
|
||||
bool bRandTex;
|
||||
//cull face
|
||||
bool bCull;
|
||||
// Ani texture num
|
||||
int AniTexNum;
|
||||
bool bZ;
|
||||
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20>ҷ<EFBFBD><D2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> tex index
|
||||
int current_tex;
|
||||
|
||||
char object_name[255];
|
||||
char parent_name[255];
|
||||
bool bparent;
|
||||
D3DXVECTOR3 *vertex;
|
||||
D3DXVECTOR2 *texcoord;
|
||||
D3DXVECTOR3 *normal;
|
||||
bool bnormal;
|
||||
//object <20><> RGBA
|
||||
DWORD ObjectColor;
|
||||
DWORD ObjectPickColor;
|
||||
|
||||
// ani texture
|
||||
CTexture *anitexture;
|
||||
|
||||
D3DXMATRIX matrix;
|
||||
D3DXVECTOR3 pos;
|
||||
D3DXVECTOR3 rot_axis;
|
||||
float rot_angle;
|
||||
vector<AseRotKey> rot_key;
|
||||
vector<AseMorphObject> morph;
|
||||
int morph_num;
|
||||
vector<AsePosKey> pos_key;
|
||||
int pos_keyNum;
|
||||
//
|
||||
vector<AseScaleKey> scale_key;
|
||||
int scale_KeyNum;
|
||||
int rot_keyNum;
|
||||
D3DXVECTOR3 scale;
|
||||
D3DXVECTOR3 scale_axis;
|
||||
D3DXQUATERNION *rot_quatkey;
|
||||
AseFace *face;
|
||||
float texstart_frame;
|
||||
float texchange_frame;
|
||||
};
|
||||
|
||||
class AseModel {
|
||||
public:
|
||||
int object_num;
|
||||
int material_num;
|
||||
vector<AseObject> pobject;
|
||||
vector<AseMaterial> pmaterial;
|
||||
};
|
||||
AseModel Model;
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
private:
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 *object;
|
||||
CTexture *texture;
|
||||
|
||||
int pick_index;
|
||||
int texture_count;
|
||||
DWORD Color;
|
||||
|
||||
WadFace *object_sub;
|
||||
|
||||
custom_vertex *vert;
|
||||
D3DXVECTOR3 *vert2;
|
||||
float frame;
|
||||
float max_frame;
|
||||
|
||||
DWORD SrcBlend,DstBlend;
|
||||
int vot;
|
||||
// ani loop <20><><EFBFBD><EFBFBD> <20>ȵ<EFBFBD><C8B5><EFBFBD>
|
||||
bool m_Loop;
|
||||
// ani <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ƴ<EFBFBD><C6B4><EFBFBD>..
|
||||
bool m_Start;
|
||||
bool m_texanistart;
|
||||
bool m_NullTexture;
|
||||
FILE *wadfile;
|
||||
};
|
||||
|
||||
#endif
|
||||
341
Engine/Effect/Effect.vcproj
Normal file
341
Engine/Effect/Effect.vcproj
Normal file
@@ -0,0 +1,341 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="Effect"
|
||||
ProjectGUID="{AE5E7ECA-0D7F-4538-B80C-900B07AA00CE}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_NoGD|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="../SoundLib;"../Zalla3D Scene Class";"../Zalla3D Base Class";../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/Effect.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="<22>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\CEffscript.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CGemRender.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CLightning.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\EffDebugLog.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MemoryPool.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SMRHeader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SMRObj.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffect.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectBase.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectBillboard.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectCylinder.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectManager.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectMesh.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectParticle.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectPlane.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectSphere.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\CEffscript.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CEffscriptDefine.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CGemRender.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\CLightning.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\EffDebugLog.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Key.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\MemoryPool.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SMRHeader.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SMRObj.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffect.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectBase.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectBillboard.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectCylinder.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectManager.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectMesh.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectParticle.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectPlane.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\X3DEffectSphere.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
229
Engine/Effect/Effect.vcxproj
Normal file
229
Engine/Effect/Effect.vcxproj
Normal file
@@ -0,0 +1,229 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug_MY|Win32">
|
||||
<Configuration>Debug_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_MY|Win32">
|
||||
<Configuration>Release_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_NoGD|Win32">
|
||||
<Configuration>Release_NoGD</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{AE5E7ECA-0D7F-4538-B80C-900B07AA00CE}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</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" />
|
||||
</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" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>../SoundLib;../Zalla3D Scene Class;../Zalla3D Base Class;../../Client/CharacterActionControl/;../Caldron;../../Client/GlobalScript;../../MemoryManager;../CrossM/Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)Effect.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CEffscript.cpp" />
|
||||
<ClCompile Include="CGemRender.cpp" />
|
||||
<ClCompile Include="CLightning.cpp" />
|
||||
<ClCompile Include="EffDebugLog.cpp" />
|
||||
<ClCompile Include="MemoryPool.cpp" />
|
||||
<ClCompile Include="SMRHeader.cpp" />
|
||||
<ClCompile Include="SMRObj.cpp" />
|
||||
<ClCompile Include="X3DEffect.cpp" />
|
||||
<ClCompile Include="X3DEffectBase.cpp" />
|
||||
<ClCompile Include="X3DEffectBillboard.cpp" />
|
||||
<ClCompile Include="X3DEffectCylinder.cpp" />
|
||||
<ClCompile Include="X3DEffectManager.cpp" />
|
||||
<ClCompile Include="X3DEffectMesh.cpp" />
|
||||
<ClCompile Include="X3DEffectParticle.cpp" />
|
||||
<ClCompile Include="X3DEffectPlane.cpp" />
|
||||
<ClCompile Include="X3DEffectSphere.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CEffscript.h" />
|
||||
<ClInclude Include="CEffscriptDefine.h" />
|
||||
<ClInclude Include="CGemRender.h" />
|
||||
<ClInclude Include="CLightning.h" />
|
||||
<ClInclude Include="EffDebugLog.h" />
|
||||
<ClInclude Include="Key.h" />
|
||||
<ClInclude Include="MemoryPool.h" />
|
||||
<ClInclude Include="SMRHeader.h" />
|
||||
<ClInclude Include="SMRObj.h" />
|
||||
<ClInclude Include="X3DEffect.h" />
|
||||
<ClInclude Include="X3DEffectBase.h" />
|
||||
<ClInclude Include="X3DEffectBillboard.h" />
|
||||
<ClInclude Include="X3DEffectCylinder.h" />
|
||||
<ClInclude Include="X3DEffectManager.h" />
|
||||
<ClInclude Include="X3DEffectMesh.h" />
|
||||
<ClInclude Include="X3DEffectParticle.h" />
|
||||
<ClInclude Include="X3DEffectPlane.h" />
|
||||
<ClInclude Include="X3DEffectSphere.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MemoryManager\MemoryManager.vcxproj">
|
||||
<Project>{b6bdd524-1dde-4a65-aed7-9ee4bc86a05d}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Zalla3D Base Class\Zalla3D Base Class.vcxproj">
|
||||
<Project>{663b3237-d6e2-4d71-8696-1425ebbedbad}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
126
Engine/Effect/Effect.vcxproj.filters
Normal file
126
Engine/Effect/Effect.vcxproj.filters
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="소스 파일">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="헤더 파일">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="리소스 파일">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CEffscript.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CGemRender.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CLightning.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EffDebugLog.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MemoryPool.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SMRHeader.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SMRObj.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffect.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectBase.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectBillboard.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectCylinder.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectManager.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectMesh.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectParticle.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectPlane.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="X3DEffectSphere.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="CEffscript.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CEffscriptDefine.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CGemRender.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CLightning.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EffDebugLog.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Key.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MemoryPool.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SMRHeader.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SMRObj.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffect.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectBase.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectBillboard.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectCylinder.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectManager.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectMesh.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectParticle.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectPlane.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="X3DEffectSphere.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
159
Engine/Effect/Key.h
Normal file
159
Engine/Effect/Key.h
Normal file
@@ -0,0 +1,159 @@
|
||||
#if !defined(KEY_H)
|
||||
#define KEY_H
|
||||
|
||||
#pragma warning(disable:4786) // don't warn about browse name overflow.
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <vector.h>
|
||||
#include <vertex.h>
|
||||
#include <quaternion.h>
|
||||
#include "z3dmath.h"
|
||||
|
||||
typedef std::map< unsigned long, vector3, std::less<unsigned long> > VectorKeyList;
|
||||
typedef std::map< unsigned long, quaternion, std::less<unsigned long> > QuaternionKeyList;
|
||||
typedef std::map< unsigned long, float, std::less<unsigned long> > FloatKeyList;
|
||||
typedef std::map< unsigned long, color, std::less<unsigned long> > ColorKeyList;
|
||||
|
||||
template <typename KeyList> class CKeyList
|
||||
{
|
||||
protected:
|
||||
KeyList m_lstKey;
|
||||
typename KeyList::iterator Lower, Upper;
|
||||
unsigned long dwLower, dwUpper;
|
||||
|
||||
public:
|
||||
CKeyList(void) { }
|
||||
~CKeyList(void) { }
|
||||
|
||||
typename KeyList::iterator Begin(void) { return m_lstKey.begin(); }
|
||||
typename KeyList::iterator End(void) { return m_lstKey.end(); }
|
||||
template <typename NewData> void SetKey(unsigned long dwFrame, NewData &Data) { m_lstKey[dwFrame] = Data; }
|
||||
template <typename NewData> BOOL Find(unsigned long dwFrame, NewData &Data)
|
||||
{
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = m_lstKey.find(dwFrame);
|
||||
if(Lower == m_lstKey.end())
|
||||
{
|
||||
Lower = m_lstKey.lower_bound(dwFrame);
|
||||
if(Lower != m_lstKey.begin()) { Lower--; }
|
||||
Data = ((*Lower).second);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
Data = ((*Lower).second);
|
||||
return TRUE;
|
||||
}
|
||||
BOOL Find(unsigned long dwFrame)
|
||||
{
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = m_lstKey.find(dwFrame);
|
||||
if(Lower == m_lstKey.end()) return FALSE; else return TRUE;
|
||||
}
|
||||
void Erase(unsigned long dwFrame)
|
||||
{
|
||||
Lower = m_lstKey.find(dwFrame);
|
||||
m_lstKey.erase(Lower);
|
||||
}
|
||||
template <typename DataType> void Load(FILE *fp, DataType &Data)
|
||||
{
|
||||
unsigned short frame;
|
||||
dwLower = 0;
|
||||
fread(&dwLower, 2, 1, fp);
|
||||
for(dwUpper = 0; dwUpper < dwLower; dwUpper++)
|
||||
{
|
||||
fread(&frame, 2, 1, fp);
|
||||
fread(&Data, sizeof(Data), 1, fp);
|
||||
m_lstKey[frame] = Data;
|
||||
}
|
||||
}
|
||||
void Save(FILE *fp)
|
||||
{
|
||||
dwLower = m_lstKey.size();
|
||||
fwrite(&dwLower, 2, 1, fp);
|
||||
for(Lower = m_lstKey.begin(); Lower != m_lstKey.end(); Lower++)
|
||||
{
|
||||
fwrite(&((*Lower).first), 2, 1, fp);
|
||||
fwrite(&((*Lower).second), sizeof((*Lower).second), 1, fp);
|
||||
}
|
||||
}
|
||||
BOOL InterpolationQ(float fFrame, quaternion &Data)
|
||||
{
|
||||
quaternion rdLower, rdUpper;
|
||||
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = Upper = m_lstKey.lower_bound(ceilf(fFrame));
|
||||
if(Upper == m_lstKey.begin()) { Upper = Lower; Upper++; } else { Lower--; }
|
||||
|
||||
dwLower = (*Lower).first;
|
||||
rdLower = (*Lower).second;
|
||||
if(Upper != m_lstKey.end())
|
||||
{
|
||||
dwUpper = (*Upper).first;
|
||||
rdUpper = (*Upper).second;
|
||||
z3d::QuaternionSlerp(Data, rdLower, rdUpper, 1.0f / (dwUpper - dwLower) * (fFrame - dwLower));
|
||||
} else
|
||||
{
|
||||
Data = rdLower;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
BOOL InterpolationC(float fFrame, color &Data)
|
||||
{
|
||||
color rdLower, rdUpper;
|
||||
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = Upper = m_lstKey.lower_bound(ceilf(fFrame));
|
||||
if(Upper == m_lstKey.begin()) { Upper = Lower; Upper++; } else { Lower--; }
|
||||
|
||||
dwLower = (*Lower).first;
|
||||
rdLower = (*Lower).second;
|
||||
if(Upper != m_lstKey.end())
|
||||
{
|
||||
dwUpper = (*Upper).first;
|
||||
rdUpper = (*Upper).second;
|
||||
Data = color::Interpolation(rdLower, rdUpper, 1.0f / (dwUpper - dwLower) * (fFrame - dwLower));
|
||||
} else
|
||||
{
|
||||
Data = rdLower;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
template <typename RetData> BOOL Interpolation(float fFrame, RetData &Data)
|
||||
{
|
||||
RetData rdLower, rdUpper;
|
||||
|
||||
if(m_lstKey.empty()) return FALSE;
|
||||
|
||||
Lower = Upper = m_lstKey.lower_bound(ceilf(fFrame));
|
||||
if(Upper == m_lstKey.begin()) { Upper = Lower; Upper++; } else { Lower--; }
|
||||
|
||||
dwLower = (*Lower).first;
|
||||
rdLower = (*Lower).second;
|
||||
if(Upper != m_lstKey.end())
|
||||
{
|
||||
dwUpper = (*Upper).first;
|
||||
rdUpper = (*Upper).second;
|
||||
Data = (((rdUpper - rdLower) / (dwUpper - dwLower)) * (fFrame - dwLower)) + rdLower;
|
||||
} else
|
||||
{
|
||||
Data = rdLower;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename KeyList, class Data>
|
||||
inline void SetKey(unsigned long dwFrame, KeyList &lstKey, Data NewData)
|
||||
{
|
||||
lstKey.SetKey(dwFrame, NewData);
|
||||
}
|
||||
|
||||
#endif // !defined(KEY_H)
|
||||
329
Engine/Effect/MemoryPool.cpp
Normal file
329
Engine/Effect/MemoryPool.cpp
Normal file
@@ -0,0 +1,329 @@
|
||||
#include "MemoryPool.h"
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include <new>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "GMMemory.h"
|
||||
|
||||
const char* const CFixedPool::ms_strErrLogFileName = "FixedMemoryPool_ErrLog.txt";
|
||||
|
||||
|
||||
struct CFixedPool::ChunkNode
|
||||
{
|
||||
ChunkNode* m_pNext;
|
||||
};
|
||||
|
||||
struct CFixedPool::AllocateInfo
|
||||
{
|
||||
AllocateInfo* m_pNext;
|
||||
|
||||
static const int ms_nPaddingSize;
|
||||
static const char* ms_strAllocatedPadding;
|
||||
static const char* ms_strDeallocatedPadding;
|
||||
static const char* ms_strNotUsedPadding;
|
||||
};
|
||||
|
||||
const char* CFixedPool::AllocateInfo::ms_strAllocatedPadding = "Aloc";
|
||||
const char* CFixedPool::AllocateInfo::ms_strDeallocatedPadding = "Free";
|
||||
const char* CFixedPool::AllocateInfo::ms_strNotUsedPadding = "Nuse";
|
||||
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
const int CFixedPool::AllocateInfo::ms_nPaddingSize = 4;
|
||||
#else
|
||||
const int CFixedPool::AllocateInfo::ms_nPaddingSize = 0;
|
||||
#endif
|
||||
|
||||
|
||||
#include "GMUndefNew.h"
|
||||
DEFINE_ALLOCATOR(CFixedPool)
|
||||
{
|
||||
if(nSize != m_nOriginalSize)
|
||||
{
|
||||
return operator new(nSize);
|
||||
}
|
||||
|
||||
m_PoolLock.Lock();
|
||||
|
||||
if(NULL == m_pNodeHead)
|
||||
{
|
||||
if(!AllocateChunks())
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
AllocateInfo* pNode = m_pNodeHead;
|
||||
m_pNodeHead = m_pNodeHead->m_pNext;
|
||||
++m_nTotalInUse;
|
||||
|
||||
m_PoolLock.Unlock();
|
||||
|
||||
char* pResult = reinterpret_cast<char*>(pNode);
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
memcpy(pResult + m_nPerAllocateSize - AllocateInfo::ms_nPaddingSize,
|
||||
AllocateInfo::ms_strAllocatedPadding, AllocateInfo::ms_nPaddingSize);
|
||||
#endif
|
||||
|
||||
return pResult + sizeof(AllocateInfo);
|
||||
}
|
||||
|
||||
|
||||
DEFINE_DEALLOCATOR(CFixedPool)
|
||||
{
|
||||
if(NULL == pDelete)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(nSize != m_nOriginalSize)
|
||||
{
|
||||
operator delete(pDelete);
|
||||
return;
|
||||
}
|
||||
|
||||
char* pszDelete = reinterpret_cast<char*>(pDelete) - sizeof(AllocateInfo);
|
||||
AllocateInfo* pNode = reinterpret_cast<AllocateInfo*>(pszDelete);
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
|
||||
// <09><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>÷ο<C3B7> Ȥ<><C8A4> <20><DEB8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
const char* pszPadding = pszDelete + m_nPerAllocateSize - AllocateInfo::ms_nPaddingSize;
|
||||
if(0 != memcmp(pszPadding, AllocateInfo::ms_strAllocatedPadding, AllocateInfo::ms_nPaddingSize))
|
||||
{
|
||||
LogBufferOverflow(pszPadding);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
m_PoolLock.Lock();
|
||||
|
||||
pNode->m_pNext = m_pNodeHead;
|
||||
m_pNodeHead = pNode;
|
||||
--m_nTotalInUse;
|
||||
|
||||
m_PoolLock.Unlock();
|
||||
}
|
||||
#include "GMRedefNew.h"
|
||||
|
||||
|
||||
|
||||
bool CFixedPool::AllocateChunks()
|
||||
{
|
||||
#include "GMUndefNew.h"
|
||||
// Allocation and make list
|
||||
ChunkNode* pChunkNode = reinterpret_cast<ChunkNode*>(
|
||||
::operator new(sizeof(ChunkNode) + m_nPerAllocateSize * m_nPerAllocateNum));
|
||||
#include "GMRedefNew.h"
|
||||
|
||||
if(0 == pChunkNode)
|
||||
{
|
||||
// Chunk <20><EFBFBD><DEB8><EFBFBD> <20>Ҵ<EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
return false;
|
||||
}
|
||||
|
||||
pChunkNode->m_pNext = m_pChunkHead;
|
||||
m_pChunkHead = pChunkNode;
|
||||
m_pNodeHead = reinterpret_cast<AllocateInfo*>(m_pChunkHead + 1);
|
||||
|
||||
m_nTotalAllocated += m_nPerAllocateNum; // <20><>ü <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
|
||||
char* pMakeList = reinterpret_cast<char*>(m_pNodeHead);
|
||||
size_t nAllocated = m_nPerAllocateNum - 1;
|
||||
|
||||
while(0 < nAllocated--)
|
||||
{
|
||||
reinterpret_cast<AllocateInfo*>(pMakeList)->m_pNext =
|
||||
reinterpret_cast<AllocateInfo*>(pMakeList + m_nPerAllocateSize);
|
||||
pMakeList += m_nPerAllocateSize;
|
||||
|
||||
#ifdef MEMPOOL_DBGMODE
|
||||
// <09><DEB8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD><EFBFBD> <20>е<EFBFBD><D0B5><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
memcpy(pMakeList - AllocateInfo::ms_nPaddingSize,
|
||||
AllocateInfo::ms_strNotUsedPadding, AllocateInfo::ms_nPaddingSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
reinterpret_cast<AllocateInfo*>(pMakeList)->m_pNext = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CFixedPool::CFixedPool()
|
||||
: m_pChunkHead(NULL), m_pNodeHead(NULL),
|
||||
m_nOriginalSize(0), m_nPerAllocateNum(0), m_nPerAllocateSize(0),
|
||||
m_nTotalAllocated(0), m_nTotalInUse(0)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
CFixedPool::CFixedPool(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen)
|
||||
: m_pChunkHead(NULL), m_pNodeHead(NULL),
|
||||
m_nOriginalSize(0), m_nPerAllocateNum(0), m_nPerAllocateSize(0),
|
||||
m_nTotalAllocated(0), m_nTotalInUse(0)
|
||||
{
|
||||
Initialize(nPerAllocateSize, nPerAllocateNum, strMaxPoolName, nNameLen);
|
||||
}
|
||||
|
||||
|
||||
CFixedPool::~CFixedPool()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool CFixedPool::Initialize(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen)
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_nOriginalSize = nPerAllocateSize;
|
||||
m_nPerAllocateNum = nPerAllocateNum;
|
||||
m_nPerAllocateSize = nPerAllocateSize + GetLeastAllocateSize();
|
||||
|
||||
const size_t nLastPos = min(nNameLen, MAX_POOL_NAME - 1);
|
||||
strncpy(m_pszPoolName, strMaxPoolName, nLastPos);
|
||||
m_pszPoolName[nLastPos] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CFixedPool::LogBufferOverflow(const char* lpBuffer)
|
||||
{
|
||||
FILE* pLogFile = fopen(ms_strErrLogFileName, "ab");
|
||||
if(NULL != pLogFile)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
__try
|
||||
{
|
||||
fprintf(pLogFile, "\n[%d-%d-%d %d:%d:%d] %s <20><EFBFBD><DEB8><EFBFBD> Ǯ<><C7AE><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>÷ο<C3B7> <20>Ǵ<EFBFBD>, "
|
||||
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><> <20>־<EFBFBD><D6BE><EFBFBD><EFBFBD>ϴ<EFBFBD>. PerAllocateSize = %d(0x%08x)\n<",
|
||||
sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, m_pszPoolName,
|
||||
m_nPerAllocateSize, m_nPerAllocateSize);
|
||||
|
||||
fwrite(lpBuffer, m_nPerAllocateSize * 2, 1, pLogFile);
|
||||
}
|
||||
__finally
|
||||
{
|
||||
fprintf(pLogFile, ">");
|
||||
fclose(pLogFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CFixedPool::Destroy()
|
||||
{
|
||||
PoolLock::Syncronize sync(m_PoolLock);
|
||||
|
||||
if(0 != m_nTotalInUse)
|
||||
{
|
||||
// <09><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD> <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. (Chunk<6E><6B> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><DEB8> ã<>Ƴ<EFBFBD><C6B3><EFBFBD>.)
|
||||
/*FILE* pLogFile = fopen(ms_strErrLogFileName, "ab");
|
||||
if(NULL != pLogFile)
|
||||
{
|
||||
SYSTEMTIME sysTime;
|
||||
GetLocalTime(&sysTime);
|
||||
|
||||
fprintf(pLogFile, "[%d-%d-%d %d:%d:%d] %s <20><EFBFBD><DEB8><EFBFBD> Ǯ<><C7AE><EFBFBD><EFBFBD> %d<><64><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>. <20>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>մϴ<D5B4>.\r\n",
|
||||
sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond,
|
||||
m_pszPoolName, m_nTotalInUse);
|
||||
|
||||
fclose(pLogFile);
|
||||
}*/
|
||||
}
|
||||
|
||||
for(ChunkNode* pChunkNode = m_pChunkHead; NULL != pChunkNode;)
|
||||
{
|
||||
ChunkNode* pDelNode = pChunkNode;
|
||||
pChunkNode = pChunkNode->m_pNext;
|
||||
delete pDelNode;
|
||||
}
|
||||
|
||||
m_nTotalAllocated = m_nTotalInUse = 0;
|
||||
m_pChunkHead = NULL;
|
||||
m_pNodeHead = NULL;
|
||||
}
|
||||
|
||||
|
||||
size_t CFixedPool::GetLeastAllocateSize()
|
||||
{
|
||||
return sizeof(AllocateInfo) + AllocateInfo::ms_nPaddingSize;
|
||||
}
|
||||
|
||||
const char* CFixedPool::GetErrFileName()
|
||||
{
|
||||
return ms_strErrLogFileName;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CFixedPoolTest::DoTest()
|
||||
{
|
||||
const char* const strErrLogFileName = CFixedPool::GetErrFileName();
|
||||
|
||||
//printf("%s Test Started.\n", __FUNCTION__);
|
||||
remove(strErrLogFileName);
|
||||
|
||||
CFixedPool pool;
|
||||
|
||||
const char* pName = "<EFBFBD><EFBFBD>ƮǮ";
|
||||
|
||||
const int nSize = 10;
|
||||
const int nPerAllocate = 100;
|
||||
|
||||
const int MAX_ALLOC = nPerAllocate * 10;
|
||||
|
||||
void* pAlloc[MAX_ALLOC];
|
||||
pool.Initialize(nSize, nPerAllocate, pName, strlen(pName));
|
||||
|
||||
|
||||
for(int i = 0; i < MAX_ALLOC; ++i)
|
||||
{
|
||||
pAlloc[i] = pool.ALLOC(nSize);
|
||||
}
|
||||
|
||||
for(int i = 0; i < MAX_ALLOC; ++i)
|
||||
{
|
||||
pool.FREE(pAlloc[i], nSize);
|
||||
}
|
||||
|
||||
pool.Destroy();
|
||||
|
||||
FILE* pFile = fopen(strErrLogFileName, "rb");
|
||||
if(NULL == pFile)
|
||||
{
|
||||
printf("\tTest Successed!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(pFile);
|
||||
|
||||
#ifdef WIN32
|
||||
char szPath[MAX_PATH];
|
||||
char szFileNameWithPath[MAX_PATH];
|
||||
|
||||
UINT nResult = GetWindowsDirectory(szPath, MAX_PATH);
|
||||
if(0 != nResult && nResult <= MAX_PATH)
|
||||
{
|
||||
_snprintf(szFileNameWithPath, MAX_PATH, "%s\\NotePad.exe %s", szPath, strErrLogFileName);
|
||||
WinExec(szFileNameWithPath, SW_SHOW);
|
||||
}
|
||||
#endif
|
||||
|
||||
printf("\tMemory Leak or Curruption Detected!\n\tPlease See %s File\n", strErrLogFileName);
|
||||
}
|
||||
|
||||
//printf("%s Test Completed.\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
93
Engine/Effect/MemoryPool.h
Normal file
93
Engine/Effect/MemoryPool.h
Normal file
@@ -0,0 +1,93 @@
|
||||
#ifndef _MEMORYPOOL_H_
|
||||
#define _MEMORYPOOL_H_
|
||||
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
|
||||
#define MEMPOOL_DBGMODE
|
||||
|
||||
#define ALLOC(nSize) Allocate((nSize))
|
||||
#define FREE(pDelete, nSize) Deallocate((pDelete), (nSize))
|
||||
|
||||
#define DECLARE_ALLOCATOR void* Allocate(size_t nSize)
|
||||
#define DECLARE_DEALLOCATOR void Deallocate(void* pDelete, size_t nSize)
|
||||
|
||||
#define DEFINE_ALLOCATOR(className) void* className::Allocate(size_t nSize)
|
||||
#define DEFINE_DEALLOCATOR(className) void className::Deallocate(void* pDelete, size_t nSize)
|
||||
|
||||
|
||||
class CNullLock
|
||||
{
|
||||
public:
|
||||
|
||||
class Syncronize
|
||||
{
|
||||
public:
|
||||
Syncronize(CNullLock& nullLock) { }
|
||||
};
|
||||
|
||||
void Lock() { }
|
||||
void Unlock() { }
|
||||
};
|
||||
|
||||
class CFixedPool
|
||||
{
|
||||
public:
|
||||
|
||||
enum { MAX_POOL_NAME = 32 };
|
||||
|
||||
CFixedPool();
|
||||
CFixedPool(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen);
|
||||
|
||||
~CFixedPool();
|
||||
|
||||
bool Initialize(size_t nPerAllocateSize, size_t nPerAllocateNum,
|
||||
const char* strMaxPoolName, size_t nNameLen);
|
||||
|
||||
void Destroy();
|
||||
unsigned long GetTotalUse() const { return static_cast<unsigned long>(m_nTotalInUse); }
|
||||
|
||||
static size_t GetLeastAllocateSize();
|
||||
static const char* GetErrFileName();
|
||||
|
||||
size_t m_nTotalInUse;
|
||||
|
||||
DECLARE_ALLOCATOR;
|
||||
DECLARE_DEALLOCATOR;
|
||||
|
||||
private:
|
||||
|
||||
bool AllocateChunks();
|
||||
void LogBufferOverflow(const char* lpBuffer);
|
||||
|
||||
typedef CNullLock PoolLock;
|
||||
struct ChunkNode;
|
||||
struct AllocateInfo;
|
||||
|
||||
PoolLock m_PoolLock;
|
||||
|
||||
ChunkNode* m_pChunkHead;
|
||||
AllocateInfo* m_pNodeHead;
|
||||
|
||||
size_t m_nOriginalSize;
|
||||
size_t m_nPerAllocateSize;
|
||||
size_t m_nPerAllocateNum;
|
||||
|
||||
size_t m_nTotalAllocated;
|
||||
|
||||
|
||||
char m_pszPoolName[MAX_POOL_NAME];
|
||||
|
||||
static const char* const ms_strErrLogFileName;
|
||||
};
|
||||
|
||||
|
||||
class CFixedPoolTest
|
||||
{
|
||||
public:
|
||||
void DoTest();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
21
Engine/Effect/ReadMe.txt
Normal file
21
Engine/Effect/ReadMe.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
========================================================================
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺귯<CCBA><EAB7AF> : Effect <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
========================================================================
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><> Effect <20><><EFBFBD>̺귯<CCBA><EAB7AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.
|
||||
|
||||
|
||||
Effect.vcproj
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>縦 <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC++ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>⺻ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
<20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Visual C++<2B><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>ɿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
<EFBFBD><EFBFBD>Ÿ <20><><EFBFBD><EFBFBD>:
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> "TODO:" <20>ּ<EFBFBD><D6BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD> <20>߰<EFBFBD><DFB0>ϰų<CFB0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>ϴ<EFBFBD>
|
||||
<EFBFBD>ҽ<EFBFBD> <20>ڵ<EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
634
Engine/Effect/SMRHeader.cpp
Normal file
634
Engine/Effect/SMRHeader.cpp
Normal file
@@ -0,0 +1,634 @@
|
||||
#include "./SMRHeader.h"
|
||||
#include "GMMemory.h"
|
||||
namespace SGEngine { namespace Core {
|
||||
bool ISSameVertex(const D3DXVECTOR3 &vec1,const D3DXVECTOR3 &vec2)
|
||||
{
|
||||
D3DXVECTOR3 vecSub = vec1 - vec2;
|
||||
if((fabs(vecSub.x) < 0.001f) &&
|
||||
(fabs(vecSub.y) < 0.001f) &&
|
||||
(fabs(vecSub.z) < 0.001f))
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void CMeshCoreData::CMeshSMorphData::SetSmartMorphData(CExportMeshVertex *pSrc,CExportMeshVertex *pDest,const int &iVertices,const int &iModelIndex,char *strModelName)
|
||||
{
|
||||
std::vector<D3DXVECTOR3> ArrRelative;
|
||||
std::vector<int> ArrRelativeIndex;
|
||||
ArrRelative.clear();
|
||||
ArrRelativeIndex.clear();
|
||||
int i;
|
||||
D3DXVECTOR3 vecRelative;
|
||||
|
||||
for(i = 0; i < iVertices; i++)
|
||||
{
|
||||
if(!ISSameVertex(pSrc[i].m_vecPos,pDest[i].m_vecPos))
|
||||
{
|
||||
ArrRelativeIndex.push_back(i);
|
||||
vecRelative = pDest[i].m_vecPos - pSrc[i].m_vecPos;
|
||||
ArrRelative.push_back(vecRelative);
|
||||
}
|
||||
}
|
||||
|
||||
m_iRelativeNum = (int)ArrRelative.size();
|
||||
m_pRelativeVertices = new D3DXVECTOR3[ArrRelative.size()];
|
||||
memcpy(m_pRelativeVertices,&ArrRelative[0],sizeof(D3DXVECTOR3) * ArrRelative.size());
|
||||
m_pRelativeIndex = new int[ArrRelativeIndex.size()];
|
||||
memcpy(m_pRelativeIndex,&ArrRelativeIndex[0],sizeof(int) * ArrRelativeIndex.size());
|
||||
m_iModelID = iModelIndex;
|
||||
if(strModelName)
|
||||
{
|
||||
strcpy(m_strName,strModelName);
|
||||
}
|
||||
|
||||
}
|
||||
void CMeshCoreData::SetSkinMeshData(const int &iVertex,D3DXMATRIX *matTm,D3DXMATRIX *matInvNodeTm) // rigid
|
||||
{
|
||||
|
||||
if(iVertex < m_iVerticesNum)
|
||||
{
|
||||
|
||||
D3DXMATRIX matSkinTm;
|
||||
|
||||
m_bUpdateData = true;
|
||||
D3DXVECTOR3 *pPos = &(m_pDefaultVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR3 *pDestPos = &(m_pVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR4 vecTrans;
|
||||
|
||||
D3DXMatrixMultiply(&matSkinTm,matInvNodeTm,matTm);
|
||||
|
||||
D3DXVec3Transform(&vecTrans,pPos,&matSkinTm);
|
||||
|
||||
pDestPos->x = vecTrans.x;
|
||||
pDestPos->y = vecTrans.y;
|
||||
pDestPos->z = vecTrans.z;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void CMeshCoreData::SetSkinMeshData(const int &iVertex,CMeshSkinData::CMeshBlendData *pBlend,const int &iBlend)
|
||||
{
|
||||
int i;
|
||||
if(iVertex < m_iVerticesNum)
|
||||
{
|
||||
D3DXMATRIX matWorldTm;
|
||||
D3DXMATRIX matInvNodeTm;
|
||||
|
||||
D3DXMATRIX matSkinTm;
|
||||
|
||||
m_bUpdateData = true;
|
||||
D3DXVECTOR3 *pPos = &(m_pDefaultVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR3 *pDestPos = &(m_pVertices[iVertex].m_vecPos);
|
||||
D3DXVECTOR4 vecTrans;
|
||||
|
||||
pDestPos->x = pDestPos->y = pDestPos->z = 0.0f;
|
||||
|
||||
for(i = 0; i < iBlend; i++ )
|
||||
{
|
||||
|
||||
matWorldTm = pBlend[i].m_pNode->m_matNodeTm;
|
||||
matWorldTm *= pBlend[i].m_fNodeWeight;
|
||||
|
||||
matInvNodeTm = pBlend[i].m_pNode->m_matInvNodeTm;
|
||||
|
||||
D3DXMatrixMultiply(&matSkinTm,&matInvNodeTm,&matWorldTm);
|
||||
D3DXVec3Transform(&vecTrans,pPos,&matSkinTm);
|
||||
|
||||
pDestPos->x += vecTrans.x;
|
||||
pDestPos->y += vecTrans.y;
|
||||
pDestPos->z += vecTrans.z;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void CMeshCoreData::SetSmartMorphInterValue(const float &fValue,const int &iIndex)
|
||||
{
|
||||
|
||||
|
||||
if(m_bSMorph)
|
||||
{
|
||||
float fInter = fValue;
|
||||
if(m_iSMorph > iIndex && m_pfSMorphInterValue)
|
||||
{
|
||||
/* if(fInter > 1.0f)
|
||||
fInter = 1.0f;
|
||||
if(fInter < 0.0f)
|
||||
fInter = 0.0f;*/
|
||||
m_pfSMorphInterValue[iIndex] = fInter;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CMeshCoreData::UpdateMeshSmartMorph()
|
||||
{
|
||||
|
||||
if(m_bSMorph && m_pVertices && m_pDefaultVertices)
|
||||
{
|
||||
int i,j;
|
||||
m_bUpdateData = true;
|
||||
memcpy(m_pVertices,m_pDefaultVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
|
||||
for(i = 0; i < m_iSMorph; i++ )
|
||||
{
|
||||
if(fabs(m_pfSMorphInterValue[i]) > 0.00001f)
|
||||
{
|
||||
for(j = 0; j < m_pSMorph[i].m_iRelativeNum; j++ )
|
||||
{
|
||||
int iVertexIndex = m_pSMorph[i].m_pRelativeIndex[j];
|
||||
m_pVertices[iVertexIndex].m_vecPos += (m_pSMorph[i].m_pRelativeVertices[j] * m_pfSMorphInterValue[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CMeshCoreData::UpdateMeshMorph(const float &fFrame)
|
||||
{
|
||||
if(m_bMorph && !m_bSMorph) // <20>ϴ<EFBFBD> smorph<70><68> <20><><EFBFBD>ÿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20>س<EFBFBD><D8B3>´<EFBFBD>.. <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
int i;
|
||||
int iSelect = 0;
|
||||
|
||||
int iCurrentFrame = (int)ceil(fFrame);
|
||||
int iBeforeFrame = 0;
|
||||
int iNextFrame = 0;
|
||||
|
||||
int iBeforeKey = 0;
|
||||
int iNextKey = 0;
|
||||
|
||||
float fInterval = 0.0f;
|
||||
|
||||
CExportMeshVertex *pVertices = NULL;
|
||||
|
||||
for(i = 0; i < m_iMorph; i++ )
|
||||
{
|
||||
if(m_pMorphData[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_iMorph == i)
|
||||
{
|
||||
iSelect = m_iMorph - 1;
|
||||
pVertices = m_pMorphData[iSelect].m_pVertices;
|
||||
memcpy(m_pVertices,pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
m_bUpdateData = true;
|
||||
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
pVertices = m_pMorphData[iSelect].m_pVertices;
|
||||
memcpy(m_pVertices,pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
m_bUpdateData = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_bUpdateData = true;
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pMorphData[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pMorphData[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
for(i = 0 ;i < m_iVerticesNum; i++ )
|
||||
{
|
||||
m_pVertices[i].m_vecPos = m_pMorphData[iNextKey].m_pVertices[i].m_vecPos - m_pMorphData[iBeforeKey].m_pVertices[i].m_vecPos;
|
||||
m_pVertices[i].m_vecPos *= fInterval;
|
||||
|
||||
m_pVertices[i].m_vecPos += m_pMorphData[iBeforeKey].m_pVertices[i].m_vecPos;
|
||||
|
||||
|
||||
m_pVertices[i].m_vecNormal = m_pMorphData[iNextKey].m_pVertices[i].m_vecNormal - m_pMorphData[iBeforeKey].m_pVertices[i].m_vecNormal;
|
||||
m_pVertices[i].m_vecNormal *= fInterval;
|
||||
|
||||
m_pVertices[i].m_vecNormal += m_pMorphData[iBeforeKey].m_pVertices[i].m_vecNormal;
|
||||
|
||||
m_pVertices[i].m_vecTexcoord = m_pMorphData[iNextKey].m_pVertices[i].m_vecTexcoord - m_pMorphData[iBeforeKey].m_pVertices[i].m_vecTexcoord;
|
||||
m_pVertices[i].m_vecTexcoord *= fInterval;
|
||||
|
||||
m_pVertices[i].m_vecTexcoord += m_pMorphData[iBeforeKey].m_pVertices[i].m_vecTexcoord;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// Linear interpolation.
|
||||
void CMeshObjNode::UpdateTm(const float &fFrame,D3DXMATRIX *matParent)
|
||||
{
|
||||
int i;
|
||||
int iSelect = 0;
|
||||
|
||||
D3DXVECTOR3 vecPos;
|
||||
D3DXVECTOR3 vecScale;
|
||||
D3DXQUATERNION qRot;
|
||||
|
||||
int iCurrentFrame = (int)ceil(fFrame);
|
||||
int iBeforeFrame = 0;
|
||||
int iNextFrame = 0;
|
||||
|
||||
int iBeforeKey = 0;
|
||||
int iNextKey = 0;
|
||||
|
||||
float fInterval = 0.0f;
|
||||
D3DXVECTOR3 vecInterval;
|
||||
|
||||
if(m_bAniNode)
|
||||
{
|
||||
|
||||
if(m_pAniNode->m_bTmAni)
|
||||
{
|
||||
CNodeTMInfo CurrentTmInfo;
|
||||
|
||||
for(i = 0; i < m_pAniNode->m_iTmKeys; i++)
|
||||
{
|
||||
if(m_pAniNode->m_pTmKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iTmKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iTmKeys - 1;
|
||||
CurrentTmInfo = m_pAniNode->m_pTmKeys[iSelect].m_TmInfo;
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
CurrentTmInfo = m_pAniNode->m_pTmKeys[iSelect].m_TmInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pTmKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pTmKeys[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
D3DXVECTOR3 vecInterval;
|
||||
|
||||
// Trans
|
||||
vecInterval.x = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecTrans.x - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.x;
|
||||
vecInterval.y = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecTrans.y - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.y;
|
||||
vecInterval.z = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecTrans.z - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
CurrentTmInfo.m_vecTrans.x = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.x + vecInterval.x;
|
||||
CurrentTmInfo.m_vecTrans.y = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.y + vecInterval.y;
|
||||
CurrentTmInfo.m_vecTrans.z = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecTrans.z + vecInterval.z;
|
||||
// Scale
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecScale.x - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.x;
|
||||
vecInterval.y = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecScale.y - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.y;
|
||||
vecInterval.z = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_vecScale.z - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
CurrentTmInfo.m_vecScale.x = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.x + vecInterval.x;
|
||||
CurrentTmInfo.m_vecScale.y = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.y + vecInterval.y;
|
||||
CurrentTmInfo.m_vecScale.z = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_vecScale.z + vecInterval.z;
|
||||
// qrot
|
||||
|
||||
D3DXQuaternionSlerp(&CurrentTmInfo.m_qRot,
|
||||
&(m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_qRot),
|
||||
&(m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_qRot),
|
||||
fInterval);
|
||||
|
||||
// qscaleaxis
|
||||
D3DXQuaternionSlerp(&CurrentTmInfo.m_qScaleAxis,
|
||||
&(m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_qScaleAxis),
|
||||
&(m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_qScaleAxis),
|
||||
fInterval);
|
||||
// fDetermination
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pTmKeys[iNextKey].m_TmInfo.m_fDetermination - m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_fDetermination;
|
||||
vecInterval.x *= fInterval;
|
||||
CurrentTmInfo.m_fDetermination = m_pAniNode->m_pTmKeys[iBeforeKey].m_TmInfo.m_fDetermination + vecInterval.x;
|
||||
|
||||
}
|
||||
|
||||
/* Convert matrix from affine value.
|
||||
ptm = position component (t)
|
||||
rtm = "essential" rotation (q)
|
||||
srtm = "stretch" rotation (u)
|
||||
stm = scale component (k)
|
||||
ftm = the flip tm -> ScaleMatrix(Point3(ap.f,ap.f,ap.f));
|
||||
Here's the correct way of reassembling the decomposed matrix:
|
||||
Matrix3 srtm, rtm, ptm, stm, ftm;
|
||||
ptm.IdentityMatrix();
|
||||
ptm.SetTrans(ap.t);
|
||||
ap.q.MakeMatrix(rtm);
|
||||
ap.u.MakeMatrix(srtm);
|
||||
stm = ScaleMatrix(ap.k);
|
||||
mat = Inverse(srtm) * stm * srtm * rtm * ftm * ptm;
|
||||
|
||||
*/
|
||||
|
||||
|
||||
D3DXMATRIX matR,matSA,matScale,matF,matP,matInvSA;
|
||||
|
||||
D3DXMatrixScaling(&matF,CurrentTmInfo.m_fDetermination,
|
||||
CurrentTmInfo.m_fDetermination,
|
||||
CurrentTmInfo.m_fDetermination);
|
||||
D3DXMatrixIdentity(&matP);
|
||||
D3DXMatrixTranslation(&matP,CurrentTmInfo.m_vecTrans.x,
|
||||
CurrentTmInfo.m_vecTrans.y,
|
||||
CurrentTmInfo.m_vecTrans.z);
|
||||
D3DXMatrixRotationQuaternion(&matR,&CurrentTmInfo.m_qRot);
|
||||
D3DXMatrixRotationQuaternion(&matSA,&CurrentTmInfo.m_qScaleAxis);
|
||||
D3DXMatrixInverse(&matInvSA,NULL,&matSA);
|
||||
D3DXMatrixScaling(&matScale,CurrentTmInfo.m_vecScale.x,
|
||||
CurrentTmInfo.m_vecScale.y,
|
||||
CurrentTmInfo.m_vecScale.z);
|
||||
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&matInvSA,&matScale);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matSA);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matR);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matF);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matP);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_pAniNode->m_bPosAni)
|
||||
{
|
||||
for(i = 0; i < m_pAniNode->m_iPosKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pPosKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iPosKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iPosKeys - 1;
|
||||
vecPos = m_pAniNode->m_pPosKeys[iSelect].m_vecPos;
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
vecPos = m_pAniNode->m_pPosKeys[iSelect].m_vecPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pPosKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pPosKeys[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pPosKeys[iNextKey].m_vecPos.x - m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.x;
|
||||
vecInterval.y = m_pAniNode->m_pPosKeys[iNextKey].m_vecPos.y - m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.y;
|
||||
vecInterval.z = m_pAniNode->m_pPosKeys[iNextKey].m_vecPos.z - m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
vecPos.x = m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.x + vecInterval.x;
|
||||
vecPos.y = m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.y + vecInterval.y;
|
||||
vecPos.z = m_pAniNode->m_pPosKeys[iBeforeKey].m_vecPos.z + vecInterval.z;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
vecPos = m_DefaultNodeTm.m_vecTrans;
|
||||
|
||||
if(m_pAniNode->m_bScaleAni)
|
||||
{
|
||||
iSelect = 0;
|
||||
|
||||
for(i = 0; i < m_pAniNode->m_iScaleKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pScaleKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iScaleKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iScaleKeys - 1;
|
||||
vecScale = m_pAniNode->m_pScaleKeys[iSelect].m_vecScale;
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
vecScale = m_pAniNode->m_pScaleKeys[iSelect].m_vecScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pScaleKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pScaleKeys[iNextKey].m_iFrame;
|
||||
|
||||
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
vecInterval.x = m_pAniNode->m_pScaleKeys[iNextKey].m_vecScale.x - m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.x;
|
||||
vecInterval.y = m_pAniNode->m_pScaleKeys[iNextKey].m_vecScale.y - m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.y;
|
||||
vecInterval.z = m_pAniNode->m_pScaleKeys[iNextKey].m_vecScale.z - m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.z;
|
||||
|
||||
vecInterval *= fInterval;
|
||||
|
||||
vecScale.x = m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.x + vecInterval.x;
|
||||
vecScale.y = m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.y + vecInterval.y;
|
||||
vecScale.z = m_pAniNode->m_pScaleKeys[iBeforeKey].m_vecScale.z + vecInterval.z;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
vecScale = m_DefaultNodeTm.m_vecScale;
|
||||
|
||||
if(m_pAniNode->m_bRotAni)
|
||||
{
|
||||
iSelect = 0;
|
||||
for(i = 0; i < m_pAniNode->m_iRotKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pRotKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iRotKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iRotKeys - 1;
|
||||
qRot = m_pAniNode->m_pRotKeys[iSelect].m_qRotKey;
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
qRot = m_pAniNode->m_pRotKeys[iSelect].m_qRotKey;
|
||||
}
|
||||
else
|
||||
{
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pRotKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pRotKeys[iNextKey].m_iFrame;
|
||||
|
||||
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
D3DXQuaternionSlerp(&qRot,
|
||||
&(m_pAniNode->m_pRotKeys[iBeforeKey].m_qRotKey),
|
||||
&(m_pAniNode->m_pRotKeys[iNextKey].m_qRotKey),
|
||||
fInterval);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
qRot = m_DefaultNodeTm.m_qRot;
|
||||
|
||||
|
||||
D3DXMatrixTransformation(&m_matNodeTm,
|
||||
NULL,NULL,&vecScale,NULL,&qRot,&vecPos);
|
||||
|
||||
} // else
|
||||
if(m_pAniNode->m_bVisAni)
|
||||
{
|
||||
|
||||
float fVis = 1.0f;
|
||||
float fInter = 0.0f;
|
||||
|
||||
for(i = 0; i < m_pAniNode->m_iVisKeys; i++ )
|
||||
{
|
||||
if(m_pAniNode->m_pVisKeys[i].m_iFrame >= iCurrentFrame)
|
||||
{
|
||||
iSelect = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(m_pAniNode->m_iVisKeys == i)
|
||||
{
|
||||
iSelect = m_pAniNode->m_iVisKeys - 1;
|
||||
fVis = m_pAniNode->m_pVisKeys[iSelect].m_fVisibility;
|
||||
|
||||
}
|
||||
else if(iSelect == 0)
|
||||
{
|
||||
fVis = m_pAniNode->m_pVisKeys[iSelect].m_fVisibility;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
iBeforeKey = iSelect - 1;
|
||||
iBeforeFrame = m_pAniNode->m_pVisKeys[iBeforeKey].m_iFrame;
|
||||
|
||||
iNextKey = iSelect;
|
||||
iNextFrame = m_pAniNode->m_pVisKeys[iNextKey].m_iFrame;
|
||||
|
||||
fInterval = (fFrame - iBeforeFrame) / (float)(iNextFrame - iBeforeFrame);
|
||||
|
||||
fInter = m_pAniNode->m_pVisKeys[iNextKey].m_fVisibility - m_pAniNode->m_pVisKeys[iBeforeKey].m_fVisibility;
|
||||
|
||||
fInter *= fInterval;
|
||||
|
||||
fVis = m_pAniNode->m_pVisKeys[iBeforeKey].m_fVisibility + fInter;
|
||||
|
||||
|
||||
}
|
||||
m_fVisibility = fVis;
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
/* vecPos = m_DefaultNodeTm.m_vecTrans;
|
||||
qRot = m_DefaultNodeTm.m_qRot;
|
||||
vecScale = m_DefaultNodeTm.m_vecScale;
|
||||
|
||||
D3DXMatrixTransformation(&m_matNodeTm,
|
||||
NULL,NULL,&vecScale,NULL,&qRot,&vecPos);
|
||||
*/
|
||||
/* D3DXMATRIX mat;
|
||||
|
||||
D3DXMatrixInverse(&mat,NULL,&m_matInvNodeTm);
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&mat);
|
||||
*/
|
||||
D3DXMatrixInverse(&m_matNodeTm,NULL,&m_matInvNodeTm);
|
||||
}
|
||||
|
||||
if(matParent)
|
||||
{
|
||||
|
||||
if(m_bWorldTM)
|
||||
{
|
||||
D3DXMATRIX matInv;
|
||||
D3DXMatrixInverse(&matInv,NULL,matParent); // exporter<65><72><EFBFBD><EFBFBD> (bipe <20><> ) ó<><C3B3> <20>ؾ<EFBFBD><D8BE><EFBFBD>.
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,&matInv); // LocalTm = WorldTm * Parent InvTm
|
||||
|
||||
}
|
||||
m_matLocalTm = m_matNodeTm;
|
||||
|
||||
D3DXMatrixMultiply(&m_matNodeTm,&m_matNodeTm,matParent); // WorldTm = LocalTm * ParentTm
|
||||
}
|
||||
}
|
||||
|
||||
void CMeshObjNode::UpdateSkinning()
|
||||
{
|
||||
int i;
|
||||
D3DXMATRIX matWorldTm;
|
||||
D3DXMATRIX matInvNodeTm;
|
||||
|
||||
int iVertexIndex;
|
||||
int iMatIndex;
|
||||
|
||||
if(m_bSkinMorph && m_pSkinData)
|
||||
{
|
||||
for(i = 0; i < m_pSkinData->m_iRigid; i++)
|
||||
{
|
||||
matWorldTm = m_pSkinData->m_pRigid[i].m_pNode->m_matNodeTm;
|
||||
matInvNodeTm = m_pSkinData->m_pRigid[i].m_pNode->m_matInvNodeTm;
|
||||
|
||||
iVertexIndex = m_pSkinData->m_pRigid[i].m_iVertexIndex;
|
||||
iMatIndex = m_pSkinData->m_pRigid[i].m_iMatIndex;
|
||||
|
||||
SetSkinMeshData(iMatIndex,iVertexIndex,&matWorldTm,&matInvNodeTm);
|
||||
|
||||
}
|
||||
for(i = 0; i < m_pSkinData->m_iBlend; i++ )
|
||||
{
|
||||
iVertexIndex = m_pSkinData->m_pBlend[i].m_iVertexIndex;
|
||||
iMatIndex = m_pSkinData->m_pBlend[i].m_iMatIndex;
|
||||
int iBlend = m_pSkinData->m_pBlend[i].m_iBlendData;
|
||||
CMeshSkinData::CMeshBlendData *pBlend = m_pSkinData->m_pBlend[i].m_pArrBlendData;
|
||||
SetSkinMeshData(iMatIndex,iVertexIndex,pBlend,iBlend);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}}
|
||||
860
Engine/Effect/SMRHeader.h
Normal file
860
Engine/Effect/SMRHeader.h
Normal file
@@ -0,0 +1,860 @@
|
||||
#include <d3dx8.h>
|
||||
#include <d3d8.h>
|
||||
#include <vector>
|
||||
|
||||
namespace SGEngine {
|
||||
|
||||
|
||||
// template function <20><><EFBFBD><EFBFBD>
|
||||
template<class _T>
|
||||
inline void SafeDelete( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
template<class _T>
|
||||
inline void SafeDeleteA( _T ptr )
|
||||
{
|
||||
if( NULL != ptr )
|
||||
{
|
||||
delete[] (ptr);
|
||||
ptr = NULL;
|
||||
}
|
||||
}
|
||||
class CExportMeshVertex
|
||||
{
|
||||
public:
|
||||
D3DXVECTOR3 m_vecPos;
|
||||
D3DXVECTOR3 m_vecNormal;
|
||||
D3DXVECTOR2 m_vecTexcoord;
|
||||
CExportMeshVertex() : m_vecPos(0.0f,0.0f,0.0f),m_vecNormal(0.0f,0.0f,0.0f),m_vecTexcoord(0.0f,0.0f)
|
||||
{}
|
||||
~CExportMeshVertex(){}
|
||||
};
|
||||
enum MESHNODETYPE
|
||||
{
|
||||
MESHNODETYPE_DUMY = 0,
|
||||
MESHNODETYPE_MATERIAL, // Material
|
||||
MESHNODETYPE_MESHDATA, // Vertex, Index Data
|
||||
MESHNODETYPE_ANINODE, // Ani Node
|
||||
MESHNODETYPE_NUM,
|
||||
};
|
||||
|
||||
enum SMRNODE
|
||||
{
|
||||
SMRNODE_NODE = 0,
|
||||
SMRNODE_GROUP,
|
||||
SMRNODE_NUM,
|
||||
};
|
||||
enum SMROBJTYPE
|
||||
{
|
||||
SMROBJ_MESH = 0,
|
||||
SMROBJ_HELPER,
|
||||
SMROBJ_BONE,
|
||||
SMROBJ_NUM,
|
||||
};
|
||||
enum SMRMESHTYPE
|
||||
{
|
||||
SMRMESHTYPE_STATIC = 0,
|
||||
SMRMESHTYPE_STATIC_WITHOUTLIGHTMAP,
|
||||
SMRMESHTYPE_DYNAMIC,
|
||||
SMRMESHTYPE_NUM,
|
||||
};
|
||||
|
||||
enum SMRANICONTROLTYPE
|
||||
{
|
||||
SMRANICONTROL_BEZIER = 0,
|
||||
SMRANICONTROL_LINEAR,
|
||||
SMRANICONTROL_TCB,
|
||||
SMRANICONTROL_SAMPLE,
|
||||
SMRANICONTROL_NUM,
|
||||
|
||||
|
||||
};
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CMeshHeader
|
||||
{
|
||||
public:
|
||||
CMeshHeader() : m_fVersion(1.0f),m_iNodes(0),m_iType(SMRMESHTYPE_STATIC)
|
||||
{
|
||||
memset(m_iExtension,0,sizeof(int)*10);
|
||||
|
||||
}
|
||||
~CMeshHeader()
|
||||
{}
|
||||
float m_fVersion;
|
||||
int m_iNodes;
|
||||
int m_iType;
|
||||
|
||||
int m_iExtension[10]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> Ȯ<><C8AE>.
|
||||
|
||||
|
||||
};
|
||||
class CMeshObjNodeHeader
|
||||
{
|
||||
public:
|
||||
CMeshObjNodeHeader() : m_iNodeType(MESHNODETYPE_DUMY), m_iNodeSize(0)
|
||||
{}
|
||||
~CMeshObjNodeHeader()
|
||||
{}
|
||||
int m_iNodeType;
|
||||
unsigned long m_iNodeSize;
|
||||
|
||||
};
|
||||
|
||||
class CNodeTMInfo // MeshTM KeyInfo.
|
||||
{
|
||||
public:
|
||||
|
||||
D3DXVECTOR3 m_vecTrans; // Translation
|
||||
D3DXVECTOR3 m_vecScale; // Scale
|
||||
D3DXQUATERNION m_qRot; // Rot
|
||||
D3DXQUATERNION m_qScaleAxis;
|
||||
float m_fDetermination;
|
||||
|
||||
CNodeTMInfo() : m_vecTrans(0.0f,0.0f,0.0f),m_vecScale(1.0f,1.0f,1.0f),m_qRot(0.0f,0.0f,0.0f,1.0f),
|
||||
m_qScaleAxis(0.0f,0.0f,0.0f,1.0f),m_fDetermination(0.0f)
|
||||
{}
|
||||
~CNodeTMInfo(){}
|
||||
};
|
||||
|
||||
class CMeshKeyAniNode
|
||||
{
|
||||
public:
|
||||
class CMeshKeyAniTm
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniTm() : m_iFrame(0)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniTm()
|
||||
{
|
||||
|
||||
}
|
||||
int m_iFrame;
|
||||
CNodeTMInfo m_TmInfo;
|
||||
|
||||
};
|
||||
|
||||
class CMeshKeyAniRot
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniRot() : m_qRotKey(0.0f,0.0f,0.0f,1.0f),m_iFrame(0)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniRot()
|
||||
{
|
||||
|
||||
}
|
||||
D3DXQUATERNION m_qRotKey;
|
||||
int m_iFrame;
|
||||
|
||||
};
|
||||
class CMeshKeyAniPos
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniPos() : m_vecPos(0.0f,0.0f,0.0f),m_iFrame(0)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniPos()
|
||||
{
|
||||
|
||||
}
|
||||
D3DXVECTOR3 m_vecPos;
|
||||
int m_iFrame;
|
||||
|
||||
};
|
||||
class CMeshKeyAniScale
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniScale() : m_iFrame(0),m_vecScale(1.0f,1.0f,1.0f)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniScale()
|
||||
{
|
||||
|
||||
}
|
||||
D3DXVECTOR3 m_vecScale;
|
||||
int m_iFrame;
|
||||
};
|
||||
class CMeshKeyAniVis
|
||||
{
|
||||
public:
|
||||
CMeshKeyAniVis() : m_iFrame(0),m_fVisibility(1.0f)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshKeyAniVis()
|
||||
{
|
||||
|
||||
}
|
||||
float m_fVisibility;
|
||||
int m_iFrame;
|
||||
|
||||
};
|
||||
|
||||
CMeshKeyAniNode() :m_iRotKeys(0),m_pRotKeys(NULL),m_bRotAni(false),m_iRotType(SMRANICONTROL_BEZIER),
|
||||
m_iPosKeys(0),m_pPosKeys(NULL),m_bPosAni(false),m_iPosType(SMRANICONTROL_BEZIER),
|
||||
m_iScaleKeys(0),m_pScaleKeys(NULL),m_bScaleAni(false),m_iScaleType(SMRANICONTROL_BEZIER),
|
||||
m_iVisKeys(0),m_pVisKeys(NULL),m_bVisAni(false),m_iVisType(SMRANICONTROL_BEZIER),
|
||||
m_bTmAni(false),m_iTmKeys(0),m_pTmKeys(NULL)
|
||||
{
|
||||
}
|
||||
~CMeshKeyAniNode()
|
||||
{
|
||||
if(m_pRotKeys)
|
||||
{
|
||||
delete[] m_pRotKeys;
|
||||
m_pRotKeys = NULL;
|
||||
}
|
||||
|
||||
if(m_pPosKeys)
|
||||
{
|
||||
delete[] m_pPosKeys;
|
||||
m_pPosKeys = NULL;
|
||||
}
|
||||
|
||||
if(m_pScaleKeys)
|
||||
{
|
||||
delete[] m_pScaleKeys;
|
||||
m_pScaleKeys = NULL;
|
||||
}
|
||||
|
||||
if(m_pVisKeys)
|
||||
{
|
||||
delete[] m_pVisKeys;
|
||||
m_pVisKeys = NULL;
|
||||
}
|
||||
if(m_pTmKeys)
|
||||
{
|
||||
delete[] m_pTmKeys;
|
||||
m_pTmKeys = NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
bool m_bRotAni;
|
||||
|
||||
int m_iRotKeys;
|
||||
CMeshKeyAniRot *m_pRotKeys;
|
||||
int m_iRotType;
|
||||
|
||||
bool m_bPosAni;
|
||||
|
||||
int m_iPosKeys;
|
||||
CMeshKeyAniPos *m_pPosKeys;
|
||||
int m_iPosType;
|
||||
|
||||
|
||||
bool m_bScaleAni;
|
||||
|
||||
int m_iScaleKeys;
|
||||
CMeshKeyAniScale *m_pScaleKeys;
|
||||
int m_iScaleType;
|
||||
|
||||
|
||||
|
||||
bool m_bVisAni;
|
||||
|
||||
int m_iVisKeys;
|
||||
CMeshKeyAniVis *m_pVisKeys;
|
||||
int m_iVisType;
|
||||
|
||||
bool m_bTmAni;
|
||||
int m_iTmKeys;
|
||||
CMeshKeyAniTm *m_pTmKeys;
|
||||
|
||||
|
||||
};
|
||||
class CMeshMaterialInfo
|
||||
{
|
||||
public:
|
||||
CMeshMaterialInfo()
|
||||
{
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
}
|
||||
~CMeshMaterialInfo(){}
|
||||
bool CheckString(const char *strName)
|
||||
{
|
||||
|
||||
if(!strcmp(m_strName,strName))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
char m_strName[256];
|
||||
|
||||
|
||||
};
|
||||
class CMeshObjNode;
|
||||
class CMeshSkinData
|
||||
{
|
||||
public:
|
||||
|
||||
class CMeshSkinRigid
|
||||
{
|
||||
public:
|
||||
int m_iMatIndex;
|
||||
int m_iVertexIndex;
|
||||
char m_strNodeName[256];
|
||||
int m_iNodeIndex;
|
||||
CMeshObjNode *m_pNode;
|
||||
|
||||
CMeshSkinRigid() : m_iVertexIndex(0), m_iMatIndex(0),m_pNode(NULL)
|
||||
{
|
||||
memset(m_strNodeName,0,sizeof(char) * 256);
|
||||
m_iNodeIndex = 0;
|
||||
}
|
||||
~CMeshSkinRigid(){}
|
||||
};
|
||||
class CMeshBlendData
|
||||
{
|
||||
public:
|
||||
char m_strNodeName[256];
|
||||
int m_iNodeIndex;
|
||||
float m_fNodeWeight;
|
||||
CMeshObjNode *m_pNode;
|
||||
|
||||
CMeshBlendData() :m_fNodeWeight(0.0f) , m_pNode(NULL)
|
||||
{
|
||||
memset(m_strNodeName,0,sizeof(char) * 256);
|
||||
m_iNodeIndex = 0;
|
||||
}
|
||||
~CMeshBlendData(){}
|
||||
};
|
||||
class CMeshSkinBlend
|
||||
{
|
||||
public:
|
||||
int m_iMatIndex;
|
||||
int m_iVertexIndex;
|
||||
CMeshBlendData *m_pArrBlendData;
|
||||
int m_iBlendData;
|
||||
|
||||
|
||||
CMeshSkinBlend() : m_iVertexIndex(0),m_iMatIndex(0)
|
||||
{
|
||||
m_pArrBlendData = NULL;
|
||||
m_iBlendData = 0;
|
||||
|
||||
}
|
||||
~CMeshSkinBlend()
|
||||
{
|
||||
SafeDeleteA(m_pArrBlendData);
|
||||
m_pArrBlendData = NULL;
|
||||
}
|
||||
};
|
||||
|
||||
CMeshSkinData() : m_iRigid(0),m_iBlend(0),m_pRigid(NULL),m_pBlend(NULL)
|
||||
{
|
||||
|
||||
}
|
||||
~CMeshSkinData()
|
||||
{
|
||||
SafeDeleteA(m_pRigid);
|
||||
m_pRigid = NULL;
|
||||
SafeDeleteA(m_pBlend);
|
||||
m_pBlend = NULL;
|
||||
|
||||
}
|
||||
void FindSkinRigidData(int iIndex,std::vector<CMeshSkinRigid *> *pArrRigid)
|
||||
{
|
||||
int i;
|
||||
if(pArrRigid)
|
||||
{
|
||||
for(i = 0; i < m_iRigid; i++)
|
||||
{
|
||||
if(m_pRigid[i].m_iVertexIndex == iIndex)
|
||||
{
|
||||
pArrRigid->push_back(&(m_pRigid[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void FindSkinBlendData(int iIndex,std::vector<CMeshSkinBlend *> *pArrBlend)
|
||||
{
|
||||
int i;
|
||||
if(pArrBlend)
|
||||
{
|
||||
for(i = 0; i < m_iBlend; i++)
|
||||
{
|
||||
if(m_pBlend[i].m_iVertexIndex == iIndex)
|
||||
{
|
||||
pArrBlend->push_back(&(m_pBlend[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int m_iRigid;
|
||||
CMeshSkinRigid *m_pRigid;
|
||||
|
||||
int m_iBlend;
|
||||
CMeshSkinBlend *m_pBlend;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CMeshObjNode;
|
||||
class CMeshCoreData
|
||||
{
|
||||
public:
|
||||
class CMeshSMorphData // Smart Morphing
|
||||
{
|
||||
public:
|
||||
int m_iModelID;
|
||||
char m_strName[256];
|
||||
D3DXVECTOR3 *m_pRelativeVertices;
|
||||
int *m_pRelativeIndex;
|
||||
int m_iRelativeNum;
|
||||
CMeshSMorphData() : m_iModelID(-1),m_pRelativeVertices(NULL),m_pRelativeIndex(NULL),m_iRelativeNum(0)
|
||||
{
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
}
|
||||
~CMeshSMorphData()
|
||||
{
|
||||
SafeDeleteA(m_pRelativeVertices);
|
||||
m_pRelativeVertices = NULL;
|
||||
SafeDeleteA(m_pRelativeIndex);
|
||||
m_pRelativeIndex = NULL;
|
||||
|
||||
}
|
||||
void SetSmartMorphData(CExportMeshVertex *pSrc,CExportMeshVertex *pDest,const int &iVertices,const int &iModelIndex = -1,char *strModelName = NULL);
|
||||
|
||||
};
|
||||
class CMeshMorphData
|
||||
{
|
||||
public:
|
||||
CMeshMorphData() : m_iFrame(0), m_pVertices(NULL)
|
||||
{}
|
||||
~CMeshMorphData()
|
||||
{
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = NULL;
|
||||
}
|
||||
int m_iFrame;
|
||||
CExportMeshVertex *m_pVertices;
|
||||
|
||||
|
||||
|
||||
};
|
||||
CMeshCoreData() : m_iType(SMRMESHTYPE_STATIC),m_iVerticesNum(0),m_iIndicesNum(0),
|
||||
m_pVertices(NULL),m_pIndices(NULL),m_iMaterialIndex(0),m_pNode(NULL),m_bUpdateData(false),
|
||||
m_bMorph(false),m_pMorphData(NULL),m_iMorph(0),
|
||||
m_bSMorph(false),m_pSMorph(NULL),m_iSMorph(0),m_pfSMorphInterValue(NULL),
|
||||
m_bCullOff(false),m_bZWriteOff(false),m_bZOff(false)
|
||||
{
|
||||
|
||||
m_bTotalBilboard = false;
|
||||
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
m_pDefaultVertices = NULL;
|
||||
}
|
||||
~CMeshCoreData()
|
||||
{
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = NULL;
|
||||
|
||||
SafeDeleteA(m_pDefaultVertices);
|
||||
m_pDefaultVertices = NULL;
|
||||
|
||||
|
||||
SafeDeleteA(m_pIndices);
|
||||
m_pIndices = NULL;
|
||||
|
||||
|
||||
SafeDeleteA(m_pMorphData);
|
||||
m_pMorphData = NULL;
|
||||
|
||||
SafeDeleteA(m_pSMorph);
|
||||
m_pSMorph = NULL;
|
||||
SafeDeleteA(m_pfSMorphInterValue);
|
||||
m_pfSMorphInterValue = NULL;
|
||||
|
||||
}
|
||||
|
||||
void SetTotalBilboard(bool bValue) { m_bTotalBilboard = bValue;}
|
||||
bool GetTotalBilboard() { return m_bTotalBilboard;}
|
||||
|
||||
void SetCullOffFlag(bool bValue) { m_bCullOff = bValue;}
|
||||
bool GetCullOffFlag() { return m_bCullOff; }
|
||||
|
||||
void SetZWriteOffFlag(bool bValue) { m_bZWriteOff = bValue;}
|
||||
bool GetZWriteOffFlag() { return m_bZWriteOff; }
|
||||
|
||||
void SetZOffFlag(bool bValue) { m_bZOff = bValue;}
|
||||
bool GetZOffFlag() { return m_bZOff; }
|
||||
|
||||
|
||||
void CreateBuffer()
|
||||
{
|
||||
|
||||
if(m_iIndicesNum > 0)
|
||||
{
|
||||
SafeDeleteA(m_pIndices);
|
||||
m_pIndices = NULL;
|
||||
m_pIndices = new WORD[m_iIndicesNum];
|
||||
}
|
||||
if(m_iVerticesNum > 0)
|
||||
{
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = NULL;
|
||||
|
||||
m_pVertices = new CExportMeshVertex[m_iVerticesNum];
|
||||
}
|
||||
}
|
||||
void CreateDefaultBuffer()
|
||||
{
|
||||
if(m_pDefaultVertices == NULL)
|
||||
{
|
||||
|
||||
if(m_iVerticesNum > 0)
|
||||
{
|
||||
m_pDefaultVertices = new CExportMeshVertex[m_iVerticesNum];
|
||||
memcpy(m_pDefaultVertices,m_pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CopyBuffer(CExportMeshVertex *pData,WORD *pData2)
|
||||
{
|
||||
if(pData != NULL && m_pVertices != NULL)
|
||||
{
|
||||
memcpy(m_pVertices,pData,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
}
|
||||
if(pData2 != NULL && m_pIndices != NULL)
|
||||
{
|
||||
memcpy(m_pIndices,pData2,sizeof(WORD) * m_iIndicesNum);
|
||||
}
|
||||
}
|
||||
void AddBuffer(CExportMeshVertex *pData,int iData,WORD *pData2,int iData2)
|
||||
{
|
||||
int i;
|
||||
int iIndexStart = m_iVerticesNum;
|
||||
|
||||
if(pData && m_pVertices)
|
||||
{
|
||||
CExportMeshVertex *pNewData = new CExportMeshVertex[m_iVerticesNum + iData];
|
||||
memcpy(pNewData,m_pVertices,sizeof(CExportMeshVertex) * m_iVerticesNum);
|
||||
for(i = 0; i < iData; i++ )
|
||||
{
|
||||
pNewData[m_iVerticesNum + i] = pData[i];
|
||||
}
|
||||
m_iVerticesNum += iData;
|
||||
SafeDeleteA(m_pVertices);
|
||||
m_pVertices = pNewData;
|
||||
}
|
||||
if(pData2 && m_pIndices)
|
||||
{
|
||||
WORD *pNewData2 = new WORD[iData2 + m_iIndicesNum];
|
||||
memcpy(pNewData2,m_pIndices,sizeof(WORD) * m_iIndicesNum);
|
||||
for(i = 0; i < iData2; i++ )
|
||||
{
|
||||
pData2[i] += iIndexStart;
|
||||
pNewData2[m_iIndicesNum + i] = pData2[i];
|
||||
|
||||
}
|
||||
m_iIndicesNum += iData2;
|
||||
SafeDeleteA(m_pIndices);
|
||||
m_pIndices = pNewData2;
|
||||
}
|
||||
|
||||
}
|
||||
void CreateMorphBuffer(int iMorphNums)
|
||||
{
|
||||
m_bMorph = true;
|
||||
m_iMorph = iMorphNums;
|
||||
m_pMorphData = new CMeshMorphData[m_iMorph];
|
||||
}
|
||||
void SetMorphBuffer(int iMorphIndex,int iFrame,int iVertices,CExportMeshVertex *pVertices)
|
||||
{
|
||||
if(pVertices && iMorphIndex < m_iMorph && m_pMorphData)
|
||||
{
|
||||
m_pMorphData[iMorphIndex].m_iFrame = iFrame;
|
||||
m_pMorphData[iMorphIndex].m_pVertices = new CExportMeshVertex[iVertices];
|
||||
memcpy(m_pMorphData[iMorphIndex].m_pVertices,pVertices,sizeof(CExportMeshVertex ) * iVertices);
|
||||
}
|
||||
}
|
||||
void SetSkinMeshData(const int &iVertex,D3DXMATRIX *matTm,D3DXMATRIX *matInvNodeTm); // rigid
|
||||
void SetSkinMeshData(const int &iVertex,CMeshSkinData::CMeshBlendData *pBlend,const int &iBlend);
|
||||
|
||||
void SetUpdateFlag(bool bFlag) { m_bUpdateData = bFlag;}
|
||||
void UpdateMeshMorph(const float &fFrame);
|
||||
|
||||
void UpdateMeshSmartMorph();
|
||||
void SetSmartMorphInterValue(const float &fValue,const int &iIndex);
|
||||
int GetSmartMorphNum() { return m_iSMorph;}
|
||||
|
||||
CMeshObjNode *m_pNode;
|
||||
|
||||
char m_strName[256];
|
||||
int m_iType;
|
||||
int m_iVerticesNum;
|
||||
int m_iIndicesNum;
|
||||
int m_iMaterialIndex;
|
||||
|
||||
bool m_bUpdateData;
|
||||
|
||||
|
||||
CExportMeshVertex *m_pVertices;
|
||||
CExportMeshVertex *m_pDefaultVertices; //skinning <20><> <20><><EFBFBD><EFBFBD> default vertices.
|
||||
|
||||
WORD *m_pIndices;
|
||||
|
||||
bool m_bMorph;
|
||||
CMeshMorphData *m_pMorphData;
|
||||
int m_iMorph;
|
||||
|
||||
bool m_bSMorph;
|
||||
CMeshSMorphData *m_pSMorph;
|
||||
int m_iSMorph;
|
||||
float *m_pfSMorphInterValue;
|
||||
bool m_bTotalBilboard;
|
||||
|
||||
bool m_bCullOff;
|
||||
bool m_bZWriteOff;
|
||||
bool m_bZOff;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class CMeshObjNode
|
||||
{
|
||||
|
||||
public:
|
||||
CMeshObjNode() : m_pParent(0),m_pChild(0),m_iChild(0),m_iParentID(-1),m_iNodeID(-1),
|
||||
m_iNodeType(SMRNODE_NODE),m_iObjectType(SMROBJ_MESH),m_iMeshType(SMRMESHTYPE_STATIC),m_pAniNode(NULL),
|
||||
m_bSkinMorph(false),m_pSkinData(NULL)
|
||||
{
|
||||
memset(m_strName,0,sizeof(char) * 256);
|
||||
m_iMeshData = 0;
|
||||
m_pArrMeshData.clear();
|
||||
|
||||
m_bAniNode = false;
|
||||
D3DXMatrixIdentity(&m_matNodeTm);
|
||||
D3DXMatrixIdentity(&m_matInvNodeTm);
|
||||
|
||||
D3DXMatrixIdentity(&m_matLocalTm);
|
||||
|
||||
|
||||
m_fVisibility = 1.0f;
|
||||
|
||||
m_bWorldTM = false;
|
||||
|
||||
}
|
||||
~CMeshObjNode()
|
||||
{
|
||||
|
||||
SafeDeleteA(m_pChild);
|
||||
m_pChild = NULL;
|
||||
|
||||
|
||||
SafeDelete(m_pAniNode);
|
||||
m_pAniNode = NULL;
|
||||
|
||||
SafeDelete(m_pSkinData);
|
||||
m_pSkinData = NULL;
|
||||
|
||||
}
|
||||
void SetParentNode(CMeshObjNode *pNode,const int &iParentID)
|
||||
{
|
||||
m_pParent = pNode;
|
||||
m_iParentID = iParentID;
|
||||
}
|
||||
CMeshObjNode *GetParentNode()
|
||||
{
|
||||
return m_pParent;
|
||||
}
|
||||
int GetParentNodeID()
|
||||
{
|
||||
return m_iParentID;
|
||||
|
||||
}
|
||||
int GetChildNum()
|
||||
{
|
||||
return m_iChild;
|
||||
}
|
||||
CMeshObjNode *GetChildNode(int iNum)
|
||||
{
|
||||
if(iNum < m_iChild)
|
||||
{
|
||||
return &(m_pChild[iNum]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void SetNodeName(const char *strName) { strcpy(m_strName,strName);}
|
||||
bool IsNodeSameName(const char *strName)
|
||||
{
|
||||
if(!strcmp(m_strName,strName)) return true;
|
||||
return false;
|
||||
}
|
||||
char *GetNodeName() { return m_strName;}
|
||||
|
||||
int GetNodeID() { return m_iNodeID;}
|
||||
void SetNodeID(const int &iNodeID) { m_iNodeID = iNodeID;}
|
||||
void SetType(const int &iNodeType,const int &iObjType,const int &iMeshType)
|
||||
{
|
||||
m_iNodeType = iNodeType;
|
||||
m_iObjectType = iObjType;
|
||||
m_iMeshType = iMeshType;
|
||||
}
|
||||
int GetNodeType() { return m_iNodeType;}
|
||||
int GetObjectType() { return m_iObjectType;}
|
||||
int GetMeshType() { return m_iMeshType;}
|
||||
|
||||
|
||||
CMeshCoreData *GetMeshData(const int &iMat)
|
||||
{
|
||||
for(unsigned int i = 0; i < m_pArrMeshData.size(); i++ )
|
||||
{
|
||||
if(m_pArrMeshData[i]->m_iMaterialIndex == iMat)
|
||||
return m_pArrMeshData[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void SetSkinMeshData(const int &iMat,const int &iVertex,CMeshSkinData::CMeshBlendData *pBlend,const int &iBlend)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < m_pArrMeshData.size(); i++ )
|
||||
{
|
||||
if(m_pArrMeshData[i]->m_iMaterialIndex == iMat)
|
||||
m_pArrMeshData[i]->SetSkinMeshData(iVertex,pBlend,iBlend);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void SetSkinMeshData(const int &iMat,const int &iVertex,D3DXMATRIX *matTm,D3DXMATRIX *matInvNodeTm)
|
||||
{
|
||||
|
||||
for(unsigned int i = 0; i < m_pArrMeshData.size(); i++ )
|
||||
{
|
||||
if(m_pArrMeshData[i]->m_iMaterialIndex == iMat)
|
||||
m_pArrMeshData[i]->SetSkinMeshData(iVertex,matTm,matInvNodeTm);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void AddMeshData(CMeshCoreData *pMesh)
|
||||
{
|
||||
m_pArrMeshData.push_back(pMesh);
|
||||
pMesh->m_pNode = this;
|
||||
|
||||
m_iMeshData++;
|
||||
|
||||
}
|
||||
void SetChildNum(const int &iNum) {
|
||||
m_iChild = iNum;
|
||||
SafeDeleteA(m_pChild);
|
||||
if(iNum > 0)
|
||||
{
|
||||
m_pChild = new CMeshObjNode[m_iChild];
|
||||
for(int i = 0; i <m_iChild; i++ )
|
||||
{
|
||||
m_pChild[i].SetParentNode(this,m_iNodeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetAniNode(CMeshKeyAniNode *pNode)
|
||||
{
|
||||
m_pAniNode = pNode;
|
||||
m_bAniNode = true;
|
||||
}
|
||||
CMeshKeyAniNode *GetAniNode()
|
||||
{
|
||||
if(m_bAniNode)
|
||||
return m_pAniNode;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
bool ISAniNode()
|
||||
{
|
||||
return m_bAniNode;
|
||||
|
||||
}
|
||||
void SetSkinData(CMeshSkinData *pData)
|
||||
{
|
||||
m_pSkinData = pData;
|
||||
m_bSkinMorph =true;
|
||||
|
||||
}
|
||||
CMeshSkinData *GetSkinData()
|
||||
{
|
||||
if(m_bSkinMorph)
|
||||
return m_pSkinData;
|
||||
return NULL;
|
||||
}
|
||||
bool ISSkinData()
|
||||
{
|
||||
return m_bSkinMorph;
|
||||
|
||||
}
|
||||
void SetWorldTMFlag(bool bFlag) { m_bWorldTM = bFlag;}
|
||||
bool GetWorldTMFlag() { return m_bWorldTM;}
|
||||
|
||||
void UpdateTm(const float &fFrame,D3DXMATRIX *matParent = NULL);
|
||||
void UpdateSkinning();
|
||||
|
||||
|
||||
CMeshObjNode * m_pParent;
|
||||
int m_iParentID;
|
||||
|
||||
CMeshObjNode * m_pChild;
|
||||
int m_iChild;
|
||||
|
||||
D3DXMATRIX m_matNodeTm;
|
||||
D3DXMATRIX m_matInvNodeTm;
|
||||
|
||||
D3DXMATRIX m_matLocalTm;
|
||||
|
||||
|
||||
|
||||
CNodeTMInfo m_DefaultNodeTm;
|
||||
float m_fVisibility;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
char m_strName[256];
|
||||
int m_iNodeID;
|
||||
|
||||
int m_iNodeType;
|
||||
int m_iObjectType;
|
||||
int m_iMeshType;
|
||||
bool m_bWorldTM;
|
||||
|
||||
|
||||
CMeshKeyAniNode *m_pAniNode;
|
||||
bool m_bAniNode;
|
||||
|
||||
bool m_bSkinMorph;
|
||||
CMeshSkinData *m_pSkinData;
|
||||
|
||||
|
||||
|
||||
std::vector<CMeshCoreData *> m_pArrMeshData; // loading <20>Ҷ<EFBFBD> ä<><C3A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
||||
int m_iMeshData;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
572
Engine/Effect/SMRObj.cpp
Normal file
572
Engine/Effect/SMRObj.cpp
Normal file
@@ -0,0 +1,572 @@
|
||||
// SMRObj.cpp: implementation of the CSMRObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SMRObj.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
const DWORD dwExportMeshVertex = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
|
||||
|
||||
void CSMRObj::GetAniNode(SGEngine::Core::CMeshObjNode *pNode,FILE *fp)
|
||||
{
|
||||
bool bAni = false;
|
||||
bool bWorldTM = false;
|
||||
bool bSkin = false;
|
||||
|
||||
int iNum[8];
|
||||
int iAniNum[14];
|
||||
|
||||
fread(iNum,sizeof(int) * 8,1,fp);
|
||||
pNode->SetNodeID(iNum[0]);
|
||||
pNode->SetType(iNum[2],iNum[3],iNum[4]);
|
||||
pNode->SetChildNum(iNum[1]);
|
||||
|
||||
bAni = (iNum[5] == 1) ? true : false;
|
||||
bWorldTM = (iNum[6] == 1) ? true : false;
|
||||
bSkin = (iNum[7] == 1) ? true : false;
|
||||
|
||||
|
||||
pNode->SetWorldTMFlag(bWorldTM);
|
||||
|
||||
|
||||
fread(pNode->GetNodeName(),sizeof(char) * 256,1,fp);
|
||||
fread(&(pNode->m_DefaultNodeTm),sizeof(SGEngine::Core::CNodeTMInfo),1,fp);
|
||||
fread(&(pNode->m_matNodeTm),sizeof(D3DXMATRIX),1,fp);
|
||||
D3DXMatrixInverse(&(pNode->m_matInvNodeTm),NULL,&(pNode->m_matNodeTm));
|
||||
|
||||
|
||||
if(bAni)
|
||||
{
|
||||
SGEngine::Core::CMeshKeyAniNode *pAniNode = new SGEngine::Core::CMeshKeyAniNode;
|
||||
fread(iAniNum,sizeof(int) * 14,1,fp);
|
||||
|
||||
pAniNode->m_bPosAni = (iAniNum[0] == 1) ? true : false;
|
||||
pAniNode->m_bRotAni = (iAniNum[1] == 1) ? true : false;
|
||||
pAniNode->m_bScaleAni = (iAniNum[2] == 1) ? true : false;
|
||||
pAniNode->m_bVisAni = (iAniNum[3] == 1) ? true : false;
|
||||
|
||||
pAniNode->m_iPosKeys = iAniNum[4];
|
||||
pAniNode->m_iPosType = iAniNum[5];
|
||||
|
||||
pAniNode->m_iRotKeys = iAniNum[6];
|
||||
pAniNode->m_iRotType = iAniNum[7];
|
||||
|
||||
pAniNode->m_iScaleKeys = iAniNum[8];
|
||||
pAniNode->m_iScaleType = iAniNum[9];
|
||||
|
||||
pAniNode->m_iVisKeys = iAniNum[10];
|
||||
pAniNode->m_iVisType = iAniNum[11];
|
||||
|
||||
pAniNode->m_bTmAni = (iAniNum[12] == 1) ? true : false;
|
||||
pAniNode->m_iTmKeys = iAniNum[13];
|
||||
|
||||
if(pAniNode->m_iPosKeys > 0)
|
||||
{
|
||||
pAniNode->m_pPosKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniPos[pAniNode->m_iPosKeys];
|
||||
fread(pAniNode->m_pPosKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniPos) * pAniNode->m_iPosKeys,1,fp);
|
||||
}
|
||||
if(pAniNode->m_iRotKeys > 0)
|
||||
{
|
||||
pAniNode->m_pRotKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniRot[pAniNode->m_iRotKeys];
|
||||
fread(pAniNode->m_pRotKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniRot) *pAniNode->m_iRotKeys,1,fp);
|
||||
|
||||
}
|
||||
if(pAniNode->m_iScaleKeys > 0)
|
||||
{
|
||||
pAniNode->m_pScaleKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniScale[pAniNode->m_iScaleKeys ];
|
||||
fread(pAniNode->m_pScaleKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniScale) *pAniNode->m_iScaleKeys ,1,fp);
|
||||
|
||||
}
|
||||
if(pAniNode->m_iVisKeys > 0)
|
||||
{
|
||||
pAniNode->m_pVisKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniVis[pAniNode->m_iVisKeys];
|
||||
fread(pAniNode->m_pVisKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniVis) *pAniNode->m_iVisKeys,1,fp);
|
||||
|
||||
}
|
||||
if(pAniNode->m_iTmKeys > 0)
|
||||
{
|
||||
pAniNode->m_pTmKeys = new SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniTm[pAniNode->m_iTmKeys];
|
||||
fread(pAniNode->m_pTmKeys,sizeof(SGEngine::Core::CMeshKeyAniNode::CMeshKeyAniTm) * pAniNode->m_iTmKeys,1,fp);
|
||||
}
|
||||
pNode->SetAniNode(pAniNode);
|
||||
|
||||
}
|
||||
if(bSkin)
|
||||
{
|
||||
SGEngine::Core::CMeshSkinData *pSkinData = new SGEngine::Core::CMeshSkinData;
|
||||
int iSkinNum[2];
|
||||
fread(iSkinNum,sizeof(int) * 2, 1,fp);
|
||||
|
||||
pSkinData->m_iRigid = iSkinNum[0];
|
||||
|
||||
pSkinData->m_iBlend = iSkinNum[1];
|
||||
|
||||
if(iSkinNum[0])
|
||||
{
|
||||
pSkinData->m_pRigid = new SGEngine::Core::CMeshSkinData::CMeshSkinRigid[iSkinNum[0]];
|
||||
fread(pSkinData->m_pRigid,sizeof(SGEngine::Core::CMeshSkinData::CMeshSkinRigid) * iSkinNum[0],1,fp);
|
||||
}
|
||||
if(iSkinNum[1])
|
||||
{
|
||||
pSkinData->m_pBlend = new SGEngine::Core::CMeshSkinData::CMeshSkinBlend[iSkinNum[1]];
|
||||
for(int iBlend = 0; iBlend < iSkinNum[1]; iBlend++)
|
||||
{
|
||||
int iBlendNum[3];
|
||||
|
||||
fread(iBlendNum,sizeof(int) * 3, 1,fp);
|
||||
pSkinData->m_pBlend[iBlend].m_iMatIndex = iBlendNum[0];
|
||||
pSkinData->m_pBlend[iBlend].m_iVertexIndex = iBlendNum[1];
|
||||
pSkinData->m_pBlend[iBlend].m_iBlendData = iBlendNum[2];
|
||||
|
||||
if(iBlendNum[2])
|
||||
{
|
||||
pSkinData->m_pBlend[iBlend].m_pArrBlendData = new SGEngine::Core::CMeshSkinData::CMeshBlendData[iBlendNum[2]];
|
||||
fread(pSkinData->m_pBlend[iBlend].m_pArrBlendData,sizeof(SGEngine::Core::CMeshSkinData::CMeshBlendData) * iBlendNum[2],1,fp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
pNode->SetSkinData(pSkinData);
|
||||
}
|
||||
for(int i= 0; i < pNode->GetChildNum(); i++)
|
||||
GetAniNode(pNode->GetChildNode(i),fp);
|
||||
|
||||
|
||||
|
||||
}
|
||||
void CSMRObj::AddMesh(SGEngine::Core::CMeshCoreData *pMesh,SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
if(pNode && pMesh)
|
||||
{
|
||||
if(!strcmp(pNode->GetNodeName() , pMesh->m_strName))
|
||||
{
|
||||
pNode->AddMeshData(pMesh);
|
||||
|
||||
if(pNode->ISSkinData())
|
||||
{
|
||||
pMesh->CreateDefaultBuffer();
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
AddMesh(pMesh,pNode->GetChildNode(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSMRObj::Load(const char *strFileName)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
|
||||
if(fp)
|
||||
{
|
||||
fread(&m_MeshHeader,sizeof(SGEngine::Core::CMeshHeader),1,fp);
|
||||
|
||||
m_iFrameInfo[0] = m_MeshHeader.m_iExtension[0]; // Start Frame
|
||||
m_iFrameInfo[1] = m_MeshHeader.m_iExtension[1]; // End Frame
|
||||
m_iFrameInfo[2] = m_MeshHeader.m_iExtension[2]; // Frame Rate
|
||||
m_iFrameInfo[3] = m_MeshHeader.m_iExtension[3]; // TickPerFrame
|
||||
|
||||
for(i = 0; i < m_MeshHeader.m_iNodes; i++ )
|
||||
{
|
||||
SGEngine::Core::CMeshObjNodeHeader ObjHeader;
|
||||
fread(&ObjHeader,sizeof(SGEngine::Core::CMeshObjNodeHeader),1,fp);
|
||||
|
||||
if(ObjHeader.m_iNodeType == SGEngine::MESHNODETYPE_MATERIAL)
|
||||
{
|
||||
m_iMaterial = ObjHeader.m_iNodeSize;
|
||||
if(m_iMaterial)
|
||||
{
|
||||
m_pMaterial = new SGEngine::Core::CMeshMaterialInfo[m_iMaterial];
|
||||
fread(m_pMaterial,sizeof(SGEngine::Core::CMeshMaterialInfo) * m_iMaterial,1,fp);
|
||||
CTexture *pTexture = NULL;
|
||||
CTexture::SetPath(EFFECTTEXTUREPATH);
|
||||
|
||||
for(j = 0; j < m_iMaterial; j++ )
|
||||
{
|
||||
|
||||
pTexture = new CTexture;
|
||||
pTexture->Load(m_pMaterial[j].m_strName);
|
||||
m_lstTexture.push_back(pTexture);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else if(ObjHeader.m_iNodeType == SGEngine::MESHNODETYPE_MESHDATA)
|
||||
{
|
||||
int iNum[6];
|
||||
m_iMeshData = ObjHeader.m_iNodeSize;
|
||||
m_pMeshData = new SGEngine::Core::CMeshCoreData[m_iMeshData];
|
||||
m_pVertexBuffer = new LPDIRECT3DVERTEXBUFFER8[m_iMeshData];
|
||||
m_pIndexBuffer= new LPDIRECT3DINDEXBUFFER8[m_iMeshData];
|
||||
|
||||
for(j = 0 ; j < (int)ObjHeader.m_iNodeSize; j++ )
|
||||
{
|
||||
|
||||
fread(iNum,sizeof(int) * 6,1,fp);
|
||||
m_pMeshData[j].m_iVerticesNum = iNum[2];
|
||||
m_pMeshData[j].m_iIndicesNum = iNum[3];
|
||||
m_pMeshData[j].m_iMaterialIndex = iNum[1];
|
||||
m_pMeshData[j].m_iType = iNum[0];
|
||||
m_pMeshData[j].m_bMorph = (iNum[4] == 1) ? true : false;
|
||||
m_pMeshData[j].m_bSMorph = (iNum[5] == 1) ? true : false;
|
||||
|
||||
fread(m_pMeshData[j].m_strName,sizeof(char) * 256, 1,fp);
|
||||
if(strchr(m_pMeshData[j].m_strName,'C'))
|
||||
{
|
||||
m_pMeshData[j].SetTotalBilboard(true);
|
||||
}
|
||||
if(strchr(m_pMeshData[j].m_strName,'Z'))
|
||||
{
|
||||
m_pMeshData[j].SetZWriteOffFlag(true);
|
||||
}
|
||||
if(strchr(m_pMeshData[j].m_strName,'W'))
|
||||
{
|
||||
m_pMeshData[j].SetCullOffFlag(true);
|
||||
}
|
||||
if(strchr(m_pMeshData[j].m_strName,'K'))
|
||||
{
|
||||
m_pMeshData[j].SetZOffFlag(true);
|
||||
}
|
||||
m_pMeshData[j].CreateBuffer();
|
||||
fread(m_pMeshData[j].m_pIndices,sizeof(WORD) * m_pMeshData[j].m_iIndicesNum,1,fp);
|
||||
fread(m_pMeshData[j].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[j].m_iVerticesNum,1,fp);
|
||||
if(m_pMeshData[j].m_bMorph)
|
||||
{
|
||||
fread(&m_pMeshData[j].m_iMorph,sizeof(int), 1,fp);
|
||||
m_pMeshData[j].m_pMorphData = new SGEngine::Core::CMeshCoreData::CMeshMorphData[m_pMeshData[j].m_iMorph];
|
||||
for(int iMorph= 0; iMorph < m_pMeshData[j].m_iMorph; iMorph++)
|
||||
{
|
||||
|
||||
fread(&m_pMeshData[j].m_pMorphData[iMorph].m_iFrame,sizeof(int),1,fp);
|
||||
m_pMeshData[j].m_pMorphData[iMorph].m_pVertices = new SGEngine::CExportMeshVertex[m_pMeshData[j].m_iVerticesNum];
|
||||
|
||||
fread(m_pMeshData[j].m_pMorphData[iMorph].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[j].m_iVerticesNum,1,fp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if(m_pMeshData[j].m_bSMorph)
|
||||
{
|
||||
m_pMeshData[j].CreateDefaultBuffer();
|
||||
fread(&(m_pMeshData[j].m_iSMorph),sizeof(int),1,fp);
|
||||
m_pMeshData[j].m_pSMorph = new SGEngine::Core::CMeshCoreData::CMeshSMorphData[m_pMeshData[j].m_iSMorph];
|
||||
m_pMeshData[j].m_pfSMorphInterValue = new float[m_pMeshData[j].m_iSMorph];
|
||||
for(int ism = 0;ism < m_pMeshData[j].m_iSMorph; ism++)
|
||||
{
|
||||
m_pMeshData[j].m_pfSMorphInterValue[ism] = 0.0f;
|
||||
int iSMNum[2];
|
||||
fread(m_pMeshData[j].m_pSMorph[ism].m_strName,sizeof(char) * 256, 1,fp);
|
||||
fread(iSMNum,sizeof(int) * 2,1,fp);
|
||||
m_pMeshData[j].m_pSMorph[ism].m_iModelID = iSMNum[0];
|
||||
m_pMeshData[j].m_pSMorph[ism].m_iRelativeNum = iSMNum[1];
|
||||
m_pMeshData[j].m_pSMorph[ism].m_pRelativeVertices = new D3DXVECTOR3[iSMNum[1]];
|
||||
m_pMeshData[j].m_pSMorph[ism].m_pRelativeIndex = new int[iSMNum[1]];
|
||||
fread(m_pMeshData[j].m_pSMorph[ism].m_pRelativeVertices,sizeof(D3DXVECTOR3) * iSMNum[1],1,fp);
|
||||
fread(m_pMeshData[j].m_pSMorph[ism].m_pRelativeIndex,sizeof(int) * iSMNum[1],1,fp);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
CSceneManager::GetDevice()->CreateVertexBuffer(m_pMeshData[j].m_iVerticesNum * sizeof(SGEngine::CExportMeshVertex),D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC,
|
||||
D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1,D3DPOOL_DEFAULT,&(m_pVertexBuffer[j]));
|
||||
|
||||
SGEngine::CExportMeshVertex *pVert = NULL;
|
||||
|
||||
m_pVertexBuffer[j]->Lock(0,0,(BYTE **) &pVert,0);
|
||||
memcpy(pVert,m_pMeshData[j].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[j].m_iVerticesNum);
|
||||
m_pVertexBuffer[j]->Unlock();
|
||||
|
||||
CSceneManager::GetDevice()->CreateIndexBuffer(sizeof(WORD) * m_pMeshData[j].m_iIndicesNum,D3DUSAGE_WRITEONLY,D3DFMT_INDEX16,D3DPOOL_DEFAULT,&m_pIndexBuffer[j]);
|
||||
|
||||
WORD *pWord = NULL;
|
||||
|
||||
m_pIndexBuffer[j]->Lock(0,0,(BYTE **)&pWord,0);
|
||||
memcpy(pWord,m_pMeshData[j].m_pIndices,sizeof(WORD) * m_pMeshData[j].m_iIndicesNum);
|
||||
m_pIndexBuffer[j]->Unlock();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else if(ObjHeader.m_iNodeType == SGEngine::MESHNODETYPE_ANINODE)
|
||||
{
|
||||
m_pRootNode = new SGEngine::Core::CMeshObjNode;
|
||||
GetAniNode(m_pRootNode,fp);
|
||||
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
for(i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
AddMesh(&m_pMeshData[i],m_pRootNode);
|
||||
}
|
||||
SetSkinningLink(m_pRootNode);
|
||||
}
|
||||
}
|
||||
SGEngine::Core::CMeshObjNode *CSMRObj::FindNode(const char *strName,SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
int i;
|
||||
if(pNode)
|
||||
{
|
||||
if(pNode->IsNodeSameName(strName))
|
||||
return pNode;
|
||||
}
|
||||
for(i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
SGEngine::Core::CMeshObjNode * pN = NULL;
|
||||
if((pN = FindNode(strName,pNode->GetChildNode(i))) != NULL)
|
||||
return pN;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
}
|
||||
void CSMRObj::SetSkinningLink(SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
if(pNode->ISSkinData())
|
||||
{
|
||||
SGEngine::Core::CMeshSkinData *pSkinData = pNode->GetSkinData();
|
||||
|
||||
for(i = 0; i < pSkinData->m_iRigid; i++ )
|
||||
{
|
||||
pSkinData->m_pRigid[i].m_pNode = FindNode(pSkinData->m_pRigid[i].m_strNodeName,m_pRootNode);
|
||||
|
||||
}
|
||||
for(i =0; i < pSkinData->m_iBlend; i++ )
|
||||
{
|
||||
for(j = 0; j < (pSkinData->m_pBlend->m_iBlendData); j++ )
|
||||
{
|
||||
pSkinData->m_pBlend[i].m_pArrBlendData[j].m_pNode =
|
||||
FindNode(pSkinData->m_pBlend[i].m_pArrBlendData[j].m_strNodeName,m_pRootNode);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for(i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
SetSkinningLink(pNode->GetChildNode(i));
|
||||
}
|
||||
}
|
||||
void CSMRObj::UpdateSkinning(SGEngine::Core::CMeshObjNode *pNode)
|
||||
{
|
||||
if(pNode->ISSkinData())
|
||||
{
|
||||
pNode->UpdateSkinning();
|
||||
}
|
||||
for(int i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
UpdateSkinning(pNode->GetChildNode(i));
|
||||
}
|
||||
|
||||
}
|
||||
void CSMRObj::UpdateBuffer(const float &fFrame)
|
||||
{
|
||||
int i;
|
||||
|
||||
SGEngine::CExportMeshVertex *pVert = NULL;
|
||||
|
||||
for(i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
m_pMeshData[i].UpdateMeshMorph(fFrame);
|
||||
m_pMeshData[i].UpdateMeshSmartMorph();
|
||||
|
||||
if(m_pMeshData[i].m_bUpdateData)
|
||||
{
|
||||
m_pMeshData[i].SetUpdateFlag(false);
|
||||
pVert = NULL;
|
||||
|
||||
m_pVertexBuffer[i]->Lock(0,0,(BYTE **) &pVert,0);
|
||||
memcpy(pVert,m_pMeshData[i].m_pVertices,sizeof(SGEngine::CExportMeshVertex) * m_pMeshData[i].m_iVerticesNum);
|
||||
m_pVertexBuffer[i]->Unlock();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CSMRObj::UpdateTm(SGEngine::Core::CMeshObjNode *pNode,const float &fFrame)
|
||||
{
|
||||
if(pNode->GetParentNode())
|
||||
pNode->UpdateTm(fFrame,&(pNode->GetParentNode()->m_matNodeTm));
|
||||
else
|
||||
pNode->UpdateTm(fFrame,NULL);
|
||||
for(int i = 0; i < pNode->GetChildNum(); i++ )
|
||||
{
|
||||
UpdateTm(pNode->GetChildNode(i),fFrame);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSMRObj::Render(LPDIRECT3DDEVICE8 lpDevice,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecScale,D3DXQUATERNION quatRot,float fFrame)
|
||||
{
|
||||
|
||||
|
||||
|
||||
int i = 0;
|
||||
float iFrame = fFrame;
|
||||
|
||||
|
||||
// Scale, Pos ,setting
|
||||
// D3DXMATRIX matWorld;
|
||||
// D3DXMatrixIdentity(&matWorld);
|
||||
// matWorld._41 = vecPos.x;
|
||||
// matWorld._42 = vecPos.y;
|
||||
// matWorld._43 = vecPos.z;
|
||||
// matWorld._11 = vecScale.x;
|
||||
// matWorld._22 = vecScale.y;
|
||||
// matWorld._33 = vecScale.z;
|
||||
D3DXMATRIX matWorld, matScale, matRot;
|
||||
D3DXMatrixScaling( &matScale, vecScale.x, vecScale.y, vecScale.z );
|
||||
D3DXMatrixRotationQuaternion( &matRot, &quatRot );
|
||||
D3DXMatrixMultiply( &matWorld, &matRot, &matScale );
|
||||
matWorld._41 = vecPos.x;
|
||||
matWorld._42 = vecPos.y;
|
||||
matWorld._43 = vecPos.z;
|
||||
|
||||
|
||||
/*m_pRootNode->m_matNodeTm._41 = vecPos.x;
|
||||
m_pRootNode->m_matNodeTm._42 = vecPos.y;
|
||||
m_pRootNode->m_matNodeTm._43 = vecPos.z;
|
||||
|
||||
m_pRootNode->m_matNodeTm._11 = vecScale.x;
|
||||
m_pRootNode->m_matNodeTm._22 = vecScale.y;
|
||||
m_pRootNode->m_matNodeTm._33 = vecScale.z;
|
||||
*/
|
||||
|
||||
|
||||
UpdateTm(m_pRootNode,iFrame);
|
||||
UpdateSkinning(m_pRootNode); // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD><D6BE><EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
UpdateBuffer(iFrame);
|
||||
|
||||
|
||||
if(iFrame > (float)m_iFrameInfo[1])
|
||||
{
|
||||
iFrame = (float)m_iFrameInfo[0];
|
||||
|
||||
}
|
||||
if(iFrame < (float)m_iFrameInfo[0])
|
||||
iFrame = (float)m_iFrameInfo[1];
|
||||
|
||||
|
||||
|
||||
D3DXMATRIX matIdentity;
|
||||
D3DXMatrixIdentity(&matIdentity);
|
||||
|
||||
lpDevice->SetPixelShader(NULL);
|
||||
lpDevice->SetVertexShader(dwExportMeshVertex);
|
||||
|
||||
for(i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
if(m_pMeshData[i].m_iVerticesNum && m_pMeshData[i].m_iIndicesNum)
|
||||
{
|
||||
if(m_pMeshData[i].m_pNode)
|
||||
{
|
||||
|
||||
if(m_pMeshData[i].GetTotalBilboard())
|
||||
{ // bilboard
|
||||
|
||||
|
||||
D3DXMATRIX view;
|
||||
D3DXMATRIX invers_view;
|
||||
|
||||
lpDevice->GetTransform(D3DTS_VIEW,&view);
|
||||
view._41 = view._42 = view._43 =0.0;
|
||||
D3DXMatrixInverse(&invers_view,NULL,&view);
|
||||
D3DXMatrixMultiply(&(m_pMeshData[i].m_pNode->m_matNodeTm),&(m_pMeshData[i].m_pNode->m_matNodeTm),&invers_view);
|
||||
|
||||
|
||||
|
||||
}
|
||||
D3DXMatrixMultiply(&(m_pMeshData[i].m_pNode->m_matNodeTm),&(m_pMeshData[i].m_pNode->m_matNodeTm),&matWorld);
|
||||
|
||||
if(m_pMeshData[i].m_pNode->ISSkinData())
|
||||
{
|
||||
lpDevice->SetTransform(D3DTS_WORLD,&matIdentity);
|
||||
}
|
||||
else{
|
||||
lpDevice->SetTransform(D3DTS_WORLD,&(m_pMeshData[i].m_pNode->m_matNodeTm));
|
||||
|
||||
}
|
||||
|
||||
int iValue = (int)(m_pMeshData[i].m_pNode->m_fVisibility * 255.0f);
|
||||
|
||||
DWORD color = D3DCOLOR_ARGB(iValue,iValue,iValue,iValue);
|
||||
lpDevice->SetRenderState(D3DRS_TEXTUREFACTOR,color);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
DWORD color = D3DCOLOR_ARGB(255,255,255,255);
|
||||
lpDevice->SetRenderState(D3DRS_TEXTUREFACTOR,color);
|
||||
}
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
lpDevice->SetRenderState(D3DRS_ALPHATESTENABLE,FALSE);
|
||||
lpDevice->SetRenderState(D3DRS_SRCBLEND,m_dwSrcBlend);
|
||||
lpDevice->SetRenderState(D3DRS_DESTBLEND,m_dwDstBlend);
|
||||
|
||||
if(m_pMeshData[i].GetCullOffFlag())
|
||||
lpDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
else
|
||||
lpDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CCW);
|
||||
|
||||
if(m_pMeshData[i].GetZWriteOffFlag())
|
||||
{
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
}
|
||||
if(m_pMeshData[i].GetZOffFlag())
|
||||
lpDevice->SetRenderState(D3DRS_ZENABLE,FALSE);
|
||||
else
|
||||
lpDevice->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TFACTOR);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
|
||||
lpDevice->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TFACTOR);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_TEXTURE);
|
||||
lpDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
lpDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
|
||||
|
||||
lpDevice->SetTexture(0,m_lstTexture[m_pMeshData[i].m_iMaterialIndex]->GetTexture());
|
||||
|
||||
lpDevice->SetStreamSource(0,m_pVertexBuffer[i],sizeof(SGEngine::CExportMeshVertex));
|
||||
lpDevice->SetIndices(m_pIndexBuffer[i],0);
|
||||
lpDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,m_pMeshData[i].m_iVerticesNum,0,m_pMeshData[i].m_iIndicesNum/3);
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);
|
||||
|
||||
lpDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_LESSEQUAL);
|
||||
lpDevice->SetRenderState(D3DRS_ALPHATESTENABLE,FALSE);
|
||||
lpDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_CW);
|
||||
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
lpDevice->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
140
Engine/Effect/SMRObj.h
Normal file
140
Engine/Effect/SMRObj.h
Normal file
@@ -0,0 +1,140 @@
|
||||
// SMRObj.h: interface for the CSMRObj class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SMROBJ_H__FD33169B_0305_4327_A366_EC1DB3AAD241__INCLUDED_)
|
||||
#define AFX_SMROBJ_H__FD33169B_0305_4327_A366_EC1DB3AAD241__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "./SMRHeader.h"
|
||||
#include "texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
class CSMRObj
|
||||
{
|
||||
public:
|
||||
CSMRObj() :m_pMaterial(NULL),m_iMaterial(0),
|
||||
m_pMeshData(NULL),m_iMeshData(0)
|
||||
{
|
||||
|
||||
m_pVertexBuffer = NULL;
|
||||
m_pIndexBuffer = NULL;
|
||||
m_lstTexture.clear();
|
||||
|
||||
m_pRootNode = NULL;
|
||||
memset(m_iFrameInfo,0,sizeof(int) * 4);
|
||||
|
||||
m_dwSrcBlend = D3DBLEND_SRCALPHA;
|
||||
m_dwDstBlend = D3DBLEND_INVSRCALPHA;
|
||||
|
||||
|
||||
|
||||
}
|
||||
~CSMRObj()
|
||||
{
|
||||
|
||||
if(m_pMaterial)
|
||||
{
|
||||
delete[] m_pMaterial;
|
||||
m_pMaterial = NULL;
|
||||
|
||||
}
|
||||
if(m_pMeshData)
|
||||
{
|
||||
delete[] m_pMeshData;
|
||||
m_pMeshData = NULL;
|
||||
|
||||
}
|
||||
if(m_pVertexBuffer)
|
||||
{
|
||||
for(int i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
if(m_pVertexBuffer[i])
|
||||
m_pVertexBuffer[i]->Release();
|
||||
}
|
||||
delete[] m_pVertexBuffer;
|
||||
}
|
||||
if(m_pIndexBuffer)
|
||||
{
|
||||
for(int i = 0; i < m_iMeshData; i++ )
|
||||
{
|
||||
if(m_pIndexBuffer[i])
|
||||
m_pIndexBuffer[i]->Release();
|
||||
}
|
||||
delete[] m_pIndexBuffer;
|
||||
|
||||
}
|
||||
|
||||
std::vector<CTexture* >::iterator itr = m_lstTexture.begin() ;
|
||||
std::vector<CTexture* >::iterator end = m_lstTexture.end() ;
|
||||
while ( itr != end )
|
||||
{
|
||||
if ( NULL != (*itr) )
|
||||
{
|
||||
delete (*itr) ;
|
||||
(*itr) = NULL ;
|
||||
}
|
||||
|
||||
++itr ;
|
||||
}
|
||||
m_lstTexture.clear();
|
||||
|
||||
if(m_pRootNode)
|
||||
{
|
||||
delete m_pRootNode;
|
||||
m_pRootNode = NULL;
|
||||
}
|
||||
}
|
||||
void Render(LPDIRECT3DDEVICE8 lpDevice,D3DXVECTOR3 vecPos,D3DXVECTOR3 vecScale,D3DXQUATERNION quatRot,float fFrame);
|
||||
void UpdateTm(SGEngine::Core::CMeshObjNode *pNode,const float &fFrame);
|
||||
void UpdateBuffer(const float &fFrame);
|
||||
void UpdateSkinning(SGEngine::Core::CMeshObjNode *pNode);
|
||||
void SetSkinningLink(SGEngine::Core::CMeshObjNode *pNode);
|
||||
SGEngine::Core::CMeshObjNode *FindNode(const char *strName,SGEngine::Core::CMeshObjNode *pNode);
|
||||
void Load(const char *strFileName);
|
||||
void AddMesh(SGEngine::Core::CMeshCoreData *pMesh,SGEngine::Core::CMeshObjNode *pNode);
|
||||
void GetAniNode(SGEngine::Core::CMeshObjNode *pNode,FILE *fp);
|
||||
|
||||
void SetSrcBlend(DWORD dwValue) { m_dwSrcBlend = dwValue;}
|
||||
void SetDstBlend(DWORD dwValue) { m_dwDstBlend = dwValue;}
|
||||
|
||||
DWORD GetSrcBlend() { return m_dwSrcBlend;}
|
||||
DWORD GetDstBlend() { return m_dwDstBlend;}
|
||||
|
||||
|
||||
SGEngine::Core::CMeshHeader m_MeshHeader;
|
||||
|
||||
SGEngine::Core::CMeshMaterialInfo *m_pMaterial;
|
||||
int m_iMaterial;
|
||||
|
||||
SGEngine::Core::CMeshCoreData *m_pMeshData;
|
||||
|
||||
|
||||
|
||||
|
||||
SGEngine::Core::CMeshObjNode *m_pRootNode;
|
||||
|
||||
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 *m_pVertexBuffer;
|
||||
LPDIRECT3DINDEXBUFFER8 *m_pIndexBuffer;
|
||||
|
||||
|
||||
std::vector<CTexture *> m_lstTexture;
|
||||
|
||||
|
||||
int m_iMeshData;
|
||||
|
||||
int m_iFrameInfo[4];
|
||||
|
||||
DWORD m_dwSrcBlend;
|
||||
DWORD m_dwDstBlend;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // !defined(AFX_SMROBJ_H__FD33169B_0305_4327_A366_EC1DB3AAD241__INCLUDED_)
|
||||
454
Engine/Effect/X3DEffect.cpp
Normal file
454
Engine/Effect/X3DEffect.cpp
Normal file
@@ -0,0 +1,454 @@
|
||||
// X3DEffect.cpp: implementation of the CX3DEffect class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectParticle.h"
|
||||
#include "X3DEffectBillboard.h"
|
||||
#include "X3DEffectCylinder.h"
|
||||
#include "X3DEffectPlane.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "EffDebugLog.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//#define __EFF_WCREATOR__
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffect::CX3DEffect()
|
||||
{
|
||||
m_dwMinFrame = 0.0f;
|
||||
m_fFrame = 0.0f;
|
||||
m_fBeforeFrame = 0.0f;
|
||||
m_bImportCenter = FALSE;
|
||||
m_lpCenter = NULL;
|
||||
m_bImportAxis = FALSE;
|
||||
m_lpAxis = NULL;
|
||||
m_dwKindMove = 0;
|
||||
m_dwCount = 0;
|
||||
m_SectorX = -1;
|
||||
m_SectorY = -1;
|
||||
map_effect = false;
|
||||
m_StartEffect = false;
|
||||
m_dwFrameTick = 33;
|
||||
m_MoveState = false;
|
||||
m_Mine = true;
|
||||
m_GemScale[0] = m_GemScale[1] = m_GemScale[2] = 1.0f;
|
||||
m_bLight = false;
|
||||
|
||||
}
|
||||
|
||||
CX3DEffect::~CX3DEffect()
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
delete pEffect;
|
||||
pEffect = NULL;
|
||||
}
|
||||
|
||||
m_lstEffect.clear();
|
||||
|
||||
if(!m_bImportCenter) if(m_lpCenter) { delete m_lpCenter; m_lpCenter = NULL; }
|
||||
if(m_lpAxis) { delete m_lpAxis; m_lpAxis = NULL; }
|
||||
}
|
||||
void CX3DEffect::SetScale(float x,float y,float z) {
|
||||
|
||||
m_GemScale[0] = x;m_GemScale[1] = y;m_GemScale[2] = z;
|
||||
if(m_lstEffect.size() > 0) {
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
if(pEffect != NULL)
|
||||
pEffect->SetEffectScale(x,y,z);
|
||||
}
|
||||
}
|
||||
}
|
||||
unsigned long CX3DEffect::AddEffect(CX3DEffectBase *pNewEffect)
|
||||
{
|
||||
pNewEffect->SetLocalDevice(m_lpD3DDevice);
|
||||
pNewEffect->SetLocalView(m_lpViewMatrix);
|
||||
pNewEffect->SetLocalEffect((void *)this);
|
||||
pNewEffect->SetLocalCenter(m_lpCenter);
|
||||
pNewEffect->SetLocalAxis(m_lpAxis);
|
||||
|
||||
m_lstEffect.push_back(pNewEffect);
|
||||
|
||||
return m_lstEffect.size() - 1;
|
||||
}
|
||||
|
||||
BOOL CX3DEffect::Interpolation(unsigned long dwTick, float fFrame)
|
||||
{
|
||||
|
||||
if((m_fFrame > m_dwMaxFrame) && !m_bLoop)
|
||||
return FALSE;
|
||||
|
||||
switch(m_dwKindMove)
|
||||
{
|
||||
case 1:
|
||||
if(m_dwCount == 30)
|
||||
return FALSE;
|
||||
m_lpCenter->x += m_vecPower.x;
|
||||
m_lpCenter->y += m_vecPower.y;
|
||||
m_lpCenter->z += m_vecPower.z;
|
||||
m_dwCount++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
if(-1.0f == fFrame)
|
||||
{
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
|
||||
if(!pEffect->Interpolation(m_fFrame))
|
||||
return FALSE;
|
||||
}
|
||||
m_fBeforeFrame = m_fFrame;
|
||||
m_fFrame += ((dwTick / m_dwFrameTick) * m_fIncFrame);
|
||||
if(m_bLoop && (m_fFrame >= m_dwMaxFrame)) {
|
||||
m_fFrame -= m_dwMaxFrame;
|
||||
m_fFrame += m_dwMinFrame;
|
||||
}
|
||||
} else
|
||||
{
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
|
||||
if(!pEffect->Interpolation(fFrame))
|
||||
return FALSE;
|
||||
}
|
||||
m_fBeforeFrame = m_fFrame;
|
||||
|
||||
m_fFrame = fFrame;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffect::Render(void)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
if(m_StartEffect) {
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->Render();
|
||||
}
|
||||
}
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
|
||||
}
|
||||
|
||||
CX3DEffectBase *CX3DEffect::GetEffect(unsigned long dwEffectNumber)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
unsigned long dwEffectCount = 0;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
if(dwEffectCount == dwEffectNumber) { return (CX3DEffectBase *)(*it); }
|
||||
dwEffectCount++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL CX3DEffect::DeleteEffect(unsigned long dwEffectNumber)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
unsigned long dwEffectCount = 0;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
if(dwEffectCount == dwEffectNumber)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
m_lstEffect.erase(it);
|
||||
delete pEffect;
|
||||
pEffect = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
dwEffectCount++;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
void CX3DEffect::SetAxis(quaternion *pAxis) {
|
||||
m_bImportAxis = TRUE;
|
||||
if(!m_lpAxis) m_lpAxis = new quaternion;
|
||||
|
||||
m_lpAxis->x = pAxis->x;
|
||||
m_lpAxis->y = pAxis->y;
|
||||
m_lpAxis->z = pAxis->z;
|
||||
m_lpAxis->w = pAxis->w;
|
||||
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetAxis(*pAxis);
|
||||
}
|
||||
}
|
||||
void CX3DEffect::SetAxis(float fAxisX, float fAxisY, float fAxisZ){
|
||||
|
||||
m_bImportAxis = TRUE;
|
||||
|
||||
if(!m_lpAxis) m_lpAxis = new quaternion;
|
||||
m_lpAxis->Identity();
|
||||
m_lpAxis->Pitch(FLOAT_DEG(fAxisX - (((unsigned long)(fAxisX / 360)) * 360.0f)));
|
||||
m_lpAxis->Yaw(FLOAT_DEG(fAxisY - (((unsigned long)(fAxisY / 360)) * 360.0f)));
|
||||
m_lpAxis->Roll(FLOAT_DEG(fAxisZ - (((unsigned long)(fAxisZ / 360)) * 360.0f)));
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetAxis(*m_lpAxis);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CX3DEffect::SetEffectSetting(void)
|
||||
{
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetLocalDevice(m_lpD3DDevice);
|
||||
pEffect->SetLocalView(m_lpViewMatrix);
|
||||
}
|
||||
}
|
||||
void CX3DEffect::SetMine(bool b) {
|
||||
m_Mine = b;
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetMine(m_Mine);
|
||||
}
|
||||
}
|
||||
void CX3DEffect::Load(const char *strFilePath, const char *strFileName,bool bLoad)
|
||||
{
|
||||
FILE *fp;
|
||||
char strFile[MAX_PATH];
|
||||
strcpy(strFile, strFilePath);
|
||||
strcat(strFile, strFileName);
|
||||
fp = fopen(strFile, "rb");
|
||||
if(!fp) {
|
||||
#ifdef __EFF_WCREATOR__
|
||||
WriteDebug(strFile); // File Converting<6E><67> Log File Write <20><>ƾ
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
CX3DEffectBase *lpEffect;
|
||||
unsigned short Size, Kind;
|
||||
unsigned long i, dwStartFrame, dwEndFrame;
|
||||
unsigned char len;
|
||||
char strTextureFile[MAX_PATH], strTemp[MAX_PATH];
|
||||
|
||||
fread(&m_dwMaxFrame, 4, 1, fp);
|
||||
fread(&m_dwFrameTick, 4, 1, fp);
|
||||
fread(&m_fIncFrame, 4, 1, fp);
|
||||
fread(&Size, 2, 1, fp);
|
||||
for(i = 0; i < Size; i++)
|
||||
{
|
||||
bool bParticle = false;
|
||||
|
||||
fread(&Kind, 2, 1, fp);
|
||||
|
||||
switch(Kind)
|
||||
{
|
||||
case EFFECT_PARTICLE:
|
||||
lpEffect = new CX3DEffectParticle;
|
||||
bParticle = true;
|
||||
break;
|
||||
|
||||
case EFFECT_BILLBOARD:
|
||||
lpEffect = new CX3DEffectBillboard;
|
||||
break;
|
||||
|
||||
case EFFECT_CYLINDER:
|
||||
lpEffect = new CX3DEffectCylinder;
|
||||
break;
|
||||
|
||||
case EFFECT_PLANE:
|
||||
lpEffect = new CX3DEffectPlane;
|
||||
break;
|
||||
|
||||
case EFFECT_SPHERE:
|
||||
lpEffect = new CX3DEffectSphere;
|
||||
break;
|
||||
|
||||
case EFFECT_MESH:
|
||||
lpEffect = new CX3DEffectMesh;
|
||||
break;
|
||||
|
||||
default:
|
||||
MessageBox(NULL, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "<EFBFBD><EFBFBD><EFBFBD><EFBFBD>", MB_OK);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
fread(&len, 1, 1, fp);
|
||||
if(len)
|
||||
{
|
||||
char *t_ptr = NULL;
|
||||
fread(strTemp, len, 1, fp);
|
||||
t_ptr = strrchr(strTemp,'\\');
|
||||
if(t_ptr != NULL) {
|
||||
t_ptr++;
|
||||
strcpy(strTextureFile,t_ptr);
|
||||
}
|
||||
else {
|
||||
strcpy(strTextureFile,strTemp);
|
||||
}
|
||||
//strcpy(strTextureFile, strFilePath);
|
||||
//strcat(strTextureFile, strTemp);
|
||||
|
||||
} else
|
||||
{
|
||||
strcpy(strTextureFile, "");
|
||||
}
|
||||
|
||||
AddEffect(lpEffect);
|
||||
if(bLoad)
|
||||
if(strTextureFile) lpEffect->LoadTexture(strTextureFile);
|
||||
fread(&dwStartFrame, 4, 1, fp);
|
||||
fread(&dwEndFrame, 4, 1, fp);
|
||||
lpEffect->SetVisibility(bLoad);
|
||||
lpEffect->Create(dwStartFrame, dwEndFrame);
|
||||
lpEffect->SetEffectKind(Kind);
|
||||
lpEffect->SetEffectScale(m_GemScale[0],m_GemScale[1],m_GemScale[2]);
|
||||
lpEffect->SetLight(m_bLight);
|
||||
lpEffect->Load(fp, strFilePath);
|
||||
if(bLoad || bParticle)
|
||||
lpEffect->CreateBuffer();
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void CX3DEffect::Save(const char *strFilePath, const char *strFileName)
|
||||
{
|
||||
FILE *fp;
|
||||
char strFile[MAX_PATH];
|
||||
strcpy(strFile, strFilePath);
|
||||
strcat(strFile, strFileName);
|
||||
fp = fopen(strFile, "wb");
|
||||
if(!fp) return;
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
unsigned short Size = m_lstEffect.size(), Kind;
|
||||
unsigned char len;
|
||||
unsigned long StartFrame, EndFrame;
|
||||
|
||||
fwrite(&m_dwMaxFrame, 4, 1, fp);
|
||||
fwrite(&m_dwFrameTick, 4, 1, fp);
|
||||
fwrite(&m_fIncFrame, 4, 1, fp);
|
||||
fwrite(&Size, 2, 1, fp);
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
|
||||
Kind = (unsigned short)pEffect->GetEffectKind();
|
||||
StartFrame = pEffect->GetStartFrame();
|
||||
EndFrame = pEffect->GetEndFrame();
|
||||
len = strlen(pEffect->GetTextureFileName()) + 1;
|
||||
|
||||
fwrite(&Kind, 2, 1, fp);
|
||||
if(len == 1)
|
||||
{
|
||||
len = 0;
|
||||
fwrite(&len, 1, 1, fp);
|
||||
} else
|
||||
{
|
||||
fwrite(&len, 1, 1, fp);
|
||||
fwrite(pEffect->GetTextureFileName(), len, 1, fp);
|
||||
}
|
||||
fwrite(&StartFrame, 4, 1, fp);
|
||||
fwrite(&EndFrame, 4, 1, fp);
|
||||
|
||||
pEffect->Save(fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
void CX3DEffect::SetDirectMove(vector3 &vecDest, vector3 &vecPower, vector3 &vecEForce)
|
||||
{
|
||||
m_dwKindMove = 1;
|
||||
m_vecDest = vecDest;
|
||||
m_vecPower = (m_vecDest - *m_lpCenter) / 30.0f;
|
||||
m_vecEForce = vecEForce;
|
||||
}
|
||||
void CX3DEffect::SetLoop(BOOL bLoop) {
|
||||
m_bLoop = bLoop;
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetGemClearBuffer(!bLoop); // clear buffer setting
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffect::SetWorldEffect(bool t) {
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetWorldEffect(t);
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffect::SetStopParticle(int t) {
|
||||
|
||||
list<CX3DEffectBase *>::iterator it;
|
||||
|
||||
CX3DEffectBase *pEffect;
|
||||
|
||||
for(it = m_lstEffect.begin(); it != m_lstEffect.end(); it++)
|
||||
{
|
||||
pEffect = (CX3DEffectBase *)(*it);
|
||||
pEffect->SetStopParticle(t);
|
||||
}
|
||||
|
||||
}
|
||||
141
Engine/Effect/X3DEffect.h
Normal file
141
Engine/Effect/X3DEffect.h
Normal file
@@ -0,0 +1,141 @@
|
||||
// X3DEffect.h: interface for the CX3DEffect class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECT_H__36D22C0B_3861_4B57_B539_4E4BFAD198C1__INCLUDED_)
|
||||
#define AFX_X3DEFFECT_H__36D22C0B_3861_4B57_B539_4E4BFAD198C1__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#pragma warning(disable:4786) // don't warn about browse name overflow.
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "z3dmath.h"
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
class CX3DEffect
|
||||
{
|
||||
protected:
|
||||
list<CX3DEffectBase *> m_lstEffect;
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDevice;
|
||||
matrix *m_lpViewMatrix;
|
||||
|
||||
unsigned long m_dwFrameTick;
|
||||
float m_fFrame;
|
||||
float m_fBeforeFrame;
|
||||
|
||||
float m_fIncFrame;
|
||||
unsigned long m_dwMaxFrame;
|
||||
unsigned long m_dwMinFrame;
|
||||
// <20><><EFBFBD><EFBFBD>Ʈ <20>̵<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool m_MoveState;
|
||||
|
||||
BOOL m_bLoop;
|
||||
unsigned long m_dwKindMove;
|
||||
vector3 m_vecDest;
|
||||
vector3 m_vecPower;
|
||||
vector3 m_vecEForce;
|
||||
unsigned long m_dwCount;
|
||||
unsigned long m_dwOldTick;
|
||||
|
||||
BOOL m_bImportCenter;
|
||||
vector3 *m_lpCenter;
|
||||
BOOL m_bImportAxis;
|
||||
quaternion *m_lpAxis;
|
||||
color m_lFlash;
|
||||
//scale value
|
||||
float m_GemScale[3];
|
||||
// effect<63><74> <20><><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD>
|
||||
bool m_StartEffect;
|
||||
bool m_Mine;
|
||||
|
||||
CKeyList<ColorKeyList> m_lstFlash;
|
||||
bool m_bLight;
|
||||
|
||||
public:
|
||||
bool map_effect;
|
||||
int m_SectorX;
|
||||
int m_SectorY;
|
||||
|
||||
CX3DEffect();
|
||||
virtual ~CX3DEffect();
|
||||
void SetMine(bool b);
|
||||
|
||||
void SetCenter(vector3 *pCenter) { m_bImportCenter = TRUE; m_lpCenter = pCenter; }
|
||||
void SetCenter(float fX, float fY, float fZ)
|
||||
{
|
||||
m_bImportCenter = FALSE;
|
||||
if(!m_lpCenter) m_lpCenter = new vector3;
|
||||
m_lpCenter->x = fX;
|
||||
m_lpCenter->y = fY;
|
||||
m_lpCenter->z = fZ;
|
||||
}
|
||||
vector3 *GetCenter(void) { return m_lpCenter; }
|
||||
|
||||
void SetAxis(quaternion *pAxis);
|
||||
void SetAxis(float fAxisX, float fAxisY, float fAxisZ);
|
||||
|
||||
quaternion *GetAxis(void) { return m_lpAxis; }
|
||||
|
||||
|
||||
void SetFlash(unsigned long dwTick, color lColor)
|
||||
{
|
||||
SetKey(dwTick, m_lstFlash, lColor);
|
||||
}
|
||||
BOOL GetFlash(unsigned long dwTick, color &lColor)
|
||||
{
|
||||
return m_lstFlash.Find(dwTick, lColor);
|
||||
}
|
||||
void SetDevice(LPDIRECT3DDEVICE8 lpD3DDevice) { m_lpD3DDevice = lpD3DDevice; }
|
||||
LPDIRECT3DDEVICE8 GetDevice(void) { return m_lpD3DDevice; }
|
||||
void SetViewMatrix(matrix *pViewMatrix) { m_lpViewMatrix = pViewMatrix; }
|
||||
matrix *GetViewMatrix(void) { return m_lpViewMatrix; }
|
||||
|
||||
|
||||
void SetFrameTick(unsigned long dwFrameTick) { m_dwFrameTick = dwFrameTick; }
|
||||
unsigned long GetFrameTick(void) { return m_dwFrameTick; }
|
||||
void SetTick(unsigned long dwTick) { m_dwOldTick = dwTick; }
|
||||
unsigned long GetTick(void) { return m_dwOldTick; }
|
||||
void SetMaxFrame(unsigned long dwMaxFrame) { m_dwMaxFrame = dwMaxFrame - 1; }
|
||||
void SetMinFrame(unsigned long dwMinFrame) {m_dwMinFrame = dwMinFrame;}
|
||||
void SetStopParticle(int t);
|
||||
|
||||
unsigned long GetMaxFrame(void) { return m_dwMaxFrame; }
|
||||
void SetFrame(float fFrame) { m_fBeforeFrame = m_fFrame; m_fFrame = fFrame; }
|
||||
float GetBeforeFrame(void) { return m_fBeforeFrame;}
|
||||
float GetFrame(void) { return m_fFrame; }
|
||||
void SetIncFrame(float fIncFrame) { m_fIncFrame = fIncFrame; }
|
||||
float GetIncFrame(void) { return m_fIncFrame; }
|
||||
void SetLoop(BOOL bLoop);
|
||||
BOOL GetLoop(void) { return m_bLoop; }
|
||||
//effect <20><><EFBFBD><EFBFBD>
|
||||
void SetEffectStart(bool t) {m_StartEffect = t;}
|
||||
bool GetEffectStart() { return m_StartEffect;}
|
||||
|
||||
unsigned long AddEffect(CX3DEffectBase *pNewEffect);
|
||||
CX3DEffectBase *GetEffect(unsigned long dwEffectNumber);
|
||||
BOOL DeleteEffect(unsigned long dwEffectNumber);
|
||||
void SetEffectSetting(void);
|
||||
|
||||
void SetFreezeMove(void) { m_dwKindMove = 0; }
|
||||
void SetDirectMove(vector3 &vecDest, vector3 &vecPower, vector3 &vecEForce);
|
||||
void SetMoveState(bool t){ m_MoveState = t;}
|
||||
bool GetMoveState() {return m_MoveState;}
|
||||
void SetScale(float x,float y,float z); //{m_GemScale[0] = x;m_GemScale[1] = y;m_GemScale[2] = z;}
|
||||
|
||||
void Render(void);
|
||||
void SetWorldEffect(bool t);
|
||||
void SetLight(bool b) { m_bLight = b;}
|
||||
|
||||
BOOL Interpolation(unsigned long dwTick, float fFrame = -1.0f);
|
||||
|
||||
void Load(const char *strFilePath, const char *strFileName,bool bLoad = true);
|
||||
void Save(const char *strFilePath, const char *strFileName);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECT_H__36D22C0B_3861_4B57_B539_4E4BFAD198C1__INCLUDED_)
|
||||
51
Engine/Effect/X3DEffectBase.cpp
Normal file
51
Engine/Effect/X3DEffectBase.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
// X3DEffectBase.cpp: implementation of the CX3DEffectBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectBase::CX3DEffectBase()
|
||||
{
|
||||
m_QuatSet = false;
|
||||
m_lpTexture = NULL;
|
||||
m_index=-1;
|
||||
m_Scale[0] = m_Scale[1] = m_Scale[2] = 1.0f;
|
||||
strcpy(m_strTextureFile, "");
|
||||
m_bWorldEffect = false;
|
||||
m_Mine = true;
|
||||
m_StopParticleFrame = -1;
|
||||
m_bLight = false;
|
||||
m_bClearBuffer = true;
|
||||
}
|
||||
|
||||
CX3DEffectBase::~CX3DEffectBase()
|
||||
{
|
||||
if(m_lpTexture) { delete m_lpTexture; m_lpTexture = NULL; }
|
||||
}
|
||||
void CX3DEffectBase::SetStopParticle(int t) {
|
||||
m_StopParticleFrame = t;
|
||||
}
|
||||
int CX3DEffectBase::GetStopParticle() {
|
||||
return m_StopParticleFrame;
|
||||
}
|
||||
void CX3DEffectBase::LoadTexture(const char *strFilename)
|
||||
{
|
||||
if(m_lpTexture) { delete m_lpTexture; m_lpTexture = NULL; }
|
||||
m_lpTexture = new CTexture();
|
||||
m_lpTexture->Init(m_lpD3DDevice);
|
||||
|
||||
m_lpTexture->SetPath(EFFECTTEXTUREPATH);
|
||||
m_lpTexture->Load((char *)strFilename);
|
||||
strcpy(m_strTextureFile, strFilename);
|
||||
}
|
||||
|
||||
void CX3DEffectBase::SetGemClearBuffer(bool b)
|
||||
{
|
||||
m_bClearBuffer = b;
|
||||
|
||||
}
|
||||
147
Engine/Effect/X3DEffectBase.h
Normal file
147
Engine/Effect/X3DEffectBase.h
Normal file
@@ -0,0 +1,147 @@
|
||||
// X3DEffectBase.h: interface for the CX3DEffectBase class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_)
|
||||
#define AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "key.h"
|
||||
#include "Texture.h"
|
||||
#include "BaseDataDefine.h"
|
||||
|
||||
#define EFFECT_PARTICLE 0
|
||||
#define EFFECT_BILLBOARD 1
|
||||
#define EFFECT_CYLINDER 2
|
||||
#define EFFECT_PLANE 3
|
||||
#define EFFECT_SPHERE 4
|
||||
#define EFFECT_MESH 5
|
||||
|
||||
class CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwEffectKind; // <20><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
// 0 : <20><>ƼŬ 1 : <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// 2 : <20>Ǹ<EFBFBD><C7B8><EFBFBD> 3 : <20>÷<EFBFBD><C3B7><EFBFBD>
|
||||
// 4 : <20><><EFBFBD>Ǿ<EFBFBD> 5 : <20><EFBFBD>
|
||||
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDevice;
|
||||
CTexture *m_lpTexture;
|
||||
char m_strTextureFile[256];
|
||||
unsigned long m_dwStartFrame, m_dwEndFrame;
|
||||
|
||||
void *m_lpLocalEffect;
|
||||
matrix *m_matLocalView;
|
||||
vector3 *m_vecLocalCenter;
|
||||
quaternion *m_quatLocalAxis;
|
||||
|
||||
quaternion m_quatAxis;
|
||||
quaternion m_TmpQuat;
|
||||
|
||||
bool m_QuatSet;
|
||||
vector3 m_vecCenter;
|
||||
color m_lColor;
|
||||
|
||||
BOOL m_bTexAni;
|
||||
bool m_Mine;
|
||||
|
||||
int m_index;
|
||||
float m_Scale[3];
|
||||
//world map effect <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
bool m_bWorldEffect;
|
||||
int m_StopParticleFrame;
|
||||
|
||||
unsigned long m_dwSrcBlending;
|
||||
unsigned long m_dwDestBlending;
|
||||
bool m_bLight;
|
||||
bool m_bVisibility;
|
||||
|
||||
public:
|
||||
CKeyList<VectorKeyList> m_lstCenter;
|
||||
CKeyList<QuaternionKeyList> m_lstAxis;
|
||||
CKeyList<ColorKeyList> m_lstColor;
|
||||
|
||||
public:
|
||||
bool m_bClearBuffer;
|
||||
void SetGemClearBuffer(bool b);
|
||||
CX3DEffectBase();
|
||||
virtual ~CX3DEffectBase();
|
||||
|
||||
void LoadTexture(const char *strFilename);
|
||||
LPDIRECT3DBASETEXTURE8 GetTexture(void) { return m_lpTexture->GetTexture(); }
|
||||
char *GetTextureFileName(void) { return m_strTextureFile; }
|
||||
|
||||
void SetLocalEffect(void *lpLocalEffect) { m_lpLocalEffect = lpLocalEffect; }
|
||||
void *GetLocalEffect(void) { return m_lpLocalEffect; }
|
||||
|
||||
void SetLocalCenter(vector3 *vecLocalCenter) { m_vecLocalCenter = vecLocalCenter; }
|
||||
vector3 *GetLocalCenter(void) { return m_vecLocalCenter; }
|
||||
void SetLocalAxis(quaternion *quatLocalAxis) { m_quatLocalAxis = quatLocalAxis; }
|
||||
quaternion *GetLocalAxis(void) { return m_quatLocalAxis; }
|
||||
|
||||
void SetLocalView(matrix *matLocalView) { m_matLocalView = matLocalView; }
|
||||
matrix *GetLocalView(void) { return m_matLocalView; }
|
||||
void SetLocalDevice(LPDIRECT3DDEVICE8 lpD3DDevice) { m_lpD3DDevice = lpD3DDevice; }
|
||||
LPDIRECT3DDEVICE8 GetLocalDevice(void) { return m_lpD3DDevice; }
|
||||
// world map effect <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> <20>Լ<EFBFBD>
|
||||
void SetWorldEffect(bool b) {m_bWorldEffect = b;}
|
||||
bool GetWorldEffect() { return m_bWorldEffect;}
|
||||
|
||||
void SetTexAni(BOOL bTexAni) { m_bTexAni = bTexAni; }
|
||||
BOOL GetTexAni(void) { return m_bTexAni; }
|
||||
|
||||
void SetColor(color lColor) { m_lColor = lColor; }
|
||||
color GetColor(void) { return m_lColor; }
|
||||
void SetMine(bool t) { m_Mine = t;}
|
||||
|
||||
void SetAlpha(COLORVALUE cAlpha) { m_lColor.a = cAlpha; }
|
||||
COLORVALUE GetAlpha(void) { return m_lColor.a; }
|
||||
void SetRColor(COLORVALUE cRColor) { m_lColor.r = cRColor; }
|
||||
COLORVALUE GetRColor(void) { return m_lColor.r; }
|
||||
void SetGColor(COLORVALUE cGColor) { m_lColor.g = cGColor; }
|
||||
COLORVALUE GetGColor(void) { return m_lColor.g; }
|
||||
void SetBColor(COLORVALUE cBColor) { m_lColor.b = cBColor; }
|
||||
COLORVALUE GetBColor(void) { return m_lColor.b; }
|
||||
|
||||
void SetSrcBlending(unsigned long dwSrcBlending) { m_dwSrcBlending = dwSrcBlending; }
|
||||
unsigned long GetSrcBlending(void) { return m_dwSrcBlending; }
|
||||
void SetDestBlending(unsigned long dwDestBlending) { m_dwDestBlending = dwDestBlending; }
|
||||
unsigned long GetDestBlending(void) { return m_dwDestBlending; }
|
||||
|
||||
void SetStartFrame(unsigned long dwStartFrame) { m_dwStartFrame = dwStartFrame; }
|
||||
unsigned long GetStartFrame(void) { return m_dwStartFrame; }
|
||||
void SetEndFrame(unsigned long dwEndFrame) { m_dwEndFrame = dwEndFrame; }
|
||||
unsigned long GetEndFrame(void) { return m_dwEndFrame; }
|
||||
|
||||
void SetEffectKind(unsigned long dwEffectKind) { m_dwEffectKind = dwEffectKind; }
|
||||
unsigned long GetEffectKind(void) { return m_dwEffectKind; }
|
||||
//scale set
|
||||
void SetEffectScale(float x,float y,float z) { m_Scale[0] = x;m_Scale[1] = y;m_Scale[2] = z;}
|
||||
|
||||
void SetAxis(float fX, float fY, float fZ, float fW) { m_quatAxis.x = fX; m_quatAxis.y = fY; m_quatAxis.z = fZ; m_quatAxis.w = fW; }
|
||||
void SetAxis(quaternion &quatAxis) {
|
||||
m_QuatSet = true;
|
||||
m_quatAxis = quatAxis;
|
||||
m_TmpQuat = m_quatAxis;
|
||||
}
|
||||
quaternion GetAxis(void) { return m_quatAxis; }
|
||||
void SetStopParticle(int t);
|
||||
int GetStopParticle();
|
||||
void SetCenter(float fX, float fY, float fZ) { m_vecCenter.x = fX; m_vecCenter.y = fY; m_vecCenter.z = fZ; }
|
||||
void SetCenter(vector3 &vecCenter) { m_vecCenter = vecCenter; }
|
||||
vector3 GetCenter(void) { return m_vecCenter; }
|
||||
void SetLight(bool b) { m_bLight = b;}
|
||||
void SetVisibility(bool b) { m_bVisibility = b;}
|
||||
|
||||
virtual void Create(unsigned long dwStartFrame, unsigned long dwEndFrame) = 0;
|
||||
virtual BOOL CreateBuffer(void) = 0;
|
||||
virtual void Render(void) = 0;
|
||||
virtual BOOL Interpolation(float fFrame) = 0;
|
||||
virtual void Load(FILE *fp, const char *strOriginalPath = NULL) = 0;
|
||||
virtual void Save(FILE *fp, const char *strOriginalPath = NULL) = 0;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTBASE_H__C6A7B2C5_B699_4078_9690_00AF0121FFA9__INCLUDED_)
|
||||
321
Engine/Effect/X3DEffectBillboard.cpp
Normal file
321
Engine/Effect/X3DEffectBillboard.cpp
Normal file
@@ -0,0 +1,321 @@
|
||||
// X3DEffectBillboard.cpp: implementation of the CX3DEffectBillboard class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectBillboard.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectBillboard::CX3DEffectBillboard()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectBillboard::~CX3DEffectBillboard()
|
||||
{
|
||||
|
||||
if(m_lpVerticesBlend) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
|
||||
// if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
// if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectBillboard::CreateBuffer(void)
|
||||
{
|
||||
// if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
// if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
if(m_lpVerticesBlend) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
/*
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
}/**/
|
||||
}
|
||||
|
||||
BOOL CX3DEffectBillboard::Interpolation(float fFrame)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
|
||||
if(!m_lstWidth.Interpolation(fFrame, m_fWidth)) return FALSE;
|
||||
if(!m_lstHeight.Interpolation(fFrame, m_fHeight)) return FALSE;
|
||||
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
if(m_bVisibility) {
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
// if(FAILED( m_lpVertices->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0) ) ) return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0) ) ) return FALSE;
|
||||
|
||||
if(m_bAxisAligned)
|
||||
{
|
||||
m_vecAxisT = vector3(0.0f, (m_fHeight / 2), 0.0f);
|
||||
m_vecEyeT = vector3(0.0f, 0.0f, -1.0f);
|
||||
|
||||
z3d::VectorRotate(m_vecAxisT, m_vecAxisT, m_quatAxis);
|
||||
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis()) z3d::VectorRotate(m_vecAxisT, m_vecAxisT, (*((CX3DEffect *)m_lpLocalEffect)->GetAxis()));
|
||||
m_vecEyeT = vector3(m_vecEyeT.x * m_matLocalView->_11 + m_vecEyeT.y * m_matLocalView->_12 + m_vecEyeT.z * m_matLocalView->_13,
|
||||
m_vecEyeT.x * m_matLocalView->_21 + m_vecEyeT.y * m_matLocalView->_22 + m_vecEyeT.z * m_matLocalView->_23,
|
||||
m_vecEyeT.x * m_matLocalView->_31 + m_vecEyeT.y * m_matLocalView->_32 + m_vecEyeT.z * m_matLocalView->_33);
|
||||
m_vecWidthT = m_vecAxisT ^ m_vecEyeT;
|
||||
m_vecWidthT.Normalize();
|
||||
m_vecWidthT *= (m_fWidth / 2);
|
||||
|
||||
pVertices[0].v = m_vecAxisT + m_vecWidthT + m_vecCenter;
|
||||
pVertices[1].v = m_vecAxisT - m_vecWidthT + m_vecCenter;
|
||||
pVertices[2].v = -m_vecAxisT + m_vecWidthT + m_vecCenter;
|
||||
pVertices[3].v = -m_vecAxisT - m_vecWidthT + m_vecCenter;
|
||||
} else
|
||||
{
|
||||
matrix *matView = ((CX3DEffect *)m_lpLocalEffect)->GetViewMatrix();
|
||||
|
||||
float w = m_fWidth / 2;
|
||||
float h = m_fHeight / 2;
|
||||
|
||||
pVertices[0].v = vector3(-w, h, 0.0f);
|
||||
pVertices[1].v = vector3(w, h, 0.0f);
|
||||
pVertices[2].v = vector3(-w, -h, 0.0f);
|
||||
pVertices[3].v = vector3(w, -h, 0.0f);
|
||||
|
||||
vector3 vecCenter;
|
||||
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, m_quatAxis);
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
{
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
|
||||
z3d::VectorRotate(vecCenter, m_vecCenter, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
} else
|
||||
{
|
||||
vecCenter = m_vecCenter;
|
||||
}
|
||||
|
||||
pVertices[0].v = vector3(pVertices[0].v.x * matView->_11 + pVertices[0].v.y * matView->_12, pVertices[0].v.x * matView->_21 + pVertices[0].v.y * matView->_22, pVertices[0].v.x * matView->_31 + pVertices[0].v.y * matView->_32);
|
||||
pVertices[1].v = vector3(pVertices[1].v.x * matView->_11 + pVertices[1].v.y * matView->_12, pVertices[1].v.x * matView->_21 + pVertices[1].v.y * matView->_22, pVertices[1].v.x * matView->_31 + pVertices[1].v.y * matView->_32);
|
||||
pVertices[2].v = vector3(pVertices[2].v.x * matView->_11 + pVertices[2].v.y * matView->_12, pVertices[2].v.x * matView->_21 + pVertices[2].v.y * matView->_22, pVertices[2].v.x * matView->_31 + pVertices[2].v.y * matView->_32);
|
||||
pVertices[3].v = vector3(pVertices[3].v.x * matView->_11 + pVertices[3].v.y * matView->_12, pVertices[3].v.x * matView->_21 + pVertices[3].v.y * matView->_22, pVertices[3].v.x * matView->_31 + pVertices[3].v.y * matView->_32);
|
||||
|
||||
pVertices[0].v += vecCenter;
|
||||
pVertices[1].v += vecCenter;
|
||||
pVertices[2].v += vecCenter;
|
||||
pVertices[3].v += vecCenter;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
pVerticesBlend[0].v = pVertices[0].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[1].v = pVertices[1].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[2].v = pVertices[2].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
pVerticesBlend[3].v = pVertices[3].v += ((*((CX3DEffect *)m_lpLocalEffect)->GetCenter()));
|
||||
} else
|
||||
{
|
||||
pVerticesBlend[0].v = pVertices[0].v;
|
||||
pVerticesBlend[1].v = pVertices[1].v;
|
||||
pVerticesBlend[2].v = pVertices[2].v;
|
||||
pVerticesBlend[3].v = pVertices[3].v;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
fEndU = f1 + 0.25f;
|
||||
fEndV = f2 + 0.25f;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndBU = f1 + 0.25f;
|
||||
fEndBV = f2 + 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU;
|
||||
fEndBV = fEndV = m_fTileV;
|
||||
}
|
||||
pVertices[0].tu = fStartU; pVertices[0].tv = fStartV;
|
||||
pVertices[1].tu = fEndU; pVertices[1].tv = fStartV;
|
||||
pVertices[2].tu = fStartU; pVertices[2].tv = fEndV;
|
||||
pVertices[3].tu = fEndU; pVertices[3].tv = fEndV;
|
||||
pVerticesBlend[0].tu = fStartBU; pVerticesBlend[0].tv = fStartBV;
|
||||
pVerticesBlend[1].tu = fEndBU; pVerticesBlend[1].tv = fStartBV;
|
||||
pVerticesBlend[2].tu = fStartBU; pVerticesBlend[2].tv = fEndBV;
|
||||
pVerticesBlend[3].tu = fEndBU; pVerticesBlend[3].tv = fEndBV;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
pVertices[0].diff = pVertices[1].diff = pVertices[2].diff = pVertices[3].diff = m_lColor;
|
||||
pVerticesBlend[0].diff = pVerticesBlend[1].diff = pVerticesBlend[2].diff = pVerticesBlend[3].diff = m_lColor;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[3].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVertices[0].diff.a = pVertices[1].diff.a = pVertices[2].diff.a = pVertices[3].diff.a;
|
||||
pVerticesBlend[3].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
pVerticesBlend[0].diff.a = pVerticesBlend[1].diff.a = pVerticesBlend[2].diff.a = pVerticesBlend[3].diff.a;
|
||||
}
|
||||
pVertices[0].spec = pVertices[1].spec = pVertices[2].spec = pVertices[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].spec = pVerticesBlend[1].spec = pVerticesBlend[2].spec = pVerticesBlend[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
fread(&m_bAxisAligned, 4, 1, fp);
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstWidth.Load(fp, m_fWidth);
|
||||
m_lstHeight.Load(fp, m_fHeight);
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectBillboard::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
fwrite(&m_bAxisAligned, 4, 1, fp);
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
77
Engine/Effect/X3DEffectBillboard.h
Normal file
77
Engine/Effect/X3DEffectBillboard.h
Normal file
@@ -0,0 +1,77 @@
|
||||
// X3DEffectBillboard.h: interface for the CX3DEffectBillboard class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_)
|
||||
#define AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectBillboard : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
float m_fWidth;
|
||||
float m_fHeight;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
BOOL m_bAxisAligned;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> Interpolation <20><> <20><><EFBFBD><EFBFBD>
|
||||
vector3 m_vecEyeT, m_vecAxisT, m_vecWidthT;
|
||||
|
||||
public:
|
||||
CX3DEffectBillboard();
|
||||
virtual ~CX3DEffectBillboard();
|
||||
|
||||
void SetWidth(float fWidth) { m_fWidth = fWidth; }
|
||||
float GetWidth(void) { return m_fWidth; }
|
||||
void SetHeight(float fHeight) { m_fHeight = fHeight; }
|
||||
float GetHeight(void) { return m_fHeight; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetAxisAligned(BOOL bAxisAligned) { m_bAxisAligned = bAxisAligned; }
|
||||
BOOL GetAxisAligned(void) { return m_bAxisAligned; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTBILLBOARD_H__C83DF58D_552F_430C_8BBD_7274114C7B44__INCLUDED_)
|
||||
316
Engine/Effect/X3DEffectCylinder.cpp
Normal file
316
Engine/Effect/X3DEffectCylinder.cpp
Normal file
@@ -0,0 +1,316 @@
|
||||
// X3DEffectCylinder.cpp: implementation of the CX3DEffectCylinder class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectCylinder.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectCylinder::CX3DEffectCylinder()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectCylinder::~CX3DEffectCylinder()
|
||||
{
|
||||
if(m_lpVerticesBlend) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
/*
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }*/
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectCylinder::CreateBuffer(void)
|
||||
{
|
||||
if(m_lpVerticesBlend) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,true);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(((m_dwSidePlane + 1) * 2) * sizeof(LVertex),LVERTEXFVF,false);
|
||||
|
||||
/*
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
*/
|
||||
m_dwPrimitive = m_dwSidePlane * 2;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
|
||||
if(quatAxis) { z3d::MatrixRotationQuaternion(matWorld, (*quatAxis)); }
|
||||
if(m_QuatSet) {
|
||||
z3d::MatrixRotationQuaternion(matWorld, (m_TmpQuat));
|
||||
}
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
vector3 *vecTemp = ((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
matWorld._41 = vecTemp->x;
|
||||
matWorld._42 = vecTemp->y;
|
||||
matWorld._43 = vecTemp->z;
|
||||
}
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, m_dwPrimitive);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, m_dwPrimitive);
|
||||
}/**/
|
||||
}
|
||||
|
||||
BOOL CX3DEffectCylinder::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
|
||||
if(!m_lstUpperHeight.Interpolation(fFrame, m_fUpperHeight)) return FALSE;
|
||||
if(!m_lstUpperRadius.Interpolation(fFrame, m_fUpperRadius)) return FALSE;
|
||||
if(!m_lstLowerHeight.Interpolation(fFrame, m_fLowerHeight)) return FALSE;
|
||||
if(!m_lstLowerRadius.Interpolation(fFrame, m_fLowerRadius)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fUpperHeight *=m_Scale[0];
|
||||
m_fUpperRadius *=m_Scale[0];
|
||||
m_fLowerHeight *=m_Scale[0];
|
||||
m_fLowerRadius *=m_Scale[0];
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
if(m_bVisibility) {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
// if(FAILED( m_lpVertices->Lock( 0, ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) )
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0) ) )
|
||||
return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, ((m_dwSidePlane + 1) * 2) * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) )
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0) ) )
|
||||
return FALSE;
|
||||
|
||||
unsigned long i, tempi;
|
||||
float degree;
|
||||
float divangle = 360.0f / m_dwSidePlane;
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
|
||||
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
|
||||
fEndU = fEndBU = 0.25f;
|
||||
fEndV = fEndBV = 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU - fStartBU;
|
||||
fEndBV = fEndV = m_fTileV - fStartBV;
|
||||
}
|
||||
|
||||
for(i = 0; i < m_dwSidePlane; i++)
|
||||
{
|
||||
degree = FLOAT_DEG(i * divangle);
|
||||
|
||||
tempi = i * 2 + 1;
|
||||
pVertices[tempi].v = vector3(m_fUpperRadius * cosf(degree), m_fUpperHeight, m_fUpperRadius * sinf(degree));
|
||||
z3d::VectorRotate(pVertices[tempi].v, pVertices[tempi].v, m_quatAxis);
|
||||
pVertices[tempi].v += m_vecCenter;
|
||||
pVerticesBlend[tempi].v = pVertices[tempi].v;
|
||||
|
||||
pVertices[tempi].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVertices[tempi].tv = fStartV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[tempi].tv = fStartBV;
|
||||
|
||||
tempi = i * 2;
|
||||
pVertices[tempi].v = vector3(m_fLowerRadius * cosf(degree), -m_fLowerHeight, m_fLowerRadius * sinf(degree));
|
||||
z3d::VectorRotate(pVertices[tempi].v, pVertices[tempi].v, m_quatAxis);
|
||||
pVertices[tempi].v += m_vecCenter;
|
||||
pVerticesBlend[tempi].v = pVertices[tempi].v;
|
||||
|
||||
pVertices[tempi].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVertices[tempi].tv = fEndV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[tempi].tv = fEndBV;
|
||||
}
|
||||
tempi = m_dwSidePlane * 2 + 1;
|
||||
pVertices[tempi].v = pVertices[1].v;
|
||||
pVertices[tempi].tu = fStartU + fEndU;
|
||||
pVertices[tempi].tv = fStartV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU;
|
||||
pVerticesBlend[tempi].tv = fStartBV;
|
||||
|
||||
tempi = m_dwSidePlane * 2;
|
||||
pVertices[tempi].v = pVertices[0].v;
|
||||
pVertices[tempi].tu = fStartU + fEndU;
|
||||
pVertices[tempi].tv = fEndV;
|
||||
pVerticesBlend[tempi].tu = fStartBU + fEndBU;
|
||||
pVerticesBlend[tempi].tv = fEndBV;
|
||||
|
||||
pVertices[0].diff = m_lColor;
|
||||
pVertices[0].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].diff = pVertices[0].diff;
|
||||
pVerticesBlend[0].spec = pVertices[0].spec;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[0].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVerticesBlend[0].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
}
|
||||
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * 2; i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
fread(&m_dwSidePlane, 4, 1, fp);
|
||||
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstUpperHeight.Load(fp, m_fUpperHeight);
|
||||
m_lstUpperRadius.Load(fp, m_fUpperRadius);
|
||||
m_lstLowerHeight.Load(fp, m_fLowerHeight);
|
||||
m_lstLowerRadius.Load(fp, m_fLowerRadius);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fUpperHeight *=m_Scale[0];
|
||||
m_fUpperRadius *=m_Scale[0];
|
||||
m_fLowerHeight *=m_Scale[0];
|
||||
m_fLowerRadius *=m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
}
|
||||
|
||||
void CX3DEffectCylinder::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
fwrite(&m_dwSidePlane, 4, 1, fp);
|
||||
|
||||
m_lstColor.Save(fp);
|
||||
m_lstUpperHeight.Save(fp);
|
||||
m_lstUpperRadius.Save(fp);
|
||||
m_lstLowerHeight.Save(fp);
|
||||
m_lstLowerRadius.Save(fp);
|
||||
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
82
Engine/Effect/X3DEffectCylinder.h
Normal file
82
Engine/Effect/X3DEffectCylinder.h
Normal file
@@ -0,0 +1,82 @@
|
||||
// X3DEffectCylinder.h: interface for the CX3DEffectCylinder class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_)
|
||||
#define AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectCylinder : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwSidePlane, m_dwPrimitive;
|
||||
float m_fUpperHeight;
|
||||
float m_fLowerHeight;
|
||||
float m_fUpperRadius;
|
||||
float m_fLowerRadius;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstUpperHeight;
|
||||
CKeyList<FloatKeyList> m_lstLowerHeight;
|
||||
CKeyList<FloatKeyList> m_lstUpperRadius;
|
||||
CKeyList<FloatKeyList> m_lstLowerRadius;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectCylinder();
|
||||
virtual ~CX3DEffectCylinder();
|
||||
|
||||
void SetSidePlane(unsigned long dwSidePlane) { m_dwSidePlane = dwSidePlane; }
|
||||
unsigned long GetSidePlane(void) { return m_dwSidePlane; }
|
||||
|
||||
void SetUpperHeight(float fUpperHeight) { m_fUpperHeight = fUpperHeight; }
|
||||
float GetUpperHeight(void) { return m_fUpperHeight; }
|
||||
void SetLowerHeight(float fLowerHeight) { m_fLowerHeight = fLowerHeight; }
|
||||
float GetLowerHeight(void) { return m_fLowerHeight; }
|
||||
|
||||
void SetUpperRadius(float fUpperRadius) { m_fUpperRadius = fUpperRadius; }
|
||||
float GetUpperRadius(void) { return m_fUpperRadius; }
|
||||
void SetLowerRadius(float fLowerRadius) { m_fLowerRadius = fLowerRadius; }
|
||||
float GetLowerRadius(void) { return m_fLowerRadius; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTCYLINDER_H__21EB02CB_6CA5_4DA9_9AD2_EBED7AFE8320__INCLUDED_)
|
||||
979
Engine/Effect/X3DEffectManager.cpp
Normal file
979
Engine/Effect/X3DEffectManager.cpp
Normal file
@@ -0,0 +1,979 @@
|
||||
// X3DEffectManager.cpp: implementation of the CX3DEffectManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffectManager.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "SceneNode.h"
|
||||
#include "SceneManager.h"
|
||||
//#include <crtdbg.h>
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectManager::CX3DEffectManager()
|
||||
{
|
||||
m_lstExist.clear();
|
||||
m_lstFree.clear();
|
||||
m_lstEffect.clear();
|
||||
m_lstEffect.reserve(40);
|
||||
m_lstScript.clear();
|
||||
m_lstScript.reserve(40);
|
||||
m_lstWScript.clear();
|
||||
m_lstIScript.clear();
|
||||
m_lstLightning.clear();
|
||||
|
||||
m_EffScriptLimitNum = DEFAULTLIMITSCRIPT;
|
||||
m_EffScriptLimitCount = 0;
|
||||
|
||||
m_pFrustum = new CViewFrustum;
|
||||
|
||||
}
|
||||
|
||||
CX3DEffectManager::~CX3DEffectManager()
|
||||
{
|
||||
DeleteAllEffect();
|
||||
DeleteAllEffectScript();
|
||||
DeleteAllWorldScript();
|
||||
DeleteAllInterfaceScript();
|
||||
DeleteAllLightning();
|
||||
|
||||
delete m_pFrustum;
|
||||
m_pFrustum = NULL;
|
||||
|
||||
// CX3DEffectMesh::DeleteAllCash(); // Mesh Cash List Delete
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectManager::UpdateFrame(void)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
long count = m_lstExist.size() - 1, j;
|
||||
CX3DEffect *pEffect;
|
||||
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW, (D3DMATRIX *)&m_matView);
|
||||
|
||||
m_dwTick = timeGetTime();
|
||||
|
||||
for(it = m_lstExist.begin(), j = 0; j <= count; it++, j++)
|
||||
{
|
||||
pEffect = m_lstEffect[(*it)];
|
||||
// <20><><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> update
|
||||
if(pEffect->GetEffectStart()) {
|
||||
if(m_dwTick - pEffect->GetTick() >= pEffect->GetFrameTick())
|
||||
{
|
||||
if(!pEffect->Interpolation(m_dwTick - pEffect->GetTick()))
|
||||
{
|
||||
m_lstFree.push_back((*it));
|
||||
delete pEffect;
|
||||
pEffect = NULL;
|
||||
m_lstExist.erase(it);
|
||||
it--;
|
||||
} else
|
||||
{
|
||||
pEffect->SetTick(m_dwTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectManager::Render(int num)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
int i=0;
|
||||
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, NULL);
|
||||
m_lpD3DDevice->SetTexture(1, NULL);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_ALWAYS);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAREF,0x00000000);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++,i++)
|
||||
{
|
||||
if(i== num) {
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
|
||||
|
||||
}
|
||||
//if(effectmap->EffectSectorIn(
|
||||
//camera pos
|
||||
matrix *matViewPosition=CSceneManager::GetCamera()->GetMatPosition();
|
||||
vector3 vecViewPos=matViewPosition->GetLoc();
|
||||
|
||||
int indexx=(int)(vecViewPos.x/SECTORSIZE);
|
||||
int indexy=(int)(vecViewPos.z/SECTORSIZE);
|
||||
|
||||
//culling
|
||||
CSceneNode CheckNode;
|
||||
|
||||
CheckNode.m_fRad=100.0f;
|
||||
CheckNode.m_AccumulateTM.Translation(*m_lstEffect[(*it)]->GetCenter());
|
||||
if(m_lstEffect[(*it)]->map_effect == true) {
|
||||
if(CheckNode.isCulling())
|
||||
{
|
||||
//if(effectmap->EffectSectorIn(indexx,indexy,i)) {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
}
|
||||
if(i == num)
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID);
|
||||
|
||||
}
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
}
|
||||
|
||||
void CX3DEffectManager::Render()
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
int i=0;
|
||||
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
|
||||
m_lpD3DDevice->SetTexture(0, NULL);
|
||||
m_lpD3DDevice->SetTexture(1, NULL);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);
|
||||
m_lpD3DDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
||||
m_lpD3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_ALWAYS);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHAREF,0x00000000);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++,i++)
|
||||
{
|
||||
if(!(m_lstEffect[(*it)]->GetEffectStart()))
|
||||
continue;
|
||||
//if(effectmap->EffectSectorIn(
|
||||
//camera pos
|
||||
matrix *matViewPosition=CSceneManager::GetCamera()->GetMatPosition();
|
||||
vector3 vecViewPos=matViewPosition->GetLoc();
|
||||
|
||||
int indexx=(int)(vecViewPos.x/SECTORSIZE);
|
||||
int indexy=(int)(vecViewPos.z/SECTORSIZE);
|
||||
|
||||
//culling
|
||||
CSceneNode CheckNode;
|
||||
|
||||
CheckNode.m_fRad=100.0f;
|
||||
CheckNode.m_AccumulateTM.Translation(*m_lstEffect[(*it)]->GetCenter());
|
||||
if(m_lstEffect[(*it)]->map_effect == true) {
|
||||
if(CheckNode.isCulling())
|
||||
{
|
||||
//if(effectmap->EffectSectorIn(indexx,indexy,i)) {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(m_lstEffect[(*it)]) m_lstEffect[(*it)]->Render();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
|
||||
}
|
||||
|
||||
XEFFECT CX3DEffectManager::AddEffect(CX3DEffect *lpNewEffect)
|
||||
{
|
||||
XEFFECT hEffect;
|
||||
if(m_lstFree.empty())
|
||||
{
|
||||
hEffect = m_lstEffect.size();
|
||||
m_lstEffect.push_back(lpNewEffect);
|
||||
} else
|
||||
{
|
||||
hEffect = m_lstFree.back();
|
||||
m_lstEffect[hEffect] = lpNewEffect;
|
||||
m_lstFree.pop_back();
|
||||
}
|
||||
|
||||
lpNewEffect->SetDevice(m_lpD3DDevice);
|
||||
lpNewEffect->SetViewMatrix(&m_matView);
|
||||
lpNewEffect->SetEffectSetting();
|
||||
lpNewEffect->SetTick(timeGetTime());
|
||||
m_lstExist.push_back(hEffect);
|
||||
return hEffect;
|
||||
}
|
||||
char *CX3DEffectManager::GetEsfName(int index) {
|
||||
if(m_lstScript[index] != NULL) {
|
||||
return m_lstScript[index]->m_FileName;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
void CX3DEffectManager::AddLightning(CLightning *new_light) {
|
||||
m_lstLightning.push_back(new_light);
|
||||
}
|
||||
CEffScript *CX3DEffectManager::AddEffScript(CEffScript *new_script) {
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
if(!new_script->GetMine()) { // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20>ƴϸ<C6B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if(new_script->GetBSkill() && (!new_script->GetChant())) { // skill effect <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if(m_EffScriptLimitCount > m_EffScriptLimitNum) {
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
m_EffScriptLimitCount++;
|
||||
}
|
||||
}
|
||||
m_lstScript.push_back(new_script);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
///////// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̽<EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20><EFBFBD>Ʈ///
|
||||
/*
|
||||
// interface effect
|
||||
vector3 pos;
|
||||
matrix *matpos = NULL;
|
||||
vector3 camera_fwd;
|
||||
matpos = CSceneManager::GetCamera()->GetMatPosition();
|
||||
|
||||
camera_fwd = CSceneManager::GetCamera()->GetViewTowardVector();
|
||||
|
||||
pos.x = matpos->_41;
|
||||
pos.y = matpos->_42;
|
||||
pos.z = matpos->_43;
|
||||
|
||||
pos.x += (camera_fwd.x * 300.0f);
|
||||
pos.y += (camera_fwd.y * 300.0f);
|
||||
pos.z += (camera_fwd.z * 300.0f);
|
||||
|
||||
new_script->SetStartPos(pos.x,pos.y,pos.z);
|
||||
|
||||
// interface effect
|
||||
//screen projection
|
||||
D3DXMATRIX t_project;
|
||||
D3DXMATRIX t_view;
|
||||
D3DXMATRIX t_world;
|
||||
D3DXVECTOR3 t_pos;
|
||||
|
||||
D3DVIEWPORT8 t_viewport;
|
||||
|
||||
t_pos.x = pos.x;
|
||||
t_pos.y = pos.y;
|
||||
t_pos.z = pos.z;
|
||||
|
||||
m_lpD3DDevice->GetViewport(&t_viewport);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW,&t_view);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_PROJECTION,&t_project);
|
||||
|
||||
D3DXVec3Project(&(new_script->m_Projection),
|
||||
&t_pos,
|
||||
&t_viewport,
|
||||
&t_project,
|
||||
&t_view,
|
||||
&t_world);
|
||||
|
||||
new_script->SetScriptValue(ESINTERFACE);
|
||||
*/
|
||||
//////////
|
||||
new_script->SetDevice(m_lpD3DDevice);
|
||||
//return (m_lstScript.size() - 1);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
return new_script;
|
||||
|
||||
}
|
||||
int CX3DEffectManager::AddWorldEffScript(CEffScript *new_script) {
|
||||
m_lstWScript.push_back(new_script);
|
||||
new_script->SetDevice(m_lpD3DDevice);
|
||||
new_script->SetWorldEffect(true);
|
||||
return (m_lstWScript.size() - 1);
|
||||
|
||||
}
|
||||
CEffScript *CX3DEffectManager::AddInterfaceScript(CEffScript *new_script) {
|
||||
// Ư<><C6AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD><C7BE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
|
||||
/* if(!(new_script->m_bInterfaceSet)) {
|
||||
vector3 pos;
|
||||
matrix *matpos = NULL;
|
||||
vector3 camera_fwd;
|
||||
vector3 camera_up;
|
||||
vector3 camera_right;
|
||||
|
||||
matpos = CSceneManager::GetCamera()->GetMatPosition();
|
||||
|
||||
camera_fwd = CSceneManager::GetCamera()->GetViewTowardVector();
|
||||
camera_up = CSceneManager::GetCamera()->GetViewUpVector();
|
||||
|
||||
camera_right = camera_fwd^camera_up;
|
||||
|
||||
//camera_fwd = CSceneManager::GetCamera()->GetFwdVector();
|
||||
|
||||
pos.x = matpos->_41;
|
||||
pos.y = matpos->_42;
|
||||
pos.z = matpos->_43;
|
||||
|
||||
pos.x += (camera_fwd.x * 100.0f);
|
||||
pos.y += (camera_fwd.y * 100.0f);
|
||||
pos.z += (camera_fwd.z * 100.0f);
|
||||
|
||||
if(new_script->m_bInterfacePos) {
|
||||
pos += (camera_up * (new_script->m_InterfacePos[1]));
|
||||
pos += ((-camera_right) * (new_script->m_InterfacePos[0]));
|
||||
}
|
||||
//pos *= 100.0f;
|
||||
|
||||
new_script->SetStartPos(pos.x,pos.y,pos.z);
|
||||
|
||||
// interface effect
|
||||
//screen projection
|
||||
D3DXMATRIX t_project;
|
||||
D3DXMATRIX t_view;
|
||||
D3DXMATRIX t_world;
|
||||
D3DXVECTOR3 t_pos;
|
||||
|
||||
D3DVIEWPORT8 t_viewport;
|
||||
|
||||
t_pos.x = pos.x;
|
||||
t_pos.y = pos.y;
|
||||
t_pos.z = pos.z;
|
||||
|
||||
|
||||
m_lpD3DDevice->GetViewport(&t_viewport);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW,&t_view);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_PROJECTION,&t_project);
|
||||
|
||||
D3DXVec3Project(&(new_script->m_Projection),
|
||||
&t_pos,
|
||||
&t_viewport,
|
||||
&t_project,
|
||||
&t_view,
|
||||
&t_world);
|
||||
|
||||
|
||||
new_script->SetScriptValue(ESINTERFACE);
|
||||
for(int i=0;i<new_script->m_SubScriptNum;i++) {
|
||||
new_script->m_SubScript[i].m_Projection = new_script->m_Projection;
|
||||
}
|
||||
}
|
||||
*/
|
||||
new_script->SetInterfaceSet(true);
|
||||
if(new_script->m_SubScriptNum >0) {
|
||||
new_script->m_bInterfacePos = true; // sub interface effect <20><> <20>̿<EFBFBD><CCBF>ϱ<EFBFBD> <20><><EFBFBD><EFBFBD> setting
|
||||
}
|
||||
m_lstIScript.push_back(new_script);
|
||||
|
||||
new_script->SetDevice(m_lpD3DDevice);
|
||||
return new_script;
|
||||
|
||||
}
|
||||
|
||||
int CX3DEffectManager::ProcessScript(int i) {// return value 0: <20><>ũ<EFBFBD><C5A9>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
// 1: <20><>ũ<EFBFBD><C5A9>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
// 2: effect target<65><74> <20>浹
|
||||
|
||||
|
||||
int index = 0;
|
||||
|
||||
if(((int)m_lstScript.size() - 1)< i) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(m_lstScript[i] == NULL) {
|
||||
DeleteEndScript(i);
|
||||
return 0;
|
||||
}
|
||||
index = m_lstScript[i]->ProcessEffect(CSceneManager::m_SkillWeatherEffect);
|
||||
if(!index)
|
||||
DeleteEndScript(i);
|
||||
else if(index == 2) {
|
||||
m_lstScript[i]->SetCrash(true);
|
||||
}
|
||||
else
|
||||
m_lstScript[i]->SetCrash(false);
|
||||
return index;
|
||||
}
|
||||
// <20>ι<EFBFBD>° Ÿ<><C5B8><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>Ʈ <20>˻<EFBFBD> :: NULL <20≯<EFBFBD> ó<><C3B3> <20><><EFBFBD>̶<EFBFBD><CCB6><EFBFBD> <20>ǹ̷<C7B9> true return
|
||||
bool CX3DEffectManager::CheckNullScript(CEffScript *t) {
|
||||
int script_num = m_lstScript.size();
|
||||
int i;
|
||||
for(i=0;i<script_num;i++) {
|
||||
if(m_lstScript[i] == t)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool CX3DEffectManager::CheckNullInterfaceScript(CEffScript *t) {
|
||||
int script_num = m_lstIScript.size();
|
||||
int i;
|
||||
for(i=0;i<script_num;i++) {
|
||||
if(m_lstIScript[i] == t)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CX3DEffectManager::CheckScript(int index,CEffScript *t) {
|
||||
if(((int)m_lstScript.size() -1) < index)
|
||||
return false;
|
||||
if(m_lstScript[index] == t)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool CX3DEffectManager::ProcessWScript(int i,bool bCull) {
|
||||
int index = 0;
|
||||
|
||||
if(((int)m_lstWScript.size() - 1)< i)
|
||||
return false;
|
||||
|
||||
if(m_lstWScript[i] == NULL) {
|
||||
DeleteWScript(i);
|
||||
return false;
|
||||
}
|
||||
/*if(bCull == false) { // Culling <20><><EFBFBD><EFBFBD>
|
||||
if(m_lstWScript[i]->GetSectorCull())
|
||||
return false;
|
||||
}*/
|
||||
index = m_lstWScript[i]->ProcessEffect();
|
||||
|
||||
if(!index)
|
||||
DeleteWScript(i);
|
||||
else if(index == 2) {
|
||||
m_lstWScript[i]->SetCrash(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
m_lstWScript[i]->SetCrash(false);
|
||||
return false;
|
||||
}
|
||||
bool CX3DEffectManager::ProcessLightning(int index) {
|
||||
|
||||
if(((int)m_lstLightning.size() - 1)< index)
|
||||
return false;
|
||||
|
||||
if(m_lstWScript[index] == NULL) {
|
||||
DeleteWScript(index);
|
||||
return false;
|
||||
}
|
||||
D3DXVECTOR3 dermy;
|
||||
|
||||
m_lstLightning[index]->UpdateLightning(dermy,false);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
bool CX3DEffectManager::ProcessInterfaceScript(int i) {
|
||||
int index = 0;
|
||||
|
||||
if(((int)m_lstIScript.size() - 1)< i)
|
||||
return false;
|
||||
|
||||
if(m_lstIScript[i] == NULL) {
|
||||
DeleteInterfaceScript(i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
index = m_lstIScript[i]->ProcessEffect(CSceneManager::m_SkillWeatherEffect);
|
||||
if(!index)
|
||||
DeleteInterfaceScript(i);
|
||||
else if(index == 2) {
|
||||
m_lstIScript[i]->SetCrash(true);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
m_lstIScript[i]->SetCrash(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CX3DEffectManager::CheckInterfaceScript(int index,CEffScript *t) {
|
||||
if(m_lstIScript[index] == t)
|
||||
return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
int CX3DEffectManager::GetLightningNum() {
|
||||
int size = m_lstLightning.size();
|
||||
return size;
|
||||
}
|
||||
|
||||
int CX3DEffectManager::GetScriptNum() {
|
||||
int size = m_lstScript.size();
|
||||
return size;
|
||||
}
|
||||
int CX3DEffectManager::GetWScriptNum() {
|
||||
int size = m_lstWScript.size();
|
||||
return size;
|
||||
|
||||
}
|
||||
int CX3DEffectManager::GetInterfaceScriptNum() {
|
||||
int size = m_lstIScript.size();
|
||||
return size;
|
||||
}
|
||||
void CX3DEffectManager::RenderScript() {
|
||||
|
||||
/* if(m_pFrustum != NULL)
|
||||
m_pFrustum->Update();
|
||||
*/
|
||||
|
||||
int size = m_lstScript.size();
|
||||
int i;
|
||||
|
||||
for(i=0;i<size;i++) {
|
||||
if(m_lstScript[i] != NULL) {
|
||||
|
||||
// Frustum Culling
|
||||
/*
|
||||
int iCount = 0;
|
||||
int iFalse = 0;
|
||||
|
||||
if(m_pFrustum != NULL) {
|
||||
if(m_lstScript[i]->m_StartPosSet)
|
||||
{
|
||||
iCount++;
|
||||
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstScript[i]->m_StartPos.x,
|
||||
m_lstScript[i]->m_StartPos.y,
|
||||
m_lstScript[i]->m_StartPos.z,
|
||||
1600.0f))
|
||||
iFalse++;
|
||||
}
|
||||
if(m_lstScript[i]->m_EndPosNum > 0)
|
||||
{
|
||||
iCount++;
|
||||
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstScript[i]->m_EndPos[0].x,
|
||||
m_lstScript[i]->m_EndPos[0].y,
|
||||
m_lstScript[i]->m_EndPos[0].z,
|
||||
1600.0f))
|
||||
iFalse++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(iFalse != iCount)*/
|
||||
m_lstScript[i]->Render();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::RenderLightning() {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstLightning.size();i++) {
|
||||
if(m_lstLightning[i] != NULL)
|
||||
m_lstLightning[i]->Render(0);
|
||||
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::RenderWorldScript(bool bCull) {
|
||||
|
||||
if(m_pFrustum != NULL)
|
||||
m_pFrustum->Update();
|
||||
|
||||
int size = m_lstWScript.size();
|
||||
int i;
|
||||
for(i=0;i<size;i++) {
|
||||
if(m_lstWScript[i] != NULL) {
|
||||
|
||||
if((bCull == false) && (m_lstWScript[i]->m_bFrustumCull) ) { // Culling <20><><EFBFBD><EFBFBD>
|
||||
if(m_lstWScript[i]->GetSectorCull())
|
||||
continue;
|
||||
}
|
||||
|
||||
if(m_lstWScript[i]->m_bPlayTime) { // Play Time Setting <20>Ǿ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if(m_lstWScript[i]->m_bVisTime) {
|
||||
// Frustum Culling
|
||||
if(m_pFrustum != NULL) {
|
||||
if(m_lstWScript[i]->m_StartPosSet)
|
||||
{
|
||||
if(m_lstWScript[i]->m_bFrustumCull) {
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstWScript[i]->m_StartPos.x,
|
||||
m_lstWScript[i]->m_StartPos.y,
|
||||
m_lstWScript[i]->m_StartPos.z,
|
||||
600.0f))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_lstWScript[i]->Render();
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Frustum Culling
|
||||
if(m_pFrustum != NULL) {
|
||||
if(m_lstWScript[i]->m_StartPosSet)
|
||||
{
|
||||
|
||||
if(m_lstWScript[i]->m_bFrustumCull) {
|
||||
if(!m_pFrustum->SphereInFrustum(m_lstWScript[i]->m_StartPos.x,
|
||||
m_lstWScript[i]->m_StartPos.y,
|
||||
m_lstWScript[i]->m_StartPos.z,
|
||||
600.0f))
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lstWScript[i]->Render();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::RenderInterfaceScript() {
|
||||
int i;
|
||||
int size = m_lstIScript.size();
|
||||
|
||||
for(i=0;i<size;i++) {
|
||||
|
||||
if(m_lstIScript[i] != NULL) {
|
||||
// unprojection
|
||||
|
||||
D3DXMATRIX t_project;
|
||||
D3DXMATRIX t_view;
|
||||
D3DXMATRIX t_world;
|
||||
|
||||
D3DXMATRIX t_ortho;
|
||||
D3DXMATRIX t_oworld;
|
||||
D3DXMATRIX t_oview;
|
||||
|
||||
D3DXMatrixIdentity(&t_oworld);
|
||||
D3DXMatrixIdentity(&t_oview);
|
||||
|
||||
D3DXVECTOR3 t_pos;
|
||||
|
||||
D3DVIEWPORT8 t_viewport;
|
||||
|
||||
m_lpD3DDevice->GetViewport(&t_viewport);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_VIEW,&t_view);
|
||||
m_lpD3DDevice->GetTransform(D3DTS_PROJECTION,&t_project);
|
||||
|
||||
D3DXMatrixOrthoLH(&t_ortho,100,100,0.1f, 10000.0f);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&t_ortho);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD,&t_oworld);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_VIEW,&t_oview);
|
||||
|
||||
D3DXVECTOR3 t_proj(0.0f,0.0f,0.2f);
|
||||
if(m_lstIScript[i]->m_bInterfacePos) {
|
||||
if(m_lstIScript[i]->m_SubScriptNum >0) { //subscript use
|
||||
for(int j=0;j<(m_lstIScript[i]->m_SubScriptNum);j++) {
|
||||
D3DXMatrixOrthoLH(&t_ortho,100,100,0.1f, 10000.0f);
|
||||
|
||||
m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&t_ortho);
|
||||
|
||||
D3DXMatrixIdentity(&t_oworld);
|
||||
D3DXMatrixIdentity(&t_oview);
|
||||
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD,&t_oworld);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_VIEW,&t_oview);
|
||||
|
||||
t_proj.x = m_lstIScript[i]->m_SubScript[j].m_InterfacePos[0];
|
||||
t_proj.y = m_lstIScript[i]->m_SubScript[j].m_InterfacePos[1];
|
||||
|
||||
D3DXVec3Unproject(
|
||||
&t_pos,
|
||||
&t_proj,
|
||||
&t_viewport,
|
||||
&t_ortho,
|
||||
&t_oview,
|
||||
&t_oworld);
|
||||
|
||||
m_lstIScript[i]->SetStartPos(t_pos.x,t_pos.y,t_pos.z);
|
||||
}
|
||||
}
|
||||
else { // sub script not use
|
||||
t_proj.x = m_lstIScript[i]->m_InterfacePos[0];
|
||||
t_proj.y = m_lstIScript[i]->m_InterfacePos[1];
|
||||
D3DXVec3Unproject(
|
||||
&t_pos,
|
||||
&t_proj,
|
||||
&t_viewport,
|
||||
&t_ortho,
|
||||
&t_oview,
|
||||
&t_oworld);
|
||||
|
||||
m_lstIScript[i]->SetStartPos(t_pos.x,t_pos.y,t_pos.z);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
m_lstIScript[i]->Render();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_PROJECTION,&t_project);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD,&t_world);
|
||||
m_lpD3DDevice->SetTransform(D3DTS_VIEW,&t_view);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::DeleteEndScript(int index) {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstScript.size();i++) {
|
||||
if(i== index) {
|
||||
if(m_lstScript[i] != NULL) {
|
||||
|
||||
if(!m_lstScript[i]->GetMine()) { // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20>ƴϸ<C6B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if(m_lstScript[i]->GetBSkill()) { // skill effect <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if(m_EffScriptLimitCount)
|
||||
m_EffScriptLimitCount--;
|
||||
}
|
||||
}
|
||||
delete m_lstScript[i];
|
||||
m_lstScript[i] = NULL;
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
|
||||
m_lstScript.erase(m_lstScript.begin() + i);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
void CX3DEffectManager::DeleteLightning(int index) {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstLightning.size();i++) {
|
||||
if(i == index) {
|
||||
if(m_lstLightning[i] != NULL) {
|
||||
delete m_lstLightning[i];
|
||||
m_lstLightning[i] = NULL;
|
||||
|
||||
}
|
||||
m_lstLightning.erase(m_lstLightning.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CX3DEffectManager::DeleteEndScript(CEffScript *del) {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstScript.size();i++) {
|
||||
if(m_lstScript[i] == del) {
|
||||
if(!m_lstScript[i]->GetMine()) { // <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ų<EFBFBD><C5B3> <20>ƴϸ<C6B4> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if(m_lstScript[i]->GetBSkill()) { // skill effect <20≯<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if(m_EffScriptLimitCount)
|
||||
m_EffScriptLimitCount--;
|
||||
}
|
||||
}
|
||||
|
||||
delete m_lstScript[i];
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
m_lstScript[i] = NULL;
|
||||
|
||||
m_lstScript.erase(m_lstScript.begin() + i);
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
break;
|
||||
}
|
||||
}
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
void CX3DEffectManager::DeleteWScript(int index) {
|
||||
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstWScript.size();i++) {
|
||||
if(i== index) {
|
||||
if(m_lstWScript[i] != NULL) {
|
||||
delete m_lstWScript[i];
|
||||
m_lstWScript[i] = NULL;
|
||||
}
|
||||
m_lstWScript.erase(m_lstWScript.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteInterfaceScript(int index) {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstIScript.size();i++) {
|
||||
if(i== index) {
|
||||
if(m_lstIScript[i] != NULL) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
}
|
||||
m_lstIScript.erase(m_lstIScript.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CX3DEffectManager::DeleteInterfaceScript(CEffScript *del) {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstIScript.size();i++) {
|
||||
if(m_lstIScript[i] == del) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
m_lstIScript.erase(m_lstIScript.begin() + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteEffect(XEFFECT hEffect)
|
||||
{
|
||||
m_lstFree.push_back(hEffect);
|
||||
delete (CX3DEffect *)m_lstEffect[hEffect];
|
||||
|
||||
EffectHandleList::iterator it;
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++)
|
||||
{
|
||||
if(hEffect == (*it)) {
|
||||
m_lstExist.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CX3DEffectManager::IsLive(XEFFECT hEffect)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
|
||||
for(it = m_lstFree.begin(); it != m_lstFree.end(); it++)
|
||||
{
|
||||
if(hEffect == (*it)) return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteAllEffect(void)
|
||||
{
|
||||
EffectHandleList::iterator it;
|
||||
|
||||
if(m_lstExist.size())
|
||||
{
|
||||
for(it = m_lstExist.begin(); it != m_lstExist.end(); it++)
|
||||
{
|
||||
delete (CX3DEffect *)m_lstEffect[(*it)];
|
||||
}
|
||||
|
||||
m_lstExist.clear();
|
||||
}
|
||||
m_lstFree.clear();
|
||||
m_lstEffect.clear();
|
||||
//m_lstScript.clear();
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteAllEffectScript() {
|
||||
|
||||
int i;
|
||||
|
||||
// Pool <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20><><EFBFBD><EFBFBD>.. by Vincent
|
||||
//if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<(int)m_lstScript.size();i++) {
|
||||
if(m_lstScript[i] != NULL) {
|
||||
delete m_lstScript[i];
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
m_lstScript[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
//}
|
||||
m_lstScript.clear();
|
||||
// _ASSERTE( _CrtCheckMemory());
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteAllLightning() {
|
||||
int i;
|
||||
for(i=0;i<(int)m_lstLightning.size();i++) {
|
||||
if(m_lstLightning[i] != NULL) {
|
||||
delete m_lstLightning[i];
|
||||
m_lstLightning[i] = NULL;
|
||||
}
|
||||
}
|
||||
m_lstLightning.clear();
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteAllWorldScript() {
|
||||
|
||||
int i;
|
||||
// Pool <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20><><EFBFBD><EFBFBD>.. by Vincent
|
||||
//if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<(int)m_lstWScript.size();i++) {
|
||||
if(m_lstWScript[i] != NULL) {
|
||||
delete m_lstWScript[i];
|
||||
m_lstWScript[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
//}
|
||||
m_lstWScript.clear();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectManager::DeleteAllInterfaceScript() {
|
||||
int i;
|
||||
// Pool <20><><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <20><EFBFBD><DEB8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ȵǰ<C8B5> <20><><EFBFBD><EFBFBD>.. by Vincent
|
||||
//if(CEffScript::ms_myPool.m_nTotalInUse) {
|
||||
for(i=0;i<(int)m_lstIScript.size();i++) {
|
||||
if(m_lstIScript[i] != NULL) {
|
||||
delete m_lstIScript[i];
|
||||
m_lstIScript[i] = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
//}
|
||||
m_lstIScript.clear();
|
||||
}
|
||||
130
Engine/Effect/X3DEffectManager.h
Normal file
130
Engine/Effect/X3DEffectManager.h
Normal file
@@ -0,0 +1,130 @@
|
||||
// X3DEffectManager.h: interface for the CX3DEffectManager class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_)
|
||||
#define AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#pragma warning(disable:4786) // don't warn about browse name overflow.
|
||||
|
||||
#include <d3d8.h>
|
||||
#include <d3dx8.h>
|
||||
#include <vector>
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "SectorEffectMap.h"
|
||||
#include "CEffscript.h"
|
||||
#include "ViewFrustum.h"
|
||||
|
||||
#define DEFAULTLIMITSCRIPT 5
|
||||
|
||||
using namespace std;
|
||||
|
||||
typedef unsigned long XEFFECT;
|
||||
typedef vector<CX3DEffect *> EffectList;
|
||||
typedef vector<XEFFECT> EffectHandleList;
|
||||
typedef vector<CEffScript *> EffectScriptList;
|
||||
typedef vector<CLightning *> LightningList;
|
||||
|
||||
class CX3DEffectManager
|
||||
{
|
||||
protected:
|
||||
LPDIRECT3DDEVICE8 m_lpD3DDevice;
|
||||
matrix m_matView;
|
||||
matrix m_matWorld;
|
||||
|
||||
EffectHandleList m_lstExist;
|
||||
EffectHandleList m_lstFree;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> script list
|
||||
EffectScriptList m_lstWScript;
|
||||
// Interface script list
|
||||
EffectScriptList m_lstIScript;
|
||||
|
||||
//Lightning list
|
||||
LightningList m_lstLightning;
|
||||
|
||||
unsigned long m_dwTick;
|
||||
unsigned long m_dwOldTick;
|
||||
int m_EffScriptLimitNum;
|
||||
int m_EffScriptLimitCount;
|
||||
|
||||
CViewFrustum *m_pFrustum;
|
||||
|
||||
|
||||
public:
|
||||
EffectList m_lstEffect;
|
||||
// skill script list
|
||||
EffectScriptList m_lstScript;
|
||||
|
||||
XEFFECT AddEffect(CX3DEffect *lpNewEffect);
|
||||
|
||||
CEffScript *AddEffScript(CEffScript *);
|
||||
int AddWorldEffScript(CEffScript *);
|
||||
CEffScript *AddInterfaceScript(CEffScript *);
|
||||
void AddLightning(CLightning *);
|
||||
|
||||
// play script :return index num
|
||||
int ProcessScript(int index);
|
||||
bool ProcessWScript(int index,bool bCull = true);
|
||||
bool ProcessInterfaceScript(int index);
|
||||
bool ProcessLightning(int index);
|
||||
|
||||
bool CheckScript(int index,CEffScript *);
|
||||
bool CheckNullScript(CEffScript *t);
|
||||
bool CheckNullInterfaceScript(CEffScript *t);
|
||||
bool CheckInterfaceScript(int index,CEffScript *t);
|
||||
|
||||
int GetScriptNum();
|
||||
int GetWScriptNum();
|
||||
int GetLightningNum();
|
||||
|
||||
char *GetEsfName(int index);
|
||||
|
||||
int GetInterfaceScriptNum();
|
||||
void SetEffScriptLimitNum(int n) {m_EffScriptLimitNum = n;}
|
||||
int GetEffScriptLimitNum() {return m_EffScriptLimitNum;}
|
||||
|
||||
|
||||
void RenderScript();
|
||||
void RenderWorldScript(bool bCull = true);
|
||||
void RenderLightning();
|
||||
|
||||
void RenderInterfaceScript();
|
||||
|
||||
void DeleteEndScript(int i);
|
||||
void DeleteEndScript(CEffScript *del);
|
||||
void DeleteWScript(int i);
|
||||
void DeleteLightning(int i);
|
||||
|
||||
void DeleteInterfaceScript(int i);
|
||||
void DeleteInterfaceScript(CEffScript *del);
|
||||
|
||||
void DeleteEffect(XEFFECT hEffect);
|
||||
BOOL IsLive(XEFFECT hEffect);
|
||||
|
||||
void Render();
|
||||
void Render(int num);
|
||||
void UpdateFrame(void);
|
||||
CX3DEffectManager();
|
||||
~CX3DEffectManager();
|
||||
|
||||
void DeleteAllEffect(void);
|
||||
void DeleteAllEffectScript();
|
||||
void DeleteAllInterfaceScript();
|
||||
void DeleteAllLightning();
|
||||
|
||||
// <20><><EFBFBD><EFBFBD> <20><>ũ<EFBFBD><C5A9>Ʈ
|
||||
void DeleteAllWorldScript();
|
||||
void SetDevice(LPDIRECT3DDEVICE8 pD3DDevice) { m_lpD3DDevice = pD3DDevice; }
|
||||
LPDIRECT3DDEVICE8 GetDevice(void) { return m_lpD3DDevice; }
|
||||
|
||||
matrix *GetViewMatrix(void) { return &m_matView; }
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTMANAGER_H__4DAA8921_D30C_4F05_B138_89DFFC19B449__INCLUDED_)
|
||||
462
Engine/Effect/X3DEffectMesh.cpp
Normal file
462
Engine/Effect/X3DEffectMesh.cpp
Normal file
@@ -0,0 +1,462 @@
|
||||
// X3DEffectMesh.cpp: implementation of the CX3DEffectMesh class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectMesh.h"
|
||||
#include "EffDebugLog.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
|
||||
//#define __EFF_WCREATOR__
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CashNode CX3DEffectMesh::m_lstCash; // Mesh cash list
|
||||
//int CX3DEffectMesh::m_nCash = 0; // Mesh cash Num
|
||||
//void CX3DEffectMesh::DeleteAllCash(); // Cash <20><><EFBFBD><EFBFBD> delete
|
||||
|
||||
CX3DEffectMesh::CX3DEffectMesh()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
m_moMesh = NULL;
|
||||
m_GemRender = NULL;
|
||||
m_fRenderFrame = 0.0f;
|
||||
m_GemObjectTexNum = NULL;
|
||||
m_dwTick = NULL;
|
||||
m_bFirst = NULL;
|
||||
m_bUpdateFrame = false;
|
||||
m_pSmrMesh = NULL;
|
||||
|
||||
// <09><><EFBFBD><EFBFBD>:m_GemRender = new CGemRender;
|
||||
}
|
||||
|
||||
CX3DEffectMesh::~CX3DEffectMesh()
|
||||
{
|
||||
if(m_moMesh) { delete[] m_moMesh; m_moMesh = NULL; }
|
||||
|
||||
if(m_GemRender)
|
||||
{
|
||||
SubUseCount(m_GemRender->GetFileName()); // <20><><EFBFBD><EFBFBD> ī<><C4AB><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD>
|
||||
// <09><><EFBFBD><EFBFBD>:if(m_GemRender) {delete m_GemRender; m_GemRender = NULL;}
|
||||
if(m_GemObjectTexNum != NULL)
|
||||
delete[] m_GemObjectTexNum;
|
||||
}
|
||||
if(m_pSmrMesh)
|
||||
delete m_pSmrMesh;
|
||||
|
||||
if(m_dwTick != NULL)
|
||||
delete[] m_dwTick;
|
||||
delete m_bFirst;
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectMesh::CreateBuffer()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Render(void)
|
||||
{
|
||||
|
||||
|
||||
DWORD cullmode,zmode;
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_CULLMODE,&cullmode);
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_ZWRITEENABLE,&zmode);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
|
||||
|
||||
D3DXVECTOR3 *vecCenter = (D3DXVECTOR3 *)((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
|
||||
if(m_GemRender)
|
||||
{
|
||||
m_GemRender->SetScale(m_Scale[0],m_Scale[1],m_Scale[2]);
|
||||
m_GemRender->SetEffectPos(*vecCenter);
|
||||
// rotation setting
|
||||
if(m_QuatSet) {
|
||||
D3DXQUATERNION tm_q;
|
||||
tm_q.x = m_quatAxis.x;
|
||||
tm_q.y = m_quatAxis.y;
|
||||
tm_q.z = m_quatAxis.z;
|
||||
tm_q.w = m_quatAxis.w;
|
||||
|
||||
m_GemRender->GetAxis(tm_q);
|
||||
}
|
||||
|
||||
m_GemRender->SetClearBuffer(m_bClearBuffer);
|
||||
if(m_bUpdateFrame) {
|
||||
// Cash <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <20>ذ<EFBFBD>
|
||||
// Texture ani <20><> Random Start Texture Ani <20><EFBFBD><D7B8><EFBFBD> Random Ani <20><> <20><><EFBFBD><EFBFBD> m_GemObjectTexNum <20>迭<EFBFBD><E8BFAD> <20>̿<EFBFBD><CCBF>Ѵ<EFBFBD>
|
||||
// Gem<65><6D> ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ͼ<CFBE><EEB3AA> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ϳ<EFBFBD><CFB3><EFBFBD>.
|
||||
// m_GemObjectTexNum[ 0 ~ ObjectNum - 1] : <20>ؽ<EFBFBD><D8BD><EFBFBD> <20>ִ<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mesh<73><68> <20><><EFBFBD><EFBFBD> <20>ý<EFBFBD><C3BD><EFBFBD> <20><>ȣ
|
||||
// m_GemObjectTexNun[ObjectNum] : Mesh Before Frame
|
||||
// m_GemObjectTexNum[ObjectNum + 1] : Mesh Current Frame
|
||||
// m_GemObjectTexNum[ObjectNum + 2] : <20><><EFBFBD><EFBFBD> <20><>ŸƮ <20>ִϽÿ<CFBD> ó<><C3B3> <20>ؽ<EFBFBD><D8BD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǿ<EFBFBD><C7BE>°<EFBFBD><C2B0><EFBFBD> üũ<C3BC>ϴ<EFBFBD> üũ <20>÷<EFBFBD><C3B7><EFBFBD>
|
||||
// m_GemObjectTexNum[ObjectNum + 3] : <20>ؽ<EFBFBD><D8BD><EFBFBD> <20>ִϽÿ<CFBD> <20>ٷ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>ؽ<EFBFBD><D8BD>İ<EFBFBD> <20><><EFBFBD>ŵǾ<C5B5><C7BE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
// Cash <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>ذ<EFBFBD>
|
||||
// Cash <20><> <20>Կ<EFBFBD> <20>־ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SetCurrentFrame <20><> <20><><EFBFBD>־<EFBFBD><D6BE><EFBFBD> <20>Ѵ<EFBFBD>
|
||||
// <20><EFBFBD><D7B7>Ƿ<EFBFBD> gem <20><> update<74>Ǿ<EFBFBD><C7BE><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> bUpdateFrame <20><> true <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־<EFBFBD>
|
||||
// Update <20><><EFBFBD>ش<EFBFBD>.
|
||||
m_GemRender->SetCurrentFrame(m_fRenderFrame,m_GemObjectTexNum,m_dwTick,m_bFirst,m_bUpdateFrame);
|
||||
m_bUpdateFrame = false;
|
||||
}
|
||||
else
|
||||
m_GemRender->SetCurrentFrame(m_fRenderFrame,m_GemObjectTexNum,m_dwTick,m_bFirst,m_bUpdateFrame);
|
||||
|
||||
if(m_bVisibility)
|
||||
m_GemRender->Render();
|
||||
|
||||
}
|
||||
if(m_pSmrMesh)
|
||||
{
|
||||
D3DXQUATERNION tm_q(0,0,0,1);
|
||||
if(m_QuatSet)
|
||||
{
|
||||
tm_q.x = m_quatAxis.x;
|
||||
tm_q.y = m_quatAxis.y;
|
||||
tm_q.z = m_quatAxis.z;
|
||||
tm_q.w = m_quatAxis.w;
|
||||
}
|
||||
|
||||
m_pSmrMesh->Render(CSceneManager::GetDevice(),*vecCenter,D3DXVECTOR3(m_Scale[0],m_Scale[1],m_Scale[2]),tm_q,m_fRenderFrame);
|
||||
}
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE,cullmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,zmode);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::LoadFile(char *file)
|
||||
{
|
||||
bool m_bGem = true;
|
||||
char strTest1[256];
|
||||
strcpy(strTest1, file);
|
||||
|
||||
char strTest2[256];
|
||||
strcpy(strTest2, file);
|
||||
|
||||
char *pStr = strrchr(strTest1,'.');
|
||||
pStr++;
|
||||
*(pStr++) = 'G';
|
||||
*(pStr++) = 'E';
|
||||
*(pStr) = 'M';
|
||||
|
||||
pStr = strrchr(strTest2,'.');
|
||||
pStr++;
|
||||
*(pStr++) = 'S';
|
||||
*(pStr++) = 'M';
|
||||
*(pStr) = 'R';
|
||||
|
||||
if(stricmp(file,strTest1) == 0)
|
||||
{
|
||||
strcpy(m_strMeshFile, file);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(m_strMeshFile, strTest2);
|
||||
m_bGem =false;
|
||||
}
|
||||
|
||||
if(m_bGem)
|
||||
{
|
||||
|
||||
|
||||
// Cash Load
|
||||
if( ( m_GemRender = LoadCash(file) ) == NULL ) {
|
||||
|
||||
m_GemRender = new CGemRender;
|
||||
m_GemRender->SetLight(m_bLight); //Set Vertex Light
|
||||
|
||||
#ifdef __EFF_WCREATOR__
|
||||
if(!m_GemRender->LoadGemFile(file,m_lpD3DDevice,m_bVisibility))
|
||||
WriteDebug(file);
|
||||
#else
|
||||
m_GemRender->LoadGemFile(file,m_lpD3DDevice,m_bVisibility);
|
||||
#endif
|
||||
|
||||
InputCash(m_GemRender); //Cash List <20>ȿ<EFBFBD> Mesh<73><68> <20><><EFBFBD>ٸ<EFBFBD> Cash List<73><74> input.
|
||||
|
||||
}
|
||||
else { //Cash load
|
||||
if(m_GemRender->m_bDecal) // Decal<61><6C> <20>̿<EFBFBD><CCBF>Ѱ͵<D1B0><CDB5><EFBFBD> Vertex Buffer <20><> <20>ʱ<EFBFBD>ȭ <20><><EFBFBD>ش<EFBFBD>
|
||||
m_GemRender->SetInitBuffer();
|
||||
|
||||
}
|
||||
// Frame Init
|
||||
//m_GemRender->SetCurrentFrame(0.0f);
|
||||
|
||||
// Texture Load (<28><><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD> Ŀ<><C4BF><EFBFBD>ִٰ<D6B4> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ij<><C4B3><EFBFBD><EFBFBD> gem <20><> texture Load)
|
||||
if(m_bVisibility && (m_GemRender->m_Texture == NULL))
|
||||
m_GemRender->LoadTexture();
|
||||
|
||||
m_GemRender->SetLight(m_bLight); //Set Vertex Light
|
||||
m_GemRender->SetMine(m_Mine);
|
||||
m_GemRender->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetScale(m_Scale[0],m_Scale[1],m_Scale[2]);
|
||||
m_GemRender->SetCash(false); // Boid <20><> Ų<><C5B2>
|
||||
|
||||
m_dwObjectNum = m_GemRender->GetObjectNum();
|
||||
|
||||
m_GemObjectTexNum = new int[m_dwObjectNum + 4];
|
||||
/* m_dwTick = new DWORD[2];
|
||||
m_bFirst = new bool;
|
||||
|
||||
*m_bFirst = false;
|
||||
memset(m_dwTick,0,sizeof(DWORD) * 2);
|
||||
*/
|
||||
memset(m_GemObjectTexNum,0,sizeof(int) * (m_dwObjectNum + 4));
|
||||
m_GemObjectTexNum[m_dwObjectNum + 2] = -1; // Rand Start Ani <20><> <20><><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pSmrMesh = new CSMRObj;
|
||||
m_pSmrMesh->SetSrcBlend(m_dwSrcBlending);
|
||||
m_pSmrMesh->SetDstBlend(m_dwDestBlending);
|
||||
m_pSmrMesh->Load(strTest2);
|
||||
|
||||
m_dwObjectNum = (DWORD)m_pSmrMesh->m_iMeshData;
|
||||
|
||||
}
|
||||
m_dwTick = new DWORD[2];
|
||||
m_bFirst = new bool;
|
||||
|
||||
*m_bFirst = false;
|
||||
memset(m_dwTick,0,sizeof(DWORD) * 2);
|
||||
|
||||
|
||||
m_moMesh = new MeshObject[m_dwObjectNum];
|
||||
}
|
||||
|
||||
BOOL CX3DEffectMesh::Interpolation(float fFrame)
|
||||
{
|
||||
for(long i = 0; i < (int)m_dwObjectNum; i++)
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_moMesh[i].m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// color setting
|
||||
if(m_GemRender)
|
||||
m_GemRender->SetColor(i,m_lColor.r, m_lColor.g, m_lColor.b);
|
||||
//m_GemObjectTexNum[i]++;
|
||||
}
|
||||
|
||||
// current frame setting
|
||||
m_fRenderFrame = fFrame;
|
||||
m_bUpdateFrame = true;
|
||||
//m_GemRender->SetCurrentFrame(fFrame);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
unsigned char len;
|
||||
fread(&len, 1, 1, fp);
|
||||
if(len)
|
||||
{
|
||||
char strTemp[MAX_PATH];
|
||||
fread(strTemp, len, 1, fp);
|
||||
strcpy(m_strMeshFile, strOriginalPath);
|
||||
strcat(m_strMeshFile, strTemp);
|
||||
} else
|
||||
{
|
||||
strcpy(m_strMeshFile, "");
|
||||
}
|
||||
|
||||
LoadFile(m_strMeshFile);
|
||||
|
||||
for(long i = 0; i < (int)m_dwObjectNum; i++)
|
||||
{
|
||||
|
||||
m_moMesh[i].m_lstColor.Load(fp, m_lColor);
|
||||
fread(&m_moMesh[i].m_fTexFrame, 4, 1, fp);
|
||||
if(m_GemRender)
|
||||
m_GemRender->SetChangeAniFrame(i,m_moMesh[i].m_fTexFrame);
|
||||
|
||||
fread(&m_moMesh[i].m_fStartTexFrame, 4, 1, fp);
|
||||
if(m_GemRender)
|
||||
m_GemRender->SetStartTexAniFrame(i,m_moMesh[i].m_fStartTexFrame);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectMesh::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
if(strlen(m_strMeshFile))
|
||||
{
|
||||
char strMesh[MAX_PATH], strTemp[MAX_PATH];
|
||||
strcpy(strMesh, m_strMeshFile);
|
||||
if(!strncmp(strMesh, strOriginalPath, strlen(strOriginalPath)))
|
||||
{
|
||||
strcpy(strTemp, &strMesh[strlen(strOriginalPath)]);
|
||||
} else {
|
||||
MessageBox(NULL, "<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߸<EFBFBD><DFB8><EFBFBD><EFBFBD><EFBFBD>", "Effect Editor", MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char len = strlen(strTemp) + 1;
|
||||
fwrite(&len, 1, 1, fp);
|
||||
fwrite(strTemp, len, 1, fp);
|
||||
|
||||
for(long i = 0; i < (int)m_dwObjectNum; i++)
|
||||
{
|
||||
m_moMesh[i].m_lstColor.Save(fp);
|
||||
fwrite(&m_moMesh[i].m_fTexFrame, 4, 1, fp);
|
||||
fwrite(&m_moMesh[i].m_fStartTexFrame, 4, 1, fp);
|
||||
}
|
||||
} else
|
||||
{
|
||||
MessageBox(NULL, "<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>߸<EFBFBD><DFB8><EFBFBD><EFBFBD><EFBFBD>", "Effect Editor", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////// Mesh Cash Func Start //////////////////////////////////
|
||||
|
||||
void CX3DEffectMesh::InputCash(CGemRender *pMesh) { // Cash <20>ȿ<EFBFBD> mesh data input
|
||||
if(m_lstCash.m_Cash.size() > EFF_MAXCASH) {
|
||||
DeleteCash();
|
||||
}
|
||||
_CashNode *pNode;
|
||||
pNode = new _CashNode;
|
||||
pNode->m_pMesh = pMesh;
|
||||
|
||||
pNode->m_nUseCount = 1;
|
||||
m_lstCash.m_Cash.push_back(pNode);
|
||||
m_lstCash.m_nCash++;
|
||||
/*
|
||||
if(m_lstCash.size() > EFF_MAXCASH) {
|
||||
DeleteCash();
|
||||
}
|
||||
_CashNode *pNode;
|
||||
pNode = new _CashNode;
|
||||
pNode->m_pMesh = pMesh;
|
||||
|
||||
pNode->m_nUseCount = 1;
|
||||
m_lstCash.push_back(pNode);
|
||||
|
||||
m_nCash++;
|
||||
*/
|
||||
}
|
||||
void CX3DEffectMesh::SubUseCount(char *strFilename) { //Cash Node<64><65> <20><><EFBFBD><EFBFBD> ī<><C4AB><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
if(strFilename == NULL)
|
||||
return;
|
||||
for(int i=0;i<(int)m_lstCash.m_Cash.size();i++) {
|
||||
if(strstr(m_lstCash.m_Cash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
m_lstCash.m_Cash[i]->m_nUseCount--;
|
||||
}
|
||||
}
|
||||
/* if(strFilename == NULL)
|
||||
return;
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
if(strstr(m_lstCash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
m_lstCash[i]->m_nUseCount--;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
CGemRender *CX3DEffectMesh::LoadCash(char *strFilename) { // Cash <20><><EFBFBD><EFBFBD> mesh load
|
||||
|
||||
if(strFilename == NULL)
|
||||
return NULL;
|
||||
|
||||
for(int i=0;i<(int)(m_lstCash.m_Cash.size());i++) {
|
||||
if(!strcmp(m_lstCash.m_Cash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
|
||||
m_lstCash.m_Cash[i]->m_nUseCount++;
|
||||
return m_lstCash.m_Cash[i]->m_pMesh;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
if(strFilename == NULL)
|
||||
return NULL;
|
||||
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
if(strstr(m_lstCash[i]->m_pMesh->GetFileName(),strFilename)) {
|
||||
|
||||
m_lstCash[i]->m_nUseCount++;
|
||||
return m_lstCash[i]->m_pMesh;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
*/
|
||||
/*
|
||||
|
||||
std::map<char*,CGemRender *>::iterator it;
|
||||
|
||||
it = m_lstCash.find( const_cast<char*>(strFilename));
|
||||
|
||||
if( m_lstCash.end() == it )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
*/
|
||||
}
|
||||
void CX3DEffectMesh::DeleteCash() { // Cash <20><><EFBFBD><EFBFBD> mesh Data delete
|
||||
|
||||
for(int i=0;i<(int)(m_lstCash.m_Cash.size());i++) {
|
||||
if(!m_lstCash.m_Cash[i]->m_nUseCount) {
|
||||
delete m_lstCash.m_Cash[i];
|
||||
m_lstCash.m_Cash[i] = NULL;
|
||||
m_lstCash.m_Cash.erase(m_lstCash.m_Cash.begin() + i);
|
||||
m_lstCash.m_nCash--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
if(!m_lstCash[i]->m_nUseCount) {
|
||||
delete m_lstCash[i];
|
||||
m_lstCash[i] = NULL;
|
||||
m_lstCash.erase(&(m_lstCash[i]));
|
||||
m_nCash--;
|
||||
break;
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
/*
|
||||
void CX3DEffectMesh::DeleteAllCash() { // Cash list <20><><EFBFBD><EFBFBD> delete
|
||||
|
||||
for(int i=0;i<m_lstCash.m_Cash.size();i++) {
|
||||
delete m_lstCash.m_Cash[i];
|
||||
m_lstCash.m_Cash[i] = NULL;
|
||||
}
|
||||
m_lstCash.m_Cash.clear();
|
||||
m_lstCash.m_nCash = 0;
|
||||
|
||||
/*
|
||||
for(int i=0;i<m_lstCash.size();i++) {
|
||||
delete m_lstCash[i];
|
||||
m_lstCash[i] = NULL;
|
||||
}
|
||||
m_lstCash.clear();
|
||||
m_nCash = 0;
|
||||
*/
|
||||
//}
|
||||
////////////////////////////////// Mesh Cash Func End //////////////////////////////////
|
||||
185
Engine/Effect/X3DEffectMesh.h
Normal file
185
Engine/Effect/X3DEffectMesh.h
Normal file
@@ -0,0 +1,185 @@
|
||||
// X3DEffectMesh.h: interface for the CX3DEffectMesh class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTMESH_H__AE1D13FE_1406_41C3_B13A_98825BC9C07C__INCLUDED_)
|
||||
#define AFX_X3DEFFECTMESH_H__AE1D13FE_1406_41C3_B13A_98825BC9C07C__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
#include "CGemRender.h"
|
||||
#include "SMRObj.h"
|
||||
|
||||
#include <vector>
|
||||
//#include <map>
|
||||
|
||||
#define EFF_MAXCASH 60
|
||||
|
||||
using namespace std;
|
||||
|
||||
class _CashNode { // Mesh Cash List node class
|
||||
public:
|
||||
CGemRender *m_pMesh; // Mesh Data
|
||||
int m_nUseCount; // <20><> <20><><EFBFBD>带 <20>̿<EFBFBD><CCBF>ϴ<EFBFBD> effect<63><74> <20><><EFBFBD><EFBFBD>(0<><30> <20>Ǹ<EFBFBD> list <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>)
|
||||
_CashNode() {
|
||||
m_pMesh = NULL;
|
||||
m_nUseCount = 0;
|
||||
}
|
||||
~_CashNode() {
|
||||
if(m_pMesh != NULL) {
|
||||
delete m_pMesh;
|
||||
m_pMesh = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
class CashNode {
|
||||
public:
|
||||
|
||||
vector<_CashNode *> m_Cash;
|
||||
int m_nCash;
|
||||
CashNode() {
|
||||
m_Cash.clear();
|
||||
m_nCash = 0;
|
||||
}
|
||||
~CashNode() {
|
||||
for(int i=0;i< (int)m_Cash.size();i++) {
|
||||
delete m_Cash[i];
|
||||
m_Cash[i] = NULL;
|
||||
}
|
||||
m_Cash.clear();
|
||||
m_nCash = 0;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
//typedef vector<_CashNode *> CashNode;
|
||||
|
||||
//typedef std::map<char* ,CGemRender *> CashNode;
|
||||
|
||||
typedef struct _MeshObject
|
||||
{
|
||||
CKeyList<ColorKeyList> m_lstColor;
|
||||
float m_fStartTexFrame;
|
||||
float m_fTexFrame;
|
||||
} MeshObject;
|
||||
|
||||
class CX3DEffectMesh : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
|
||||
bool m_bUpdateFrame;
|
||||
|
||||
char m_strMeshFile[MAX_PATH];
|
||||
// CEffectMesh *Mesh;
|
||||
CGemRender *m_GemRender;
|
||||
CSMRObj *m_pSmrMesh;
|
||||
|
||||
float m_fRenderFrame; // Render <20>Ǿ<EFBFBD><C7BE><EFBFBD> <20><> Frame
|
||||
static CashNode m_lstCash; // Mesh cash list
|
||||
// static int m_nCash; // Mesh cash Num
|
||||
int *m_GemObjectTexNum; // Gem Object Texture Num
|
||||
DWORD *m_dwTick;
|
||||
bool *m_bFirst;
|
||||
public:
|
||||
unsigned long m_dwObjectNum;
|
||||
MeshObject *m_moMesh;
|
||||
|
||||
public:
|
||||
CX3DEffectMesh();
|
||||
virtual ~CX3DEffectMesh();
|
||||
|
||||
// Mesh Cash Func
|
||||
CGemRender *LoadCash(char *strFilename); // Cash <20><><EFBFBD><EFBFBD> mesh load
|
||||
void InputCash(CGemRender *); // Cash <20>ȿ<EFBFBD> mesh data input
|
||||
void DeleteCash(); // Cash <20><><EFBFBD><EFBFBD> mesh Data delete
|
||||
//static void DeleteAllCash(); // Cash <20><><EFBFBD><EFBFBD> delete
|
||||
void SubUseCount(char *strFilename); // Cash <20><><EFBFBD><EFBFBD> ī<><C4AB><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD>
|
||||
|
||||
unsigned long GetMaxFrame(void)
|
||||
{
|
||||
if(m_GemRender)
|
||||
return (unsigned long)m_GemRender->GetMaxFrame();
|
||||
else if(m_pSmrMesh)
|
||||
{
|
||||
return (unsigned long)m_pSmrMesh->m_iFrameInfo[1];
|
||||
}
|
||||
}
|
||||
|
||||
void SetSrcBlending(unsigned long dwSrcBlending)
|
||||
{
|
||||
m_dwSrcBlending = dwSrcBlending;
|
||||
if(m_GemRender)
|
||||
{
|
||||
// Mesh->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetSrcBlend(m_dwSrcBlending);
|
||||
}
|
||||
else if(m_pSmrMesh)
|
||||
{
|
||||
m_pSmrMesh->SetSrcBlend(m_dwSrcBlending);
|
||||
}
|
||||
|
||||
}
|
||||
void SetDestBlending(unsigned long dwDestBlending)
|
||||
{
|
||||
m_dwDestBlending = dwDestBlending;
|
||||
if(m_GemRender)
|
||||
{
|
||||
|
||||
// Mesh->SetBlend(m_dwSrcBlending, m_dwDestBlending);
|
||||
m_GemRender->SetDstBlend(m_dwDestBlending);
|
||||
|
||||
}
|
||||
else if(m_pSmrMesh)
|
||||
{
|
||||
m_pSmrMesh->SetDstBlend(m_dwDestBlending);
|
||||
}
|
||||
}
|
||||
|
||||
void SetTexFrame(unsigned long dwObjectNum, float fTexFrame)
|
||||
{
|
||||
m_moMesh[dwObjectNum].m_fTexFrame = fTexFrame;
|
||||
// Mesh->SetTexAniFrame(dwObjectNum, fTexFrame);
|
||||
if(m_GemRender)
|
||||
{
|
||||
m_GemRender->SetChangeAniFrame(dwObjectNum, fTexFrame);
|
||||
}
|
||||
}
|
||||
float GetTexFrame(unsigned long dwObjectNum) { return m_moMesh[dwObjectNum].m_fTexFrame; }
|
||||
|
||||
void SetStartTexFrame(unsigned long dwObjectNum, float fStartTexFrame)
|
||||
{
|
||||
m_moMesh[dwObjectNum].m_fStartTexFrame = fStartTexFrame;
|
||||
if(m_GemRender)
|
||||
{
|
||||
|
||||
m_GemRender->SetStartTexAniFrame(dwObjectNum,fStartTexFrame);
|
||||
// Mesh->SetStartTexAni(dwObjectNum, fStartTexFrame);
|
||||
}
|
||||
}
|
||||
float GetStartTexFrame(unsigned long dwObjectNum) { return m_moMesh[dwObjectNum].m_fStartTexFrame; }
|
||||
|
||||
void SetObjectColor(unsigned long dwObjectNum)
|
||||
{
|
||||
// Mesh->SetPickColor(dwObjectNum, r, g, b, a);
|
||||
// Mesh->SetPickNum(dwObjectNum);
|
||||
if(m_GemRender)
|
||||
{
|
||||
|
||||
m_GemRender->SetPickObject(dwObjectNum);
|
||||
}
|
||||
}
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer();
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
|
||||
void LoadFile(char *file);
|
||||
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTMESH_H__AE1D13FE_1406_41C3_B13A_98825BC9C07C__INCLUDED_)
|
||||
824
Engine/Effect/X3DEffectParticle.cpp
Normal file
824
Engine/Effect/X3DEffectParticle.cpp
Normal file
@@ -0,0 +1,824 @@
|
||||
// X3DEffectParticle.cpp: implementation of the CX3DEffectParticle class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectParticle.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectParticle::CX3DEffectParticle()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
m_lpVerticeIndex = NULL;
|
||||
m_lpVerticeInfo = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectParticle::~CX3DEffectParticle()
|
||||
{
|
||||
if(m_lpVerticeInfo) { delete[] m_lpVerticeInfo; m_lpVerticeInfo = NULL; }
|
||||
/* if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }*/
|
||||
|
||||
if(m_lpVerticeIndex) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_INDEX,m_lpVerticeIndex);
|
||||
else
|
||||
m_lpVerticeIndex->Release();
|
||||
m_lpVerticeIndex = NULL;
|
||||
}
|
||||
if(m_lpVerticesBlend) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
|
||||
if (m_lpVerticeInfo) { delete[] m_lpVerticeInfo; m_lpVerticeInfo = NULL; }
|
||||
m_lpVerticeInfo = NULL;
|
||||
|
||||
m_dwMaxAmount = m_dwDrawAmount = 0;
|
||||
|
||||
m_dwVolumeType = 0;
|
||||
m_fVolX = m_fVolY = m_fVolZ = m_fRadius = m_fInnerRadius = 0.0f;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::CreateBuffer(void)
|
||||
{
|
||||
FloatKeyList::iterator fIt;
|
||||
unsigned long i;
|
||||
|
||||
m_dwMaxAmount = m_dwDrawAmount = 0;
|
||||
for(fIt = m_lstAmount.Begin(); fIt != m_lstAmount.End(); fIt++)
|
||||
{
|
||||
m_dwMaxAmount += ((*fIt).second);
|
||||
}
|
||||
|
||||
if(m_lpVerticeInfo) { delete[] m_lpVerticeInfo; m_lpVerticeInfo = NULL; }
|
||||
/* if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
*/
|
||||
if(m_lpVerticeIndex) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_INDEX,m_lpVerticeIndex);
|
||||
//m_lpVerticeIndex->Release();
|
||||
m_lpVerticeIndex = NULL;
|
||||
}
|
||||
if(m_lpVerticesBlend) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticeIndex = CSceneManager::ms_pBufferPools->GetIndexBuffer(m_dwMaxAmount * 2 * 3 * sizeof(unsigned short),D3DFMT_INDEX16,false);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(m_dwMaxAmount * 4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticeIndex = CSceneManager::ms_pBufferPools->GetIndexBuffer(m_dwMaxAmount * 2 * 3 * sizeof(unsigned short),D3DFMT_INDEX16,false);
|
||||
/*
|
||||
m_lpD3DDevice->CreateVertexBuffer( m_dwMaxAmount * 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT , &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( m_dwMaxAmount * 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC |D3DUSAGE_WRITEONLY, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
m_lpD3DDevice->CreateIndexBuffer( m_dwMaxAmount * 2 * 3 * sizeof(unsigned short), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16,
|
||||
D3DPOOL_MANAGED, &m_lpVerticeIndex);*/
|
||||
m_lpVerticeInfo = new Particle[m_dwMaxAmount];
|
||||
|
||||
unsigned short *pVerticeIndex;
|
||||
// m_lpVerticeIndex->Lock(0, m_dwMaxAmount * 2 * 3 * sizeof(unsigned short), (unsigned char **)&pVerticeIndex, 0);
|
||||
m_lpVerticeIndex->Lock(0, 0, (unsigned char **)&pVerticeIndex, 0);
|
||||
|
||||
for(i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
m_lpVerticeInfo[i].fLifetime = -1.0f;
|
||||
|
||||
pVerticeIndex[i * 6 + 0] = i * 4 + 0;
|
||||
pVerticeIndex[i * 6 + 1] = i * 4 + 1;
|
||||
pVerticeIndex[i * 6 + 2] = i * 4 + 2;
|
||||
|
||||
pVerticeIndex[i * 6 + 3] = i * 4 + 1;
|
||||
pVerticeIndex[i * 6 + 4] = i * 4 + 3;
|
||||
pVerticeIndex[i * 6 + 5] = i * 4 + 2;
|
||||
}
|
||||
|
||||
m_lpVerticeIndex->Unlock();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::CreateParticle(LPParticle lpParticle)
|
||||
{
|
||||
unsigned long i;
|
||||
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
for(i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
if(m_lpVerticeInfo[i].fLifetime > 0.0f) continue;
|
||||
|
||||
m_lpVerticeInfo[i].vecPos = lpParticle->vecPos;
|
||||
m_lpVerticeInfo[i].vecVel = lpParticle->vecVel;
|
||||
m_lpVerticeInfo[i].lColor = lpParticle->lColor;
|
||||
m_lpVerticeInfo[i].fRotation = lpParticle->fRotation;
|
||||
m_lpVerticeInfo[i].dwRotationCount = rand() % 128;
|
||||
m_lpVerticeInfo[i].fWidth = lpParticle->fWidth;
|
||||
m_lpVerticeInfo[i].fHeight = lpParticle->fHeight;
|
||||
m_lpVerticeInfo[i].fMaxLife = m_lpVerticeInfo[i].fLifetime = lpParticle->fLifetime;
|
||||
m_lpVerticeInfo[i].fTexFrame = lpParticle->fTexFrame;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::SetVolumeNone(void)
|
||||
{
|
||||
m_dwVolumeType = 0;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::SetVolumeSquare(float fVolX, float fVolY, float fVolZ)
|
||||
{
|
||||
m_dwVolumeType = 1;
|
||||
m_fVolX = fVolX;
|
||||
m_fVolY = fVolY;
|
||||
m_fVolZ = fVolZ;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::SetVolumeCircle(float fRadius, float fInnerRadius)
|
||||
{
|
||||
m_dwVolumeType = 2;
|
||||
m_fRadius = fRadius;
|
||||
m_fInnerRadius = fInnerRadius;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
|
||||
if(m_lpVertices == NULL) return;
|
||||
DWORD cullmode,zmode;
|
||||
DWORD amode;
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_ZWRITEENABLE,&zmode);
|
||||
|
||||
//m_lpD3DDevice->SetRenderState(D3DRS_ZENABLE,FALSE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_ALPHABLENDENABLE,&amode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
|
||||
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
|
||||
|
||||
m_lpD3DDevice->GetRenderState(D3DRS_CULLMODE,&cullmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_DIFFUSE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_TEXTURE);
|
||||
m_lpD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
|
||||
|
||||
m_lpD3DDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_DISABLE);
|
||||
m_lpD3DDevice->SetTextureStageState(1,D3DTSS_ALPHAOP,D3DTOP_DISABLE);
|
||||
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
if(m_dwDrawAmount)
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwDrawAmount * 4, 0, m_dwDrawAmount * 2);
|
||||
/**/
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
// m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
// m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
if(m_dwDrawAmount)
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwDrawAmount * 4, 0, m_dwDrawAmount * 2);
|
||||
}//***/
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,zmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_CULLMODE,cullmode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,amode);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZENABLE,TRUE);
|
||||
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
float local_volx;
|
||||
float local_voly;
|
||||
float local_volz;
|
||||
float local_rad;
|
||||
float local_inrad;
|
||||
|
||||
if(m_lpVertices == NULL) return FALSE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
float fTempFrame;
|
||||
|
||||
fTempFrame = ((CX3DEffect *)m_lpLocalEffect)->GetFrame();
|
||||
if(m_StopParticleFrame != -1) {
|
||||
// extension3 :: mid effect <20><> <20><>ƼŬ<C6BC><C5AC> end effect <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ڽ<EFBFBD><DABD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
|
||||
if(!m_lstCenter.Interpolation(fTempFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstEForce.Interpolation(fTempFrame, m_vecEForce)) return FALSE;
|
||||
if(!m_lstAlpha.Interpolation(fTempFrame, m_fAlpha)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fTempFrame, m_quatAxis)) return FALSE;
|
||||
if(!m_lstDirection.InterpolationQ(fTempFrame, m_quatDir)) return FALSE;
|
||||
if(!m_lstPower.Interpolation(fTempFrame, m_fPower)) return FALSE;
|
||||
if(!m_lstAngle.Interpolation(fTempFrame, m_fAngle)) return FALSE;
|
||||
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
|
||||
m_fPower *=m_Scale[0];
|
||||
m_vecEForce.x *=m_Scale[0];
|
||||
m_vecEForce.y *=m_Scale[0];
|
||||
m_vecEForce.z *=m_Scale[0];
|
||||
|
||||
m_fAngle *=m_Scale[0];
|
||||
|
||||
local_volx= m_fVolX * m_Scale[0];
|
||||
local_voly = m_fVolY * m_Scale[0];
|
||||
local_volz = m_fVolZ * m_Scale[0];
|
||||
local_rad = m_fRadius * m_Scale[0];
|
||||
local_inrad = m_fInnerRadius * m_Scale[0];
|
||||
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
if(m_bVisibility) {
|
||||
matrix *matView = ((CX3DEffect *)m_lpLocalEffect)->GetViewMatrix();
|
||||
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
// if(FAILED( m_lpVertices->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) )
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0 ) ) )
|
||||
return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) )
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0 ) ) )
|
||||
return FALSE;
|
||||
|
||||
m_dwDrawAmount = 0;
|
||||
unsigned long mul;
|
||||
float w, h, d, degree, cosx, siny;
|
||||
vector3 vecCenter, pVer[4];
|
||||
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
for(unsigned long i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
|
||||
if(m_lpVerticeInfo[i].fLifetime < 0.0f) continue;
|
||||
else if(m_lpVerticeInfo[i].fLifetime < ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame())
|
||||
m_lpVerticeInfo[i].fLifetime = 0.0f;
|
||||
|
||||
m_lpVerticeInfo[i].vecVel += m_vecEForce;
|
||||
m_lpVerticeInfo[i].vecPos += m_lpVerticeInfo[i].vecVel;
|
||||
|
||||
if(!ParticleInterpolation(i)) return FALSE;
|
||||
|
||||
w = m_lpVerticeInfo[i].fWidth / 2;
|
||||
h = m_lpVerticeInfo[i].fHeight / 2;
|
||||
|
||||
d = m_lpVerticeInfo[i].fRotation * m_lpVerticeInfo[i].dwRotationCount;
|
||||
degree = d - (((unsigned long)(d / 360)) * 360.0f);
|
||||
cosx = cosf(degree);
|
||||
siny = sinf(degree);
|
||||
|
||||
mul = m_dwDrawAmount << 2;
|
||||
|
||||
pVer[0] = vector3(-w * cosx - h * siny, -w * siny + h * cosx, 0.0f);
|
||||
pVer[1] = vector3(w * cosx - h * siny, w * siny + h * cosx, 0.0f);
|
||||
pVer[2] = vector3(-w * cosx + h * siny, -w * siny - h * cosx, 0.0f);
|
||||
pVer[3] = vector3(w * cosx + h * siny, w * siny - h * cosx, 0.0f);
|
||||
|
||||
/* if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
{
|
||||
z3d::VectorRotate(pVer[0], pVer[0], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[1], pVer[1], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[2], pVer[2], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[3], pVer[3], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
}*/
|
||||
|
||||
pVertices[mul + 0].v = vector3(pVer[0].x * matView->_11 + pVer[0].y * matView->_12, pVer[0].x * matView->_21 + pVer[0].y * matView->_22, pVer[0].x * matView->_31 + pVer[0].y * matView->_32);
|
||||
pVertices[mul + 1].v = vector3(pVer[1].x * matView->_11 + pVer[1].y * matView->_12, pVer[1].x * matView->_21 + pVer[1].y * matView->_22, pVer[1].x * matView->_31 + pVer[1].y * matView->_32);
|
||||
pVertices[mul + 2].v = vector3(pVer[2].x * matView->_11 + pVer[2].y * matView->_12, pVer[2].x * matView->_21 + pVer[2].y * matView->_22, pVer[2].x * matView->_31 + pVer[2].y * matView->_32);
|
||||
pVertices[mul + 3].v = vector3(pVer[3].x * matView->_11 + pVer[3].y * matView->_12, pVer[3].x * matView->_21 + pVer[3].y * matView->_22, pVer[3].x * matView->_31 + pVer[3].y * matView->_32);
|
||||
|
||||
pVertices[mul + 0].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 1].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 2].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 3].v += m_lpVerticeInfo[i].vecPos;
|
||||
|
||||
pVertices[mul + 0].diff = pVertices[mul + 1].diff =
|
||||
pVertices[mul + 2].diff = pVertices[mul + 3].diff = m_lpVerticeInfo[i].lColor;
|
||||
|
||||
pVertices[mul + 3].diff.a *= m_fAlpha;
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a =
|
||||
pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
|
||||
pVertices[mul + 0].spec = pVertices[mul + 1].spec =
|
||||
pVertices[mul + 2].spec = pVertices[mul + 3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
pVerticesBlend[mul + 0].v = pVertices[mul + 0].v;
|
||||
pVerticesBlend[mul + 1].v = pVertices[mul + 1].v;
|
||||
pVerticesBlend[mul + 2].v = pVertices[mul + 2].v;
|
||||
pVerticesBlend[mul + 3].v = pVertices[mul + 3].v;
|
||||
|
||||
pVerticesBlend[mul + 0].diff = pVerticesBlend[mul + 1].diff =
|
||||
pVerticesBlend[mul + 2].diff = pVerticesBlend[mul + 3].diff = pVertices[mul + 0].diff;
|
||||
|
||||
pVerticesBlend[mul + 0].spec = pVerticesBlend[mul + 1].spec =
|
||||
pVerticesBlend[mul + 2].spec = pVerticesBlend[mul + 3].spec = pVertices[mul + 0].spec;
|
||||
|
||||
long t = (long)m_lpVerticeInfo[i].fTexFrame;
|
||||
float f1 = (t % 4) * 0.25;
|
||||
float f2 = (t / 4) * 0.25;
|
||||
pVertices[mul + 0].tu = f1; pVertices[mul + 0].tv = f2;
|
||||
pVertices[mul + 1].tu = f1 + 0.25f; pVertices[mul + 1].tv = f2;
|
||||
pVertices[mul + 2].tu = f1; pVertices[mul + 2].tv = f2 + 0.25f;
|
||||
pVertices[mul + 3].tu = f1 + 0.25f; pVertices[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
if(15 == t) { if(0.16f < m_fTexSpeed) t = 0; else t = 15; } else t++;
|
||||
f1 = (t % 4) * 0.25;
|
||||
f2 = (t / 4) * 0.25;
|
||||
pVerticesBlend[mul + 0].tu = f1; pVerticesBlend[mul + 0].tv = f2;
|
||||
pVerticesBlend[mul + 1].tu = f1 + 0.25f; pVerticesBlend[mul + 1].tv = f2;
|
||||
pVerticesBlend[mul + 2].tu = f1; pVerticesBlend[mul + 2].tv = f2 + 0.25f;
|
||||
pVerticesBlend[mul + 3].tu = f1 + 0.25f; pVerticesBlend[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// float fAlpha = ;
|
||||
pVertices[mul + 3].diff.a *= (floorf(m_lpVerticeInfo[i].fTexFrame + 1.0f) - m_lpVerticeInfo[i].fTexFrame);
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a = pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
pVerticesBlend[mul + 3].diff.a *= (m_lpVerticeInfo[i].fTexFrame - floorf(m_lpVerticeInfo[i].fTexFrame));
|
||||
// pVerticesBlend[mul + 3].diff.a *= (1.0f - fAlpha);
|
||||
pVerticesBlend[mul + 0].diff.a = pVerticesBlend[mul + 1].diff.a = pVerticesBlend[mul + 2].diff.a = pVerticesBlend[mul + 3].diff.a;
|
||||
///////////////////////////////////////////
|
||||
} else
|
||||
{
|
||||
pVertices[mul + 0].tu = 0.0f; pVertices[mul + 0].tv = 0.0f;
|
||||
pVertices[mul + 1].tu = 1.0f; pVertices[mul + 1].tv = 0.0f;
|
||||
pVertices[mul + 2].tu = 0.0f; pVertices[mul + 2].tv = 1.0f;
|
||||
pVertices[mul + 3].tu = 1.0f; pVertices[mul + 3].tv = 1.0f;
|
||||
}
|
||||
|
||||
m_lpVerticeInfo[i].fLifetime -= ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame();
|
||||
m_lpVerticeInfo[i].dwRotationCount++;
|
||||
|
||||
// <20><><EFBFBD>İ<EFBFBD><C4B0><EFBFBD> 5<><35><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD> draw list<73><74><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if((pVertices[mul +3].diff.a)<1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_dwDrawAmount++;
|
||||
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
} //if(m_bVisibility)
|
||||
|
||||
}
|
||||
else { // <20>Ϲ<EFBFBD> particle
|
||||
|
||||
if(!m_lstCenter.Interpolation(fTempFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstEForce.Interpolation(fTempFrame, m_vecEForce)) return FALSE;
|
||||
if(!m_lstAlpha.Interpolation(fTempFrame, m_fAlpha)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fTempFrame, m_quatAxis)) return FALSE;
|
||||
if(!m_lstDirection.InterpolationQ(fTempFrame, m_quatDir)) return FALSE;
|
||||
if(!m_lstPower.Interpolation(fTempFrame, m_fPower)) return FALSE;
|
||||
if(!m_lstAngle.Interpolation(fTempFrame, m_fAngle)) return FALSE;
|
||||
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
|
||||
m_fPower *=m_Scale[0];
|
||||
m_vecEForce.x *=m_Scale[0];
|
||||
m_vecEForce.y *=m_Scale[0];
|
||||
m_vecEForce.z *=m_Scale[0];
|
||||
|
||||
m_fAngle *=m_Scale[0];
|
||||
|
||||
local_volx= m_fVolX * m_Scale[0];
|
||||
local_voly = m_fVolY * m_Scale[0];
|
||||
local_volz = m_fVolZ * m_Scale[0];
|
||||
local_rad = m_fRadius * m_Scale[0];
|
||||
local_inrad = m_fInnerRadius * m_Scale[0];
|
||||
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
local_volx = m_fVolX;
|
||||
local_voly = m_fVolY;
|
||||
local_volz = m_fVolZ;
|
||||
local_rad = m_fRadius;
|
||||
local_inrad = m_fInnerRadius;
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(m_bVisibility) {
|
||||
float fAmount;
|
||||
Particle pNewParticle;
|
||||
|
||||
if(m_lstAmount.Find(fTempFrame, fAmount))
|
||||
{
|
||||
float a, b, r, c, a1, p;
|
||||
|
||||
a1 = FLOAT_PHI / fAmount;
|
||||
c = ((2 * FLOAT_PHI) / fAmount);
|
||||
|
||||
for(unsigned long i = 0; i < (unsigned long)fAmount; i++)
|
||||
{
|
||||
p = m_fPower * (1.0f - m_fPowerSeed * (1.0f - (((float)rand()) / RAND_MAX) * 2.0f));
|
||||
a = (m_fAngle * (((float)rand()) / RAND_MAX));
|
||||
b = c * i;
|
||||
r = p * sinf(a);
|
||||
|
||||
pNewParticle.vecVel = vector3(r * cosf(b), p * cosf(a), r * sinf(b));
|
||||
z3d::VectorRotate(pNewParticle.vecVel, pNewParticle.vecVel, m_quatDir);
|
||||
z3d::VectorRotate(pNewParticle.vecVel, pNewParticle.vecVel, m_quatAxis);
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
z3d::VectorRotate(pNewParticle.vecVel, pNewParticle.vecVel, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
pNewParticle.fMaxLife = pNewParticle.fLifetime = m_fLifetime * (1.0f - m_fLifetimeSeed * (1.0f - (((float)rand()) / RAND_MAX) * 2.0f));
|
||||
|
||||
pNewParticle.fRotation = m_fRotation * (1.0f - m_fPowerSeed * (1.0f - (((float)rand()) / RAND_MAX) * 2.0f));
|
||||
pNewParticle.fTexFrame = 01.0;
|
||||
|
||||
switch(m_dwVolumeType)
|
||||
{
|
||||
case 0:
|
||||
pNewParticle.vecPos = m_vecCenter;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
pNewParticle.vecPos = vector3(((float)rand() / RAND_MAX) * local_volx,
|
||||
((float)rand() / RAND_MAX) * local_voly,
|
||||
((float)rand() / RAND_MAX) * local_volz) - vector3(local_volx / 2, local_voly / 2, local_volz / 2);
|
||||
z3d::VectorRotate(pNewParticle.vecPos, pNewParticle.vecPos, m_quatAxis);
|
||||
pNewParticle.vecPos += m_vecCenter;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
{
|
||||
float degree = 2.0f * FLOAT_PHI * (((float)rand()) / RAND_MAX);
|
||||
float radius = local_inrad + (local_rad - local_inrad * (((float)rand()) / RAND_MAX));
|
||||
|
||||
pNewParticle.vecPos = vector3(radius * cosf(degree), 0, radius * sinf(degree));
|
||||
z3d::VectorRotate(pNewParticle.vecPos, pNewParticle.vecPos, m_quatAxis);
|
||||
pNewParticle.vecPos += m_vecCenter;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetAxis()) z3d::VectorRotate(pNewParticle.vecPos, pNewParticle.vecPos, *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter()) pNewParticle.vecPos += (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
|
||||
CreateParticle(&pNewParticle);
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
matrix *matView = ((CX3DEffect *)m_lpLocalEffect)->GetViewMatrix();
|
||||
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
// if(FAILED( m_lpVertices->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVertices, 0 ) ) )
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0 ) ) )
|
||||
return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, m_dwMaxAmount * 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, 0 ) ) )
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0 ) ) )
|
||||
return FALSE;
|
||||
|
||||
m_dwDrawAmount = 0;
|
||||
unsigned long mul;
|
||||
float w, h, d, degree, cosx, siny;
|
||||
vector3 vecCenter, pVer[4];
|
||||
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
for(unsigned long i = 0; i < m_dwMaxAmount; i++)
|
||||
{
|
||||
|
||||
if(m_lpVerticeInfo[i].fLifetime < 0.0f) continue;
|
||||
else if(m_lpVerticeInfo[i].fLifetime < ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame())
|
||||
m_lpVerticeInfo[i].fLifetime = 0.0f;
|
||||
|
||||
m_lpVerticeInfo[i].vecVel += m_vecEForce;
|
||||
m_lpVerticeInfo[i].vecPos += m_lpVerticeInfo[i].vecVel;
|
||||
|
||||
if(!ParticleInterpolation(i)) return FALSE;
|
||||
|
||||
w = m_lpVerticeInfo[i].fWidth / 2;
|
||||
h = m_lpVerticeInfo[i].fHeight / 2;
|
||||
|
||||
d = m_lpVerticeInfo[i].fRotation * m_lpVerticeInfo[i].dwRotationCount;
|
||||
degree = d - (((unsigned long)(d / 360)) * 360.0f);
|
||||
cosx = cosf(degree);
|
||||
siny = sinf(degree);
|
||||
|
||||
mul = m_dwDrawAmount << 2;
|
||||
|
||||
pVer[0] = vector3(-w * cosx - h * siny, -w * siny + h * cosx, 0.0f);
|
||||
pVer[1] = vector3(w * cosx - h * siny, w * siny + h * cosx, 0.0f);
|
||||
pVer[2] = vector3(-w * cosx + h * siny, -w * siny - h * cosx, 0.0f);
|
||||
pVer[3] = vector3(w * cosx + h * siny, w * siny - h * cosx, 0.0f);
|
||||
|
||||
/* if(((CX3DEffect *)m_lpLocalEffect)->GetAxis())
|
||||
{
|
||||
z3d::VectorRotate(pVer[0], pVer[0], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[1], pVer[1], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[2], pVer[2], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
z3d::VectorRotate(pVer[3], pVer[3], *((CX3DEffect *)m_lpLocalEffect)->GetAxis());
|
||||
}*/
|
||||
|
||||
pVertices[mul + 0].v = vector3(pVer[0].x * matView->_11 + pVer[0].y * matView->_12, pVer[0].x * matView->_21 + pVer[0].y * matView->_22, pVer[0].x * matView->_31 + pVer[0].y * matView->_32);
|
||||
pVertices[mul + 1].v = vector3(pVer[1].x * matView->_11 + pVer[1].y * matView->_12, pVer[1].x * matView->_21 + pVer[1].y * matView->_22, pVer[1].x * matView->_31 + pVer[1].y * matView->_32);
|
||||
pVertices[mul + 2].v = vector3(pVer[2].x * matView->_11 + pVer[2].y * matView->_12, pVer[2].x * matView->_21 + pVer[2].y * matView->_22, pVer[2].x * matView->_31 + pVer[2].y * matView->_32);
|
||||
pVertices[mul + 3].v = vector3(pVer[3].x * matView->_11 + pVer[3].y * matView->_12, pVer[3].x * matView->_21 + pVer[3].y * matView->_22, pVer[3].x * matView->_31 + pVer[3].y * matView->_32);
|
||||
|
||||
pVertices[mul + 0].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 1].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 2].v += m_lpVerticeInfo[i].vecPos;
|
||||
pVertices[mul + 3].v += m_lpVerticeInfo[i].vecPos;
|
||||
|
||||
pVertices[mul + 0].diff = pVertices[mul + 1].diff =
|
||||
pVertices[mul + 2].diff = pVertices[mul + 3].diff = m_lpVerticeInfo[i].lColor;
|
||||
|
||||
pVertices[mul + 3].diff.a *= m_fAlpha;
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a =
|
||||
pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
|
||||
pVertices[mul + 0].spec = pVertices[mul + 1].spec =
|
||||
pVertices[mul + 2].spec = pVertices[mul + 3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
pVerticesBlend[mul + 0].v = pVertices[mul + 0].v;
|
||||
pVerticesBlend[mul + 1].v = pVertices[mul + 1].v;
|
||||
pVerticesBlend[mul + 2].v = pVertices[mul + 2].v;
|
||||
pVerticesBlend[mul + 3].v = pVertices[mul + 3].v;
|
||||
|
||||
pVerticesBlend[mul + 0].diff = pVerticesBlend[mul + 1].diff =
|
||||
pVerticesBlend[mul + 2].diff = pVerticesBlend[mul + 3].diff = pVertices[mul + 0].diff;
|
||||
|
||||
pVerticesBlend[mul + 0].spec = pVerticesBlend[mul + 1].spec =
|
||||
pVerticesBlend[mul + 2].spec = pVerticesBlend[mul + 3].spec = pVertices[mul + 0].spec;
|
||||
|
||||
long t = (long)m_lpVerticeInfo[i].fTexFrame;
|
||||
float f1 = (t % 4) * 0.25;
|
||||
float f2 = (t / 4) * 0.25;
|
||||
pVertices[mul + 0].tu = f1; pVertices[mul + 0].tv = f2;
|
||||
pVertices[mul + 1].tu = f1 + 0.25f; pVertices[mul + 1].tv = f2;
|
||||
pVertices[mul + 2].tu = f1; pVertices[mul + 2].tv = f2 + 0.25f;
|
||||
pVertices[mul + 3].tu = f1 + 0.25f; pVertices[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
if(15 == t) { if(0.16f < m_fTexSpeed) t = 0; else t = 15; } else t++;
|
||||
f1 = (t % 4) * 0.25;
|
||||
f2 = (t / 4) * 0.25;
|
||||
pVerticesBlend[mul + 0].tu = f1; pVerticesBlend[mul + 0].tv = f2;
|
||||
pVerticesBlend[mul + 1].tu = f1 + 0.25f; pVerticesBlend[mul + 1].tv = f2;
|
||||
pVerticesBlend[mul + 2].tu = f1; pVerticesBlend[mul + 2].tv = f2 + 0.25f;
|
||||
pVerticesBlend[mul + 3].tu = f1 + 0.25f; pVerticesBlend[mul + 3].tv = f2 + 0.25f;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// float fAlpha = ;
|
||||
pVertices[mul + 3].diff.a *= (floorf(m_lpVerticeInfo[i].fTexFrame + 1.0f) - m_lpVerticeInfo[i].fTexFrame);
|
||||
pVertices[mul + 0].diff.a = pVertices[mul + 1].diff.a = pVertices[mul + 2].diff.a = pVertices[mul + 3].diff.a;
|
||||
|
||||
pVerticesBlend[mul + 3].diff.a *= (m_lpVerticeInfo[i].fTexFrame - floorf(m_lpVerticeInfo[i].fTexFrame));
|
||||
// pVerticesBlend[mul + 3].diff.a *= (1.0f - fAlpha);
|
||||
pVerticesBlend[mul + 0].diff.a = pVerticesBlend[mul + 1].diff.a = pVerticesBlend[mul + 2].diff.a = pVerticesBlend[mul + 3].diff.a;
|
||||
///////////////////////////////////////////
|
||||
} else
|
||||
{
|
||||
pVertices[mul + 0].tu = 0.0f; pVertices[mul + 0].tv = 0.0f;
|
||||
pVertices[mul + 1].tu = 1.0f; pVertices[mul + 1].tv = 0.0f;
|
||||
pVertices[mul + 2].tu = 0.0f; pVertices[mul + 2].tv = 1.0f;
|
||||
pVertices[mul + 3].tu = 1.0f; pVertices[mul + 3].tv = 1.0f;
|
||||
}
|
||||
|
||||
m_lpVerticeInfo[i].fLifetime -= ((CX3DEffect *)m_lpLocalEffect)->GetIncFrame();
|
||||
m_lpVerticeInfo[i].dwRotationCount++;
|
||||
|
||||
// <20><><EFBFBD>İ<EFBFBD><C4B0><EFBFBD> 1<><31><EFBFBD><EFBFBD><EFBFBD≯<EFBFBD> draw list<73><74><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
if((pVertices[mul +3].diff.a)<1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
m_dwDrawAmount++;
|
||||
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
} //if(m_bVisibility)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectParticle::ParticleInterpolation(unsigned long dwNumber)
|
||||
{
|
||||
if(m_lpVerticeInfo == NULL)
|
||||
return FALSE;
|
||||
|
||||
float fFrame = 100.0f * (1.0f - (m_lpVerticeInfo[dwNumber].fLifetime / m_lpVerticeInfo[dwNumber].fMaxLife));
|
||||
|
||||
if(!m_lstWidth.Interpolation(fFrame, m_lpVerticeInfo[dwNumber].fWidth)) return FALSE;
|
||||
if(!m_lstHeight.Interpolation(fFrame, m_lpVerticeInfo[dwNumber].fHeight)) return FALSE;
|
||||
m_lpVerticeInfo[dwNumber].fWidth *=m_Scale[0];
|
||||
m_lpVerticeInfo[dwNumber].fHeight *=m_Scale[0];
|
||||
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lpVerticeInfo[dwNumber].lColor)) return FALSE;
|
||||
|
||||
if(m_fTexSpeed)
|
||||
{
|
||||
if(fFrame == 100.0f)
|
||||
{
|
||||
m_lpVerticeInfo[dwNumber].fTexFrame = 15.0f;
|
||||
} else
|
||||
{
|
||||
float a = fFrame * m_fTexSpeed;
|
||||
m_lpVerticeInfo[dwNumber].fTexFrame = a - (((unsigned long)(a / 16)) * 16.0f);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
fread(&m_fPowerSeed, 4, 1, fp);
|
||||
fread(&m_fLifetime, 4, 1, fp);
|
||||
fread(&m_fLifetimeSeed, 4, 1, fp);
|
||||
|
||||
fread(&m_fRotation, 4, 1, fp);
|
||||
fread(&m_fTexSpeed, 4, 1, fp);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
fread(&m_dwVolumeType, 4, 1, fp); // 0 : None, 1 : Square, 2 : Circle
|
||||
fread(&m_fVolX, 4, 1, fp);
|
||||
fread(&m_fVolY, 4, 1, fp);
|
||||
fread(&m_fVolZ, 4, 1, fp);
|
||||
fread(&m_fRadius, 4, 1, fp);
|
||||
fread(&m_fInnerRadius, 4, 1, fp);
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fVolX *=m_Scale[0];
|
||||
m_fVolY *=m_Scale[0];
|
||||
m_fVolZ *=m_Scale[0];
|
||||
m_fRadius *=m_Scale[0];
|
||||
m_fInnerRadius *=m_Scale[0];
|
||||
}
|
||||
}
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
float fAmount;
|
||||
m_lstAmount.Load(fp, fAmount);
|
||||
m_lstAlpha.Load(fp, m_fAlpha);
|
||||
m_lstPower.Load(fp, m_fPower);
|
||||
m_lstAngle.Load(fp, m_fAngle);
|
||||
m_lstEForce.Load(fp, m_vecEForce);
|
||||
if(m_bWorldEffect) {
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fPower *=m_Scale[0];
|
||||
m_vecEForce.x *=m_Scale[0];
|
||||
m_vecEForce.y *=m_Scale[0];
|
||||
m_vecEForce.z *=m_Scale[0];
|
||||
}
|
||||
}
|
||||
m_lstDirection.Load(fp, m_quatDir);
|
||||
|
||||
// Scenario<69><6F> <20><><EFBFBD><EFBFBD>Ʈ
|
||||
m_lstWidth.Load(fp, m_fAlpha);
|
||||
m_lstHeight.Load(fp, m_fAlpha);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
}
|
||||
|
||||
void CX3DEffectParticle::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
fwrite(&m_fPowerSeed, 4, 1, fp);
|
||||
fwrite(&m_fLifetime, 4, 1, fp);
|
||||
fwrite(&m_fLifetimeSeed, 4, 1, fp);
|
||||
|
||||
fwrite(&m_fRotation, 4, 1, fp);
|
||||
fwrite(&m_fTexSpeed, 4, 1, fp);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
fwrite(&m_dwVolumeType, 4, 1, fp); // 0 : None, 1 : Square, 2 : Circle
|
||||
fwrite(&m_fVolX, 4, 1, fp);
|
||||
fwrite(&m_fVolY, 4, 1, fp);
|
||||
fwrite(&m_fVolZ, 4, 1, fp);
|
||||
fwrite(&m_fRadius, 4, 1, fp);
|
||||
fwrite(&m_fInnerRadius, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
|
||||
m_lstAmount.Save(fp);
|
||||
m_lstAlpha.Save(fp);
|
||||
m_lstPower.Save(fp);
|
||||
m_lstAngle.Save(fp);
|
||||
m_lstEForce.Save(fp);
|
||||
m_lstDirection.Save(fp);
|
||||
|
||||
// Scenario<69><6F> <20><><EFBFBD><EFBFBD>Ʈ
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
}
|
||||
114
Engine/Effect/X3DEffectParticle.h
Normal file
114
Engine/Effect/X3DEffectParticle.h
Normal file
@@ -0,0 +1,114 @@
|
||||
// X3DEffectParticle.h: interface for the CX3DEffectParticle class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_)
|
||||
#define AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
typedef struct _Particle
|
||||
{
|
||||
vector3 vecPos;
|
||||
vector3 vecVel;
|
||||
float fLifetime;
|
||||
float fMaxLife;
|
||||
float fTexFrame;
|
||||
|
||||
float fRotation;
|
||||
unsigned long dwRotationCount;
|
||||
float fWidth;
|
||||
float fHeight;
|
||||
color lColor;
|
||||
} Particle, *LPParticle;
|
||||
|
||||
class CX3DEffectParticle : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwMaxAmount;
|
||||
unsigned long m_dwDrawAmount;
|
||||
float m_fAlpha;
|
||||
float m_fPower;
|
||||
float m_fAngle;
|
||||
vector3 m_vecEForce;
|
||||
quaternion m_quatDir;
|
||||
|
||||
float m_fPowerSeed;
|
||||
float m_fLifetime;
|
||||
float m_fLifetimeSeed;
|
||||
|
||||
float m_fRotation;
|
||||
float m_fTexSpeed;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD>
|
||||
unsigned long m_dwVolumeType; // 0 : None, 1 : Square, 2 : Circle
|
||||
float m_fVolX;
|
||||
float m_fVolY;
|
||||
float m_fVolZ;
|
||||
float m_fRadius;
|
||||
float m_fInnerRadius;
|
||||
|
||||
// <20><>ƼŬ <20><><EFBFBD><EFBFBD> / <20><><EFBFBD><EFBFBD>
|
||||
LPParticle m_lpVerticeInfo;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
LPDIRECT3DINDEXBUFFER8 m_lpVerticeIndex;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstAmount;
|
||||
CKeyList<FloatKeyList> m_lstAlpha;
|
||||
CKeyList<FloatKeyList> m_lstPower;
|
||||
CKeyList<FloatKeyList> m_lstAngle;
|
||||
CKeyList<VectorKeyList> m_lstEForce;
|
||||
CKeyList<QuaternionKeyList> m_lstDirection;
|
||||
|
||||
// Scenario<69><6F> <20><><EFBFBD><EFBFBD>Ʈ
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
public:
|
||||
CX3DEffectParticle();
|
||||
virtual ~CX3DEffectParticle();
|
||||
|
||||
void SetVolumeNone(void);
|
||||
void SetVolumeSquare(float fVolX, float fVolY, float fVolZ);
|
||||
void SetVolumeCircle(float fRadius, float fInnerRadius);
|
||||
|
||||
void SetPowerSeed(float fPowerSeed) { m_fPowerSeed = fPowerSeed; }
|
||||
void SetLifetime(float fLifetime) { m_fLifetime = fLifetime; }
|
||||
void SetLifetimeSeed(float fLifetimeSeed) { m_fLifetimeSeed = fLifetimeSeed; }
|
||||
void SetRotation(float fRotation) { m_fRotation = fRotation; }
|
||||
void SetTexSpeed(float fTexSpeed) { m_fTexSpeed = fTexSpeed; }
|
||||
|
||||
vector3 GetEForce(void) { return m_vecEForce; }
|
||||
unsigned char GetMainAlpha(void) { return (unsigned char)(m_fAlpha * 255); }
|
||||
float GetAmount(float fFrame) { float temp; m_lstAmount.Interpolation(fFrame, temp); return temp;}
|
||||
float GetLifetime(void) { return m_fLifetime; }
|
||||
float GetPower(void) { return m_fPower; }
|
||||
float GetAngle(void) { return m_fAngle; }
|
||||
quaternion GetDirection(void) { return m_quatDir; }
|
||||
float GetWidth(float fFrame) { float temp; m_lstWidth.Interpolation(fFrame, temp); return temp; }
|
||||
float GetHeight(float fFrame) { float temp; m_lstHeight.Interpolation(fFrame, temp); return temp; }
|
||||
|
||||
unsigned char GetAlpha(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.a; }
|
||||
unsigned char GetRColor(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.r; }
|
||||
unsigned char GetGColor(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.g; }
|
||||
unsigned char GetBColor(float fFrame) { color temp; m_lstColor.InterpolationC(fFrame, temp); return temp.b; }
|
||||
|
||||
BOOL CreateParticle(LPParticle lpParticle);
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
|
||||
BOOL ParticleInterpolation(unsigned long dwNumber);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTPARTICLE_H__0750B6D9_11E2_41A9_BFEF_D92F0F1E0CC5__INCLUDED_)
|
||||
281
Engine/Effect/X3DEffectPlane.cpp
Normal file
281
Engine/Effect/X3DEffectPlane.cpp
Normal file
@@ -0,0 +1,281 @@
|
||||
// X3DEffectPlane.cpp: implementation of the CX3DEffectPlane class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectPlane.h"
|
||||
#include "SceneManager.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectPlane::CX3DEffectPlane()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectPlane::~CX3DEffectPlane()
|
||||
{
|
||||
//if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
//if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
if(m_lpVerticesBlend) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
else
|
||||
m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
if(CSceneManager::ms_pBufferPools)
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
else
|
||||
m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectPlane::CreateBuffer(void)
|
||||
{
|
||||
if(m_lpVerticesBlend) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVerticesBlend);
|
||||
//m_lpVerticesBlend->Release();
|
||||
m_lpVerticesBlend = NULL;
|
||||
}
|
||||
if(m_lpVertices) {
|
||||
CSceneManager::ms_pBufferPools->UnRef(Caldron::Scene::D3DBUFFEROBJ_VERTEX,m_lpVertices);
|
||||
// m_lpVertices->Release();
|
||||
m_lpVertices = NULL;
|
||||
}
|
||||
// m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
// m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,true);
|
||||
m_lpVertices = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
m_lpVerticesBlend = CSceneManager::ms_pBufferPools->GetVertexBuffer(4 * sizeof(LVertex),LVERTEXFVF,false);
|
||||
|
||||
/*
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( 4 * sizeof(LVertex), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, LVERTEXFVF, D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
if(quatAxis) { z3d::MatrixRotationQuaternion(matWorld, (*quatAxis)); }
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
vector3 *vecTemp = ((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
matWorld._41 = vecTemp->x;
|
||||
matWorld._42 = vecTemp->y;
|
||||
matWorld._43 = vecTemp->z;
|
||||
}
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CX3DEffectPlane::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
|
||||
if(!m_lstWidth.Interpolation(fFrame, m_fWidth)) return FALSE;
|
||||
if(!m_lstHeight.Interpolation(fFrame, m_fHeight)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
if(m_bVisibility) {
|
||||
|
||||
|
||||
{
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
// if(FAILED( m_lpVertices->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
// if(FAILED( m_lpVerticesBlend->Lock( 0, 4 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD | D3DLOCK_NOSYSLOCK) ) ) return FALSE;
|
||||
if(FAILED( m_lpVertices->Lock( 0, 0, (unsigned char **)&pVertices, 0) ) ) return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, 0, (unsigned char **)&pVerticesBlend, 0) ) ) return FALSE;
|
||||
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
fEndU = f1 + 0.25f;
|
||||
fEndV = f2 + 0.25f;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndBU = f1 + 0.25f;
|
||||
fEndBV = f2 + 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU;
|
||||
fEndBV = fEndV = m_fTileV;
|
||||
}
|
||||
|
||||
pVertices[0].v = vector3(-(m_fWidth / 2), 0, (m_fHeight / 2));
|
||||
pVertices[1].v = vector3( (m_fWidth / 2), 0, (m_fHeight / 2));
|
||||
pVertices[2].v = vector3(-(m_fWidth / 2), 0, -(m_fHeight / 2));
|
||||
pVertices[3].v = vector3( (m_fWidth / 2), 0, -(m_fHeight / 2));
|
||||
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, m_quatAxis);
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, m_quatAxis);
|
||||
|
||||
/* quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
if(quatAxis)
|
||||
{
|
||||
z3d::VectorRotate(pVertices[0].v, pVertices[0].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[1].v, pVertices[1].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[2].v, pVertices[2].v, (*quatAxis));
|
||||
z3d::VectorRotate(pVertices[3].v, pVertices[3].v, (*quatAxis));
|
||||
}
|
||||
|
||||
pVerticesBlend[0].v = pVertices[0].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[1].v = pVertices[1].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[2].v = pVertices[2].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());
|
||||
pVerticesBlend[3].v = pVertices[3].v += m_vecCenter + (*((CX3DEffect *)m_lpLocalEffect)->GetCenter());*/
|
||||
pVerticesBlend[0].v = pVertices[0].v += m_vecCenter;
|
||||
pVerticesBlend[1].v = pVertices[1].v += m_vecCenter;
|
||||
pVerticesBlend[2].v = pVertices[2].v += m_vecCenter;
|
||||
pVerticesBlend[3].v = pVertices[3].v += m_vecCenter;
|
||||
|
||||
pVertices[0].tu = fStartU; pVertices[0].tv = fStartV;
|
||||
pVertices[1].tu = fEndU; pVertices[1].tv = fStartV;
|
||||
pVertices[2].tu = fStartU; pVertices[2].tv = fEndV;
|
||||
pVertices[3].tu = fEndU; pVertices[3].tv = fEndV;
|
||||
pVerticesBlend[0].tu = fStartBU; pVerticesBlend[0].tv = fStartBV;
|
||||
pVerticesBlend[1].tu = fEndBU; pVerticesBlend[1].tv = fStartBV;
|
||||
pVerticesBlend[2].tu = fStartBU; pVerticesBlend[2].tv = fEndBV;
|
||||
pVerticesBlend[3].tu = fEndBU; pVerticesBlend[3].tv = fEndBV;
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
pVertices[0].diff = pVertices[1].diff = pVertices[2].diff = pVertices[3].diff = m_lColor;
|
||||
pVerticesBlend[0].diff = pVerticesBlend[1].diff = pVerticesBlend[2].diff = pVerticesBlend[3].diff = m_lColor;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[3].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVertices[0].diff.a = pVertices[1].diff.a = pVertices[2].diff.a = pVertices[3].diff.a;
|
||||
pVerticesBlend[3].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
pVerticesBlend[0].diff.a = pVerticesBlend[1].diff.a = pVerticesBlend[2].diff.a = pVerticesBlend[3].diff.a;
|
||||
}
|
||||
pVertices[0].spec = pVertices[1].spec = pVertices[2].spec = pVertices[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].spec = pVerticesBlend[1].spec = pVerticesBlend[2].spec = pVerticesBlend[3].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstWidth.Load(fp, m_fWidth);
|
||||
m_lstHeight.Load(fp, m_fHeight);
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
|
||||
m_fWidth *=m_Scale[0];
|
||||
m_fHeight *=m_Scale[0];
|
||||
}
|
||||
}
|
||||
|
||||
void CX3DEffectPlane::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
m_lstColor.Save(fp);
|
||||
m_lstWidth.Save(fp);
|
||||
m_lstHeight.Save(fp);
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
69
Engine/Effect/X3DEffectPlane.h
Normal file
69
Engine/Effect/X3DEffectPlane.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// X3DEffectPlane.h: interface for the CX3DEffectPlane class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_)
|
||||
#define AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectPlane : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
float m_fWidth;
|
||||
float m_fHeight;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstWidth;
|
||||
CKeyList<FloatKeyList> m_lstHeight;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectPlane();
|
||||
virtual ~CX3DEffectPlane();
|
||||
|
||||
void SetWidth(float fWidth) { m_fWidth = fWidth; }
|
||||
float GetWidth(void) { return m_fWidth; }
|
||||
void SetHeight(float fHeight) { m_fHeight = fHeight; }
|
||||
float GetHeight(void) { return m_fHeight; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer(void);
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTPLANE_H__0FB11223_90D1_47D3_9948_08C94D138879__INCLUDED_)
|
||||
473
Engine/Effect/X3DEffectSphere.cpp
Normal file
473
Engine/Effect/X3DEffectSphere.cpp
Normal file
@@ -0,0 +1,473 @@
|
||||
// X3DEffectSphere.cpp: implementation of the CX3DEffectSphere class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "X3DEffect.h"
|
||||
#include "X3DEffectSphere.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CX3DEffectSphere::CX3DEffectSphere()
|
||||
{
|
||||
m_dwSrcBlending = D3DBLEND_SRCALPHA;
|
||||
m_dwDestBlending = D3DBLEND_ONE;
|
||||
|
||||
m_bTexAni = FALSE;
|
||||
|
||||
m_lpVertices = NULL;
|
||||
m_lpVerticesBlend = NULL;
|
||||
m_lpVerticeIndex = NULL;
|
||||
}
|
||||
|
||||
CX3DEffectSphere::~CX3DEffectSphere()
|
||||
{
|
||||
if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Create(unsigned long dwStartFrame, unsigned long dwEndFrame)
|
||||
{
|
||||
m_dwStartFrame = dwStartFrame;
|
||||
m_dwEndFrame = dwEndFrame;
|
||||
}
|
||||
|
||||
BOOL CX3DEffectSphere::CreateBuffer()
|
||||
{
|
||||
if(m_lpVerticeIndex) { m_lpVerticeIndex->Release(); m_lpVerticeIndex = NULL; }
|
||||
if(m_lpVerticesBlend) { m_lpVerticesBlend->Release(); m_lpVerticesBlend = NULL; }
|
||||
if(m_lpVertices) { m_lpVertices->Release(); m_lpVertices = NULL; }
|
||||
|
||||
if(m_bUpperVis && m_bLowerVis) m_dwTotalSegment = m_dwSegment * 2;
|
||||
else if(m_bUpperVis || m_bLowerVis) m_dwTotalSegment = m_dwSegment;
|
||||
else return FALSE;
|
||||
|
||||
m_lpD3DDevice->CreateVertexBuffer( (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVertices );
|
||||
m_lpD3DDevice->CreateVertexBuffer( (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), D3DUSAGE_WRITEONLY | D3DUSAGE_DYNAMIC, LVERTEXFVF,
|
||||
D3DPOOL_DEFAULT, &m_lpVerticesBlend );
|
||||
m_lpD3DDevice->CreateIndexBuffer( m_dwSidePlane * m_dwTotalSegment * 2 * 3 * sizeof(unsigned short), D3DUSAGE_WRITEONLY, D3DFMT_INDEX16,
|
||||
D3DPOOL_MANAGED, &m_lpVerticeIndex);
|
||||
|
||||
if(m_dwTotalSegment == m_dwSegment)
|
||||
{
|
||||
m_dwNumVertex = (m_dwSidePlane + 1) * (m_dwSegment + 1);
|
||||
} else
|
||||
{
|
||||
m_dwNumVertex = (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2;
|
||||
}
|
||||
m_dwPrimitive = m_dwSidePlane * m_dwTotalSegment * 2;
|
||||
|
||||
unsigned short *pVerticeIndex;
|
||||
m_lpVerticeIndex->Lock(0, m_dwSidePlane * m_dwTotalSegment * 2 * 3 * sizeof(unsigned short), (unsigned char **)&pVerticeIndex, 0);
|
||||
|
||||
unsigned long i, j, ti = 0, tv = 0;
|
||||
unsigned long temp, t1, t2;
|
||||
|
||||
// Upper
|
||||
if(m_bUpperVis)
|
||||
{
|
||||
for(j = 0; j < m_dwSegment; j++)
|
||||
{
|
||||
for(i = 0; i < m_dwSidePlane; i++)
|
||||
{
|
||||
temp = j * (m_dwSidePlane * 6) + i * 6;
|
||||
t1 = (m_dwSidePlane + 1) * j + i;
|
||||
t2 = (m_dwSidePlane + 1) * (j + 1) + i;
|
||||
if(m_bUpperUp)
|
||||
{
|
||||
// Up
|
||||
pVerticeIndex[temp + 0] = t1 + 0;
|
||||
pVerticeIndex[temp + 1] = t1 + 1;
|
||||
pVerticeIndex[temp + 2] = t2;
|
||||
|
||||
pVerticeIndex[temp + 3] = t1 + 1;
|
||||
pVerticeIndex[temp + 4] = t2 + 1;
|
||||
pVerticeIndex[temp + 5] = t2;
|
||||
} else
|
||||
{
|
||||
// Center
|
||||
pVerticeIndex[temp + 0] = t1 + 0;
|
||||
pVerticeIndex[temp + 1] = t2;
|
||||
pVerticeIndex[temp + 2] = t1 + 1;
|
||||
|
||||
pVerticeIndex[temp + 3] = t2;
|
||||
pVerticeIndex[temp + 4] = t2 + 1;
|
||||
pVerticeIndex[temp + 5] = t1 + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ti = m_dwSidePlane * m_dwSegment * 2 * 3;
|
||||
tv = (m_dwSidePlane + 1) * (m_dwSegment + 1);
|
||||
}
|
||||
|
||||
// Lower
|
||||
if(m_bLowerVis)
|
||||
{
|
||||
for(j = 0; j < m_dwSegment; j++)
|
||||
{
|
||||
for(i = 0; i < m_dwSidePlane; i++)
|
||||
{
|
||||
temp = j * (m_dwSidePlane * 6) + i * 6 + ti;
|
||||
t1 = (m_dwSidePlane + 1) * j + i;
|
||||
t2 = (m_dwSidePlane + 1) * (j + 1) + i;
|
||||
if(m_bLowerUp)
|
||||
{
|
||||
// Up
|
||||
pVerticeIndex[temp + 0] = tv + t1 + 0;
|
||||
pVerticeIndex[temp + 1] = tv + t2;
|
||||
pVerticeIndex[temp + 2] = tv + t1 + 1;
|
||||
|
||||
pVerticeIndex[temp + 3] = tv + t2;
|
||||
pVerticeIndex[temp + 4] = tv + t2 + 1;
|
||||
pVerticeIndex[temp + 5] = tv + t1 + 1;
|
||||
} else
|
||||
{
|
||||
// Center
|
||||
pVerticeIndex[temp + 0] = tv + t1 + 0;
|
||||
pVerticeIndex[temp + 1] = tv + t1 + 1;
|
||||
pVerticeIndex[temp + 2] = tv + t2;
|
||||
|
||||
pVerticeIndex[temp + 3] = tv + t1 + 1;
|
||||
pVerticeIndex[temp + 4] = tv + t2 + 1;
|
||||
pVerticeIndex[temp + 5] = tv + t2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
m_lpVerticeIndex->Unlock();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Render(void)
|
||||
{
|
||||
if(!m_bVisibility)
|
||||
return;
|
||||
if(m_lpVertices == NULL) return;
|
||||
|
||||
matrix matWorld;
|
||||
matWorld.MakeIdent();
|
||||
quaternion *quatAxis = ((CX3DEffect *)m_lpLocalEffect)->GetAxis();
|
||||
if(quatAxis) { z3d::MatrixRotationQuaternion(matWorld, (*quatAxis)); }
|
||||
if(((CX3DEffect *)m_lpLocalEffect)->GetCenter())
|
||||
{
|
||||
vector3 *vecTemp = ((CX3DEffect *)m_lpLocalEffect)->GetCenter();
|
||||
matWorld._41 = vecTemp->x;
|
||||
matWorld._42 = vecTemp->y;
|
||||
matWorld._43 = vecTemp->z;
|
||||
}
|
||||
m_lpD3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX *)&matWorld);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetTexture(0, GetTexture());
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, m_dwSrcBlending);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, m_dwDestBlending);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVertices, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwNumVertex, 0, m_dwPrimitive);
|
||||
|
||||
if(m_bTexAni)
|
||||
{
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_ZWRITEENABLE,FALSE);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
|
||||
m_lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);
|
||||
m_lpD3DDevice->SetStreamSource(0, m_lpVerticesBlend, sizeof(LVertex));
|
||||
m_lpD3DDevice->SetVertexShader(LVERTEXFVF);
|
||||
m_lpD3DDevice->SetIndices(m_lpVerticeIndex, 0);
|
||||
m_lpD3DDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, m_dwNumVertex, 0, m_dwPrimitive);
|
||||
}/**/
|
||||
}
|
||||
|
||||
BOOL CX3DEffectSphere::Interpolation(float fFrame)
|
||||
{
|
||||
|
||||
|
||||
if(m_lpVertices == NULL) return FALSE;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(!m_lstCenter.Interpolation(fFrame, m_vecCenter)) return FALSE;
|
||||
if(!m_lstAxis.InterpolationQ(fFrame, m_quatAxis)) return FALSE;
|
||||
if(!m_lstHeightFactor.Interpolation(fFrame, m_fHeightFactor)) return FALSE;
|
||||
if(!m_lstRadius.Interpolation(fFrame, m_fRadius)) return FALSE;
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fRadius *= m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
if(!m_lstUpperFactor.Interpolation(fFrame, m_fUpperFactor)) return FALSE;
|
||||
if(!m_lstLowerFactor.Interpolation(fFrame, m_fLowerFactor)) return FALSE;
|
||||
if(!m_lstColor.InterpolationC(fFrame, m_lColor)) return FALSE;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
if(!m_lstTexFrame.Interpolation(fFrame, m_fTexFrame)) return FALSE;
|
||||
} else
|
||||
{
|
||||
if(!m_lstStartU.Interpolation(fFrame, m_fStartU)) return FALSE;
|
||||
if(!m_lstStartV.Interpolation(fFrame, m_fStartV)) return FALSE;
|
||||
if(!m_lstTileU.Interpolation(fFrame, m_fTileU)) return FALSE;
|
||||
if(!m_lstTileV.Interpolation(fFrame, m_fTileV)) return FALSE;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
if(m_bVisibility) {
|
||||
|
||||
{
|
||||
LVertex *pVertices, *pVerticesBlend;
|
||||
if(FAILED( m_lpVertices->Lock( 0, (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), (unsigned char **)&pVertices, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
if(FAILED( m_lpVerticesBlend->Lock( 0, (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2 * sizeof(LVertex), (unsigned char **)&pVerticesBlend, D3DLOCK_DISCARD ) ) )
|
||||
return FALSE;
|
||||
|
||||
unsigned long i, tempi, j, t1, tv = 0;
|
||||
float degree, hdegree, height, hcos;
|
||||
float divangle = FLOAT_PHI * 2.0f / m_dwSidePlane;
|
||||
float f1, f2;
|
||||
float fStartU, fStartV, fEndU, fEndV;
|
||||
float fStartBU, fStartBV, fEndBU, fEndBV;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
f1 = (((long)m_fTexFrame) % 4) * 0.25;
|
||||
f2 = (((long)m_fTexFrame) / 4) * 0.25;
|
||||
fStartU = f1;
|
||||
fStartV = f2;
|
||||
|
||||
f1 = (((long)ceilf(m_fTexFrame)) % 4) * 0.25;
|
||||
f2 = (((long)ceilf(m_fTexFrame)) / 4) * 0.25;
|
||||
fStartBU = f1;
|
||||
fStartBV = f2;
|
||||
fEndU = fEndBU = 0.25f;
|
||||
fEndV = fEndBV = 0.25f;
|
||||
} else
|
||||
{
|
||||
fStartBU = fStartU = m_fStartU;
|
||||
fStartBV = fStartV = m_fStartV;
|
||||
fEndBU = fEndU = m_fTileU - fStartBU;
|
||||
fEndBV = fEndV = m_fTileV - fStartBV;
|
||||
}
|
||||
|
||||
float fHEV = fEndV / 2.0f, fSV = fHEV + fStartV, fDSV = fSV * 2.0f;
|
||||
float fHEBV = fEndBV / 2.0f, fSBV = fHEBV + fStartBV, fDSBV = fSBV * 2.0f;
|
||||
float fSegTemp, fSegBTemp;
|
||||
if(m_bUpperVis)
|
||||
{
|
||||
for(j = 0; j <= m_dwSegment; j++)
|
||||
{
|
||||
if(m_bUpperUp)
|
||||
hdegree = (FLOAT_PHI / 2.0f) - ((j * FLOAT_PHI) / (2.0f * m_dwSegment) * m_fUpperFactor);
|
||||
else
|
||||
hdegree = ((j * FLOAT_PHI) / (2.0f * m_dwSegment)) * m_fUpperFactor;
|
||||
height = m_fRadius * m_fHeightFactor * sinf(hdegree);
|
||||
hcos = cosf(hdegree);
|
||||
fSegTemp = fHEV * j / m_dwSegment;
|
||||
fSegBTemp = fHEBV * j / m_dwSegment;
|
||||
|
||||
for(i = 0; i <= m_dwSidePlane; i++)
|
||||
{
|
||||
if(i == m_dwSidePlane) tempi = 0; else tempi = i;
|
||||
|
||||
degree = tempi * divangle;
|
||||
t1 = (m_dwSidePlane + 1) * j + i;
|
||||
|
||||
pVertices[t1].v = vector3(m_fRadius * cosf(degree) * hcos, height, m_fRadius * sinf(degree) * hcos);
|
||||
z3d::VectorRotate(pVertices[t1].v, pVertices[t1].v, m_quatAxis);
|
||||
pVertices[t1].v += m_vecCenter;
|
||||
pVerticesBlend[t1].v = pVertices[t1].v;
|
||||
|
||||
pVertices[t1].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[t1].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
if(m_bUpperUp)
|
||||
{
|
||||
if(m_bUpperTex)
|
||||
{
|
||||
pVertices[t1].tv = fStartV + fSegTemp * m_fUpperFactor;
|
||||
pVerticesBlend[t1].tv = fStartBV + fSegBTemp * m_fUpperFactor;
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fStartV + fSegTemp;
|
||||
pVerticesBlend[t1].tv = fStartBV + fSegBTemp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_bUpperTex)
|
||||
{
|
||||
pVertices[t1].tv = (fStartV + fSV) - ((fStartV + fSegTemp) * m_fUpperFactor);
|
||||
pVerticesBlend[t1].tv = (fStartBV + fSBV) - ((fStartBV + fSegBTemp) * m_fUpperFactor);
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fSV - fSegTemp;
|
||||
pVerticesBlend[t1].tv = fSBV - fSegBTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tv = (m_dwSidePlane + 1) * (m_dwSegment + 1);
|
||||
}
|
||||
|
||||
if(m_bLowerVis)
|
||||
{
|
||||
for(j = 0; j <= m_dwSegment; j++)
|
||||
{
|
||||
if(m_bLowerUp)
|
||||
hdegree = (FLOAT_PHI / 2.0f) - ((j * FLOAT_PHI) / (2.0f * m_dwSegment) * m_fLowerFactor);
|
||||
else
|
||||
hdegree = ((j * FLOAT_PHI) / (2.0f * m_dwSegment)) * m_fLowerFactor;
|
||||
height = m_fRadius * m_fHeightFactor * sinf(hdegree);
|
||||
hcos = cosf(hdegree);
|
||||
fSegTemp = fHEV * j / m_dwSegment;
|
||||
fSegBTemp = fHEBV * j / m_dwSegment;
|
||||
|
||||
for(i = 0; i <= m_dwSidePlane; i++)
|
||||
{
|
||||
if(i == m_dwSidePlane) tempi = 0; else tempi = i;
|
||||
|
||||
degree = tempi * divangle;
|
||||
t1 = tv + (m_dwSidePlane + 1) * j + i;
|
||||
|
||||
pVertices[t1].v = vector3(m_fRadius * cosf(degree) * hcos, -height, m_fRadius * sinf(degree) * hcos);
|
||||
z3d::VectorRotate(pVertices[t1].v, pVertices[t1].v, m_quatAxis);
|
||||
pVertices[t1].v += m_vecCenter;
|
||||
pVerticesBlend[t1].v = pVertices[t1].v;
|
||||
|
||||
pVertices[t1].tu = fStartU + fEndU * (float)i / m_dwSidePlane;
|
||||
pVerticesBlend[t1].tu = fStartBU + fEndBU * (float)i / m_dwSidePlane;
|
||||
if(m_bLowerUp)
|
||||
{
|
||||
if(m_bLowerTex)
|
||||
{
|
||||
pVertices[t1].tv = fDSV - ((fStartV + fSegTemp) * m_fLowerFactor);
|
||||
pVerticesBlend[t1].tv = fDSBV - ((fStartBV + fSegBTemp) * m_fLowerFactor);
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fDSV - (fStartV + fSegTemp);
|
||||
pVerticesBlend[t1].tv = fDSBV - (fStartBV + fSegBTemp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_bLowerTex)
|
||||
{
|
||||
pVertices[t1].tv = fSV + fSegTemp * m_fLowerFactor;
|
||||
pVerticesBlend[t1].tv = fSBV + fSegBTemp * m_fLowerFactor;
|
||||
} else
|
||||
{
|
||||
pVertices[t1].tv = fSV + fSegTemp;
|
||||
pVerticesBlend[t1].tv = fSBV + fSegBTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pVertices[0].diff = m_lColor;
|
||||
pVertices[0].spec = color(0xFF, 0xFF, 0xFF, 0xFF);
|
||||
pVerticesBlend[0].diff =pVertices[0].diff;
|
||||
pVerticesBlend[0].spec =pVertices[0].spec;
|
||||
if(m_bTexAni)
|
||||
{
|
||||
pVertices[0].diff.a *= (floorf(m_fTexFrame + 1.0f) - m_fTexFrame);
|
||||
pVerticesBlend[0].diff.a *= (m_fTexFrame - floorf(m_fTexFrame));
|
||||
}
|
||||
|
||||
if(m_dwTotalSegment == m_dwSegment)
|
||||
{
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * (m_dwSegment + 1); i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
} else
|
||||
{
|
||||
for(i = 1; i < (m_dwSidePlane + 1) * (m_dwSegment + 1) * 2; i++)
|
||||
{
|
||||
pVertices[i].diff = pVertices[0].diff;
|
||||
pVertices[i].spec = pVertices[0].spec;
|
||||
pVerticesBlend[i].diff = pVerticesBlend[0].diff;
|
||||
pVerticesBlend[i].spec = pVerticesBlend[0].spec;
|
||||
}
|
||||
}
|
||||
m_lpVerticesBlend->Unlock();
|
||||
m_lpVertices->Unlock();
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Load(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fread(&m_bTexAni, 4, 1, fp);
|
||||
fread(&m_dwSrcBlending, 4, 1, fp);
|
||||
fread(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Load(fp, m_quatAxis);
|
||||
m_lstCenter.Load(fp, m_vecCenter);
|
||||
|
||||
fread(&m_dwSidePlane, 4, 1, fp);
|
||||
fread(&m_dwSegment, 4, 1, fp);
|
||||
|
||||
fread(&m_bUpperTex, 4, 1, fp);
|
||||
fread(&m_bUpperUp, 4, 1, fp);
|
||||
fread(&m_bUpperVis, 4, 1, fp);
|
||||
fread(&m_bLowerTex, 4, 1, fp);
|
||||
fread(&m_bLowerUp, 4, 1, fp);
|
||||
fread(&m_bLowerVis, 4, 1, fp);
|
||||
|
||||
m_lstColor.Load(fp, m_lColor);
|
||||
m_lstHeightFactor.Load(fp, m_fHeightFactor);
|
||||
m_lstRadius.Load(fp, m_fRadius);
|
||||
if(m_Scale[0] != 1.0f) {
|
||||
m_fRadius *= m_Scale[0];
|
||||
|
||||
m_vecCenter.x *=m_Scale[0];
|
||||
m_vecCenter.z *=m_Scale[0];
|
||||
m_vecCenter.y *=(m_Scale[0]);
|
||||
}
|
||||
m_lstUpperFactor.Load(fp, m_fUpperFactor);
|
||||
m_lstLowerFactor.Load(fp, m_fLowerFactor);
|
||||
|
||||
m_lstStartU.Load(fp, m_fStartU);
|
||||
m_lstStartV.Load(fp, m_fStartV);
|
||||
m_lstTileU.Load(fp, m_fTileU);
|
||||
m_lstTileV.Load(fp, m_fTileV);
|
||||
m_lstTexFrame.Load(fp, m_fTexFrame);
|
||||
}
|
||||
|
||||
void CX3DEffectSphere::Save(FILE *fp, const char *strOriginalPath)
|
||||
{
|
||||
fwrite(&m_bTexAni, 4, 1, fp);
|
||||
fwrite(&m_dwSrcBlending, 4, 1, fp);
|
||||
fwrite(&m_dwDestBlending, 4, 1, fp);
|
||||
|
||||
m_lstAxis.Save(fp);
|
||||
m_lstCenter.Save(fp);
|
||||
|
||||
fwrite(&m_dwSidePlane, 4, 1, fp);
|
||||
fwrite(&m_dwSegment, 4, 1, fp);
|
||||
|
||||
fwrite(&m_bUpperTex, 4, 1, fp);
|
||||
fwrite(&m_bUpperUp, 4, 1, fp);
|
||||
fwrite(&m_bUpperVis, 4, 1, fp);
|
||||
fwrite(&m_bLowerTex, 4, 1, fp);
|
||||
fwrite(&m_bLowerUp, 4, 1, fp);
|
||||
fwrite(&m_bLowerVis, 4, 1, fp);
|
||||
|
||||
m_lstColor.Save(fp);
|
||||
m_lstHeightFactor.Save(fp);
|
||||
m_lstRadius.Save(fp);
|
||||
m_lstUpperFactor.Save(fp);
|
||||
m_lstLowerFactor.Save(fp);
|
||||
|
||||
m_lstStartU.Save(fp);
|
||||
m_lstStartV.Save(fp);
|
||||
m_lstTileU.Save(fp);
|
||||
m_lstTileV.Save(fp);
|
||||
m_lstTexFrame.Save(fp);
|
||||
}
|
||||
107
Engine/Effect/X3DEffectSphere.h
Normal file
107
Engine/Effect/X3DEffectSphere.h
Normal file
@@ -0,0 +1,107 @@
|
||||
// X3DEffectSphere.h: interface for the CX3DEffectSphere class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_)
|
||||
#define AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "X3DEffectBase.h"
|
||||
|
||||
class CX3DEffectSphere : public CX3DEffectBase
|
||||
{
|
||||
protected:
|
||||
unsigned long m_dwSegment, m_dwTotalSegment;
|
||||
unsigned long m_dwSidePlane;
|
||||
unsigned long m_dwPrimitive, m_dwNumVertex;
|
||||
float m_fHeightFactor;
|
||||
float m_fRadius;
|
||||
|
||||
BOOL m_bUpperVis;
|
||||
BOOL m_bUpperUp;
|
||||
BOOL m_bUpperTex;
|
||||
float m_fUpperFactor;
|
||||
BOOL m_bLowerVis;
|
||||
BOOL m_bLowerUp;
|
||||
BOOL m_bLowerTex;
|
||||
float m_fLowerFactor;
|
||||
|
||||
float m_fTileU;
|
||||
float m_fTileV;
|
||||
float m_fStartU;
|
||||
float m_fStartV;
|
||||
float m_fTexFrame;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVertices;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_lpVerticesBlend;
|
||||
LPDIRECT3DINDEXBUFFER8 m_lpVerticeIndex;
|
||||
|
||||
public:
|
||||
CKeyList<FloatKeyList> m_lstHeightFactor;
|
||||
CKeyList<FloatKeyList> m_lstRadius;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstUpperFactor;
|
||||
CKeyList<FloatKeyList> m_lstLowerFactor;
|
||||
|
||||
CKeyList<FloatKeyList> m_lstTileU;
|
||||
CKeyList<FloatKeyList> m_lstTileV;
|
||||
CKeyList<FloatKeyList> m_lstStartU;
|
||||
CKeyList<FloatKeyList> m_lstStartV;
|
||||
CKeyList<FloatKeyList> m_lstTexFrame;
|
||||
|
||||
public:
|
||||
CX3DEffectSphere();
|
||||
virtual ~CX3DEffectSphere();
|
||||
|
||||
void SetSegment(unsigned long dwSegment) { m_dwSegment = dwSegment; }
|
||||
unsigned long GetSegment(void) { return m_dwSegment; }
|
||||
void SetSidePlane(unsigned long dwSidePlane) { m_dwSidePlane = dwSidePlane * 4; }
|
||||
unsigned long GetSidePlane(void) { return m_dwSidePlane; }
|
||||
|
||||
void SetUpperVis(BOOL bUpperVis) { m_bUpperVis = bUpperVis; }
|
||||
BOOL GetUpperVis(void) { return m_bUpperVis; }
|
||||
void SetUpperUp(BOOL bUpperUp) { m_bUpperUp = bUpperUp; }
|
||||
BOOL GetUpperUp(void) { return m_bUpperUp; }
|
||||
void SetUpperTex(BOOL bUpperTex) { m_bUpperTex = bUpperTex; }
|
||||
BOOL GetUpperTex(void) { return m_bUpperTex; }
|
||||
void SetLowerVis(BOOL bLowerVis) { m_bLowerVis = bLowerVis; }
|
||||
BOOL GetLowerVis(void) { return m_bLowerVis; }
|
||||
void SetLowerUp(BOOL bLowerUp) { m_bLowerUp = bLowerUp; }
|
||||
BOOL GetLowerUp(void) { return m_bLowerUp; }
|
||||
void SetLowerTex(BOOL bLowerTex) { m_bLowerTex = bLowerTex; }
|
||||
BOOL GetLowerTex(void) { return m_bLowerTex; }
|
||||
|
||||
void SetRadius(float fRadius) { m_fRadius = fRadius; }
|
||||
float GetRadius(void) { return m_fRadius; }
|
||||
void SetHeightFactor(float fHeightFactor) { m_fHeightFactor = fHeightFactor; }
|
||||
float GetHeightFactor(void) { return m_fHeightFactor; }
|
||||
void SetUpperFactor(float fUpperFactor) { m_fUpperFactor = fUpperFactor; }
|
||||
float GetUpperFactor(void) { return m_fUpperFactor; }
|
||||
void SetLowerFactor(float fLowerFactor) { m_fLowerFactor = fLowerFactor; }
|
||||
float GetLowerFactor(void) { return m_fLowerFactor; }
|
||||
|
||||
void SetTileU(float fTileU) { m_fTileU = fTileU; }
|
||||
float GetTileU(void) { return m_fTileU; }
|
||||
void SetTileV(float fTileV) { m_fTileV = fTileV; }
|
||||
float GetTileV(void) { return m_fTileV; }
|
||||
|
||||
void SetStartU(float fStartU) { m_fStartU = fStartU; }
|
||||
float GetStartU(void) { return m_fStartU; }
|
||||
void SetStartV(float fStartV) { m_fStartV = fStartV; }
|
||||
float GetStartV(void) { return m_fStartV; }
|
||||
|
||||
void SetTexFrame(float fTexFrame) { m_fTexFrame = fTexFrame; }
|
||||
float GetTexFrame(void) { return m_fTexFrame; }
|
||||
|
||||
void Create(unsigned long dwStartFrame, unsigned long dwEndFrame);
|
||||
BOOL CreateBuffer();
|
||||
void Render(void);
|
||||
BOOL Interpolation(float fFrame);
|
||||
void Load(FILE *fp, const char *strOriginalPath = NULL);
|
||||
void Save(FILE *fp, const char *strOriginalPath = NULL);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_X3DEFFECTSPHERE_H__DEFBF05C_A2DA_46B4_968C_1706C124EA75__INCLUDED_)
|
||||
18
Engine/SoundLib/Common.h
Normal file
18
Engine/SoundLib/Common.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
#pragma warning(disable:4786)
|
||||
#pragma warning(disable:4251)
|
||||
#pragma warning(disable:4503)
|
||||
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <math.h>
|
||||
#include <process.h>
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#endif //__COMMON_H__
|
||||
88
Engine/SoundLib/DefineSound.h
Normal file
88
Engine/SoundLib/DefineSound.h
Normal file
@@ -0,0 +1,88 @@
|
||||
#ifndef DEFINESOUND_H__
|
||||
#define DEFINESOUND_H__
|
||||
|
||||
#include "Common.h"
|
||||
#include <math.h>
|
||||
#include <dsound.h>
|
||||
|
||||
//====================================
|
||||
// Sound Property
|
||||
//====================================
|
||||
#define VOLUME_MIN 0.0f
|
||||
//#define VOLUME_MIN 0.0001f
|
||||
#define VOLUME_MAX 1.0f
|
||||
#define PAN_LEFT -1.0f
|
||||
#define PAN_CENTER 0.0f
|
||||
#define PAN_RIGHT 1.0f
|
||||
#define PITCH_ORIGINAL 1.0f
|
||||
#define MODE_NORMAL 0x00000000
|
||||
#define MODE_HEADRELATIVE 0x00000001
|
||||
#define MODE_DISABLE 0x00000002
|
||||
|
||||
//====================================
|
||||
// Sound SampleRate
|
||||
//====================================
|
||||
#define SOUND_SAMPLE_11k 11025
|
||||
#define SOUND_SAMPLE_22k 22050
|
||||
#define SOUND_SAMPLE_44k 44100
|
||||
|
||||
//====================================
|
||||
// 3DSound Algorithm
|
||||
//====================================
|
||||
#define SOUND_ALGORITHM_NO DS3DALG_NO_VIRTUALIZATION
|
||||
#define SOUND_ALGORITHM_FULL DS3DALG_HRTF_FULL
|
||||
#define SOUND_ALGORITHM_LIGHT DS3DALG_HRTF_LIGHT
|
||||
|
||||
//====================================
|
||||
// Sound Creation Flag
|
||||
//====================================
|
||||
#define SOUND_FLAG_3D DSBCAPS_CTRL3D|DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_CTRLVOLUME|DSBCAPS_MUTE3DATMAXDISTANCE
|
||||
#define SOUND_FLAG_2D DSBCAPS_CTRLVOLUME|DSBCAPS_GETCURRENTPOSITION2
|
||||
|
||||
//====================================
|
||||
// Macro
|
||||
//====================================
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
|
||||
//====================================
|
||||
// Util Function
|
||||
//====================================
|
||||
static int LinearToLogVol(double fLevel)
|
||||
{
|
||||
// Clamp the value
|
||||
if(fLevel <= 0.0f)
|
||||
return DSBVOLUME_MIN;
|
||||
else if(fLevel >= 1.0f)
|
||||
return 0;
|
||||
return (long) (-2000.0 * log10(1.0f / fLevel));
|
||||
}
|
||||
|
||||
static float LogToLinearVol(int iLevel)
|
||||
{
|
||||
// Clamp the value
|
||||
if(iLevel <= -9600)
|
||||
return 0.0f;
|
||||
else if(iLevel >= 0)
|
||||
return 1.0f;
|
||||
return pow((float)10, (float)(double(iLevel + 2000) / 2000.0f)) / 10.0f;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T Clamp(T var, T min, T max )
|
||||
{
|
||||
if( var < min ) var = min;
|
||||
if( var > max ) var = max;
|
||||
return var;
|
||||
}
|
||||
|
||||
template<class _Ty>
|
||||
struct ptr_less : std::binary_function<_Ty, _Ty, bool>
|
||||
{
|
||||
bool operator()(const _Ty& _X, const _Ty& _Y) const
|
||||
{ return (*_X < *_Y); }
|
||||
};
|
||||
|
||||
|
||||
#endif //DEFINESOUND_H__
|
||||
276
Engine/SoundLib/EAXBuffer.cpp
Normal file
276
Engine/SoundLib/EAXBuffer.cpp
Normal file
@@ -0,0 +1,276 @@
|
||||
// CEAXBuffer.cpp: implementation of the CCEAXBuffer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "DefineSound.h"
|
||||
#include "EAXBuffer.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
CEAXBuffer::CEAXBuffer()
|
||||
{
|
||||
m_pPropertySet = 0;
|
||||
m_Props.lDirect = EAXBUFFER_DEFAULTDIRECT;
|
||||
m_Props.lDirectHF = EAXBUFFER_DEFAULTDIRECTHF;
|
||||
m_Props.lRoom = EAXBUFFER_DEFAULTROOM;
|
||||
m_Props.lRoomHF = EAXBUFFER_DEFAULTROOMHF;
|
||||
m_Props.flRoomRolloffFactor = EAXBUFFER_DEFAULTROOMROLLOFFFACTOR;
|
||||
m_Props.lObstruction = EAXBUFFER_DEFAULTOBSTRUCTION;
|
||||
m_Props.flObstructionLFRatio = EAXBUFFER_DEFAULTOBSTRUCTIONLFRATIO;
|
||||
m_Props.lOcclusion = EAXBUFFER_DEFAULTOCCLUSION;
|
||||
m_Props.flOcclusionLFRatio = EAXBUFFER_DEFAULTOCCLUSIONLFRATIO;
|
||||
m_Props.flOcclusionRoomRatio = EAXBUFFER_DEFAULTOCCLUSIONROOMRATIO;
|
||||
m_Props.lOutsideVolumeHF = EAXBUFFER_DEFAULTOUTSIDEVOLUMEHF;
|
||||
m_Props.flAirAbsorptionFactor = EAXBUFFER_DEFAULTAIRABSORPTIONFACTOR;
|
||||
m_Props.dwFlags = EAXBUFFER_DEFAULTFLAGS;
|
||||
}
|
||||
|
||||
CEAXBuffer::~CEAXBuffer()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
bool CEAXBuffer::Create( IUnknown* pUnknown )
|
||||
{
|
||||
if(!pUnknown)
|
||||
return false;
|
||||
HRESULT hr = pUnknown->QueryInterface(IID_IKsPropertySet, (void**)&m_pPropertySet);
|
||||
if(FAILED(hr))
|
||||
return false;
|
||||
|
||||
DWORD nSupport = 0;
|
||||
hr = m_pPropertySet->QuerySupport(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_ALLPARAMETERS,
|
||||
&nSupport);
|
||||
if((nSupport != (KSPROPERTY_SUPPORT_GET |
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
{
|
||||
SAFE_RELEASE(m_pPropertySet);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_ALLPARAMETERS,
|
||||
0,
|
||||
0,
|
||||
(void*)(&m_Props),
|
||||
sizeof(EAXBUFFERPROPERTIES));
|
||||
if(FAILED(hr))
|
||||
{
|
||||
SAFE_RELEASE(m_pPropertySet);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CEAXBuffer::Destroy()
|
||||
{
|
||||
SAFE_RELEASE(m_pPropertySet);
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetDirect(int iDirect)
|
||||
{
|
||||
m_Props.lDirect = iDirect;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_DIRECT,
|
||||
0,
|
||||
0,
|
||||
&iDirect,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetDirectHF(int iDirectHF)
|
||||
{
|
||||
m_Props.lDirectHF = iDirectHF;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_DIRECTHF,
|
||||
0,
|
||||
0,
|
||||
&iDirectHF,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetRoom(int iRoom)
|
||||
{
|
||||
m_Props.lRoom = iRoom;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_ROOM,
|
||||
0,
|
||||
0,
|
||||
&iRoom,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetRoomHF(int iRoomHF)
|
||||
{
|
||||
m_Props.lRoomHF = iRoomHF;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_ROOMHF,
|
||||
0,
|
||||
0,
|
||||
&iRoomHF,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetRoomRolloffFactor(float fRoomRolloffFactor)
|
||||
{
|
||||
m_Props.flRoomRolloffFactor = fRoomRolloffFactor;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_ROOMROLLOFFFACTOR,
|
||||
0,
|
||||
0,
|
||||
&fRoomRolloffFactor,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetObstruction(int iObstruction)
|
||||
{
|
||||
m_Props.lObstruction = iObstruction;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_OBSTRUCTION,
|
||||
0,
|
||||
0,
|
||||
&iObstruction,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetObstructionLFRatio(float fObstructionLFRatio)
|
||||
{
|
||||
m_Props.flObstructionLFRatio = fObstructionLFRatio;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_OBSTRUCTIONLFRATIO,
|
||||
0,
|
||||
0,
|
||||
&fObstructionLFRatio,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetOcclusion(int iOcclusion)
|
||||
{
|
||||
m_Props.lOcclusion = iOcclusion;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_OCCLUSION,
|
||||
0,
|
||||
0,
|
||||
&iOcclusion,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetOcclusionLFRatio(float fOcclusionLFRatio)
|
||||
{
|
||||
m_Props.flOcclusionLFRatio = fOcclusionLFRatio;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_OCCLUSIONLFRATIO,
|
||||
0,
|
||||
0,
|
||||
&fOcclusionLFRatio,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetOcclusionRoomRatio(float fOcclusionRoomRatio)
|
||||
{
|
||||
m_Props.flOcclusionRoomRatio = fOcclusionRoomRatio;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_OCCLUSIONROOMRATIO,
|
||||
0,
|
||||
0,
|
||||
&fOcclusionRoomRatio,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetOutsideVolumeHF(int iOutsideVolumeHF)
|
||||
{
|
||||
m_Props.lOutsideVolumeHF = iOutsideVolumeHF;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_OUTSIDEVOLUMEHF,
|
||||
0,
|
||||
0,
|
||||
&iOutsideVolumeHF,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetAirAbsorptionFactor(float fAirAbsorptionFactor)
|
||||
{
|
||||
m_Props.flAirAbsorptionFactor = fAirAbsorptionFactor;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_AIRABSORPTIONFACTOR,
|
||||
0,
|
||||
0,
|
||||
&fAirAbsorptionFactor,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetFlags(DWORD nFlags)
|
||||
{
|
||||
m_Props.dwFlags = nFlags;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_FLAGS,
|
||||
0,
|
||||
0,
|
||||
&nFlags,
|
||||
sizeof(DWORD));
|
||||
}
|
||||
|
||||
void CEAXBuffer::SetProperties(const EAXBUFFERPROPERTIES& props)
|
||||
{
|
||||
m_Props = props;
|
||||
if(!m_pPropertySet) return;
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_ALLPARAMETERS,
|
||||
0,
|
||||
0,
|
||||
(void*)(&props),
|
||||
sizeof(EAXBUFFERPROPERTIES));
|
||||
}
|
||||
|
||||
void CEAXBuffer::GetProperties(EAXBUFFERPROPERTIES& props)
|
||||
{
|
||||
/*
|
||||
DWORD nSize;
|
||||
if(m_pPropertySet)
|
||||
{
|
||||
m_pPropertySet->Get(
|
||||
DSPROPSETID_EAX20_BufferProperties,
|
||||
DSPROPERTY_EAXBUFFER_ALLPARAMETERS,
|
||||
0,
|
||||
0,
|
||||
&m_Props,
|
||||
sizeof(EAXBUFFERPROPERTIES),
|
||||
&nSize);
|
||||
}*/
|
||||
|
||||
props = m_Props;
|
||||
}
|
||||
44
Engine/SoundLib/EAXBuffer.h
Normal file
44
Engine/SoundLib/EAXBuffer.h
Normal file
@@ -0,0 +1,44 @@
|
||||
// EAXBuffer.h: interface for the CEAXBuffer class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_EAXBUFFER_H__6BCC188D_ED42_4499_B923_4B61AA73B318__INCLUDED_)
|
||||
#define AFX_EAXBUFFER_H__6BCC188D_ED42_4499_B923_4B61AA73B318__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "dsound.h"
|
||||
#include "eax.h"
|
||||
|
||||
class CEAXBuffer
|
||||
{
|
||||
private:
|
||||
IKsPropertySet* m_pPropertySet;
|
||||
EAXBUFFERPROPERTIES m_Props;
|
||||
|
||||
public:
|
||||
CEAXBuffer();
|
||||
virtual ~CEAXBuffer();
|
||||
|
||||
bool Create( IUnknown* pUnknown );
|
||||
void Destroy();
|
||||
void SetDirect(int iDirect);
|
||||
void SetDirectHF(int iDirectHF);
|
||||
void SetRoom(int iRoom);
|
||||
void SetRoomHF(int iRoomHF);
|
||||
void SetRoomRolloffFactor(float fRoomRolloffFactor);
|
||||
void SetObstruction(int iObstruction);
|
||||
void SetObstructionLFRatio(float fObstructionLFRatio);
|
||||
void SetOcclusion(int iOcclusion);
|
||||
void SetOcclusionLFRatio(float fOcclusionLFRatio);
|
||||
void SetOcclusionRoomRatio(float fOcclusionRoomRatio);
|
||||
void SetOutsideVolumeHF(int iOutsideVolumeHF);
|
||||
void SetAirAbsorptionFactor(float fAirAbsorptionFactor);
|
||||
void SetFlags(DWORD dwFlags);
|
||||
void SetProperties(const EAXBUFFERPROPERTIES& props);
|
||||
void GetProperties(EAXBUFFERPROPERTIES& props);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_EAXBUFFER_H__6BCC188D_ED42_4499_B923_4B61AA73B318__INCLUDED_)
|
||||
348
Engine/SoundLib/EAXListener.cpp
Normal file
348
Engine/SoundLib/EAXListener.cpp
Normal file
@@ -0,0 +1,348 @@
|
||||
// CEAXListener.cpp: implementation of the CCEAXListener class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "DefineSound.h"
|
||||
#include "EAXListener.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
|
||||
CEAXListener::CEAXListener()
|
||||
{
|
||||
m_pPropertySet = 0;
|
||||
m_Props.lRoom = EAXLISTENER_DEFAULTROOM;
|
||||
m_Props.lRoomHF = EAXLISTENER_DEFAULTROOMHF;
|
||||
m_Props.flRoomRolloffFactor = EAXLISTENER_DEFAULTROOMROLLOFFFACTOR;
|
||||
m_Props.flDecayTime = EAXLISTENER_DEFAULTDECAYTIME;
|
||||
m_Props.flDecayHFRatio = EAXLISTENER_DEFAULTDECAYHFRATIO;
|
||||
m_Props.lReflections = EAXLISTENER_DEFAULTREFLECTIONS;
|
||||
m_Props.flReflectionsDelay = EAXLISTENER_DEFAULTREFLECTIONSDELAY;
|
||||
m_Props.lReverb = EAXLISTENER_DEFAULTREVERB;
|
||||
m_Props.flReverbDelay = EAXLISTENER_DEFAULTREVERBDELAY;
|
||||
m_Props.dwEnvironment = EAXLISTENER_DEFAULTENVIRONMENT;
|
||||
m_Props.flEnvironmentSize = EAXLISTENER_DEFAULTENVIRONMENTSIZE;
|
||||
m_Props.flEnvironmentDiffusion = EAXLISTENER_DEFAULTENVIRONMENTDIFFUSION;
|
||||
m_Props.flAirAbsorptionHF = EAXLISTENER_DEFAULTAIRABSORPTIONHF;
|
||||
m_Props.dwFlags = EAXLISTENER_DEFAULTFLAGS;
|
||||
}
|
||||
|
||||
|
||||
CEAXListener::~CEAXListener()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
bool CEAXListener::Create( IUnknown* pUnknown )
|
||||
{
|
||||
if(!pUnknown)
|
||||
return false;
|
||||
|
||||
HRESULT hr = pUnknown->QueryInterface(IID_IKsPropertySet, (void**)&m_pPropertySet);
|
||||
if(FAILED(hr))
|
||||
return false;
|
||||
|
||||
DWORD nSupport = 0;
|
||||
hr = m_pPropertySet->QuerySupport(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ALLPARAMETERS,
|
||||
&nSupport);
|
||||
if((nSupport != (KSPROPERTY_SUPPORT_GET |
|
||||
KSPROPERTY_SUPPORT_SET)))
|
||||
{
|
||||
SAFE_RELEASE(m_pPropertySet);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ALLPARAMETERS,
|
||||
0,
|
||||
0,
|
||||
(void*)&m_Props,
|
||||
sizeof(EAXLISTENERPROPERTIES));
|
||||
if(FAILED(hr))
|
||||
{
|
||||
SAFE_RELEASE(m_pPropertySet);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CEAXListener::Destroy()
|
||||
{
|
||||
SAFE_RELEASE(m_pPropertySet);
|
||||
}
|
||||
|
||||
|
||||
void CEAXListener::SetRoom(int iRoom)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.lRoom = iRoom;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ROOM,
|
||||
0,
|
||||
0,
|
||||
&iRoom,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXListener::SetRoomHF(int iRoomHF)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.lRoomHF = iRoomHF;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ROOMHF,
|
||||
0,
|
||||
0,
|
||||
&iRoomHF,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXListener::SetRoomRolloffFactor(float fRoomRolloffFactor)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flRoomRolloffFactor = fRoomRolloffFactor;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ROOMROLLOFFFACTOR,
|
||||
0,
|
||||
0,
|
||||
&fRoomRolloffFactor,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetDecayTime(float fDecayTime)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flDecayTime = fDecayTime;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_DECAYTIME,
|
||||
0,
|
||||
0,
|
||||
&fDecayTime,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetDecayHFRatio(float fDecayHFRatio)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flDecayHFRatio = fDecayHFRatio;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_DECAYHFRATIO,
|
||||
0,
|
||||
0,
|
||||
&fDecayHFRatio,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetReflections(int iReflections)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.lReflections = iReflections;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_REFLECTIONS,
|
||||
0,
|
||||
0,
|
||||
&iReflections,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXListener::SetReflectionsDelay(float fReflectionsDelay)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flReflectionsDelay = fReflectionsDelay;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_REFLECTIONSDELAY,
|
||||
0,
|
||||
0,
|
||||
&fReflectionsDelay,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetReverb(int iReverb)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.lReverb = iReverb;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_REVERB,
|
||||
0,
|
||||
0,
|
||||
&iReverb,
|
||||
sizeof(int));
|
||||
}
|
||||
|
||||
void CEAXListener::SetReverbDelay(float fReverbDelay)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flReverbDelay = fReverbDelay;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_REVERBDELAY,
|
||||
0,
|
||||
0,
|
||||
&fReverbDelay,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetEnvironment(DWORD nEnvironment)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.dwEnvironment = nEnvironment;
|
||||
|
||||
/*===========================
|
||||
EAX_ENVIRONMENT_GENERIC
|
||||
EAX_ENVIRONMENT_PADDEDCELL
|
||||
EAX_ENVIRONMENT_ROOM
|
||||
EAX_ENVIRONMENT_BATHROOM
|
||||
EAX_ENVIRONMENT_LIVINGROOM
|
||||
EAX_ENVIRONMENT_STONEROOM
|
||||
EAX_ENVIRONMENT_AUDITORIUM
|
||||
EAX_ENVIRONMENT_CONCERTHALL
|
||||
EAX_ENVIRONMENT_CAVE
|
||||
EAX_ENVIRONMENT_ARENA
|
||||
EAX_ENVIRONMENT_HANGAR
|
||||
EAX_ENVIRONMENT_CARPETEDHALLWAY
|
||||
EAX_ENVIRONMENT_HALLWAY
|
||||
EAX_ENVIRONMENT_STONECORRIDOR
|
||||
EAX_ENVIRONMENT_ALLEY
|
||||
EAX_ENVIRONMENT_FOREST
|
||||
EAX_ENVIRONMENT_CITY
|
||||
EAX_ENVIRONMENT_MOUNTAINS
|
||||
EAX_ENVIRONMENT_QUARRY
|
||||
EAX_ENVIRONMENT_PLAIN
|
||||
EAX_ENVIRONMENT_PARKINGLOT
|
||||
EAX_ENVIRONMENT_SEWERPIPE
|
||||
EAX_ENVIRONMENT_UNDERWATER
|
||||
EAX_ENVIRONMENT_DRUGGED
|
||||
EAX_ENVIRONMENT_DIZZY
|
||||
EAX_ENVIRONMENT_PSYCHOTIC
|
||||
=============================*/
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ENVIRONMENT,
|
||||
0,
|
||||
0,
|
||||
&nEnvironment,
|
||||
sizeof(DWORD));
|
||||
}
|
||||
|
||||
void CEAXListener::SetEnvironmentSize(float fEnvironmentSize)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flEnvironmentSize = fEnvironmentSize;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ENVIRONMENTSIZE,
|
||||
0,
|
||||
0,
|
||||
&fEnvironmentSize,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetEnvironmentDiffusion(float fEnvironmentDiffusion)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flEnvironmentDiffusion = fEnvironmentDiffusion;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ENVIRONMENTDIFFUSION,
|
||||
0,
|
||||
0,
|
||||
&fEnvironmentDiffusion,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetAirAbsorptionHF(float fAirAbsorptionHF)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.flAirAbsorptionHF = fAirAbsorptionHF;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_AIRABSORPTIONHF,
|
||||
0,
|
||||
0,
|
||||
&fAirAbsorptionHF,
|
||||
sizeof(float));
|
||||
}
|
||||
|
||||
void CEAXListener::SetFlags(DWORD nFlags)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props.dwFlags = nFlags;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_FLAGS,
|
||||
0,
|
||||
0,
|
||||
&nFlags,
|
||||
sizeof(DWORD));
|
||||
}
|
||||
|
||||
void CEAXListener::SetProperties(const EAXLISTENERPROPERTIES& props)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
m_Props = props;
|
||||
|
||||
m_pPropertySet->Set(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ALLPARAMETERS,
|
||||
0,
|
||||
0,
|
||||
(void*)&props,
|
||||
sizeof(EAXLISTENERPROPERTIES));
|
||||
}
|
||||
|
||||
void CEAXListener::GetProperties(EAXLISTENERPROPERTIES& props)
|
||||
{
|
||||
if(!m_pPropertySet) return;
|
||||
|
||||
/*DWORD nSize;
|
||||
m_pPropertySet->Get(
|
||||
DSPROPSETID_EAX20_ListenerProperties,
|
||||
DSPROPERTY_EAXLISTENER_ALLPARAMETERS,
|
||||
0,
|
||||
0,
|
||||
&props,
|
||||
sizeof(EAXLISTENERPROPERTIES),
|
||||
&nSize);*/
|
||||
|
||||
props = m_Props;
|
||||
}
|
||||
45
Engine/SoundLib/EAXListener.h
Normal file
45
Engine/SoundLib/EAXListener.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// EAXListener.h: interface for the CEAXListener class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_EAXLISTENER_H__2EAC4DBE_7D26_4C60_8206_B2034CAD2022__INCLUDED_)
|
||||
#define AFX_EAXLISTENER_H__2EAC4DBE_7D26_4C60_8206_B2034CAD2022__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "dsound.h"
|
||||
#include "eax.h"
|
||||
|
||||
class CEAXListener
|
||||
{
|
||||
protected:
|
||||
IKsPropertySet* m_pPropertySet;
|
||||
EAXLISTENERPROPERTIES m_Props;
|
||||
|
||||
public:
|
||||
CEAXListener();
|
||||
virtual ~CEAXListener();
|
||||
|
||||
bool Create( IUnknown* pUnknown );
|
||||
void Destroy();
|
||||
void SetRoom(int iRoom);
|
||||
void SetRoomHF(int iRoomHF);
|
||||
void SetRoomRolloffFactor(float fRoomRolloffFactor);
|
||||
void SetDecayTime(float fDecayTime);
|
||||
void SetDecayHFRatio(float fDecayHFRatio);
|
||||
void SetReflections(int iReflections);
|
||||
void SetReflectionsDelay(float fReflectionsDelay);
|
||||
void SetReverb(int iReverb);
|
||||
void SetReverbDelay(float fReverbDelay);
|
||||
void SetEnvironment(DWORD dwEnvironment);
|
||||
void SetEnvironmentSize(float fEnvironmentSize);
|
||||
void SetEnvironmentDiffusion(float fEnvironmentDiffusion);
|
||||
void SetAirAbsorptionHF(float fAirAbsorption);
|
||||
void SetFlags(DWORD dwFlags);
|
||||
void SetProperties(const EAXLISTENERPROPERTIES& props);
|
||||
void GetProperties(EAXLISTENERPROPERTIES& props);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_EAXLISTENER_H__2EAC4DBE_7D26_4C60_8206_B2034CAD2022__INCLUDED_)
|
||||
183
Engine/SoundLib/Listener.cpp
Normal file
183
Engine/SoundLib/Listener.cpp
Normal file
@@ -0,0 +1,183 @@
|
||||
// Listener.cpp: implementation of the CListener class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "DefineSound.h"
|
||||
#include "SoundMgr.h"
|
||||
#include "Listener.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
CListener::CListener( LPDIRECTSOUND8 pDS ) : m_pListener(NULL), m_pDSBuffer(NULL)
|
||||
{
|
||||
Create( pDS );
|
||||
}
|
||||
|
||||
|
||||
CListener::~CListener()
|
||||
{
|
||||
Destory();
|
||||
}
|
||||
|
||||
|
||||
void CListener::Create( LPDIRECTSOUND8 pDS )
|
||||
{
|
||||
DSBUFFERDESC dsbdesc;
|
||||
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;
|
||||
|
||||
ZeroMemory( &dsbdesc, sizeof(DSBUFFERDESC) );
|
||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbdesc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
|
||||
|
||||
if( FAILED(pDS->CreateSoundBuffer(&dsbdesc, &pDSBPrimary, NULL)) )
|
||||
{
|
||||
MessageBox( NULL, "FAILED(pDS->CreateSoundBuffer(&dsbdesc, &pDSBPrimary, NULL))",
|
||||
"CListener::Create", MB_OK );
|
||||
SAFE_RELEASE( pDSBPrimary );
|
||||
Destory();
|
||||
return;
|
||||
}
|
||||
|
||||
if( FAILED(pDSBPrimary->QueryInterface(IID_IDirectSound3DListener8,
|
||||
(VOID**)&m_pListener)) )
|
||||
{
|
||||
SAFE_RELEASE( pDSBPrimary );
|
||||
MessageBox( NULL, "FAILED(pDSBPrimary->QueryInterface",
|
||||
"CListener::Create", MB_OK );
|
||||
SAFE_RELEASE( pDSBPrimary );
|
||||
Destory();
|
||||
return;
|
||||
}
|
||||
|
||||
m_Prop.dwSize = sizeof(DS3DLISTENER);
|
||||
m_pListener->GetAllParameters( &m_Prop );
|
||||
SAFE_RELEASE( pDSBPrimary );
|
||||
|
||||
//=============================
|
||||
// EAX Listener
|
||||
//=============================
|
||||
if( CSoundMgr::_GetInstance()->GetInitProp()->m_bUseEAX == false ) return;
|
||||
|
||||
WAVEFORMATEX wf;
|
||||
memset(&wf, 0, sizeof(WAVEFORMATEX));
|
||||
wf.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wf.nChannels = 1;
|
||||
wf.nSamplesPerSec = 22050;
|
||||
wf.nBlockAlign = 2;
|
||||
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign;
|
||||
wf.wBitsPerSample = 16;
|
||||
|
||||
DSBUFFERDESC desc;
|
||||
ZeroMemory(&desc, sizeof(desc));
|
||||
desc.dwSize = sizeof(desc);
|
||||
desc.dwFlags = DSBCAPS_LOCHARDWARE | DSBCAPS_CTRL3D;
|
||||
desc.lpwfxFormat = &wf;
|
||||
desc.dwBufferBytes = 1024;
|
||||
|
||||
LPDIRECTSOUNDBUFFER pDSBuffer = NULL;
|
||||
if( FAILED(pDS->CreateSoundBuffer(&desc, &pDSBuffer, NULL)) )
|
||||
{
|
||||
MessageBox( NULL, "Not Use EAX!", "Fail!", MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
if( FAILED(pDSBuffer->QueryInterface(IID_IDirectSoundBuffer8, (void**)&m_pDSBuffer)) )
|
||||
{
|
||||
MessageBox( NULL, "FAILED(pDSBuffer->QueryInterface",
|
||||
"CListener::Create", MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(pDSBuffer);
|
||||
|
||||
//Success
|
||||
m_EAXListener.Create( m_pDSBuffer );
|
||||
}
|
||||
|
||||
|
||||
void CListener::Destory()
|
||||
{
|
||||
SAFE_RELEASE( m_pDSBuffer );
|
||||
SAFE_RELEASE( m_pListener );
|
||||
}
|
||||
|
||||
|
||||
void CListener::Update()
|
||||
{
|
||||
m_pListener->SetAllParameters( &m_Prop, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CListener::SetDistanceFactor( float fDistanceFactor )
|
||||
{
|
||||
m_Prop.flDistanceFactor = fDistanceFactor;
|
||||
}
|
||||
|
||||
|
||||
void CListener::SetDopplerFactor( float fDopplerFactor )
|
||||
{
|
||||
m_Prop.flDopplerFactor = fDopplerFactor;
|
||||
}
|
||||
|
||||
|
||||
void CListener::SetOrientation( D3DVECTOR& vFront, D3DVECTOR& vTop )
|
||||
{
|
||||
memcpy( &m_Prop.vOrientFront, &vFront, sizeof(D3DVECTOR) );
|
||||
memcpy( &m_Prop.vOrientTop, &vTop, sizeof(D3DVECTOR) );
|
||||
}
|
||||
|
||||
|
||||
void CListener::SetPosition( D3DVECTOR& vPos )
|
||||
{
|
||||
memcpy( &m_Prop.vPosition, &vPos, sizeof(D3DVECTOR) );
|
||||
}
|
||||
|
||||
|
||||
void CListener::SetRolloffFactor( float fRolloffFactor )
|
||||
{
|
||||
m_Prop.flRolloffFactor = fRolloffFactor;
|
||||
}
|
||||
|
||||
|
||||
void CListener::SetVelocity( D3DVECTOR& vVel )
|
||||
{
|
||||
memcpy( &m_Prop.vVelocity, &vVel, sizeof(D3DVECTOR) );
|
||||
}
|
||||
|
||||
|
||||
void CListener::GetDistanceFactor( float& fDistanceFactor )
|
||||
{
|
||||
fDistanceFactor = m_Prop.flDistanceFactor;
|
||||
}
|
||||
|
||||
|
||||
void CListener::GetDopplerFactor( float& fDopplerFactor )
|
||||
{
|
||||
fDopplerFactor = m_Prop.flDopplerFactor;
|
||||
}
|
||||
|
||||
|
||||
void CListener::GetOrientation( D3DVECTOR& vFront, D3DVECTOR& vTop )
|
||||
{
|
||||
memcpy( &vFront, &m_Prop.vOrientFront, sizeof(D3DVECTOR) );
|
||||
memcpy( &vTop, &m_Prop.vOrientTop, sizeof(D3DVECTOR) );
|
||||
}
|
||||
|
||||
|
||||
void CListener::GetPosition( D3DVECTOR& vPos )
|
||||
{
|
||||
memcpy( &vPos, &m_Prop.vPosition, sizeof(D3DVECTOR) );
|
||||
}
|
||||
|
||||
|
||||
void CListener::GetRolloffFactor( float& fRolloffFactor )
|
||||
{
|
||||
fRolloffFactor = m_Prop.flRolloffFactor;
|
||||
}
|
||||
|
||||
|
||||
void CListener::GetVelocity( D3DVECTOR& vVel )
|
||||
{
|
||||
memcpy( &vVel, &m_Prop.vVelocity, sizeof(D3DVECTOR) );
|
||||
}
|
||||
|
||||
|
||||
53
Engine/SoundLib/Listener.h
Normal file
53
Engine/SoundLib/Listener.h
Normal file
@@ -0,0 +1,53 @@
|
||||
// Listener.h: interface for the CListener class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_LISTENER_H__FE18A847_15A9_41C1_AD4D_E368D6D1A346__INCLUDED_)
|
||||
#define AFX_LISTENER_H__FE18A847_15A9_41C1_AD4D_E368D6D1A346__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <dsound.h>
|
||||
#include "EAXListener.h"
|
||||
|
||||
class CListener
|
||||
{
|
||||
protected:
|
||||
LPDIRECTSOUND3DLISTENER8 m_pListener;
|
||||
LPDIRECTSOUNDBUFFER8 m_pDSBuffer;
|
||||
DS3DLISTENER m_Prop;
|
||||
CEAXListener m_EAXListener;
|
||||
|
||||
protected:
|
||||
void Create( LPDIRECTSOUND8 pDS );
|
||||
void Destory();
|
||||
|
||||
public:
|
||||
CListener( LPDIRECTSOUND8 pDS );
|
||||
virtual ~CListener();
|
||||
|
||||
void Update();
|
||||
CEAXListener* GetEAX() { return &m_EAXListener; };
|
||||
|
||||
void SetPosition(D3DVECTOR& vPos);
|
||||
void GetPosition(D3DVECTOR& vPos);
|
||||
|
||||
void SetVelocity(D3DVECTOR& vVel);
|
||||
void GetVelocity(D3DVECTOR& vVel);
|
||||
|
||||
void SetOrientation(D3DVECTOR& vFront, D3DVECTOR& vTop);
|
||||
void GetOrientation(D3DVECTOR& vFront, D3DVECTOR& vTop);
|
||||
|
||||
void SetDistanceFactor(float fDistanceFactor);
|
||||
void GetDistanceFactor(float& fDistanceFactor);
|
||||
|
||||
void SetDopplerFactor(float fDopplerFactor);
|
||||
void GetDopplerFactor(float& fDopplerFactor);
|
||||
|
||||
void SetRolloffFactor(float fRolloffFactor);
|
||||
void GetRolloffFactor(float& fRolloffFactor);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_LISTENER_H__FE18A847_15A9_41C1_AD4D_E368D6D1A346__INCLUDED_)
|
||||
132
Engine/SoundLib/OggLoader.cpp
Normal file
132
Engine/SoundLib/OggLoader.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
// OggLoader.cpp: implementation of the COggLoader class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "OggLoader.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
COggLoader::COggLoader() : m_dwBufferSize(0),
|
||||
m_dwNumSamples(0),
|
||||
m_pVorbisInfo(NULL),
|
||||
m_bEOF(false),
|
||||
m_bOpen(false),
|
||||
m_pFP(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
COggLoader::~COggLoader()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
|
||||
bool COggLoader::Open( char* strFileName )
|
||||
{
|
||||
if(m_bOpen) return false;
|
||||
|
||||
if( (m_pFP = fopen( strFileName, "rb" )) == NULL)
|
||||
return false;
|
||||
|
||||
m_bOpen = true;
|
||||
if (ov_open(m_pFP, &m_VorbisFile, NULL, 0) < 0)
|
||||
{
|
||||
char buf[MAX_PATH] = {0};
|
||||
sprintf( buf, "<EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>. : %s \n COggLoader::Open", strFileName );
|
||||
MessageBox( NULL, buf, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>忡<EFBFBD><EFBFBD>", MB_OK );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !GetStreamInfo() )
|
||||
{
|
||||
char buf[MAX_PATH] = {0};
|
||||
sprintf( buf, "<EFBFBD>ش<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>Ʈ<EFBFBD><C6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>. : %s \n COggLoader::Open", strFileName );
|
||||
MessageBox( NULL, buf, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>忡<EFBFBD><EFBFBD>", MB_OK );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool COggLoader::Close()
|
||||
{
|
||||
if(!m_bOpen) return false;
|
||||
|
||||
if( ov_clear(&m_VorbisFile) < 0 )
|
||||
return false;
|
||||
|
||||
if( m_pFP ) fclose( m_pFP );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool COggLoader::Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead )
|
||||
{
|
||||
if(!m_bOpen) return false;
|
||||
|
||||
char* pCurBuffer = (char*)pBuffer;
|
||||
DWORD dwBytesRead = 0;
|
||||
int iSection = 0;
|
||||
while( (dwBytesRead < dwSizeToRead) && !m_bEOF )
|
||||
{
|
||||
int iRet = ov_read(&m_VorbisFile, pCurBuffer, dwSizeToRead - dwBytesRead, 0, 2, 1, &iSection);
|
||||
if (iRet == 0 || iSection != 0)
|
||||
{
|
||||
m_bEOF = true;
|
||||
}
|
||||
else if (iRet < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
dwBytesRead += iRet;
|
||||
pCurBuffer += iRet;
|
||||
}
|
||||
|
||||
*pdwSizeRead = dwBytesRead;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool COggLoader::Reset()
|
||||
{
|
||||
if(!m_bOpen)
|
||||
return false;
|
||||
|
||||
m_bEOF = false;
|
||||
ov_pcm_seek(&m_VorbisFile, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
DWORD COggLoader::GetSize()
|
||||
{
|
||||
return m_dwNumSamples * m_WaveFormatEx.nChannels * m_WaveFormatEx.wBitsPerSample / 8;
|
||||
}
|
||||
|
||||
|
||||
bool COggLoader::GetStreamInfo()
|
||||
{
|
||||
// Get vorbis file information
|
||||
m_pVorbisInfo = ov_info(&m_VorbisFile,-1);
|
||||
|
||||
if( !m_pVorbisInfo ) return false;
|
||||
|
||||
// Get the number of PCM samples in this file
|
||||
m_dwNumSamples = (long)ov_pcm_total(&m_VorbisFile,-1);
|
||||
|
||||
// set up the WaveFormatEx structure
|
||||
m_WaveFormatEx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
m_WaveFormatEx.nChannels = m_pVorbisInfo->channels;
|
||||
m_WaveFormatEx.nSamplesPerSec = m_pVorbisInfo->rate;
|
||||
m_WaveFormatEx.wBitsPerSample = 16;
|
||||
m_WaveFormatEx.nBlockAlign = m_WaveFormatEx.nChannels * m_WaveFormatEx.wBitsPerSample / 8;
|
||||
m_WaveFormatEx.nAvgBytesPerSec = m_WaveFormatEx.nSamplesPerSec * m_WaveFormatEx.nBlockAlign;
|
||||
m_WaveFormatEx.cbSize = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
45
Engine/SoundLib/OggLoader.h
Normal file
45
Engine/SoundLib/OggLoader.h
Normal file
@@ -0,0 +1,45 @@
|
||||
// OggLoader.h: interface for the COggLoader class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_OGGLOADER_H__EDD0A382_ACBB_4E9B_974E_02D96D520340__INCLUDED_)
|
||||
#define AFX_OGGLOADER_H__EDD0A382_ACBB_4E9B_974E_02D96D520340__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include "Common.h"
|
||||
#include <dsound.h>
|
||||
#include <vorbis/codec.h>
|
||||
#include <vorbis/vorbisfile.h>
|
||||
|
||||
class COggLoader
|
||||
{
|
||||
public:
|
||||
DWORD m_dwBufferSize;
|
||||
DWORD m_dwNumSamples;
|
||||
vorbis_info* m_pVorbisInfo;
|
||||
bool m_bEOF;
|
||||
bool m_bOpen;
|
||||
FILE* m_pFP;
|
||||
|
||||
WAVEFORMATEX m_WaveFormatEx;
|
||||
OggVorbis_File m_VorbisFile;
|
||||
|
||||
public:
|
||||
COggLoader();
|
||||
virtual ~COggLoader();
|
||||
|
||||
void Init();
|
||||
bool Open( char* strFileName);
|
||||
bool Close();
|
||||
bool Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );
|
||||
DWORD GetSize();
|
||||
bool Reset();
|
||||
WAVEFORMATEX* GetFormat() { return &m_WaveFormatEx; };
|
||||
bool IsEOF() { return m_bEOF; };
|
||||
bool GetStreamInfo();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_OGGLOADER_H__EDD0A382_ACBB_4E9B_974E_02D96D520340__INCLUDED_)
|
||||
21
Engine/SoundLib/ReadMe.txt
Normal file
21
Engine/SoundLib/ReadMe.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
========================================================================
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>̺귯<CCBA><EAB7AF> : SoundLib <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
|
||||
========================================================================
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><> SoundLib <20><><EFBFBD>̺귯<CCBA><EAB7AF> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>.
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʾҽ<CABE><D2BD>ϴ<EFBFBD>.
|
||||
|
||||
|
||||
SoundLib.vcproj
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>縦 <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> VC++ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> <20>⺻ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD><EFBFBD>Դϴ<D4B4>.
|
||||
<20>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Visual C++<2B><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>Ͽ<EFBFBD>
|
||||
<20><><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7><EFBFBD>, <20><><EFBFBD><EFBFBD> <20><>
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD>ɿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ֽ<EFBFBD><D6BD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
<EFBFBD><EFBFBD>Ÿ <20><><EFBFBD><EFBFBD>:
|
||||
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>α<CEB1> <20><><EFBFBD><EFBFBD><EFBFBD>翡<EFBFBD><E7BFA1> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD> "TODO:" <20>ּ<EFBFBD><D6BC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ڰ<EFBFBD> <20>߰<EFBFBD><DFB0>ϰų<CFB0> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ؾ<EFBFBD> <20>ϴ<EFBFBD>
|
||||
<EFBFBD>ҽ<EFBFBD> <20>ڵ<EFBFBD> <20>κ<EFBFBD><CEBA><EFBFBD> <20><>Ÿ<EFBFBD><C5B8><EFBFBD>ϴ<EFBFBD>.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
367
Engine/SoundLib/Sound.cpp
Normal file
367
Engine/SoundLib/Sound.cpp
Normal file
@@ -0,0 +1,367 @@
|
||||
// Sound.cpp: implementation of the CSound class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "WaveLoader.h"
|
||||
#include "Sound.h"
|
||||
#include "SoundMgr.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
CSound::CSound() : m_ppDSBuffer( NULL ),
|
||||
m_pWaveFile( NULL ),
|
||||
m_dwNumBuffers( 0 ),
|
||||
m_dwDSBufferSize( 0 ),
|
||||
m_bSound3D( false ),
|
||||
m_bLoop( false ),
|
||||
m_fVolume( VOLUME_MAX ),
|
||||
m_dwLastPlayTime( 0 ),
|
||||
m_dwLatestPlayIndex( 0 ),
|
||||
m_iPreserveScore( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CSound::~CSound()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
HRESULT CSound::RestoreBuffer( LPDIRECTSOUNDBUFFER pDSB, bool* pbWasRestored )
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if( pDSB == NULL )
|
||||
return CO_E_NOTINITIALIZED;
|
||||
if( pbWasRestored )
|
||||
*pbWasRestored = FALSE;
|
||||
|
||||
DWORD dwStatus;
|
||||
if( FAILED( hr = pDSB->GetStatus( &dwStatus ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( dwStatus & DSBSTATUS_BUFFERLOST )
|
||||
{
|
||||
do
|
||||
{
|
||||
hr = pDSB->Restore();
|
||||
if( hr == DSERR_BUFFERLOST )
|
||||
Sleep( 10 );
|
||||
}
|
||||
while( ( hr = pDSB->Restore() ) == DSERR_BUFFERLOST );
|
||||
|
||||
if( pbWasRestored != NULL )
|
||||
*pbWasRestored = TRUE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LPDIRECTSOUNDBUFFER CSound::GetFreeBuffer()
|
||||
{
|
||||
if( m_ppDSBuffer == NULL )
|
||||
return FALSE;
|
||||
|
||||
DWORD i=0;
|
||||
for( ; i<m_dwNumBuffers; i++ )
|
||||
{
|
||||
if( m_ppDSBuffer[i] )
|
||||
{
|
||||
DWORD dwStatus = 0;
|
||||
m_ppDSBuffer[i]->GetStatus( &dwStatus );
|
||||
if ( ( dwStatus & DSBSTATUS_PLAYING ) == 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( i != m_dwNumBuffers )
|
||||
{
|
||||
m_dwLatestPlayIndex = i;
|
||||
return m_ppDSBuffer[ i ];
|
||||
}
|
||||
else
|
||||
return m_ppDSBuffer[ rand() % m_dwNumBuffers ];
|
||||
}
|
||||
|
||||
|
||||
LPDIRECTSOUNDBUFFER CSound::GetBuffer( DWORD dwIndex )
|
||||
{
|
||||
if( m_ppDSBuffer == NULL )
|
||||
return NULL;
|
||||
if( dwIndex >= m_dwNumBuffers )
|
||||
return NULL;
|
||||
|
||||
return m_ppDSBuffer[dwIndex];
|
||||
}
|
||||
|
||||
|
||||
void CSound::Stop()
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
|
||||
for( DWORD i=0; i<m_dwNumBuffers; i++ )
|
||||
hr |= m_ppDSBuffer[i]->Stop();
|
||||
|
||||
if( FAILED(hr) )
|
||||
MessageBox( NULL, "hr |= m_ppDSBuffer[i]->Stop()", "CSound::Stop", MB_OK );
|
||||
}
|
||||
|
||||
|
||||
void CSound::Reset()
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
|
||||
for( DWORD i=0; i<m_dwNumBuffers; i++ )
|
||||
hr |= m_ppDSBuffer[i]->SetCurrentPosition( 0 );
|
||||
|
||||
if( FAILED(hr) )
|
||||
MessageBox( NULL, "hr |= m_ppDSBuffer[i]->SetCurrentPosition",
|
||||
"CSound::Stop", MB_OK );
|
||||
}
|
||||
|
||||
|
||||
bool CSound::IsPlaying()
|
||||
{
|
||||
bool bIsPlaying = false;
|
||||
|
||||
if( m_ppDSBuffer == NULL )
|
||||
return false;
|
||||
|
||||
for( DWORD i=0; i<m_dwNumBuffers; i++ )
|
||||
{
|
||||
if( m_ppDSBuffer[i] )
|
||||
{
|
||||
DWORD dwStatus = 0;
|
||||
m_ppDSBuffer[i]->GetStatus( &dwStatus );
|
||||
bIsPlaying |= ( ( dwStatus & DSBSTATUS_PLAYING ) != 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return bIsPlaying;
|
||||
}
|
||||
|
||||
|
||||
bool CSound::Create( const char* strFileName, DWORD dwNumBuffers )
|
||||
{
|
||||
DWORD i;
|
||||
DWORD dwDSBufferSize = NULL;
|
||||
m_dwNumBuffers = dwNumBuffers;
|
||||
|
||||
LPDIRECTSOUND8 pDS = CSoundMgr::_GetInstance()->GetDirectSound();
|
||||
m_ppDSBuffer = new LPDIRECTSOUNDBUFFER8[dwNumBuffers];
|
||||
for( i = 0; i < dwNumBuffers; ++i )
|
||||
{
|
||||
m_ppDSBuffer[i] = 0;
|
||||
}
|
||||
m_pWaveFile = new CWaveLoader;
|
||||
|
||||
if( FAILED(m_pWaveFile->Open((LPSTR)strFileName, NULL, WAVEFILE_READ)) )
|
||||
{
|
||||
char buf[MAX_PATH] = {0};
|
||||
sprintf( buf, "<EFBFBD>ش<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD>. : %s \n CSound::Create", strFileName );
|
||||
MessageBox( NULL, buf, "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>忡<EFBFBD><EFBFBD>", MB_OK );
|
||||
SAFE_DELETE(m_pWaveFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dwDSBufferSize = m_pWaveFile->GetSize();
|
||||
|
||||
WAVEFORMATEX wfx;
|
||||
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
|
||||
wfx.nChannels = m_pWaveFile->m_pwfx->nChannels;
|
||||
wfx.nSamplesPerSec = m_pWaveFile->m_pwfx->nSamplesPerSec;
|
||||
wfx.wBitsPerSample = m_pWaveFile->m_pwfx->wBitsPerSample;
|
||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfx.nBlockAlign = wfx.wBitsPerSample / 8 * wfx.nChannels;
|
||||
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||
|
||||
if( m_bSound3D && wfx.nChannels != 1 )
|
||||
{
|
||||
MessageBox( NULL, "3DSound Only Acquire One Channel", "Sound::Create", MB_OK );
|
||||
wfx.nChannels = 1;
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
//Create Buffer
|
||||
DSBUFFERDESC dsbd;
|
||||
ZeroMemory( &dsbd, sizeof(DSBUFFERDESC) );
|
||||
dsbd.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbd.dwFlags = DSBCAPS_CTRLVOLUME;
|
||||
if( m_bSound3D ) dsbd.dwFlags |= DSBCAPS_CTRL3D|DSBCAPS_MUTE3DATMAXDISTANCE;
|
||||
dsbd.dwBufferBytes = m_dwDSBufferSize;
|
||||
dsbd.guid3DAlgorithm = m_bSound3D ? CSoundMgr::_GetInstance()->GetInitProp()->m_guidSound3DAlgorithm : GUID_NULL;
|
||||
dsbd.lpwfxFormat = &wfx;
|
||||
|
||||
|
||||
//========================================
|
||||
LPDIRECTSOUNDBUFFER tempBuffer;
|
||||
if( FAILED(pDS->CreateSoundBuffer( &dsbd, &tempBuffer, NULL )) )
|
||||
{
|
||||
//MessageBox( NULL, "pDS->CreateSoundBuffer( &dsbd, &tempBuffer, NULL )", "CSound::Create", MB_OK );
|
||||
SAFE_RELEASE( tempBuffer );
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
if( FAILED(tempBuffer->QueryInterface( IID_IDirectSoundBuffer8, (LPVOID*)m_ppDSBuffer )) )
|
||||
{
|
||||
//MessageBox( NULL, "pDS->CreateSoundBuffer( &dsbd, &tempBuffer, NULL )", "CSound::Create", MB_OK );
|
||||
SAFE_RELEASE( tempBuffer );
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
SAFE_RELEASE(tempBuffer)
|
||||
|
||||
for( i = 1; i < dwNumBuffers; i++ )
|
||||
{
|
||||
if( FAILED(pDS->DuplicateSoundBuffer( m_ppDSBuffer[0], (LPDIRECTSOUNDBUFFER*)&m_ppDSBuffer[i])) )
|
||||
{
|
||||
//MessageBox( NULL, "pDS->DuplicateSoundBuffer( m_ppDSBuffer[0], &m_ppDSBuffer[i])",
|
||||
// "CSound::Create", MB_OK );
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FillBuffer( m_ppDSBuffer[0] );
|
||||
//===============================================
|
||||
|
||||
|
||||
/*
|
||||
if( FAILED(pDS->CreateSoundBuffer( &dsbd, &m_ppDSBuffer[0], NULL )) )
|
||||
{
|
||||
//MessageBox( NULL, "pDS->CreateSoundBuffer( &dsbd, &m_ppDSBuffer[0], NULL )",
|
||||
// "CSound::Create", MB_OK );
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
for( i = 1; i < dwNumBuffers; i++ )
|
||||
{
|
||||
if( FAILED(pDS->DuplicateSoundBuffer( m_ppDSBuffer[0], &m_ppDSBuffer[i])) )
|
||||
{
|
||||
//MessageBox( NULL, "pDS->DuplicateSoundBuffer( m_ppDSBuffer[0], &m_ppDSBuffer[i])",
|
||||
// "CSound::Create", MB_OK );
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
FillBuffer( m_ppDSBuffer[0] );
|
||||
*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CSound::Destroy()
|
||||
{
|
||||
for( DWORD i = 0; i < m_dwNumBuffers; i++ )
|
||||
{
|
||||
SAFE_RELEASE( m_ppDSBuffer[i] );
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY( m_ppDSBuffer );
|
||||
SAFE_DELETE( m_pWaveFile );
|
||||
}
|
||||
|
||||
|
||||
void CSound::Play()
|
||||
{
|
||||
if( 0 == this )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_dwLastPlayTime = timeGetTime();
|
||||
|
||||
bool bRestored;
|
||||
LPDIRECTSOUNDBUFFER pDSB = GetFreeBuffer();
|
||||
|
||||
if( FAILED(RestoreBuffer(pDSB, &bRestored)) )
|
||||
{
|
||||
MessageBox(NULL, "FAILED(RestoreBuffer(pDSB, &bRestored))",
|
||||
"CSound::Play", MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
if( bRestored )
|
||||
{
|
||||
FillBuffer( pDSB );
|
||||
}
|
||||
|
||||
SetVolume(pDSB, m_fVolume);
|
||||
|
||||
pDSB->Play(0,0, m_bLoop ? DSBPLAY_LOOPING:0 );
|
||||
}
|
||||
|
||||
|
||||
void CSound::FillBuffer( LPDIRECTSOUNDBUFFER pDSBuffer )
|
||||
{
|
||||
VOID* pDSLockedBuffer = NULL;
|
||||
DWORD dwDSLockedBufferSize = 0;
|
||||
DWORD dwWavDataRead = 0;
|
||||
|
||||
if( FAILED(RestoreBuffer( pDSBuffer, NULL)) )
|
||||
{
|
||||
MessageBox( NULL, "FAILED(RestoreBuffer( pDSBuffer, NULL))",
|
||||
"CSound::FillBuffer", MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
if( FAILED(pDSBuffer->Lock(0, 0, &pDSLockedBuffer, &dwDSLockedBufferSize,
|
||||
NULL, NULL, DSBLOCK_ENTIREBUFFER ) ) )
|
||||
{
|
||||
MessageBox( NULL, "FAILED(pDSBuffer->Lock", "CSound::FillBuffer", MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
m_pWaveFile->ResetFile();
|
||||
|
||||
if( FAILED(m_pWaveFile->Read((BYTE*)pDSLockedBuffer, dwDSLockedBufferSize, &dwWavDataRead)) )
|
||||
{
|
||||
MessageBox( NULL, "FAILED(m_pWaveFile->Read", "CSound::FillBuffer", MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
if( dwWavDataRead == 0 )
|
||||
{
|
||||
MessageBox( NULL, "dwWavDataRead == 0", "CSound::FillBuffer", MB_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
pDSBuffer->Unlock( pDSLockedBuffer, dwDSLockedBufferSize, NULL, 0 );
|
||||
}
|
||||
|
||||
void CSound::SetVolume(LPDIRECTSOUNDBUFFER pDSBuffer, float fVol )
|
||||
{
|
||||
if( !pDSBuffer ) return;
|
||||
|
||||
m_fVolume = Clamp( fVol, VOLUME_MIN, VOLUME_MAX );
|
||||
float fMasterVol = CSoundMgr::_GetInstance()->GetVolume();
|
||||
fMasterVol = Clamp( fMasterVol, VOLUME_MIN, VOLUME_MAX );
|
||||
int iVol = LinearToLogVol(m_fVolume * fMasterVol);
|
||||
|
||||
if(iVol < -10000)
|
||||
iVol = -10000;
|
||||
|
||||
if( FAILED(pDSBuffer->SetVolume(iVol)) )
|
||||
{
|
||||
MessageBox( NULL, "FAILED(pDSBuffer->SetVolume(iVol))",
|
||||
"CSound::SetVolume", MB_OK );
|
||||
}
|
||||
}
|
||||
|
||||
void CSound::SetVolume( float fVol )
|
||||
{
|
||||
if( !m_ppDSBuffer ) return;
|
||||
|
||||
m_fVolume = Clamp( fVol, VOLUME_MIN, VOLUME_MAX );
|
||||
}
|
||||
59
Engine/SoundLib/Sound.h
Normal file
59
Engine/SoundLib/Sound.h
Normal file
@@ -0,0 +1,59 @@
|
||||
// Sound.h: interface for the CSound class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SOUND_H__C6C8A751_6637_4E39_9525_125C0632F1D0__INCLUDED_)
|
||||
#define AFX_SOUND_H__C6C8A751_6637_4E39_9525_125C0632F1D0__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <dsound.h>
|
||||
#include "DefineSound.h"
|
||||
|
||||
class CWaveLoader;
|
||||
class CSoundMgr;
|
||||
|
||||
class CSound
|
||||
{
|
||||
friend class CSound3D;
|
||||
friend class CSoundMgr;
|
||||
|
||||
protected:
|
||||
LPDIRECTSOUNDBUFFER8* m_ppDSBuffer;
|
||||
CWaveLoader* m_pWaveFile;
|
||||
DWORD m_dwNumBuffers;
|
||||
DWORD m_dwDSBufferSize;
|
||||
bool m_bSound3D;
|
||||
bool m_bLoop;
|
||||
float m_fVolume;
|
||||
DWORD m_dwLastPlayTime;
|
||||
DWORD m_dwLatestPlayIndex;
|
||||
int m_iPreserveScore;
|
||||
|
||||
public:
|
||||
CSound();
|
||||
virtual ~CSound();
|
||||
|
||||
bool Create( const char* strFileName, DWORD dwNumBuffers );
|
||||
void Destroy();
|
||||
void Play();
|
||||
|
||||
inline void SetLooping( bool bLoop ) { m_bLoop = bLoop; }
|
||||
inline bool IsLooping() { return m_bLoop; }
|
||||
void SetVolume( float fVol );
|
||||
void SetVolume(LPDIRECTSOUNDBUFFER pDSBuffer, float fVol );
|
||||
inline void GetVolume( float& fVol ) { fVol = m_fVolume; }
|
||||
|
||||
HRESULT RestoreBuffer( LPDIRECTSOUNDBUFFER pDSB, bool* pbWasRestored );
|
||||
void FillBuffer( LPDIRECTSOUNDBUFFER pDSBuffer );
|
||||
LPDIRECTSOUNDBUFFER GetFreeBuffer();
|
||||
LPDIRECTSOUNDBUFFER GetBuffer( DWORD dwIndex );
|
||||
void Stop();
|
||||
void Reset();
|
||||
bool IsPlaying();
|
||||
inline DWORD GetAllBufferSize() { return (m_dwDSBufferSize*m_dwNumBuffers); }
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SOUND_H__C6C8A751_6637_4E39_9525_125C0632F1D0__INCLUDED_)
|
||||
177
Engine/SoundLib/Sound3D.cpp
Normal file
177
Engine/SoundLib/Sound3D.cpp
Normal file
@@ -0,0 +1,177 @@
|
||||
// Sound3D.cpp: implementation of the CSound3D class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "DefineSound.h"
|
||||
#include "Sound.h"
|
||||
#include "Sound3D.h"
|
||||
#include "SoundMgr.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
CSound3D::CSound3D() : m_pSound( NULL ),
|
||||
m_ppDS3DBuffer( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CSound3D::~CSound3D()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
||||
bool CSound3D::Create( const char* strFileName, DWORD dwNumBuffers )
|
||||
{
|
||||
m_pSound = new CSound;
|
||||
m_pSound->m_bSound3D = true;
|
||||
|
||||
if( !m_pSound->Create( strFileName, dwNumBuffers ) )
|
||||
{
|
||||
Destroy();
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ppDS3DBuffer = new LPDIRECTSOUND3DBUFFER8[dwNumBuffers];
|
||||
|
||||
for( DWORD i = 0; i < dwNumBuffers; i++ )
|
||||
{
|
||||
m_ppDS3DBuffer[i] = Get3DSoundBufferInterface( i );
|
||||
}
|
||||
|
||||
//=============================
|
||||
// Create EAX
|
||||
//=============================
|
||||
// if( CSoundMgr::_GetInstance()->GetInitProp()->m_bUseEAX )
|
||||
// m_EAXBuffer.Create( m_pDS3DBuffer );
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::Destroy()
|
||||
{
|
||||
for( DWORD i = 0; i < m_pSound->m_dwNumBuffers; i++ )
|
||||
{
|
||||
SAFE_RELEASE( m_ppDS3DBuffer[i] );
|
||||
SAFE_DELETE( m_ppDS3DBuffer[i] );
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY( m_ppDS3DBuffer ) ;
|
||||
SAFE_DELETE( m_pSound );
|
||||
}
|
||||
|
||||
|
||||
LPDIRECTSOUND3DBUFFER8 CSound3D::Get3DSoundBufferInterface( DWORD dwIndex )
|
||||
{
|
||||
LPDIRECTSOUND3DBUFFER8 pDS3DBuffer;
|
||||
HRESULT hr = m_pSound->m_ppDSBuffer[dwIndex]->QueryInterface( IID_IDirectSound3DBuffer8, (void**)&pDS3DBuffer );
|
||||
if( FAILED( hr ) )
|
||||
{
|
||||
MessageBox( NULL, "m_pSound->m_ppDSBuffer[dwIndex]->QueryInterface( IID_IDirectSound3DBuffer8, (void**)&pDS3DBuffer )",
|
||||
"CSound3D::Get3DSoundBufferInterface", MB_OK );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pDS3DBuffer;
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetConeAngles( DWORD dwInside, DWORD dwOutside )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetConeAngles( dwInside, dwOutside, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetConeOrientation( D3DVECTOR& vOrientation )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetConeOrientation( vOrientation.x,
|
||||
vOrientation.y, vOrientation.z, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetConeOutsideVolume( float fVolume )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetConeOutsideVolume( LinearToLogVol(fVolume), DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetMaxDistance( float fMaxDist )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetMaxDistance( fMaxDist, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetMinDistance( float fMinDist )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetMinDistance( fMinDist, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetMode( DWORD dwMode )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetMode( dwMode, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetPosition( D3DVECTOR& vPos )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetPosition( vPos.x, vPos.y, vPos.z, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::SetVelocity( const D3DVECTOR& vVel )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->SetVelocity( vVel.x, vVel.y, vVel.z, DS3D_IMMEDIATE );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetConeAngles( DWORD& dwInside, DWORD& dwOutside )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetConeAngles( &dwInside, &dwOutside );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetConeOrientation( D3DVECTOR& vOrientation )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetConeOrientation( &vOrientation );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetConeOutsideVolume( float& fVolume )
|
||||
{
|
||||
LPLONG V = NULL ;
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetConeOutsideVolume( V );
|
||||
fVolume = LogToLinearVol( *V );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetMaxDistance( float& fMaxDist )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetMaxDistance( &fMaxDist );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetMinDistance( float& fMinDist )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetMinDistance( &fMinDist );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetMode( DWORD& dwMode )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetMode( &dwMode );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetPosition( D3DVECTOR& vPos )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetPosition( &vPos );
|
||||
}
|
||||
|
||||
|
||||
void CSound3D::GetVelocity( D3DVECTOR& vVel )
|
||||
{
|
||||
m_ppDS3DBuffer[m_pSound->m_dwLatestPlayIndex]->GetVelocity( &vVel );
|
||||
}
|
||||
|
||||
|
||||
74
Engine/SoundLib/Sound3D.h
Normal file
74
Engine/SoundLib/Sound3D.h
Normal file
@@ -0,0 +1,74 @@
|
||||
// Sound3D.h: interface for the CSound3D class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SOUND3D_H__9100BA05_DC25_4ECD_A2A7_4E34F81982C6__INCLUDED_)
|
||||
#define AFX_SOUND3D_H__9100BA05_DC25_4ECD_A2A7_4E34F81982C6__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <dsound.h>
|
||||
#include "EAXBuffer.h"
|
||||
|
||||
class CSound;
|
||||
class CWaveLoader;
|
||||
class CSoundMgr;
|
||||
|
||||
class CSound3D
|
||||
{
|
||||
protected:
|
||||
friend class CSoundMgr;
|
||||
CSound* m_pSound;
|
||||
LPDIRECTSOUND3DBUFFER8* m_ppDS3DBuffer;
|
||||
//CEAXBuffer m_EAXBuffer;
|
||||
|
||||
protected:
|
||||
LPDIRECTSOUND3DBUFFER8 Get3DSoundBufferInterface( DWORD dwIndex );
|
||||
|
||||
public:
|
||||
CSound3D();
|
||||
virtual ~CSound3D();
|
||||
|
||||
bool Create( const char* strFileName, DWORD dwNumBuffers );
|
||||
void Destroy();
|
||||
void Play() { m_pSound->Play(); };
|
||||
void Stop() { m_pSound->Stop(); };
|
||||
void Reset() { m_pSound->Reset(); };
|
||||
bool IsPlaying() { return m_pSound->IsPlaying(); };
|
||||
inline DWORD GetAllBufferSize() { return m_pSound->GetAllBufferSize(); };
|
||||
LPDIRECTSOUNDBUFFER GetFreeBuffer() { return m_pSound->GetFreeBuffer(); };
|
||||
LPDIRECTSOUNDBUFFER GetBuffer( DWORD dwIndex ) { return m_pSound->GetBuffer( dwIndex ); };
|
||||
inline void SetVolume( float fVol ) { m_pSound->SetVolume(fVol); };
|
||||
void GetVolume( float& fVol ) { m_pSound->GetVolume(fVol); };
|
||||
inline void SetLooping( bool bLoop ) { m_pSound->SetLooping(bLoop); };
|
||||
inline bool IsLooping() { return m_pSound->IsLooping(); };
|
||||
|
||||
//3D Property
|
||||
void SetPosition(D3DVECTOR& vPos);
|
||||
void GetPosition(D3DVECTOR& vPos);
|
||||
|
||||
void SetVelocity(const D3DVECTOR& vVel);
|
||||
void GetVelocity(D3DVECTOR& vVel);
|
||||
|
||||
void SetMaxDistance(float fMaxDist );
|
||||
void GetMaxDistance(float& fMaxDist);
|
||||
|
||||
void SetMinDistance(float fMinDist);
|
||||
void GetMinDistance(float& fMinDist);
|
||||
|
||||
void SetConeAngles(DWORD dwInside, DWORD dwOutside);
|
||||
void GetConeAngles(DWORD& dwInside, DWORD& dwOutside);
|
||||
|
||||
void SetConeOrientation(D3DVECTOR& vOrientation);
|
||||
void GetConeOrientation(D3DVECTOR& vOrientation);
|
||||
|
||||
void SetConeOutsideVolume(float fVolume);
|
||||
void GetConeOutsideVolume(float& fVolume);
|
||||
|
||||
void SetMode(DWORD dwMode);
|
||||
void GetMode(DWORD& dwMode);
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SOUND3D_H__9100BA05_DC25_4ECD_A2A7_4E34F81982C6__INCLUDED_)
|
||||
321
Engine/SoundLib/SoundLib.vcproj
Normal file
321
Engine/SoundLib/SoundLib.vcproj
Normal file
@@ -0,0 +1,321 @@
|
||||
<?xml version="1.0" encoding="ks_c_5601-1987"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="SoundLib"
|
||||
ProjectGUID="{00A76BEC-6D9A-4CAC-9E79-EDA8E5A9B9C4}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./vorbis_sdk/include;../../MemoryManager"
|
||||
AdditionalUsingDirectories=""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/SoundLib.lib"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)vorbis_sdk\lib""/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./vorbis_sdk/include;../../MemoryManager"
|
||||
AdditionalUsingDirectories=""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/SoundLib.lib"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)vorbis_sdk\lib""/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_NoGD|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./vorbis_sdk/include;../../MemoryManager"
|
||||
AdditionalUsingDirectories=""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/SoundLib.lib"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)vorbis_sdk\lib""/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="./vorbis_sdk/include;../../MemoryManager"
|
||||
AdditionalUsingDirectories=""
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
|
||||
RuntimeLibrary="0"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/SoundLib.lib"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)vorbis_sdk\lib""/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug_MY|Win32"
|
||||
OutputDirectory="../../Library/$(ConfigurationName)"
|
||||
IntermediateDirectory="../../Intermediate/$(ProjectName)/$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./vorbis_sdk/include;../../MemoryManager"
|
||||
AdditionalUsingDirectories=""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="$(OutDir)/SoundLib.lib"
|
||||
AdditionalLibraryDirectories=""$(ProjectDir)vorbis_sdk\lib""/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="<22>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\EAXBuffer.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\EAXListener.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Listener.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OggLoader.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Sound.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Sound3D.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SoundMgr.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StreamingSound.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StreamingSound3D.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WaveLoader.cpp">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\Common.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\DefineSound.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\eax.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\EAXBuffer.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\EAXListener.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Listener.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\OggLoader.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Sound.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Sound3D.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SoundMgr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\SoundMgrInit.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StreamingSound.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\StreamingSound3D.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\WaveLoader.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="<22><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD>"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\ReadMe.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
226
Engine/SoundLib/SoundLib.vcxproj
Normal file
226
Engine/SoundLib/SoundLib.vcxproj
Normal file
@@ -0,0 +1,226 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug_MY|Win32">
|
||||
<Configuration>Debug_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_MY|Win32">
|
||||
<Configuration>Release_MY</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release_NoGD|Win32">
|
||||
<Configuration>Release_NoGD</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{00A76BEC-6D9A-4CAC-9E79-EDA8E5A9B9C4}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</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" />
|
||||
</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" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Library/$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">../../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'" />
|
||||
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>./vorbis_sdk/include;../../MemoryManager;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)SoundLib.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>
|
||||
</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./vorbis_sdk/include;../../MemoryManager;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<OpenMPSupport>true</OpenMPSupport>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)SoundLib.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)vorbis_sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoGD|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./vorbis_sdk/include;../../MemoryManager;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)SoundLib.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)vorbis_sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_MY|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>./vorbis_sdk/include;../../MemoryManager;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)SoundLib.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)vorbis_sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_MY|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>./vorbis_sdk/include;../../MemoryManager;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<OutputFile>$(OutDir)SoundLib.lib</OutputFile>
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)vorbis_sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EAXBuffer.cpp" />
|
||||
<ClCompile Include="EAXListener.cpp" />
|
||||
<ClCompile Include="Listener.cpp" />
|
||||
<ClCompile Include="OggLoader.cpp" />
|
||||
<ClCompile Include="Sound.cpp" />
|
||||
<ClCompile Include="Sound3D.cpp" />
|
||||
<ClCompile Include="SoundMgr.cpp" />
|
||||
<ClCompile Include="StreamingSound.cpp" />
|
||||
<ClCompile Include="StreamingSound3D.cpp" />
|
||||
<ClCompile Include="WaveLoader.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Common.h" />
|
||||
<ClInclude Include="DefineSound.h" />
|
||||
<ClInclude Include="eax.h" />
|
||||
<ClInclude Include="EAXBuffer.h" />
|
||||
<ClInclude Include="EAXListener.h" />
|
||||
<ClInclude Include="Listener.h" />
|
||||
<ClInclude Include="OggLoader.h" />
|
||||
<ClInclude Include="Sound.h" />
|
||||
<ClInclude Include="Sound3D.h" />
|
||||
<ClInclude Include="SoundMgr.h" />
|
||||
<ClInclude Include="SoundMgrInit.h" />
|
||||
<ClInclude Include="StreamingSound.h" />
|
||||
<ClInclude Include="StreamingSound3D.h" />
|
||||
<ClInclude Include="WaveLoader.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MemoryManager\MemoryManager.vcxproj">
|
||||
<Project>{b6bdd524-1dde-4a65-aed7-9ee4bc86a05d}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
96
Engine/SoundLib/SoundLib.vcxproj.filters
Normal file
96
Engine/SoundLib/SoundLib.vcxproj.filters
Normal file
@@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="소스 파일">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="헤더 파일">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="리소스 파일">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="EAXBuffer.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="EAXListener.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Listener.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="OggLoader.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Sound.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Sound3D.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SoundMgr.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StreamingSound.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="StreamingSound3D.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="WaveLoader.cpp">
|
||||
<Filter>소스 파일</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Common.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="DefineSound.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="eax.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EAXBuffer.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="EAXListener.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Listener.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OggLoader.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Sound.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Sound3D.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SoundMgr.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="SoundMgrInit.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StreamingSound.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="StreamingSound3D.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="WaveLoader.h">
|
||||
<Filter>헤더 파일</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
566
Engine/SoundLib/SoundMgr.cpp
Normal file
566
Engine/SoundLib/SoundMgr.cpp
Normal file
@@ -0,0 +1,566 @@
|
||||
// SoundMgr.cpp: implementation of the CSoundMgr class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SoundMgr.h"
|
||||
#include "GMMemory.h"
|
||||
|
||||
CSoundMgr* CSoundMgr::ms_pSoundMgr = NULL;
|
||||
|
||||
CSoundMgr* CSoundMgr::_GetInstance()
|
||||
{
|
||||
if( ms_pSoundMgr == NULL )
|
||||
{
|
||||
ms_pSoundMgr = new CSoundMgr();
|
||||
}
|
||||
|
||||
return ms_pSoundMgr;
|
||||
}
|
||||
|
||||
DWORD WINAPI _TimeEventThread( LPVOID lp )
|
||||
{
|
||||
CSoundMgr::_GetInstance()->ThreadFunc();
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CSoundMgr::Init( SoundMgrInit& Init )
|
||||
{
|
||||
//============================
|
||||
// Initialize variables
|
||||
//============================
|
||||
m_bInit = false;
|
||||
m_pDS = NULL;
|
||||
m_pListener = NULL;
|
||||
m_hTimeEventThread = NULL;
|
||||
m_hDestroyEvent = NULL;
|
||||
m_dwTimeEventID = NULL;
|
||||
m_fMasterVolume = VOLUME_MAX;
|
||||
|
||||
memcpy( &m_InitProp, &Init, sizeof(SoundMgrInit) );
|
||||
if( m_InitProp.m_hWnd == 0 )
|
||||
{
|
||||
MessageBox(NULL, "Not Init hWnd!!", "CSoundMgr::Init", MB_OK);
|
||||
return false;
|
||||
}
|
||||
|
||||
//============================
|
||||
// Create DirectSound
|
||||
//============================
|
||||
if( FAILED(DirectSoundCreate8(NULL, &m_pDS, NULL)) )
|
||||
{
|
||||
MessageBox(NULL, "Failed to initialize DirectSound. \n CSoundMgr::Init",
|
||||
"DirectSound Device Error", MB_OK);
|
||||
SAFE_RELEASE( m_pDS );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( FAILED(m_pDS->SetCooperativeLevel(m_InitProp.m_hWnd, /*DSSCL_PRIORITY*/ DSSCL_EXCLUSIVE)) )
|
||||
{
|
||||
MessageBox(NULL, "Failed to set the DirectSound cooperative levels. \n CSoundMgr::Init",
|
||||
"DirectSound Device Error", MB_OK);
|
||||
SAFE_RELEASE( m_pDS );
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !SetPrimaryBufferFormat(m_InitProp.m_dwPrimaryChannels,
|
||||
m_InitProp.m_dwPrimaryFrequency, m_InitProp.m_dwPrimaryBitRate) )
|
||||
{
|
||||
MessageBox( NULL, "Failed to create DirectSound buffer. \n CSoundMgr::Init",
|
||||
"DirectSound Device Error", MB_OK );
|
||||
SAFE_RELEASE( m_pDS );
|
||||
return false;
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Get Caps
|
||||
//==============================
|
||||
ZeroMemory( &m_Caps, sizeof(DSCAPS) );
|
||||
m_Caps.dwSize = sizeof(DSCAPS);
|
||||
if( FAILED(m_pDS->GetCaps(&m_Caps)) )
|
||||
{
|
||||
MessageBox( NULL, "Failed to initialize sound driver. \n CSoundMgr::Init",
|
||||
"DirectSound Device Error", MB_OK );
|
||||
}
|
||||
|
||||
//==============================
|
||||
// Create Listener
|
||||
//==============================
|
||||
m_pListener = new CListener( m_pDS );
|
||||
|
||||
//==============================
|
||||
// Create thread
|
||||
//==============================
|
||||
m_hTimeEventThread = CreateThread( NULL, 0, _TimeEventThread, NULL, 0, &m_dwTimeEventID );
|
||||
|
||||
//==============================
|
||||
// Init CriticalSection
|
||||
//==============================
|
||||
ZeroMemory(&m_csSoundUpdate, sizeof(CRITICAL_SECTION));
|
||||
InitializeCriticalSection(&m_csSoundUpdate);
|
||||
|
||||
//<2F>ʱ<EFBFBD>ȭ<EFBFBD><C8AD><EFBFBD><EFBFBD>
|
||||
m_bInit = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CSoundMgr::SetPrimaryBufferFormat(DWORD dwPrimaryChannels, DWORD dwPrimaryFreq, DWORD dwPrimaryBitRate)
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;
|
||||
|
||||
// Get the primary buffer
|
||||
DSBUFFERDESC dsbd;
|
||||
ZeroMemory( &dsbd, sizeof(DSBUFFERDESC) );
|
||||
dsbd.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||
dsbd.dwBufferBytes = 0;
|
||||
dsbd.lpwfxFormat = NULL;
|
||||
|
||||
if(FAILED(m_pDS->CreateSoundBuffer(&dsbd, &pDSBPrimary, NULL))) return false;
|
||||
|
||||
WAVEFORMATEX wfx;
|
||||
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
|
||||
wfx.wFormatTag = (WORD) WAVE_FORMAT_PCM;
|
||||
wfx.nChannels = (WORD) dwPrimaryChannels;
|
||||
wfx.nSamplesPerSec = (DWORD) dwPrimaryFreq;
|
||||
wfx.wBitsPerSample = (WORD) dwPrimaryBitRate;
|
||||
wfx.nBlockAlign = (WORD) (wfx.wBitsPerSample / 8 * wfx.nChannels);
|
||||
wfx.nAvgBytesPerSec = (DWORD) (wfx.nSamplesPerSec * wfx.nBlockAlign);
|
||||
|
||||
if( FAILED(pDSBPrimary->SetFormat(&wfx)) )
|
||||
{
|
||||
SAFE_RELEASE( pDSBPrimary );
|
||||
return false;
|
||||
}
|
||||
|
||||
SAFE_RELEASE( pDSBPrimary );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::ReleaseAllData()
|
||||
{
|
||||
m_hDestroyEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
m_bInit = false;
|
||||
WaitForSingleObject( m_hDestroyEvent, INFINITE );
|
||||
|
||||
SOUNDMAP::iterator iter_snd;
|
||||
SOUND3DMAP::iterator iter_snd3d;
|
||||
STREAMINGMAP::iterator iter_strm;
|
||||
STREAMING3DMAP::iterator iter_strm3d;
|
||||
|
||||
for( iter_snd = m_SoundMap.begin(); iter_snd != m_SoundMap.end(); iter_snd++ )
|
||||
{
|
||||
SAFE_DELETE( iter_snd->second );
|
||||
}
|
||||
|
||||
for( iter_snd3d = m_Sound3DMap.begin(); iter_snd3d != m_Sound3DMap.end(); iter_snd3d++ )
|
||||
{
|
||||
SAFE_DELETE( iter_snd3d->second );
|
||||
}
|
||||
|
||||
for( iter_strm = m_StreamingMap.begin(); iter_strm != m_StreamingMap.end(); iter_strm++ )
|
||||
{
|
||||
SAFE_DELETE( iter_strm->second );
|
||||
}
|
||||
|
||||
for( iter_strm3d = m_Streaming3DMap.begin(); iter_strm3d != m_Streaming3DMap.end(); iter_strm3d++ )
|
||||
{
|
||||
SAFE_DELETE( iter_strm3d->second );
|
||||
}
|
||||
|
||||
m_SoundMap.clear();
|
||||
m_Sound3DMap.clear();
|
||||
m_StreamingMap.clear();
|
||||
m_Streaming3DMap.clear();
|
||||
|
||||
CloseHandle( m_hDestroyEvent );
|
||||
CloseHandle( m_hTimeEventThread );
|
||||
DeleteCriticalSection( &m_csSoundUpdate );
|
||||
|
||||
SAFE_DELETE( m_pListener );
|
||||
SAFE_RELEASE( m_pDS );
|
||||
}
|
||||
|
||||
|
||||
bool CSoundMgr::GetSound( CSound*& pSound, char* strFileName, DWORD dwNumBuffers )
|
||||
{
|
||||
SimpleCircleBuffer(SOUND);
|
||||
SOUNDMAP::iterator iter;
|
||||
DWORD dwHashID = GetHashID(strFileName);
|
||||
iter = m_SoundMap.find( dwHashID );
|
||||
|
||||
if( iter != m_SoundMap.end() )
|
||||
{
|
||||
pSound = iter->second;
|
||||
pSound->SetVolume(1);
|
||||
pSound->m_iPreserveScore += 50;
|
||||
return true;
|
||||
}
|
||||
|
||||
pSound = NULL;
|
||||
pSound = new CSound();
|
||||
|
||||
if( pSound )
|
||||
{
|
||||
if( !pSound->Create( strFileName, dwNumBuffers ) )
|
||||
{
|
||||
SAFE_DELETE( pSound );
|
||||
return false;
|
||||
}
|
||||
|
||||
pSound->SetVolume(1);
|
||||
pSound->m_iPreserveScore += 50;
|
||||
m_SoundMap.insert( SOUNDMAP::iterator::value_type(dwHashID, pSound) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CSoundMgr::GetSound3D( CSound3D*& pSound3D, const char* strFileName, DWORD dwNumBuffers )
|
||||
{
|
||||
SimpleCircleBuffer(SOUND3D);
|
||||
SOUND3DMAP::iterator iter;
|
||||
DWORD dwHashID = GetHashID(strFileName);
|
||||
iter = m_Sound3DMap.find( dwHashID );
|
||||
|
||||
if( iter != m_Sound3DMap.end() )
|
||||
{
|
||||
pSound3D = iter->second;
|
||||
pSound3D->SetVolume(1);
|
||||
pSound3D->m_pSound->m_iPreserveScore += 50;
|
||||
return true;
|
||||
}
|
||||
|
||||
pSound3D = NULL;
|
||||
pSound3D = new CSound3D();
|
||||
|
||||
if( pSound3D )
|
||||
{
|
||||
if( !pSound3D->Create( strFileName, dwNumBuffers ) )
|
||||
{
|
||||
SAFE_DELETE( pSound3D );
|
||||
return false;
|
||||
}
|
||||
|
||||
pSound3D->SetVolume(1);
|
||||
pSound3D->m_pSound->m_iPreserveScore += 50;
|
||||
m_Sound3DMap.insert( SOUND3DMAP::iterator::value_type(dwHashID, pSound3D) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::GetStreamingSound( CStreamingSound*& pStreamingSound, char* strFileName )
|
||||
{
|
||||
SimpleCircleBuffer(STREAM);
|
||||
STREAMINGMAP::iterator iter;
|
||||
DWORD dwHashID = GetHashID(strFileName);
|
||||
iter = m_StreamingMap.find( dwHashID );
|
||||
|
||||
if( iter != m_StreamingMap.end() )
|
||||
{
|
||||
pStreamingSound = iter->second;
|
||||
pStreamingSound->SetVolume(1);
|
||||
return;
|
||||
}
|
||||
|
||||
pStreamingSound = new CStreamingSound();
|
||||
|
||||
if( !pStreamingSound->Create( strFileName ) )
|
||||
{
|
||||
SAFE_DELETE(pStreamingSound);
|
||||
return;
|
||||
}
|
||||
|
||||
pStreamingSound->SetVolume(1);
|
||||
m_StreamingMap.insert( STREAMINGMAP::iterator::value_type(dwHashID, pStreamingSound) );
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::GetStreamingSound3D( CStreamingSound3D*& pStreamingSound3D, char* strFileName )
|
||||
{
|
||||
SimpleCircleBuffer(STREAM3D);
|
||||
STREAMING3DMAP::iterator iter;
|
||||
DWORD dwHashID = GetHashID(strFileName);
|
||||
iter = m_Streaming3DMap.find( dwHashID );
|
||||
|
||||
if( iter != m_Streaming3DMap.end() )
|
||||
{
|
||||
pStreamingSound3D = iter->second;
|
||||
pStreamingSound3D->SetVolume(1);
|
||||
return;
|
||||
}
|
||||
|
||||
pStreamingSound3D = new CStreamingSound3D();
|
||||
if( !pStreamingSound3D->Create(strFileName) )
|
||||
{
|
||||
SAFE_DELETE(pStreamingSound3D);
|
||||
return;
|
||||
}
|
||||
|
||||
pStreamingSound3D->SetVolume(1);
|
||||
m_Streaming3DMap.insert( STREAMING3DMAP::iterator::value_type(dwHashID, pStreamingSound3D) );
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::InsertStream( CStreamingSound* pStreamSound )
|
||||
{
|
||||
m_StreamProcess.push_back( pStreamSound );
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::RemoveStream( CStreamingSound* pStreamSound )
|
||||
{
|
||||
m_StreamRemoval.push_back( pStreamSound );
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::ServiceStreamingBuffers()
|
||||
{
|
||||
STREAMLIST::iterator itr;
|
||||
for(itr = m_StreamRemoval.begin(); itr != m_StreamRemoval.end(); itr++)
|
||||
{
|
||||
STREAMLIST::iterator itor = find(m_StreamProcess.begin(), m_StreamProcess.end(), *itr);
|
||||
if(itor != m_StreamProcess.end())
|
||||
m_StreamProcess.erase(itor);
|
||||
}
|
||||
|
||||
m_StreamRemoval.clear();
|
||||
|
||||
for(itr = m_StreamProcess.begin(); itr != m_StreamProcess.end(); itr++)
|
||||
{
|
||||
(*itr)->ServiceBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DWORD CSoundMgr::GetUseMemory()
|
||||
{
|
||||
DWORD dwSize = 0;
|
||||
SOUNDMAP::iterator iter_snd;
|
||||
SOUND3DMAP::iterator iter_snd3d;
|
||||
STREAMINGMAP::iterator iter_strm;
|
||||
STREAMING3DMAP::iterator iter_strm3d;
|
||||
|
||||
for( iter_snd = m_SoundMap.begin(); iter_snd != m_SoundMap.end(); iter_snd++ )
|
||||
{
|
||||
dwSize += iter_snd->second->GetAllBufferSize();
|
||||
}
|
||||
|
||||
for( iter_snd3d = m_Sound3DMap.begin(); iter_snd3d != m_Sound3DMap.end(); iter_snd3d++ )
|
||||
{
|
||||
dwSize += iter_snd3d->second->GetAllBufferSize();
|
||||
}
|
||||
|
||||
for( iter_strm = m_StreamingMap.begin(); iter_strm != m_StreamingMap.end(); iter_strm++ )
|
||||
{
|
||||
dwSize += iter_strm->second->GetBufferSize();
|
||||
}
|
||||
|
||||
for( iter_strm3d = m_Streaming3DMap.begin(); iter_strm3d != m_Streaming3DMap.end(); iter_strm3d++ )
|
||||
{
|
||||
dwSize += iter_strm3d->second->GetBufferSize();
|
||||
}
|
||||
|
||||
return dwSize;
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::SimpleCircleBuffer( DWORD dwType )
|
||||
{
|
||||
switch( dwType )
|
||||
{
|
||||
case SOUND:
|
||||
{
|
||||
if( m_SoundMap.size() > m_InitProp.m_dwLimitSound )
|
||||
{
|
||||
SOUNDMAP::iterator iter_snd;
|
||||
// DWORD dwFlowTime;
|
||||
for( iter_snd = m_SoundMap.begin(); iter_snd != m_SoundMap.end(); )
|
||||
{
|
||||
if( !iter_snd->second->IsPlaying() )
|
||||
{
|
||||
--iter_snd->second->m_iPreserveScore;
|
||||
if( iter_snd->second->m_iPreserveScore < 0 )
|
||||
{
|
||||
SOUNDMAP::iterator iter_delete;
|
||||
iter_delete = iter_snd;
|
||||
++iter_snd;
|
||||
SAFE_DELETE( iter_delete->second );
|
||||
m_SoundMap.erase( iter_delete );
|
||||
if( m_SoundMap.size() <= m_InitProp.m_dwLimitSound ) break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++iter_snd;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SOUND3D:
|
||||
{
|
||||
if( m_Sound3DMap.size() > m_InitProp.m_dwLimitSound3D )
|
||||
{
|
||||
SOUND3DMAP::iterator iter_snd3d;
|
||||
// DWORD dwFlowTime;
|
||||
for( iter_snd3d = m_Sound3DMap.begin(); iter_snd3d != m_Sound3DMap.end(); )
|
||||
{
|
||||
if( !iter_snd3d->second->IsPlaying() )
|
||||
{
|
||||
--iter_snd3d->second->m_pSound->m_iPreserveScore;
|
||||
if( iter_snd3d->second->m_pSound->m_iPreserveScore < 0 )
|
||||
{
|
||||
SOUND3DMAP::iterator iter_delete;
|
||||
iter_delete = iter_snd3d;
|
||||
++iter_snd3d;
|
||||
SAFE_DELETE( iter_delete->second );
|
||||
m_Sound3DMap.erase( iter_delete );
|
||||
if( m_Sound3DMap.size() <= m_InitProp.m_dwLimitSound3D ) break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
++iter_snd3d;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case STREAM:
|
||||
{
|
||||
if( m_StreamingMap.size() > m_InitProp.m_dwLimitStreaming )
|
||||
{
|
||||
STREAMINGMAP::iterator iter_strm;
|
||||
for( iter_strm = m_StreamingMap.begin(); iter_strm != m_StreamingMap.end(); )
|
||||
{
|
||||
if( !iter_strm->second->IsPlaying() )
|
||||
{
|
||||
STREAMINGMAP::iterator iter_delete;
|
||||
iter_delete = iter_strm;
|
||||
++iter_strm;
|
||||
SAFE_DELETE( iter_delete->second );
|
||||
m_StreamingMap.erase( iter_delete );
|
||||
if( m_StreamingMap.size() <= m_InitProp.m_dwLimitStreaming ) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
++iter_strm;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case STREAM3D:
|
||||
{
|
||||
if( m_Streaming3DMap.size() > m_InitProp.m_dwLimitStreaming )
|
||||
{
|
||||
STREAMING3DMAP::iterator iter_strm3d;
|
||||
for( iter_strm3d = m_Streaming3DMap.begin(); iter_strm3d != m_Streaming3DMap.end(); )
|
||||
{
|
||||
if( !iter_strm3d->second->IsPlaying() )
|
||||
{
|
||||
STREAMING3DMAP::iterator iter_delete;
|
||||
iter_delete = iter_strm3d;
|
||||
++iter_strm3d;
|
||||
SAFE_DELETE( iter_delete->second );
|
||||
m_Streaming3DMap.erase( iter_delete );
|
||||
if( m_Streaming3DMap.size() <= m_InitProp.m_dwLimitStreaming ) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
++iter_strm3d;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DSCAPS CSoundMgr::GetCaps()
|
||||
{
|
||||
return m_Caps;
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::SetVolume( float fVol )
|
||||
{
|
||||
m_fMasterVolume = fVol;
|
||||
}
|
||||
|
||||
|
||||
float CSoundMgr::GetVolume()
|
||||
{
|
||||
return m_fMasterVolume;
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::_Destroy()
|
||||
{
|
||||
if( ms_pSoundMgr )
|
||||
{
|
||||
ms_pSoundMgr->ReleaseAllData();
|
||||
}
|
||||
|
||||
SAFE_DELETE( ms_pSoundMgr );
|
||||
}
|
||||
|
||||
|
||||
void CSoundMgr::AllStopStreamingSound()
|
||||
{
|
||||
STREAMINGMAP::iterator iter;
|
||||
for( iter = m_StreamingMap.begin(); iter != m_StreamingMap.end(); iter++ )
|
||||
{
|
||||
iter->second->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CSoundMgr::AllStopStreamingSound3D()
|
||||
{
|
||||
STREAMING3DMAP::iterator iter;
|
||||
for( iter = m_Streaming3DMap.begin(); iter != m_Streaming3DMap.end(); iter++ )
|
||||
{
|
||||
iter->second->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
DWORD CSoundMgr::GetHashID( const char* strFileName )
|
||||
{
|
||||
DWORD id = 0;
|
||||
int iLength = (int)strlen(strFileName);
|
||||
|
||||
for(int i=0;i < iLength; ++i)
|
||||
{
|
||||
id += (( i + 1) * strFileName[i]);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
void CSoundMgr::ThreadFunc()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
Sleep( 50 );
|
||||
|
||||
if( !m_bInit )
|
||||
{
|
||||
SetEvent( m_hDestroyEvent );
|
||||
break;
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
EnterCriticalSection( &m_csSoundUpdate );
|
||||
//-----------------------------------------
|
||||
static int iServiceStreams = 0;
|
||||
if((iServiceStreams++) % 12 == 1) ServiceStreamingBuffers();
|
||||
m_pListener->Update();
|
||||
//-----------------------------------------
|
||||
LeaveCriticalSection( &m_csSoundUpdate );
|
||||
//-----------------------------------------
|
||||
}
|
||||
}
|
||||
99
Engine/SoundLib/SoundMgr.h
Normal file
99
Engine/SoundLib/SoundMgr.h
Normal file
@@ -0,0 +1,99 @@
|
||||
// SoundMgr.h: interface for the CSoundMgr class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_SOUNDMGR_H__5CBFAA8B_CAA9_47E7_8C9C_456C45247983__INCLUDED_)
|
||||
#define AFX_SOUNDMGR_H__5CBFAA8B_CAA9_47E7_8C9C_456C45247983__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
#include <dsound.h>
|
||||
#include "DefineSound.h"
|
||||
#include "Common.h"
|
||||
#include "Sound.h"
|
||||
#include "Sound3D.h"
|
||||
#include "StreamingSound.h"
|
||||
#include "StreamingSound3D.h"
|
||||
#include "Listener.h"
|
||||
#include "SoundMgrInit.h"
|
||||
using namespace std;
|
||||
|
||||
class CSoundMgr
|
||||
{
|
||||
enum eCIRCLEBUFTYPE
|
||||
{
|
||||
SOUND = 0,
|
||||
SOUND3D,
|
||||
STREAM,
|
||||
STREAM3D,
|
||||
};
|
||||
|
||||
private:
|
||||
typedef map<DWORD, CSound*> SOUNDMAP;
|
||||
typedef map<DWORD, CSound3D*> SOUND3DMAP;
|
||||
typedef map<DWORD, CStreamingSound*> STREAMINGMAP;
|
||||
typedef map<DWORD, CStreamingSound3D*> STREAMING3DMAP;
|
||||
typedef list<CStreamingSound*> STREAMLIST;
|
||||
typedef list<CStreamingSound3D*> STREAM3DLIST;
|
||||
|
||||
LPDIRECTSOUND8 m_pDS;
|
||||
static CSoundMgr* ms_pSoundMgr;
|
||||
bool m_bInit;
|
||||
SoundMgrInit m_InitProp;
|
||||
DSCAPS m_Caps;
|
||||
CListener* m_pListener;
|
||||
SOUNDMAP m_SoundMap;
|
||||
SOUND3DMAP m_Sound3DMap;
|
||||
STREAMINGMAP m_StreamingMap;
|
||||
STREAMING3DMAP m_Streaming3DMap;
|
||||
HANDLE m_hTimeEventThread;
|
||||
DWORD m_dwTimeEventID;
|
||||
STREAMLIST m_StreamProcess;
|
||||
STREAMLIST m_StreamRemoval;
|
||||
CRITICAL_SECTION m_csSoundUpdate;
|
||||
float m_fMasterVolume;
|
||||
|
||||
public:
|
||||
HANDLE m_hDestroyEvent;
|
||||
|
||||
private:
|
||||
bool SetPrimaryBufferFormat(DWORD dwPrimaryChannels,
|
||||
DWORD dwPrimaryFreq, DWORD dwPrimaryBitRate);
|
||||
void SimpleCircleBuffer( DWORD dwType );
|
||||
DWORD GetHashID( const char* strFileName );
|
||||
void ServiceStreamingBuffers();
|
||||
|
||||
public:
|
||||
inline LPDIRECTSOUND8 GetDirectSound() { return m_pDS; }
|
||||
inline CRITICAL_SECTION& GetUpdateCS() { return m_csSoundUpdate; }
|
||||
void InsertStream( CStreamingSound* pStreamSound );
|
||||
void RemoveStream( CStreamingSound* pStreamSound );
|
||||
void ThreadFunc();
|
||||
|
||||
public:
|
||||
CSoundMgr() {};
|
||||
virtual ~CSoundMgr() {};
|
||||
|
||||
bool Init( SoundMgrInit& Init );
|
||||
void ReleaseAllData();
|
||||
inline bool IsInitialized() { return m_bInit; }
|
||||
inline CListener* GetListener() { return m_pListener; }
|
||||
bool GetSound( CSound*& pSound, char* strFileName, DWORD dwNumBuffers=5 );
|
||||
bool GetSound3D( CSound3D*& pSound3D, const char* strFileName, DWORD dwNumBuffers=10 );
|
||||
void GetStreamingSound( CStreamingSound*& pStreamingSound, char* strFileName );
|
||||
void GetStreamingSound3D( CStreamingSound3D*& pStreamingSound3D, char* strFileName );
|
||||
void AllStopStreamingSound();
|
||||
void AllStopStreamingSound3D();
|
||||
DWORD GetUseMemory();
|
||||
DSCAPS GetCaps();
|
||||
void SetVolume( float fVol );
|
||||
float GetVolume();
|
||||
inline SoundMgrInit* GetInitProp() { return &m_InitProp; }
|
||||
|
||||
static CSoundMgr* _GetInstance();
|
||||
static void _Destroy();
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_SOUNDMGR_H__5CBFAA8B_CAA9_47E7_8C9C_456C45247983__INCLUDED_)
|
||||
38
Engine/SoundLib/SoundMgrInit.h
Normal file
38
Engine/SoundLib/SoundMgrInit.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef ___SOUNDMGRINIT_H___
|
||||
#define ___SOUNDMGRINIT_H___
|
||||
|
||||
#include <dsound.h>
|
||||
#include "DefineSound.h"
|
||||
|
||||
class SoundMgrInit
|
||||
{
|
||||
public:
|
||||
|
||||
HWND m_hWnd;
|
||||
bool m_bUseEAX;
|
||||
GUID m_guidSound3DAlgorithm;
|
||||
DWORD m_dwPrimaryFrequency;
|
||||
DWORD m_dwPrimaryChannels;
|
||||
DWORD m_dwPrimaryBitRate;
|
||||
DWORD m_dwLimitSound;
|
||||
DWORD m_dwLimitSound3D;
|
||||
DWORD m_dwLimitStreaming;
|
||||
|
||||
SoundMgrInit() { Clear(); };
|
||||
virtual ~SoundMgrInit() {};
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_hWnd = 0;
|
||||
m_bUseEAX = false;
|
||||
m_guidSound3DAlgorithm = SOUND_ALGORITHM_NO;
|
||||
m_dwPrimaryFrequency = SOUND_SAMPLE_22k;
|
||||
m_dwPrimaryChannels = 2;
|
||||
m_dwPrimaryBitRate = 16;
|
||||
m_dwLimitSound = 5;
|
||||
m_dwLimitSound3D = 20;
|
||||
m_dwLimitStreaming = 10;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //___SOUNDMGRINIT_H___
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user