Add PhysicsEffects to Extras. The build is only tested on Windows and Android.

The Android/NEON optimized version of Physics Effects is thanks to Graham Rhodes and Anthony Hamilton, See Issue 587
This commit is contained in:
erwin.coumans
2012-03-05 04:59:58 +00:00
parent 6cf8dfc202
commit a93a661b94
462 changed files with 86626 additions and 0 deletions

View File

@@ -0,0 +1,280 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="99_BulletPhysicsEffects"
ProjectGUID="{74D8E3A1-33A5-49FB-B822-FA4EA49C66E8}"
RootNamespace="My99_BulletPhysicsEffects"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../include"
PreprocessorDefinitions="PFX_USE_FREE_VECTORMATH;WIN32;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib "
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;../../../lib/Win32 Debug&quot;"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../../../include"
PreprocessorDefinitions="PFX_USE_FREE_VECTORMATH;WIN32;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;../../../lib/Win32 Release&quot;"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btBulletPhysicsEffectsWorld.cpp"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelBroadphase.cpp"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelCollisionDispatcher.cpp"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelConstraintSolver.cpp"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelConstraintSolver2.cpp"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelData.cpp"
>
</File>
<File
RelativePath=".\bullet_physics_func.cpp"
>
</File>
<File
RelativePath="..\common\ctrl_func.win32.cpp"
>
</File>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath="..\common\perf_func.win32.cpp"
>
</File>
<File
RelativePath="..\common\render_func.win32.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\barrel.h"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btBulletPhysicsEffectsWorld.h"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btlowlevelbroadphase.h"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelCollisionDispatcher.h"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelConstraintSolver.h"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelConstraintSolver2.h"
>
</File>
<File
RelativePath="..\..\..\include\BulletPhysicsEffects\btLowLevelData.h"
>
</File>
<File
RelativePath=".\landscape.h"
>
</File>
<File
RelativePath=".\physics_func.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
<File
RelativePath=".\ReadMe.txt"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,89 @@
cmake_minimum_required(VERSION 2.4)
#this line has to appear before 'PROJECT' in order to be able to disable incremental linking
SET(MSVC_INCREMENTAL_DEFAULT ON)
PROJECT(App_99_BulletPhysicsEffects)
IF (NOT CMAKE_BUILD_TYPE)
# SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_BUILD_TYPE "Release")
ENDIF (NOT CMAKE_BUILD_TYPE)
OPTION(USE_MSVC_RUNTIME_LIBRARY_DLL "Use MSVC Runtime Library DLL (/MD or /MDd)" ON)
OPTION(USE_MSVC_INCREMENTAL_LINKING "Use MSVC Incremental Linking" OFF)
IF(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
SET(App_99_BulletPhysicsEffects_SRCS
main.cpp
bullet_physics_func.cpp
../common/ctrl_func.win32.cpp
../common/perf_func.win32.cpp
../common/render_func.win32.cpp
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.cpp
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.cpp
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.cpp
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelBroadphase.cpp
)
SET(App_99_BulletPhysicsEffects_HDRS
physics_func.h
landscape.h
barrel.h
../common/render_func.h
../common/common.h
../common/ctrl_func.h
../common/perf_func.h
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btBulletPhysicsEffectsWorld.h
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelConstraintSolver2.h
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelCollisionDispatcher.h
${PHYSICS_EFFECTS_SOURCE_DIR}/include/BulletPhysicsEffects/btLowLevelBroadphase.h
)
INCLUDE_DIRECTORIES(
../../../../../src
# ${VECTOR_MATH_INCLUDE}
)
#LINK_DIRECTORIES(
#
#)
#ADD_DEFINITIONS(-DUNICODE)
#ADD_DEFINITIONS(-D_UNICODE)
ADD_EXECUTABLE(App_99_BulletPhysicsEffects WIN32
${App_99_BulletPhysicsEffects_SRCS}
${App_99_BulletPhysicsEffects_HDRS}
)
TARGET_LINK_LIBRARIES(App_99_BulletPhysicsEffects
PfxBaseLevel
PfxLowLevel
PfxUtil
BulletDynamics
BulletCollision
LinearMath
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(App_99_BulletPhysicsEffects PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(App_99_BulletPhysicsEffects PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(App_99_BulletPhysicsEffects PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF()

View File

@@ -0,0 +1,202 @@
/*
Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc.
All rights reserved.
Physics Effects is open software; you can redistribute it and/or
modify it under the terms of the BSD License.
Physics Effects is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the BSD License for more details.
A copy of the BSD License is distributed with
Physics Effects under the filename: physics_effects_license.txt
*/
#define BarrelVtxCount 57
#define BarrelIdxCount 180
static float BarrelVtx[] = {
0.0f,-0.5f,0.0f, 0.0f,-1.0f,0.0f,
0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f,
0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f,
0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f,
-0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f,
0.107853f,-0.5f,-0.331936f, 0.0f,-1.0f,0.0f,
-0.282362f,-0.5f,-0.205148f, 0.0f,-1.0f,0.0f,
-0.349018f,-0.5f,0.0f, 0.0f,-1.0f,0.0f,
-0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f,
-0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f,
0.107853f,-0.5f,0.331936f, 0.0f,-1.0f,0.0f,
0.282362f,-0.5f,0.205148f, 0.0f,-1.0f,0.0f,
0.0f,0.5f,0.0f, 0.0f,1.0f,0.0f,
0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f,
0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f,
0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f,
0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f,
-0.107853f,0.5f,-0.331936f, 0.0f,1.0f,0.0f,
-0.282362f,0.5f,-0.205148f, 0.0f,1.0f,0.0f,
-0.349018f,0.5f,0.0f, 0.0f,1.0f,0.0f,
-0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f,
-0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f,
0.107853f,0.5f,0.331936f, 0.0f,1.0f,0.0f,
0.282362f,0.5f,0.205148f, 0.0f,1.0f,0.0f,
0.349018f,-0.5f,0.0f, 0.957307f,-0.289072f,0.0f,
0.404509f,0.0f,-0.293893f, 0.809017f,0.0f,-0.587785f,
0.5f,0.0f,0.0f, 1.0f,0.0f,0.0f,
0.282362f,-0.5f,-0.205148f, 0.774478f,-0.289072f,-0.562691f,
0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f,
0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f,
0.107853f,-0.5f,-0.331936f, 0.295824f,-0.289072f,-0.910453f,
-0.154509f,0.0f,-0.475528f, -0.309017f,0.0f,-0.951057f,
0.154508f,0.0f,-0.475528f, 0.309017f,0.0f,-0.951057f,
-0.107853f,-0.5f,-0.331936f, -0.295824f,-0.289072f,-0.910453f,
-0.404509f,0.0f,-0.293893f, -0.809017f,0.0f,-0.587785f,
-0.282362f,-0.5f,-0.205148f, -0.774478f,-0.289072f,-0.562691f,
-0.5f,0.0f,0.0f, -1.0f,0.0f,0.0f,
-0.349018f,-0.5f,0.0f, -0.957307f,-0.289072f,0.0f,
-0.404508f,0.0f,0.293893f, -0.809017f,0.0f,0.587785f,
-0.282362f,-0.5f,0.205148f, -0.774478f,-0.289072f,0.562691f,
-0.154509f,0.0f,0.475528f, -0.309017f,0.0f,0.951056f,
-0.107853f,-0.5f,0.331936f, -0.295824f,-0.289072f,0.910453f,
0.154509f,0.0f,0.475528f, 0.309017f,0.0f,0.951056f,
0.107853f,-0.5f,0.331936f, 0.295824f,-0.289072f,0.910453f,
0.404509f,0.0f,0.293892f, 0.809017f,0.0f,0.587785f,
0.282362f,-0.5f,0.205148f, 0.774478f,-0.289072f,0.562691f,
0.282362f,0.5f,-0.205148f, 0.774478f,0.289072f,-0.562691f,
0.349018f,0.5f,0.0f, 0.957307f,0.289072f,0.0f,
0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f,
-0.107853f,0.5f,-0.331936f, -0.295824f,0.289072f,-0.910453f,
0.107853f,0.5f,-0.331936f, 0.295824f,0.289072f,-0.910453f,
-0.282362f,0.5f,-0.205148f, -0.774478f,0.289072f,-0.562691f,
-0.349018f,0.5f,0.0f, -0.957307f,0.289072f,0.0f,
-0.282362f,0.5f,0.205148f, -0.774478f,0.289072f,0.562691f,
-0.107853f,0.5f,0.331936f, -0.295824f,0.289072f,0.910453f,
0.107853f,0.5f,0.331936f, 0.295824f,0.289072f,0.910453f,
0.282362f,0.5f,0.205148f, 0.774478f,0.289072f,0.562691f,
};
static float BarrelTex[] = {
0.0f,0.5f,
0.0f,0.85f,
0.0f,0.75f,
0.0f,0.95f,
0.0f,0.05f,
0.0f,-0.05f,
0.0f,0.15f,
0.0f,0.25f,
0.0f,0.35f,
0.0f,0.45f,
0.0f,0.55f,
0.0f,0.65f,
1.0f,0.5f,
1.0f,0.75f,
1.0f,0.85f,
1.0f,0.95f,
1.0f,-0.05f,
1.0f,0.05f,
1.0f,0.15f,
1.0f,0.25f,
1.0f,0.35f,
1.0f,0.45f,
1.0f,0.55f,
1.0f,0.65f,
0.0f,0.75f,
0.5f,0.85f,
0.5f,0.75f,
0.0f,0.85f,
0.5f,0.95f,
0.0f,0.95f,
0.0f,-0.05f,
0.5f,0.05f,
0.5f,-0.05f,
0.0f,0.05f,
0.5f,0.15f,
0.0f,0.15f,
0.5f,0.25f,
0.0f,0.25f,
0.5f,0.35f,
0.0f,0.35f,
0.5f,0.45f,
0.0f,0.45f,
0.5f,0.55f,
0.0f,0.55f,
0.5f,0.65f,
0.0f,0.65f,
1.0f,0.85f,
1.0f,0.75f,
1.0f,0.95f,
1.0f,0.05f,
1.0f,-0.05f,
1.0f,0.15f,
1.0f,0.25f,
1.0f,0.35f,
1.0f,0.45f,
1.0f,0.55f,
1.0f,0.65f,
};
static unsigned short BarrelIdx[] = {
0,1,2,
0,3,1,
0,4,5,
0,6,4,
0,7,6,
0,8,7,
0,9,8,
0,10,9,
0,11,10,
0,2,11,
12,13,14,
12,14,15,
12,16,17,
12,17,18,
12,18,19,
12,19,20,
12,20,21,
12,21,22,
12,22,23,
12,23,13,
24,25,26,
24,27,25,
27,28,25,
27,29,28,
30,31,32,
30,33,31,
33,34,31,
33,35,34,
35,36,34,
35,37,36,
37,38,36,
37,39,38,
39,40,38,
39,41,40,
41,42,40,
41,43,42,
43,44,42,
43,45,44,
45,26,44,
45,24,26,
26,46,47,
26,25,46,
25,48,46,
25,28,48,
32,49,50,
32,31,49,
31,51,49,
31,34,51,
34,52,51,
34,36,52,
36,53,52,
36,38,53,
38,54,53,
38,40,54,
40,55,54,
40,42,55,
42,56,55,
42,44,56,
44,47,56,
44,26,47,
};

View File

@@ -0,0 +1,318 @@
/*
Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc.
All rights reserved.
Physics Effects is open software; you can redistribute it and/or
modify it under the terms of the BSD License.
Physics Effects is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the BSD License for more details.
A copy of the BSD License is distributed with
Physics Effects under the filename: physics_effects_license.txt
*/
#define LargeMeshVtxCount 81
#define LargeMeshIdxCount 384
static float LargeMeshVtx[] = {
-25.0f,-2.19407f,18.5625f, 0.232976f,0.967754f,0.0957829f,
-25.0f,0.0644502f,24.75f, 0.188094f,0.871343f,-0.45319f,
-18.75f,-4.50287f,18.5625f, -0.0716098f,0.995449f,0.0628767f,
-18.75f,-0.39999f,24.75f, -0.0602794f,0.895848f,-0.440253f,
-12.5f,-1.2166f,18.5625f, -0.269469f,0.961403f,0.0555879f,
-12.5f,-0.942431f,24.75f, -0.0997841f,0.993258f,0.0589987f,
-6.25f,1.93598f,18.5625f, -0.283933f,0.956351f,-0.0691025f,
-6.25f,-0.445954f,24.75f, -0.180725f,0.942766f,0.280233f,
0.0f,2.76983f,18.5625f, 0.171645f,0.984908f,0.0222501f,
0.0f,2.76642f,24.75f, 0.0784993f,0.995428f,-0.0544117f,
6.25f,-2.53736f,18.5625f, 0.248298f,0.965028f,0.0840741f,
6.25f,-0.915645f,24.75f, 0.164311f,0.945856f,-0.279926f,
12.5f,-1.60054f,18.5625f, -0.180435f,0.983586f,0.00115547f,
12.5f,0.831925f,24.75f, -0.0692495f,0.964821f,-0.253623f,
18.75f,-0.800282f,18.5625f, 0.10755f,0.951538f,0.288112f,
18.75f,-1.47284f,24.75f, 0.232178f,0.972664f,0.00429361f,
25.0f,-2.78379f,18.5625f, 0.1833f,0.937477f,0.295867f,
25.0f,-0.967508f,24.75f, -0.0773477f,0.956641f,-0.280812f,
-25.0f,-0.352038f,12.375f, -0.192222f,0.972435f,0.131987f,
-18.75f,0.681228f,12.375f, -0.107779f,0.962569f,0.248686f,
-12.5f,2.72065f,12.375f, 0.0520846f,0.993034f,0.105692f,
-6.25f,-1.78776f,12.375f, -0.0133223f,0.99674f,-0.0795754f,
0.0f,1.57707f,12.375f, -0.129025f,0.969662f,-0.207627f,
6.25f,0.424356f,12.375f, 0.180995f,0.97074f,0.157815f,
12.5f,0.283234f,12.375f, -0.16285f,0.973539f,0.160316f,
18.75f,2.57015f,12.375f, -0.165454f,0.978339f,0.124408f,
25.0f,3.07363f,12.375f, -0.00454559f,0.988151f,0.153417f,
-25.0f,-0.893751f,6.1875f, -0.0836251f,0.990084f,-0.112876f,
-18.75f,0.930932f,6.1875f, 0.00269413f,0.971838f,-0.235633f,
-12.5f,-0.684529f,6.1875f, -0.010319f,0.927048f,-0.3748f,
-6.25f,-0.661383f,6.1875f, 0.012265f,0.999875f,-0.00994222f,
0.0f,0.385718f,6.1875f, -0.15435f,0.984937f,-0.0779465f,
6.25f,0.589796f,6.1875f, 0.0241717f,0.999582f,-0.0158589f,
12.5f,0.47454f,6.1875f, -0.017184f,0.997953f,-0.0616073f,
18.75f,1.59939f,6.1875f, -0.0902706f,0.957309f,-0.274609f,
25.0f,1.13434f,6.1875f, 0.0346006f,0.957441f,-0.286547f,
-25.0f,0.74548f,0.0f, 0.329903f,0.930812f,0.157334f,
-18.75f,-2.47437f,0.0f, 0.247844f,0.968142f,0.0357041f,
-12.5f,-4.16309f,1.81975e-007f, -0.0623898f,0.997626f,-0.0291436f,
-6.25f,-0.700022f,0.0f, -0.217067f,0.974987f,-0.0477624f,
0.0f,-0.0957388f,0.0f, -0.117693f,0.990712f,-0.068098f,
6.25f,0.614077f,0.0f, -0.0713214f,0.997305f,0.01722f,
12.5f,0.299109f,0.0f, 0.218606f,0.968641f,0.118094f,
18.75f,-1.71753f,0.0f, 0.0339493f,0.985612f,-0.165579f,
25.0f,-1.12638f,0.0f, -0.0547573f,0.989177f,-0.136126f,
-25.0f,-0.403319f,-6.1875f, -0.1263f,0.989211f,-0.074223f,
-18.75f,-0.0730335f,-6.1875f, 0.0173428f,0.965382f,0.260261f,
-12.5f,-0.450125f,-6.1875f, 0.0658811f,0.875f,0.479619f,
-6.25f,-0.180204f,-6.1875f, 0.0116584f,0.981445f,0.19139f,
0.0f,-0.632679f,-6.1875f, -0.0557983f,0.993041f,-0.103716f,
6.25f,0.308409f,-6.1875f, -0.191898f,0.96766f,-0.163737f,
12.5f,2.5011f,-6.1875f, 0.0758397f,0.996403f,-0.0378189f,
18.75f,-1.69303f,-6.1875f, 0.16761f,0.974057f,0.15205f,
25.0f,-0.141349f,-6.1875f, -0.204846f,0.978471f,0.0251341f,
-25.0f,-1.10316f,-12.375f, -0.0350644f,0.993748f,-0.106001f,
-18.75f,1.06711f,-12.375f, -0.309806f,0.919244f,-0.242922f,
-12.5f,3.61544f,-12.375f, -0.0506281f,0.998702f,-0.00561657f,
-6.25f,1.6504f,-12.375f, 0.322294f,0.937465f,0.131477f,
0.0f,-1.60595f,-12.375f, 0.086016f,0.995916f,0.0274459f,
6.25f,-0.849859f,-12.375f, -0.0332811f,0.997087f,0.0686255f,
12.5f,-0.942201f,-12.375f, -0.153559f,0.982185f,-0.108312f,
18.75f,0.494873f,-12.375f, 0.0753195f,0.981472f,0.176181f,
25.0f,-0.333828f,-12.375f, 0.035057f,0.987194f,0.155624f,
-25.0f,2.1862f,-18.5625f, 0.612899f,0.782306f,0.111138f,
-18.75f,-3.38259f,-18.5625f, 0.0194078f,0.992789f,-0.118297f,
-12.5f,-0.880916f,-18.5625f, -0.282251f,0.949875f,-0.13443f,
-6.25f,0.818158f,-18.5625f, 0.1476f,0.981788f,-0.119612f,
0.0f,-1.48019f,-18.5625f, -0.044551f,0.996013f,-0.0772824f,
6.25f,1.47123f,-18.5625f, -0.117036f,0.97986f,0.161792f,
12.5f,0.164076f,-18.5625f, -0.0340355f,0.978993f,0.201034f,
18.75f,2.14568f,-18.5625f, -0.0439269f,0.994859f,0.0912435f,
25.0f,0.626506f,-18.5625f, 0.208015f,0.968592f,0.136229f,
-25.0f,0.296889f,-24.75f, 0.46973f,0.844327f,-0.257809f,
-18.75f,-3.18022f,-24.75f, -0.0226758f,0.998794f,-0.0435401f,
-12.5f,1.8927f,-24.75f, -0.202772f,0.919836f,0.335836f,
-6.25f,1.46387f,-24.75f, 0.224904f,0.955746f,0.189652f,
0.0f,-2.52726f,-24.75f, -0.0435882f,0.993572f,-0.10447f,
6.25f,1.30397f,-24.75f, -0.28646f,0.956525f,-0.0547707f,
12.5f,1.85812f,-24.75f, 0.0521949f,0.979796f,0.193067f,
18.75f,1.56331f,-24.75f, -0.0270784f,0.999629f,-0.00293115f,
25.0f,1.05366f,-24.75f, 0.161f,0.986887f,-0.0115473f,
};
static float LargeMeshTex[] = {
0.125f,0.0f,
0.0f,0.0f,
0.125f,0.125f,
0.0f,0.125f,
0.125f,0.25f,
0.0f,0.25f,
0.125f,0.375f,
0.0f,0.375f,
0.125f,0.5f,
0.0f,0.5f,
0.125f,0.625f,
0.0f,0.625f,
0.125f,0.75f,
0.0f,0.75f,
0.125f,0.875f,
0.0f,0.875f,
0.125f,1.0f,
0.0f,1.0f,
0.25f,0.0f,
0.25f,0.125f,
0.25f,0.25f,
0.25f,0.375f,
0.25f,0.5f,
0.25f,0.625f,
0.25f,0.75f,
0.25f,0.875f,
0.25f,1.0f,
0.375f,0.0f,
0.375f,0.125f,
0.375f,0.25f,
0.375f,0.375f,
0.375f,0.5f,
0.375f,0.625f,
0.375f,0.75f,
0.375f,0.875f,
0.375f,1.0f,
0.5f,0.0f,
0.5f,0.125f,
0.5f,0.25f,
0.5f,0.375f,
0.5f,0.5f,
0.5f,0.625f,
0.5f,0.75f,
0.5f,0.875f,
0.5f,1.0f,
0.625f,0.0f,
0.625f,0.125f,
0.625f,0.25f,
0.625f,0.375f,
0.625f,0.5f,
0.625f,0.625f,
0.625f,0.75f,
0.625f,0.875f,
0.625f,1.0f,
0.75f,0.0f,
0.75f,0.125f,
0.75f,0.25f,
0.75f,0.375f,
0.75f,0.5f,
0.75f,0.625f,
0.75f,0.75f,
0.75f,0.875f,
0.75f,1.0f,
0.875f,0.0f,
0.875f,0.125f,
0.875f,0.25f,
0.875f,0.375f,
0.875f,0.5f,
0.875f,0.625f,
0.875f,0.75f,
0.875f,0.875f,
0.875f,1.0f,
1.0f,0.0f,
1.0f,0.125f,
1.0f,0.25f,
1.0f,0.375f,
1.0f,0.5f,
1.0f,0.625f,
1.0f,0.75f,
1.0f,0.875f,
1.0f,1.0f,
};
static unsigned short LargeMeshIdx[] = {
0,1,2,
3,2,1,
2,3,4,
5,4,3,
4,5,6,
7,6,5,
6,7,8,
9,8,7,
8,9,10,
11,10,9,
10,11,12,
13,12,11,
12,13,14,
15,14,13,
14,15,16,
17,16,15,
18,0,19,
2,19,0,
19,2,20,
4,20,2,
20,4,21,
6,21,4,
21,6,22,
8,22,6,
22,8,23,
10,23,8,
23,10,24,
12,24,10,
24,12,25,
14,25,12,
25,14,26,
16,26,14,
27,18,28,
19,28,18,
28,19,29,
20,29,19,
29,20,30,
21,30,20,
30,21,31,
22,31,21,
31,22,32,
23,32,22,
32,23,33,
24,33,23,
33,24,34,
25,34,24,
34,25,35,
26,35,25,
36,27,37,
28,37,27,
37,28,38,
29,38,28,
38,29,39,
30,39,29,
39,30,40,
31,40,30,
40,31,41,
32,41,31,
41,32,42,
33,42,32,
42,33,43,
34,43,33,
43,34,44,
35,44,34,
45,36,46,
37,46,36,
46,37,47,
38,47,37,
47,38,48,
39,48,38,
48,39,49,
40,49,39,
49,40,50,
41,50,40,
50,41,51,
42,51,41,
51,42,52,
43,52,42,
52,43,53,
44,53,43,
54,45,55,
46,55,45,
55,46,56,
47,56,46,
56,47,57,
48,57,47,
57,48,58,
49,58,48,
58,49,59,
50,59,49,
59,50,60,
51,60,50,
60,51,61,
52,61,51,
61,52,62,
53,62,52,
63,54,64,
55,64,54,
64,55,65,
56,65,55,
65,56,66,
57,66,56,
66,57,67,
58,67,57,
67,58,68,
59,68,58,
68,59,69,
60,69,59,
69,60,70,
61,70,60,
70,61,71,
62,71,61,
72,63,73,
64,73,63,
73,64,74,
65,74,64,
74,65,75,
66,75,65,
75,66,76,
67,76,66,
76,67,77,
68,77,67,
77,68,78,
69,78,68,
78,69,79,
70,79,69,
79,70,80,
71,80,70,
};

View File

@@ -0,0 +1,485 @@
/*
Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc.
All rights reserved.
Physics Effects is open software; you can redistribute it and/or
modify it under the terms of the BSD License.
Physics Effects is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the BSD License for more details.
A copy of the BSD License is distributed with
Physics Effects under the filename: physics_effects_license.txt
*/
#include "btBulletDynamicsCommon.h"
#include "../common/common.h"
#include "../common/ctrl_func.h"
#include "../common/render_func.h"
#include "../common/perf_func.h"
#include "physics_func.h"
#include "barrel.h"
#include "landscape.h"
#ifdef WIN32
#include <gl/gl.h>
#include <gl/glu.h>
#endif
#define SAMPLE_NAME "api_physics_effects/1_simple"
static bool s_isRunning = true;
int sceneId = 2;
bool simulating = false;
int landscapeMeshId;
int convexMeshId;
/*
kPfxShapeSphere = 0,
kPfxShapeBox,
kPfxShapeCapsule,
kPfxShapeCylinder,
kPfxShapeConvexMesh,
kPfxShapeLargeTriMesh,
kPfxShapeReserved0,
kPfxShapeReserved1,
kPfxShapeReserved2,
kPfxShapeUser0,
kPfxShapeUser1,
kPfxShapeUser2,
kPfxShapeCount // =12
*/
extern void debugRenderPhysics();
static void render(void)
{
render_begin();
for(int i=0;i<physics_get_num_rigidbodies();i++) {
const PfxRigidState &state = physics_get_state(i);
const PfxCollidable &coll = physics_get_collidable(i);
PfxTransform3 rbT(state.getOrientation(), state.getPosition());
PfxShapeIterator itrShape(coll);
for(int j=0;j<coll.getNumShapes();j++,++itrShape) {
const PfxShape &shape = *itrShape;
PfxTransform3 offsetT = shape.getOffsetTransform();
PfxTransform3 worldT = rbT * offsetT;
switch(shape.getType()) {
case kPfxShapeSphere:
render_sphere(
worldT,
Vectormath::Aos::Vector3(1,1,1),
Vectormath::floatInVec(shape.getSphere().m_radius));
break;
case kPfxShapeBox:
render_box(
worldT,
Vectormath::Aos::Vector3(1,1,1),
shape.getBox().m_half);
break;
case kPfxShapeCapsule:
render_capsule(
worldT,
Vectormath::Aos::Vector3(1,1,1),
Vectormath::floatInVec(shape.getCapsule().m_radius),
Vectormath::floatInVec(shape.getCapsule().m_halfLen));
break;
case kPfxShapeCylinder:
render_cylinder(
worldT,
Vectormath::Aos::Vector3(1,1,1),
Vectormath::floatInVec(shape.getCylinder().m_radius),
Vectormath::floatInVec(shape.getCylinder().m_halfLen));
break;
case kPfxShapeConvexMesh:
render_mesh(
worldT,
Vectormath::Aos::Vector3(1,1,1),
convexMeshId);
break;
case kPfxShapeLargeTriMesh:
render_mesh(
worldT,
Vectormath::Aos::Vector3(1,1,1),
landscapeMeshId);
break;
default:
break;
}
}
}
debugRenderPhysics();
render_end();
}
static int init(void)
{
perf_init();
ctrl_init();
render_init();
physics_init();
landscapeMeshId = render_init_mesh(
LargeMeshVtx,sizeof(float)*6,
LargeMeshVtx+3,sizeof(float)*6,
LargeMeshIdx,sizeof(unsigned short)*3,
LargeMeshVtxCount,LargeMeshIdxCount/3);
convexMeshId = render_init_mesh(
BarrelVtx,sizeof(float)*6,
BarrelVtx+3,sizeof(float)*6,
BarrelIdx,sizeof(unsigned short)*3,
BarrelVtxCount,BarrelIdxCount/3);
return 0;
}
static int shutdown(void)
{
ctrl_release();
render_release();
physics_release();
perf_release();
return 0;
}
static void update(void)
{
static btClock clock;
static bool first = true;
btScalar dt=1.f;
if (first)
{
first=false;
clock.reset();
} else
{
dt = (btScalar)clock.getTimeMicroseconds()/100000.f;
clock.reset();
}
float angX,angY,r=1.f;
render_get_view_angle(angX,angY,r);
ctrl_update();
if(ctrl_button_pressed(BTN_UP)) {
angX -= 0.05f*dt;
if(angX < -1.4f) angX = -1.4f;
if(angX > -0.01f) angX = -0.01f;
}
if(ctrl_button_pressed(BTN_DOWN)) {
angX += 0.05f*dt;
if(angX < -1.4f) angX = -1.4f;
if(angX > -0.01f) angX = -0.01f;
}
if(ctrl_button_pressed(BTN_LEFT)) {
angY -= 0.05f*dt;
}
if(ctrl_button_pressed(BTN_RIGHT)) {
angY += 0.05f*dt;
}
if(ctrl_button_pressed(BTN_ZOOM_OUT)) {
r *= (1.f+0.2*dt);
if(r > 500.0f) r = 500.0f;
}
if(ctrl_button_pressed(BTN_ZOOM_IN)) {
r *= (1.f-0.2*dt);
if(r < 1.0f) r = 1.0f;
}
if(ctrl_button_pressed(BTN_SCENE_RESET) == BTN_STAT_DOWN) {
physics_create_scene(sceneId);
}
if(ctrl_button_pressed(BTN_SCENE_NEXT) == BTN_STAT_DOWN) {
physics_create_scene(++sceneId);
}
if(ctrl_button_pressed(BTN_SIMULATION) == BTN_STAT_DOWN) {
simulating = !simulating;
}
if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_DOWN) {
simulating = true;
}
else if(ctrl_button_pressed(BTN_STEP) == BTN_STAT_UP || ctrl_button_pressed(BTN_STEP) == BTN_STAT_KEEP) {
simulating = false;
}
render_set_view_angle(angX,angY,r);
}
#ifndef WIN32
///////////////////////////////////////////////////////////////////////////////
// Main
int main(void)
{
init();
physics_create_scene(sceneId);
printf("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME);
while (s_isRunning) {
update();
if(simulating) physics_simulate();
render();
perf_sync();
}
shutdown();
printf("## %s: FINISHED ##\n", SAMPLE_NAME);
return 0;
}
#else
#include <stdio.h>
#include <setjmp.h>
static jmp_buf buf;
void second(void) {
printf("second\n"); // prints
longjmp(buf,1); // jumps back to where setjmp was called - making setjmp now return 1
}
void first(void) {
second();
printf("first\n"); // does not print
}
int main2() {
if ( ! setjmp(buf) ) {
first(); // when executed, setjmp returns 0
} else { // when longjmp jumps back, setjmp returns 1
printf("main\n"); // prints
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
// WinMain
extern HDC hDC;
extern HGLRC hRC;
HWND hWnd;
HINSTANCE hInstance;
void releaseWindow()
{
if(hRC) {
wglMakeCurrent(0,0);
wglDeleteContext(hRC);
}
if(hDC) ReleaseDC(hWnd,hDC);
if(hWnd) DestroyWindow(hWnd);
UnregisterClass(SAMPLE_NAME,hInstance);
}
LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg) {
case WM_SYSCOMMAND:
{
switch (wParam) {
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return 0;
}
break;
}
case WM_CLOSE:
PostQuitMessage(0);
return 0;
case WM_SIZE:
render_resize(LOWORD(lParam),HIWORD(lParam));
return 0;
}
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
bool createWindow(char* title, int width, int height)
{
WNDCLASS wc;
RECT rect;
rect.left=0;
rect.right=width;
rect.top=0;
rect.bottom=height;
hInstance = GetModuleHandle(NULL);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = SAMPLE_NAME;
if(!RegisterClass(&wc)) {
return false;
}
AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | WS_EX_WINDOWEDGE);
if(!(hWnd=CreateWindowEx(WS_EX_APPWINDOW|WS_EX_WINDOWEDGE,SAMPLE_NAME,title,
WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,
0,0,rect.right-rect.left,rect.bottom-rect.top,
NULL,NULL,hInstance,NULL))) {
releaseWindow();
return false;
}
static PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR),
1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
32,
0, 0,
0, 0,
0, 0,
0, 0,
0,
0, 0, 0, 0,
32,
0,
0,
PFD_MAIN_PLANE,
0,
0, 0, 0
};
if(!(hDC=GetDC(hWnd)))
{
releaseWindow();
OutputDebugString("");
return FALSE;
}
int pixelformat;
if ( (pixelformat = ChoosePixelFormat(hDC, &pfd)) == 0 ){
OutputDebugString("ChoosePixelFormat Failed....");
return FALSE;
}
if (SetPixelFormat(hDC, pixelformat, &pfd) == FALSE){
OutputDebugString("SetPixelFormat Failed....");
return FALSE;
}
if (!(hRC=wglCreateContext(hDC))){
OutputDebugString("Creating HGLRC Failed....");
return FALSE;
}
// Set Vsync
//BOOL (WINAPI *wglSwapIntervalEXT)(int) = NULL;
//if(strstr((char*)glGetString( GL_EXTENSIONS ),"WGL_EXT_swap_control")== 0) {
//}
//else {
//wglSwapIntervalEXT = (BOOL (WINAPI*)(int))wglGetProcAddress("wglSwapIntervalEXT");
//if(wglSwapIntervalEXT) wglSwapIntervalEXT(1);
//}
wglMakeCurrent(hDC,hRC);
ShowWindow(hWnd,SW_SHOW);
SetForegroundWindow(hWnd);
SetFocus(hWnd);
render_resize(width, height);
glClearColor(0.0f,0.0f,0.0f,0.0f);
glClearDepth(1.0f);
return TRUE;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
main2();
if(!createWindow(SAMPLE_NAME,DISPLAY_WIDTH,DISPLAY_HEIGHT)) {
MessageBox(NULL,"Can't create gl window.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return 0;
}
init();
physics_create_scene(sceneId);
SCE_PFX_PRINTF("## %s: INIT SUCCEEDED ##\n", SAMPLE_NAME);
MSG msg;
while(s_isRunning) {
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
if(msg.message==WM_QUIT) {
s_isRunning = false;
}
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else {
update();
if(simulating) physics_simulate();
render();
perf_sync();
}
}
shutdown();
SCE_PFX_PRINTF("## %s: FINISHED ##\n", SAMPLE_NAME);
releaseWindow();
return (msg.wParam);
}
#endif

View File

@@ -0,0 +1,49 @@
/*
Physics Effects Copyright(C) 2011 Sony Computer Entertainment Inc.
All rights reserved.
Physics Effects is open software; you can redistribute it and/or
modify it under the terms of the BSD License.
Physics Effects is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the BSD License for more details.
A copy of the BSD License is distributed with
Physics Effects under the filename: physics_effects_license.txt
*/
#ifndef __PHYSICS_FUNC_H__
#define __PHYSICS_FUNC_H__
#define SCE_PFX_USE_PERFCOUNTER
#include "physics_effects.h"
using namespace sce::PhysicsEffects;
//E Simulation
//J シミュレーション
bool physics_init();
void physics_release();
void physics_create_scene(int sceneId);
void physics_simulate();
//E Picking
//J ピッキング
PfxVector3 physics_pick_start(const PfxVector3 &p1,const PfxVector3 &p2);
void physics_pick_update(const PfxVector3 &p);
void physics_pick_end();
//E Change parameters
//J パラメータの取得
int physics_get_num_rigidbodies();
const PfxRigidState& physics_get_state(int id);
const PfxRigidBody& physics_get_body(int id);
const PfxCollidable& physics_get_collidable(int id);
int physics_get_num_contacts();
const PfxContactManifold &physics_get_contact(int id);
#endif /* __PHYSICS_FUNC_H__ */