• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision20acbb7bffa787e828641f4fc7782de092005293 (tree)
Time2012-06-02 23:57:14
Authorshom5xg <shom@.(no...>
Commitershom5xg

Log Message

first commit

Change Summary

Incremental Difference

Binary files /dev/null and b/util/lib/glpng/glpng.lib differ
Binary files /dev/null and b/util/lib/glpng/glpngd.lib differ
Binary files /dev/null and b/util/lib/glut/freeglut.lib differ
--- /dev/null
+++ b/util/project/util_dx/util.props
@@ -0,0 +1,8 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <ImportGroup Label="PropertySheets" />
4+ <PropertyGroup Label="UserMacros" />
5+ <PropertyGroup />
6+ <ItemDefinitionGroup />
7+ <ItemGroup />
8+</Project>
--- /dev/null
+++ b/util/project/util_dx/util_dx.vcxproj
@@ -0,0 +1,138 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <ItemGroup Label="ProjectConfigurations">
4+ <ProjectConfiguration Include="Debug|Win32">
5+ <Configuration>Debug</Configuration>
6+ <Platform>Win32</Platform>
7+ </ProjectConfiguration>
8+ <ProjectConfiguration Include="Release|Win32">
9+ <Configuration>Release</Configuration>
10+ <Platform>Win32</Platform>
11+ </ProjectConfiguration>
12+ </ItemGroup>
13+ <ItemGroup>
14+ <ClCompile Include="..\..\src\util\mm\mm_angle.cpp" />
15+ <ClCompile Include="..\..\src\util\mm\mm_etc.cpp" />
16+ <ClCompile Include="..\..\src\util\mm\mm_float.cpp" />
17+ <ClCompile Include="..\..\src\util\mm\mm_matrix.cpp" />
18+ <ClCompile Include="..\..\src\util\mm\mm_shape.cpp" />
19+ <ClCompile Include="..\..\src\util\mm\mm_type.cpp" />
20+ <ClCompile Include="..\..\src\util\mm\mm_vector.cpp" />
21+ <ClCompile Include="..\..\src\util\pch_util.cpp">
22+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
23+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
24+ </ClCompile>
25+ <ClCompile Include="..\..\src\util\util.cpp" />
26+ </ItemGroup>
27+ <ItemGroup>
28+ <ClInclude Include="..\..\src\util\mm\mm.h" />
29+ <ClInclude Include="..\..\src\util\mm\mm_angle.h" />
30+ <ClInclude Include="..\..\src\util\mm\mm_etc.h" />
31+ <ClInclude Include="..\..\src\util\mm\mm_float.h" />
32+ <ClInclude Include="..\..\src\util\mm\mm_matrix.h" />
33+ <ClInclude Include="..\..\src\util\mm\mm_shape.h" />
34+ <ClInclude Include="..\..\src\util\mm\mm_type.h" />
35+ <ClInclude Include="..\..\src\util\mm\mm_vector.h" />
36+ <ClInclude Include="..\..\src\util\pch\pch_common.h" />
37+ <ClInclude Include="..\..\src\util\pch\pch_dx.h" />
38+ <ClInclude Include="..\..\src\util\pch_util.h" />
39+ <ClInclude Include="..\..\src\util\util.h" />
40+ </ItemGroup>
41+ <PropertyGroup Label="Globals">
42+ <ProjectGuid>{232B4361-3E5A-4334-9A18-5FE5A1048791}</ProjectGuid>
43+ <Keyword>Win32Proj</Keyword>
44+ <RootNamespace>mm</RootNamespace>
45+ <ProjectName>0_util_dx</ProjectName>
46+ </PropertyGroup>
47+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
48+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
49+ <ConfigurationType>StaticLibrary</ConfigurationType>
50+ <UseDebugLibraries>true</UseDebugLibraries>
51+ <CharacterSet>Unicode</CharacterSet>
52+ </PropertyGroup>
53+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
54+ <ConfigurationType>StaticLibrary</ConfigurationType>
55+ <UseDebugLibraries>false</UseDebugLibraries>
56+ <WholeProgramOptimization>true</WholeProgramOptimization>
57+ <CharacterSet>Unicode</CharacterSet>
58+ </PropertyGroup>
59+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
60+ <ImportGroup Label="ExtensionSettings">
61+ </ImportGroup>
62+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
63+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
64+ <Import Project="util.props" />
65+ </ImportGroup>
66+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
67+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+ <Import Project="util.props" />
69+ </ImportGroup>
70+ <PropertyGroup Label="UserMacros" />
71+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
72+ <LinkIncremental>true</LinkIncremental>
73+ <LibraryPath>C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib;C:\Program Files\Microsoft DirectX SDK %28November 2008%29\Lib\x86;$(LibraryPath)</LibraryPath>
74+ <IncludePath>C:\Program Files\boost\boost_1_42;C:\Program Files\Microsoft DirectX SDK %28November 2008%29\Include;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include;$(VCInstallDir)include</IncludePath>
75+ <OutDir>$(ProjectDir)$(Configuration)_Output\</OutDir>
76+ <TargetName>util_dx_Debug</TargetName>
77+ </PropertyGroup>
78+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
79+ <LinkIncremental>false</LinkIncremental>
80+ <LibraryPath>C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib;C:\Program Files\Microsoft DirectX SDK %28November 2008%29\Lib\x86;$(LibraryPath)</LibraryPath>
81+ <IncludePath>C:\Program Files\boost\boost_1_42;C:\Program Files\Microsoft DirectX SDK %28November 2008%29\Include;C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include;$(VCInstallDir)include</IncludePath>
82+ <OutDir>$(ProjectDir)$(Configuration)_Output\</OutDir>
83+ <TargetName>util_dx</TargetName>
84+ </PropertyGroup>
85+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
86+ <ClCompile>
87+ <PrecompiledHeader>Use</PrecompiledHeader>
88+ <WarningLevel>Level4</WarningLevel>
89+ <Optimization>Disabled</Optimization>
90+ <PreprocessorDefinitions>WIN32;DX;_DEBUG;_WINDOWS;_USRDLL;MM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
91+ <TreatWarningAsError>true</TreatWarningAsError>
92+ <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
93+ <PrecompiledHeaderFile>pch_util.h</PrecompiledHeaderFile>
94+ <AdditionalIncludeDirectories>$(ProjectDir)..\..\src\</AdditionalIncludeDirectories>
95+ </ClCompile>
96+ <Link>
97+ <SubSystem>Windows</SubSystem>
98+ <GenerateDebugInformation>true</GenerateDebugInformation>
99+ <ModuleDefinitionFile>
100+ </ModuleDefinitionFile>
101+ <AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
102+ <IgnoreSpecificDefaultLibraries>
103+ </IgnoreSpecificDefaultLibraries>
104+ </Link>
105+ <PostBuildEvent>
106+ <Command>copy $(OutDir)util_dx_Debug.lib $(ProjectDir)..\..\..\_release\util_dx_Debug.lib</Command>
107+ </PostBuildEvent>
108+ </ItemDefinitionGroup>
109+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
110+ <ClCompile>
111+ <WarningLevel>Level4</WarningLevel>
112+ <PrecompiledHeader>Use</PrecompiledHeader>
113+ <Optimization>MaxSpeed</Optimization>
114+ <FunctionLevelLinking>true</FunctionLevelLinking>
115+ <IntrinsicFunctions>true</IntrinsicFunctions>
116+ <PreprocessorDefinitions>WIN32;DX;NDEBUG;_WINDOWS;_USRDLL;MM_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
117+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
118+ <PrecompiledHeaderFile>pch_util.h</PrecompiledHeaderFile>
119+ <AdditionalIncludeDirectories>$(ProjectDir)..\..\src\</AdditionalIncludeDirectories>
120+ <TreatWarningAsError>true</TreatWarningAsError>
121+ </ClCompile>
122+ <Link>
123+ <SubSystem>Windows</SubSystem>
124+ <GenerateDebugInformation>true</GenerateDebugInformation>
125+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
126+ <OptimizeReferences>true</OptimizeReferences>
127+ <ModuleDefinitionFile>
128+ </ModuleDefinitionFile>
129+ <AdditionalDependencies>winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
130+ </Link>
131+ <PostBuildEvent>
132+ <Command>copy $(OutDir)util_dx.lib $(ProjectDir)..\..\..\_release\util_dx.lib</Command>
133+ </PostBuildEvent>
134+ </ItemDefinitionGroup>
135+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
136+ <ImportGroup Label="ExtensionTargets">
137+ </ImportGroup>
138+</Project>
\ No newline at end of file
--- /dev/null
+++ b/util/project/util_dx/util_dx.vcxproj.filters
@@ -0,0 +1,84 @@
1+<?xml version="1.0" encoding="utf-8"?>
2+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+ <ItemGroup>
4+ <Filter Include="src">
5+ <UniqueIdentifier>{b2728c86-4f50-48ec-82bf-ab74bae098b5}</UniqueIdentifier>
6+ </Filter>
7+ <Filter Include="src\util">
8+ <UniqueIdentifier>{56012a4e-1e08-412b-acd4-433271545edb}</UniqueIdentifier>
9+ </Filter>
10+ <Filter Include="src\util\mm">
11+ <UniqueIdentifier>{6d8993d7-be52-434e-9558-3a6ae36007a7}</UniqueIdentifier>
12+ </Filter>
13+ <Filter Include="src\util\pch">
14+ <UniqueIdentifier>{24b2f42c-f8d4-4917-9d84-33a179a9445e}</UniqueIdentifier>
15+ </Filter>
16+ </ItemGroup>
17+ <ItemGroup>
18+ <ClCompile Include="..\..\src\util\mm\mm_angle.cpp">
19+ <Filter>src\util\mm</Filter>
20+ </ClCompile>
21+ <ClCompile Include="..\..\src\util\mm\mm_etc.cpp">
22+ <Filter>src\util\mm</Filter>
23+ </ClCompile>
24+ <ClCompile Include="..\..\src\util\mm\mm_float.cpp">
25+ <Filter>src\util\mm</Filter>
26+ </ClCompile>
27+ <ClCompile Include="..\..\src\util\mm\mm_matrix.cpp">
28+ <Filter>src\util\mm</Filter>
29+ </ClCompile>
30+ <ClCompile Include="..\..\src\util\mm\mm_shape.cpp">
31+ <Filter>src\util\mm</Filter>
32+ </ClCompile>
33+ <ClCompile Include="..\..\src\util\mm\mm_type.cpp">
34+ <Filter>src\util\mm</Filter>
35+ </ClCompile>
36+ <ClCompile Include="..\..\src\util\mm\mm_vector.cpp">
37+ <Filter>src\util\mm</Filter>
38+ </ClCompile>
39+ <ClCompile Include="..\..\src\util\util.cpp">
40+ <Filter>src\util</Filter>
41+ </ClCompile>
42+ <ClCompile Include="..\..\src\util\pch_util.cpp">
43+ <Filter>src\util</Filter>
44+ </ClCompile>
45+ </ItemGroup>
46+ <ItemGroup>
47+ <ClInclude Include="..\..\src\util\util.h">
48+ <Filter>src\util</Filter>
49+ </ClInclude>
50+ <ClInclude Include="..\..\src\util\mm\mm.h">
51+ <Filter>src\util\mm</Filter>
52+ </ClInclude>
53+ <ClInclude Include="..\..\src\util\mm\mm_angle.h">
54+ <Filter>src\util\mm</Filter>
55+ </ClInclude>
56+ <ClInclude Include="..\..\src\util\mm\mm_etc.h">
57+ <Filter>src\util\mm</Filter>
58+ </ClInclude>
59+ <ClInclude Include="..\..\src\util\mm\mm_float.h">
60+ <Filter>src\util\mm</Filter>
61+ </ClInclude>
62+ <ClInclude Include="..\..\src\util\mm\mm_matrix.h">
63+ <Filter>src\util\mm</Filter>
64+ </ClInclude>
65+ <ClInclude Include="..\..\src\util\mm\mm_shape.h">
66+ <Filter>src\util\mm</Filter>
67+ </ClInclude>
68+ <ClInclude Include="..\..\src\util\mm\mm_type.h">
69+ <Filter>src\util\mm</Filter>
70+ </ClInclude>
71+ <ClInclude Include="..\..\src\util\mm\mm_vector.h">
72+ <Filter>src\util\mm</Filter>
73+ </ClInclude>
74+ <ClInclude Include="..\..\src\util\pch_util.h">
75+ <Filter>src\util</Filter>
76+ </ClInclude>
77+ <ClInclude Include="..\..\src\util\pch\pch_common.h">
78+ <Filter>src\util\pch</Filter>
79+ </ClInclude>
80+ <ClInclude Include="..\..\src\util\pch\pch_dx.h">
81+ <Filter>src\util\pch</Filter>
82+ </ClInclude>
83+ </ItemGroup>
84+</Project>
\ No newline at end of file
--- /dev/null
+++ b/util/src/util/mm/mm.h
@@ -0,0 +1,17 @@
1+/***************************************************************************/
2+/** @file mm.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+#include "mm_type.h"
10+
11+#include "mm_vector.h"
12+#include "mm_matrix.h"
13+#include "mm_float.h"
14+#include "mm_angle.h"
15+#include "mm_shape.h"
16+#include "mm_etc.h"
17+
--- /dev/null
+++ b/util/src/util/mm/mm_angle.cpp
@@ -0,0 +1,167 @@
1+/***************************************************************************/
2+/** @file mm_angle.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+#include <math.h>
10+
11+
12+namespace
13+{
14+ f64 sin_raw( f64 in_val )
15+ {
16+ return sin( in_val );
17+ }
18+ f64 cos_raw( f64 in_val )
19+ {
20+ return cos( in_val );
21+ }
22+ f64 tan_raw( f64 in_val )
23+ {
24+ return tan( in_val );
25+ }
26+}
27+
28+
29+/***************************************************************************
30+ mm( namespace )
31+****************************************************************************/
32+
33+angle mm::degree_to_angle( f32 deg )
34+{
35+ while( deg < 0.0f || 360.0f <= deg )
36+ {
37+ deg = deg + 360.0f * mm::sign_f( deg ) * -1.0f;
38+ }
39+
40+ const f32 ang_max = SCAST<f32>( 0x100000000 );
41+ return ( SCAST< angle >( ang_max * deg / 360.0f ) );
42+}
43+
44+f32 mm::degree_to_radian( f32 deg )
45+{
46+ return ( deg * ( sc_fPi / 180.0f ) );
47+}
48+
49+vec2f mm::degree_to_v2( f32 deg )
50+{
51+ const f32 rad = degree_to_radian( deg );
52+
53+ return ( radian_to_v2( rad ) );
54+}
55+
56+f32 mm::angle_to_degree( angle ang )
57+{
58+ const f32 deg = 180.0f * SCAST<f32>( ang ) / SCAST<f32>( 0x80000000 );
59+
60+ return ( deg == 360.0f ) ? 0.0f : deg;
61+}
62+
63+f32 mm::angle_to_radian( angle ang )
64+{
65+ const f32 deg = angle_to_degree( ang );
66+
67+ return ( degree_to_radian( deg ) );
68+}
69+
70+vec2f mm::angle_to_v2( angle ang )
71+{
72+ const f32 rad = angle_to_radian( ang );
73+
74+ return ( radian_to_v2( rad ) );
75+}
76+
77+f32 mm::radian_to_degree( f32 rad )
78+{
79+ return ( rad * ( 180.0f / sc_fPi ) );
80+}
81+
82+angle mm::radian_to_angle( f32 rad )
83+{
84+ const f32 deg = radian_to_degree( rad );
85+
86+ return ( degree_to_angle( deg ) );
87+}
88+
89+vec2f mm::radian_to_v2( f32 rad )
90+{
91+ return vec2f( cos( rad ), sin( rad ) );
92+}
93+
94+f32 mm::v2_to_degree( const vec2f& v )
95+{
96+ const f32 rad = v2_to_radian( v );
97+
98+ return ( radian_to_degree( rad ) );
99+}
100+
101+angle mm::v2_to_angle( const vec2f& v )
102+{
103+ const f32 rad = v2_to_radian( v );
104+
105+ return ( radian_to_angle( rad ) );
106+}
107+
108+f32 mm::v2_to_radian( const vec2f& v )
109+{
110+ if( is_equal_zero_f( v.x ) )
111+ {
112+ return ( v.y == 0.0f ) ? 0.0f :
113+ ( v.y > 0.0f ) ? ( sc_fPi * 0.5f ) : ( sc_fPi * 1.5f );
114+ }
115+ else if( is_equal_zero_f( v.y ) )
116+ {
117+ return ( v.x > 0.0f ) ? 0.0f : sc_fPi;
118+ }
119+ else
120+ {
121+ return ( atan2( v.y, v.x ) + ( ( v.x > 0.0f ) ? 0.0f : sc_fPi ) - ( sc_fPi * 0.5f ) );
122+ }
123+}
124+
125+vec2f mm::inverse_dir(
126+ const vec2f& v2_dir,
127+ b32 b_inverse_x, b32 b_inverse_y
128+ )
129+{
130+ vec2f v2_out;
131+
132+ v2_out.x = b_inverse_x ? ( - v2_dir.x ) : v2_dir.x;
133+ v2_out.y = b_inverse_y ? ( - v2_dir.y ) : v2_dir.y;
134+
135+ return v2_out;
136+}
137+
138+f32 mm::sin( f32 in_rad )
139+{
140+ return SCAST< f32 >( sin( SCAST< f64 >( in_rad ) ) );
141+}
142+
143+f64 mm::sin( f64 in_rad )
144+{
145+ return sin_raw( in_rad );
146+}
147+
148+f32 mm::cos( f32 in_rad )
149+{
150+ return SCAST< f32 >( cos( SCAST< f64 >( in_rad ) ) );
151+}
152+
153+f64 mm::cos( f64 in_rad )
154+{
155+ return cos_raw( in_rad );
156+}
157+
158+f32 mm::tan( f32 in_rad )
159+{
160+ return SCAST< f32 >( tan( SCAST< f64 >( in_rad ) ) );
161+}
162+
163+f64 mm::tan( f64 in_rad )
164+{
165+ return tan_raw( in_rad );
166+}
167+
--- /dev/null
+++ b/util/src/util/mm/mm_angle.h
@@ -0,0 +1,39 @@
1+/***************************************************************************/
2+/** @file mm_angle.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+
10+namespace mm
11+{
12+ const f32 sc_fPi = 3.141592654f;
13+
14+ __declspec( dllexport ) angle degree_to_angle( f32 deg );
15+ __declspec( dllexport ) f32 degree_to_radian( f32 deg );
16+ __declspec( dllexport ) vec2f degree_to_v2( f32 deg );
17+ __declspec( dllexport ) f32 angle_to_degree( angle ang );
18+ __declspec( dllexport ) f32 angle_to_radian( angle ang );
19+ __declspec( dllexport ) vec2f angle_to_v2( angle ang );
20+ __declspec( dllexport ) f32 radian_to_degree( f32 rad );
21+ __declspec( dllexport ) angle radian_to_angle( f32 rad );
22+ __declspec( dllexport ) vec2f radian_to_v2( f32 rad );
23+ __declspec( dllexport ) f32 v2_to_degree( const vec2f& v );
24+ __declspec( dllexport ) angle v2_to_angle( const vec2f& v );
25+ __declspec( dllexport ) f32 v2_to_radian( const vec2f& v );
26+
27+ __declspec( dllexport ) vec2f inverse_dir(
28+ const vec2f& v2_dir,
29+ b32 b_inverse_x = TRUE, b32 b_inverse_y = TRUE
30+ );
31+
32+ __declspec( dllexport ) f32 sin( f32 in_rad );
33+ __declspec( dllexport ) f64 sin( f64 in_rad );
34+ __declspec( dllexport ) f32 cos( f32 in_rad );
35+ __declspec( dllexport ) f64 cos( f64 in_rad );
36+ __declspec( dllexport ) f32 tan( f32 in_rad );
37+ __declspec( dllexport ) f64 tan( f64 in_rad );
38+}
39+
--- /dev/null
+++ b/util/src/util/mm/mm_etc.cpp
@@ -0,0 +1,90 @@
1+/***************************************************************************/
2+/** @file mm_etc.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+
10+/***************************************************************************
11+ mm( namespace )
12+****************************************************************************/
13+
14+u32 mm::rand_i()
15+{
16+ return ( rand() );
17+}
18+
19+s32 mm::sign_i( const s32 in_val )
20+{
21+ return ( in_val >= 0 ) ? 1 : -1;
22+}
23+f32 mm::sign_f( const f32 in_val )
24+{
25+ return ( in_val >= 0.0f ) ? 1.0f : -1.0f;
26+}
27+
28+s32 mm::abs_i( const s32 in_val )
29+{
30+ return ( in_val * sign_i( in_val ) );
31+}
32+f32 mm::abs_f( const f32 in_val )
33+{
34+ return ( in_val * sign_f( in_val ) );
35+}
36+
37+b32 mm::is_nearly_equal_i( const s32 a, const s32 b, const s32 tolerance )
38+{
39+ return ( abs_i( a - b ) < tolerance );
40+
41+}
42+b32 mm::is_nearly_equal_f( const f32 a, const f32 b, const f32 tolerance )
43+{
44+ return ( abs_f( a - b ) < tolerance );
45+
46+}
47+
48+s32 mm::clamp_i( s32 in_iVal, s32 in_iMin, s32 in_iMax )
49+{
50+ return (
51+ ( in_iVal < in_iMin ) ? in_iMin :
52+ ( in_iVal > in_iMax ) ? in_iMax :
53+ in_iVal
54+ );
55+}
56+
57+f32 mm::clamp_f( f32 in_fVal, f32 in_fMin, f32 in_fMax )
58+{
59+ return (
60+ ( in_fVal < in_fMin ) ? in_fMin :
61+ ( in_fVal > in_fMax ) ? in_fMax :
62+ in_fVal
63+ );
64+}
65+
66+f32 mm::saturate( f32 in_fVal )
67+{
68+ return ( clamp_f( in_fVal, 0.f, 1.f ) );
69+}
70+
71+s32 mm::min_i( s32 in_iVal1, s32 in_iVal2 )
72+{
73+ return ( ( in_iVal1 < in_iVal2 ) ? in_iVal1 : in_iVal2 );
74+}
75+
76+f32 mm::min_f( f32 in_fVal1, f32 in_fVal2 )
77+{
78+ return ( ( in_fVal1 < in_fVal2 ) ? in_fVal1 : in_fVal2 );
79+}
80+
81+s32 mm::max_i( s32 in_iVal1, s32 in_iVal2 )
82+{
83+ return ( ( in_iVal1 > in_iVal2 ) ? in_iVal1 : in_iVal2 );
84+}
85+
86+f32 mm::max_f( f32 in_fVal1, f32 in_fVal2 )
87+{
88+ return ( ( in_fVal1 > in_fVal2 ) ? in_fVal1 : in_fVal2 );
89+}
90+
--- /dev/null
+++ b/util/src/util/mm/mm_etc.h
@@ -0,0 +1,33 @@
1+/***************************************************************************/
2+/** @file mm_etc.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+
10+namespace mm
11+{
12+ __declspec( dllexport ) u32 rand_i();
13+
14+ __declspec( dllexport ) s32 sign_i( const s32 in_val );
15+ __declspec( dllexport ) f32 sign_f( const f32 in_val );
16+
17+ __declspec( dllexport ) s32 abs_i( const s32 in_val );
18+ __declspec( dllexport ) f32 abs_f( const f32 in_val );
19+
20+ __declspec( dllexport ) b32 is_nearly_equal_i
21+ ( const s32 a, const s32 b, const s32 tolerance );
22+ __declspec( dllexport ) b32 is_nearly_equal_f
23+ ( const f32 a, const f32 b, const f32 tolerance );
24+
25+ __declspec( dllexport ) s32 clamp_i( s32 in_iVal, s32 in_iMin, s32 in_iMax );
26+ __declspec( dllexport ) f32 clamp_f( f32 in_fVal, f32 in_fMin, f32 in_fMax );
27+ __declspec( dllexport ) f32 saturate( f32 in_fVal );
28+
29+ __declspec( dllexport ) s32 min_i( s32 in_iVal1, s32 in_iVal2 );
30+ __declspec( dllexport ) f32 min_f( f32 in_fVal1, f32 in_fVal2 );
31+ __declspec( dllexport ) s32 max_i( s32 in_iVal1, s32 in_iVal2 );
32+ __declspec( dllexport ) f32 max_f( f32 in_fVal1, f32 in_fVal2 );
33+}
--- /dev/null
+++ b/util/src/util/mm/mm_float.cpp
@@ -0,0 +1,118 @@
1+/***************************************************************************/
2+/** @file mm_float.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+#include "mm.h"
10+
11+
12+/***************************************************************************
13+ mm( namespace )
14+****************************************************************************/
15+
16+f32 mm::abs( f32 in_fVal )
17+{
18+ return fabs( in_fVal );
19+}
20+
21+b32 mm::is_equal_f( f32 num_1, f32 num_2 )
22+{
23+ return ( abs( num_1 - num_2 ) < FLT_EPSILON );
24+}
25+
26+b32 mm::is_equal_zero_f( f32 in_num )
27+{
28+ return ( is_equal_f( in_num, 0.0f ) );
29+}
30+
31+f32 mm::square( f32 val )
32+{
33+ return ( val * val );
34+}
35+
36+f32 mm::sq( f32 val )
37+{
38+ return square( val );
39+}
40+
41+f32 mm::pow( f32 val, f32 num )
42+{
43+ f32 ret = 1.0f;
44+
45+ for( int i=0; i<num; ++i )
46+ {
47+ ret *= val;
48+ }
49+
50+ return ret;
51+}
52+
53+f32 mm::sqrt( f32 val )
54+{
55+ if( val == 0 ) { return 0; }
56+
57+ ///--
58+ const f32 x_init = val;
59+
60+ f32 x = val, x_prev;
61+
62+ do
63+ {
64+ x_prev = x;
65+
66+ x = ( x_prev + x_init / x_prev ) / 2;
67+ }
68+ while( x < x_prev );
69+ ///--
70+
71+ return x_prev;
72+}
73+
74+f32 mm::lerp( f32 in_fMin, f32 in_fMax, f32 in_fRatio )
75+{
76+ return ( in_fMax - in_fMin ) * in_fRatio + in_fMin;
77+}
78+
79+f32 mm::ratio( f32 in_fVal, f32 in_fMin, f32 in_fMax )
80+{
81+ cf32 fBottom = ( in_fMin < in_fMax ) ? in_fMin : in_fMax;
82+ cf32 fTop = ( in_fMin < in_fMax ) ? in_fMax : in_fMin;
83+
84+ return ( in_fVal - fBottom ) / ( fTop / fBottom );
85+}
86+
87+f32 mm::half( f32 in_val )
88+{
89+ return ( in_val / 2.0f );
90+}
91+
92+f32 mm::quarter( f32 in_val )
93+{
94+ return ( in_val / 4.0f );
95+}
96+
97+f32 mm::minus( f32 in_val )
98+{
99+ return ( in_val * -1.0f );
100+}
101+
102+f32 mm::pythagorean( f32 length_a, f32 length_b )
103+{
104+ return ( mm::sqrt( mm::square( length_a ) + mm::square( length_b ) ) );
105+}
106+
107+f32 mm::pythagorean_inv( f32 length_sloping, f32 length_a )
108+{
109+ return (
110+ mm::sqrt( mm::square( length_sloping ) - mm::square( length_a ) )
111+ );
112+}
113+
114+u32 mm::mul_as_float( u32 in_uVal, f32 in_fVal )
115+{
116+ return SCAST<u32>( SCAST<f32>( in_uVal ) * in_fVal );
117+}
118+
--- /dev/null
+++ b/util/src/util/mm/mm_float.h
@@ -0,0 +1,33 @@
1+/***************************************************************************/
2+/** @file mm_float.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+
10+namespace mm
11+{
12+ __declspec( dllexport ) f32 abs( f32 in_fVal );
13+
14+ __declspec( dllexport ) b32 is_equal_f( f32 in_num_1, f32 in_num_2 );
15+ __declspec( dllexport ) b32 is_equal_zero_f( f32 in_num );
16+
17+ __declspec( dllexport ) f32 square( f32 val );
18+ __declspec( dllexport ) f32 sq( f32 val );
19+ __declspec( dllexport ) f32 pow( f32 val, f32 num );
20+ __declspec( dllexport ) f32 sqrt( f32 val );
21+
22+ __declspec( dllexport ) f32 lerp( f32 in_fMin, f32 in_fMax, f32 in_fRatio );
23+ __declspec( dllexport ) f32 ratio( f32 in_fVal, f32 in_fMin, f32 in_fMax );
24+
25+ __declspec( dllexport ) f32 half( f32 in_val );
26+ __declspec( dllexport ) f32 quarter( f32 in_val );
27+ __declspec( dllexport ) f32 minus( f32 in_val );
28+
29+ __declspec( dllexport ) f32 pythagorean( f32 length_a, f32 length_b );
30+ __declspec( dllexport ) f32 pythagorean_inv( f32 length_sloping, f32 length_b );
31+
32+ __declspec( dllexport ) u32 mul_as_float( u32 in_uVal, f32 in_fVal );
33+}
--- /dev/null
+++ b/util/src/util/mm/mm_matrix.cpp
@@ -0,0 +1,35 @@
1+/***************************************************************************/
2+/** @file mm_matrix.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+#include "mm.h"
10+
11+
12+/***************************************************************************
13+ mm( namespace )
14+****************************************************************************/
15+
16+void mm::identify_x( matrix& io_mtx )
17+{
18+ D3DXMatrixIdentity( &io_mtx );
19+}
20+
21+void mm::scaling_x( matrix& io_mtx, const vec3f& in_v3_scale )
22+{
23+ D3DXMatrixScaling( &io_mtx, VEC3_ARGS( in_v3_scale ) );
24+}
25+
26+void mm::rotation_z_x( matrix& io_mtx, f32 in_rad_z )
27+{
28+ D3DXMatrixRotationZ( &io_mtx, in_rad_z );
29+}
30+
31+void mm::translation_x( matrix& io_mtx, const vec3f& in_v3_offset )
32+{
33+ D3DXMatrixTranslation( &io_mtx, VEC3_ARGS( in_v3_offset ) );
34+}
35+
--- /dev/null
+++ b/util/src/util/mm/mm_matrix.h
@@ -0,0 +1,23 @@
1+/***************************************************************************/
2+/** @file mm_vector.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+
10+namespace mm
11+{
12+#ifdef DX
13+ typedef D3DXMATRIX matrix;
14+#else
15+#endif
16+
17+ __declspec( dllexport ) void identify_x( matrix& io_mtx );
18+
19+ __declspec( dllexport ) void scaling_x( matrix& io_mtx, const vec3f& in_v3_scale );
20+ __declspec( dllexport ) void rotation_z_x( matrix& io_mtx, f32 in_rad_z );
21+ __declspec( dllexport ) void translation_x( matrix& io_mtx, const vec3f& in_v3_offset );
22+}
23+
--- /dev/null
+++ b/util/src/util/mm/mm_shape.cpp
@@ -0,0 +1,91 @@
1+/***************************************************************************/
2+/** @file mm_shape.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+#include "mm.h"
10+
11+
12+/***************************************************************************
13+ mm::ellipse_t
14+****************************************************************************/
15+
16+mm::ellipse_t::ellipse_t()
17+:
18+m_v_pos( mm::zero_v2() ),
19+m_v_dir( mm::zero_v2() ),
20+m_half_length_of_major_axis( 0.0f ),
21+m_dist_center_to_focus( 0.0f ),
22+
23+m_v2_pos_focus_tbl(),
24+
25+m_degree_of_spread( 0.0f )
26+{
27+ for( u32 i=0; i<ELEMENTSOF( m_v2_pos_focus_tbl ); ++i )
28+ {
29+ mm::zero_v( m_v2_pos_focus_tbl[i] );
30+ }
31+}
32+
33+void mm::ellipse_t::SetPos( const vec2f& v2_pos )
34+{
35+ m_v_pos = v2_pos;
36+}
37+
38+void mm::ellipse_t::SetDir( const vec2f& v2_dir )
39+{
40+ m_v_dir = v2_dir;
41+}
42+
43+void mm::ellipse_t::SetLengthOfMajorAxis( f32 length )
44+{
45+ m_half_length_of_major_axis = length / 2.0f;
46+
47+ SetAngleOfSpread( m_degree_of_spread );
48+}
49+
50+void mm::ellipse_t::SetAngleOfSpread( f32 degree )
51+{
52+ m_degree_of_spread = degree;
53+
54+ const f32 rad = mm::degree_to_radian( degree );
55+
56+ m_dist_center_to_focus =
57+ m_half_length_of_major_axis *
58+ mm::sqrt( 1.0f - mm::square( tan( rad ) ) );
59+}
60+
61+void mm::ellipse_t::GetFocusPoint( vec2f& v2_out, b32 b_near ) const
62+{
63+ const f32 scale_dir =
64+ m_half_length_of_major_axis +
65+ m_dist_center_to_focus * ( b_near ? -1.0f : 1.0f );
66+
67+ v2_out = m_v_pos + m_v_dir * scale_dir;
68+}
69+
70+f32 mm::ellipse_t::GetLengthOfMinorAxis() const
71+{
72+ const f32 length_of_minor_axis_sq =
73+ mm::square( m_half_length_of_major_axis ) -
74+ mm::square( m_dist_center_to_focus );
75+
76+ return ( mm::sqrt( length_of_minor_axis_sq ) * 2.0f );
77+}
78+
79+b32 mm::ellipse_t::IsIncluded( const vec2f& v2_pos ) const
80+{
81+ vec2f v_focus_near, v_focus_far;
82+ GetFocusPoint( v_focus_near, TRUE );
83+ GetFocusPoint( v_focus_far, FALSE );
84+
85+ const f32 dist_to_focus_near = mm::length( v2_pos - v_focus_near );
86+ const f32 dist_to_focus_far = mm::length( v2_pos - v_focus_far );
87+ const f32 dist_sum = dist_to_focus_near + dist_to_focus_far;
88+
89+ return ( dist_sum <= m_half_length_of_major_axis * 2.0f );
90+}
91+
--- /dev/null
+++ b/util/src/util/mm/mm_shape.h
@@ -0,0 +1,41 @@
1+/***************************************************************************/
2+/** @file mm_shape.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+
10+namespace mm
11+{
12+ ///-- "ellipse"
13+ class ellipse_t
14+ {
15+ public:
16+ __declspec( dllexport ) ellipse_t();
17+
18+ __declspec( dllexport ) void SetPos( const vec2f& v2_pos );
19+ __declspec( dllexport ) void SetDir( const vec2f& v2_dir );
20+ __declspec( dllexport ) void SetLengthOfMajorAxis( f32 length );
21+ __declspec( dllexport ) void SetAngleOfSpread( f32 degree );
22+
23+ __declspec( dllexport ) void GetFocusPoint( vec2f& v2_out, b32 b_near ) const;
24+ __declspec( dllexport ) f32 GetLengthOfMinorAxis() const;
25+
26+ __declspec( dllexport ) b32 IsIncluded( const vec2f& v2_pos ) const;
27+
28+ private:
29+ vec2f m_v_pos;
30+ vec2f m_v_dir;
31+ f32 m_half_length_of_major_axis;
32+ f32 m_dist_center_to_focus;
33+
34+ vec2f m_v2_pos_focus_tbl[2];
35+
36+ f32 m_degree_of_spread;
37+ };
38+ ///--
39+}
40+
41+
--- /dev/null
+++ b/util/src/util/mm/mm_shape2.cpp
@@ -0,0 +1,218 @@
1+/***************************************************************************/
2+/** @file mm_shape.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch.h"
8+
9+#include "mm_shape.h"
10+
11+
12+/***************************************************************************
13+ mm::ellipse_t
14+****************************************************************************/
15+
16+mm::ellipse_t::ellipse_t()
17+:
18+m_v_pos( mm::zero_v2() ),
19+m_v_dir( mm::zero_v2() ),
20+m_half_length_of_major_axis( 0.0f ),
21+m_dist_center_to_focus( 0.0f ),
22+
23+m_v2_pos_focus_tbl(),
24+
25+m_degree_of_spread( 0.0f )
26+
27+#ifdef _DEBUG
28+,m_p_buf_vertex( NULL )//,
29+#endif
30+{
31+ for( u32 i=0; i<ELEMENTSOF( m_v2_pos_focus_tbl ); ++i )
32+ {
33+ mm::zero_v( m_v2_pos_focus_tbl[i] );
34+ }
35+}
36+
37+#ifdef _DEBUG
38+mm::ellipse_t::~ellipse_t()
39+{
40+ my_safe_rel( m_p_buf_vertex );
41+}
42+#endif
43+
44+void mm::ellipse_t::SetPos( const vec2f& v2_pos )
45+{
46+ m_v_pos = v2_pos;
47+}
48+
49+void mm::ellipse_t::SetDir( const vec2f& v2_dir )
50+{
51+ m_v_dir = v2_dir;
52+}
53+
54+void mm::ellipse_t::SetLengthOfMajorAxis( f32 length )
55+{
56+ m_half_length_of_major_axis = length / 2.0f;
57+
58+ SetAngleOfSpread( m_degree_of_spread );
59+}
60+
61+void mm::ellipse_t::SetAngleOfSpread( f32 degree )
62+{
63+ m_degree_of_spread = degree;
64+
65+ const f32 rad = mm::degree_to_radian( degree );
66+
67+ m_dist_center_to_focus =
68+ m_half_length_of_major_axis *
69+ mm::sqrt( 1.0f - mm::square( tan( rad ) ) );
70+}
71+
72+void mm::ellipse_t::GetFocusPoint( vec2f& v2_out, b32 b_near ) const
73+{
74+ const f32 scale_dir =
75+ m_half_length_of_major_axis +
76+ m_dist_center_to_focus * ( b_near ? -1.0f : 1.0f );
77+
78+ v2_out = m_v_pos + m_v_dir * scale_dir;
79+}
80+
81+f32 mm::ellipse_t::GetLengthOfMinorAxis() const
82+{
83+ const f32 length_of_minor_axis_sq =
84+ mm::square( m_half_length_of_major_axis ) -
85+ mm::square( m_dist_center_to_focus );
86+
87+ return ( mm::sqrt( length_of_minor_axis_sq ) * 2.0f );
88+}
89+
90+b32 mm::ellipse_t::IsIncluded( const vec2f& v2_pos ) const
91+{
92+ vec2f v_focus_near, v_focus_far;
93+ GetFocusPoint( v_focus_near, TRUE );
94+ GetFocusPoint( v_focus_far, FALSE );
95+
96+ const f32 dist_to_focus_near = mm::length( v2_pos - v_focus_near );
97+ const f32 dist_to_focus_far = mm::length( v2_pos - v_focus_far );
98+ const f32 dist_sum = dist_to_focus_near + dist_to_focus_far;
99+
100+ return ( dist_sum <= m_half_length_of_major_axis * 2.0f );
101+}
102+
103+#ifdef _DEBUG
104+void mm::ellipse_t::Draw( LPDIRECT3DDEVICE9 p_device, u32 color )
105+{
106+ if( !m_p_buf_vertex )
107+ {
108+ p_device->CreateVertexBuffer(
109+ sizeof( vertex_t ) * sc_length_of_vertex_list,
110+ D3DUSAGE_WRITEONLY, sc_fvf, D3DPOOL_MANAGED,
111+ &m_p_buf_vertex, NULL
112+ );
113+ }
114+
115+ ///--
116+ const vec2f v_dir_cross = mm::get_v( -m_v_dir.y, m_v_dir.x );
117+
118+ const vec2f v_left_top =
119+ m_v_pos +
120+ m_v_dir * m_half_length_of_major_axis * 2.0f -
121+ v_dir_cross * GetLengthOfMinorAxis() / 2.0f;
122+ const vec2f v_right_top =
123+ m_v_pos +
124+ m_v_dir * m_half_length_of_major_axis * 2.0f +
125+ v_dir_cross * GetLengthOfMinorAxis() / 2.0f;
126+ const vec2f v_left_bottom =
127+ m_v_pos -
128+ v_dir_cross * GetLengthOfMinorAxis() / 2.0f;
129+ const vec2f v_right_bottom =
130+ m_v_pos +
131+ v_dir_cross * GetLengthOfMinorAxis() / 2.0f;
132+
133+ const vec2f v_mid_lt_rt = mm::mid_point( v_left_top, v_right_top );
134+ const vec2f v_mid_rt_rb = mm::mid_point( v_right_top, v_right_bottom );
135+ const vec2f v_mid_rb_lb = mm::mid_point( v_right_bottom, v_left_bottom );
136+ const vec2f v_mid_lb_lt = mm::mid_point( v_left_bottom, v_left_top );
137+
138+ const vec2f v_intpol_rt =
139+ mm::mid_point(
140+ mm::mid_point( v_mid_lt_rt, v_right_top ),
141+ mm::mid_point( v_mid_rt_rb, v_right_top )
142+ );
143+ const vec2f v_intpol_rb =
144+ mm::mid_point(
145+ mm::mid_point( v_mid_rt_rb, v_right_bottom ),
146+ mm::mid_point( v_mid_rb_lb, v_right_bottom )
147+ );
148+ const vec2f v_intpol_lb =
149+ mm::mid_point(
150+ mm::mid_point( v_mid_rb_lb, v_left_bottom ),
151+ mm::mid_point( v_mid_lb_lt, v_left_bottom )
152+ );
153+ const vec2f v_intpol_lt =
154+ mm::mid_point(
155+ mm::mid_point( v_mid_lb_lt, v_left_top ),
156+ mm::mid_point( v_mid_lt_rt, v_left_top )
157+ );
158+
159+ const vertex_t vertex_tbl[] =
160+ {
161+ { v_mid_lt_rt.x, v_mid_lt_rt.y, 0.0f, 1.0f, color },
162+ { v_intpol_rt.x, v_intpol_rt.y, 0.0f, 1.0f, color },
163+ { v_mid_rt_rb.x, v_mid_rt_rb.y, 0.0f, 1.0f, color },
164+ { v_intpol_rb.x, v_intpol_rb.y, 0.0f, 1.0f, color },
165+ { v_mid_rb_lb.x, v_mid_rb_lb.y, 0.0f, 1.0f, color },
166+ { v_intpol_lb.x, v_intpol_lb.y, 0.0f, 1.0f, color },
167+ { v_mid_lb_lt.x, v_mid_lb_lt.y, 0.0f, 1.0f, color },
168+ { v_intpol_lt.x, v_intpol_lt.y, 0.0f, 1.0f, color },
169+ { v_mid_lt_rt.x, v_mid_lt_rt.y, 0.0f, 1.0f, color },
170+ };
171+ STATIC_ASSERT( ELEMENTSOF( vertex_tbl ) == sc_length_of_vertex_list );
172+ ///--
173+
174+ ///--
175+ void *p_written = NULL;
176+ m_p_buf_vertex->Lock(
177+ 0,
178+ sizeof( vertex_t ) * sc_length_of_vertex_list,
179+ SCAST< void** >( &p_written ),
180+ 0
181+ );
182+
183+ memcpy(
184+ p_written,
185+ vertex_tbl,
186+ sizeof( vertex_t ) * sc_length_of_vertex_list
187+ );
188+
189+ m_p_buf_vertex->Unlock();
190+ ///--
191+
192+ ///--
193+ #define STSS p_device->SetTextureStageState
194+
195+ STSS( 0 , D3DTSS_COLORARG2 , D3DTA_DIFFUSE );
196+ STSS( 0 , D3DTSS_COLOROP , D3DTOP_SELECTARG2 );
197+ STSS( 0 , D3DTSS_ALPHAARG2 , D3DTA_DIFFUSE );
198+ STSS( 0 , D3DTSS_ALPHAOP , D3DTOP_SELECTARG2 );
199+
200+ #undef STSS
201+
202+ #define SRS p_device->SetRenderState
203+
204+ SRS( D3DRS_ALPHABLENDENABLE , FALSE );
205+
206+ #undef SRS
207+ ///--
208+
209+ ///--
210+ p_device->SetStreamSource( 0, m_p_buf_vertex, 0, sizeof( vertex_t ) );
211+ p_device->SetFVF( sc_fvf );
212+
213+ p_device->
214+ DrawPrimitive( D3DPT_LINESTRIP, 0, sc_length_of_vertex_list - 1 );
215+ ///--
216+}
217+#endif
218+
--- /dev/null
+++ b/util/src/util/mm/mm_type.cpp
@@ -0,0 +1,10 @@
1+/***************************************************************************/
2+/** @file mm_type.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+#include "mm.h"
10+
--- /dev/null
+++ b/util/src/util/mm/mm_type.h
@@ -0,0 +1,115 @@
1+/***************************************************************************/
2+/** @file mm_type.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+///-- basis
10+typedef short int u8;
11+typedef short unsigned int u16;
12+typedef unsigned int u32;
13+typedef short signed int s16;
14+typedef signed int s32;
15+typedef float f32;
16+typedef double f64;
17+typedef u8 b8;
18+typedef u32 b32;
19+
20+#define ct const
21+
22+typedef ct u8 cu8;
23+typedef ct u16 cu16;
24+typedef ct u32 cu32;
25+typedef ct s16 cs16;
26+typedef ct s32 cs32;
27+typedef ct f32 cf32;
28+typedef ct f64 cf64;
29+typedef cu8 cb8;
30+typedef cu32 cb32;
31+
32+#undef TRUE
33+#define TRUE 1
34+#undef FALSE
35+#define FALSE 0
36+///--
37+
38+///-- angle
39+typedef u32 angle;
40+///--
41+
42+///-- vector
43+#ifdef DX
44+
45+struct D3DXVECTOR2;
46+struct D3DXVECTOR3;
47+struct D3DXVECTOR4;
48+
49+typedef D3DXVECTOR2 vec2f;
50+typedef D3DXVECTOR3 vec3f;
51+typedef D3DXVECTOR4 vec4f;
52+
53+#else //if GL
54+
55+struct vec2f
56+{
57+ f32 x;
58+ f32 y;
59+
60+ vec2f()
61+ {
62+ this->x = 0.0f;
63+ this->y = 0.0f;
64+ }
65+ vec2f( f32 x, f32 y )
66+ {
67+ this->x = x;
68+ this->y = y;
69+ }
70+};
71+struct vec3f
72+{
73+ f32 x;
74+ f32 y;
75+ f32 z;
76+
77+ vec3f()
78+ {
79+ this->x = 0.0f;
80+ this->y = 0.0f;
81+ this->z = 0.0f;
82+ }
83+ vec3f( f32 x, f32 y, f32 z )
84+ {
85+ this->x = x;
86+ this->y = y;
87+ this->z = z;
88+ }
89+};
90+struct vec4f
91+{
92+ f32 x;
93+ f32 y;
94+ f32 z;
95+ f32 w;
96+
97+ vec4f()
98+ {
99+ this->x = 0.0f;
100+ this->y = 0.0f;
101+ this->z = 0.0f;
102+ this->w = 0.0f;
103+ }
104+ vec4f( f32 x, f32 y, f32 z, f32 w )
105+ {
106+ this->x = x;
107+ this->y = y;
108+ this->z = z;
109+ this->w = w;
110+ }
111+};
112+
113+#endif
114+///--
115+
--- /dev/null
+++ b/util/src/util/mm/mm_vector.cpp
@@ -0,0 +1,515 @@
1+/***************************************************************************/
2+/** @file mm_vector.cpp
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+#include "mm.h"
10+
11+
12+/***************************************************************************
13+ mm( namespace )
14+****************************************************************************/
15+
16+void mm::zero_v( vec2f& v )
17+{
18+ v = vec2f( 0.0f, 0.0f );
19+}
20+void mm::zero_v( vec3f& v )
21+{
22+ v = vec3f( 0.0f, 0.0f, 0.0f );
23+}
24+void mm::zero_v( vec4f& v )
25+{
26+ v = vec4f( 0.0f, 0.0f, 0.0f, 0.0f );
27+}
28+vec2f mm::zero_v2()
29+{
30+ return vec2f( 0.0f, 0.0f );
31+}
32+vec3f mm::zero_v3()
33+{
34+ return vec3f( 0.0f, 0.0f, 0.0f );
35+}
36+vec4f mm::zero_v4()
37+{
38+ return vec4f( 0.0f, 0.0f, 0.0f, 0.0f );
39+}
40+
41+void mm::half_v( vec2f& v )
42+{
43+ v = vec2f( 0.5f, 0.5f );
44+}
45+void mm::half_v( vec3f& v )
46+{
47+ v = vec3f( 0.5f, 0.5f, 0.5f );
48+}
49+void mm::half_v( vec4f& v )
50+{
51+ v = vec4f( 0.5f, 0.5f, 0.5f, 0.5f );
52+}
53+vec2f mm::half_v2()
54+{
55+ return vec2f( 0.5f, 0.5f );
56+}
57+vec3f mm::half_v3()
58+{
59+ return vec3f( 0.5f, 0.5f, 0.5f );
60+}
61+vec4f mm::half_v4()
62+{
63+ return vec4f( 0.5f, 0.5f, 0.5f, 0.5f );
64+}
65+
66+void mm::one_v( vec2f& v )
67+{
68+ v = vec2f( 1.0f, 1.0f );
69+}
70+void mm::one_v( vec3f& v )
71+{
72+ v = vec3f( 1.0f, 1.0f, 1.0f );
73+}
74+void mm::one_v( vec4f& v )
75+{
76+ v = vec4f( 1.0f, 1.0f, 1.0f, 1.0f );
77+}
78+vec2f mm::one_v2()
79+{
80+ return vec2f( 1.0f, 1.0f );
81+}
82+vec3f mm::one_v3()
83+{
84+ return vec3f( 1.0f, 1.0f, 1.0f );
85+}
86+vec4f mm::one_v4()
87+{
88+ return vec4f( 1.0f, 1.0f, 1.0f, 1.0f );
89+}
90+
91+void mm::neg_v( vec2f& v )
92+{
93+ v = vec2f( -1.0f, -1.0f );
94+}
95+void mm::neg_v( vec3f& v )
96+{
97+ v = vec3f( -1.0f, -1.0f, -1.0f );
98+}
99+void mm::neg_v( vec4f& v )
100+{
101+ v = vec4f( -1.0f, -1.0f, -1.0f, -1.0f );
102+}
103+vec2f mm::neg_v2()
104+{
105+ return vec2f( -1.0f, -1.0f );
106+}
107+vec3f mm::neg_v3()
108+{
109+ return vec3f( -1.0f, -1.0f, -1.0f );
110+}
111+vec4f mm::neg_v4()
112+{
113+ return vec4f( -1.0f, -1.0f, -1.0f, -1.0f );
114+}
115+
116+vec2f mm::get_v( f32 x, f32 y )
117+{
118+ return vec2f( x, y );
119+}
120+
121+vec3f mm::get_v( f32 x, f32 y, f32 z )
122+{
123+ return vec3f( x, y, z );
124+}
125+
126+vec4f mm::get_v( f32 x, f32 y, f32 z, f32 w )
127+{
128+ return vec4f( x, y, z, w );
129+}
130+
131+vec2f mm::get_v2_all( f32 in_val )
132+{
133+ return get_v( in_val, in_val );
134+}
135+
136+vec3f mm::get_v3_all( f32 in_val )
137+{
138+ return get_v( in_val, in_val, in_val );
139+}
140+
141+vec4f mm::get_v4_all( f32 in_val )
142+{
143+ return get_v( in_val, in_val, in_val, in_val );
144+}
145+
146+vec3f mm::v2_to_v3( const vec2f& in_v2, f32 in_z )
147+{
148+ return vec3f( in_v2.x, in_v2.y, in_z );
149+}
150+
151+vec4f mm::v3_to_v4( const vec3f& in_v3, f32 in_w )
152+{
153+ return vec4f( in_v3.x, in_v3.y, in_v3.z, in_w );
154+}
155+
156+vec2f mm::v3_to_v2( const vec3f& in_v3 )
157+{
158+ return vec2f( in_v3.x, in_v3.y );
159+}
160+
161+vec3f mm::v4_to_v3( const vec4f& in_v4 )
162+{
163+ return vec3f( in_v4.x, in_v4.y, in_v4.z );
164+}
165+
166+vec2f mm::add_v( const vec2f& in_v2_1, const vec2f& in_v2_2 )
167+{
168+ const f32 x = in_v2_1.x + in_v2_2.x;
169+ const f32 y = in_v2_1.y + in_v2_2.y;
170+
171+ return vec2f( x, y );
172+}
173+
174+vec3f mm::add_v( const vec3f& in_v3_1, const vec3f& in_v3_2 )
175+{
176+ const f32 x = in_v3_1.x + in_v3_2.x;
177+ const f32 y = in_v3_1.y + in_v3_2.y;
178+ const f32 z = in_v3_1.z + in_v3_2.z;
179+
180+ return vec3f( x, y, z );
181+}
182+
183+vec4f mm::add_v( const vec4f& in_v4_1, const vec4f& in_v4_2 )
184+{
185+ const f32 x = in_v4_1.x + in_v4_2.x;
186+ const f32 y = in_v4_1.y + in_v4_2.y;
187+ const f32 z = in_v4_1.z + in_v4_2.z;
188+ const f32 w = in_v4_1.w + in_v4_2.w;
189+
190+ return vec4f( x, y, z, w );
191+}
192+
193+vec2f mm::add_x_v( const vec2f& in_v2_1, f32 in_x )
194+{
195+ const f32 x = in_v2_1.x + in_x;
196+
197+ return vec2f( x, in_v2_1.y );
198+}
199+
200+vec3f mm::add_x_v( const vec3f& in_v3_1, f32 in_x )
201+{
202+ const f32 x = in_v3_1.x + in_x;
203+
204+ return vec3f( x, in_v3_1.y, in_v3_1.z );
205+}
206+
207+vec4f mm::add_x_v( const vec4f& in_v4_1, f32 in_x )
208+{
209+ const f32 x = in_v4_1.x + in_x;
210+
211+ return vec4f( x, in_v4_1.y, in_v4_1.z, in_v4_1.w );
212+}
213+
214+vec2f mm::add_y_v( const vec2f& in_v2_1, f32 in_y )
215+{
216+ const f32 y = in_v2_1.y + in_y;
217+
218+ return vec2f( in_v2_1.x, y );
219+}
220+
221+vec3f mm::add_y_v( const vec3f& in_v3_1, f32 in_y )
222+{
223+ const f32 y = in_v3_1.y + in_y;
224+
225+ return vec3f( in_v3_1.x, y, in_v3_1.z );
226+}
227+
228+vec4f mm::add_y_v( const vec4f& in_v4_1, f32 in_y )
229+{
230+ const f32 y = in_v4_1.y + in_y;
231+
232+ return vec4f( in_v4_1.x, y, in_v4_1.z, in_v4_1.w );
233+}
234+
235+vec3f mm::add_z_v( const vec3f& in_v3_1, f32 in_z )
236+{
237+ const f32 z = in_v3_1.z + in_z;
238+
239+ return vec3f( in_v3_1.x, in_v3_1.y, z );
240+}
241+
242+vec4f mm::add_z_v( const vec4f& in_v4_1, f32 in_z )
243+{
244+ const f32 z = in_v4_1.z + in_z;
245+
246+ return vec4f( in_v4_1.x, in_v4_1.y, z, in_v4_1.w );
247+}
248+
249+vec4f mm::add_w_v( const vec4f& in_v4_1, f32 in_w )
250+{
251+ const f32 w = in_v4_1.w + in_w;
252+
253+ return vec4f( in_v4_1.x, in_v4_1.y, in_v4_1.z, w );
254+}
255+
256+vec2f mm::sub_v( const vec2f& in_v2_1, const vec2f& in_v2_2 )
257+{
258+ const f32 x = in_v2_1.x - in_v2_2.x;
259+ const f32 y = in_v2_1.y - in_v2_2.y;
260+
261+ return vec2f( x, y );
262+}
263+
264+vec3f mm::sub_v( const vec3f& in_v3_1, const vec3f& in_v3_2 )
265+{
266+ const f32 x = in_v3_1.x - in_v3_2.x;
267+ const f32 y = in_v3_1.y - in_v3_2.y;
268+ const f32 z = in_v3_1.z - in_v3_2.z;
269+
270+ return vec3f( x, y, z );
271+}
272+
273+vec4f mm::sub_v( const vec4f& in_v4_1, const vec4f& in_v4_2 )
274+{
275+ const f32 x = in_v4_1.x - in_v4_2.x;
276+ const f32 y = in_v4_1.y - in_v4_2.y;
277+ const f32 z = in_v4_1.z - in_v4_2.z;
278+ const f32 w = in_v4_1.w - in_v4_2.w;
279+
280+ return vec4f( x, y, z, w );
281+}
282+
283+vec2f mm::sub_x_v( const vec2f& in_v2_1, f32 in_x )
284+{
285+ const f32 x = in_v2_1.x - in_x;
286+
287+ return vec2f( x, in_v2_1.y );
288+}
289+
290+vec3f mm::sub_x_v( const vec3f& in_v3_1, f32 in_x )
291+{
292+ const f32 x = in_v3_1.x - in_x;
293+
294+ return vec3f( x, in_v3_1.y, in_v3_1.z );
295+}
296+
297+vec4f mm::sub_x_v( const vec4f& in_v4_1, f32 in_x )
298+{
299+ const f32 x = in_v4_1.x - in_x;
300+
301+ return vec4f( x, in_v4_1.y, in_v4_1.z, in_v4_1.w );
302+}
303+
304+vec2f mm::sub_y_v( const vec2f& in_v2_1, f32 in_y )
305+{
306+ const f32 y = in_v2_1.y - in_y;
307+
308+ return vec2f( in_v2_1.x, y );
309+}
310+
311+vec3f mm::sub_y_v( const vec3f& in_v3_1, f32 in_y )
312+{
313+ const f32 y = in_v3_1.y - in_y;
314+
315+ return vec3f( in_v3_1.x, y, in_v3_1.z );
316+}
317+
318+vec4f mm::sub_y_v( const vec4f& in_v4_1, f32 in_y )
319+{
320+ const f32 y = in_v4_1.y - in_y;
321+
322+ return vec4f( in_v4_1.x, y, in_v4_1.z, in_v4_1.w );
323+}
324+
325+vec3f mm::sub_z_v( const vec3f& in_v3_1, f32 in_z )
326+{
327+ const f32 z = in_v3_1.z - in_z;
328+
329+ return vec3f( in_v3_1.x, in_v3_1.y, z );
330+}
331+
332+vec4f mm::sub_z_v( const vec4f& in_v4_1, f32 in_z )
333+{
334+ const f32 z = in_v4_1.z - in_z;
335+
336+ return vec4f( in_v4_1.x, in_v4_1.y, z, in_v4_1.w );
337+}
338+
339+vec4f mm::sub_w_v( const vec4f& in_v4_1, f32 in_w )
340+{
341+ const f32 w = in_v4_1.w - in_w;
342+
343+ return vec4f( in_v4_1.x, in_v4_1.y, in_v4_1.z, w );
344+}
345+
346+vec2f mm::mul_v( const vec2f& in_v2_1, const f32 in_val )
347+{
348+ const f32 x = in_v2_1.x * in_val;
349+ const f32 y = in_v2_1.y * in_val;
350+
351+ return vec2f( x, y );
352+}
353+
354+vec3f mm::mul_v( const vec3f& in_v3_1, const f32 in_val )
355+{
356+ const f32 x = in_v3_1.x * in_val;
357+ const f32 y = in_v3_1.y * in_val;
358+ const f32 z = in_v3_1.z * in_val;
359+
360+ return vec3f( x, y, z );
361+}
362+
363+vec4f mm::mul_v( const vec4f& in_v4_1, const f32 in_val )
364+{
365+ const f32 x = in_v4_1.x * in_val;
366+ const f32 y = in_v4_1.y * in_val;
367+ const f32 z = in_v4_1.z * in_val;
368+ const f32 w = in_v4_1.w * in_val;
369+
370+ return vec4f( x, y, z, w );
371+}
372+
373+#define MM_ASSERT( expr ) if( !expr ){ DebugBreak(); }
374+
375+vec2f mm::div_v( const vec2f& in_v2_1, const f32 in_val )
376+{
377+ MM_ASSERT( !( mm::is_equal_zero_f( in_val ) ) );
378+
379+ const f32 x = in_v2_1.x / in_val;
380+ const f32 y = in_v2_1.y / in_val;
381+
382+ return vec2f( x, y );
383+}
384+
385+vec3f mm::div_v( const vec3f& in_v3_1, const f32 in_val )
386+{
387+ MM_ASSERT( !( mm::is_equal_zero_f( in_val ) ) );
388+
389+ const f32 x = in_v3_1.x / in_val;
390+ const f32 y = in_v3_1.y / in_val;
391+ const f32 z = in_v3_1.z / in_val;
392+
393+ return vec3f( x, y, z );
394+}
395+
396+vec4f mm::div_v( const vec4f& in_v4_1, const f32 in_val )
397+{
398+ MM_ASSERT( !( mm::is_equal_zero_f( in_val ) ) );
399+
400+ const f32 x = in_v4_1.x / in_val;
401+ const f32 y = in_v4_1.y / in_val;
402+ const f32 z = in_v4_1.z / in_val;
403+ const f32 w = in_v4_1.w / in_val;
404+
405+ return vec4f( x, y, z, w );
406+}
407+
408+f32 mm::length( const vec2f& v )
409+{
410+ return D3DXVec2Length( &v );
411+}
412+f32 mm::length( const vec3f& v )
413+{
414+ return D3DXVec3Length( &v );
415+}
416+f32 mm::length( const vec4f& v )
417+{
418+ return D3DXVec4Length( &v );
419+}
420+
421+f32 mm::length_sq( const vec2f& v )
422+{
423+ return D3DXVec2LengthSq( &v );
424+}
425+f32 mm::length_sq( const vec3f& v )
426+{
427+ return D3DXVec3LengthSq( &v );
428+}
429+f32 mm::length_sq( const vec4f& v )
430+{
431+ return D3DXVec4LengthSq( &v );
432+}
433+
434+f32 mm::dot( const vec2f& v1, const vec2f& v2 )
435+{
436+ return ( v1.x * v2.x ) + ( v1.y * v2.y );
437+}
438+
439+vec2f mm::normalize( const vec2f& v_in )
440+{
441+ vec2f v_out;
442+
443+ D3DXVec2Normalize( &v_out, &v_in );
444+
445+ return v_out;
446+}
447+
448+vec2f mm::mid_point( const vec2f& v1, const vec2f& v2 )
449+{
450+ return ( ( v1 + v2 ) / 2.0f );
451+}
452+
453+vec2f mm::translate( const vec2f& v, const vec2f& v_move )
454+{
455+ return ( v + v_move );
456+}
457+
458+vec2f mm::rotate( const vec2f& v, f32 rad )
459+{
460+ vec2f v_out;
461+
462+ v_out.x = v.x * cos( rad ) - v.y * sin( rad );
463+ v_out.y = v.x * sin( rad ) + v.y * cos( rad );
464+
465+ return v_out;
466+}
467+
468+vec2f mm::rotate_on_pivot(
469+ const vec2f& v, f32 rad,
470+ const vec2f& v_pos_pivot
471+ )
472+{
473+ const vec2f v_temp1 = mm::translate( v, -v_pos_pivot );
474+ const vec2f v_temp2 = mm::rotate( v_temp1, rad );
475+ return ( mm::translate( v_temp2, +v_pos_pivot ) );
476+}
477+
478+vec2f mm::bezier(
479+ const vec2f& v1, const vec2f& v2, const vec2f& v3, const vec2f& v4,
480+ f32 t
481+ )
482+{
483+ const f32 inv_t = ( 1.0f - t );
484+
485+ return (
486+ mm::pow( inv_t, 3 ) * v1 +
487+ 3.0f * mm::sq( inv_t ) * t * v2 +
488+ 3.0f * inv_t * mm::sq( t ) * v3 +
489+ mm::pow( t, 3 ) * v4
490+ );
491+}
492+
493+f32 mm::distance( const vec2f& v_pos_1, const vec2f& v_pos_2 )
494+{
495+ const vec2f v_pos_dif = v_pos_1 - v_pos_2;
496+
497+ return ( pythagorean( v_pos_dif.x, v_pos_dif.y ) );
498+}
499+
500+f32 mm::dist( const vec2f& v_pos_1, const vec2f& v_pos_2 )
501+{
502+ return ( mm::distance( v_pos_1, v_pos_2 ) );
503+}
504+
505+vec2f mm::direction( const vec2f& v_pos_src, const vec2f& v_pos_dest )
506+{
507+ return ( mm::normalize( v_pos_dest - v_pos_src ) );
508+}
509+
510+vec2f mm::dir( const vec2f& v_pos_src, const vec2f& v_pos_dest )
511+{
512+ return ( mm::direction( v_pos_src, v_pos_dest ) );
513+}
514+
515+
--- /dev/null
+++ b/util/src/util/mm/mm_vector.h
@@ -0,0 +1,137 @@
1+/***************************************************************************/
2+/** @file mm_vector.h
3+ @brief 算術関数
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+
10+namespace mm
11+{
12+ ///-- generation
13+ //-- constant value
14+ __declspec( dllexport ) void zero_v( vec2f& v );
15+ __declspec( dllexport ) void zero_v( vec3f& v );
16+ __declspec( dllexport ) void zero_v( vec4f& v );
17+ __declspec( dllexport ) vec2f zero_v2();
18+ __declspec( dllexport ) vec3f zero_v3();
19+ __declspec( dllexport ) vec4f zero_v4();
20+
21+ __declspec( dllexport ) void half_v( vec2f& v );
22+ __declspec( dllexport ) void half_v( vec3f& v );
23+ __declspec( dllexport ) void half_v( vec4f& v );
24+ __declspec( dllexport ) vec2f half_v2();
25+ __declspec( dllexport ) vec3f half_v3();
26+ __declspec( dllexport ) vec4f half_v4();
27+
28+ __declspec( dllexport ) void one_v( vec2f& v );
29+ __declspec( dllexport ) void one_v( vec3f& v );
30+ __declspec( dllexport ) void one_v( vec4f& v );
31+ __declspec( dllexport ) vec2f one_v2();
32+ __declspec( dllexport ) vec3f one_v3();
33+ __declspec( dllexport ) vec4f one_v4();
34+
35+ __declspec( dllexport ) void neg_v( vec2f& v );
36+ __declspec( dllexport ) void neg_v( vec3f& v );
37+ __declspec( dllexport ) void neg_v( vec4f& v );
38+ __declspec( dllexport ) vec2f neg_v2();
39+ __declspec( dllexport ) vec3f neg_v3();
40+ __declspec( dllexport ) vec4f neg_v4();
41+ //--
42+
43+ //-- specification value
44+ __declspec( dllexport ) vec2f get_v( f32 x, f32 y );
45+ __declspec( dllexport ) vec3f get_v( f32 x, f32 y, f32 z );
46+ __declspec( dllexport ) vec4f get_v( f32 x, f32 y, f32 z, f32 w );
47+
48+ __declspec( dllexport ) vec2f get_v2_all( f32 in_val );
49+ __declspec( dllexport ) vec3f get_v3_all( f32 in_val );
50+ __declspec( dllexport ) vec4f get_v4_all( f32 in_val );
51+ //--
52+ ///--
53+
54+ ///-- conversion
55+ __declspec( dllexport ) vec3f v2_to_v3( const vec2f& in_v2, f32 in_z = 0.0f );
56+ __declspec( dllexport ) vec4f v3_to_v4( const vec3f& in_v3, f32 in_w = 0.0f );
57+ __declspec( dllexport ) vec2f v3_to_v2( const vec3f& in_v3 );
58+ __declspec( dllexport ) vec3f v4_to_v3( const vec4f& in_v4 );
59+ ///--
60+
61+ ///-- basic arithmetic operation
62+ __declspec( dllexport ) vec2f add_v( const vec2f& in_v2_1, const vec2f& in_v2_2 );
63+ __declspec( dllexport ) vec3f add_v( const vec3f& in_v3_1, const vec3f& in_v3_2 );
64+ __declspec( dllexport ) vec4f add_v( const vec4f& in_v4_1, const vec4f& in_v4_2 );
65+
66+ __declspec( dllexport ) vec2f add_x_v( const vec2f& in_v2_1, f32 in_x );
67+ __declspec( dllexport ) vec3f add_x_v( const vec3f& in_v3_1, f32 in_x );
68+ __declspec( dllexport ) vec4f add_x_v( const vec4f& in_v4_1, f32 in_x );
69+
70+ __declspec( dllexport ) vec2f add_y_v( const vec2f& in_v2_1, f32 in_y );
71+ __declspec( dllexport ) vec3f add_y_v( const vec3f& in_v3_1, f32 in_y );
72+ __declspec( dllexport ) vec4f add_y_v( const vec4f& in_v4_1, f32 in_y );
73+
74+ __declspec( dllexport ) vec3f add_z_v( const vec3f& in_v3_1, f32 in_z );
75+ __declspec( dllexport ) vec4f add_z_v( const vec4f& in_v4_1, f32 in_z );
76+
77+ __declspec( dllexport ) vec4f add_w_v( const vec4f& in_v4_1, f32 in_w );
78+
79+ __declspec( dllexport ) vec2f sub_v( const vec2f& in_v2_1, const vec2f& in_v2_2 );
80+ __declspec( dllexport ) vec3f sub_v( const vec3f& in_v3_1, const vec3f& in_v3_2 );
81+ __declspec( dllexport ) vec4f sub_v( const vec4f& in_v4_1, const vec4f& in_v4_2 );
82+
83+ __declspec( dllexport ) vec2f sub_x_v( const vec2f& in_v2_1, f32 in_x );
84+ __declspec( dllexport ) vec3f sub_x_v( const vec3f& in_v3_1, f32 in_x );
85+ __declspec( dllexport ) vec4f sub_x_v( const vec4f& in_v4_1, f32 in_x );
86+
87+ __declspec( dllexport ) vec2f sub_y_v( const vec2f& in_v2_1, f32 in_y );
88+ __declspec( dllexport ) vec3f sub_y_v( const vec3f& in_v3_1, f32 in_y );
89+ __declspec( dllexport ) vec4f sub_y_v( const vec4f& in_v4_1, f32 in_y );
90+
91+ __declspec( dllexport ) vec3f sub_z_v( const vec3f& in_v3_1, f32 in_z );
92+ __declspec( dllexport ) vec4f sub_z_v( const vec4f& in_v4_1, f32 in_z );
93+
94+ __declspec( dllexport ) vec4f sub_w_v( const vec4f& in_v4_1, f32 in_w );
95+
96+ __declspec( dllexport ) vec2f mul_v( const vec2f& in_v2_1, const f32 in_val );
97+ __declspec( dllexport ) vec3f mul_v( const vec3f& in_v3_1, const f32 in_val );
98+ __declspec( dllexport ) vec4f mul_v( const vec4f& in_v4_1, const f32 in_val );
99+
100+ __declspec( dllexport ) vec2f div_v( const vec2f& in_v2_1, const f32 in_val );
101+ __declspec( dllexport ) vec3f div_v( const vec3f& in_v3_1, const f32 in_val );
102+ __declspec( dllexport ) vec4f div_v( const vec4f& in_v4_1, const f32 in_val );
103+ ///--
104+
105+ ///-- utility funcs
106+ __declspec( dllexport ) f32 length( const vec2f& v );
107+ __declspec( dllexport ) f32 length( const vec3f& v );
108+ __declspec( dllexport ) f32 length( const vec4f& v );
109+
110+ __declspec( dllexport ) f32 length_sq( const vec2f& v );
111+ __declspec( dllexport ) f32 length_sq( const vec3f& v );
112+ __declspec( dllexport ) f32 length_sq( const vec4f& v );
113+
114+ __declspec( dllexport ) f32 dot( const vec2f& v1, const vec2f& v2 );
115+
116+ __declspec( dllexport ) vec2f normalize( const vec2f& v_in );
117+
118+ __declspec( dllexport ) vec2f mid_point( const vec2f& v1, const vec2f& v2 );
119+
120+ __declspec( dllexport ) vec2f translate( const vec2f& v, const vec2f& v_move );
121+ __declspec( dllexport ) vec2f rotate( const vec2f& v, f32 rad );
122+ __declspec( dllexport ) vec2f rotate_on_pivot( const vec2f& v, f32 rad, const vec2f& v_pos_pivot );
123+
124+ __declspec( dllexport ) vec2f bezier(
125+ const vec2f& v1, const vec2f& v2, const vec2f& v3, const vec2f& v4,
126+ f32 t
127+ );
128+
129+ __declspec( dllexport ) f32 distance( const vec2f& v_pos_1, const vec2f& v_pos_2 );
130+ __declspec( dllexport ) f32 dist( const vec2f& v_pos_1, const vec2f& v_pos_2 ); //abbr.
131+ __declspec( dllexport ) vec2f direction( const vec2f& v_pos_src, const vec2f& v_pos_dest );
132+ __declspec( dllexport ) vec2f dir( const vec2f& v_pos_src, const vec2f& v_pos_dest ); //abbr.
133+ ///--
134+}
135+
136+
137+#define VEC3_ARGS( _in_v3 ) _in_v3.x, _in_v3.y, _in_v3.z
--- /dev/null
+++ b/util/src/util/pch/pch_common.h
@@ -0,0 +1,212 @@
1+/***************************************************************************/
2+/** @file pch_common.h
3+ @brief 共通で使用するマクロや定数の定義
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+///-- コンパイル時のオプション指定
10+
11+//#define STRICT // 型チェックを厳密に行う
12+
13+#ifndef WIN32_LEAN_AND_MEAN
14+#define WIN32_LEAN_AND_MEAN // ヘッダーからあまり使われない関数を省く
15+#endif
16+
17+///--
18+
19+
20+///-- 警告の抑制
21+
22+#pragma warning (disable: 4127) //"条件式が定数です"
23+#pragma warning (disable: 4238) //"右辺値のクラスが左辺値に使用されます"
24+#pragma warning (disable: 4351) //"新しい動作: 配列 '配列' の要素は既定で初期化されます"
25+
26+///--
27+
28+
29+///-- 往々に用いられるヘッダのインクルード
30+
31+//ユニコード対応(_Tマクロ)
32+#include <tchar.h>
33+
34+//エラー対処
35+#include <crtdbg.h>
36+
37+//stl
38+#include <string>
39+#include <vector>
40+#include <map>
41+#include <algorithm>
42+#include <cstdlib> // for "rand"
43+#include <bitset>
44+
45+//boost
46+#include <boost/format.hpp>
47+#include <boost/scoped_ptr.hpp>
48+#include <boost/shared_ptr.hpp>
49+#include <boost/foreach.hpp>
50+#include <boost/static_assert.hpp>
51+#include <boost/array.hpp>
52+
53+//メモリリーク検出
54+#define _CRTDBG_MAP_ALLOC
55+#include <crtdbg.h>
56+#ifdef _DEBUG
57+#define new new(_NORMAL_BLOCK,__FILE__,__LINE__)
58+#endif
59+
60+///--
61+
62+
63+///-- define types
64+
65+typedef short int u8;
66+typedef short unsigned int u16;
67+typedef unsigned int u32;
68+typedef short signed int s16;
69+typedef signed int s32;
70+typedef float f32;
71+typedef double f64;
72+typedef u8 b8;
73+typedef u32 b32;
74+
75+#define ct const
76+
77+typedef ct u8 cu8;
78+typedef ct u16 cu16;
79+typedef ct u32 cu32;
80+typedef ct s16 cs16;
81+typedef ct s32 cs32;
82+typedef ct f32 cf32;
83+typedef ct f64 cf64;
84+typedef cu8 cb8;
85+typedef cu32 cb32;
86+
87+#undef TRUE
88+#define TRUE 1
89+#undef FALSE
90+#define FALSE 0
91+
92+typedef std::basic_string<TCHAR> tstring;
93+
94+///--
95+
96+///-- マクロの定義
97+
98+//-- max
99+#define U32_MAX ( static_cast<u32>( -1 ) )
100+#define F32_MAX ( FLT_MAX )
101+//--
102+
103+//-- invalid
104+#define UINT_INVALID ( static_cast<UINT>( -1 ) )
105+#define U32_INVALID ( U32_MAX )
106+#define F32_INVALID ( F32_MAX )
107+
108+#define TEX_IDX_INVALID ( U32_MAX )
109+//--
110+
111+//-- smart pointer
112+#define CREATE_SPTR( _class, ... ) \
113+( boost::shared_ptr< _class >( new _class( __VA_ARGS__ ) ) )
114+
115+#define SPTR_T( _class ) boost::shared_ptr< _class >
116+//--
117+
118+//-- boost
119+#define foreach BOOST_FOREACH
120+//--
121+
122+//-- ifnot
123+#define ifnot( expr ) if( !( expr ) )
124+//--
125+
126+//-- UNUSED
127+#define UNUSED( _var ) ( (void)_var )
128+//--
129+
130+//-- ELEMENTSOF
131+#define ELEMENTSOF( _tbl ) ( sizeof( _tbl ) / sizeof( _tbl[0] ) )
132+//--
133+
134+//-- debug util
135+#ifdef _DEBUG
136+ #define DEBUG_PRINTF( str, ... ) \
137+ do{ \
138+ TCHAR sz_temp[256]; \
139+ _stprintf_s( sz_temp, str, __VA_ARGS__ ); \
140+ OutputDebugString( sz_temp ); \
141+ } while( false )
142+#else
143+ #define DEBUG_PRINTF( str, ... )
144+ //vacant
145+#endif
146+
147+#ifdef _DEBUG
148+ #define ASSERT( expr ) \
149+ if( !( expr ) ) \
150+ { \
151+ DEBUG_PRINTF( \
152+ _T( "Assertion failed! in (%d)\n" ), \
153+ __LINE__ \
154+ ); \
155+ DebugBreak(); \
156+ }
157+ #define VERIFY( expr ) do { ASSERT( expr ); } while( false )
158+ #define DEBUG_BREAK() do { ASSERT( false ); } while( false )
159+ #define STATIC_ASSERT( expr ) BOOST_STATIC_ASSERT( expr )
160+#else
161+ #define ASSERT( expr )
162+ #define VERIFY( expr ) if( expr ) {;}
163+ #define DEBUG_BREAK()
164+ #define STATIC_ASSERT( expr )
165+#endif
166+//--
167+
168+//-- FAILED
169+#define DBREAK_IF_FAILED( hr ) \
170+ do { if( FAILED( hr ) ) { DEBUG_BREAK(); } } while( false )
171+#define DBREAK_IF_SUCCEED( hr ) \
172+ do { if( SUCCEED( hr ) ) { DEBUG_BREAK(); } } while( false )
173+//--
174+
175+//-- color
176+#define COLOR_RED ( set_color_rgba( 0xff, 0x00, 0x00 ) )
177+#define COLOR_MAROON ( set_color_rgba( 0x80, 0x00, 0x00 ) )
178+#define COLOR_FUCHSIA ( set_color_rgba( 0xff, 0x00, 0xff ) )
179+#define COLOR_PURPLE ( set_color_rgba( 0x80, 0x00, 0x80 ) )
180+#define COLOR_LIME ( set_color_rgba( 0x00, 0xff, 0x00 ) )
181+#define COLOR_GREEN ( set_color_rgba( 0x00, 0x80, 0x00 ) )
182+#define COLOR_YELLOW ( set_color_rgba( 0xff, 0xff, 0x00 ) )
183+#define COLOR_OLIVE ( set_color_rgba( 0x80, 0x80, 0x00 ) )
184+#define COLOR_BLUE ( set_color_rgba( 0x00, 0x00, 0xff ) )
185+#define COLOR_NAVY ( set_color_rgba( 0x00, 0x00, 0x80 ) )
186+#define COLOR_AQUA ( set_color_rgba( 0x00, 0xff, 0xff ) )
187+#define COLOR_TEAL ( set_color_rgba( 0x00, 0x80, 0x80 ) )
188+#define COLOR_WHITE ( set_color_rgba( 0xff, 0xff, 0xff ) )
189+#define COLOR_SILVER ( set_color_rgba( 0xC0, 0xC0, 0xC0 ) )
190+#define COLOR_GRAY ( set_color_rgba( 0x80, 0x80, 0x80 ) )
191+#define COLOR_BLACK ( set_color_rgba( 0x00, 0x00, 0x00 ) )
192+
193+#define COLOR_LIGHT_YELLOW ( set_color_rgba( 255, 255, 25 ) )
194+//--
195+
196+//-- cast
197+#define SCAST static_cast
198+#define CCAST const_cast
199+#define RCAST reinterpret_cast
200+#define DCAST dynamic_cast
201+//--
202+
203+//-- time
204+extern u32 get_time();
205+//--
206+
207+//-- switch
208+#define DEFAULT_NOEFFECT default: break
209+#define DEFAULT_UNUSED default: DEBUG_BREAK(); break
210+//--
211+
212+///--
--- /dev/null
+++ b/util/src/util/pch/pch_dx.h
@@ -0,0 +1,30 @@
1+/***************************************************************************/
2+/** @file pch_dx.h
3+ @brief 共通で使用するマクロや定数の定義
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+
10+//windows
11+#include <windows.h>
12+#include <mmsystem.h>
13+
14+//エラー対処
15+#include <dxerr9.h>
16+#pragma comment( lib, "dxerr9.lib" )
17+
18+//directx
19+#include <d3d9.h>
20+#include <d3dx9.h>
21+#include <d3dx9math.h>
22+#include <d3dx9mesh.h>
23+#pragma comment( lib, "d3d9.lib" )
24+#pragma comment( lib, "d3dx9.lib" )
25+
26+#define DIRECTINPUT_VERSION 0x0800
27+#include <dinput.h>
28+#pragma comment( lib, "dxguid.lib" )
29+#pragma comment( lib, "dinput8.lib" )
30+
--- /dev/null
+++ b/util/src/util/pch/pch_gl.h
@@ -0,0 +1,16 @@
1+/***************************************************************************/
2+/** @file pch_gl.h
3+ @brief 共通で使用するマクロや定数の定義
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+#ifdef NDEBUG
10+
11+// do not open the console window
12+#pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" )
13+
14+#endif
15+
16+#include "glut/glut.h"
\ No newline at end of file
--- /dev/null
+++ b/util/src/util/pch_util.cpp
@@ -0,0 +1,9 @@
1+/***************************************************************************/
2+/** @file pch_util.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+
--- /dev/null
+++ b/util/src/util/pch_util.h
@@ -0,0 +1,25 @@
1+/***************************************************************************/
2+/** @file pch_util.h
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#ifndef __PCH_UTIL_H__
8+#define __PCH_UTIL_H__
9+
10+#ifdef DX
11+
12+#include "util/pch/pch_dx.h"
13+
14+#else //GL
15+
16+#include "util/pch/pch_gl.h"
17+
18+#endif
19+
20+#include "util/pch/pch_common.h"
21+
22+#include "util/mm/mm.h"
23+#include "util/util.h"
24+
25+#endif //__PCH_UTIL_H__
\ No newline at end of file
--- /dev/null
+++ b/util/src/util/util.cpp
@@ -0,0 +1,244 @@
1+/***************************************************************************/
2+/** @file util.cpp
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#include "pch_util.h"
8+
9+#include "util.h"
10+
11+
12+void my_memzero( void* dst, u32 size )
13+{
14+ memset( dst, 0, size );
15+}
16+
17+u32 set_color_argb( u32 a, u32 r, u32 g, u32 b )
18+{
19+ ASSERT( ( a <= 0xff ) && ( r <= 0xff ) && ( g <= 0xff ) && ( b <= 0xff ) );
20+
21+ return (
22+ ( ( (a) & 0xff ) << 24 ) |
23+ ( ( (r) & 0xff ) << 16 ) | ( ( (g) & 0xff ) << 8 ) | ( (b) & 0xff )
24+ );
25+}
26+
27+u32 set_color_rgba( u32 r, u32 g, u32 b, u32 a )
28+{
29+ return ( set_color_argb( a, r, g, b ) );
30+}
31+
32+u32 switch_color_a( u32 color, u32 a )
33+{
34+ return ( set_color_argb( a, get_color_r( color ), get_color_g( color ), get_color_b( color ) ) );
35+}
36+
37+u32 switch_color_r( u32 color, u32 r )
38+{
39+ return ( set_color_argb( get_color_a( color ), r, get_color_g( color ), get_color_b( color ) ) );
40+}
41+
42+u32 switch_color_g( u32 color, u32 g )
43+{
44+ return ( set_color_argb( get_color_a( color ), get_color_r( color ), g, get_color_b( color ) ) );
45+}
46+
47+u32 switch_color_b( u32 color, u32 b )
48+{
49+ return ( set_color_argb( get_color_a( color ), get_color_r( color ), get_color_g( color ), b ) );
50+}
51+
52+u32 add_color_a( u32 color, u32 a )
53+{
54+ return ( switch_color_a( color, mm::min_i( get_color_a( color ) + a, 0xff ) ) );
55+}
56+
57+u32 add_color_r( u32 color, u32 r )
58+{
59+ return ( switch_color_r( color, mm::min_i( get_color_a( color ) + r, 0xff ) ) );
60+}
61+
62+u32 add_color_g( u32 color, u32 g )
63+{
64+ return ( switch_color_g( color, mm::min_i( get_color_a( color ) + g, 0xff ) ) );
65+}
66+
67+u32 add_color_b( u32 color, u32 b )
68+{
69+ return ( switch_color_b( color, mm::min_i( get_color_a( color ) + b, 0xff ) ) );
70+}
71+
72+u32 sub_color_a( u32 color, u32 a )
73+{
74+ return ( switch_color_a( color, mm::max_i( static_cast<s32>( get_color_a( color ) ) - a, 0 ) ) );
75+}
76+
77+u32 sub_color_r( u32 color, u32 r )
78+{
79+ return ( switch_color_r( color, mm::max_i( static_cast<s32>( get_color_r( color ) ) - r, 0 ) ) );
80+}
81+
82+u32 sub_color_g( u32 color, u32 g )
83+{
84+ return ( switch_color_g( color, mm::max_i( static_cast<s32>( get_color_g( color ) ) - g, 0 ) ) );
85+}
86+
87+u32 sub_color_b( u32 color, u32 b )
88+{
89+ return ( switch_color_b( color, mm::max_i( static_cast<s32>( get_color_b( color ) ) - b, 0 ) ) );
90+}
91+
92+u32 get_color_a( u32 color )
93+{
94+ return ( color >> 24 );
95+}
96+
97+u32 get_color_r( u32 color )
98+{
99+ return ( ( color >> 16 ) & 0xff );
100+}
101+
102+u32 get_color_g( u32 color )
103+{
104+ return ( ( color >> 8 ) & 0xff );
105+}
106+
107+u32 get_color_b( u32 color )
108+{
109+ return ( color & 0xff );
110+}
111+
112+/***************************************************************************
113+ mm( namespace )
114+****************************************************************************/
115+
116+color_t::color_t()
117+{
118+}
119+
120+color_t::color_t( u32 in_r, u32 in_g, u32 in_b, u32 in_a )
121+{
122+ m_color = set_color_rgba( in_r, in_g, in_b, in_a );
123+}
124+
125+color_t::color_t( f32 in_r, f32 in_g, f32 in_b, f32 in_a )
126+{
127+ color_t(
128+ SCAST< u32 >( in_r * SCAST< f32 >( 0xff ) ),
129+ SCAST< u32 >( in_g * SCAST< f32 >( 0xff ) ),
130+ SCAST< u32 >( in_b * SCAST< f32 >( 0xff ) ),
131+ SCAST< u32 >( in_a * SCAST< f32 >( 0xff ) )
132+ );
133+}
134+
135+
136+void color_t::set( u32 in_r, u32 in_g, u32 in_b, u32 in_a )
137+{
138+ m_color = set_color_rgba( in_r, in_g, in_b, in_a );
139+}
140+
141+void color_t::switch_r( u32 in_r )
142+{
143+ m_color = switch_color_r( m_color, in_r );
144+}
145+
146+void color_t::switch_g( u32 in_g )
147+{
148+ m_color = switch_color_g( m_color, in_g );
149+}
150+
151+void color_t::switch_b( u32 in_b )
152+{
153+ m_color = switch_color_b( m_color, in_b );
154+}
155+
156+void color_t::switch_a( u32 in_a )
157+{
158+ m_color = switch_color_a( m_color, in_a );
159+}
160+
161+void color_t::add_r( u32 r )
162+{
163+ m_color = add_color_r( m_color, r );
164+}
165+
166+void color_t::add_g( u32 g )
167+{
168+ m_color = add_color_g( m_color, g );
169+}
170+
171+void color_t::add_b( u32 b )
172+{
173+ m_color = add_color_b( m_color, b );
174+}
175+
176+void color_t::add_a( u32 a )
177+{
178+ m_color = add_color_a( m_color, a );
179+}
180+
181+void color_t::sub_r( u32 r )
182+{
183+ m_color = sub_color_r( m_color, r );
184+}
185+
186+void color_t::sub_g( u32 g )
187+{
188+ m_color = sub_color_g( m_color, g );
189+}
190+
191+void color_t::sub_b( u32 b )
192+{
193+ m_color = sub_color_b( m_color, b );
194+}
195+
196+void color_t::sub_a( u32 a )
197+{
198+ m_color = sub_color_a( m_color, a );
199+}
200+
201+u32 color_t::get_raw() const
202+{
203+ return m_color;
204+}
205+
206+u32 color_t::get_r() const
207+{
208+ return get_color_r( m_color );
209+}
210+
211+u32 color_t::get_g() const
212+{
213+ return get_color_g( m_color );
214+}
215+
216+u32 color_t::get_b() const
217+{
218+ return get_color_b( m_color );
219+}
220+
221+u32 color_t::get_a() const
222+{
223+ return get_color_a( m_color );
224+}
225+
226+u32 get_time()
227+{
228+#ifdef DX
229+ return timeGetTime(); //ミリ秒単位
230+#else //if GL
231+ return glutGet( GLUT_ELAPSED_TIME );
232+#endif
233+}
234+
235+f32 dot_to_meter( f32 dot )
236+{
237+ return ( dot / 7.0f );
238+}
239+
240+f32 meter_to_dot( f32 meter )
241+{
242+ return ( meter * 7.0f );
243+}
244+
--- /dev/null
+++ b/util/src/util/util.h
@@ -0,0 +1,131 @@
1+/***************************************************************************/
2+/** @file util.h
3+ @brief
4+ @author shom
5+****************************************************************************/
6+
7+#pragma once
8+
9+///-- delete, Release
10+template < class T >
11+void my_safe_del( T*& p )
12+{
13+ if( p )
14+ {
15+ delete p;
16+ p = NULL;
17+ }
18+}
19+
20+template < class T >
21+void my_safe_del_array( T*& p )
22+{
23+ if( p )
24+ {
25+ delete[] p;
26+ p = NULL;
27+ }
28+}
29+
30+template < class T >
31+void my_safe_rel( T*& p )
32+{
33+ if( p )
34+ {
35+ p->Release();
36+ p = NULL;
37+ }
38+}
39+///--
40+
41+///-- "zero-set"
42+extern void my_memzero( void* dst, u32 size );
43+///--
44+
45+///-- "color"
46+extern u32 set_color_argb( u32 a, u32 r = 0xff, u32 g = 0xff, u32 b = 0xff );
47+extern u32 set_color_rgba( u32 r, u32 g, u32 b, u32 a = 0xff );
48+
49+extern u32 switch_color_a( u32 color, u32 a );
50+extern u32 switch_color_r( u32 color, u32 r );
51+extern u32 switch_color_g( u32 color, u32 g );
52+extern u32 switch_color_b( u32 color, u32 b );
53+
54+extern u32 add_color_a( u32 color, u32 a );
55+extern u32 add_color_r( u32 color, u32 r );
56+extern u32 add_color_g( u32 color, u32 g );
57+extern u32 add_color_b( u32 color, u32 b );
58+
59+extern u32 sub_color_a( u32 color, u32 a );
60+extern u32 sub_color_r( u32 color, u32 r );
61+extern u32 sub_color_g( u32 color, u32 g );
62+extern u32 sub_color_b( u32 color, u32 b );
63+
64+extern u32 get_color_a( u32 color );
65+extern u32 get_color_r( u32 color );
66+extern u32 get_color_g( u32 color );
67+extern u32 get_color_b( u32 color );
68+
69+
70+class color_t
71+{
72+public:
73+ color_t();
74+ color_t( u32 in_r, u32 in_g, u32 in_b, u32 in_a = 0xff );
75+ color_t( f32 in_r, f32 in_g, f32 in_b, f32 in_a = 1.f );
76+
77+ void set( u32 in_r, u32 in_g, u32 in_b, u32 in_a = 0xff );
78+
79+ void switch_r( u32 in_r );
80+ void switch_g( u32 in_g );
81+ void switch_b( u32 in_b );
82+ void switch_a( u32 in_a );
83+
84+ void add_r( u32 in_r );
85+ void add_g( u32 in_g );
86+ void add_b( u32 in_b );
87+ void add_a( u32 in_a );
88+
89+ void sub_r( u32 in_r );
90+ void sub_g( u32 in_g );
91+ void sub_b( u32 in_b );
92+ void sub_a( u32 in_a );
93+
94+ u32 get_raw() const;
95+ u32 get_r() const;
96+ u32 get_g() const;
97+ u32 get_b() const;
98+ u32 get_a() const;
99+
100+private:
101+ u32 m_color;
102+};
103+///--
104+
105+///-- "time"
106+extern u32 get_time();
107+///--
108+
109+///-- "convert unit"
110+extern f32 dot_to_meter( f32 dot );
111+extern f32 meter_to_dot( f32 meter );
112+///--
113+
114+///-- "enum definition"
115+//need to define ENUM_KIND
116+
117+#define DEF_ENUM_BEGIN() \
118+ \
119+enum BOOST_PP_CAT( e, ENUM_KIND ) \
120+{
121+
122+#define DEF_ENUM( _name ) \
123+ \
124+ BOOST_PP_CAT( e, ENUM_KIND )##_##_name##,
125+
126+#define DEF_ENUM_END() \
127+ \
128+ BOOST_PP_CAT( eNof_, ENUM_KIND ), \
129+ BOOST_PP_CAT( e, ENUM_KIND )##_Invalid = U32_INVALID, \
130+};
131+///--
--- /dev/null
+++ b/util/util.sln
@@ -0,0 +1,20 @@
1+
2+Microsoft Visual Studio Solution File, Format Version 11.00
3+# Visual C++ Express 2010
4+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util_dx", "project\util_dx\util_dx.vcxproj", "{232B4361-3E5A-4334-9A18-5FE5A1048791}"
5+EndProject
6+Global
7+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+ Debug|Win32 = Debug|Win32
9+ Release|Win32 = Release|Win32
10+ EndGlobalSection
11+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+ {232B4361-3E5A-4334-9A18-5FE5A1048791}.Debug|Win32.ActiveCfg = Debug|Win32
13+ {232B4361-3E5A-4334-9A18-5FE5A1048791}.Debug|Win32.Build.0 = Debug|Win32
14+ {232B4361-3E5A-4334-9A18-5FE5A1048791}.Release|Win32.ActiveCfg = Release|Win32
15+ {232B4361-3E5A-4334-9A18-5FE5A1048791}.Release|Win32.Build.0 = Release|Win32
16+ EndGlobalSection
17+ GlobalSection(SolutionProperties) = preSolution
18+ HideSolutionNode = FALSE
19+ EndGlobalSection
20+EndGlobal