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,721 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="5_raycast.windows"
ProjectGUID="{96B87A78-C8E3-43C5-B0E4-9A30999B2712}"
RootNamespace="5_raycast.win32"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Win32 Debug|Win32"
OutputDirectory="$(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="_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
DisableSpecificWarnings="4819"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib libScePhysicsEffectsD.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="Win32 Debug|x64"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../include;"
PreprocessorDefinitions="_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
DisableSpecificWarnings="4819"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib libScePhysicsEffectsD.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;../../../lib/Win32 Debug&quot;"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Win32 Release|Win32"
OutputDirectory="$(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="NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
DisableSpecificWarnings="4819"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkLibraryDependencies="true"
AdditionalDependencies="opengl32.lib glu32.lib libScePhysicsEffects.lib"
ShowProgress="0"
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>
<Configuration
Name="Win32 Release|x64"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../../../include;"
PreprocessorDefinitions="NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
DisableSpecificWarnings="4819"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkLibraryDependencies="true"
AdditionalDependencies="opengl32.lib glu32.lib libScePhysicsEffects.lib"
ShowProgress="0"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;../../../lib/Win32 Release&quot;"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Win64 Debug|Win32"
OutputDirectory="$(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="_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
DisableSpecificWarnings="4819"
/>
<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="Win64 Debug|x64"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../../include;"
PreprocessorDefinitions="_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
DisableSpecificWarnings="4819"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib libScePhysicsEffectsD.lib"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;../../../lib/$(ConfigurationName)&quot;"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Win64 Release|Win32"
OutputDirectory="$(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="NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
DisableSpecificWarnings="4819"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkLibraryDependencies="true"
AdditionalDependencies="opengl32.lib glu32.lib"
ShowProgress="0"
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>
<Configuration
Name="Win64 Release|x64"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../../../include;"
PreprocessorDefinitions="NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
EnableEnhancedInstructionSet="0"
FloatingPointModel="2"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
DisableSpecificWarnings="4819"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkLibraryDependencies="true"
AdditionalDependencies="opengl32.lib glu32.lib libScePhysicsEffects.lib"
ShowProgress="0"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;../../../lib/$(ConfigurationName)&quot;"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<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="Header Files"
>
<File
RelativePath=".\physics_func.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\main.cpp"
>
</File>
<File
RelativePath=".\physics_func.cpp"
>
</File>
</Filter>
<Filter
Name="Common"
>
<File
RelativePath="..\common\common.h"
>
</File>
<File
RelativePath="..\common\ctrl_func.h"
>
</File>
<File
RelativePath="..\common\ctrl_func.win32.cpp"
>
</File>
<File
RelativePath="..\common\perf_func.h"
>
</File>
<File
RelativePath="..\common\perf_func.win32.cpp"
>
</File>
<File
RelativePath="..\common\render_func.h"
>
</File>
<File
RelativePath="..\common\render_func.win32.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,77 @@
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_5_Raycast)
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_5_Raycast_SRCS
main.cpp
physics_func.cpp
../common/ctrl_func.win32.cpp
../common/perf_func.win32.cpp
../common/render_func.win32.cpp
)
SET(App_5_Raycast_HDRS
physics_func.h
landscape.h
barrel.h
../common/render_func.h
../common/common.h
../common/ctrl_func.h
../common/perf_func.h
)
INCLUDE_DIRECTORIES(
${PHYSICS_EFFECTS_SOURCE_DIR}/include
# ${VECTOR_MATH_INCLUDE}
)
#LINK_DIRECTORIES(
#
#)
#ADD_DEFINITIONS(-DUNICODE)
#ADD_DEFINITIONS(-D_UNICODE)
ADD_EXECUTABLE(App_5_Raycast WIN32
${App_5_Raycast_SRCS}
${App_5_Raycast_HDRS}
)
TARGET_LINK_LIBRARIES(App_5_Raycast
PfxBaseLevel
PfxLowLevel
PfxUtil
${OPENGL_gl_LIBRARY}
${OPENGL_glu_LIBRARY}
)
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
SET_TARGET_PROPERTIES(App_5_Raycast PROPERTIES DEBUG_POSTFIX "_Debug")
SET_TARGET_PROPERTIES(App_5_Raycast PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
SET_TARGET_PROPERTIES(App_5_Raycast PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
ENDIF()

View File

@@ -0,0 +1,202 @@
/*
Physics Effects Copyright(C) 2010 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) 2010 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,544 @@
/*
Physics Effects Copyright(C) 2010 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 "../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
// ARA begin insert new code
#ifdef __ANDROID__
#include <EGL/egl.h>
#include <GLES/gl.h>
#endif
// ARA end
#define SAMPLE_NAME "api_physics_effects/5_raycast"
//#define ENABLE_DEBUG_DRAW
#ifdef ENABLE_DEBUG_DRAW
#define ENABLE_DEBUG_DRAW_CONTACT
#define ENABLE_DEBUG_DRAW_AABB
#define ENABLE_DEBUG_DRAW_ISLAND
#endif
static bool s_isRunning = true;
int sceneId = 0;
bool simulating = false;
int landscapeMeshId;
int convexMeshId;
void render(void)
{
render_begin();
const PfxVector3 colorWhite(1.0f);
const PfxVector3 colorGray(0.7f);
for(int i=0;i<physics_get_num_rigidbodies();i++) {
const PfxRigidState &state = physics_get_state(i);
const PfxCollidable &coll = physics_get_collidable(i);
PfxVector3 color = state.isAsleep()?colorGray:colorWhite;
PfxTransform3 rbT(state.getOrientation(), state.getPosition());
PfxShapeIterator itrShape(coll);
for(PfxUInt32 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,
color,
PfxFloatInVec(shape.getSphere().m_radius));
break;
case kPfxShapeBox:
render_box(
worldT,
color,
shape.getBox().m_half);
break;
case kPfxShapeCapsule:
render_capsule(
worldT,
color,
PfxFloatInVec(shape.getCapsule().m_radius),
PfxFloatInVec(shape.getCapsule().m_halfLen));
break;
case kPfxShapeCylinder:
render_cylinder(
worldT,
color,
PfxFloatInVec(shape.getCylinder().m_radius),
PfxFloatInVec(shape.getCylinder().m_halfLen));
break;
case kPfxShapeConvexMesh:
render_mesh(
worldT,
color,
convexMeshId);
break;
case kPfxShapeLargeTriMesh:
render_mesh(
worldT,
color,
landscapeMeshId);
break;
default:
break;
}
}
}
render_debug_begin();
#ifdef ENABLE_DEBUG_DRAW_CONTACT
for(int i=0;i<physics_get_num_contacts();i++) {
const PfxContactManifold &contact = physics_get_contact(i);
const PfxRigidState &stateA = physics_get_state(contact.getRigidBodyIdA());
const PfxRigidState &stateB = physics_get_state(contact.getRigidBodyIdB());
for(int j=0;j<contact.getNumContacts();j++) {
const PfxContactPoint &cp = contact.getContactPoint(j);
PfxVector3 pA = stateA.getPosition()+rotate(stateA.getOrientation(),pfxReadVector3(cp.m_localPointA));
const float w = 0.05f;
render_debug_line(pA+PfxVector3(-w,0.0f,0.0f),pA+PfxVector3(w,0.0f,0.0f),PfxVector3(0,0,1));
render_debug_line(pA+PfxVector3(0.0f,-w,0.0f),pA+PfxVector3(0.0f,w,0.0f),PfxVector3(0,0,1));
render_debug_line(pA+PfxVector3(0.0f,0.0f,-w),pA+PfxVector3(0.0f,0.0f,w),PfxVector3(0,0,1));
}
}
#endif
#ifdef ENABLE_DEBUG_DRAW_AABB
for(int i=0;i<physics_get_num_rigidbodies();i++) {
const PfxRigidState &state = physics_get_state(i);
const PfxCollidable &coll = physics_get_collidable(i);
PfxVector3 center = state.getPosition() + coll.getCenter();
PfxVector3 half = absPerElem(PfxMatrix3(state.getOrientation())) * coll.getHalf();
render_debug_box(center,half,PfxVector3(1,0,0));
}
#endif
#ifdef ENABLE_DEBUG_DRAW_ISLAND
const PfxIsland *island = physics_get_islands();
if(island) {
for(PfxUInt32 i=0;i<pfxGetNumIslands(island);i++) {
PfxIslandUnit *islandUnit = pfxGetFirstUnitInIsland(island,i);
PfxVector3 aabbMin(SCE_PFX_FLT_MAX);
PfxVector3 aabbMax(-SCE_PFX_FLT_MAX);
for(;islandUnit!=NULL;islandUnit=pfxGetNextUnitInIsland(islandUnit)) {
const PfxRigidState &state = physics_get_state(pfxGetUnitId(islandUnit));
const PfxCollidable &coll = physics_get_collidable(pfxGetUnitId(islandUnit));
PfxVector3 center = state.getPosition() + coll.getCenter();
PfxVector3 half = absPerElem(PfxMatrix3(state.getOrientation())) * coll.getHalf();
aabbMin = minPerElem(aabbMin,center-half);
aabbMax = maxPerElem(aabbMax,center+half);
}
render_debug_box((aabbMax+aabbMin)*0.5f,(aabbMax-aabbMin)*0.5f,PfxVector3(0,1,0));
}
}
#endif
for(int i=0;i<physics_get_num_rays();i++) {
const PfxRayInput& rayInput = physics_get_rayinput(i);
const PfxRayOutput& rayOutput = physics_get_rayoutput(i);
if(rayOutput.m_contactFlag) {
render_debug_line(
rayInput.m_startPosition,
rayOutput.m_contactPoint,
PfxVector3(1.0f,0.0f,1.0f));
render_debug_line(
rayOutput.m_contactPoint,
rayOutput.m_contactPoint+rayOutput.m_contactNormal,
PfxVector3(1.0f,0.0f,1.0f));
}
else {
render_debug_line(rayInput.m_startPosition,
rayInput.m_startPosition+rayInput.m_direction,
PfxVector3(0.5f,0.0f,0.5f));
}
}
extern bool doAreaRaycast;
extern PfxVector3 areaCenter;
extern PfxVector3 areaExtent;
if(doAreaRaycast) {
render_debug_box(areaCenter,areaExtent,PfxVector3(0,0,1));
}
render_debug_end();
render_end();
}
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;
}
void update(void)
{
float angX,angY,r;
render_get_view_angle(angX,angY,r);
ctrl_update();
if(ctrl_button_pressed(BTN_UP)) {
angX -= 0.05f;
if(angX < -1.4f) angX = -1.4f;
if(angX > -0.01f) angX = -0.01f;
}
if(ctrl_button_pressed(BTN_DOWN)) {
angX += 0.05f;
if(angX < -1.4f) angX = -1.4f;
if(angX > -0.01f) angX = -0.01f;
}
if(ctrl_button_pressed(BTN_LEFT)) {
angY -= 0.05f;
}
if(ctrl_button_pressed(BTN_RIGHT)) {
angY += 0.05f;
}
if(ctrl_button_pressed(BTN_ZOOM_OUT)) {
r *= 1.1f;
if(r > 500.0f) r = 500.0f;
}
if(ctrl_button_pressed(BTN_ZOOM_IN)) {
r *= 0.9f;
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
// ARA begin insert new code
#ifdef __ANDROID__
///////////////////////////////////////////////////////////////////////////////
// sceneChange
//
/// This function is used to change the physics scene on Android devices
///////////////////////////////////////////////////////////////////////////////
void sceneChange()
{
physics_create_scene(sceneId++);
}
#else // __ANDROID__
// ARA end
///////////////////////////////////////////////////////////////////////////////
// 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;
}
// ARA begin insert new code
#endif // __ANDROID__
// ARA end
#else // _WIN32
///////////////////////////////////////////////////////////////////////////////
// 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)
{
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
/*
Physics Effects Copyright(C) 2010 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);
// Get ray information
int physics_get_num_rays();
const PfxRayInput& physics_get_rayinput(int id);
const PfxRayOutput& physics_get_rayoutput(int id);
// Get contact information
int physics_get_num_contacts();
const PfxContactManifold &physics_get_contact(int id);
// Get simulation island
const PfxIsland* physics_get_islands();
#endif /* __PHYSICS_FUNC_H__ */