x
This commit is contained in:
@@ -0,0 +1,308 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Blitz2DRelease|Win32">
|
||||
<Configuration>Blitz2DRelease</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Blitz3DRelease|Win32">
|
||||
<Configuration>Blitz3DRelease</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Template|Win32">
|
||||
<Configuration>Template</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<SccProjectName />
|
||||
<SccLocalPath />
|
||||
<ProjectGuid>{BE0BA538-6215-4836-9227-1D3627E40D61}</ProjectGuid>
|
||||
<WindowsTargetPlatformVersion>10.0.10586.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Template|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<UseOfMfc>false</UseOfMfc>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">
|
||||
<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" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="$(VCTargetsPath)Microsoft.Cpp.UpgradeFromVC60.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>.\Release\</OutDir>
|
||||
<IntDir>.\Release\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">
|
||||
<OutDir>.\blitz3d___Win32_Blitz2DRelease\</OutDir>
|
||||
<IntDir>.\blitz3d___Win32_Blitz2DRelease\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">
|
||||
<OutDir>.\blitz3d___Win32_Blitz3DRelease\</OutDir>
|
||||
<IntDir>.\blitz3d___Win32_Blitz3DRelease\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>..\#Build\$(ProjectName)\$(ConfigurationName)\</OutDir>
|
||||
<IntDir>..\#Intermediate\$(ProjectName)\$(ConfigurationName)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Release\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Release\blitz3d.pch</PrecompiledHeaderOutputFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>std.h</PrecompiledHeaderFile>
|
||||
<ObjectFileName>.\Release\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Release\</ProgramDataBaseFileName>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Release\blitz3d.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Release\blitz3d.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\blitz3d___Win32_Blitz2DRelease\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\blitz3d___Win32_Blitz2DRelease\blitz3d.pch</PrecompiledHeaderOutputFile>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>std.h</PrecompiledHeaderFile>
|
||||
<ObjectFileName>.\blitz3d___Win32_Blitz2DRelease\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\blitz3d___Win32_Blitz2DRelease\</ProgramDataBaseFileName>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\blitz3d___Win32_Blitz2DRelease\blitz3d.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\blitz3d___Win32_Blitz2DRelease\blitz3d.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<StringPooling>true</StringPooling>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PreprocessorDefinitions>_LIB;WIN32;NDEBUG;PRO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\blitz3d___Win32_Blitz3DRelease\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\blitz3d___Win32_Blitz3DRelease\blitz3d.pch</PrecompiledHeaderOutputFile>
|
||||
<PrecompiledHeader />
|
||||
<ObjectFileName>.\blitz3d___Win32_Blitz3DRelease\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\blitz3d___Win32_Blitz3DRelease\</ProgramDataBaseFileName>
|
||||
<CallingConvention>StdCall</CallingConvention>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\blitz3d___Win32_Blitz3DRelease\blitz3d.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\blitz3d___Win32_Blitz3DRelease\blitz3d.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<InlineFunctionExpansion>Default</InlineFunctionExpansion>
|
||||
<FunctionLevelLinking>false</FunctionLevelLinking>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AssemblerListingLocation>.\Debug\</AssemblerListingLocation>
|
||||
<PrecompiledHeaderOutputFile>.\Debug\blitz3d.pch</PrecompiledHeaderOutputFile>
|
||||
<ObjectFileName>.\Debug\</ObjectFileName>
|
||||
<ProgramDataBaseFileName>.\Debug\</ProgramDataBaseFileName>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
</ClCompile>
|
||||
<ResourceCompile>
|
||||
<Culture>0x0409</Culture>
|
||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ResourceCompile>
|
||||
<Bscmake>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Debug\blitz3d.bsc</OutputFile>
|
||||
</Bscmake>
|
||||
<Lib>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<OutputFile>.\Debug\blitz3d.lib</OutputFile>
|
||||
</Lib>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="animation.cpp" />
|
||||
<ClCompile Include="animator.cpp" />
|
||||
<ClCompile Include="brush.cpp" />
|
||||
<ClCompile Include="cachedtexture.cpp" />
|
||||
<ClCompile Include="camera.cpp" />
|
||||
<ClCompile Include="collision.cpp" />
|
||||
<ClCompile Include="entity.cpp" />
|
||||
<ClCompile Include="frustum.cpp" />
|
||||
<ClCompile Include="geom.cpp" />
|
||||
<ClCompile Include="light.cpp" />
|
||||
<ClCompile Include="listener.cpp" />
|
||||
<ClCompile Include="loader_3ds.cpp" />
|
||||
<ClCompile Include="loader_b3d.cpp" />
|
||||
<ClCompile Include="loader_x.cpp" />
|
||||
<ClCompile Include="md2model.cpp" />
|
||||
<ClCompile Include="md2norms.cpp" />
|
||||
<ClCompile Include="md2rep.cpp" />
|
||||
<ClCompile Include="meshcollider.cpp" />
|
||||
<ClCompile Include="meshloader.cpp" />
|
||||
<ClCompile Include="meshmodel.cpp" />
|
||||
<ClCompile Include="meshutil.cpp" />
|
||||
<ClCompile Include="mirror.cpp" />
|
||||
<ClCompile Include="model.cpp" />
|
||||
<ClCompile Include="object.cpp" />
|
||||
<ClCompile Include="pivot.cpp" />
|
||||
<ClCompile Include="planemodel.cpp" />
|
||||
<ClCompile Include="q3bspmodel.cpp" />
|
||||
<ClCompile Include="q3bsprep.cpp" />
|
||||
<ClCompile Include="sprite.cpp" />
|
||||
<ClCompile Include="std.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">std.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Blitz2DRelease|Win32'">std.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Blitz3DRelease|Win32'">std.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="surface.cpp" />
|
||||
<ClCompile Include="terrain.cpp" />
|
||||
<ClCompile Include="terrainrep.cpp" />
|
||||
<ClCompile Include="texture.cpp" />
|
||||
<ClCompile Include="world.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="animation.h" />
|
||||
<ClInclude Include="animator.h" />
|
||||
<ClInclude Include="blitz3d.h" />
|
||||
<ClInclude Include="brush.h" />
|
||||
<ClInclude Include="cachedtexture.h" />
|
||||
<ClInclude Include="camera.h" />
|
||||
<ClInclude Include="collision.h" />
|
||||
<ClInclude Include="entity.h" />
|
||||
<ClInclude Include="frustum.h" />
|
||||
<ClInclude Include="geom.h" />
|
||||
<ClInclude Include="light.h" />
|
||||
<ClInclude Include="listener.h" />
|
||||
<ClInclude Include="loader_3ds.h" />
|
||||
<ClInclude Include="loader_b3d.h" />
|
||||
<ClInclude Include="loader_x.h" />
|
||||
<ClInclude Include="md2model.h" />
|
||||
<ClInclude Include="md2norms.h" />
|
||||
<ClInclude Include="md2rep.h" />
|
||||
<ClInclude Include="meshcollider.h" />
|
||||
<ClInclude Include="meshloader.h" />
|
||||
<ClInclude Include="meshmodel.h" />
|
||||
<ClInclude Include="meshutil.h" />
|
||||
<ClInclude Include="mirror.h" />
|
||||
<ClInclude Include="model.h" />
|
||||
<ClInclude Include="object.h" />
|
||||
<ClInclude Include="pivot.h" />
|
||||
<ClInclude Include="planemodel.h" />
|
||||
<ClInclude Include="q3bspmodel.h" />
|
||||
<ClInclude Include="q3bsprep.h" />
|
||||
<ClInclude Include="rendercontext.h" />
|
||||
<ClInclude Include="sprite.h" />
|
||||
<ClInclude Include="std.h" />
|
||||
<ClInclude Include="surface.h" />
|
||||
<ClInclude Include="terrain.h" />
|
||||
<ClInclude Include="terrainrep.h" />
|
||||
<ClInclude Include="texture.h" />
|
||||
<ClInclude Include="world.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,233 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{962a947f-b247-4138-9efd-8b71759b7a57}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{8867a7d7-3bbe-4ef6-a38a-cd4e1a7180d9}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="animation.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="animator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="brush.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="cachedtexture.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="camera.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="collision.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="entity.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="frustum.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="geom.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="light.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="listener.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="loader_3ds.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="loader_b3d.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="loader_x.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="md2model.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="md2norms.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="md2rep.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meshcollider.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meshloader.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meshmodel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meshutil.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="mirror.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="model.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="object.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pivot.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="planemodel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="q3bspmodel.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="q3bsprep.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sprite.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="std.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="surface.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="terrain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="terrainrep.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="texture.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="world.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="animation.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="animator.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="blitz3d.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="brush.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="cachedtexture.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="camera.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="collision.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="entity.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="frustum.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="geom.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="light.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="listener.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="loader_3ds.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="loader_b3d.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="loader_x.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="md2model.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="md2norms.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="md2rep.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="meshcollider.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="meshloader.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="meshmodel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="meshutil.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="mirror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="model.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="object.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pivot.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="planemodel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="q3bspmodel.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="q3bsprep.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="rendercontext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sprite.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="std.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="surface.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="terrain.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="terrainrep.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="texture.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="world.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "std.h"
|
||||
#include "collision.h"
|
||||
|
||||
const float COLLISION_EPSILON=.001f;
|
||||
const float COLLISION_FLT_EPSILON=.001f;
|
||||
|
||||
/*
|
||||
//
|
||||
@@ -202,7 +202,7 @@ bool Collision::update( const Line &line,float t,const Vector &n ){
|
||||
if( t>time ) return false;
|
||||
Plane p(line*t,n);
|
||||
if( p.n.dot( line.d )>=0 ) return false;
|
||||
if( p.distance(line.o)<-COLLISION_EPSILON ) return false;
|
||||
if( p.distance(line.o)<-COLLISION_FLT_EPSILON ) return false;
|
||||
|
||||
time=t;
|
||||
normal=n;
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "geom.h"
|
||||
|
||||
extern const float COLLISION_EPSILON;
|
||||
extern const float COLLISION_FLT_EPSILON;
|
||||
|
||||
struct Collision{
|
||||
float time;
|
||||
|
||||
+331
-331
@@ -10,549 +10,549 @@ class Plane;
|
||||
class Matrix;
|
||||
class Transform;
|
||||
|
||||
const float PI=3.14159265359f; //180 degrees
|
||||
const float TWOPI=PI*2.0f; //360 degrees
|
||||
const float HALFPI=PI*.5f; //90 degrees
|
||||
const float QUARTERPI=PI*.25f; //45 degrees
|
||||
const float EPSILON=.000001f; //small value
|
||||
const float INFINITY=10000000.0f; //big value
|
||||
static float PI = 3.14159265359f; //180 degrees
|
||||
static float TWOPI = PI*2.0f; //360 degrees
|
||||
static float HALFPI = PI*.5f; //90 degrees
|
||||
static float QUARTERPI = PI*.25f; //45 degrees
|
||||
//static float FLT_EPSILON=.000001f; //small value
|
||||
//static float INFINITY=10000000.0f; //big value
|
||||
|
||||
class Vector{
|
||||
class Vector {
|
||||
public:
|
||||
float x,y,z;
|
||||
float x, y, z;
|
||||
|
||||
Vector():x(0),y(0),z(0){
|
||||
Vector() :x(0), y(0), z(0) {
|
||||
}
|
||||
Vector( float x,float y,float z ):x(x),y(y),z(z){
|
||||
Vector(float x, float y, float z) :x(x), y(y), z(z) {
|
||||
}
|
||||
operator float*(){
|
||||
operator float*() {
|
||||
return &x;
|
||||
}
|
||||
operator const float *(){
|
||||
operator const float *() {
|
||||
return &x;
|
||||
}
|
||||
float &operator[]( int n ){
|
||||
return (&x)[n];
|
||||
float &operator[](int n) {
|
||||
return (&x)[n];
|
||||
}
|
||||
float operator[]( int n )const{
|
||||
return (&x)[n];
|
||||
float operator[](int n)const {
|
||||
return (&x)[n];
|
||||
}
|
||||
Vector operator-()const{
|
||||
return Vector( -x,-y,-z );
|
||||
Vector operator-()const {
|
||||
return Vector(-x, -y, -z);
|
||||
}
|
||||
Vector operator*( float scale )const{
|
||||
return Vector( x*scale,y*scale,z*scale );
|
||||
Vector operator*(float scale)const {
|
||||
return Vector(x*scale, y*scale, z*scale);
|
||||
}
|
||||
Vector operator*( const Vector &q )const{
|
||||
return Vector( x*q.x,y*q.y,z*q.z );
|
||||
Vector operator*(const Vector &q)const {
|
||||
return Vector(x*q.x, y*q.y, z*q.z);
|
||||
}
|
||||
Vector operator/( float scale )const{
|
||||
return Vector( x/scale,y/scale,z/scale );
|
||||
Vector operator/(float scale)const {
|
||||
return Vector(x / scale, y / scale, z / scale);
|
||||
}
|
||||
Vector operator/( const Vector &q )const{
|
||||
return Vector( x/q.x,y/q.y,z/q.z );
|
||||
Vector operator/(const Vector &q)const {
|
||||
return Vector(x / q.x, y / q.y, z / q.z);
|
||||
}
|
||||
Vector operator+( const Vector &q )const{
|
||||
return Vector( x+q.x,y+q.y,z+q.z );
|
||||
Vector operator+(const Vector &q)const {
|
||||
return Vector(x + q.x, y + q.y, z + q.z);
|
||||
}
|
||||
Vector operator-( const Vector &q )const{
|
||||
return Vector( x-q.x,y-q.y,z-q.z );
|
||||
Vector operator-(const Vector &q)const {
|
||||
return Vector(x - q.x, y - q.y, z - q.z);
|
||||
}
|
||||
Vector &operator*=( float scale ){
|
||||
x*=scale;y*=scale;z*=scale;return *this;
|
||||
Vector &operator*=(float scale) {
|
||||
x *= scale; y *= scale; z *= scale; return *this;
|
||||
}
|
||||
Vector &operator*=( const Vector &q ){
|
||||
x*=q.x;y*=q.y;z*=q.z;return *this;
|
||||
Vector &operator*=(const Vector &q) {
|
||||
x *= q.x; y *= q.y; z *= q.z; return *this;
|
||||
}
|
||||
Vector &operator/=( float scale ){
|
||||
x/=scale;y/=scale;z/=scale;return *this;
|
||||
Vector &operator/=(float scale) {
|
||||
x /= scale; y /= scale; z /= scale; return *this;
|
||||
}
|
||||
Vector &operator/=( const Vector &q ){
|
||||
x/=q.x;y/=q.y;z/=q.z;return *this;
|
||||
Vector &operator/=(const Vector &q) {
|
||||
x /= q.x; y /= q.y; z /= q.z; return *this;
|
||||
}
|
||||
Vector &operator+=( const Vector &q ){
|
||||
x+=q.x;y+=q.y;z+=q.z;return *this;
|
||||
Vector &operator+=(const Vector &q) {
|
||||
x += q.x; y += q.y; z += q.z; return *this;
|
||||
}
|
||||
Vector &operator-=( const Vector &q ){
|
||||
x-=q.x;y-=q.y;z-=q.z;return *this;
|
||||
Vector &operator-=(const Vector &q) {
|
||||
x -= q.x; y -= q.y; z -= q.z; return *this;
|
||||
}
|
||||
bool operator<( const Vector &q )const{
|
||||
if( fabs(x-q.x)>EPSILON ) return x<q.x ? true : false;
|
||||
if( fabs(y-q.y)>EPSILON ) return y<q.y ? true : false;
|
||||
return fabs(z-q.z)>EPSILON && z<q.z;
|
||||
bool operator<(const Vector &q)const {
|
||||
if (fabs(x - q.x) > FLT_FLT_EPSILON) return x < q.x ? true : false;
|
||||
if (fabs(y - q.y) > FLT_FLT_EPSILON) return y < q.y ? true : false;
|
||||
return fabs(z - q.z) > FLT_FLT_EPSILON && z < q.z;
|
||||
}
|
||||
bool operator==( const Vector &q )const{
|
||||
return fabs(x-q.x)<=EPSILON && fabs(y-q.y)<=EPSILON && fabs(z-q.z)<=EPSILON;
|
||||
bool operator==(const Vector &q)const {
|
||||
return fabs(x - q.x) <= FLT_FLT_EPSILON && fabs(y - q.y) <= FLT_FLT_EPSILON && fabs(z - q.z) <= FLT_FLT_EPSILON;
|
||||
}
|
||||
bool operator!=( const Vector &q )const{
|
||||
return fabs(x-q.x)>EPSILON || fabs(y-q.y)>EPSILON || fabs(z-q.z)>EPSILON;
|
||||
bool operator!=(const Vector &q)const {
|
||||
return fabs(x - q.x) > FLT_FLT_EPSILON || fabs(y - q.y) > FLT_FLT_EPSILON || fabs(z - q.z) > FLT_FLT_EPSILON;
|
||||
}
|
||||
float dot( const Vector &q )const{
|
||||
return x*q.x+y*q.y+z*q.z;
|
||||
float dot(const Vector &q)const {
|
||||
return x*q.x + y*q.y + z*q.z;
|
||||
}
|
||||
Vector cross( const Vector &q )const{
|
||||
return Vector( y*q.z-z*q.y,z*q.x-x*q.z,x*q.y-y*q.x );
|
||||
Vector cross(const Vector &q)const {
|
||||
return Vector(y*q.z - z*q.y, z*q.x - x*q.z, x*q.y - y*q.x);
|
||||
}
|
||||
float length()const{
|
||||
return sqrtf(x*x+y*y+z*z);
|
||||
float length()const {
|
||||
return sqrtf(x*x + y*y + z*z);
|
||||
}
|
||||
float distance( const Vector &q )const{
|
||||
float dx=x-q.x,dy=y-q.y,dz=z-q.z;return sqrtf(dx*dx+dy*dy+dz*dz);
|
||||
float distance(const Vector &q)const {
|
||||
float dx = x - q.x, dy = y - q.y, dz = z - q.z; return sqrtf(dx*dx + dy*dy + dz*dz);
|
||||
}
|
||||
Vector normalized()const{
|
||||
float l=length();return Vector( x/l,y/l,z/l );
|
||||
Vector normalized()const {
|
||||
float l = length(); return Vector(x / l, y / l, z / l);
|
||||
}
|
||||
void normalize(){
|
||||
float l=length();x/=l;y/=l;z/=l;
|
||||
void normalize() {
|
||||
float l = length(); x /= l; y /= l; z /= l;
|
||||
}
|
||||
float yaw()const{
|
||||
return -atan2f( x,z );
|
||||
float yaw()const {
|
||||
return -atan2f(x, z);
|
||||
}
|
||||
float pitch()const{
|
||||
return -atan2f( y,sqrtf( x*x+z*z ) );
|
||||
float pitch()const {
|
||||
return -atan2f(y, sqrtf(x*x + z*z));
|
||||
}
|
||||
void clear(){
|
||||
x=y=z=0;
|
||||
void clear() {
|
||||
x = y = z = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class Line{
|
||||
class Line {
|
||||
public:
|
||||
Vector o,d;
|
||||
Line(){
|
||||
Vector o, d;
|
||||
Line() {
|
||||
}
|
||||
Line( const Vector &o,const Vector &d ):o(o),d(d){
|
||||
Line(const Vector &o, const Vector &d) :o(o), d(d) {
|
||||
}
|
||||
Line operator+( const Vector &q )const{
|
||||
return Line( o+q,d );
|
||||
Line operator+(const Vector &q)const {
|
||||
return Line(o + q, d);
|
||||
}
|
||||
Line operator-( const Vector &q )const{
|
||||
return Line( o-q,d );
|
||||
Line operator-(const Vector &q)const {
|
||||
return Line(o - q, d);
|
||||
}
|
||||
Vector operator*( float q )const{
|
||||
return o+d*q;
|
||||
Vector operator*(float q)const {
|
||||
return o + d*q;
|
||||
}
|
||||
Vector nearest( const Vector &q )const{
|
||||
return o+d*(d.dot(q-o)/d.dot(d));
|
||||
Vector nearest(const Vector &q)const {
|
||||
return o + d*(d.dot(q - o) / d.dot(d));
|
||||
}
|
||||
};
|
||||
|
||||
class Plane{
|
||||
class Plane {
|
||||
public:
|
||||
Vector n;
|
||||
float d;
|
||||
|
||||
Plane():d(0){
|
||||
Plane() :d(0) {
|
||||
}
|
||||
//normal/offset form
|
||||
Plane( const Vector &n,float d ):n(n),d(d){
|
||||
Plane(const Vector &n, float d) :n(n), d(d) {
|
||||
}
|
||||
//point/normal form
|
||||
Plane( const Vector &p,const Vector &n ):n(n),d(-n.dot(p)){
|
||||
Plane(const Vector &p, const Vector &n) :n(n), d(-n.dot(p)) {
|
||||
}
|
||||
//create plane from tri
|
||||
Plane( const Vector &v0,const Vector &v1,const Vector &v2 ){
|
||||
n=(v1-v0).cross(v2-v0).normalized();d=-n.dot(v0);
|
||||
Plane(const Vector &v0, const Vector &v1, const Vector &v2) {
|
||||
n = (v1 - v0).cross(v2 - v0).normalized(); d = -n.dot(v0);
|
||||
}
|
||||
Plane operator-()const{
|
||||
return Plane( -n,-d );
|
||||
Plane operator-()const {
|
||||
return Plane(-n, -d);
|
||||
}
|
||||
float t_intersect( const Line &q )const{
|
||||
return -distance(q.o)/n.dot(q.d);
|
||||
float t_intersect(const Line &q)const {
|
||||
return -distance(q.o) / n.dot(q.d);
|
||||
}
|
||||
Vector intersect( const Line &q )const{
|
||||
Vector intersect(const Line &q)const {
|
||||
return q*t_intersect(q);
|
||||
}
|
||||
Line intersect( const Plane &q )const{
|
||||
Vector lv=n.cross( q.n ).normalized();
|
||||
return Line( q.intersect( Line( nearest( n*-d ),n.cross(lv) ) ),lv );
|
||||
Line intersect(const Plane &q)const {
|
||||
Vector lv = n.cross(q.n).normalized();
|
||||
return Line(q.intersect(Line(nearest(n*-d), n.cross(lv))), lv);
|
||||
}
|
||||
Vector nearest( const Vector &q )const{
|
||||
return q-n*distance(q);
|
||||
Vector nearest(const Vector &q)const {
|
||||
return q - n*distance(q);
|
||||
}
|
||||
void negate(){
|
||||
n=-n;d=-d;
|
||||
void negate() {
|
||||
n = -n; d = -d;
|
||||
}
|
||||
float distance( const Vector &q )const{
|
||||
return n.dot(q)+d;
|
||||
float distance(const Vector &q)const {
|
||||
return n.dot(q) + d;
|
||||
}
|
||||
};
|
||||
|
||||
struct Quat{
|
||||
struct Quat {
|
||||
float w;
|
||||
Vector v;
|
||||
Quat():w(1){
|
||||
Quat() :w(1) {
|
||||
}
|
||||
Quat( float w,const Vector &v ):w(w),v(v){
|
||||
Quat(float w, const Vector &v) :w(w), v(v) {
|
||||
}
|
||||
Quat operator-()const{
|
||||
return Quat( w,-v );
|
||||
Quat operator-()const {
|
||||
return Quat(w, -v);
|
||||
}
|
||||
Quat operator+( const Quat &q )const{
|
||||
return Quat( w+q.w,v+q.v );
|
||||
Quat operator+(const Quat &q)const {
|
||||
return Quat(w + q.w, v + q.v);
|
||||
}
|
||||
Quat operator-( const Quat &q )const{
|
||||
return Quat( w-q.w,v-q.v );
|
||||
Quat operator-(const Quat &q)const {
|
||||
return Quat(w - q.w, v - q.v);
|
||||
}
|
||||
Quat operator*( const Quat &q )const{
|
||||
return Quat( w*q.w-v.dot(q.v),q.v.cross(v)+q.v*w+v*q.w );
|
||||
Quat operator*(const Quat &q)const {
|
||||
return Quat(w*q.w - v.dot(q.v), q.v.cross(v) + q.v*w + v*q.w);
|
||||
}
|
||||
Vector operator*( const Vector &q )const{
|
||||
return (*this * Quat(0,q) * -*this).v;
|
||||
Vector operator*(const Vector &q)const {
|
||||
return (*this * Quat(0, q) * -*this).v;
|
||||
}
|
||||
Quat operator*( float q )const{
|
||||
return Quat( w*q,v*q );
|
||||
Quat operator*(float q)const {
|
||||
return Quat(w*q, v*q);
|
||||
}
|
||||
Quat operator/( float q )const{
|
||||
return Quat( w/q,v/q );
|
||||
Quat operator/(float q)const {
|
||||
return Quat(w / q, v / q);
|
||||
}
|
||||
float dot( const Quat &q )const{
|
||||
return v.x*q.v.x+v.y*q.v.y+v.z*q.v.z+w*q.w;
|
||||
float dot(const Quat &q)const {
|
||||
return v.x*q.v.x + v.y*q.v.y + v.z*q.v.z + w*q.w;
|
||||
}
|
||||
float length()const{
|
||||
return sqrtf( w*w+v.x*v.x+v.y*v.y+v.z*v.z );
|
||||
float length()const {
|
||||
return sqrtf(w*w + v.x*v.x + v.y*v.y + v.z*v.z);
|
||||
}
|
||||
void normalize(){
|
||||
*this=*this/length();
|
||||
void normalize() {
|
||||
*this = *this / length();
|
||||
}
|
||||
Quat normalized()const{
|
||||
return *this/length();
|
||||
Quat normalized()const {
|
||||
return *this / length();
|
||||
}
|
||||
Quat slerpTo( const Quat &q,float a )const{
|
||||
Quat t=q;
|
||||
float d=dot(q),b=1-a;
|
||||
if( d<0 ){ t.w=-t.w;t.v=-t.v;d=-d; }
|
||||
if( d<1-EPSILON ){
|
||||
float om=acosf( d );
|
||||
float si=sinf( om );
|
||||
a=sinf( a*om )/si;
|
||||
b=sinf( b*om )/si;
|
||||
Quat slerpTo(const Quat &q, float a)const {
|
||||
Quat t = q;
|
||||
float d = dot(q), b = 1 - a;
|
||||
if (d < 0) { t.w = -t.w; t.v = -t.v; d = -d; }
|
||||
if (d < 1 - FLT_FLT_EPSILON) {
|
||||
float om = acosf(d);
|
||||
float si = sinf(om);
|
||||
a = sinf(a*om) / si;
|
||||
b = sinf(b*om) / si;
|
||||
}
|
||||
return *this*b + t*a;
|
||||
}
|
||||
Vector i()const{
|
||||
float xz=v.x*v.z,wy=w*v.y;
|
||||
float xy=v.x*v.y,wz=w*v.z;
|
||||
float yy=v.y*v.y,zz=v.z*v.z;
|
||||
return Vector( 1-2*(yy+zz),2*(xy-wz),2*(xz+wy) );
|
||||
Vector i()const {
|
||||
float xz = v.x*v.z, wy = w*v.y;
|
||||
float xy = v.x*v.y, wz = w*v.z;
|
||||
float yy = v.y*v.y, zz = v.z*v.z;
|
||||
return Vector(1 - 2 * (yy + zz), 2 * (xy - wz), 2 * (xz + wy));
|
||||
}
|
||||
Vector j()const{
|
||||
float yz=v.y*v.z,wx=w*v.x;
|
||||
float xy=v.x*v.y,wz=w*v.z;
|
||||
float xx=v.x*v.x,zz=v.z*v.z;
|
||||
return Vector( 2*(xy+wz),1-2*(xx+zz),2*(yz-wx) );
|
||||
Vector j()const {
|
||||
float yz = v.y*v.z, wx = w*v.x;
|
||||
float xy = v.x*v.y, wz = w*v.z;
|
||||
float xx = v.x*v.x, zz = v.z*v.z;
|
||||
return Vector(2 * (xy + wz), 1 - 2 * (xx + zz), 2 * (yz - wx));
|
||||
}
|
||||
Vector k()const{
|
||||
float xz=v.x*v.z,wy=w*v.y;
|
||||
float yz=v.y*v.z,wx=w*v.x;
|
||||
float xx=v.x*v.x,yy=v.y*v.y;
|
||||
return Vector( 2*(xz-wy),2*(yz+wx),1-2*(xx+yy) );
|
||||
Vector k()const {
|
||||
float xz = v.x*v.z, wy = w*v.y;
|
||||
float yz = v.y*v.z, wx = w*v.x;
|
||||
float xx = v.x*v.x, yy = v.y*v.y;
|
||||
return Vector(2 * (xz - wy), 2 * (yz + wx), 1 - 2 * (xx + yy));
|
||||
}
|
||||
};
|
||||
|
||||
class Matrix{
|
||||
class Matrix {
|
||||
static Matrix tmps[64];
|
||||
static Matrix &alloc_tmp(){ static int tmp=0;return tmps[tmp++&63]; }
|
||||
static Matrix &alloc_tmp() { static int tmp = 0; return tmps[tmp++ & 63]; }
|
||||
friend class Transform;
|
||||
public:
|
||||
Vector i,j,k;
|
||||
Vector i, j, k;
|
||||
|
||||
Matrix():i(Vector(1,0,0)),j(Vector(0,1,0)),k(Vector(0,0,1)){
|
||||
Matrix() :i(Vector(1, 0, 0)), j(Vector(0, 1, 0)), k(Vector(0, 0, 1)) {
|
||||
}
|
||||
Matrix( const Vector &i,const Vector &j,const Vector &k ):i(i),j(j),k(k){
|
||||
Matrix(const Vector &i, const Vector &j, const Vector &k) :i(i), j(j), k(k) {
|
||||
}
|
||||
Matrix( const Quat &q ){
|
||||
float xx=q.v.x*q.v.x,yy=q.v.y*q.v.y,zz=q.v.z*q.v.z;
|
||||
float xy=q.v.x*q.v.y,xz=q.v.x*q.v.z,yz=q.v.y*q.v.z;
|
||||
float wx=q.w*q.v.x,wy=q.w*q.v.y,wz=q.w*q.v.z;
|
||||
i=Vector( 1-2*(yy+zz),2*(xy-wz),2*(xz+wy) ),
|
||||
j=Vector( 2*(xy+wz),1-2*(xx+zz),2*(yz-wx) ),
|
||||
k=Vector( 2*(xz-wy),2*(yz+wx),1-2*(xx+yy) );
|
||||
Matrix(const Quat &q) {
|
||||
float xx = q.v.x*q.v.x, yy = q.v.y*q.v.y, zz = q.v.z*q.v.z;
|
||||
float xy = q.v.x*q.v.y, xz = q.v.x*q.v.z, yz = q.v.y*q.v.z;
|
||||
float wx = q.w*q.v.x, wy = q.w*q.v.y, wz = q.w*q.v.z;
|
||||
i = Vector(1 - 2 * (yy + zz), 2 * (xy - wz), 2 * (xz + wy)),
|
||||
j = Vector(2 * (xy + wz), 1 - 2 * (xx + zz), 2 * (yz - wx)),
|
||||
k = Vector(2 * (xz - wy), 2 * (yz + wx), 1 - 2 * (xx + yy));
|
||||
}
|
||||
Matrix( float angle,const Vector &axis ){
|
||||
const Vector &u=axis;
|
||||
float c=cosf(angle),s=sinf(angle);
|
||||
float x2=axis.x*axis.x,y2=axis.y*axis.y,z2=axis.z*axis.z;
|
||||
i=Vector( x2+c*(1-x2),u.x*u.y*(1-c)-u.z*s,u.z*u.x*(1-c)+u.y*s );
|
||||
j=Vector( u.x*u.y*(1-c)+u.z*s,y2+c*(1-y2),u.y*u.z*(1-c)-u.x*s );
|
||||
k=Vector( u.z*u.x*(1-c)-u.y*s,u.y*u.z*(1-c)+u.x*s,z2+c*(1-z2) );
|
||||
Matrix(float angle, const Vector &axis) {
|
||||
const Vector &u = axis;
|
||||
float c = cosf(angle), s = sinf(angle);
|
||||
float x2 = axis.x*axis.x, y2 = axis.y*axis.y, z2 = axis.z*axis.z;
|
||||
i = Vector(x2 + c*(1 - x2), u.x*u.y*(1 - c) - u.z*s, u.z*u.x*(1 - c) + u.y*s);
|
||||
j = Vector(u.x*u.y*(1 - c) + u.z*s, y2 + c*(1 - y2), u.y*u.z*(1 - c) - u.x*s);
|
||||
k = Vector(u.z*u.x*(1 - c) - u.y*s, u.y*u.z*(1 - c) + u.x*s, z2 + c*(1 - z2));
|
||||
}
|
||||
Vector &operator[]( int n ){
|
||||
return (&i)[n];
|
||||
}
|
||||
const Vector &operator[]( int n )const{
|
||||
Vector &operator[](int n) {
|
||||
return (&i)[n];
|
||||
}
|
||||
Matrix &operator~()const{
|
||||
Matrix &m=alloc_tmp();
|
||||
m.i.x=i.x;m.i.y=j.x;m.i.z=k.x;
|
||||
m.j.x=i.y;m.j.y=j.y;m.j.z=k.y;
|
||||
m.k.x=i.z;m.k.y=j.z;m.k.z=k.z;
|
||||
const Vector &operator[](int n)const {
|
||||
return (&i)[n];
|
||||
}
|
||||
Matrix &operator~()const {
|
||||
Matrix &m = alloc_tmp();
|
||||
m.i.x = i.x; m.i.y = j.x; m.i.z = k.x;
|
||||
m.j.x = i.y; m.j.y = j.y; m.j.z = k.y;
|
||||
m.k.x = i.z; m.k.y = j.z; m.k.z = k.z;
|
||||
return m;
|
||||
}
|
||||
float determinant()const{
|
||||
return i.x*(j.y*k.z-j.z*k.y )-i.y*(j.x*k.z-j.z*k.x )+i.z*(j.x*k.y-j.y*k.x );
|
||||
float determinant()const {
|
||||
return i.x*(j.y*k.z - j.z*k.y) - i.y*(j.x*k.z - j.z*k.x) + i.z*(j.x*k.y - j.y*k.x);
|
||||
}
|
||||
Matrix &operator-()const{
|
||||
Matrix &m=alloc_tmp();
|
||||
float t=1.0f/determinant();
|
||||
m.i.x= t*(j.y*k.z-j.z*k.y);m.i.y=-t*(i.y*k.z-i.z*k.y);m.i.z= t*(i.y*j.z-i.z*j.y);
|
||||
m.j.x=-t*(j.x*k.z-j.z*k.x);m.j.y= t*(i.x*k.z-i.z*k.x);m.j.z=-t*(i.x*j.z-i.z*j.x);
|
||||
m.k.x= t*(j.x*k.y-j.y*k.x);m.k.y=-t*(i.x*k.y-i.y*k.x);m.k.z= t*(i.x*j.y-i.y*j.x);
|
||||
Matrix &operator-()const {
|
||||
Matrix &m = alloc_tmp();
|
||||
float t = 1.0f / determinant();
|
||||
m.i.x = t*(j.y*k.z - j.z*k.y); m.i.y = -t*(i.y*k.z - i.z*k.y); m.i.z = t*(i.y*j.z - i.z*j.y);
|
||||
m.j.x = -t*(j.x*k.z - j.z*k.x); m.j.y = t*(i.x*k.z - i.z*k.x); m.j.z = -t*(i.x*j.z - i.z*j.x);
|
||||
m.k.x = t*(j.x*k.y - j.y*k.x); m.k.y = -t*(i.x*k.y - i.y*k.x); m.k.z = t*(i.x*j.y - i.y*j.x);
|
||||
return m;
|
||||
}
|
||||
Matrix &cofactor()const{
|
||||
Matrix &m=alloc_tmp();
|
||||
m.i.x= (j.y*k.z-j.z*k.y);m.i.y=-(j.x*k.z-j.z*k.x);m.i.z= (j.x*k.y-j.y*k.x);
|
||||
m.j.x=-(i.y*k.z-i.z*k.y);m.j.y= (i.x*k.z-i.z*k.x);m.j.z=-(i.x*k.y-i.y*k.x);
|
||||
m.k.x= (i.y*j.z-i.z*j.y);m.k.y=-(i.x*j.z-i.z*j.x);m.k.z= (i.x*j.y-i.y*j.x);
|
||||
Matrix &cofactor()const {
|
||||
Matrix &m = alloc_tmp();
|
||||
m.i.x = (j.y*k.z - j.z*k.y); m.i.y = -(j.x*k.z - j.z*k.x); m.i.z = (j.x*k.y - j.y*k.x);
|
||||
m.j.x = -(i.y*k.z - i.z*k.y); m.j.y = (i.x*k.z - i.z*k.x); m.j.z = -(i.x*k.y - i.y*k.x);
|
||||
m.k.x = (i.y*j.z - i.z*j.y); m.k.y = -(i.x*j.z - i.z*j.x); m.k.z = (i.x*j.y - i.y*j.x);
|
||||
return m;
|
||||
}
|
||||
bool operator==( const Matrix &q )const{
|
||||
return i==q.i && j==q.j && k==q.k;
|
||||
bool operator==(const Matrix &q)const {
|
||||
return i == q.i && j == q.j && k == q.k;
|
||||
}
|
||||
bool operator!=( const Matrix &q )const{
|
||||
return i!=q.i || j!=q.j || k!=q.k;
|
||||
bool operator!=(const Matrix &q)const {
|
||||
return i != q.i || j != q.j || k != q.k;
|
||||
}
|
||||
Vector operator*( const Vector &q )const{
|
||||
return Vector( i.x*q.x+j.x*q.y+k.x*q.z,i.y*q.x+j.y*q.y+k.y*q.z,i.z*q.x+j.z*q.y+k.z*q.z );
|
||||
Vector operator*(const Vector &q)const {
|
||||
return Vector(i.x*q.x + j.x*q.y + k.x*q.z, i.y*q.x + j.y*q.y + k.y*q.z, i.z*q.x + j.z*q.y + k.z*q.z);
|
||||
}
|
||||
Matrix &operator*( const Matrix &q )const{
|
||||
Matrix &m=alloc_tmp();
|
||||
m.i.x=i.x*q.i.x+j.x*q.i.y+k.x*q.i.z;m.i.y=i.y*q.i.x+j.y*q.i.y+k.y*q.i.z;m.i.z=i.z*q.i.x+j.z*q.i.y+k.z*q.i.z;
|
||||
m.j.x=i.x*q.j.x+j.x*q.j.y+k.x*q.j.z;m.j.y=i.y*q.j.x+j.y*q.j.y+k.y*q.j.z;m.j.z=i.z*q.j.x+j.z*q.j.y+k.z*q.j.z;
|
||||
m.k.x=i.x*q.k.x+j.x*q.k.y+k.x*q.k.z;m.k.y=i.y*q.k.x+j.y*q.k.y+k.y*q.k.z;m.k.z=i.z*q.k.x+j.z*q.k.y+k.z*q.k.z;
|
||||
Matrix &operator*(const Matrix &q)const {
|
||||
Matrix &m = alloc_tmp();
|
||||
m.i.x = i.x*q.i.x + j.x*q.i.y + k.x*q.i.z; m.i.y = i.y*q.i.x + j.y*q.i.y + k.y*q.i.z; m.i.z = i.z*q.i.x + j.z*q.i.y + k.z*q.i.z;
|
||||
m.j.x = i.x*q.j.x + j.x*q.j.y + k.x*q.j.z; m.j.y = i.y*q.j.x + j.y*q.j.y + k.y*q.j.z; m.j.z = i.z*q.j.x + j.z*q.j.y + k.z*q.j.z;
|
||||
m.k.x = i.x*q.k.x + j.x*q.k.y + k.x*q.k.z; m.k.y = i.y*q.k.x + j.y*q.k.y + k.y*q.k.z; m.k.z = i.z*q.k.x + j.z*q.k.y + k.z*q.k.z;
|
||||
return m;
|
||||
}
|
||||
void orthogonalize(){
|
||||
void orthogonalize() {
|
||||
k.normalize();
|
||||
i=j.cross( k ).normalized();
|
||||
j=k.cross( i );
|
||||
i = j.cross(k).normalized();
|
||||
j = k.cross(i);
|
||||
}
|
||||
Matrix &orthogonalized()const{
|
||||
Matrix &m=alloc_tmp();
|
||||
m=*this;m.orthogonalize();
|
||||
Matrix &orthogonalized()const {
|
||||
Matrix &m = alloc_tmp();
|
||||
m = *this; m.orthogonalize();
|
||||
return m;
|
||||
}
|
||||
};
|
||||
|
||||
class Box{
|
||||
class Box {
|
||||
public:
|
||||
Vector a,b;
|
||||
Box():a( Vector(INFINITY,INFINITY,INFINITY) ),b( Vector(-INFINITY,-INFINITY,-INFINITY) ){
|
||||
Vector a, b;
|
||||
Box() :a(Vector(INFINITY, INFINITY, INFINITY)), b(Vector(-INFINITY, -INFINITY, -INFINITY)) {
|
||||
}
|
||||
Box( const Vector &q ):a(q),b(q){
|
||||
Box(const Vector &q) :a(q), b(q) {
|
||||
}
|
||||
Box( const Vector &a,const Vector &b ):a(a),b(b){
|
||||
Box(const Vector &a, const Vector &b) :a(a), b(b) {
|
||||
}
|
||||
Box( const Line &l ):a(l.o),b(l.o){
|
||||
update( l.o+l.d );
|
||||
Box(const Line &l) :a(l.o), b(l.o) {
|
||||
update(l.o + l.d);
|
||||
}
|
||||
void clear(){
|
||||
a.x=a.y=a.z=INFINITY;
|
||||
b.x=b.y=b.z=-INFINITY;
|
||||
void clear() {
|
||||
a.x = a.y = a.z = INFINITY;
|
||||
b.x = b.y = b.z = -INFINITY;
|
||||
}
|
||||
bool empty()const{
|
||||
return b.x<a.x || b.y<a.y || b.z<a.z;
|
||||
bool empty()const {
|
||||
return b.x < a.x || b.y < a.y || b.z < a.z;
|
||||
}
|
||||
Vector centre()const{
|
||||
return Vector( (a.x+b.x)*.5f,(a.y+b.y)*.5f,(a.z+b.z)*.5f );
|
||||
Vector centre()const {
|
||||
return Vector((a.x + b.x)*.5f, (a.y + b.y)*.5f, (a.z + b.z)*.5f);
|
||||
}
|
||||
Vector corner( int n )const{
|
||||
return Vector( ((n&1)?b:a).x,((n&2)?b:a).y,((n&4)?b:a).z );
|
||||
Vector corner(int n)const {
|
||||
return Vector(((n & 1) ? b : a).x, ((n & 2) ? b : a).y, ((n & 4) ? b : a).z);
|
||||
}
|
||||
void update( const Vector &q ){
|
||||
if( q.x<a.x ) a.x=q.x;if( q.y<a.y ) a.y=q.y;if( q.z<a.z ) a.z=q.z;
|
||||
if( q.x>b.x ) b.x=q.x;if( q.y>b.y ) b.y=q.y;if( q.z>b.z ) b.z=q.z;
|
||||
void update(const Vector &q) {
|
||||
if (q.x < a.x) a.x = q.x; if (q.y < a.y) a.y = q.y; if (q.z < a.z) a.z = q.z;
|
||||
if (q.x > b.x) b.x = q.x; if (q.y > b.y) b.y = q.y; if (q.z > b.z) b.z = q.z;
|
||||
}
|
||||
void update( const Box &q ){
|
||||
if( q.a.x<a.x ) a.x=q.a.x;if( q.a.y<a.y ) a.y=q.a.y;if( q.a.z<a.z ) a.z=q.a.z;
|
||||
if( q.b.x>b.x ) b.x=q.b.x;if( q.b.y>b.y ) b.y=q.b.y;if( q.b.z>b.z ) b.z=q.b.z;
|
||||
void update(const Box &q) {
|
||||
if (q.a.x < a.x) a.x = q.a.x; if (q.a.y < a.y) a.y = q.a.y; if (q.a.z < a.z) a.z = q.a.z;
|
||||
if (q.b.x > b.x) b.x = q.b.x; if (q.b.y > b.y) b.y = q.b.y; if (q.b.z > b.z) b.z = q.b.z;
|
||||
}
|
||||
bool overlaps( const Box &q )const{
|
||||
bool overlaps(const Box &q)const {
|
||||
return
|
||||
(b.x<q.b.x?b.x:q.b.x)>=(a.x>q.a.x?a.x:q.a.x) &&
|
||||
(b.y<q.b.y?b.y:q.b.y)>=(a.y>q.a.y?a.y:q.a.y) &&
|
||||
(b.z<q.b.z?b.z:q.b.z)>=(a.z>q.a.z?a.z:q.a.z);
|
||||
(b.x < q.b.x ? b.x : q.b.x) >= (a.x > q.a.x ? a.x : q.a.x) &&
|
||||
(b.y < q.b.y ? b.y : q.b.y) >= (a.y > q.a.y ? a.y : q.a.y) &&
|
||||
(b.z < q.b.z ? b.z : q.b.z) >= (a.z > q.a.z ? a.z : q.a.z);
|
||||
}
|
||||
void expand( float n ){
|
||||
a.x-=n;a.y-=n;a.z-=n;b.x+=n;b.y+=n;b.z+=n;
|
||||
void expand(float n) {
|
||||
a.x -= n; a.y -= n; a.z -= n; b.x += n; b.y += n; b.z += n;
|
||||
}
|
||||
float width()const{
|
||||
return b.x-a.x;
|
||||
float width()const {
|
||||
return b.x - a.x;
|
||||
}
|
||||
float height()const{
|
||||
return b.y-a.y;
|
||||
float height()const {
|
||||
return b.y - a.y;
|
||||
}
|
||||
float depth()const{
|
||||
return b.z-a.z;
|
||||
float depth()const {
|
||||
return b.z - a.z;
|
||||
}
|
||||
bool contains( const Vector &q ){
|
||||
return q.x>=a.x && q.x<=b.x && q.y>=a.y && q.y<=b.y && q.z>=a.z && q.z<=b.z;
|
||||
bool contains(const Vector &q) {
|
||||
return q.x >= a.x && q.x <= b.x && q.y >= a.y && q.y <= b.y && q.z >= a.z && q.z <= b.z;
|
||||
}
|
||||
};
|
||||
|
||||
class Transform{
|
||||
class Transform {
|
||||
static Transform tmps[64];
|
||||
static Transform &alloc_tmp(){ static int tmp=0;return tmps[tmp++&63]; }
|
||||
static Transform &alloc_tmp() { static int tmp = 0; return tmps[tmp++ & 63]; }
|
||||
public:
|
||||
Matrix m;
|
||||
Vector v;
|
||||
|
||||
Transform(){
|
||||
Transform() {
|
||||
}
|
||||
Transform( const Matrix &m ):m(m){
|
||||
Transform(const Matrix &m) :m(m) {
|
||||
}
|
||||
Transform( const Vector &v ):v(v){
|
||||
Transform(const Vector &v) :v(v) {
|
||||
}
|
||||
Transform( const Matrix &m,const Vector &v ):m(m),v(v){
|
||||
Transform(const Matrix &m, const Vector &v) :m(m), v(v) {
|
||||
}
|
||||
Transform &operator-()const{
|
||||
Transform &t=alloc_tmp();
|
||||
t.m=-m;t.v=t.m*-v;
|
||||
Transform &operator-()const {
|
||||
Transform &t = alloc_tmp();
|
||||
t.m = -m; t.v = t.m*-v;
|
||||
return t;
|
||||
}
|
||||
Transform &operator~()const{
|
||||
Transform &t=alloc_tmp();
|
||||
t.m=~m;t.v=t.m*-v;
|
||||
Transform &operator~()const {
|
||||
Transform &t = alloc_tmp();
|
||||
t.m = ~m; t.v = t.m*-v;
|
||||
return t;
|
||||
}
|
||||
Vector operator*( const Vector &q )const{
|
||||
return m*q+v;
|
||||
Vector operator*(const Vector &q)const {
|
||||
return m*q + v;
|
||||
}
|
||||
Line operator*( const Line &q )const{
|
||||
Vector t=(*this)*q.o;
|
||||
return Line( t,(*this)*(q.o+q.d)-t );
|
||||
Line operator*(const Line &q)const {
|
||||
Vector t = (*this)*q.o;
|
||||
return Line(t, (*this)*(q.o + q.d) - t);
|
||||
}
|
||||
Box operator*( const Box &q )const{
|
||||
Box t( (*this*q.corner(0) ) );
|
||||
for( int k=1;k<8;++k ) t.update( *this*q.corner(k) );
|
||||
Box operator*(const Box &q)const {
|
||||
Box t((*this*q.corner(0)));
|
||||
for (int k = 1; k < 8; ++k) t.update(*this*q.corner(k));
|
||||
return t;
|
||||
}
|
||||
Transform &operator*( const Transform &q )const{
|
||||
Transform &t=alloc_tmp();
|
||||
t.m=m*q.m;t.v=m*q.v+v;
|
||||
Transform &operator*(const Transform &q)const {
|
||||
Transform &t = alloc_tmp();
|
||||
t.m = m*q.m; t.v = m*q.v + v;
|
||||
return t;
|
||||
}
|
||||
bool operator==( const Transform &q )const{
|
||||
return m==q.m && v==q.v;
|
||||
bool operator==(const Transform &q)const {
|
||||
return m == q.m && v == q.v;
|
||||
}
|
||||
bool operator!=( const Transform &q )const{
|
||||
return !operator==( q );
|
||||
bool operator!=(const Transform &q)const {
|
||||
return !operator==(q);
|
||||
}
|
||||
};
|
||||
|
||||
inline float transformRadius( float r,const Matrix &t ){
|
||||
static const float sq_3=sqrtf(1.0f/3.0f);
|
||||
return (t * Vector( sq_3,sq_3,sq_3 )).length()*r;
|
||||
inline float transformRadius(float r, const Matrix &t) {
|
||||
static const float sq_3 = sqrtf(1.0f / 3.0f);
|
||||
return (t * Vector(sq_3, sq_3, sq_3)).length()*r;
|
||||
}
|
||||
|
||||
inline Matrix pitchMatrix( float q ){
|
||||
return Matrix( Vector(1,0,0),Vector(0,cosf(q),sinf(q)),Vector(0,-sinf(q),cosf(q)) );
|
||||
inline Matrix pitchMatrix(float q) {
|
||||
return Matrix(Vector(1, 0, 0), Vector(0, cosf(q), sinf(q)), Vector(0, -sinf(q), cosf(q)));
|
||||
}
|
||||
|
||||
inline Matrix yawMatrix( float q ){
|
||||
return Matrix( Vector(cosf(q),0,sinf(q)),Vector(0,1,0),Vector(-sinf(q),0,cosf(q)) );
|
||||
inline Matrix yawMatrix(float q) {
|
||||
return Matrix(Vector(cosf(q), 0, sinf(q)), Vector(0, 1, 0), Vector(-sinf(q), 0, cosf(q)));
|
||||
}
|
||||
|
||||
inline Matrix rollMatrix( float q ){
|
||||
return Matrix( Vector(cosf(q),sinf(q),0),Vector(-sinf(q),cosf(q),0),Vector(0,0,1) );
|
||||
inline Matrix rollMatrix(float q) {
|
||||
return Matrix(Vector(cosf(q), sinf(q), 0), Vector(-sinf(q), cosf(q), 0), Vector(0, 0, 1));
|
||||
}
|
||||
|
||||
inline float matrixPitch( const Matrix &m ){
|
||||
inline float matrixPitch(const Matrix &m) {
|
||||
return m.k.pitch();
|
||||
// return asinf( -m.k.y );
|
||||
// return asinf( -m.k.y );
|
||||
}
|
||||
|
||||
inline float matrixYaw( const Matrix &m ){
|
||||
inline float matrixYaw(const Matrix &m) {
|
||||
return m.k.yaw();
|
||||
//return atan2f( -m.k.x,m.k.z );
|
||||
}
|
||||
|
||||
inline float matrixRoll( const Matrix &m ){
|
||||
return atan2f( m.i.y,m.j.y );
|
||||
inline float matrixRoll(const Matrix &m) {
|
||||
return atan2f(m.i.y, m.j.y);
|
||||
//Matrix t=pitchMatrix( -matrixPitch(m) )*yawMatrix( -matrixYaw(m) )*m;
|
||||
//return atan2f( t.i.y,t.i.x );
|
||||
}
|
||||
|
||||
inline Matrix scaleMatrix( float x,float y,float z ){
|
||||
return Matrix( Vector( x,0,0 ),Vector( 0,y,0 ),Vector( 0,0,z ) );
|
||||
inline Matrix scaleMatrix(float x, float y, float z) {
|
||||
return Matrix(Vector(x, 0, 0), Vector(0, y, 0), Vector(0, 0, z));
|
||||
}
|
||||
|
||||
inline Matrix scaleMatrix( const Vector &scale ){
|
||||
return Matrix( Vector( scale.x,0,0 ),Vector( 0,scale.y,0 ),Vector( 0,0,scale.z ) );
|
||||
inline Matrix scaleMatrix(const Vector &scale) {
|
||||
return Matrix(Vector(scale.x, 0, 0), Vector(0, scale.y, 0), Vector(0, 0, scale.z));
|
||||
}
|
||||
|
||||
inline Quat pitchQuat( float p ){
|
||||
return Quat( cosf(p/-2),Vector( sinf(p/-2),0,0 ) );
|
||||
inline Quat pitchQuat(float p) {
|
||||
return Quat(cosf(p / -2), Vector(sinf(p / -2), 0, 0));
|
||||
}
|
||||
|
||||
inline Quat yawQuat( float y ){
|
||||
return Quat( cosf(y/2),Vector( 0,sinf(y/2),0 ) );
|
||||
inline Quat yawQuat(float y) {
|
||||
return Quat(cosf(y / 2), Vector(0, sinf(y / 2), 0));
|
||||
}
|
||||
|
||||
inline Quat rollQuat( float r ){
|
||||
return Quat( cosf(r/-2),Vector( 0,0,sinf(r/-2) ) );
|
||||
inline Quat rollQuat(float r) {
|
||||
return Quat(cosf(r / -2), Vector(0, 0, sinf(r / -2)));
|
||||
}
|
||||
|
||||
//inline Quat rotationQuat( float p,float y,float r ){
|
||||
// return yawQuat(y)*pitchQuat(p)*rollQuat(r);
|
||||
//}
|
||||
|
||||
Quat rotationQuat( float p,float y,float r );
|
||||
Quat rotationQuat(float p, float y, float r);
|
||||
|
||||
inline Matrix rotationMatrix( float p,float y,float r ){
|
||||
inline Matrix rotationMatrix(float p, float y, float r) {
|
||||
return yawMatrix(y)*pitchMatrix(p)*rollMatrix(r);
|
||||
}
|
||||
|
||||
inline Matrix rotationMatrix( const Vector &rot ){
|
||||
inline Matrix rotationMatrix(const Vector &rot) {
|
||||
return yawMatrix(rot.y)*pitchMatrix(rot.x)*rollMatrix(rot.z);
|
||||
}
|
||||
|
||||
inline float quatPitch( const Quat &q ){
|
||||
inline float quatPitch(const Quat &q) {
|
||||
return q.k().pitch();
|
||||
}
|
||||
|
||||
inline float quatYaw( const Quat &q ){
|
||||
inline float quatYaw(const Quat &q) {
|
||||
return q.k().yaw();
|
||||
}
|
||||
|
||||
inline float quatRoll( const Quat &q ){
|
||||
// Vector i=q.i(),j=q.j();
|
||||
// return atan2f( i.y,j.y );
|
||||
return matrixRoll( q );
|
||||
inline float quatRoll(const Quat &q) {
|
||||
// Vector i=q.i(),j=q.j();
|
||||
// return atan2f( i.y,j.y );
|
||||
return matrixRoll(q);
|
||||
}
|
||||
|
||||
inline Quat matrixQuat( const Matrix &p ){
|
||||
Matrix m=p;
|
||||
inline Quat matrixQuat(const Matrix &p) {
|
||||
Matrix m = p;
|
||||
m.orthogonalize();
|
||||
float t=m.i.x+m.j.y+m.k.z,w,x,y,z;
|
||||
if( t>EPSILON ){
|
||||
t=sqrtf( t+1 )*2;
|
||||
x=(m.k.y-m.j.z)/t;
|
||||
y=(m.i.z-m.k.x)/t;
|
||||
z=(m.j.x-m.i.y)/t;
|
||||
w=t/4;
|
||||
}else if( m.i.x>m.j.y && m.i.x>m.k.z ){
|
||||
t=sqrtf( m.i.x-m.j.y-m.k.z+1 )*2;
|
||||
x=t/4;
|
||||
y=(m.j.x+m.i.y)/t;
|
||||
z=(m.i.z+m.k.x)/t;
|
||||
w=(m.k.y-m.j.z)/t;
|
||||
}else if( m.j.y>m.k.z ){
|
||||
t=sqrtf( m.j.y-m.k.z-m.i.x+1 )*2;
|
||||
x=(m.j.x+m.i.y)/t;
|
||||
y=t/4;
|
||||
z=(m.k.y+m.j.z)/t;
|
||||
w=(m.i.z-m.k.x)/t;
|
||||
}else{
|
||||
t=sqrtf( m.k.z-m.j.y-m.i.x+1 )*2;
|
||||
x=(m.i.z+m.k.x)/t;
|
||||
y=(m.k.y+m.j.z)/t;
|
||||
z=t/4;
|
||||
w=(m.j.x-m.i.y)/t;
|
||||
float t = m.i.x + m.j.y + m.k.z, w, x, y, z;
|
||||
if (t > FLT_FLT_EPSILON) {
|
||||
t = sqrtf(t + 1) * 2;
|
||||
x = (m.k.y - m.j.z) / t;
|
||||
y = (m.i.z - m.k.x) / t;
|
||||
z = (m.j.x - m.i.y) / t;
|
||||
w = t / 4;
|
||||
} else if (m.i.x > m.j.y && m.i.x > m.k.z) {
|
||||
t = sqrtf(m.i.x - m.j.y - m.k.z + 1) * 2;
|
||||
x = t / 4;
|
||||
y = (m.j.x + m.i.y) / t;
|
||||
z = (m.i.z + m.k.x) / t;
|
||||
w = (m.k.y - m.j.z) / t;
|
||||
} else if (m.j.y > m.k.z) {
|
||||
t = sqrtf(m.j.y - m.k.z - m.i.x + 1) * 2;
|
||||
x = (m.j.x + m.i.y) / t;
|
||||
y = t / 4;
|
||||
z = (m.k.y + m.j.z) / t;
|
||||
w = (m.i.z - m.k.x) / t;
|
||||
} else {
|
||||
t = sqrtf(m.k.z - m.j.y - m.i.x + 1) * 2;
|
||||
x = (m.i.z + m.k.x) / t;
|
||||
y = (m.k.y + m.j.z) / t;
|
||||
z = t / 4;
|
||||
w = (m.j.x - m.i.y) / t;
|
||||
}
|
||||
return Quat( w,Vector( x,y,z ) );
|
||||
return Quat(w, Vector(x, y, z));
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -343,7 +343,7 @@ static void parseAnimKeys( Animation *anim,int type ){
|
||||
in.sgetn( (char*)&angle,4 );
|
||||
in.sgetn( (char*)&axis,12 );
|
||||
// _log( "ROT_KEY: time="+itoa(time)+" angle="+ftoa(angle)+" axis="+ftoa(axis.x)+","+ftoa(axis.y)+","+ftoa(axis.z) );
|
||||
if( axis.length()>EPSILON ){
|
||||
if( axis.length()>FLT_EPSILON ){
|
||||
if( flip_tris ) angle=-angle;
|
||||
if( conv ) axis=conv_tform.m*axis;
|
||||
quat=Quat( cosf( angle/2 ),axis.normalized()*sinf( angle/2 ) )*quat;
|
||||
@@ -394,8 +394,8 @@ static void parseMeshInfo( MeshModel *root,float curr_time ){
|
||||
_log( "PIVOT: "+ftoa(pivot.x)+","+ftoa(pivot.y)+","+ftoa(pivot.z) );
|
||||
break;
|
||||
case 0xb014: //BOUNDBOX
|
||||
in.sgetn( (char*)&box.a,12 );
|
||||
in.sgetn( (char*)&box.b,12 );
|
||||
in.sgetn( (char*)&(box.a),12 );
|
||||
in.sgetn( (char*)&(box.b),12 );
|
||||
box_centre=box.centre();
|
||||
if( conv ) box_centre=conv_tform * box_centre;
|
||||
_log( "BOUNDBOX: min="+ftoa(box.a.x)+","+ftoa(box.a.y)+","+ftoa(box.a.z)+" max="+ftoa(box.b.x)+","+ftoa(box.b.y)+","+ftoa(box.b.z) );
|
||||
|
||||
@@ -34,7 +34,7 @@ static void parseAnimKey( IDirectXFileData *fileData,MeshModel *e ){
|
||||
if( n==4 ){
|
||||
Quat rot=*(Quat*)data;
|
||||
if( conv ){
|
||||
if( fabs(rot.w)<1-EPSILON ){
|
||||
if( fabs(rot.w)<1-FLT_EPSILON ){
|
||||
rot.normalize();
|
||||
//quat-to-axis/angle
|
||||
float half=acosf( rot.w );
|
||||
|
||||
+149
-149
@@ -6,164 +6,164 @@
|
||||
extern gxRuntime *gx_runtime;
|
||||
extern gxGraphics *gx_graphics;
|
||||
|
||||
static Vector *normals=0;
|
||||
static float tex_coords[2][2]={{0,0},{0,0}};
|
||||
static Vector *normals = 0;
|
||||
static float tex_coords[2][2] = { {0,0},{0,0} };
|
||||
|
||||
#pragma pack( push,1 )
|
||||
|
||||
struct md2_header{
|
||||
int magic;
|
||||
int version;
|
||||
int skinWidth;
|
||||
int skinHeight;
|
||||
int frameSize;
|
||||
int numSkins;
|
||||
int numVertices;
|
||||
int numTexCoords;
|
||||
int numTriangles;
|
||||
int numGlCommands;
|
||||
int numFrames;
|
||||
int offsetSkins;
|
||||
int offsetTexCoords;
|
||||
int offsetTriangles;
|
||||
int offsetFrames;
|
||||
int offsetGlCommands;
|
||||
struct md2_header {
|
||||
int magic;
|
||||
int version;
|
||||
int skinWidth;
|
||||
int skinHeight;
|
||||
int frameSize;
|
||||
int numSkins;
|
||||
int numVertices;
|
||||
int numTexCoords;
|
||||
int numTriangles;
|
||||
int numGlCommands;
|
||||
int numFrames;
|
||||
int offsetSkins;
|
||||
int offsetTexCoords;
|
||||
int offsetTriangles;
|
||||
int offsetFrames;
|
||||
int offsetGlCommands;
|
||||
int offsetEnd;
|
||||
};
|
||||
|
||||
struct md2_uv{
|
||||
short u,v;
|
||||
struct md2_uv {
|
||||
short u, v;
|
||||
};
|
||||
|
||||
struct md2_vert{
|
||||
unsigned char x,y,z,n;
|
||||
struct md2_vert {
|
||||
unsigned char x, y, z, n;
|
||||
};
|
||||
|
||||
struct md2_tri{
|
||||
unsigned short verts[3],uvs[3];
|
||||
struct md2_tri {
|
||||
unsigned short verts[3], uvs[3];
|
||||
};
|
||||
|
||||
#pragma pack( pop )
|
||||
|
||||
struct t_vert{
|
||||
unsigned short i,uv;
|
||||
bool operator<( const t_vert &t )const{
|
||||
return memcmp( &i,&t.i,4 )<0;
|
||||
struct t_vert {
|
||||
unsigned short i, uv;
|
||||
bool operator<(const t_vert &t)const {
|
||||
return memcmp(&i, &t.i, 4) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct t_tri{
|
||||
struct t_tri {
|
||||
unsigned short verts[3];
|
||||
};
|
||||
|
||||
MD2Rep::MD2Rep( const string &f ):
|
||||
mesh(0),n_verts(0),n_tris(0),n_frames(0){
|
||||
MD2Rep::MD2Rep(const string &f) :
|
||||
mesh(0), n_verts(0), n_tris(0), n_frames(0) {
|
||||
|
||||
filebuf in;
|
||||
md2_header header;
|
||||
|
||||
if( !in.open( f.c_str(),ios_base::in|ios_base::binary ) ) return;
|
||||
if( in.sgetn( (char*)&header,sizeof(header) )!=sizeof(header) ) return;
|
||||
if( header.magic!='2PDI' || header.version!=8 ) return;
|
||||
if (!in.open(f.c_str(), ios_base::in | ios_base::binary)) return;
|
||||
if (in.sgetn((char*)&header, sizeof(header)) != sizeof(header)) return;
|
||||
if (header.magic != '2PDI' || header.version != 8) return;
|
||||
|
||||
n_frames=header.numFrames;
|
||||
n_tris=header.numTriangles;
|
||||
n_frames = header.numFrames;
|
||||
n_tris = header.numTriangles;
|
||||
|
||||
//read in tex coords
|
||||
vector<md2_uv> md2_uvs;
|
||||
md2_uvs.resize( header.numTexCoords );
|
||||
in.pubseekpos( header.offsetTexCoords );
|
||||
in.sgetn( (char*)md2_uvs.begin(),header.numTexCoords*sizeof(md2_uv) );
|
||||
md2_uvs.resize(header.numTexCoords);
|
||||
in.pubseekpos(header.offsetTexCoords);
|
||||
in.sgetn((char*)(&md2_uvs.begin()[0]), header.numTexCoords * sizeof(md2_uv));
|
||||
|
||||
//read in triangles
|
||||
vector<md2_tri> md2_tris;
|
||||
md2_tris.resize( n_tris );
|
||||
in.pubseekpos( header.offsetTriangles );
|
||||
in.sgetn( (char*)md2_tris.begin(),n_tris*sizeof(md2_tri) );
|
||||
md2_tris.resize(n_tris);
|
||||
in.pubseekpos(header.offsetTriangles);
|
||||
in.sgetn((char*)(&md2_tris.begin()[0]), n_tris * sizeof(md2_tri));
|
||||
|
||||
vector<t_tri> t_tris;
|
||||
vector<t_vert> t_verts;
|
||||
map<t_vert,int> t_map;
|
||||
map<t_vert, int> t_map;
|
||||
|
||||
int k;
|
||||
for( k=0;k<n_tris;++k ){
|
||||
for (k = 0; k < n_tris; ++k) {
|
||||
t_tri tr;
|
||||
for( int j=0;j<3;++j ){
|
||||
for (int j = 0; j < 3; ++j) {
|
||||
t_vert t;
|
||||
t.i=md2_tris[k].verts[j];
|
||||
t.uv=md2_tris[k].uvs[j];
|
||||
map<t_vert,int>::iterator it=t_map.find( t );
|
||||
if( it==t_map.end() ){
|
||||
t.i = md2_tris[k].verts[j];
|
||||
t.uv = md2_tris[k].uvs[j];
|
||||
map<t_vert, int>::iterator it = t_map.find(t);
|
||||
if (it == t_map.end()) {
|
||||
//create new vert
|
||||
tr.verts[j]=t_map[t]=t_verts.size();
|
||||
t_verts.push_back( t );
|
||||
tr.verts[j] = t_map[t] = t_verts.size();
|
||||
t_verts.push_back(t);
|
||||
//add UVs
|
||||
VertexUV uv;
|
||||
uv.u=md2_uvs[t.uv].u/(float)(header.skinWidth);
|
||||
uv.v=md2_uvs[t.uv].v/(float)(header.skinHeight);
|
||||
uvs.push_back( uv );
|
||||
}else{
|
||||
uv.u = md2_uvs[t.uv].u / (float)(header.skinWidth);
|
||||
uv.v = md2_uvs[t.uv].v / (float)(header.skinHeight);
|
||||
uvs.push_back(uv);
|
||||
} else {
|
||||
//reuse vert
|
||||
tr.verts[j]=it->second;
|
||||
tr.verts[j] = it->second;
|
||||
}
|
||||
}
|
||||
t_tris.push_back( tr );
|
||||
t_tris.push_back(tr);
|
||||
}
|
||||
n_verts=t_verts.size();
|
||||
n_verts = t_verts.size();
|
||||
|
||||
frames.resize( n_frames );
|
||||
in.pubseekpos( header.offsetFrames );
|
||||
frames.resize(n_frames);
|
||||
in.pubseekpos(header.offsetFrames);
|
||||
|
||||
vector<md2_vert> md2_verts;
|
||||
md2_verts.resize( header.numVertices );
|
||||
md2_verts.resize(header.numVertices);
|
||||
|
||||
//read in frames
|
||||
for( k=0;k<n_frames;++k ){
|
||||
for (k = 0; k < n_frames; ++k) {
|
||||
char t_buff[16];
|
||||
Frame *fr=&frames[k];
|
||||
in.sgetn( (char*)&fr->scale,12 );
|
||||
in.sgetn( (char*)&fr->trans,12 );
|
||||
in.sgetn( t_buff,16 );
|
||||
Frame *fr = &frames[k];
|
||||
in.sgetn((char*)&fr->scale, 12);
|
||||
in.sgetn((char*)&fr->trans, 12);
|
||||
in.sgetn(t_buff, 16);
|
||||
|
||||
fr->scale=Vector( fr->scale.y,fr->scale.z,fr->scale.x );
|
||||
fr->trans=Vector( fr->trans.y,fr->trans.z,fr->trans.x );
|
||||
fr->scale = Vector(fr->scale.y, fr->scale.z, fr->scale.x);
|
||||
fr->trans = Vector(fr->trans.y, fr->trans.z, fr->trans.x);
|
||||
|
||||
//read vertices
|
||||
in.sgetn( (char*)md2_verts.begin(),header.numVertices*sizeof(md2_vert) );
|
||||
in.sgetn((char*)&md2_verts.begin()[0], header.numVertices * sizeof(md2_vert));
|
||||
|
||||
fr->verts.resize( n_verts );
|
||||
for( int j=0;j<n_verts;++j ){
|
||||
Vertex *v=&fr->verts[j];
|
||||
const t_vert &tv=t_verts[j];
|
||||
const md2_vert &mv=md2_verts[tv.i];
|
||||
v->x=mv.y;
|
||||
v->y=mv.z;
|
||||
v->z=mv.x;
|
||||
v->n=mv.n;
|
||||
box.update( Vector( v->x,v->y,v->z ) * fr->scale + fr->trans );
|
||||
fr->verts.resize(n_verts);
|
||||
for (int j = 0; j < n_verts; ++j) {
|
||||
Vertex *v = &fr->verts[j];
|
||||
const t_vert &tv = t_verts[j];
|
||||
const md2_vert &mv = md2_verts[tv.i];
|
||||
v->x = mv.y;
|
||||
v->y = mv.z;
|
||||
v->z = mv.x;
|
||||
v->n = mv.n;
|
||||
box.update(Vector(v->x, v->y, v->z) * fr->scale + fr->trans);
|
||||
}
|
||||
}
|
||||
|
||||
//create mesh and setup tris
|
||||
mesh=gx_graphics->createMesh( n_verts,n_tris,0 );
|
||||
mesh->lock( true );
|
||||
for( k=0;k<n_tris;++k ){
|
||||
const t_tri &t=t_tris[k];
|
||||
mesh->setTriangle( k,t.verts[0],t.verts[2],t.verts[1] );
|
||||
mesh = gx_graphics->createMesh(n_verts, n_tris, 0);
|
||||
mesh->lock(true);
|
||||
for (k = 0; k < n_tris; ++k) {
|
||||
const t_tri &t = t_tris[k];
|
||||
mesh->setTriangle(k, t.verts[0], t.verts[2], t.verts[1]);
|
||||
}
|
||||
mesh->unlock();
|
||||
|
||||
//build normals
|
||||
if( !normals ){
|
||||
normals=(Vector*)md2norms;
|
||||
for( int k=0;k<sizeof(md2norms)/12;++k ){
|
||||
normals[k]=Vector(normals[k].y,normals[k].z,normals[k].x);
|
||||
if (!normals) {
|
||||
normals = (Vector*)md2norms;
|
||||
for (int k = 0; k < sizeof(md2norms) / 12; ++k) {
|
||||
normals[k] = Vector(normals[k].y, normals[k].z, normals[k].x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MD2Rep::~MD2Rep(){
|
||||
if( mesh ) gx_graphics->freeMesh( mesh );
|
||||
MD2Rep::~MD2Rep() {
|
||||
if (mesh) gx_graphics->freeMesh(mesh);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -180,41 +180,41 @@ void MD2Rep::render( Vert *v,int frame ){
|
||||
}
|
||||
*/
|
||||
|
||||
void MD2Rep::render( Vert *v,int frame,float time ){
|
||||
void MD2Rep::render(Vert *v, int frame, float time) {
|
||||
|
||||
const Frame &frame_b=frames[frame];
|
||||
const Vertex *v_b=frame_b.verts.begin();
|
||||
const Vector scale_b=frame_b.scale,trans_b=frame_b.trans;
|
||||
const Frame &frame_b = frames[frame];
|
||||
const Vertex *v_b = (Vertex*)(&frame_b.verts.begin()[0]);
|
||||
const Vector scale_b = frame_b.scale, trans_b = frame_b.trans;
|
||||
|
||||
for( int k=0;k<n_verts;++v,++v_b,++k ){
|
||||
for (int k = 0; k < n_verts; ++v, ++v_b, ++k) {
|
||||
|
||||
const Vector t_b( v_b->x*scale_b.x+trans_b.x,v_b->y*scale_b.y+trans_b.y,v_b->z*scale_b.z+trans_b.z );
|
||||
const Vector &n_b=normals[ v_b->n ];
|
||||
const Vector t_b(v_b->x*scale_b.x + trans_b.x, v_b->y*scale_b.y + trans_b.y, v_b->z*scale_b.z + trans_b.z);
|
||||
const Vector &n_b = normals[v_b->n];
|
||||
|
||||
v->coords+=(t_b-v->coords)*time;
|
||||
v->normal+=(n_b-v->normal)*time;
|
||||
v->coords += (t_b - v->coords)*time;
|
||||
v->normal += (n_b - v->normal)*time;
|
||||
}
|
||||
}
|
||||
|
||||
void MD2Rep::render( Vert *v,int render_a,int render_b,float render_t ){
|
||||
const Frame &frame_a=frames[render_a];
|
||||
const Vector scale_a=frame_a.scale,trans_a=frame_a.trans;
|
||||
void MD2Rep::render(Vert *v, int render_a, int render_b, float render_t) {
|
||||
const Frame &frame_a = frames[render_a];
|
||||
const Vector scale_a = frame_a.scale, trans_a = frame_a.trans;
|
||||
|
||||
const Frame &frame_b=frames[render_b];
|
||||
const Vector scale_b=frame_b.scale,trans_b=frame_b.trans;
|
||||
const Frame &frame_b = frames[render_b];
|
||||
const Vector scale_b = frame_b.scale, trans_b = frame_b.trans;
|
||||
|
||||
const Vertex *v_a=frame_a.verts.begin();
|
||||
const Vertex *v_b=frame_b.verts.begin();
|
||||
const Vertex *v_a = (Vertex*)(&frame_a.verts.begin()[0]);
|
||||
const Vertex *v_b = (Vertex*)(&frame_b.verts.begin()[0]);
|
||||
|
||||
for( int k=0;k<n_verts;++v,++v_a,++v_b,++k ){
|
||||
for (int k = 0; k < n_verts; ++v, ++v_a, ++v_b, ++k) {
|
||||
|
||||
const Vector t_a( v_a->x*scale_a.x+trans_a.x,v_a->y*scale_a.y+trans_a.y,v_a->z*scale_a.z+trans_a.z );
|
||||
const Vector t_b( v_b->x*scale_b.x+trans_b.x,v_b->y*scale_b.y+trans_b.y,v_b->z*scale_b.z+trans_b.z );
|
||||
v->coords=(t_b-t_a)*render_t+t_a;
|
||||
const Vector t_a(v_a->x*scale_a.x + trans_a.x, v_a->y*scale_a.y + trans_a.y, v_a->z*scale_a.z + trans_a.z);
|
||||
const Vector t_b(v_b->x*scale_b.x + trans_b.x, v_b->y*scale_b.y + trans_b.y, v_b->z*scale_b.z + trans_b.z);
|
||||
v->coords = (t_b - t_a)*render_t + t_a;
|
||||
|
||||
const Vector &n_a=normals[v_a->n];
|
||||
const Vector &n_b=normals[v_b->n];
|
||||
v->normal=(n_b-n_a)*render_t+n_a;
|
||||
const Vector &n_a = normals[v_a->n];
|
||||
const Vector &n_b = normals[v_b->n];
|
||||
v->normal = (n_b - n_a)*render_t + n_a;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,36 +227,36 @@ void MD2Rep::render( Vert *v,const Vert *v_a,const Vert *v_b,float render_t ){
|
||||
}
|
||||
*/
|
||||
|
||||
void MD2Rep::render( Model *model,int render_a,int render_b,float render_t ){
|
||||
const Frame &frame_a=frames[render_a];
|
||||
const Vector scale_a=frame_a.scale,trans_a=frame_a.trans;
|
||||
void MD2Rep::render(Model *model, int render_a, int render_b, float render_t) {
|
||||
const Frame &frame_a = frames[render_a];
|
||||
const Vector scale_a = frame_a.scale, trans_a = frame_a.trans;
|
||||
|
||||
const Frame &frame_b=frames[render_b];
|
||||
const Vector scale_b=frame_b.scale,trans_b=frame_b.trans;
|
||||
const Frame &frame_b = frames[render_b];
|
||||
const Vector scale_b = frame_b.scale, trans_b = frame_b.trans;
|
||||
|
||||
const VertexUV *uv=uvs.begin();
|
||||
const Vertex *v_a=frame_a.verts.begin();
|
||||
const Vertex *v_b=frame_b.verts.begin();
|
||||
const VertexUV *uv = (VertexUV*)&uvs.begin()[0];
|
||||
const Vertex *v_a = (Vertex*)(&frame_a.verts.begin()[0]);
|
||||
const Vertex *v_b = (Vertex*)(&frame_b.verts.begin()[0]);
|
||||
|
||||
mesh->lock( true );
|
||||
for( int k=0;k<n_verts;++uv,++v_a,++v_b,++k ){
|
||||
mesh->lock(true);
|
||||
for (int k = 0; k < n_verts; ++uv, ++v_a, ++v_b, ++k) {
|
||||
|
||||
const Vector t_a( v_a->x*scale_a.x+trans_a.x,v_a->y*scale_a.y+trans_a.y,v_a->z*scale_a.z+trans_a.z );
|
||||
const Vector t_b( v_b->x*scale_b.x+trans_b.x,v_b->y*scale_b.y+trans_b.y,v_b->z*scale_b.z+trans_b.z );
|
||||
const Vector t( (t_b-t_a)*render_t+t_a );
|
||||
const Vector t_a(v_a->x*scale_a.x + trans_a.x, v_a->y*scale_a.y + trans_a.y, v_a->z*scale_a.z + trans_a.z);
|
||||
const Vector t_b(v_b->x*scale_b.x + trans_b.x, v_b->y*scale_b.y + trans_b.y, v_b->z*scale_b.z + trans_b.z);
|
||||
const Vector t((t_b - t_a)*render_t + t_a);
|
||||
|
||||
const Vector &n_a=normals[v_a->n];
|
||||
const Vector &n_b=normals[v_b->n];
|
||||
const Vector n( (n_b-n_a)*render_t+n_a );
|
||||
const Vector &n_a = normals[v_a->n];
|
||||
const Vector &n_b = normals[v_b->n];
|
||||
const Vector n((n_b - n_a)*render_t + n_a);
|
||||
|
||||
tex_coords[0][0]=uv->u;
|
||||
tex_coords[0][1]=uv->v;
|
||||
tex_coords[0][0] = uv->u;
|
||||
tex_coords[0][1] = uv->v;
|
||||
|
||||
mesh->setVertex( k,&t.x,&n.x,tex_coords );
|
||||
mesh->setVertex(k, &t.x, &n.x, tex_coords);
|
||||
}
|
||||
mesh->unlock();
|
||||
|
||||
model->enqueue( mesh,0,n_verts,0,n_tris );
|
||||
model->enqueue(mesh, 0, n_verts, 0, n_tris);
|
||||
}
|
||||
/*
|
||||
void MD2Rep::render( Model *model,const Vert *v_a,const Vert *v_b,float render_t ){
|
||||
@@ -280,30 +280,30 @@ void MD2Rep::render( Model *model,const Vert *v_a,const Vert *v_b,float render_t
|
||||
}
|
||||
*/
|
||||
|
||||
void MD2Rep::render( Model *model,const Vert *v_a,int render_b,float render_t ){
|
||||
void MD2Rep::render(Model *model, const Vert *v_a, int render_b, float render_t) {
|
||||
|
||||
const Frame &frame_b=frames[render_b];
|
||||
const Vector scale_b=frame_b.scale,trans_b=frame_b.trans;
|
||||
const Frame &frame_b = frames[render_b];
|
||||
const Vector scale_b = frame_b.scale, trans_b = frame_b.trans;
|
||||
|
||||
const VertexUV *uv=uvs.begin();
|
||||
const Vertex *v_b=frame_b.verts.begin();
|
||||
const VertexUV *uv = (VertexUV*)&uvs.begin()[0];
|
||||
const Vertex *v_b = (Vertex*)&frame_b.verts.begin()[0];
|
||||
|
||||
mesh->lock( true );
|
||||
for( int k=0;k<n_verts;++uv,++v_a,++v_b,++k ){
|
||||
mesh->lock(true);
|
||||
for (int k = 0; k < n_verts; ++uv, ++v_a, ++v_b, ++k) {
|
||||
|
||||
const Vector t_b( v_b->x*scale_b.x+trans_b.x,v_b->y*scale_b.y+trans_b.y,v_b->z*scale_b.z+trans_b.z );
|
||||
const Vector t( (t_b-v_a->coords)*render_t+v_a->coords );
|
||||
const Vector t_b(v_b->x*scale_b.x + trans_b.x, v_b->y*scale_b.y + trans_b.y, v_b->z*scale_b.z + trans_b.z);
|
||||
const Vector t((t_b - v_a->coords)*render_t + v_a->coords);
|
||||
|
||||
const Vector &n_b=normals[v_b->n];
|
||||
const Vector n( (n_b-v_a->normal)*render_t+v_a->normal );
|
||||
const Vector &n_b = normals[v_b->n];
|
||||
const Vector n((n_b - v_a->normal)*render_t + v_a->normal);
|
||||
|
||||
tex_coords[0][0]=uv->u;
|
||||
tex_coords[0][1]=uv->v;
|
||||
tex_coords[0][0] = uv->u;
|
||||
tex_coords[0][1] = uv->v;
|
||||
|
||||
mesh->setVertex( k,&t.x,&n.x,tex_coords );
|
||||
mesh->setVertex(k, &t.x, &n.x, tex_coords);
|
||||
}
|
||||
mesh->unlock();
|
||||
|
||||
model->enqueue( mesh,0,n_verts,0,n_tris );
|
||||
model->enqueue(mesh, 0, n_verts, 0, n_tris);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,11 +166,11 @@ Vector static tf( const Vector &v ){
|
||||
}
|
||||
|
||||
#ifdef BETA
|
||||
static log( const string &t ){
|
||||
static int log( const string &t ){
|
||||
gx_runtime->debugLog( t.c_str() );
|
||||
}
|
||||
#else
|
||||
static log( const string &t ){}
|
||||
static int log( const string &t ){}
|
||||
#endif
|
||||
|
||||
static Surf *findSurf( q3_face *f ){
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ void Surface::updateNormals(){
|
||||
const Vector &v1=vertices[t.verts[1]].coords;
|
||||
const Vector &v2=vertices[t.verts[2]].coords;
|
||||
Vector n=(v1-v0).cross(v2-v0);
|
||||
if( n.length()<=EPSILON ) continue;
|
||||
if( n.length()<= FLT_FLT_EPSILON ) continue;
|
||||
n.normalize();
|
||||
norm_map[v0]+=n;
|
||||
norm_map[v1]+=n;
|
||||
|
||||
@@ -15,7 +15,7 @@ static const TerrainRep *curr;
|
||||
static Frustum frustum;
|
||||
static int out_cnt,proc_cnt,clip_cnt;
|
||||
|
||||
static float proj_epsilon=EPSILON; //.01f;
|
||||
static float proj_epsilon= FLT_FLT_EPSILON; //.01f;
|
||||
|
||||
struct TerrainRep::Cell{
|
||||
unsigned char height;
|
||||
@@ -259,7 +259,7 @@ void TerrainRep::insert( Tri *t ){
|
||||
Vector v=Vector( verts[t->v1].v+verts[t->v2].v )/2;
|
||||
// float d=eye_plane.distance( v );
|
||||
float d=eye_vec.distance( v );
|
||||
if( d<EPSILON ) d=EPSILON;
|
||||
if( d<FLT_FLT_EPSILON ) d= FLT_FLT_EPSILON;
|
||||
t->proj_err=errors[t->id].error/d;
|
||||
if( t->proj_err>proj_epsilon ){
|
||||
tri_que.push( t );
|
||||
@@ -344,7 +344,7 @@ TerrainRep::Error TerrainRep::calcErr( int id,const Vert &v0,const Vert &v1,cons
|
||||
|
||||
Vert tv( (v1.x+v2.x)/2,(v1.z+v2.z)/2 );
|
||||
float e=fabs(tv.v.y-(v1.v.y+v2.v.y)/2);
|
||||
et.error= e>=1 ? 255 : ceil( (e-EPSILON)*255.0f );
|
||||
et.error= e>=1 ? 255 : ceil( (e- FLT_FLT_EPSILON)*255.0f );
|
||||
|
||||
Error el=calcErr( id*2,tv,v2,v0 );
|
||||
Error er=calcErr( id*2+1,tv,v0,v1 );
|
||||
@@ -382,7 +382,7 @@ TerrainRep::Error TerrainRep::calcErr( int id,int x,int z,const Vert &v0,const V
|
||||
|
||||
Vert tv( (v1.x+v2.x)/2,(v1.z+v2.z)/2 );
|
||||
float e=fabs(tv.v.y-(v1.v.y+v2.v.y)/2);
|
||||
et.error= e>=1 ? 255 : ceil( (e-EPSILON)*255.0f );
|
||||
et.error= e>=1 ? 255 : ceil( (e- FLT_FLT_EPSILON)*255.0f );
|
||||
|
||||
Error el=calcErr( id*2,x,z,tv,v2,v0 );
|
||||
Error er=calcErr( id*2+1,x,z,tv,v0,v1 );
|
||||
|
||||
+9
-9
@@ -234,10 +234,10 @@ void World::collide( Object *src ){
|
||||
|
||||
Plane coll_plane( coll_line*coll.time,coll.normal );
|
||||
|
||||
coll_plane.d-=COLLISION_EPSILON;
|
||||
coll_plane.d-=COLLISION_FLT_EPSILON;
|
||||
coll.time=coll_plane.t_intersect( coll_line );
|
||||
|
||||
if( coll.time>0 ){// && fabs(coll.normal.dot( coll_line.d ))>EPSILON ){
|
||||
if( coll.time>0 ){// && fabs(coll.normal.dot( coll_line.d ))>FLT_EPSILON ){
|
||||
//update source position - ONLY IF AHEAD!
|
||||
sv=coll_line*coll.time;
|
||||
td*=1-coll.time;
|
||||
@@ -257,7 +257,7 @@ void World::collide( Object *src ){
|
||||
}else if( n_hit==1 ){
|
||||
if( planes[0].distance(nv)>=0 ){
|
||||
dv=nv;n_hit=0;
|
||||
}else if( fabs( planes[0].n.dot( coll_plane.n ) )<1-EPSILON ){
|
||||
}else if( fabs( planes[0].n.dot( coll_plane.n ) )<1-FLT_FLT_EPSILON ){
|
||||
dv=coll_plane.intersect( planes[0] ).nearest( dv );
|
||||
}else{
|
||||
//SQUISHED!
|
||||
@@ -277,11 +277,11 @@ void World::collide( Object *src ){
|
||||
|
||||
if( coll_info->response==COLLISION_RESPONSE_SLIDE ){
|
||||
float d=dd.length();
|
||||
if( d<=EPSILON ){ dv=sv;break; }
|
||||
if( d<= FLT_FLT_EPSILON ){ dv=sv;break; }
|
||||
if( d>td ) dd*=td/d;
|
||||
}else if( coll_info->response==COLLISION_RESPONSE_SLIDEXZ ){
|
||||
float d=Vector( dd.x,0,dd.z ).length();
|
||||
if( d<=EPSILON ){ dv=sv;break; }
|
||||
if( d<= FLT_FLT_EPSILON ){ dv=sv;break; }
|
||||
if( d>td_xz ) dd*=td_xz/d;
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ void World::collide( Object *src ){
|
||||
//move plane out a bit (cough)
|
||||
coll_plane.d-=.001f;
|
||||
|
||||
if( fabs(coll.normal.dot( coll_line.d ))>EPSILON ){
|
||||
if( fabs(coll.normal.dot( coll_line.d ))>FLT_EPSILON ){
|
||||
float t=coll_plane.t_intersect( coll_line );
|
||||
//update source position - ONLY IF AHEAD!
|
||||
if( t>0 ){
|
||||
@@ -421,7 +421,7 @@ void World::collide( Object *src ){
|
||||
}else if( n_hit==1 ){
|
||||
if( planes[0].distance(nv)>=0 ){
|
||||
dv=nv;n_hit=0;
|
||||
}else if( fabs( planes[0].n.dot( coll_plane.n ) )<1-EPSILON ){
|
||||
}else if( fabs( planes[0].n.dot( coll_plane.n ) )<1-FLT_EPSILON ){
|
||||
dv=coll_plane.intersect( planes[0] ).nearest( dv );
|
||||
}else{
|
||||
hits=MAX_HITS;break;
|
||||
@@ -439,11 +439,11 @@ void World::collide( Object *src ){
|
||||
|
||||
if( coll_info->response==COLLISION_RESPONSE_SLIDE ){
|
||||
float d=dd.length();
|
||||
if( d<=EPSILON ){ dv=sv;break; }
|
||||
if( d<=FLT_EPSILON ){ dv=sv;break; }
|
||||
if( d>td ) dd*=td/d;
|
||||
}else if( coll_info->response==COLLISION_RESPONSE_SLIDEXZ ){
|
||||
float d=Vector( dd.x,0,dd.z ).length();
|
||||
if( d<=EPSILON ){ dv=sv;break; }
|
||||
if( d<=FLT_EPSILON ){ dv=sv;break; }
|
||||
if( d>td_xz ) dd*=td_xz/d;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user