This commit is contained in:
2025-11-28 23:13:44 +05:30
commit a3a8e79709
7360 changed files with 1156074 additions and 0 deletions

View File

@ -0,0 +1,84 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
cmake_minimum_required(VERSION 3.7)
project(SamplesAndSDK C CXX)
IF(NOT DEFINED CMAKEMODULES_VERSION)
SET(CMAKEMODULES_PATH $ENV{PM_CMakeModules_PATH} CACHE INTERNAL "Path to CMakeModules")
SET(CMAKEMODULES_NAME $ENV{PM_CMakeModules_NAME} CACHE INTERNAL "CMakeModules name")
SET(CMAKEMODULES_VERSION $ENV{PM_CMakeModules_VERSION} CACHE INTERNAL "CMakeModules version from generation batch")
#TODO: More elegance
IF(NOT EXISTS ${CMAKEMODULES_PATH})
MESSAGE(FATAL_ERROR "Could not find ${CMAKEMODULES_PATH}")
ENDIF()
ENDIF()
SET(CMAKE_MODULE_PATH ${CMAKEMODULES_PATH})
# This is required to be defined by external callers!
IF(NOT DEFINED PHYSX_ROOT_DIR)
MESSAGE(FATAL_ERROR "PHYSX_ROOT_DIR variable wasn't set.")
ENDIF()
IF(NOT EXISTS ${PHYSX_ROOT_DIR})
MESSAGE(FATAL_ERROR "PHYSX_ROOT_DIR variable was invalid.")
ENDIF()
INCLUDE(NvidiaBuildOptions)
IF(CMAKE_CONFIGURATION_TYPES)
SET(CMAKE_CONFIGURATION_TYPES debug checked profile release)
SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset config to what we need"
FORCE)
# Need to define these at least once.
SET(CMAKE_EXE_LINKER_FLAGS_PROFILE "")
SET(CMAKE_EXE_LINKER_FLAGS_CHECKED "")
ENDIF()
SET(SOURCE_DISTRO_FILE_LIST "")
SET(PROJECT_CMAKE_FILES_DIR compiler/cmake)
SET(PLATFORM_CMAKELISTS ${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/CMakeLists.txt)
IF(NOT EXISTS ${PLATFORM_CMAKELISTS})
MESSAGE(FATAL_ERROR "Unable to find platform CMakeLists.txt for ${TARGET_BUILD_PLATFORM} at ${PLATFORM_CMAKELISTS}")
ENDIF()
# Include the platform specific CMakeLists
INCLUDE(${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/CMakeLists.txt)
IF(PX_GENERATE_SOURCE_DISTRO)
FOREACH(FILE_NAME ${SOURCE_DISTRO_FILE_LIST})
FILE(APPEND "${CMAKE_CURRENT_BINARY_DIR}/source_distro_list.txt" "${FILE_NAME}\n")
ENDFOREACH()
ENDIF()

View File

@ -0,0 +1,177 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleBase common
#
SET(SAMPLEBASE_DIR ${PHYSX_ROOT_DIR}/samples/samplebase/)
# One of the test files reaches into this directory for an include
SET(UTILS_SRC_DIR "${PHYSX_ROOT_DIR}/test/common/Utils")
# Include here after the directories are defined so that the platform specific file can use the variables.
include(${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/SampleBase.cmake)
SET(SAMPLEBASE_FILES
${SAMPLEBASE_DIR}/AcclaimLoader.cpp
${SAMPLEBASE_DIR}/AcclaimLoader.h
${SAMPLEBASE_DIR}/Dummy.cpp
${SAMPLEBASE_DIR}/InputEventBuffer.cpp
${SAMPLEBASE_DIR}/InputEventBuffer.h
${SAMPLEBASE_DIR}/PhysXSample.cpp
${SAMPLEBASE_DIR}/PhysXSample.h
${SAMPLEBASE_DIR}/PhysXSampleApplication.cpp
${SAMPLEBASE_DIR}/PhysXSampleApplication.h
${SAMPLEBASE_DIR}/Picking.cpp
${SAMPLEBASE_DIR}/Picking.h
${SAMPLEBASE_DIR}/RawLoader.cpp
${SAMPLEBASE_DIR}/RawLoader.h
${SAMPLEBASE_DIR}/RaycastCCD.cpp
${SAMPLEBASE_DIR}/RaycastCCD.h
${SAMPLEBASE_DIR}/RenderBaseActor.cpp
${SAMPLEBASE_DIR}/RenderBaseActor.h
${SAMPLEBASE_DIR}/RenderBaseObject.cpp
${SAMPLEBASE_DIR}/RenderBaseObject.h
${SAMPLEBASE_DIR}/RenderBoxActor.cpp
${SAMPLEBASE_DIR}/RenderBoxActor.h
${SAMPLEBASE_DIR}/RenderCapsuleActor.cpp
${SAMPLEBASE_DIR}/RenderCapsuleActor.h
${SAMPLEBASE_DIR}/RenderGridActor.cpp
${SAMPLEBASE_DIR}/RenderGridActor.h
${SAMPLEBASE_DIR}/RenderMaterial.cpp
${SAMPLEBASE_DIR}/RenderMaterial.h
${SAMPLEBASE_DIR}/RenderMeshActor.cpp
${SAMPLEBASE_DIR}/RenderMeshActor.h
${SAMPLEBASE_DIR}/RenderPhysX3Debug.cpp
${SAMPLEBASE_DIR}/RenderPhysX3Debug.h
${SAMPLEBASE_DIR}/RenderSphereActor.cpp
${SAMPLEBASE_DIR}/RenderSphereActor.h
${SAMPLEBASE_DIR}/RenderTexture.cpp
${SAMPLEBASE_DIR}/RenderTexture.h
${SAMPLEBASE_DIR}/SampleAllocator.cpp
${SAMPLEBASE_DIR}/SampleAllocator.h
${SAMPLEBASE_DIR}/SampleAllocatorSDKClasses.h
${SAMPLEBASE_DIR}/SampleArray.h
${SAMPLEBASE_DIR}/SampleBaseInputEventIds.h
${SAMPLEBASE_DIR}/SampleCamera.cpp
${SAMPLEBASE_DIR}/SampleCamera.h
${SAMPLEBASE_DIR}/SampleCameraController.cpp
${SAMPLEBASE_DIR}/SampleCameraController.h
${SAMPLEBASE_DIR}/SampleCharacterHelpers.cpp
${SAMPLEBASE_DIR}/SampleCharacterHelpers.h
${SAMPLEBASE_DIR}/SampleConsole.cpp
${SAMPLEBASE_DIR}/SampleConsole.h
${SAMPLEBASE_DIR}/SampleInputMappingAsset.cpp
${SAMPLEBASE_DIR}/SampleInputMappingAsset.h
${SAMPLEBASE_DIR}/SampleMain.cpp
${SAMPLEBASE_DIR}/SampleMouseFilter.cpp
${SAMPLEBASE_DIR}/SampleMouseFilter.h
${SAMPLEBASE_DIR}/SamplePreprocessor.h
${SAMPLEBASE_DIR}/SampleRandomPrecomputed.cpp
${SAMPLEBASE_DIR}/SampleRandomPrecomputed.h
${SAMPLEBASE_DIR}/SampleStepper.cpp
${SAMPLEBASE_DIR}/SampleStepper.h
${SAMPLEBASE_DIR}/SampleUserInputDefines.h
${SAMPLEBASE_DIR}/SampleUtils.h
${SAMPLEBASE_DIR}/Test.h
${SAMPLEBASE_DIR}/TestGeometryHelpers.cpp
${SAMPLEBASE_DIR}/TestGeometryHelpers.h
${SAMPLEBASE_DIR}/TestGroup.cpp
${SAMPLEBASE_DIR}/TestGroup.h
${SAMPLEBASE_DIR}/TestMotionGenerator.cpp
${SAMPLEBASE_DIR}/TestMotionGenerator.h
${SAMPLEBASE_DIR}/wavefront.cpp
${SAMPLEBASE_DIR}/wavefront.h
)
ADD_LIBRARY(SampleBase STATIC
${SAMPLEBASE_FILES}
)
TARGET_INCLUDE_DIRECTORIES(SampleBase
PRIVATE ${PHYSX_ROOT_DIR}/include
PRIVATE ${PHYSX_ROOT_DIR}/source/common/src
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/framework/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/platform/include
PRIVATE ${UTILS_SRC_DIR}
PRIVATE ${PHYSX_ROOT_DIR}/source/common/include
PRIVATE ${PHYSX_ROOT_DIR}/source/common/src
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/include
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/include
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/contact
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/common
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/convex
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/distance
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/gjk
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/intersection
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/mesh
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/Ice
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/hf
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/pcm
)
TARGET_COMPILE_DEFINITIONS(SampleBase
PRIVATE ${SAMPLEBASE_COMPILE_DEFS}
)
IF(NV_USE_GAMEWORKS_OUTPUT_DIRS)
SET_TARGET_PROPERTIES(SampleBase PROPERTIES
COMPILE_PDB_NAME_DEBUG "SampleBase_static_${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SampleBase_static_${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SampleBase_static_${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SampleBase_static_${CMAKE_RELEASE_POSTFIX}"
ARCHIVE_OUTPUT_NAME_DEBUG "SampleBase_static"
ARCHIVE_OUTPUT_NAME_CHECKED "SampleBase_static"
ARCHIVE_OUTPUT_NAME_PROFILE "SampleBase_static"
ARCHIVE_OUTPUT_NAME_RELEASE "SampleBase_static"
)
ELSE()
SET_TARGET_PROPERTIES(SampleBase PROPERTIES
COMPILE_PDB_NAME_DEBUG "SampleBase${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SampleBase${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SampleBase${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SampleBase${CMAKE_RELEASE_POSTFIX}"
)
ENDIF()
TARGET_LINK_LIBRARIES(SampleBase
PUBLIC SampleToolkit
PUBLIC ${SAMPLEBASE_PLATFORM_LINKED_LIBS}
)
IF(PX_GENERATE_SOURCE_DISTRO)
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEBASE_FILES})
ENDIF()

View File

@ -0,0 +1,134 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleFramework common
#
FIND_PACKAGE(Targa $ENV{PM_targa_VERSION} CONFIG REQUIRED)
SET(SAMPLEFRAMEWORK_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework)
# Include here after the directories are defined so that the platform specific file can use the variables.
include(${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/SampleFramework.cmake)
SET(SAMPLEFRAMEWORK_FILES
${SAMPLEFRAMEWORK_DIR}/framework/src/nv_dds.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/nv_dds.h
${SAMPLEFRAMEWORK_DIR}/framework/src/ODBlock.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleApplication.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleAsset.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleAssetManager.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleCommandLine.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleDirManager.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleInputAsset.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleLineDebugRender.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleMaterialAsset.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SamplePointDebugRender.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleTextureAsset.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleTree.cpp
${SAMPLEFRAMEWORK_DIR}/framework/src/SampleTriangleDebugRender.cpp
${SAMPLEFRAMEWORK_DIR}/framework/include/FrameworkFoundation.h
${SAMPLEFRAMEWORK_DIR}/framework/include/ODBlock.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleActor.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleApplication.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleArray.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleAsset.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleAssetManager.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleCommandLine.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleDirManager.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleFilesystem.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleFrameworkInputEventIds.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleInputAsset.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleLineDebugRender.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleMaterialAsset.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SamplePointDebugRender.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleTextureAsset.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleTree.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleTriangleDebugRender.h
${SAMPLEFRAMEWORK_DIR}/framework/include/SampleXml.h
${TARGA_SRC_DIR}/targa.cpp
)
ADD_LIBRARY(SampleFramework STATIC
${SAMPLEFRAMEWORK_PLATFORM_SOURCES}
${SAMPLEFRAMEWORK_FILES}
)
TARGET_INCLUDE_DIRECTORIES(SampleFramework
PUBLIC ${SAMPLEFRAMEWORK_PLATFORM_INCLUDES}
PUBLIC ${SAMPLEFRAMEWORK_DIR}/framework/include
PUBLIC ${SAMPLEFRAMEWORK_DIR}/renderer/include
PUBLIC ${SAMPLEFRAMEWORK_DIR}/platform/include
PRIVATE ${PHYSX_ROOT_DIR}/include
PRIVATE ${PHYSX_ROOT_DIR}/source/common/src
PRIVATE ${PHYSX_ROOT_DIR}/source/fastxml/include
PRIVATE ${TARGA_INCLUDE_DIR}
)
TARGET_COMPILE_DEFINITIONS(SampleFramework
PRIVATE ${SAMPLEFRAMEWORK_COMPILE_DEFS}
)
IF(NV_USE_GAMEWORKS_OUTPUT_DIRS)
SET_TARGET_PROPERTIES(SampleFramework PROPERTIES
COMPILE_PDB_NAME_DEBUG "SampleFramework_static_${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SampleFramework_static_${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SampleFramework_static_${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SampleFramework_static_${CMAKE_RELEASE_POSTFIX}"
ARCHIVE_OUTPUT_NAME_DEBUG "SampleFramework_static"
ARCHIVE_OUTPUT_NAME_CHECKED "SampleFramework_static"
ARCHIVE_OUTPUT_NAME_PROFILE "SampleFramework_static"
ARCHIVE_OUTPUT_NAME_RELEASE "SampleFramework_static"
)
ELSE()
SET_TARGET_PROPERTIES(SampleFramework PROPERTIES
COMPILE_PDB_NAME_DEBUG "SampleFramework${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SampleFramework${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SampleFramework${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SampleFramework${CMAKE_RELEASE_POSTFIX}"
)
ENDIF()
TARGET_LINK_LIBRARIES(SampleFramework
PRIVATE ${SAMPLEFRAMEWORK_PRIVATE_PLATFORM_LINKED_LIBS}
PUBLIC PhysXFoundation SampleToolkit
PUBLIC ${SAMPLEFRAMEWORK_PLATFORM_LINKED_LIBS}
)
IF(PX_GENERATE_SOURCE_DISTRO)
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEFRAMEWORK_PLATFORM_SOURCES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEFRAMEWORK_FILES})
ENDIF()

View File

@ -0,0 +1,98 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SamplePlatform common
#
SET(SAMPLEPLATFORM_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/platform)
# Include here after the directories are defined so that the platform specific file can use the variables.
INCLUDE(${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/SamplePlatform.cmake)
SET(SAMPLEPLATFORM_FILES
${SAMPLEPLATFORM_DIR}/src/SamplePlatform.cpp
${SAMPLEPLATFORM_DIR}/src/SampleUserInput.cpp
${SAMPLEPLATFORM_DIR}/include/SampleUserInputIds.h
${SAMPLEPLATFORM_DIR}/include/SampleUserInput.h
${SAMPLEPLATFORM_DIR}/include/SamplePlatform.h
)
ADD_LIBRARY(SamplePlatform STATIC
${SAMPLEPLATFORM_PLATFORM_SOURCES}
${SAMPLEPLATFORM_FILES}
)
TARGET_INCLUDE_DIRECTORIES(SamplePlatform
PRIVATE ${SAMPLEPLATFORM_PLATFORM_INCLUDES}
PRIVATE ${SAMPLEPLATFORM_DIR}/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/framework/include
PRIVATE ${PHYSX_ROOT_DIR}/include
PRIVATE ${PHYSX_ROOT_DIR}/source/common/src
)
TARGET_COMPILE_DEFINITIONS(SamplePlatform
PRIVATE ${SAMPLEPLATFORM_COMPILE_DEFS}
)
IF(NV_USE_GAMEWORKS_OUTPUT_DIRS)
SET_TARGET_PROPERTIES(SamplePlatform PROPERTIES
COMPILE_PDB_NAME_DEBUG "SamplePlatform_static_${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SamplePlatform_static_${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SamplePlatform_static_${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SamplePlatform_static_${CMAKE_RELEASE_POSTFIX}"
ARCHIVE_OUTPUT_NAME_DEBUG "SamplePlatform_static"
ARCHIVE_OUTPUT_NAME_CHECKED "SamplePlatform_static"
ARCHIVE_OUTPUT_NAME_PROFILE "SamplePlatform_static"
ARCHIVE_OUTPUT_NAME_RELEASE "SamplePlatform_static"
)
ELSE()
SET_TARGET_PROPERTIES(SamplePlatform PROPERTIES
COMPILE_PDB_NAME_DEBUG "SamplePlatform${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SamplePlatform${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SamplePlatform${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SamplePlatform${CMAKE_RELEASE_POSTFIX}"
)
ENDIF()
TARGET_LINK_LIBRARIES(SamplePlatform
PUBLIC SampleToolkit
PUBLIC ${SAMPLEPLATFORM_PLATFORM_LINKED_LIBS}
)
IF(PX_GENERATE_SOURCE_DISTRO)
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEPLATFORM_PLATFORM_SOURCES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEPLATFORM_FILES})
ENDIF()

View File

@ -0,0 +1,175 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleRenderer common
#
SET(SAMPLERENDERER_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer)
# Include here after the directories are defined so that the platform specific file can use the variables.
include(${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/SampleRenderer.cmake)
SET(SAMPLERENDERER_FILES
${SAMPLERENDERER_DIR}/src/Renderer.cpp
${SAMPLERENDERER_DIR}/src/RendererBoxShape.cpp
${SAMPLERENDERER_DIR}/src/RendererCapsuleShape.cpp
${SAMPLERENDERER_DIR}/src/RendererColor.cpp
${SAMPLERENDERER_DIR}/src/RendererDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererDirectionalLight.cpp
${SAMPLERENDERER_DIR}/src/RendererDirectionalLightDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererGridShape.cpp
${SAMPLERENDERER_DIR}/src/RendererIndexBuffer.cpp
${SAMPLERENDERER_DIR}/src/RendererIndexBufferDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererInstanceBuffer.cpp
${SAMPLERENDERER_DIR}/src/RendererInstanceBufferDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererLight.cpp
${SAMPLERENDERER_DIR}/src/RendererLightDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererMaterial.cpp
${SAMPLERENDERER_DIR}/src/RendererMaterialDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererMaterialInstance.cpp
${SAMPLERENDERER_DIR}/src/RendererMesh.cpp
${SAMPLERENDERER_DIR}/src/RendererMeshContext.cpp
${SAMPLERENDERER_DIR}/src/RendererMeshDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererMeshShape.cpp
${SAMPLERENDERER_DIR}/src/RendererProjection.cpp
${SAMPLERENDERER_DIR}/src/RendererShape.cpp
${SAMPLERENDERER_DIR}/src/RendererSpotLight.cpp
${SAMPLERENDERER_DIR}/src/RendererSpotLightDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererTarget.cpp
${SAMPLERENDERER_DIR}/src/RendererTargetDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererTerrainShape.cpp
${SAMPLERENDERER_DIR}/src/RendererTexture.cpp
${SAMPLERENDERER_DIR}/src/RendererTexture2D.cpp
${SAMPLERENDERER_DIR}/src/RendererTexture2DDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererTextureDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererVertexBuffer.cpp
${SAMPLERENDERER_DIR}/src/RendererVertexBufferDesc.cpp
${SAMPLERENDERER_DIR}/src/RendererWindow.cpp
)
SET(SAMPLERENDERER_HEADERS
${SAMPLERENDERER_DIR}/include/GLIncludes.h
${SAMPLERENDERER_DIR}/include/Renderer.h
${SAMPLERENDERER_DIR}/include/RendererBoxShape.h
${SAMPLERENDERER_DIR}/include/RendererCapsuleShape.h
${SAMPLERENDERER_DIR}/include/RendererColor.h
${SAMPLERENDERER_DIR}/include/RendererConfig.h
${SAMPLERENDERER_DIR}/include/RendererDesc.h
${SAMPLERENDERER_DIR}/include/RendererDirectionalLight.h
${SAMPLERENDERER_DIR}/include/RendererDirectionalLightDesc.h
${SAMPLERENDERER_DIR}/include/RendererFoundation.h
${SAMPLERENDERER_DIR}/include/RendererGridShape.h
${SAMPLERENDERER_DIR}/include/RendererIndexBuffer.h
${SAMPLERENDERER_DIR}/include/RendererIndexBufferDesc.h
${SAMPLERENDERER_DIR}/include/RendererInstanceBuffer.h
${SAMPLERENDERER_DIR}/include/RendererInstanceBufferDesc.h
${SAMPLERENDERER_DIR}/include/RendererInteropableBuffer.h
${SAMPLERENDERER_DIR}/include/RendererLight.h
${SAMPLERENDERER_DIR}/include/RendererLightDesc.h
${SAMPLERENDERER_DIR}/include/RendererMaterial.h
${SAMPLERENDERER_DIR}/include/RendererMaterialDesc.h
${SAMPLERENDERER_DIR}/include/RendererMaterialInstance.h
${SAMPLERENDERER_DIR}/include/RendererMemoryMacros.h
${SAMPLERENDERER_DIR}/include/RendererMesh.h
${SAMPLERENDERER_DIR}/include/RendererMeshContext.h
${SAMPLERENDERER_DIR}/include/RendererMeshDesc.h
${SAMPLERENDERER_DIR}/include/RendererMeshShape.h
${SAMPLERENDERER_DIR}/include/RendererProjection.h
${SAMPLERENDERER_DIR}/include/RendererShape.h
${SAMPLERENDERER_DIR}/include/RendererSpotLight.h
${SAMPLERENDERER_DIR}/include/RendererSpotLightDesc.h
${SAMPLERENDERER_DIR}/include/RendererTarget.h
${SAMPLERENDERER_DIR}/include/RendererTargetDesc.h
${SAMPLERENDERER_DIR}/include/RendererTerrainShape.h
${SAMPLERENDERER_DIR}/include/RendererTexture.h
${SAMPLERENDERER_DIR}/include/RendererTexture2D.h
${SAMPLERENDERER_DIR}/include/RendererTexture2DDesc.h
${SAMPLERENDERER_DIR}/include/RendererTextureDesc.h
${SAMPLERENDERER_DIR}/include/RendererUtils.h
${SAMPLERENDERER_DIR}/include/RendererVertexBuffer.h
${SAMPLERENDERER_DIR}/include/RendererVertexBufferDesc.h
${SAMPLERENDERER_DIR}/include/RendererWindow.h
)
ADD_LIBRARY(SampleRenderer STATIC
${SAMPLERENDERER_PLATFORM_SOURCES}
${SAMPLERENDERER_FILES}
${SAMPLERENDERER_HEADERS}
)
TARGET_INCLUDE_DIRECTORIES(SampleRenderer
PRIVATE ${SAMPLERENDERER_PLATFORM_INCLUDES}
PRIVATE ${SAMPLERENDERER_DIR}/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/platform/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/framework/include
PRIVATE ${PHYSX_ROOT_DIR}/include
PRIVATE ${PHYSX_ROOT_DIR}/source/common/src
)
TARGET_COMPILE_DEFINITIONS(SampleRenderer
PRIVATE ${SAMPLERENDERER_COMPILE_DEFS}
)
IF(NV_USE_GAMEWORKS_OUTPUT_DIRS)
SET_TARGET_PROPERTIES(SampleRenderer PROPERTIES
COMPILE_PDB_NAME_DEBUG "SampleRenderer_static_${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SampleRenderer_static_${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SampleRenderer_static_${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SampleRenderer_static_${CMAKE_RELEASE_POSTFIX}"
ARCHIVE_OUTPUT_NAME_DEBUG "SampleRenderer_static"
ARCHIVE_OUTPUT_NAME_CHECKED "SampleRenderer_static"
ARCHIVE_OUTPUT_NAME_PROFILE "SampleRenderer_static"
ARCHIVE_OUTPUT_NAME_RELEASE "SampleRenderer_static"
)
ELSE()
SET_TARGET_PROPERTIES(SampleRenderer PROPERTIES
COMPILE_PDB_NAME_DEBUG "SampleRenderer${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SampleRenderer${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SampleRenderer${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SampleRenderer${CMAKE_RELEASE_POSTFIX}"
)
ENDIF()
TARGET_LINK_LIBRARIES(SampleRenderer
PUBLIC SampleToolkit
PUBLIC ${SAMPLERENDERER_PLATFORM_LINKED_LIBS}
)
IF(PX_GENERATE_SOURCE_DISTRO)
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLERENDERER_PLATFORM_SOURCES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLERENDERER_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLERENDERER_HEADERS})
ENDIF()

View File

@ -0,0 +1,228 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build Samples common
#
# Include here after the directories are defined so that the platform specific file can use the variables.
include(${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/Samples.cmake)
SET(SAMPLEBRIDGES_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplebridges)
SET(SAMPLEBRIDGES_SOURCE_FILES
${SAMPLEBRIDGES_SOURCE_DIR}/SampleBridges.cpp
${SAMPLEBRIDGES_SOURCE_DIR}/SampleBridges.h
${SAMPLEBRIDGES_SOURCE_DIR}/SampleBridgesCCT.cpp
${SAMPLEBRIDGES_SOURCE_DIR}/SampleBridgesInputEventIds.h
${SAMPLEBRIDGES_SOURCE_DIR}/SampleBridgesSettings.h
)
SOURCE_GROUP("Sample bridges" FILES ${SAMPLEBRIDGES_SOURCE_FILES})
SET(SAMPLEHELLOWORLD_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplehelloworld)
SET(SAMPLEHELLOWORLD_SOURCE_FILES
${SAMPLEHELLOWORLD_SOURCE_DIR}/SampleHelloWorld.h
${SAMPLEHELLOWORLD_SOURCE_DIR}/SampleHelloWorld.cpp
)
SOURCE_GROUP("Sample helloworld" FILES ${SAMPLEHELLOWORLD_SOURCE_FILES})
SET(SAMPLELARGEWORLD_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplelargeworld)
SET(SAMPLELARGEWORLD_SOURCE_FILES
${SAMPLELARGEWORLD_SOURCE_DIR}/ChunkLoader.cpp
${SAMPLELARGEWORLD_SOURCE_DIR}/ChunkLoader.h
${SAMPLELARGEWORLD_SOURCE_DIR}/MeshBuilder.cpp
${SAMPLELARGEWORLD_SOURCE_DIR}/MeshBuilder.h
${SAMPLELARGEWORLD_SOURCE_DIR}/SampleLargeWorld.cpp
${SAMPLELARGEWORLD_SOURCE_DIR}/SampleLargeWorld.h
${SAMPLELARGEWORLD_SOURCE_DIR}/SampleLargeWorldCCT.cpp
${SAMPLELARGEWORLD_SOURCE_DIR}/SampleLargeWorldInputEventIds.h
)
SOURCE_GROUP("Sample large world" FILES ${SAMPLELARGEWORLD_SOURCE_FILES})
SET(SAMPLENORTHPOLE_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplenorthpole)
SET(SAMPLENORTHPOLE_SOURCE_FILES
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPole.cpp
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPole.h
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPoleBuilder.cpp
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPoleCameraController.cpp
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPoleCameraController.h
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPoleCCT.cpp
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPoleDynamics.cpp
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPoleFilterShader.cpp
${SAMPLENORTHPOLE_SOURCE_DIR}/SampleNorthPoleInputEventIds.h
)
SOURCE_GROUP("Sample north pole" FILES ${SAMPLENORTHPOLE_SOURCE_FILES})
SET(SAMPLESUBMARINE_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplesubmarine)
SET(SAMPLESUBMARINE_SOURCE_FILES
${SAMPLESUBMARINE_SOURCE_DIR}/Crab.cpp
${SAMPLESUBMARINE_SOURCE_DIR}/Crab.h
${SAMPLESUBMARINE_SOURCE_DIR}/SampleSubmarine.cpp
${SAMPLESUBMARINE_SOURCE_DIR}/SampleSubmarine.h
${SAMPLESUBMARINE_SOURCE_DIR}/SampleSubmarineInputEventIds.h
${SAMPLESUBMARINE_SOURCE_DIR}/SubmarineCameraController.h
)
SOURCE_GROUP("Sample submarine" FILES ${SAMPLESUBMARINE_SOURCE_FILES})
SET(SAMPLEVEHICLE_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplevehicle)
SET(SAMPLEVEHICLE_SOURCE_FILES
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicleDebugRender.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicleInputEventIds.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicleTerrain.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_CameraController.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_CameraController.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_ControlInputs.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_ControlInputs.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_GameLogic.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_GameLogic.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_SceneQuery.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_SceneQuery.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_VehicleController.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_VehicleController.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_VehicleCooking.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_VehicleCooking.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_VehicleManager.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_VehicleManager.h
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_WheelQueryResults.cpp
${SAMPLEVEHICLE_SOURCE_DIR}/SampleVehicle_WheelQueryResults.h
)
SOURCE_GROUP("Sample vehicle" FILES ${SAMPLEVEHICLE_SOURCE_FILES})
SET(SAMPLECUSTOMGRAVITY_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplecustomgravity)
SET(SAMPLECUSTOMGRAVITY_SOURCE_FILES
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/Planet.cpp
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/Planet.h
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravity.cpp
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravity.h
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravity_CCT.cpp
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravityBuilder.cpp
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravityCameraController.cpp
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravityCameraController.h
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravityFilterShader.cpp
${SAMPLECUSTOMGRAVITY_SOURCE_DIR}/SampleCustomGravityInputEventIds.h
)
SOURCE_GROUP("Sample custom gravity" FILES ${SAMPLECUSTOMGRAVITY_SOURCE_FILES})
SET(SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR ${PHYSX_ROOT_DIR}/samples/samplecctsharedcode)
SET(SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_FILES
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/KinematicPlatform.cpp
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/KinematicPlatform.h
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/SampleCCTActor.cpp
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/SampleCCTActor.h
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/SampleCCTCameraController.cpp
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/SampleCCTCameraController.h
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/SampleCCTJump.cpp
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_DIR}/SampleCCTJump.h
)
SOURCE_GROUP("Sample CCT shared" FILES ${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_FILES})
ADD_EXECUTABLE(Samples
${SAMPLEBRIDGES_SOURCE_FILES}
${SAMPLECUSTOMGRAVITY_SOURCE_FILES}
${SAMPLEHELLOWORLD_SOURCE_FILES}
${SAMPLELARGEWORLD_SOURCE_FILES}
${SAMPLENORTHPOLE_SOURCE_FILES}
${SAMPLESUBMARINE_SOURCE_FILES}
${SAMPLEVEHICLE_SOURCE_FILES}
${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_FILES}
)
SOURCE_GROUP(SampleBridges FILES ${SAMPLEBRIDGES_SOURCE_FILES})
SOURCE_GROUP(SampleCustomGravity FILES ${SAMPLECUSTOMGRAVITY_SOURCE_FILES})
SOURCE_GROUP(SampleHelloWorld FILES ${SAMPLEHELLOWORLD_SOURCE_FILES})
SOURCE_GROUP(SampleLargeWorld FILES ${SAMPLELARGEWORLD_SOURCE_FILES})
SOURCE_GROUP(SampleNorthPole FILES ${SAMPLENORTHPOLE_SOURCE_FILES})
SOURCE_GROUP(SampleSubmarine FILES ${SAMPLESUBMARINE_SOURCE_FILES})
SOURCE_GROUP(SampleVehicle FILES ${SAMPLEVEHICLE_SOURCE_FILES})
SOURCE_GROUP(CCTShared FILES ${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_FILES})
TARGET_INCLUDE_DIRECTORIES(Samples
PRIVATE ${PHYSX_ROOT_DIR}/include/
PRIVATE ${PHYSX_ROOT_DIR}/samples/samplecctsharedcode
PRIVATE ${PHYSX_ROOT_DIR}/samples/samplebase
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/framework/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/include
PRIVATE ${PHYSX_ROOT_DIR}/samples/sampleframework/platform/include
PRIVATE ${PHYSX_ROOT_DIR}/source/common/include
PRIVATE ${PHYSX_ROOT_DIR}/source/common/src
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/include
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/include
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/contact
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/common
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/convex
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/distance
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/gjk
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/intersection
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/mesh
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/hf
PRIVATE ${PHYSX_ROOT_DIR}/source/geomutils/src/pcm
PRIVATE ${PHYSX_ROOT_DIR}/source/PhysXVehicle/src
)
TARGET_COMPILE_DEFINITIONS(Samples
PRIVATE ${SAMPLES_COMPILE_DEFS}
)
IF(NV_USE_GAMEWORKS_OUTPUT_DIRS)
SET_TARGET_PROPERTIES(Samples PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PX_EXE_OUTPUT_DIRECTORY_DEBUG}
RUNTIME_OUTPUT_DIRECTORY_PROFILE ${PX_EXE_OUTPUT_DIRECTORY_PROFILE}
RUNTIME_OUTPUT_DIRECTORY_CHECKED ${PX_EXE_OUTPUT_DIRECTORY_CHECKED}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PX_EXE_OUTPUT_DIRECTORY_RELEASE}
OUTPUT_NAME Samples${EXE_SUFFIX}
)
ELSE()
IF(APPEND_CONFIG_NAME)
SET_TARGET_PROPERTIES(Samples PROPERTIES
DEBUG_OUTPUT_NAME SamplesDEBUG
PROFILE_OUTPUT_NAME SamplesPROFILE
CHECKED_OUTPUT_NAME SamplesCHECKED
RELEASE_OUTPUT_NAME Samples
)
ENDIF()
ENDIF()
TARGET_LINK_LIBRARIES(Samples
PUBLIC SampleBase SamplePlatform SampleFramework SampleRenderer SampleToolkit PhysX PhysXPvdSDK PhysXVehicle PhysXCharacterKinematic PhysXExtensions PhysXCooking PhysXCommon PhysXFoundation SampleToolkit
PUBLIC ${SAMPLES_PLATFORM_LINKED_LIBS}
)
IF(PX_GENERATE_SOURCE_DISTRO)
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEBRIDGES_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLECUSTOMGRAVITY_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEHELLOWORLD_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLELARGEWORLD_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLENORTHPOLE_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLESUBMARINE_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLEVEHICLE_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLECHARACTERCONTROLLER_SHARED_SOURCE_FILES})
ENDIF()

View File

@ -0,0 +1,107 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build PxToolkit common
#
SET(PXTOOLKIT_ROOT_DIR ${PHYSX_ROOT_DIR}/samples/pxtoolkit)
SET(PXTOOLKIT_SRC_DIR ${PXTOOLKIT_ROOT_DIR}/src)
SET(PXTOOLKIT_INCLUDE_DIR ${PXTOOLKIT_ROOT_DIR}/include)
# Include here after the directories are defined so that the platform specific file can use the variables.
include(${PHYSX_ROOT_DIR}/samples/${PROJECT_CMAKE_FILES_DIR}/${TARGET_BUILD_PLATFORM}/SamplesToolkit.cmake)
SET(SAMPLETOOLKIT_FILES
${PXTOOLKIT_SRC_DIR}/PxTkBmpLoader.cpp
${PXTOOLKIT_SRC_DIR}/PxTkFPS.cpp
${PXTOOLKIT_SRC_DIR}/PxTkMatrixUtils.cpp
${PXTOOLKIT_SRC_DIR}/PxTkRandom.cpp
${PXTOOLKIT_SRC_DIR}/PxTkStream.cpp
)
SET(SAMPLETOOLKIT_HEADERS
${PXTOOLKIT_INCLUDE_DIR}/PxTkBmpLoader.h
${PXTOOLKIT_INCLUDE_DIR}/PxTkFile.h
${PXTOOLKIT_INCLUDE_DIR}/PxTkFPS.h
${PXTOOLKIT_INCLUDE_DIR}/PxTkMatrixUtils.h
${PXTOOLKIT_INCLUDE_DIR}/PxTkNamespaceMangle.h
${PXTOOLKIT_INCLUDE_DIR}/PxTkRandom.h
${PXTOOLKIT_INCLUDE_DIR}/PxTkStream.h
${PXTOOLKIT_INCLUDE_DIR}/PxToolkit.h
)
ADD_LIBRARY(SampleToolkit STATIC
${SAMPLETOOLKIT_PLATFORM_SOURCE_FILES}
${SAMPLETOOLKIT_FILES}
${SAMPLETOOLKIT_HEADERS}
)
TARGET_INCLUDE_DIRECTORIES(SampleToolkit
PRIVATE ${SAMPLETOOLKIT_PLATFORM_INCLUDES}
PRIVATE ${PHYSX_ROOT_DIR}/include/
PUBLIC ${PXTOOLKIT_INCLUDE_DIR}
INTERFACE $<INSTALL_INTERFACE:include>$<BUILD_INTERFACE:${PXTOOLKIT_INCLUDE_DIR}>
)
TARGET_COMPILE_DEFINITIONS(SampleToolkit
PRIVATE ${SAMPLETOOLKIT_COMPILE_DEFS}
)
TARGET_LINK_LIBRARIES(SampleToolkit PhysXFoundation PhysXExtensions)
IF(NV_USE_GAMEWORKS_OUTPUT_DIRS)
SET_TARGET_PROPERTIES(SampleToolkit PROPERTIES
COMPILE_PDB_NAME_DEBUG "SamplesToolkit_static_${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SamplesToolkit_static_${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SamplesToolkit_static_${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SamplesToolkit_static_${CMAKE_RELEASE_POSTFIX}"
ARCHIVE_OUTPUT_NAME_DEBUG "SamplesToolkit_static"
ARCHIVE_OUTPUT_NAME_CHECKED "SamplesToolkit_static"
ARCHIVE_OUTPUT_NAME_PROFILE "SamplesToolkit_static"
ARCHIVE_OUTPUT_NAME_RELEASE "SamplesToolkit_static"
)
ELSE()
SET_TARGET_PROPERTIES(SampleToolkit PROPERTIES
COMPILE_PDB_NAME_DEBUG "SamplesToolkit${CMAKE_DEBUG_POSTFIX}"
COMPILE_PDB_NAME_CHECKED "SamplesToolkit${CMAKE_CHECKED_POSTFIX}"
COMPILE_PDB_NAME_PROFILE "SamplesToolkit${CMAKE_PROFILE_POSTFIX}"
COMPILE_PDB_NAME_RELEASE "SamplesToolkit${CMAKE_RELEASE_POSTFIX}"
)
ENDIF()
IF(PX_GENERATE_SOURCE_DISTRO)
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLETOOLKIT_PLATFORM_SOURCE_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLETOOLKIT_FILES})
LIST(APPEND SOURCE_DISTRO_FILE_LIST ${SAMPLETOOLKIT_HEADERS})
ENDIF()

View File

@ -0,0 +1,68 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
IF(NOT DEFINED PHYSX_LINUX_COMPILE_DEFS)
MESSAGE(FATAL ERROR "Samples uses the PhysX compile defs, and they're not defined when they need to be.")
ENDIF()
IF (NOT DEFINED PHYSX_CXX_FLAGS)
MESSAGE(FATAL ERROR "Samples uses the PhysX CXX flags, and they're not defined when they need to be.")
ENDIF()
SET(SAMPLES_ADDITIONAL_WARNINGS "-Wno-missing-field-initializers -Wno-macro-redefined -Wno-unused-parameter -Wno-header-hygiene -Wno-double-promotion -Wno-format-pedantic -Wno-switch-enum -Wno-unused-variable -Wno-sign-compare -Wno-shadow -Wno-sometimes-uninitialized -Wno-conditional-uninitialized -Wno-vla -Wno-vla-extension -Wno-reorder -Wno-duplicate-enum -Wno-unknown-pragmas -Wno-shadow-field -Wno-comma -Wno-cast-qual -Wno-null-pointer-arithmetic")
# Get the CXX Flags from the Cached variables set by the PhysX CMakeLists
SET(CMAKE_CXX_FLAGS "${PHYSX_CXX_FLAGS} ${SAMPLES_ADDITIONAL_WARNINGS}")
SET(CMAKE_CXX_FLAGS_DEBUG ${PHYSX_CXX_FLAGS_DEBUG})
SET(CMAKE_CXX_FLAGS_CHECKED ${PHYSX_CXX_FLAGS_CHECKED})
SET(CMAKE_CXX_FLAGS_PROFILE ${PHYSX_CXX_FLAGS_PROFILE})
SET(CMAKE_CXX_FLAGS_RELEASE ${PHYSX_CXX_FLAGS_RELEASE})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath='$ORIGIN'")
#Include projects
INCLUDE(SampleBase.cmake)
INCLUDE(SampleFramework.cmake)
INCLUDE(SampleRenderer.cmake)
INCLUDE(SamplePlatform.cmake)
INCLUDE(SamplesToolkit.cmake)
SET_PROPERTY(TARGET SampleToolkit PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SampleBase PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SampleFramework PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SamplePlatform PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SampleRenderer PROPERTY FOLDER "PhysX Samples/Libraries only")
IF(PX_BUILDSAMPLES)
INCLUDE(Samples.cmake)
SET_PROPERTY(TARGET Samples PROPERTY FOLDER "PhysX Samples")
ENDIF()
IF(PX_BUILDPUBLICSAMPLES)
INCLUDE(Samples.cmake)
SET_PROPERTY(TARGET Samples PROPERTY FOLDER "PhysX Samples")
ENDIF()

View File

@ -0,0 +1,43 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleBase
#
SET(SAMPLEBASE_COMPILE_DEFS
# Common to all configurations
${PHYSX_LINUX_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_LINUX_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_LINUX_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_LINUX_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_LINUX_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLEBASE_PLATFORM_LINKED_LIBS Cg)

View File

@ -0,0 +1,60 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleFramework
#
find_package(OpenGL $ENV{PM_OpenGL_VERSION} CONFIG REQUIRED) # Pull in OpenGL and GLUT
find_package(Cg $ENV{PM_cg_VERSION} CONFIG REQUIRED)
SET(SAMPLEFRAMEWORK_PLATFORM_INCLUDES
)
SET(SAMPLEFRAMEWORK_PLATFORM_OBJECT_FILES
$<TARGET_OBJECTS:FastXml>
)
SET(SAMPLEFRAMEWORK_COMPILE_DEFS
# Common to all configurations
${PHYSX_LINUX_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_LINUX_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_LINUX_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_LINUX_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_LINUX_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLEFRAMEWORK_PLATFORM_SOURCES
${SAMPLEFRAMEWORK_PLATFORM_OBJECT_FILES}
${PHYSX_ROOT_DIR}/samples/sampleframework/framework/src/linux/LinuxSampleAssetManager.cpp
)
SET(SAMPLEFRAMEWORK_PLATFORM_LINKED_LIBS Cg GL GLUT)

View File

@ -0,0 +1,53 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SamplePlatform
#
FIND_PACKAGE(glew $ENV{PM_glew_VERSION} REQUIRED CONFIG)
SET(SAMPLEPLATFORM_COMPILE_DEFS
# Common to all configurations
${PHYSX_LINUX_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_LINUX_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_LINUX_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_LINUX_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_LINUX_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLEPLATFORM_PLATFORM_SOURCES
${PHYSX_ROOT_DIR}/samples/sampleframework/platform/src/linux/LinuxSamplePlatform.cpp
${PHYSX_ROOT_DIR}/samples/sampleframework/platform/src/linux/LinuxSampleUserInput.cpp
)
SET(SAMPLEPLATFORM_PLATFORM_LINKED_LIBS glew Cg)

View File

@ -0,0 +1,95 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleRenderer
#
find_package(OpenGL $ENV{PM_OpenGL_VERSION} CONFIG REQUIRED) # Pull in OpenGL and GLUT
SET(SAMPLERENDERER_COMPILE_DEFS
# Common to all configurations
${PHYSX_LINUX_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_LINUX_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_LINUX_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_LINUX_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_LINUX_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLE_NULLRENDERER_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/src/null)
SET(SAMPLERENDERER_NULLRENDERER_SOURCES
${SAMPLE_NULLRENDERER_DIR}/NULLRenderer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRenderer.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererDirectionalLight.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererDirectionalLight.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererIndexBuffer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererIndexBuffer.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererInstanceBuffer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererInstanceBuffer.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMaterial.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMaterial.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMesh.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMesh.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererSpotLight.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererSpotLight.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererTexture2D.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererTexture2D.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererVertexBuffer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererVertexBuffer.h
)
SET(SAMPLE_OGLRENDERER_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/src/ogl)
SET(SAMPLERENDERER_OGLRENDERER_SOURCES
${SAMPLE_OGLRENDERER_DIR}/OGLRenderer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRenderer.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererDirectionalLight.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererDirectionalLight.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererIndexBuffer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererIndexBuffer.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererInstanceBuffer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererInstanceBuffer.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMaterial.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMaterial.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMesh.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMesh.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererSpotLight.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererSpotLight.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererTexture2D.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererTexture2D.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererVertexBuffer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererVertexBuffer.h
)
SET(SAMPLERENDERER_PLATFORM_SOURCES
${SAMPLERENDERER_NULLRENDERER_SOURCES}
${SAMPLERENDERER_OGLRENDERER_SOURCES}
)
SET(SAMPLERENDERER_PLATFORM_LINKED_LIBS SamplePlatform glew Cg CgGL GL X11 Xxf86vm)

View File

@ -0,0 +1,49 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build Samples
#
FIND_PACKAGE(glew $ENV{PM_glew_VERSION} REQUIRED CONFIG)
find_package(OpenGL $ENV{PM_OpenGL_VERSION} CONFIG REQUIRED) # Pull in OpenGL and GLUT
SET(SAMPLES_COMPILE_DEFS
# Common to all configurations
${PHYSX_LINUX_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_LINUX_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_LINUX_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_LINUX_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_LINUX_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLES_PLATFORM_LINKED_LIBS GLU X11 Xxf86vm Cg CgGL GL rt pthread dl glew -Wl,-rpath='${ORIGIN}')

View File

@ -0,0 +1,48 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build PxToolkit
#
SET(SAMPLETOOLKIT_PLATFORM_SOURCE_FILES
)
SET(SAMPLETOOLKIT_PLATFORM_INCLUDES
)
SET(SAMPLETOOLKIT_COMPILE_DEFS
# Common to all configurations
${PHYSX_LINUX_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_LINUX_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_LINUX_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_LINUX_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_LINUX_RELEASE_COMPILE_DEFS};>
)

View File

@ -0,0 +1,114 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
IF(NOT DEFINED PHYSX_WINDOWS_COMPILE_DEFS)
MESSAGE(FATAL ERROR "Samples uses the PhysX compile defs, and they're not defined when they need to be.")
ENDIF()
IF (NOT DEFINED PHYSX_CXX_FLAGS)
MESSAGE(FATAL ERROR "Samples uses the PhysX CXX flags, and they're not defined when they need to be.")
ENDIF()
IF (MSVC12)
SET(ADDL_WARNINGS "/wd4512")
ENDIF()
IF(NOT CMAKE_CL_64)
# disable CUDA stuff for MSVC15 and MSVC14 win32
IF(NOT PX_GENERATE_GPU_PROJECTS)
SET(PHYSX_CUDA_DEFS "DISABLE_CUDA_PHYSX")
ENDIF()
ENDIF()
SET(SAMPLES_WINDOWS_COMPILE_DEFS ${PHYSX_CUDA_DEFS};${PHYSX_LIBTYPE_DEFS})
# Get the CXX Flags from the Cached variables set by the PhysX CMakeLists
SET(CMAKE_CXX_FLAGS "${PHYSX_CXX_FLAGS} /wd4245 /wd4512 /wd4996 /wd4244 /wd4100 /wd4456 /wd4189 /wd4505 /wd4389 /EHsc ${ADDL_WARNINGS}")
SET(CMAKE_CXX_FLAGS_DEBUG "${PHYSX_CXX_FLAGS_DEBUG}")
SET(CMAKE_CXX_FLAGS_CHECKED ${PHYSX_CXX_FLAGS_CHECKED})
SET(CMAKE_CXX_FLAGS_PROFILE ${PHYSX_CXX_FLAGS_PROFILE})
SET(CMAKE_CXX_FLAGS_RELEASE ${PHYSX_CXX_FLAGS_RELEASE})
# Build PDBs for all configurations
SET(CMAKE_SHARED_LINKER_FLAGS "/DEBUG")
# Don't redefine PHYSX_WINDOWS_COMPILE_DEFS
# Get the PhysXDevice path
SET(SLN_PHYSXDEVICE_PATH "$ENV{PM_PhysXDevice_PATH}/bin/x86/")
# Include ConfigureFileMT to expose that function
INCLUDE(ConfigureFileMt)
# Include all of the projects
INCLUDE(SampleBase.cmake)
INCLUDE(SampleFramework.cmake)
INCLUDE(SampleRenderer.cmake)
INCLUDE(SamplePlatform.cmake)
INCLUDE(SamplesToolkit.cmake)
SET_PROPERTY(TARGET SampleToolkit PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SampleBase PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SampleFramework PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SamplePlatform PROPERTY FOLDER "PhysX Samples/Libraries only")
SET_PROPERTY(TARGET SampleRenderer PROPERTY FOLDER "PhysX Samples/Libraries only")
IF(PX_BUILDSAMPLES)
INCLUDE(SampleHelloWorld.cmake)
INCLUDE(SampleBridges.cmake)
INCLUDE(SampleCharacterController.cmake)
INCLUDE(SampleCustomGravity.cmake)
INCLUDE(SampleDebugRendering.cmake)
INCLUDE(SampleInstancing.cmake)
INCLUDE(SampleLargeWorld.cmake)
INCLUDE(SampleNorthPole.cmake)
INCLUDE(SampleRaycastCCD.cmake)
INCLUDE(SampleSubmarine.cmake)
INCLUDE(SampleVehicle.cmake)
INCLUDE(Samples.cmake)
SET_PROPERTY(TARGET SampleHelloWorld PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleBridges PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleCharacterController PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleCustomGravity PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleDebugRendering PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleInstancing PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleLargeWorld PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleNorthPole PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleRaycastCCD PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleSubmarine PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET SampleVehicle PROPERTY FOLDER "PhysX Samples")
SET_PROPERTY(TARGET Samples PROPERTY FOLDER "PhysX Samples")
ENDIF()
IF(PX_BUILDPUBLICSAMPLES)
INCLUDE(Samples.cmake)
SET_PROPERTY(TARGET Samples PROPERTY FOLDER "PhysX Samples")
ENDIF()

View File

@ -0,0 +1,41 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleBase
#
SET(SAMPLEBASE_COMPILE_DEFS
# Common to all configurations
${PHYSX_WINDOWS_COMPILE_DEFS};${SAMPLES_WINDOWS_COMPILE_DEFS};_HAS_EXCEPTIONS=0;
$<$<CONFIG:debug>:${PHYSX_WINDOWS_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_WINDOWS_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_WINDOWS_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_WINDOWS_RELEASE_COMPILE_DEFS};>
)

View File

@ -0,0 +1,49 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleFramework
#
SET(SAMPLEFRAMEWORK_COMPILE_DEFS
# Common to all configurations
${PHYSX_WINDOWS_COMPILE_DEFS};${SAMPLES_WINDOWS_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_WINDOWS_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_WINDOWS_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_WINDOWS_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_WINDOWS_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLEFRAMEWORK_PLATFORM_SOURCES
${PHYSX_ROOT_DIR}/samples/sampleframework/framework/src/windows/WindowsSampleAssetManager.cpp
)
SET(SAMPLEFRAMEWORK_PRIVATE_PLATFORM_LINKED_LIBS
)

View File

@ -0,0 +1,67 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SamplePlatform
#
IF(NOT DIRECTX_INCLUDE_DIRS)
IF($ENV{PM_DirectXSDK_VERSION})
find_package(DirectXSDK $ENV{PM_DirectXSDK_VERSION} CONFIG REQUIRED)
ELSE()
IF(EXISTS $ENV{DXSDK_DIR})
SET(DIRECTX_INCLUDE_DIRS $ENV{DXSDK_DIR}/Include)
ELSE()
MESSAGE("For samples compilation please install DXSDK.")
ENDIF()
ENDIF()
SET(DIRECTX_INCLUDE_DIRS ${DIRECTX_INCLUDE_DIRS} CACHE INTERNAL "DirectX SDK include path")
ENDIF()
SET(SAMPLEPLATFORM_COMPILE_DEFS
# Common to all configurations
${PHYSX_WINDOWS_COMPILE_DEFS};${SAMPLES_WINDOWS_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_WINDOWS_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_WINDOWS_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_WINDOWS_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_WINDOWS_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLEPLATFORM_PLATFORM_SOURCES
${PHYSX_ROOT_DIR}/samples/sampleframework/platform/src/windows/WindowsSamplePlatform.cpp
${PHYSX_ROOT_DIR}/samples/sampleframework/platform/src/windows/WindowsSampleUserInput.cpp
${PHYSX_ROOT_DIR}/samples/sampleframework/platform/include/windows/WindowsSampleUserInputIds.h
${PHYSX_ROOT_DIR}/samples/sampleframework/platform/include/windows/WindowsSampleUserInput.h
${PHYSX_ROOT_DIR}/samples/sampleframework/platform/include/windows/WindowsSamplePlatform.h
)
SET(SAMPLEPLATFORM_PLATFORM_INCLUDES
${DIRECTX_INCLUDE_DIRS}
)

View File

@ -0,0 +1,171 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build SampleRenderer
#
IF(NOT DIRECTX_INCLUDE_DIRS)
IF($ENV{PM_DirectXSDK_VERSION})
find_package(DirectXSDK $ENV{PM_DirectXSDK_VERSION} CONFIG REQUIRED)
ELSE()
IF(EXISTS $ENV{DXSDK_DIR})
SET(DIRECTX_INCLUDE_DIRS $ENV{DXSDK_DIR}/Include)
ELSE()
MESSAGE("For samples compilation please install DXSDK.")
ENDIF()
ENDIF()
SET(DIRECTX_INCLUDE_DIRS ${DIRECTX_INCLUDE_DIRS} CACHE INTERNAL "DirectX SDK include path")
ENDIF()
SET(SAMPLERENDERER_COMPILE_DEFS
# Common to all configurations
${PHYSX_WINDOWS_COMPILE_DEFS};${SAMPLES_WINDOWS_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_WINDOWS_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_WINDOWS_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_WINDOWS_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_WINDOWS_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLE_NULLRENDERER_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/src/null)
SET(SAMPLERENDERER_NULLRENDERER_SOURCES
${SAMPLE_NULLRENDERER_DIR}/NULLRenderer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRenderer.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererDirectionalLight.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererDirectionalLight.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererIndexBuffer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererIndexBuffer.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererInstanceBuffer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererInstanceBuffer.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMaterial.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMaterial.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMesh.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererMesh.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererSpotLight.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererSpotLight.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererTexture2D.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererTexture2D.h
${SAMPLE_NULLRENDERER_DIR}/NULLRendererVertexBuffer.cpp
${SAMPLE_NULLRENDERER_DIR}/NULLRendererVertexBuffer.h
)
SET(SAMPLE_D3D9RENDERER_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/src/d3d9)
SET(SAMPLERENDERER_D3D9RENDERER_SOURCES
${SAMPLE_D3D9RENDERER_DIR}/D3D9Renderer.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9Renderer.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererDirectionalLight.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererDirectionalLight.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererIndexBuffer.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererIndexBuffer.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererInstanceBuffer.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererInstanceBuffer.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererMaterial.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererMaterial.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererMesh.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererMesh.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererSpotLight.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererSpotLight.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererTarget.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererTarget.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererTexture2D.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererTexture2D.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererVertexBuffer.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9RendererVertexBuffer.h
${SAMPLE_D3D9RENDERER_DIR}/D3D9WPFRenderer.cpp
${SAMPLE_D3D9RENDERER_DIR}/D3D9WPFRenderer.h
)
SET(SAMPLE_D3D11RENDERER_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/src/d3d11)
SET(SAMPLERENDERER_D3D11RENDERER_SOURCES
${SAMPLE_D3D11RENDERER_DIR}/D3D11Renderer.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11Renderer.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererDirectionalLight.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererDirectionalLight.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererIndexBuffer.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererIndexBuffer.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererInstanceBuffer.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererInstanceBuffer.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererMaterial.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererMaterial.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererMemoryMacros.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererMesh.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererMesh.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererResourceManager.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererSpotLight.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererSpotLight.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTarget.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTarget.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTexture2D.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTexture2D.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTexture3D.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTexture3D.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTextureCommon.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererTraits.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererUtils.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererUtils.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererVariableManager.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererVariableManager.h
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererVertexBuffer.cpp
${SAMPLE_D3D11RENDERER_DIR}/D3D11RendererVertexBuffer.h
)
SET(SAMPLE_OGLRENDERER_DIR ${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/src/ogl)
SET(SAMPLERENDERER_OGLRENDERER_SOURCES
${PHYSX_ROOT_DIR}/samples/sampleframework/renderer/include/windows/WindowsGLIncludes.h
${SAMPLE_OGLRENDERER_DIR}/OGLRenderer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRenderer.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererDirectionalLight.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererDirectionalLight.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererIndexBuffer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererIndexBuffer.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererInstanceBuffer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererInstanceBuffer.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMaterial.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMaterial.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMesh.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererMesh.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererSpotLight.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererSpotLight.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererTexture2D.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererTexture2D.h
${SAMPLE_OGLRENDERER_DIR}/OGLRendererVertexBuffer.cpp
${SAMPLE_OGLRENDERER_DIR}/OGLRendererVertexBuffer.h
)
SET(SAMPLERENDERER_PLATFORM_SOURCES
${SAMPLERENDERER_NULLRENDERER_SOURCES}
${SAMPLERENDERER_D3D9RENDERER_SOURCES}
${SAMPLERENDERER_D3D11RENDERER_SOURCES}
${SAMPLERENDERER_OGLRENDERER_SOURCES}
)
SET(SAMPLERENDERER_PLATFORM_INCLUDES
${DIRECTX_INCLUDE_DIRS}
)

View File

@ -0,0 +1,43 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build Samples
#
SET(SAMPLES_COMPILE_DEFS
# Common to all configurations
${PHYSX_WINDOWS_COMPILE_DEFS};${SAMPLES_WINDOWS_COMPILE_DEFS};_HAS_EXCEPTIONS=0;
$<$<CONFIG:debug>:${PHYSX_WINDOWS_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_WINDOWS_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_WINDOWS_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_WINDOWS_RELEASE_COMPILE_DEFS};>
)
SET(SAMPLES_PLATFORM_LINKED_LIBS Winmm.lib)

View File

@ -0,0 +1,48 @@
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions
## are met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above copyright
## notice, this list of conditions and the following disclaimer in the
## documentation and/or other materials provided with the distribution.
## * Neither the name of NVIDIA CORPORATION nor the names of its
## contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
## EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
## PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
## EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
## PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
## PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
## OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#
# Build PxToolkit
#
SET(SAMPLETOOLKIT_PLATFORM_SOURCE_FILES
)
SET(SAMPLETOOLKIT_PLATFORM_INCLUDES
)
SET(SAMPLETOOLKIT_COMPILE_DEFS
# Common to all configurations
${PHYSX_WINDOWS_COMPILE_DEFS};${SAMPLES_WINDOWS_COMPILE_DEFS};
$<$<CONFIG:debug>:${PHYSX_WINDOWS_DEBUG_COMPILE_DEFS};>
$<$<CONFIG:checked>:${PHYSX_WINDOWS_CHECKED_COMPILE_DEFS};>
$<$<CONFIG:profile>:${PHYSX_WINDOWS_PROFILE_COMPILE_DEFS};>
$<$<CONFIG:release>:${PHYSX_WINDOWS_RELEASE_COMPILE_DEFS};>
)

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,718 @@
# 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware
# File Created: 30.05.2012 13:18:35
mtllib barn.mtl
#
# object ID106
#
v -0.082183 0.000000 0.100946
v -0.082183 -0.042783 0.100946
v -0.082183 0.000000 -0.035483
v -0.082183 -0.042783 -0.035483
v -0.136332 0.000000 0.100946
v -0.136332 0.000000 -0.035483
v -0.136332 -0.042783 -0.035483
v -0.136332 -0.042783 0.077346
v -0.136332 -0.042783 0.100946
v -0.120540 -0.021399 0.100946
v -0.120540 0.000000 0.100946
v -0.096807 -0.021399 0.100946
v -0.096807 0.000000 0.100946
v -0.096845 -0.042783 -0.035483
v -0.096845 -0.032718 -0.035483
v -0.118784 -0.032718 -0.035483
v -0.090068 -0.023939 -0.035483
v -0.090068 0.000000 -0.035483
v -0.118784 -0.042783 -0.035483
v -0.126993 -0.023939 -0.035483
v -0.126993 0.000000 -0.035483
v -0.118784 -0.055721 -0.008189
v -0.096892 -0.055721 -0.008189
v -0.096892 -0.055721 0.077481
v -0.118770 -0.055721 0.077454
v -0.096807 0.000000 0.098185
v -0.090068 0.000000 -0.034239
v -0.090068 -0.023939 -0.034239
v -0.126993 -0.023939 -0.034239
v -0.126993 0.000000 -0.034239
v -0.096807 -0.021399 0.098185
v -0.120540 0.000000 0.098185
v -0.120540 -0.021399 0.098185
v -0.118784 -0.032718 -0.034239
v -0.096845 -0.032718 -0.034239
v -0.096845 -0.042783 -0.034239
v -0.118784 -0.042783 -0.034239
v -0.000680 0.000000 0.229454
v -0.000680 -0.023986 0.229454
v 0.029401 0.000000 0.229454
v 0.029401 -0.023986 0.229454
v -0.000680 0.000000 0.199095
v 0.029401 0.000000 0.199095
v 0.029401 -0.023986 0.199095
v -0.000680 -0.023986 0.199095
v -0.000680 -0.019623 0.207949
v -0.000680 0.000000 0.207949
v -0.000680 -0.019623 0.221254
v -0.000680 0.000000 0.221254
v 0.029401 -0.021047 0.225033
v 0.029401 0.000000 0.225033
v 0.029401 -0.021047 0.204331
v 0.029401 0.000000 0.204331
v 0.013287 -0.031240 0.221207
v 0.013295 -0.031240 0.208938
v 0.000868 0.000000 0.221254
v 0.028703 0.000000 0.225033
v 0.028703 -0.021047 0.225033
v 0.028703 -0.021047 0.204331
v 0.028703 0.000000 0.204331
v 0.000868 -0.019623 0.221254
v 0.000868 0.000000 0.207949
v 0.000868 -0.019623 0.207949
v -0.146629 -0.010703 -0.125923
v -0.147899 -0.010703 -0.125923
v -0.147899 0.000000 -0.125923
v -0.146629 0.000000 -0.125923
v -0.146629 0.000000 -0.127193
v -0.146629 -0.010703 -0.127193
# 69 vertices
vn 1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 0.000000 1.000000
vn 0.000001 0.000000 1.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.660445 -0.750874 0.000000
vn 0.660445 -0.750875 0.000000
vn 0.000000 -0.903622 -0.428331
vn -0.593413 -0.804898 0.000071
vn -0.593529 -0.804812 0.000099
vn -0.593150 -0.805092 0.000008
vn -0.593118 -0.805116 0.000000
vn -0.000244 -0.875781 0.482708
vn 0.000000 -0.875942 0.482417
vn -0.000175 -0.875826 0.482627
vn -0.000598 -0.875548 0.483131
vn 0.000000 1.000000 0.000000
vn -1.000000 0.000000 -0.000006
vn 0.000000 1.000000 0.000002
vn 1.000000 0.000000 0.000019
vn 1.000000 0.000000 0.000018
vn 1.000000 0.000001 0.000006
vn 1.000000 0.000001 0.000007
vn 1.000000 0.000000 -0.000003
vn -1.000000 0.000000 0.000003
vn 0.000000 1.000000 0.000003
vn 1.000000 0.000000 0.000012
vn 0.000000 -1.000000 -0.000003
vn -0.000001 0.000000 -1.000000
vn 0.000000 -0.750875 0.660445
vn 0.410762 -0.911743 0.000254
vn 0.410578 -0.911825 0.000093
vn 0.410472 -0.911873 0.000000
vn 0.410569 -0.911829 0.000085
vn 0.000000 -0.805001 -0.593273
vn -0.460824 -0.887491 -0.000113
vn -0.460693 -0.887560 0.000000
vn -0.460794 -0.887507 -0.000087
vn -0.461022 -0.887388 -0.000285
vn -0.000044 0.000000 1.000000
vn -0.000022 0.000001 1.000000
vn -0.000023 0.000001 1.000000
vn 0.000000 -0.000001 -1.000000
# 44 vertex normals
vt 0.068504 0.016855 0.000000
vt 0.067352 0.016855 0.000000
vt 0.068504 0.013182 0.000000
vt 0.067352 0.013182 0.000000
vt 0.064497 0.016855 0.000000
vt 0.064497 0.013182 0.000000
vt 0.065649 0.013182 0.000000
vt 0.065649 0.016220 0.000000
vt 0.065649 0.016855 0.000000
vt 0.067221 0.016945 0.000000
vt 0.066188 0.017520 0.000000
vt 0.065763 0.016945 0.000000
vt 0.065763 0.018096 0.000000
vt 0.066188 0.018096 0.000000
vt 0.066827 0.017520 0.000000
vt 0.066827 0.018096 0.000000
vt 0.067221 0.018096 0.000000
vt 0.066826 0.013104 0.000000
vt 0.066826 0.012833 0.000000
vt 0.067221 0.013104 0.000000
vt 0.066236 0.012833 0.000000
vt 0.067009 0.012596 0.000000
vt 0.067221 0.011952 0.000000
vt 0.067009 0.011952 0.000000
vt 0.066236 0.013104 0.000000
vt 0.065763 0.013104 0.000000
vt 0.066015 0.012596 0.000000
vt 0.066015 0.011952 0.000000
vt 0.065763 0.011952 0.000000
vt 0.066236 0.013917 0.000000
vt 0.066825 0.013917 0.000000
vt 0.066825 0.016223 0.000000
vt 0.066236 0.016223 0.000000
vt 0.068898 0.016781 0.000000
vt 0.068898 0.016855 0.000000
vt 0.068717 0.013215 0.000000
vt 0.068717 0.013182 0.000000
vt 0.068717 0.012571 0.000000
vt 0.069711 0.012571 0.000000
vt 0.069711 0.013215 0.000000
vt 0.068898 0.017357 0.000000
vt 0.069537 0.016781 0.000000
vt 0.069537 0.017357 0.000000
vt 0.069962 0.016855 0.000000
vt 0.069537 0.016855 0.000000
vt 0.069962 0.013182 0.000000
vt 0.069711 0.013182 0.000000
vt 0.066202 0.012833 0.000000
vt 0.066793 0.012833 0.000000
vt 0.066793 0.013104 0.000000
vt 0.066202 0.013104 0.000000
vt 0.066975 0.012596 0.000000
vt 0.066975 0.011952 0.000000
vt 0.066015 0.012563 0.000000
vt 0.067009 0.012563 0.000000
vt 0.069066 0.013215 0.000000
vt 0.069066 0.013182 0.000000
vt 0.066263 0.017520 0.000000
vt 0.066263 0.018096 0.000000
vt 0.066827 0.017595 0.000000
vt 0.066188 0.017595 0.000000
vt 0.066753 0.018096 0.000000
vt 0.066753 0.017520 0.000000
vt 0.066826 0.013694 0.000000
vt 0.066793 0.013694 0.000000
vt 0.066269 0.012833 0.000000
vt 0.066269 0.013104 0.000000
vt 0.066826 0.012866 0.000000
vt 0.066236 0.012866 0.000000
vt 0.066018 0.016491 0.000000
vt 0.066018 0.015222 0.000000
vt 0.067609 0.016491 0.000000
vt 0.067609 0.015222 0.000000
vt 0.066727 0.011952 0.000000
vt 0.068246 0.012426 0.000000
vt 0.067868 0.013637 0.000000
vt 0.066349 0.013163 0.000000
vt 0.065632 0.014600 0.000000
vt 0.065933 0.013479 0.000000
vt 0.065214 0.012596 0.000000
vt 0.065005 0.013016 0.000000
vt 0.065619 0.014109 0.000000
vt 0.064690 0.013645 0.000000
vt 0.064497 0.014033 0.000000
vt 0.067800 0.015016 0.000000
vt 0.068862 0.015426 0.000000
vt 0.068899 0.015195 0.000000
vt 0.067977 0.013935 0.000000
vt 0.069075 0.014114 0.000000
vt 0.069120 0.013841 0.000000
vt 0.066757 0.014641 0.000000
vt 0.066862 0.014000 0.000000
vt 0.066572 0.014581 0.000000
vt 0.066100 0.016924 0.000000
vt 0.066018 0.016924 0.000000
vt 0.067573 0.016724 0.000000
vt 0.067609 0.016724 0.000000
vt 0.068686 0.016724 0.000000
vt 0.068686 0.017819 0.000000
vt 0.067573 0.017819 0.000000
vt 0.065062 0.016924 0.000000
vt 0.066100 0.017628 0.000000
vt 0.065062 0.017628 0.000000
vt 0.066018 0.018096 0.000000
vt 0.066018 0.017628 0.000000
vt 0.067609 0.018096 0.000000
vt 0.067609 0.017819 0.000000
vt 0.067806 0.014980 0.000000
vt 0.068905 0.015159 0.000000
vt 0.068013 0.013941 0.000000
vt 0.067837 0.015022 0.000000
vt 0.069070 0.014151 0.000000
vt 0.067971 0.013972 0.000000
vt 0.065897 0.013552 0.000000
vt 0.064968 0.013089 0.000000
vt 0.065546 0.014072 0.000000
vt 0.065860 0.013442 0.000000
vt 0.064727 0.013572 0.000000
vt 0.065656 0.014035 0.000000
vt 15.460242 0.000000 0.000000
# 120 texture coords
g ID106
usemtl Color_A11_
s 1
f 1/1/1 2/2/1 3/3/1
f 4/4/1 3/3/1 2/2/1
f 5/5/2 6/6/2 7/7/2
f 7/7/2 8/8/2 5/5/2
f 8/8/2 9/9/2 5/5/2
s 2
f 2/10/3 10/11/3 9/12/3
f 9/12/3 10/11/3 5/13/3
f 11/14/3 5/13/3 10/11/3
f 10/11/3 2/10/3 12/15/3
f 12/15/3 2/10/3 13/16/3
f 1/17/4 13/16/3 2/10/3
f 14/18/5 15/19/5 4/20/5
f 16/21/5 17/22/5 15/19/5
f 15/19/5 17/22/5 4/20/5
f 4/20/5 17/22/5 3/23/5
f 18/24/5 3/23/5 17/22/5
f 19/25/5 7/26/5 16/21/5
f 17/22/5 16/21/5 20/27/5
f 16/21/5 7/26/5 20/27/5
f 20/27/5 7/26/5 21/28/5
f 6/29/5 21/28/5 7/26/5
usemtl Color_007_
s 1
f 22/30/6 23/31/6 24/32/6
s 4
f 24/32/7 23/31/8 2/2/8
f 23/31/8 4/4/8 2/2/8
s 8
f 22/30/9 7/26/9 19/25/9
f 19/25/9 14/18/9 23/31/9
f 14/18/9 4/20/9 23/31/9
s 4
f 7/7/10 22/30/11 25/33/12
s 1
f 25/33/6 22/30/6 24/32/6
s 8
f 23/31/9 22/30/9 19/25/9
s 4
f 8/8/13 7/7/10 25/33/12
f 25/33/12 9/9/13 8/8/13
s 8
f 2/10/14 9/12/15 25/33/16
f 25/33/16 24/32/17 2/10/14
usemtl Color_A11_
s 4
f 26/34/18 13/35/18 1/1/18 27/36/18
f 27/36/18 1/1/18 3/3/18 18/37/18
usemtl Color_007_
s 1
f 28/38/5 29/39/5 30/40/5 27/36/5
f 31/41/3 26/34/3 32/42/3 33/43/3
usemtl Color_A11_
s 4
f 5/44/18 11/45/18 32/42/18 6/46/18
f 30/40/18 21/47/18 6/46/18 32/42/18
usemtl Color_007_
s 1
f 34/48/5 35/49/5 36/50/5 37/51/5
s 8
f 17/22/19 28/52/19 27/53/19 18/24/19
s 4
f 20/27/20 29/54/20 28/55/20 17/22/20
s 8
f 21/47/21 30/40/22 29/56/23 20/57/24
f 10/11/1 33/58/1 32/59/25 11/14/25
s 4
f 12/15/18 31/60/18 33/61/18 10/11/18
s 8
f 13/16/26 26/62/26 31/63/2 12/15/2
s 4
f 14/18/19 36/50/19 35/49/19 15/19/19
s 16
f 19/64/27 37/65/27 36/50/27 14/18/27
s 4
f 16/21/28 34/66/28 37/67/28 19/25/28
s 8
f 15/19/29 35/68/29 34/69/29 16/21/29
usemtl Color_A11_
s 4
f 26/34/18 27/36/18 30/40/18 32/42/18
s 1
f 38/70/3 39/71/3 40/72/3
f 41/73/3 40/72/3 39/71/3
f 42/74/30 43/75/30 44/76/30
f 44/76/30 45/77/30 42/74/30
s 2
f 39/78/2 46/79/2 45/77/2
f 45/77/2 46/79/2 42/80/2
f 47/81/2 42/80/2 46/79/2
f 46/79/2 39/78/2 48/82/2
f 48/82/2 39/78/2 49/83/2
f 38/84/2 49/83/2 39/78/2
f 41/73/1 50/85/1 40/86/1
f 51/87/1 40/86/1 50/85/1
f 52/88/1 44/76/1 53/89/1
f 43/90/1 53/89/1 44/76/1
usemtl Color_007_
s 4
f 54/91/31 41/73/31 39/71/31
s 8
f 55/92/32 44/76/33 41/73/34 54/91/35
s 4
f 44/76/36 55/92/36 45/77/36
s 16
f 39/78/37 45/77/38 55/92/39
f 55/92/39 54/93/40 39/78/37
usemtl Color_A11_
s 4
f 56/94/18 49/95/18 38/70/18 57/96/18
f 57/96/18 38/70/18 40/72/18 51/97/18
usemtl Color_007_
s 1
f 58/98/1 59/99/1 60/100/1 57/96/1
f 61/101/2 56/94/2 62/102/2 63/103/2
usemtl Color_A11_
s 4
f 42/104/18 47/105/18 62/102/18 43/106/18
f 60/100/18 53/107/18 43/106/18 62/102/18
s 2
f 52/88/1 50/85/1 41/73/1 44/76/1
usemtl Color_007_
s 8
f 50/85/5 58/108/5 57/109/5 51/87/5
s 4
f 52/88/18 59/110/18 58/111/18 50/85/18
s 8
f 53/89/41 60/112/41 59/113/42 52/88/43
f 46/79/3 63/114/3 62/115/3 47/81/3
s 4
f 48/82/18 61/116/18 63/117/18 46/79/18
s 8
f 49/83/5 56/118/5 61/119/5 48/82/5
usemtl Color_A11_
s 4
f 56/94/18 57/96/18 60/100/18 62/102/18
usemtl Fencing_Picket_Concave_
s 1
f 64/120/44 65/120/44 66/120/44 67/120/44
f 67/120/2 68/120/2 69/120/2 64/120/2
# 35 polygons - 52 triangles
#
# object Object001
#
v 0.081139 0.000000 0.236512
v -0.000803 0.000000 0.236884
v -0.000803 -0.010703 0.236884
v 0.081139 -0.010703 0.236512
v -0.000803 -0.010703 0.235614
v -0.000803 0.000000 0.235614
v 0.080241 0.000000 0.235614
v 0.080241 -0.010703 0.235614
# 8 vertices
vn 0.004540 0.000000 0.999990
vn 0.000000 0.000000 -1.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn -1.000000 0.000001 0.000000
# 5 vertex normals
vt -5.265154 0.000000 0.000000
vt 0.052684 0.000000 0.000000
vt 0.052684 1.003295 0.000000
vt -5.265154 1.003294 0.000000
vt 15.460242 0.000000 0.000000
# 5 texture coords
g Object001
usemtl Fencing_Picket_Concave_
s 1
f 70/121/45 71/122/45 72/123/45 73/124/45
f 74/123/46 75/122/46 76/121/46 77/124/46
s 2
f 71/125/47 70/125/47 76/125/47 75/125/47
f 73/125/48 72/125/48 74/125/48 77/125/48
s 4
f 71/125/49 75/125/49 74/125/49 72/125/49
# 5 polygons
#
# object Object002
#
v -0.147511 -0.010703 0.236512
v -0.029710 -0.010703 0.236884
v -0.029710 0.000000 0.236884
v -0.147511 0.000000 0.236512
v -0.029710 0.000000 0.235614
v -0.029710 -0.010703 0.235614
v -0.146613 -0.010703 0.235614
v -0.146613 0.000000 0.235614
# 8 vertices
vn -0.003158 0.000000 0.999995
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 1.000000 -0.000002 0.000000
vn 0.000000 1.000000 0.000000
# 5 vertex normals
vt 9.620263 1.003294 0.000000
vt 1.949500 1.003293 0.000000
vt 1.949499 -0.000001 0.000000
vt 9.620263 0.000000 0.000000
vt 15.460242 0.000000 0.000000
# 5 texture coords
g Object002
usemtl Fencing_Picket_Concave_
s 1
f 78/126/50 79/127/50 80/128/50 81/129/50
f 82/128/51 83/127/51 84/126/51 85/129/51
s 2
f 79/130/52 78/130/52 84/130/52 83/130/52
s 4
f 79/130/53 83/130/53 82/130/53 80/130/53
s 2
f 81/130/54 80/130/54 82/130/54 85/130/54
# 5 polygons
#
# object Object003
#
v -0.147511 0.000000 0.236512
v -0.147883 0.000000 0.123473
v -0.147883 -0.010703 0.123473
v -0.147511 -0.010703 0.236512
v -0.146613 -0.010703 0.123473
v -0.146613 0.000000 0.123473
v -0.146613 0.000000 0.235614
v -0.146613 -0.010703 0.235614
# 8 vertices
vn -0.999995 0.000000 0.003291
vn 1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
# 5 vertex normals
vt -15.460242 0.000000 0.000000
vt -8.101910 0.000000 0.000000
vt -8.101910 1.003294 0.000000
vt -15.460242 1.003294 0.000000
vt 15.460242 0.000000 0.000000
# 5 texture coords
g Object003
usemtl Fencing_Picket_Concave_
s 1
f 86/131/55 87/132/55 88/133/55 89/134/55
f 90/133/56 91/132/56 92/131/56 93/134/56
s 2
f 87/135/57 86/135/57 92/135/57 91/135/57
s 4
f 87/135/58 91/135/58 90/135/58 88/135/58
s 2
f 89/135/59 88/135/59 90/135/59 93/135/59
# 5 polygons
#
# object Object004
#
v -0.147899 -0.010703 0.100947
v -0.147899 0.000000 0.100947
v -0.147899 0.000000 -0.125923
v -0.147899 -0.010703 -0.125923
v -0.146629 0.000000 -0.125923
v -0.146629 0.000000 0.100947
v -0.146629 -0.010703 0.100947
v -0.146629 -0.010703 -0.125923
# 8 vertices
vn -1.000000 0.000000 0.000000
vn 1.000000 0.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 0.000000 1.000000
vn 0.000000 1.000000 0.000000
# 5 vertex normals
vt -6.623784 1.003294 0.000000
vt -6.623784 0.000000 0.000000
vt 8.262674 0.000000 0.000000
vt 8.262673 1.003294 0.000000
vt 15.460242 0.000000 0.000000
# 5 texture coords
g Object004
usemtl Fencing_Picket_Concave_
s 1
f 94/136/60 95/137/60 96/138/60 97/139/60
f 98/138/61 99/137/61 100/136/61 101/139/61
s 2
f 100/140/62 94/140/62 97/140/62 101/140/62
s 4
f 95/140/63 94/140/63 100/140/63 99/140/63
s 2
f 95/140/64 99/140/64 98/140/64 96/140/64
# 5 polygons
#
# object Object005
#
v -0.146629 -0.010703 -0.127193
v -0.146629 0.000000 -0.127193
v -0.120441 0.000000 -0.127193
v -0.120441 -0.010703 -0.127193
v -0.120441 0.000000 -0.125923
v -0.146629 0.000000 -0.125923
v -0.146629 -0.010703 -0.125923
v -0.120441 -0.010703 -0.125923
# 8 vertices
vn 0.000000 -0.000001 -1.000000
vn 0.000000 0.000001 1.000000
vn 0.000000 -1.000000 0.000001
vn 0.000000 1.000000 -0.000001
vn 1.000000 0.000000 0.000000
# 5 vertex normals
vt -9.621305 1.003288 0.000000
vt -9.621305 -0.000006 0.000000
vt -7.902966 -0.000006 0.000000
vt -7.902966 1.003288 0.000000
vt 15.460242 0.000000 0.000000
# 5 texture coords
g Object005
usemtl Fencing_Picket_Concave_
s 1
f 102/141/65 103/142/65 104/143/65 105/144/65
f 106/143/66 107/142/66 108/141/66 109/144/66
s 2
f 108/145/67 102/145/67 105/145/67 109/145/67
f 103/145/68 107/145/68 106/145/68 104/145/68
s 4
f 105/145/69 104/145/69 106/145/69 109/145/69
# 5 polygons
#
# object Object006
#
v -0.089151 0.000000 -0.127193
v 0.081139 0.000000 -0.126821
v 0.081139 -0.010703 -0.126821
v -0.089151 -0.010703 -0.127193
v 0.080241 -0.010703 -0.125923
v 0.080241 0.000000 -0.125923
v -0.089151 0.000000 -0.125923
v -0.089151 -0.010703 -0.125923
# 8 vertices
vn 0.002184 -0.000001 -0.999998
vn 0.000000 0.000001 1.000000
vn -1.000000 0.000000 0.000000
vn 0.000000 1.000000 -0.000001
vn 0.000000 -1.000000 0.000001
# 5 vertex normals
vt -5.849831 -0.000003 0.000000
vt 5.264511 -0.000003 0.000000
vt 5.264849 1.003292 0.000000
vt -5.849831 1.003292 0.000000
vt 15.460242 0.000000 0.000000
# 5 texture coords
g Object006
usemtl Fencing_Picket_Concave_
s 1
f 110/146/70 111/147/70 112/148/70 113/149/70
f 114/148/71 115/147/71 116/146/71 117/149/71
s 2
f 116/150/72 110/150/72 113/150/72 117/150/72
s 4
f 111/150/73 110/150/73 116/150/73 115/150/73
f 113/150/74 112/150/74 114/150/74 117/150/74
# 5 polygons
#
# object Object007
#
v 0.081139 0.000000 -0.126821
v 0.081511 0.000000 0.061702
v 0.081511 -0.010703 0.061702
v 0.081139 -0.010703 -0.126821
v 0.080241 -0.010703 0.061702
v 0.080241 0.000000 0.061702
v 0.080241 0.000000 -0.125923
v 0.080241 -0.010703 -0.125923
# 8 vertices
vn 0.999998 0.000000 -0.001973
vn -1.000000 0.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000001 1.000000 0.000000
vn 0.000000 0.000000 1.000000
vn -0.000001 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
# 7 vertex normals
vt -8.262674 0.000000 0.000000
vt 4.048695 0.000000 0.000000
vt 4.048696 1.003294 0.000000
vt -8.262673 1.003294 0.000000
vt 15.460242 0.000000 0.000000
# 5 texture coords
g Object007
usemtl Fencing_Picket_Concave_
s 1
f 118/151/75 119/152/75 120/153/75 121/154/75
f 122/153/76 123/152/76 124/151/76 125/154/76
s 2
f 119/155/77 118/155/78 124/155/78 123/155/77
s 4
f 119/155/79 123/155/79 122/155/79 120/155/79
s 2
f 121/155/80 120/155/81 122/155/81 125/155/80
# 5 polygons
#
# object Object008
#
v 0.081511 0.000000 0.090732
v 0.081139 0.000000 0.236512
v 0.081139 -0.010703 0.236512
v 0.081511 -0.010703 0.090732
v 0.080241 -0.010703 0.235614
v 0.080241 0.000000 0.235614
v 0.080241 0.000000 0.090732
v 0.080241 -0.010703 0.090732
# 8 vertices
vn 0.999997 0.000000 0.002552
vn -1.000000 0.000000 0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 -1.000000 0.000000
# 5 vertex normals
vt 5.953518 0.000001 0.000000
vt 15.460242 0.000000 0.000000
vt 15.460242 1.003294 0.000000
vt 5.953519 1.003297 0.000000
# 4 texture coords
g Object008
usemtl Fencing_Picket_Concave_
s 1
f 126/156/82 127/157/82 128/158/82 129/159/82
f 130/158/83 131/157/83 132/156/83 133/159/83
s 2
f 132/157/84 126/157/84 129/157/84 133/157/84
s 4
f 127/157/85 126/157/85 132/157/85 131/157/85
f 129/157/86 128/157/86 130/157/86 133/157/86
# 5 polygons

Binary file not shown.

Binary file not shown.

Binary file not shown.

4784
physx/samples/media/city.obj Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

43304
physx/samples/media/tree.obj Normal file

File diff suppressed because it is too large Load Diff

View File

View File

@ -0,0 +1,57 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOOLKIT_BMP_LOADER_H
#define PX_TOOLKIT_BMP_LOADER_H
#include "extensions/PxDefaultStreams.h"
namespace PxToolkit
{
class BmpLoader
{
public:
BmpLoader(void);
~BmpLoader(void);
// returns true if success. Data is persists until the class is destructed.
bool loadBmp(const char* filename);
bool loadBmp(PxFileHandle f);
int mWidth;
int mHeight;
unsigned char* mRGB;
bool mHasAlpha;
};
}
#endif

View File

@ -0,0 +1,61 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOOLKIT_FPS_H
#define PX_TOOLKIT_FPS_H
#include "common/PxPhysXCommonConfig.h"
#include "PsTime.h"
namespace PxToolkit
{
using namespace physx;
class FPS
{
public:
FPS();
~FPS();
void update();
PX_FORCE_INLINE float getFPS() const { return mFPS; }
PX_FORCE_INLINE float getInstantFPS() const { return mInstantFPS; }
private:
shdfnd::Time mTimer;
shdfnd::Time mTimer2;
PxReal mFPS;
PxReal mInstantFPS;
PxU32 mFrames;
PxU32 mFrames2;
};
}
#endif

View File

@ -0,0 +1,86 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOOLKIT_FILE_H
#define PX_TOOLKIT_FILE_H
#include "foundation/PxSimpleTypes.h"
// fopen_s - returns 0 on success, non-zero on failure
#if PX_MICROSOFT_FAMILY
#include <stdio.h>
namespace PxToolkit
{
PX_INLINE physx::PxI32 fopen_s(FILE** file, const char* name, const char* mode)
{
static const physx::PxU32 MAX_LEN = 300;
char buf[MAX_LEN+1];
physx::PxU32 i;
for(i = 0; i<MAX_LEN && name[i]; i++)
buf[i] = name[i] == '/' ? '\\' : name[i];
buf[i] = 0;
return i == MAX_LEN ? -1 : ::fopen_s(file, buf, mode);
};
} // namespace PxToolkit
#elif PX_UNIX_FAMILY || PX_PS4 || PX_SWITCH
#include <stdio.h>
namespace PxToolkit
{
PX_INLINE physx::PxI32 fopen_s(FILE** file, const char* name, const char* mode)
{
FILE* fp = ::fopen(name, mode);
if (fp)
{
*file = fp;
return 0;
}
return -1;
}
} // PxToolkit
#else
#error "Platform not supported!"
#endif
#endif //PX_TOOLKIT_FILE_H

View File

@ -0,0 +1,48 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOOLKIT_MATRIX_UTILS_H
#define PX_TOOLKIT_MATRIX_UTILS_H
#include "common/PxPhysXCommonConfig.h"
#include "foundation/PxMat33.h"
namespace PxToolkit
{
using namespace physx;
void setRotX(PxMat33& m, PxReal angle);
void setRotY(PxMat33& m, PxReal angle);
void setRotZ(PxMat33& m, PxReal angle);
PxQuat getRotXQuat(float angle);
PxQuat getRotYQuat(float angle);
PxQuat getRotZQuat(float angle);
}
#endif

View File

@ -0,0 +1,39 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOOLKIT_NAMESPACE_MANGLE_H
#define PX_TOOLKIT_NAMESPACE_MANGLE_H
#include "Ps.h"
namespace physx {
namespace Ps = shdfnd;
// we need this until all our code lives in physx namespace
}
#endif

View File

@ -0,0 +1,137 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOOLKIT_RANDOM_H
#define PX_TOOLKIT_RANDOM_H
#include "common/PxPhysXCommonConfig.h"
#define TEST_MAX_RAND 0xffff
namespace PxToolkit
{
using namespace physx;
class BasicRandom
{
public:
BasicRandom(PxU32 seed=0) : mRnd(seed) {}
~BasicRandom() {}
PX_FORCE_INLINE void setSeed(PxU32 seed) { mRnd = seed; }
PX_FORCE_INLINE PxU32 getCurrentValue() const { return mRnd; }
PxU32 randomize() { mRnd = mRnd * 2147001325 + 715136305; return mRnd; }
PX_FORCE_INLINE PxU32 rand() { return randomize() & 0xffff; }
PX_FORCE_INLINE PxU32 rand32() { return randomize() & 0xffffffff; }
PxF32 rand(PxF32 a, PxF32 b)
{
const PxF32 r = rand32()/(static_cast<PxF32>(0xffffffff));
return r*(b-a) + a;
}
PxI32 rand(PxI32 a, PxI32 b)
{
return a + static_cast<PxI32>(rand32()%(b-a));
}
PxF32 randomFloat()
{
return rand()/(static_cast<PxF32>(0xffff)) - 0.5f;
}
PxF32 randomFloat32()
{
return rand32()/(static_cast<PxF32>(0xffffffff)) - 0.5f;
}
PxF32 randomFloat32(PxReal a, PxReal b) { return rand32()/PxF32(0xffffffff)*(b-a)+a; }
void unitRandomPt(physx::PxVec3& v);
void unitRandomQuat(physx::PxQuat& v);
PxVec3 unitRandomPt();
PxQuat unitRandomQuat();
private:
PxU32 mRnd;
};
//--------------------------------------
// Fast, very good random numbers
//
// Period = 2^249
//
// Kirkpatrick, S., and E. Stoll, 1981; A Very Fast Shift-Register
// Sequence Random Number Generator, Journal of Computational Physics,
// V. 40.
//
// Maier, W.L., 1991; A Fast Pseudo Random Number Generator,
// Dr. Dobb's Journal, May, pp. 152 - 157
class RandomR250
{
public:
RandomR250(PxI32 s);
void setSeed(PxI32 s);
PxU32 randI();
PxReal randUnit();
PxReal rand(PxReal lower, PxReal upper)
{
return lower + randUnit() * (upper - lower);
}
private:
PxU32 mBuffer[250];
PxI32 mIndex;
};
void SetSeed(PxU32 seed);
PxU32 Rand();
PX_INLINE PxF32 Rand(PxF32 a,PxF32 b)
{
const PxF32 r = static_cast<PxF32>(Rand())/(static_cast<PxF32>(TEST_MAX_RAND));
return r*(b-a) + a;
}
PX_INLINE PxF32 RandLegacy(PxF32 a,PxF32 b)
{
const PxF32 r = static_cast<PxF32>(Rand())/(static_cast<PxF32>(0x7fff)+1.0f);
return r*(b-a) + a;
}
//returns numbers from [a, b-1]
PX_INLINE PxI32 Rand(PxI32 a,PxI32 b)
{
return a + static_cast<PxI32>(Rand()%(b-a));
}
}
#endif

View File

@ -0,0 +1,60 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PX_TOOLKIT_STREAM_H
#define PX_TOOLKIT_STREAM_H
#include "extensions/PxDefaultStreams.h"
#include "cooking/PxCooking.h"
namespace physx
{
class PxTriangleMesh;
class PxConvexMesh;
class PxPhysics;
class PxCooking;
class PxTriangleMeshDesc;
}
namespace PxToolkit
{
using namespace physx;
// temporarily located here
physx::PxTriangleMesh* createTriangleMesh32(physx::PxPhysics& physics, physx::PxCooking& cooking, const PxVec3* verts, PxU32 vertCount, const PxU32* indices32, PxU32 triCount, bool insert = false);
physx::PxConvexMesh* createConvexMesh(physx::PxPhysics& physics, physx::PxCooking& cooking, const PxVec3* verts, PxU32 vertCount, PxConvexFlags flags);
physx::PxConvexMesh* createConvexMeshSafe(physx::PxPhysics& physics, physx::PxCooking& cooking, const PxVec3* verts, PxU32 vertCount, PxConvexFlags flags, PxU32 vLimit = 256);
//this function is for MultiMaterial and MultiMaterialTerrain
physx::PxTriangleMesh* createTriangleMesh32(physx::PxPhysics& physics, physx::PxCooking& cooking, physx::PxTriangleMeshDesc* meshDesc, bool insert = false);
}
#endif

View File

@ -0,0 +1,34 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxTkRandom.h"
#include "PxTkFPS.h"
#include "PxTkStream.h"
#include "PxTkBmpLoader.h"
#include "PxTkMatrixUtils.h"

View File

@ -0,0 +1,200 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "PxTkBmpLoader.h"
#include "PxTkFile.h"
using namespace PxToolkit;
#define MAKETWOCC(a,b) ( (static_cast<char>(a)) | ((static_cast<char>(b))<< 8) )
static bool isBigEndian() { int i = 1; return *(reinterpret_cast<char*>(&i))==0; }
static unsigned short endianSwap(unsigned short nValue)
{
return (((nValue>> 8)) | (nValue << 8));
}
static unsigned int endianSwap(unsigned int i)
{
unsigned char b1, b2, b3, b4;
b1 = i & 255;
b2 = ( i >> 8 ) & 255;
b3 = ( i>>16 ) & 255;
b4 = ( i>>24 ) & 255;
return (static_cast<unsigned int>(b1) << 24) + (static_cast<unsigned int>(b2) << 16) + (static_cast<unsigned int>(b3) << 8) + b4;
}
// -------------------------------------------------------------------
#pragma pack(1)
struct BMPHEADER {
unsigned short Type;
unsigned int Size;
unsigned short Reserved1;
unsigned short Reserved2;
unsigned int OffBits;
};
// Only Win3.0 BMPINFO (see later for OS/2)
struct BMPINFO {
unsigned int Size;
unsigned int Width;
unsigned int Height;
unsigned short Planes;
unsigned short BitCount;
unsigned int Compression;
unsigned int SizeImage;
unsigned int XPelsPerMeter;
unsigned int YPelsPerMeter;
unsigned int ClrUsed;
unsigned int ClrImportant;
};
#pragma pack()
// Compression Type
#define BI_RGB 0L
#define BI_RLE8 1L
#define BI_RLE4 2L
// -------------------------------------------------------------------
BmpLoader::BmpLoader() :
mWidth (0),
mHeight (0),
mRGB (NULL),
mHasAlpha (false)
{
}
// -------------------------------------------------------------------
BmpLoader::~BmpLoader()
{
if (mRGB) free(mRGB);
}
// -------------------------------------------------------------------
bool BmpLoader::loadBmp(PxFileHandle f)
{
if (!f) return false;
if (mRGB) {
free(mRGB);
mRGB = NULL;
}
mWidth = 0;
mHeight = 0;
size_t num;
BMPHEADER header;
num = fread(&header, 1, sizeof(BMPHEADER), f);
if(isBigEndian()) header.Type = endianSwap(header.Type);
if (num != sizeof(BMPHEADER)) { fclose(f); return false; }
if (header.Type != MAKETWOCC('B','M')) { fclose(f); return false; }
BMPINFO info;
num = fread(&info, 1, sizeof(BMPINFO), f);
if (num != sizeof(BMPINFO)) { fclose(f); return false; }
if(isBigEndian()) info.Size = endianSwap(info.Size);
if(isBigEndian()) info.BitCount = endianSwap(info.BitCount);
if(isBigEndian()) info.Compression = endianSwap(info.Compression);
if(isBigEndian()) info.Width = endianSwap(info.Width);
if(isBigEndian()) info.Height = endianSwap(info.Height);
if (info.Size != sizeof(BMPINFO)) { fclose(f); return false; }
if (info.BitCount != 24 && info.BitCount != 32) { fclose(f); return false; }
if (info.Compression != BI_RGB) { fclose(f); return false; }
mWidth = info.Width;
mHeight = info.Height;
int bytesPerPixel = 0;
if(info.BitCount == 24)
{
mHasAlpha = false;
bytesPerPixel = 3;
}
else if(info.BitCount == 32)
{
mHasAlpha = true;
bytesPerPixel = 4;
}
else assert(0);
mRGB = static_cast<unsigned char*>(malloc(mWidth * mHeight * bytesPerPixel));
int lineLen = (((info.Width * (info.BitCount>>3)) + 3)>>2)<<2;
unsigned char* line = static_cast<unsigned char*>(malloc(lineLen));
for(int i = info.Height-1; i >= 0; i--)
{
num = fread(line, 1, static_cast<size_t>(lineLen), f);
if (num != static_cast<size_t>(lineLen))
{
fclose(f);
free(line);
return false;
}
unsigned char* src = line;
unsigned char* dest = mRGB + i*info.Width*bytesPerPixel;
for(unsigned int j = 0; j < info.Width; j++)
{
unsigned char b = *src++;
unsigned char g = *src++;
unsigned char r = *src++;
unsigned char a = mHasAlpha ? *src++ : 0;
*dest++ = r;
*dest++ = g;
*dest++ = b;
if(mHasAlpha)
*dest++ = a;
}
}
free(line);
return true;
}
// -------------------------------------------------------------------
bool BmpLoader::loadBmp(const char *filename)
{
PxFileHandle f = NULL;
PxToolkit::fopen_s(&f, filename, "rb");
bool ret = loadBmp(f);
if(f) fclose(f);
return ret;
}

View File

@ -0,0 +1,69 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxTkFPS.h"
using namespace PxToolkit;
FPS::FPS()
{
mFrames = 0;
mFrames2 = 0;
mFPS = 0.0f;
mInstantFPS = 0.0f;
}
FPS::~FPS()
{
}
void FPS::update()
{
// Keep track of the time lapse and frame count
mFrames++;
mFrames2++;
// Instant frame rate
PxReal Delta = PxReal(mTimer2.peekElapsedSeconds());
if(Delta > 0.01f)
{
mInstantFPS = PxReal(mFrames2) / Delta;
mTimer2.getElapsedSeconds();
mFrames2 = 0;
}
// Update the frame rate once per second
Delta = PxReal(mTimer.peekElapsedSeconds());
if(Delta > 1.0f)
{
mFPS = PxReal(mFrames) / Delta;
mTimer.getElapsedSeconds();
mFrames = 0;
}
}

View File

@ -0,0 +1,89 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxTkMatrixUtils.h"
using namespace PxToolkit;
void PxToolkit::setRotX(PxMat33& m, PxReal angle)
{
m = PxMat33(PxIdentity);
const PxReal cos = cosf(angle);
const PxReal sin = sinf(angle);
m[1][1] = m[2][2] = cos;
m[1][2] = sin;
m[2][1] = -sin;
}
void PxToolkit::setRotY(PxMat33& m, PxReal angle)
{
m = PxMat33(PxIdentity);
const PxReal cos = cosf(angle);
const PxReal sin = sinf(angle);
m[0][0] = m[2][2] = cos;
m[0][2] = -sin;
m[2][0] = sin;
}
void PxToolkit::setRotZ(PxMat33& m, PxReal angle)
{
m = PxMat33(PxIdentity);
const PxReal cos = cosf(angle);
const PxReal sin = sinf(angle);
m[0][0] = m[1][1] = cos;
m[0][1] = sin;
m[1][0] = -sin;
}
PxQuat PxToolkit::getRotXQuat(float angle)
{
PxMat33 m;
setRotX(m, angle);
return PxQuat(m);
}
PxQuat PxToolkit::getRotYQuat(float angle)
{
PxMat33 m;
setRotY(m, angle);
return PxQuat(m);
}
PxQuat PxToolkit::getRotZQuat(float angle)
{
PxMat33 m;
setRotZ(m, angle);
return PxQuat(m);
}

View File

@ -0,0 +1,141 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxTkRandom.h"
#include "foundation/PxQuat.h"
using namespace physx;
using namespace PxToolkit;
static RandomR250 gRandomR250(0x95d6739b);
PxVec3 BasicRandom::unitRandomPt()
{
PxVec3 v;
do
{
v.x = randomFloat();
v.y = randomFloat();
v.z = randomFloat();
}
while(v.normalize()<1e-6f);
return v;
}
PxQuat BasicRandom::unitRandomQuat()
{
PxQuat v;
do
{
v.x = randomFloat();
v.y = randomFloat();
v.z = randomFloat();
v.w = randomFloat();
}
while(v.normalize()<1e-6f);
return v;
}
void BasicRandom::unitRandomPt(PxVec3& v)
{
v = unitRandomPt();
}
void BasicRandom::unitRandomQuat(PxQuat& v)
{
v = unitRandomQuat();
}
void PxToolkit::SetSeed(PxU32 seed)
{
gRandomR250.setSeed(seed);
}
PxU32 PxToolkit::Rand()
{
return gRandomR250.randI() & TEST_MAX_RAND;
}
RandomR250::RandomR250(PxI32 s)
{
setSeed(s);
}
void RandomR250::setSeed(PxI32 s)
{
BasicRandom lcg(s);
mIndex = 0;
PxI32 j;
for (j = 0; j < 250; j++) // fill r250 buffer with bit values
mBuffer[j] = lcg.randomize();
for (j = 0; j < 250; j++) // set some MSBs to 1
if ( lcg.randomize() > 0x40000000L )
mBuffer[j] |= 0x80000000L;
PxU32 msb = 0x80000000; // turn on diagonal bit
PxU32 mask = 0xffffffff; // turn off the leftmost bits
for (j = 0; j < 32; j++)
{
const PxI32 k = 7 * j + 3; // select a word to operate on
mBuffer[k] &= mask; // turn off bits left of the diagonal
mBuffer[k] |= msb; // turn on the diagonal bit
mask >>= 1;
msb >>= 1;
}
}
PxU32 RandomR250::randI()
{
PxI32 j;
// wrap pointer around
if ( mIndex >= 147 ) j = mIndex - 147;
else j = mIndex + 103;
const PxU32 new_rand = mBuffer[ mIndex ] ^ mBuffer[ j ];
mBuffer[ mIndex ] = new_rand;
// increment pointer for next time
if ( mIndex >= 249 ) mIndex = 0;
else mIndex++;
return new_rand >> 1;
}
PxReal RandomR250::randUnit()
{
PxU32 mask = (1<<23)-1;
return PxF32(randI()&(mask))/PxF32(mask);
}

View File

@ -0,0 +1,149 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxTkStream.h"
#include "foundation/PxAssert.h"
#include "PxTkFile.h"
#include "PxTkNamespaceMangle.h"
#include "PsIntrinsics.h"
#include "foundation/PxMath.h"
#include "PxPhysics.h"
#include "geometry/PxConvexMesh.h"
#include "cooking/PxCooking.h"
#include "foundation/PxBounds3.h"
#include "extensions/PxDefaultStreams.h"
using namespace PxToolkit;
///////////////////////////////////////////////////////////////////////////////
PxTriangleMesh* PxToolkit::createTriangleMesh32(PxPhysics& physics, PxCooking& cooking, const PxVec3* verts, PxU32 vertCount, const PxU32* indices32, PxU32 triCount, bool insert)
{
PxTriangleMeshDesc meshDesc;
meshDesc.points.count = vertCount;
meshDesc.points.stride = sizeof(PxVec3);
meshDesc.points.data = verts;
meshDesc.triangles.count = triCount;
meshDesc.triangles.stride = 3*sizeof(PxU32);
meshDesc.triangles.data = indices32;
if(!insert)
{
PxDefaultMemoryOutputStream writeBuffer;
bool status = cooking.cookTriangleMesh(meshDesc, writeBuffer);
if(!status)
return NULL;
PxDefaultMemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());
return physics.createTriangleMesh(readBuffer);
}
else
{
return cooking.createTriangleMesh(meshDesc,physics.getPhysicsInsertionCallback());
}
}
PxTriangleMesh* PxToolkit::createTriangleMesh32(PxPhysics& physics, PxCooking& cooking, PxTriangleMeshDesc* meshDesc, bool insert)
{
if(!insert)
{
PxDefaultMemoryOutputStream writeBuffer;
bool status = cooking.cookTriangleMesh(*meshDesc, writeBuffer);
if(!status)
return NULL;
PxDefaultMemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());
return physics.createTriangleMesh(readBuffer);
}
else
{
return cooking.createTriangleMesh(*meshDesc,physics.getPhysicsInsertionCallback());
}
}
PxConvexMesh* PxToolkit::createConvexMesh(PxPhysics& physics, PxCooking& cooking, const PxVec3* verts, PxU32 vertCount, PxConvexFlags flags)
{
PxConvexMeshDesc convexDesc;
convexDesc.points.count = vertCount;
convexDesc.points.stride = sizeof(PxVec3);
convexDesc.points.data = verts;
convexDesc.flags = flags;
return cooking.createConvexMesh(convexDesc, physics.getPhysicsInsertionCallback());
}
PxConvexMesh* PxToolkit::createConvexMeshSafe(PxPhysics& physics, PxCooking& cooking, const PxVec3* verts, PxU32 vertCount, PxConvexFlags flags, PxU32 vLimit)
{
PxConvexMeshDesc convexDesc;
convexDesc.points.count = vertCount;
convexDesc.points.stride = sizeof(PxVec3);
convexDesc.points.data = verts;
convexDesc.flags = flags;
convexDesc.vertexLimit = vLimit;
PxDefaultMemoryOutputStream buf;
bool retVal = cooking.cookConvexMesh(convexDesc, buf);
if(!retVal)
{
// create AABB
PxBounds3 aabb;
aabb.setEmpty();
for (PxU32 i = 0; i < vertCount; i++)
{
aabb.include(verts[i]);
}
PxVec3 aabbVerts[8];
aabbVerts[0] = PxVec3(aabb.minimum.x,aabb.minimum.y,aabb.minimum.z);
aabbVerts[1] = PxVec3(aabb.maximum.x,aabb.minimum.y,aabb.minimum.z);
aabbVerts[2] = PxVec3(aabb.maximum.x,aabb.maximum.y,aabb.minimum.z);
aabbVerts[3] = PxVec3(aabb.minimum.x,aabb.maximum.y,aabb.minimum.z);
aabbVerts[4] = PxVec3(aabb.minimum.x,aabb.minimum.y,aabb.maximum.z);
aabbVerts[5] = PxVec3(aabb.maximum.x,aabb.minimum.y,aabb.maximum.z);
aabbVerts[6] = PxVec3(aabb.maximum.x,aabb.maximum.y,aabb.maximum.z);
aabbVerts[7] = PxVec3(aabb.minimum.x,aabb.maximum.y,aabb.maximum.z);
convexDesc.points.count = 8;
convexDesc.points.stride = sizeof(PxVec3);
convexDesc.points.data = &aabbVerts[0];
convexDesc.flags = flags;
retVal = cooking.cookConvexMesh(convexDesc, buf);
}
if(!retVal)
{
return NULL;
}
PxDefaultMemoryInputData input(buf.getData(), buf.getSize());
return physics.createConvexMesh(input);
}

View File

@ -0,0 +1,683 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include <stdio.h>
#include "AcclaimLoader.h"
#include "FrameworkFoundation.h"
#include "PsMathUtils.h"
#include "PxTkFile.h"
#include "SampleAllocatorSDKClasses.h"
#include "SampleArray.h"
#define MAX_FILE_BUFFER_SIZE 4096
#define MAX_TOKEN_LENGTH 512
///////////////////////////////////////////////////////////////////////////////
static inline bool isWhiteSpace(int c)
{
return ( c == ' ') || (c == '\t');
}
///////////////////////////////////////////////////////////////////////////////
static inline bool isWhiteSpaceAndNewline(int c)
{
return ( c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') ;
}
///////////////////////////////////////////////////////////////////////////////
static inline bool isNumeric(int c)
{
return ('0' <= c) && (c <= '9');
}
///////////////////////////////////////////////////////////////////////////////
class SampleFileBuffer
{
SampleFramework::File* mFP;
char mBuffer[MAX_FILE_BUFFER_SIZE];
int mCurrentBufferSize;
int mCurrentCounter;
int mEOF;
public:
SampleFileBuffer(SampleFramework::File* fp) :
mFP(fp),
mCurrentBufferSize(0),
mCurrentCounter(0),
mEOF(0)
{}
///////////////////////////////////////////////////////////////////////////
inline void rewind(int offset = 1)
{
mCurrentCounter -= offset;
}
///////////////////////////////////////////////////////////////////////////
void readBuffer()
{
mCurrentBufferSize = (int)fread(mBuffer, 1, MAX_FILE_BUFFER_SIZE, mFP);
mEOF = feof(mFP);
mCurrentCounter = 0;
}
///////////////////////////////////////////////////////////////////////////
char getCharacter()
{
if (mCurrentCounter >= mCurrentBufferSize)
{
if (mEOF) return EOF;
readBuffer();
if (mCurrentBufferSize == 0)
return EOF;
}
return mBuffer[mCurrentCounter++];
}
///////////////////////////////////////////////////////////////////////////
bool skipWhiteSpace(bool stopAtEndOfLine)
{
char c = 0;
do
{
c = getCharacter();
bool skip = (stopAtEndOfLine) ? isWhiteSpace(c) : isWhiteSpaceAndNewline(c);
if (skip == false)
{
rewind();
return true;
}
} while (c != EOF);
return false; // end of file
}
///////////////////////////////////////////////////////////////////////////////
bool getNextToken(char* token, bool stopAtEndOfLine)
{
if (skipWhiteSpace(stopAtEndOfLine) == false)
return false;
char* str = token;
char c = 0;
do
{
c = getCharacter();
if (c == EOF)
{
*str = 0;
}
else if (isWhiteSpaceAndNewline(c) == true)
{
*str = 0;
rewind();
return (strlen(token) > 0);
}
else
*str++ = (char) c;
} while (c != EOF);
return false;
}
///////////////////////////////////////////////////////////////////////////////
bool getNextTokenButMarker(char* token)
{
if (skipWhiteSpace(false) == false)
return 0;
char* str = token;
char c = 0;
do
{
c = getCharacter();
if (c == ':')
{
rewind();
*str = 0;
return false;
}
if (c == EOF)
{
*str = 0;
}
else if (isWhiteSpaceAndNewline(c) == true)
{
*str = 0;
rewind();
return (strlen(token) > 0);
}
else
*str++ = (char) c;
} while (c != EOF);
return false;
}
///////////////////////////////////////////////////////////////////////////////
bool getNextTokenButNumeric(char* token)
{
if (skipWhiteSpace(false) == false)
return 0;
char* str = token;
char c = 0;
do
{
c = getCharacter();
if (isNumeric(c))
{
rewind();
*str = 0;
return false;
}
if (c == EOF)
{
*str = 0;
}
else if (isWhiteSpaceAndNewline(c) == true)
{
*str = 0;
rewind();
return (strlen(token) > 0);
}
else
*str++ = (char) c;
} while (c != EOF);
return false;
}
///////////////////////////////////////////////////////////////////////////////
void skipUntilNextLine()
{
char c = 0;
do
{
c = getCharacter();
} while ((c != '\n') && (c != EOF));
}
///////////////////////////////////////////////////////////////////////////////
void skipUntilNextBlock()
{
char dummy[MAX_TOKEN_LENGTH];
while (getNextTokenButMarker(dummy) == true)
;
}
///////////////////////////////////////////////////////////////////////////////
bool getNextFloat(float& val, bool stopAtEndOfLine = true)
{
char dummy[MAX_TOKEN_LENGTH];
if (getNextToken(dummy, stopAtEndOfLine) == false)
return false;
val = float(atof(dummy));
return true;
}
///////////////////////////////////////////////////////////////////////////////
bool getNextInt(int& val, bool stopAtEndOfLine = true)
{
char dummy[MAX_TOKEN_LENGTH];
if (getNextToken(dummy, stopAtEndOfLine) == false)
return false;
val = int(atoi(dummy));
return true;
}
///////////////////////////////////////////////////////////////////////////////
bool getNextString(char* val, bool stopAtEndOfLine = true)
{
char dummy[MAX_TOKEN_LENGTH];
if (getNextToken(dummy, stopAtEndOfLine) == false)
return false;
strcpy(val, dummy);
return true;
}
///////////////////////////////////////////////////////////////////////////////
bool getNextVec3(PxVec3& val, bool stopAtEndOfLine = true)
{
if (getNextFloat(val.x, stopAtEndOfLine) == false)
return false;
if (getNextFloat(val.y, stopAtEndOfLine) == false)
return false;
if (getNextFloat(val.z, stopAtEndOfLine) == false)
return false;
return true;
}
};
///////////////////////////////////////////////////////////////////////////////
static bool readHeader(SampleFileBuffer& buffer, Acclaim::ASFData& data)
{
using namespace Acclaim;
char token[MAX_TOKEN_LENGTH], value[MAX_TOKEN_LENGTH];
while (buffer.getNextTokenButMarker(token) == true)
{
if (strcmp(token, "mass") == 0)
{
if (buffer.getNextFloat(data.mHeader.mMass) == false)
return false;
}
else if (strcmp(token, "length") == 0)
{
if (buffer.getNextFloat(data.mHeader.mLengthUnit) == false)
return false;
}
else if (strcmp(token, "angle") == 0)
{
if (buffer.getNextToken(value, true) == false)
return false;
data.mHeader.mAngleInDegree = (strcmp(value, "deg") == 0);
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
static bool readRoot(SampleFileBuffer& buffer, Acclaim::ASFData& data)
{
using namespace Acclaim;
char token[MAX_TOKEN_LENGTH];
while (buffer.getNextTokenButMarker(token) == true)
{
if (strcmp(token, "order") == 0)
buffer.skipUntilNextLine();
else if (strcmp(token, "axis") == 0)
buffer.skipUntilNextLine();
else if (strcmp(token, "position") == 0)
{
if (buffer.getNextVec3(data.mRoot.mPosition) == false)
return false;
}
else if (strcmp(token, "orientation") == 0)
{
if (buffer.getNextVec3(data.mRoot.mOrientation) == false)
return false;
}
else
{
buffer.skipUntilNextLine();
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
static bool readBone(SampleFileBuffer& buffer, Acclaim::Bone& bone)
{
using namespace Acclaim;
int nbDOF = 0;
char token[MAX_TOKEN_LENGTH], dummy[MAX_TOKEN_LENGTH];
if (buffer.getNextTokenButMarker(token) == false)
return false;
if (strcmp(token, "begin") != 0)
return false;
while (buffer.getNextToken(token, false) == true)
{
if (strcmp(token, "id") == 0)
{
if (buffer.getNextInt(bone.mID) == false) return false;
}
else if (strcmp(token, "name") == 0)
{
if (buffer.getNextString(bone.mName) == false) return false;
}
else if (strcmp(token, "direction") == 0)
{
if (buffer.getNextVec3(bone.mDirection) == false) return false;
}
else if (strcmp(token, "length") == 0)
{
if (buffer.getNextFloat(bone.mLength) == false) return false;
}
else if (strcmp(token, "axis") == 0)
{
if (buffer.getNextVec3(bone.mAxis) == false) return false;
buffer.getNextToken(dummy, true);
}
else if (strcmp(token, "dof") == 0)
{
while ((buffer.getNextToken(dummy, true) == true))
{
if (strcmp(dummy, "rx") == 0)
{
bone.mDOF |= BoneDOFFlag::eRX;
nbDOF++;
}
else if (strcmp(dummy, "ry") == 0)
{
bone.mDOF |= BoneDOFFlag::eRY;
nbDOF++;
}
else if (strcmp(dummy, "rz") == 0)
{
bone.mDOF |= BoneDOFFlag::eRZ;
nbDOF++;
}
else if (strcmp(dummy, "l") == 0)
{
bone.mDOF |= BoneDOFFlag::eLENGTH;
nbDOF++;
}
}
continue;
}
else if (strcmp(token, "limits") == 0)
{
int cnt = 0;
while ( cnt++ < nbDOF)
{
// we ignore limit data for now
if (buffer.getNextToken(dummy, false) == false) return false;
if (buffer.getNextToken(dummy, false) == false) return false;
}
}
else if (strcmp(token, "end") == 0)
break;
else
buffer.skipUntilNextLine();
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
static bool readBoneData(SampleFileBuffer& buffer, Acclaim::ASFData& data)
{
using namespace Acclaim;
Bone tempBones[MAX_BONE_NUMBER];
PxU32 nbBones = 0;
// read all the temporary bones onto temporary buffer
bool moreBone = false;
do {
moreBone = readBone(buffer, tempBones[nbBones]);
if (moreBone)
nbBones++;
PX_ASSERT(nbBones <= MAX_BONE_NUMBER);
} while (moreBone == true);
// allocate the right size and copy the bone data
data.mBones = (Bone*)malloc(sizeof(Bone) * nbBones);
data.mNbBones = nbBones;
for (PxU32 i = 0; i < nbBones; i++)
{
data.mBones[i] = tempBones[i];
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
static Acclaim::Bone* getBoneFromName(Acclaim::ASFData& data, const char* name)
{
// use a simple linear search -> probably we could use hash map if performance is an issue
for (PxU32 i = 0; i < data.mNbBones; i++)
{
if (strcmp(name, data.mBones[i].mName) == 0)
return &data.mBones[i];
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
static bool readHierarchy(SampleFileBuffer& buffer, Acclaim::ASFData& data)
{
using namespace Acclaim;
char token[MAX_TOKEN_LENGTH];
char dummy[MAX_TOKEN_LENGTH];
while (buffer.getNextTokenButMarker(token) == true)
{
if (strcmp(token, "begin") == 0)
;
else if (strcmp(token, "end") == 0)
break;
else
{
Bone* parent = getBoneFromName(data, token);
while (buffer.getNextToken(dummy, true) == true)
{
Bone* child = getBoneFromName(data, dummy);
if (!child)
return false;
child->mParent = parent;
}
}
buffer.skipUntilNextLine();
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
static bool readFrameData(SampleFileBuffer& buffer, Acclaim::ASFData& asfData, Acclaim::FrameData& frameData)
{
using namespace Acclaim;
char token[MAX_TOKEN_LENGTH];
while (buffer.getNextTokenButNumeric(token) == true)
{
if (strcmp(token, "root") == 0)
{
buffer.getNextVec3(frameData.mRootPosition);
buffer.getNextVec3(frameData.mRootOrientation);
}
else
{
Bone* bone = getBoneFromName(asfData, token);
if (bone == 0)
return false;
int id = bone->mID - 1;
float val = 0;
if (bone->mDOF & BoneDOFFlag::eRX)
{
buffer.getNextFloat(val);
frameData.mBoneFrameData[id].x = val;
}
if (bone->mDOF & BoneDOFFlag::eRY)
{
buffer.getNextFloat(val);
frameData.mBoneFrameData[id].y = val;
}
if (bone->mDOF & BoneDOFFlag::eRZ)
{
buffer.getNextFloat(val);
frameData.mBoneFrameData[id].z = val;
}
}
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
bool Acclaim::readASFData(const char* filename, Acclaim::ASFData& data)
{
using namespace Acclaim;
char token[MAX_TOKEN_LENGTH];
SampleFramework::File* fp = NULL;
PxToolkit::fopen_s(&fp, filename, "r");
if (!fp)
return false;
SampleFileBuffer buffer(fp);
while (buffer.getNextToken(token, false) == true)
{
if (token[0] == '#') // comment
{
buffer.skipUntilNextLine();
continue;
}
else if (token[0] == ':') // blocks
{
const char* str = token + 1; // remainder of the string
if (strcmp(str, "version") == 0) // ignore version number
buffer.skipUntilNextLine();
else if (strcmp(str, "name") == 0) // probably 'VICON'
buffer.skipUntilNextLine();
else if (strcmp(str, "units") == 0)
{
if ( readHeader(buffer, data) == false)
return false;
}
else if (strcmp(str, "documentation") == 0)
buffer.skipUntilNextBlock();
else if (strcmp(str, "root") == 0)
{
if (readRoot(buffer, data) == false)
return false;
}
else if (strcmp(str, "bonedata") == 0)
{
if (readBoneData(buffer, data) == false)
return false;
}
else if (strcmp(str, "hierarchy") == 0)
{
if (readHierarchy(buffer, data) == false)
return false;
}
else
{
// ERROR! - unrecognized block name
}
}
else
{
// ERRROR!
continue;
}
}
fclose(fp);
return true;
}
///////////////////////////////////////////////////////////////////////////////
bool Acclaim::readAMCData(const char* filename, Acclaim::ASFData& asfData, Acclaim::AMCData& amcData)
{
using namespace Acclaim;
char token[MAX_TOKEN_LENGTH];
SampleArray<FrameData> tempFrameData;
tempFrameData.reserve(300);
SampleFramework::File* fp = NULL;
PxToolkit::fopen_s(&fp, filename, "r");
if (!fp)
return false;
SampleFileBuffer buffer(fp);
while (buffer.getNextToken(token, false) == true)
{
if (token[0] == '#') // comment
{
buffer.skipUntilNextLine();
continue;
}
else if (token[0] == ':') // blocks
{
const char* str = token + 1; // remainder of the string
if (strcmp(str, "FULLY-SPECIFIED") == 0)
continue;
else if (strcmp(str, "DEGREES") == 0)
continue;
}
else if (isNumeric(token[0]) == true)
{
// frame number
//int frameNo = atoi(token);
FrameData frameData;
if (readFrameData(buffer, asfData, frameData) == true)
tempFrameData.pushBack(frameData);
}
}
amcData.mNbFrames = tempFrameData.size();
amcData.mFrameData = (FrameData*)malloc(sizeof(FrameData) * amcData.mNbFrames);
memcpy(amcData.mFrameData, tempFrameData.begin(), sizeof(FrameData) * amcData.mNbFrames);
fclose(fp);
return true;
}

View File

@ -0,0 +1,132 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef ACCLAIM_LOADER
#define ACCLAIM_LOADER
#include "foundation/PxFlags.h"
#include "foundation/PxTransform.h"
#include "SampleAllocator.h"
#include "SampleArray.h"
namespace Acclaim
{
#define MAX_BONE_NAME_CHARACTER_LENGTH 100
#define MAX_BONE_NUMBER 32
///////////////////////////////////////////////////////////////////////////////
struct BoneDOFFlag
{
enum Enum
{
eRX = (1<<0),
eRY = (1<<1),
eRZ = (1<<2),
eLENGTH = (1<<3)
};
};
typedef PxFlags<BoneDOFFlag::Enum,PxU16> BoneDOFFlags;
PX_FLAGS_OPERATORS(BoneDOFFlag::Enum, PxU16)
///////////////////////////////////////////////////////////////////////////////
struct Bone
{
int mID;
char mName[MAX_BONE_NAME_CHARACTER_LENGTH];
PxVec3 mDirection;
PxReal mLength;
PxVec3 mAxis;
BoneDOFFlags mDOF;
Bone* mParent;
public:
Bone() :
mID(-1),
mDirection(0.0f),
mLength(0.0f),
mAxis(0.0f, 0.0f, 1.0f),
mDOF(0),
mParent(NULL)
{
}
};
///////////////////////////////////////////////////////////////////////////////
struct ASFData
{
struct Header
{
PxReal mMass;
PxReal mLengthUnit;
bool mAngleInDegree;
};
struct Root
{
PxVec3 mPosition;
PxVec3 mOrientation;
};
Header mHeader;
Root mRoot;
Bone* mBones;
PxU32 mNbBones;
public:
void release() { if (mBones) free(mBones); }
};
///////////////////////////////////////////////////////////////////////////////
struct FrameData
{
PxVec3 mRootPosition;
PxVec3 mRootOrientation;
PxVec3 mBoneFrameData[MAX_BONE_NUMBER];
PxU32 mNbBones;
};
///////////////////////////////////////////////////////////////////////////////
struct AMCData
{
FrameData* mFrameData;
PxU32 mNbFrames;
public:
void release() { if (mFrameData) free(mFrameData); }
};
///////////////////////////////////////////////////////////////////////////////
bool readASFData(const char* filename, ASFData& data);
bool readAMCData(const char* filename, ASFData& asfData, AMCData& amcData);
}
#endif // ACCLAIM_LOADER

View File

@ -0,0 +1,49 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// PT: dummy file to test each header can be included on his own without anything else
// DON'T REMOVE.
//#include "SampleErrorStream.h"
//#include "RenderBaseActor.h"
//#include "RenderBoxActor.h"
//#include "RenderSphereActor.h"
//#include "RenderCapsuleActor.h"
//#include "RenderMeshActor.h"
//#include "RenderGridActor.h"
//#include "RenderMaterial.h"
//#include "RawLoader.h"
//#include "RenderPhysX3Debug.h"
//#include "SampleBase.h"
//#include "SampleBridges.h"
//#include "SampleMain.h"
//#include "SampleMouseFilter.h"
//#include "SampleUtils.h"
//#include "SampleCamera.h"
//#include "SampleCameraController.h"
#include "SampleStepper.h"

View File

@ -0,0 +1,162 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "InputEventBuffer.h"
#include "PhysXSampleApplication.h"
using namespace physx;
using namespace SampleRenderer;
using namespace SampleFramework;
using namespace PxToolkit;
InputEventBuffer::InputEventBuffer(PhysXSampleApplication& p)
: mResetInputCacheReq(0)
, mResetInputCacheAck(0)
, mLastKeyDownEx(NULL)
, mLastDigitalInput(NULL)
, mLastAnalogInput(NULL)
, mLastPointerInput(NULL)
, mApp(p)
, mClearBuffer(false)
{
}
InputEventBuffer::~InputEventBuffer()
{
}
void InputEventBuffer::onKeyDownEx(SampleFramework::SampleUserInput::KeyCode keyCode, PxU32 wParam)
{
checkResetLastInput();
if(mLastKeyDownEx && mLastKeyDownEx->isEqual(keyCode, wParam))
return;
if(mRingBuffer.isFull())
return;
KeyDownEx& event = mRingBuffer.front().get<KeyDownEx>();
PX_PLACEMENT_NEW(&event, KeyDownEx);
event.keyCode = keyCode;
event.wParam = wParam;
mLastKeyDownEx = &event;
mRingBuffer.incFront(1);
}
void InputEventBuffer::onAnalogInputEvent(const SampleFramework::InputEvent& e, float val)
{
checkResetLastInput();
if(mLastAnalogInput && mLastAnalogInput->isEqual(e, val))
return;
if(mRingBuffer.isFull() || (mRingBuffer.size() > MAX_ANALOG_EVENTS))
return;
AnalogInput& event = mRingBuffer.front().get<AnalogInput>();
PX_PLACEMENT_NEW(&event, AnalogInput);
event.e = e;
event.val = val;
mLastAnalogInput = &event;
mRingBuffer.incFront(1);
}
void InputEventBuffer::onDigitalInputEvent(const SampleFramework::InputEvent& e, bool val)
{
checkResetLastInput();
if(mLastDigitalInput && mLastDigitalInput->isEqual(e, val))
return;
if(mRingBuffer.isFull())
return;
DigitalInput& event = mRingBuffer.front().get<DigitalInput>();
PX_PLACEMENT_NEW(&event, DigitalInput);
event.e = e;
event.val = val;
mLastDigitalInput = &event;
mRingBuffer.incFront(1);
}
void InputEventBuffer::onPointerInputEvent(const SampleFramework::InputEvent& e, PxU32 x, PxU32 y, PxReal dx, PxReal dy, bool val)
{
checkResetLastInput();
if(mLastPointerInput && mLastPointerInput->isEqual(e, x, y, dx, dy, val))
return;
if(mRingBuffer.isFull() || (mRingBuffer.size() > MAX_MOUSE_EVENTS))
return;
PointerInput& event = mRingBuffer.front().get<PointerInput>();
PX_PLACEMENT_NEW(&event, PointerInput);
event.e = e;
event.x = x;
event.y = y;
event.dx = dx;
event.dy = dy;
event.val = val;
mLastPointerInput = &event;
mRingBuffer.incFront(1);
}
void InputEventBuffer::clear()
{
mClearBuffer = true;
}
void InputEventBuffer::flush()
{
if(mResetInputCacheReq==mResetInputCacheAck)
mResetInputCacheReq++;
PxU32 size = mRingBuffer.size();
Ps::memoryBarrier();
// do not work on more than size, else input cache might become overwritten
while(size-- && !mClearBuffer)
{
mRingBuffer.back().get<EventType>().report(mApp);
mRingBuffer.incBack(1);
}
if(mClearBuffer)
{
mRingBuffer.clear();
mClearBuffer = false;
}
}
void InputEventBuffer::KeyDownEx::report(PhysXSampleApplication& app) const
{
app.onKeyDownEx(keyCode, wParam);
}
void InputEventBuffer::AnalogInput::report(PhysXSampleApplication& app) const
{
app.onAnalogInputEvent(e, val);
}
void InputEventBuffer::DigitalInput::report(PhysXSampleApplication& app) const
{
app.onDigitalInputEvent(e, val);
}
void InputEventBuffer::PointerInput::report(PhysXSampleApplication& app) const
{
app.onPointerInputEvent(e, x, y, dx, dy, val);
}

View File

@ -0,0 +1,228 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef INPUT_BUFFER_H
#define INPUT_BUFFER_H
#include "SamplePreprocessor.h"
#include "SampleAllocator.h"
#include "SampleUserInput.h"
#include "foundation/PxAssert.h"
#include "PsIntrinsics.h"
class PhysXSampleApplication;
template<typename T, PxU32 SIZE>
class RingBuffer
{
public:
RingBuffer()
: mReadCount(0)
, mWriteCount(0)
{
// SIZE has to be power of two
#if PX_VC
PX_COMPILE_TIME_ASSERT(SIZE > 0);
PX_COMPILE_TIME_ASSERT((SIZE&(SIZE-1)) == 0);
#else
PX_ASSERT(SIZE > 0);
PX_ASSERT((SIZE&(SIZE-1)) == 0);
#endif
}
PX_FORCE_INLINE bool isEmpty() const { return mReadCount==mWriteCount; }
PX_FORCE_INLINE bool isFull() const { return isFull(mReadCount, mWriteCount); }
PX_FORCE_INLINE PxU32 size() const { return size(mReadCount, mWriteCount); }
PX_FORCE_INLINE PxU32 capacity() const { return SIZE; }
// clear is only save if called from reader thread!
PX_FORCE_INLINE void clear() { mReadCount=mWriteCount; }
PX_FORCE_INLINE const T& back() const { PX_ASSERT(!isEmpty()); return mRing[mReadCount&moduloMask]; }
PX_FORCE_INLINE T& front() { return mRing[mWriteCount&moduloMask]; }
PX_FORCE_INLINE void incFront(PxU32 inc) { PX_ASSERT(SIZE-size() >= inc); mWriteCount+=inc; }
PX_FORCE_INLINE void incBack(PxU32 inc) { PX_ASSERT(size() >= inc); mReadCount+=inc; }
PX_FORCE_INLINE bool pushFront(const T& e)
{
if(!isFull())
{
mRing[mWriteCount&moduloMask] = e;
Ps::memoryBarrier();
mWriteCount++;
return true;
}
else
return false;
}
PX_FORCE_INLINE bool popBack(T& e)
{
if(!isEmpty())
{
e = mRing[mReadCount&moduloMask];
mReadCount++;
return true;
}
else
return false;
}
private:
PX_FORCE_INLINE static PxU32 moduloDistance(PxI32 r, PxI32 w) { return PxU32((w-r)&moduloMask); }
PX_FORCE_INLINE static bool isFull(PxI32 r, PxI32 w) { return r!=w && moduloDistance(r,w)==0; }
PX_FORCE_INLINE static PxU32 size(PxI32 r, PxI32 w) { return isFull(r, w) ? SIZE : moduloDistance(r, w); }
private:
static const PxU32 moduloMask = SIZE-1;
T mRing[SIZE];
volatile PxI32 mReadCount;
volatile PxI32 mWriteCount;
};
class InputEventBuffer: public SampleFramework::InputEventListener, public SampleAllocateable
{
public:
InputEventBuffer(PhysXSampleApplication& p);
virtual ~InputEventBuffer();
virtual void onKeyDownEx(SampleFramework::SampleUserInput::KeyCode keyCode, PxU32 wParam);
virtual void onAnalogInputEvent(const SampleFramework::InputEvent& , float val);
virtual void onDigitalInputEvent(const SampleFramework::InputEvent& , bool val);
virtual void onPointerInputEvent(const SampleFramework::InputEvent&, PxU32 x, PxU32 y, PxReal dx, PxReal dy, bool val);
void clear();
void flush();
private:
PX_FORCE_INLINE void checkResetLastInput()
{
if(mResetInputCacheReq!=mResetInputCacheAck)
{
mLastKeyDownEx = NULL;
mLastDigitalInput = NULL;
mLastAnalogInput = NULL;
mLastPointerInput = NULL;
mResetInputCacheAck++;
PX_ASSERT(mResetInputCacheReq==mResetInputCacheAck);
}
}
struct EventType
{
virtual ~EventType() {}
virtual void report(PhysXSampleApplication& app) const { }
};
struct KeyDownEx: public EventType
{
virtual void report(PhysXSampleApplication& app) const;
bool isEqual(SampleFramework::SampleUserInput::KeyCode _keyCode, PxU32 _wParam)
{
return (_keyCode == keyCode) && (_wParam == wParam);
}
SampleFramework::SampleUserInput::KeyCode keyCode;
PxU32 wParam;
};
struct AnalogInput: public EventType
{
virtual void report(PhysXSampleApplication& app) const;
bool isEqual(SampleFramework::InputEvent _e, float _val)
{
return (_e.m_Id == e.m_Id) && (_e.m_Analog == e.m_Analog) && (_e.m_Sensitivity == e.m_Sensitivity) && (_val == val);
}
SampleFramework::InputEvent e;
float val;
};
struct DigitalInput: public EventType
{
virtual void report(PhysXSampleApplication& app) const;
bool isEqual(SampleFramework::InputEvent _e, bool _val)
{
return (_e.m_Id == e.m_Id) && (_e.m_Analog == e.m_Analog) && (_e.m_Sensitivity == e.m_Sensitivity) && (_val == val);
}
SampleFramework::InputEvent e;
bool val;
};
struct PointerInput: public EventType
{
virtual void report(PhysXSampleApplication& app) const;
bool isEqual(SampleFramework::InputEvent _e, PxU32 _x, PxU32 _y, PxReal _dx, PxReal _dy, bool _val)
{
return (_e.m_Id == e.m_Id) && (_e.m_Analog == e.m_Analog) && (_e.m_Sensitivity == e.m_Sensitivity) &&
(_x == x) && (_y == y) && (_dx == dx) && (_dy == dy) && (_val == val);
}
SampleFramework::InputEvent e;
PxU32 x;
PxU32 y;
PxReal dx;
PxReal dy;
bool val;
};
struct EventsUnion
{
template<class Event> PX_CUDA_CALLABLE PX_FORCE_INLINE Event& get()
{
return reinterpret_cast<Event&>(events);
}
template<class Event> PX_CUDA_CALLABLE PX_FORCE_INLINE const Event& get() const
{
return reinterpret_cast<const Event&>(events);
}
union
{
PxU8 eventType[sizeof(EventType)];
PxU8 keyDownEx[sizeof(KeyDownEx)];
PxU8 analogInput[sizeof(AnalogInput)];
PxU8 digitalInput[sizeof(DigitalInput)];
PxU8 pointerInput[sizeof(PointerInput)];
} events;
};
static const PxU32 MAX_EVENTS = 64;
static const PxU32 MAX_MOUSE_EVENTS = 48;
static const PxU32 MAX_ANALOG_EVENTS = 48;
RingBuffer<EventsUnion, MAX_EVENTS> mRingBuffer;
volatile PxU32 mResetInputCacheReq;
volatile PxU32 mResetInputCacheAck;
KeyDownEx* mLastKeyDownEx;
DigitalInput* mLastDigitalInput;
AnalogInput* mLastAnalogInput;
PointerInput* mLastPointerInput;
PhysXSampleApplication& mApp;
bool mClearBuffer;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,344 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
#ifndef PHYSX_SAMPLE_H
#define PHYSX_SAMPLE_H
#include "PhysXSampleApplication.h"
#include "SampleStepper.h"
#include "SampleDirManager.h"
#include "PxPhysicsAPI.h"
#include "extensions/PxExtensionsAPI.h"
namespace SampleFramework
{
class SampleInputAsset;
}
namespace physx
{
class Picking;
}
struct PhysXShape
{
PxRigidActor* mActor;
PxShape* mShape;
PhysXShape(PxRigidActor* actor, PxShape* shape) : mActor(actor), mShape(shape) {}
PhysXShape(const PhysXShape& shape) : mActor(shape.mActor), mShape(shape.mShape) {}
bool operator<(const PhysXShape& shape) const { return mActor == shape.mActor ? mShape < shape.mShape : mActor < shape.mActor; }
};
enum StepperType
{
DEFAULT_STEPPER,
FIXED_STEPPER,
VARIABLE_STEPPER
};
class PhysXSample : public RAWImportCallback
, public SampleAllocateable
, public PxDeletionListener
{
typedef std::map<PhysXShape, RenderBaseActor*> PhysXShapeToRenderActorMap;
public:
PhysXSample(PhysXSampleApplication& app, PxU32 maxSubSteps=8);
virtual ~PhysXSample();
public:
void render();
void displayFPS();
SampleFramework::SampleAsset* getAsset(const char* relativePath, SampleFramework::SampleAsset::Type type, bool abortOnError = true);
void importRAWFile(const char* relativePath, PxReal scale, bool recook=false);
void removeActor(PxRigidActor* actor);
void removeRenderObject(RenderBaseActor *renderAcotr);
void createRenderObjectsFromActor(PxRigidActor* actor, RenderMaterial* material=NULL);
RenderBaseActor* createRenderBoxFromShape(PxRigidActor* actor, PxShape* shape, RenderMaterial* material=NULL, const PxReal* uvs=NULL);
RenderBaseActor* createRenderObjectFromShape(PxRigidActor* actor, PxShape* shape, RenderMaterial* material=NULL);
RenderMeshActor* createRenderMeshFromRawMesh(const RAWMesh& data, PxShape* shape = NULL);
RenderTexture* createRenderTextureFromRawTexture(const RAWTexture& data);
RenderMaterial* createRenderMaterialFromTextureFile(const char* filename);
PxRigidActor* createGrid(RenderMaterial* material=NULL);
PxRigidDynamic* createBox(const PxVec3& pos, const PxVec3& dims, const PxVec3* linVel=NULL, RenderMaterial* material=NULL, PxReal density=1.0f);
PxRigidDynamic* createSphere(const PxVec3& pos, PxReal radius, const PxVec3* linVel=NULL, RenderMaterial* material=NULL, PxReal density=1.0f);
PxRigidDynamic* createCapsule(const PxVec3& pos, PxReal radius, PxReal halfHeight, const PxVec3* linVel=NULL, RenderMaterial* material=NULL, PxReal density=1.0f);
PxRigidDynamic* createConvex(const PxVec3& pos, const PxVec3* linVel=NULL, RenderMaterial* material=NULL, PxReal density=1.0f);
PxRigidDynamic* createCompound(const PxVec3& pos, const std::vector<PxTransform>& localPoses, const std::vector<const PxGeometry*>& geometries, const PxVec3* linVel=NULL, RenderMaterial* material=NULL, PxReal density=1.0f);
PxRigidDynamic* createTestCompound(const PxVec3& pos, PxU32 nbBoxes, float boxSize, float amplitude, const PxVec3* linVel, RenderMaterial* material, PxReal density, bool makeSureVolumeEmpty = false);
void createRenderObjectsFromScene();
void setSubStepper(const PxReal stepSize, const PxU32 maxSteps) { getStepper()->setSubStepper(stepSize, maxSteps); }
void togglePause();
void toggleFlyCamera();
void initRenderObjects();
// project from world coords to screen coords (can be used for text rendering)
void project(const PxVec3& v, int& x, int& y, float& depth);
public:
virtual void onInit();
virtual void onInit(bool restart) { onInit(); }
virtual void onShutdown();
// called after simulate() has completed
virtual void onSubstep(float dtime) {}
// called after simulate() has completed, but before fetchResult() is called
virtual void onSubstepPreFetchResult() {}
// called before simulate() is called
virtual void onSubstepSetup(float dtime, PxBaseTask* cont) {}
// called after simulate() has started
virtual void onSubstepStart(float dtime) {}
virtual void onTickPreRender(float dtime);
virtual void customizeRender() {}
virtual void helpRender(PxU32 x, PxU32 y, PxU8 textAlpha) {}
virtual void descriptionRender(PxU32 x, PxU32 y, PxU8 textAlpha) {}
virtual void onTickPostRender(float dtime);
virtual void onAnalogInputEvent(const SampleFramework::InputEvent& , float val);
virtual void onDigitalInputEvent(const SampleFramework::InputEvent& , bool val);
virtual void onPointerInputEvent(const SampleFramework::InputEvent& ie, PxU32 x, PxU32 y, PxReal dx, PxReal dy, bool val);
virtual void onKeyDownEx(SampleFramework::SampleUserInput::KeyCode keyCode, PxU32 param);
virtual void onResize(PxU32 width, PxU32 height);
virtual void newMaterial(const RAWMaterial&);
virtual void newMesh(const RAWMesh&);
virtual void newShape(const RAWShape&);
virtual void newHelper(const RAWHelper&);
virtual void newTexture(const RAWTexture&);
void unregisterInputEvents();
void registerInputEvents(bool ignoreSaved = false);
virtual void collectInputEvents(std::vector<const SampleFramework::InputEvent*>& inputEvents);
virtual SampleFramework::SampleDirManager& getSampleOutputDirManager();
// delete listener
virtual void onRelease(const PxBase* observed, void* userData, PxDeletionEventFlag::Enum deletionEvent);
protected:
// Let samples override this
virtual void getDefaultSceneDesc(PxSceneDesc&) {}
virtual void customizeSceneDesc(PxSceneDesc&) {}
virtual void customizeTolerances(PxTolerancesScale&) {}
virtual void renderScene() {}
// this lets samples customize the debug objects
enum DebugObjectType
{
DEBUG_OBJECT_BOX = (1 << 0),
DEBUG_OBJECT_SPHERE = (1 << 1),
DEBUG_OBJECT_CAPSULE = (1 << 2),
DEBUG_OBJECT_CONVEX = (1 << 3),
DEBUG_OBJECT_COMPOUND = (1 << 4),
DEBUG_OBJECT_ALL = (DEBUG_OBJECT_BOX | DEBUG_OBJECT_SPHERE | DEBUG_OBJECT_CAPSULE | DEBUG_OBJECT_CONVEX | DEBUG_OBJECT_COMPOUND)
};
virtual PxU32 getDebugObjectTypes() const { return DEBUG_OBJECT_ALL; }
virtual PxReal getDebugObjectsVelocity() const { return 20.0f; }
virtual PxVec3 getDebugBoxObjectExtents() const { return PxVec3(0.3f, 0.3f, 1.0f); }
virtual PxReal getDebugSphereObjectRadius() const { return 0.3f; }
virtual PxReal getDebugCapsuleObjectRadius() const { return 0.3f; }
virtual PxReal getDebugCapsuleObjectHalfHeight() const { return 1.0f; }
virtual PxReal getDebugConvexObjectScale() const { return 0.3f; }
virtual void onDebugObjectCreation(PxRigidDynamic* actor){ }
Stepper* getStepper();
void prepareInputEventUserInputInfo(const char* sampleName,PxU32 &userInputCS, PxU32 &inputEventCS);
private:
///////////////////////////////////////////////////////////////////////////////
PhysXSample& operator= (const PhysXSample&);
public: // Helpers from PhysXSampleApplication
PX_FORCE_INLINE void fatalError(const char* msg) { mApplication.fatalError(msg); }
PX_FORCE_INLINE void setCameraController(CameraController* c) { mApplication.setCameraController(c); }
PX_FORCE_INLINE void toggleVisualizationParam(PxScene& scene, PxVisualizationParameter::Enum param)
{
PxSceneWriteLock scopedLock(scene);
const bool visualization = scene.getVisualizationParameter(param) == 1.0f;
scene.setVisualizationParameter(param, visualization ? 0.0f : 1.0f);
mApplication.refreshVisualizationMenuState(param);
}
public: // getter & setter
PX_FORCE_INLINE void setDefaultMaterial(PxMaterial* material) { mMaterial = material; }
PX_FORCE_INLINE void setFilename(const char* name) { mFilename = name; }
PX_FORCE_INLINE PhysXSampleApplication& getApplication() const { return mApplication; }
PX_FORCE_INLINE PxPhysics& getPhysics() const { return *mPhysics; }
PX_FORCE_INLINE PxCooking& getCooking() const { return *mCooking; }
PX_FORCE_INLINE PxScene& getActiveScene() const { return *mScene; }
PX_FORCE_INLINE PxMaterial& getDefaultMaterial() const { return *mMaterial; }
RenderMaterial* getMaterial(PxU32 materialID);
PX_FORCE_INLINE Camera& getCamera() const { return mApplication.getCamera(); }
PX_FORCE_INLINE SampleRenderer::Renderer* getRenderer() const { return mApplication.getRenderer(); }
PX_FORCE_INLINE RenderPhysX3Debug* getDebugRenderer() const { return mApplication.getDebugRenderer(); }
PX_FORCE_INLINE Console* getConsole() const { return mApplication.mConsole; }
PX_FORCE_INLINE CameraController* getCurrentCameraController() const { return mApplication.mCurrentCameraController; }
PX_FORCE_INLINE DefaultCameraController& getDefaultCameraController() const { return mCameraController; }
PX_FORCE_INLINE const PxMat44& getEyeTransform(void) const { return mApplication.m_worldToView.getInverseTransform();}
PX_FORCE_INLINE PxReal getSimulationTime() const { return mSimulationTime; }
PX_FORCE_INLINE PxReal getDebugRenderScale() const { return mDebugRenderScale; }
PX_FORCE_INLINE bool isPaused() const { return mApplication.isPaused(); }
PX_FORCE_INLINE bool isConnectedPvd() const { return mPvd ? mPvd->isConnected() : false; }
#if PX_SUPPORT_GPU_PHYSX
PX_FORCE_INLINE bool isGpuSupported() const { return mCudaContextManager && mCudaContextManager->contextIsValid(); }
#else
PX_FORCE_INLINE bool isGpuSupported() const { return false; }
#endif
PX_FORCE_INLINE void setMenuExpandState(bool menuExpand) { mApplication.mMenuExpand = menuExpand; }
PX_FORCE_INLINE void setEyeTransform(const PxVec3& pos, const PxVec3& rot) {mApplication.setEyeTransform(pos, rot); }
PX_FORCE_INLINE void resetExtendedHelpText() { mExtendedHelpPage = 0; }
PX_FORCE_INLINE void addPhysicsActors(PxRigidActor* actor) { mPhysicsActors.push_back(actor); }
void unlink(RenderBaseActor* renderActor, PxShape* shape, PxRigidActor* actor);
void link(RenderBaseActor* renderActor, PxShape* shape, PxRigidActor* actor);
RenderBaseActor* getRenderActor(PxRigidActor* actor, PxShape* shape);
const char* getSampleOutputFilePath(const char* inFilePath, const char* outExtension);
void showExtendedInputEventHelp(PxU32 x, PxU32 y);
void freeDeletedActors();
PX_FORCE_INLINE StepperType getStepperType() const { return mStepperType; }
protected:
void updateRenderObjectsFromRigidActor(PxRigidActor& actor, RenderMaterial* mat = NULL);
void updateRenderObjectsFromArticulation(PxArticulationBase& articulation);
protected:
void togglePvdConnection();
void createPvdConnection();
void bufferActiveTransforms();
void updateRenderObjectsDebug(float dtime); // update of render actors debug draw information, will be called while the simulation is NOT running
void updateRenderObjectsSync(float dtime); // update of render objects while the simulation is NOT running
void updateRenderObjectsAsync(float dtime); // update of render objects, potentially while the simulation is running (for rigid bodies etc. because data is double buffered)
void saveUserInputs();
void saveInputEvents(const std::vector<const SampleFramework::InputEvent*>& );
void parseSampleOutputAsset(const char* sampleName, PxU32 , PxU32 );
void spawnDebugObject();
void removeRenderActorsFromPhysicsActor(const PxRigidActor* actor);
protected: // configurations
bool mInitialDebugRender;
bool mCreateCudaCtxManager;
bool mCreateGroundPlane;
StepperType mStepperType;
PxU32 mMaxNumSubSteps;
PxU32 mNbThreads;
PxReal mDefaultDensity;
protected: // control
bool mDisplayFPS;
bool& mPause;
bool& mOneFrameUpdate;
bool& mShowHelp;
bool& mShowDescription;
bool& mShowExtendedHelp;
bool mHideGraphics;
bool mEnableAutoFlyCamera;
DefaultCameraController& mCameraController;
DefaultCameraController mFlyCameraController;
PhysXSampleApplication::PvdParameters& mPvdParams;
protected:
PhysXSampleApplication& mApplication;
PxFoundation* mFoundation;
PxPhysics* mPhysics;
PxCooking* mCooking;
PxScene* mScene;
PxMaterial* mMaterial;
PxDefaultCpuDispatcher* mCpuDispatcher;
physx::PxPvd* mPvd;
physx::PxPvdTransport* mTransport;
physx::PxPvdInstrumentationFlags mPvdFlags;
#if PX_SUPPORT_GPU_PHYSX
PxCudaContextManager* mCudaContextManager;
#endif
std::vector<PxRigidActor*> mPhysicsActors;
std::vector<RenderBaseActor*> mDeletedRenderActors;
std::vector<RenderBaseActor*> mRenderActors;
std::vector<RenderTexture*> mRenderTextures;
std::vector<SampleFramework::SampleAsset*> mManagedAssets;
std::vector<RenderMaterial*> mRenderMaterials;
RenderMaterial* (&mManagedMaterials)[MATERIAL_COUNT];
SampleFramework::SampleInputAsset* mSampleInputAsset;
PxActor** mBufferedActiveActors;
std::vector<PxActor*> mDeletedActors;
PxU32 mActiveTransformCount;
PxU32 mActiveTransformCapacity;
bool mIsFlyCamera;
PhysXShapeToRenderActorMap mPhysXShapeToRenderActorMap;
private:
PxU32 mMeshTag;
const char* mFilename;
PxReal mScale;
PxReal mDebugRenderScale;
protected:
bool mWaitForResults;
private:
PxToolkit::FPS mFPS;
CameraController* mSavedCameraController;
DebugStepper mDebugStepper;
FixedStepper mFixedStepper;
VariableStepper mVariableStepper;
bool mWireFrame;
PxReal mSimulationTime;
Picking* mPicking;
bool mPicked;
physx::PxU8 mExtendedHelpPage;
physx::PxU32 mDebugObjectType;
static const PxU32 SCRATCH_BLOCK_SIZE = 1024*128;
void* mScratchBlock;
};
PxToolkit::BasicRandom& getSampleRandom();
PxErrorCallback& getSampleErrorCallback();
#endif // PHYSX_SAMPLE_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,362 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PHYSX_SAMPLE_APPLICATION_H
#define PHYSX_SAMPLE_APPLICATION_H
#include "SamplePreprocessor.h"
#include "SampleApplication.h"
#include "SampleCamera.h"
#include "SampleCameraController.h"
#include "SampleAllocator.h"
#include "PxFiltering.h"
#include "RawLoader.h"
#include "RendererMeshContext.h"
#include "PxTkFPS.h"
#include "PxVisualizationParameter.h"
#include "PxTkRandom.h"
#include <PsThread.h>
#include <PsSync.h>
#include "PsHashMap.h"
#include "PsUtilities.h"
#include "SampleArray.h"
#if PX_WINDOWS
#include "task/PxTask.h"
#endif
#define SAMPLE_MEDIA_PATH "samples/media/"
#define SAMPLE_OUTPUT_PATH "samples/media/user/"
namespace physx
{
class PxDefaultCpuDispatcher;
class PxPhysics;
class PxCooking;
class PxScene;
class PxGeometry;
class PxMaterial;
class PxRigidActor;
};
class RenderPhysX3Debug;
class RenderBaseActor;
class RenderMaterial;
class RenderMeshActor;
class RenderTexture;
class Stepper;
class Console;
class PhysXSampleApplication;
class PhysXSample;
class InputEventBuffer;
namespace Test
{
class TestGroup;
}
class PhysXSampleCreator
{
public:
virtual ~PhysXSampleCreator() {}
virtual PhysXSample* operator()(PhysXSampleApplication& app) const = 0;
};
typedef PhysXSampleCreator *SampleCreator;
typedef PhysXSample* (*FunctionCreator)(PhysXSampleApplication& app);
// typedef PhysXSample* (*SampleCreator)(PhysXSampleApplication& app);
struct SampleSetup
{
SampleSetup() :
mName (NULL),
mWidth (0),
mHeight (0),
mFullscreen (false)
{
}
const char* mName;
PxU32 mWidth;
PxU32 mHeight;
bool mFullscreen;
};
// Default materials created by PhysXSampleApplication
enum MaterialIndex
{
MATERIAL_GREY,
MATERIAL_RED,
MATERIAL_GREEN,
MATERIAL_BLUE,
MATERIAL_YELLOW,
MATERIAL_FLAT,
MATERIAL_COUNT,
};
template <typename Container>
void releaseAll(Container& container)
{
for (PxU32 i = 0; i < container.size(); ++i)
container[i]->release();
container.clear();
}
class PhysXSampleApplication : public SampleFramework::SampleApplication, public SampleAllocateable, public Ps::ThreadT<Ps::RawAllocator>
{
public:
using SampleAllocateable::operator new;
using SampleAllocateable::operator delete;
private:
friend class PhysXSample;
struct PvdParameters
{
char ip[256];
PxU32 port;
PxU32 timeout;
bool useFullPvdConnection;
PvdParameters()
: port(5425)
, timeout(10)
, useFullPvdConnection(true)
{
Ps::strlcpy(ip, 256, "127.0.0.1");
}
};
struct MenuKey
{
enum Enum
{
NONE,
ESCAPE,
SELECT,
NAVI_UP,
NAVI_DOWN,
NAVI_LEFT,
NAVI_RIGHT
};
};
// menu events
struct MenuType
{
enum Enum
{
NONE,
HELP,
SETTINGS,
VISUALIZATIONS,
TESTS
};
};
struct MenuTogglableItem
{
MenuTogglableItem(PxU32 c, const char* n) : toggleCommand(c), toggleState(false), name(n) {}
PxU32 toggleCommand;
bool toggleState;
const char* name;
};
public:
PhysXSampleApplication(const SampleFramework::SampleCommandLine& cmdline);
virtual ~PhysXSampleApplication();
///////////////////////////////////////////////////////////////////////////////
// PsThread interface
virtual void execute();
///////////////////////////////////////////////////////////////////////////////
// Implements SampleApplication/RendererWindow
virtual void onInit();
virtual void onShutdown();
virtual float tweakElapsedTime(float dtime);
virtual void onTickPreRender(float dtime);
virtual void onRender();
virtual void onTickPostRender(float dtime);
void onKeyDownEx(SampleFramework::SampleUserInput::KeyCode keyCode, PxU32 wParam);
void onAnalogInputEvent(const SampleFramework::InputEvent& , float val);
void onDigitalInputEvent(const SampleFramework::InputEvent& , bool val);
void onPointerInputEvent(const SampleFramework::InputEvent&, PxU32 x, PxU32 y, PxReal dx, PxReal dy, bool val);
virtual void onResize(PxU32 width, PxU32 height);
void baseTickPreRender(float dtime);
void baseTickPostRender(float dtime);
void baseResize(PxU32 width, PxU32 height);
///////////////////////////////////////////////////////////////////////////////
void customizeSample(SampleSetup&);
// void onSubstep(float dtime);
///////////////////////////////////////////////////////////////////////////////
void applyDefaultVisualizationSettings();
void saveCameraState();
void restoreCameraState();
// Camera functions
PX_FORCE_INLINE void setDefaultCameraController() { mCurrentCameraController = &mCameraController; mCameraController = DefaultCameraController();}
PX_FORCE_INLINE void resetDefaultCameraController() { mCameraController = DefaultCameraController(); }
PX_FORCE_INLINE void setCameraController(CameraController* c) { mCurrentCameraController = c; }
PX_FORCE_INLINE PxReal getTextAlpha1() const { return mTextAlphaHelp; }
PX_FORCE_INLINE PxReal getTextAlpha2() const { return mTextAlphaDesc; }
PX_FORCE_INLINE bool isPaused() const { return mPause; }
PX_FORCE_INLINE Camera& getCamera() { return mCamera; }
PX_FORCE_INLINE RenderPhysX3Debug* getDebugRenderer() const { return mDebugRenderer; }
PX_FORCE_INLINE Ps::MutexT<Ps::RawAllocator>& getInputMutex() { return mInputMutex; }
bool isConsoleActive() const;
void showCursor(bool show);
void setMouseCursorHiding(bool hide);
void setMouseCursorRecentering(bool recenter);
void handleMouseVisualization();
void updateEngine();
void setPvdParams(const SampleFramework::SampleCommandLine& cmdLine);
PX_FORCE_INLINE void registerLight(SampleRenderer::RendererLight* light) { mLights.push_back(light); }
void collectInputEvents(std::vector<const SampleFramework::InputEvent*>& inputEvents);
const char* inputInfoMsg(const char* firstPart,const char* secondPart, PxI32 inputEventId1, PxI32 inputEventId2);
const char* inputInfoMsg_Aor_BandC(const char* firstPart,const char* secondPart, PxI32 inputEventIdA, PxI32 inputEventIdB, PxI32 inputEventIdC);
const char* inputMoveInfoMsg(const char* firstPart,const char* secondPart, PxI32 inputEventId1, PxI32 inputEventId2,PxI32 inputEventId3,PxI32 inputEventId4);
void requestToClose() { mIsCloseRequested = true; }
bool isCloseRequested() { return mIsCloseRequested; }
private:
PxReal mTextAlphaHelp;
PxReal mTextAlphaDesc;
MenuType::Enum mMenuType;
std::vector<MenuTogglableItem> mMenuVisualizations;
size_t mMenuVisualizationsIndexSelected;
void setMenuVisualizations(MenuTogglableItem& togglableItem);
char m_Msg[512];
PxTransform mSavedView;
bool mIsCloseRequested;
protected:
Console* mConsole;
Camera mCamera;
DefaultCameraController mCameraController;
CameraController* mCurrentCameraController;
std::vector<SampleRenderer::RendererLight*> mLights;
RenderMaterial* mManagedMaterials[MATERIAL_COUNT];
RenderPhysX3Debug* mDebugRenderer;
bool mPause;
bool mOneFrameUpdate;
bool mSwitchSample;
bool mShowHelp;
bool mShowDescription;
bool mShowExtendedHelp;
volatile bool mHideMouseCursor;
InputEventBuffer* mInputEventBuffer;
Ps::MutexT<RawAllocator> mInputMutex;
bool mDrawScreenQuad;
SampleRenderer::RendererColor mScreenQuadTopColor;
SampleRenderer::RendererColor mScreenQuadBottomColor;
PvdParameters mPvdParams;
void updateCameraViewport(PxU32 w, PxU32 h);
bool initLogo();
private:
bool handleMenuKey(MenuKey::Enum menuKey);
void handleSettingMenuKey(MenuKey::Enum menuKey);
void refreshVisualizationMenuState(PxVisualizationParameter::Enum p);
void toggleDebugRenderer();
//-----------------------------------------------------------------------------
// PhysXSampleManager
//-----------------------------------------------------------------------------
public:
static bool registerSample(SampleCreator creator, const char* fullPath)
{
return addSample(getSampleTreeRoot(), creator, fullPath);
}
bool getNextSample();
void switchSample();
protected:
static Test::TestGroup* mSampleTreeRoot;
static Test::TestGroup& getSampleTreeRoot();
static bool addSample(Test::TestGroup& root, SampleCreator creator, const char* fullPath);
public:
bool mMenuExpand;
Test::TestGroup* mRunning;
Test::TestGroup* mSelected;
PhysXSample* mSample;
const char* mDefaultSamplePath;
};
const char* getSampleMediaFilename(const char* filename);
PxToolkit::BasicRandom& getSampleRandom();
PxErrorCallback& getSampleErrorCallback();
//=============================================================================
// macro REGISTER_SAMPLE
//-----------------------------------------------------------------------------
class SampleFunctionCreator : public PhysXSampleCreator
{
public:
SampleFunctionCreator(FunctionCreator func) : mFunc(func) {}
virtual PhysXSample* operator()(PhysXSampleApplication& app) const { return (*mFunc)(app); }
private:
FunctionCreator mFunc;
};
#define SAMPLE_CREATOR(className) create##className
#define SAMPLE_STARTER(className) className##Starter
#define SAMPLE_CREATOR_VAR(className) g##className##creator
#define REGISTER_SAMPLE(className, fullPath) \
static PhysXSample* SAMPLE_CREATOR(className)(PhysXSampleApplication& app) { \
return SAMPLE_NEW(className)(app); \
} \
static SampleFunctionCreator SAMPLE_CREATOR_VAR(className)(SAMPLE_CREATOR(className)); \
struct SAMPLE_STARTER(className) { \
SAMPLE_STARTER(className)() { \
PhysXSampleApplication::registerSample(&SAMPLE_CREATOR_VAR(className), fullPath); \
} \
} g##className##Starter;
///////////////////////////////////////////////////////////////////////////////
#endif

View File

@ -0,0 +1,289 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "PxScene.h"
#include "PxQueryReport.h"
#include "PxBatchQueryDesc.h"
#include "extensions/PxJoint.h"
#include "PxRigidDynamic.h"
#include "extensions/PxDistanceJoint.h"
#include "extensions/PxSphericalJoint.h"
#include "PxArticulationLink.h"
#include "PxShape.h"
#include "Picking.h"
#include "RendererMemoryMacros.h"
#if PX_UNIX_FAMILY
#include <stdio.h>
#endif
using namespace physx; // PT: please DO NOT indent the whole file
Picking::Picking(PhysXSample& frame) :
mSelectedActor (NULL),
mMouseJoint (NULL),
mMouseActor (NULL),
mMouseActorToDelete (NULL),
mDistanceToPicked (0.0f),
mMouseScreenX (0),
mMouseScreenY (0),
mFrame (frame)
{
}
Picking::~Picking() {}
bool Picking::isPicked() const
{
return mMouseJoint!=0;
}
void Picking::moveCursor(PxI32 x, PxI32 y)
{
mMouseScreenX = x;
mMouseScreenY = y;
}
/*void Picking::moveCursor(PxReal deltaDepth)
{
const PxReal range[2] = { 0.0f, 1.0f };
const PxReal r = (range[1] - range[0]);
const PxReal d = (mMouseDepth - range[0])/r;
const PxReal delta = deltaDepth*0.02f*(1.0f - d);
mMouseDepth = PxClamp(mMouseDepth + delta, range[0], range[1]);
}*/
void Picking::tick()
{
if(mMouseJoint)
moveActor(mMouseScreenX,mMouseScreenY);
// PT: delete mouse actor one frame later to avoid crashes
SAFE_RELEASE(mMouseActorToDelete);
}
void Picking::computeCameraRay(PxVec3& orig, PxVec3& dir, PxI32 x, PxI32 y) const
{
const PxVec3& camPos = mFrame.getCamera().getPos();
// compute picking ray
// const PxVec3 rayOrig = unProject(x, y, 0.0f); // PT: what the frell is that?
const PxVec3 rayOrig = camPos;
const PxVec3 rayDir = (unProject(x, y, 1.0f) - rayOrig).getNormalized();
orig = rayOrig;
dir = rayDir;
}
bool Picking::pick(int x, int y)
{
PxScene& scene = mFrame.getActiveScene();
PxVec3 rayOrig, rayDir;
computeCameraRay(rayOrig, rayDir, x, y);
// raycast rigid bodies in scene
PxRaycastHit hit; hit.shape = NULL;
PxRaycastBuffer hit1;
scene.raycast(rayOrig, rayDir, PX_MAX_F32, hit1, PxHitFlag::ePOSITION);
hit = hit1.block;
if(hit.shape)
{
const char* shapeName = hit.shape->getName();
if(shapeName)
shdfnd::printFormatted("Picked shape name: %s\n", shapeName);
PxRigidActor* actor = hit.actor;
PX_ASSERT(actor);
mSelectedActor = static_cast<PxRigidActor*>(actor->is<PxRigidDynamic>());
if(!mSelectedActor)
mSelectedActor = static_cast<PxRigidActor*>(actor->is<PxArticulationLink>());
//ML::this is very useful to debug some collision problem
PxTransform t = actor->getGlobalPose();
PX_UNUSED(t);
shdfnd::printFormatted("id = %i\n PxTransform transform(PxVec3(%f, %f, %f), PxQuat(%f, %f, %f, %f))\n", reinterpret_cast<size_t>(actor->userData), t.p.x, t.p.y, t.p.z, t.q.x, t.q.y, t.q.z, t.q.w);
}
else
mSelectedActor = 0;
if(mSelectedActor)
{
shdfnd::printFormatted("Actor '%s' picked! (userData: %p)\n", mSelectedActor->getName(), mSelectedActor->userData);
//if its a dynamic rigid body, joint it for dragging purposes:
grabActor(hit.position, rayOrig);
}
#ifdef VISUALIZE_PICKING_RAYS
Ray ray;
ray.origin = rayOrig;
ray.dir = rayDir;
mRays.push_back(ray);
#endif
return true;
}
//----------------------------------------------------------------------------//
PxActor* Picking::letGo()
{
// let go any picked actor
if(mMouseJoint)
{
mMouseJoint->release();
mMouseJoint = NULL;
// SAFE_RELEASE(mMouseActor); // PT: releasing immediately crashes
PX_ASSERT(!mMouseActorToDelete);
mMouseActorToDelete = mMouseActor; // PT: instead, we mark for deletion next frame
}
PxActor* returnedActor = mSelectedActor;
mSelectedActor = NULL;
return returnedActor;
}
//----------------------------------------------------------------------------//
void Picking::grabActor(const PxVec3& worldImpact, const PxVec3& rayOrigin)
{
if(!mSelectedActor
|| (mSelectedActor->getType() != PxActorType::eRIGID_DYNAMIC
&& mSelectedActor->getType() != PxActorType::eARTICULATION_LINK))
return;
PxScene& scene = mFrame.getActiveScene();
PxPhysics& physics = scene.getPhysics();
//create a shape less actor for the mouse
{
mMouseActor = physics.createRigidDynamic(PxTransform(worldImpact, PxQuat(PxIdentity)));
mMouseActor->setRigidBodyFlag(PxRigidBodyFlag::eKINEMATIC, true);
mMouseActor->setMass(1.0f);
mMouseActor->setMassSpaceInertiaTensor(PxVec3(1.0f, 1.0f, 1.0f));
scene.addActor(*mMouseActor);
}
PxRigidActor* pickedActor = static_cast<PxRigidActor*>(mSelectedActor);
#if USE_D6_JOINT_FOR_MOUSE
mMouseJoint = PxD6JointCreate( physics,
mMouseActor,
PxTransform(PxIdentity),
pickedActor,
PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact)));
mMouseJoint->setMotion(PxD6Axis::eSWING1, PxD6Motion::eFREE);
mMouseJoint->setMotion(PxD6Axis::eSWING2, PxD6Motion::eFREE);
mMouseJoint->setMotion(PxD6Axis::eTWIST, PxD6Motion::eFREE);
#elif USE_SPHERICAL_JOINT_FOR_MOUSE
mMouseJoint = PxSphericalJointCreate(physics,
mMouseActor,
PxTransform(PxIdentity),
pickedActor,
PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact)));
#else
mMouseJoint = PxDistanceJointCreate(physics,
mMouseActor,
PxTransform(PxIdentity),
pickedActor,
PxTransform(pickedActor->getGlobalPose().transformInv(worldImpact)));
mMouseJoint->setMaxDistance(0.0f);
mMouseJoint->setMinDistance(0.0f);
mMouseJoint->setDistanceJointFlags(PxDistanceJointFlag::eMAX_DISTANCE_ENABLED);
#endif
mDistanceToPicked = (worldImpact - rayOrigin).magnitude();
}
//----------------------------------------------------------------------------//
void Picking::moveActor(int x, int y)
{
if(!mMouseActor)
return;
PxVec3 rayOrig, rayDir;
computeCameraRay(rayOrig, rayDir, x, y);
const PxVec3 pos = rayOrig + mDistanceToPicked * rayDir;
mMouseActor->setKinematicTarget(PxTransform(pos, PxQuat(PxIdentity)));
}
//----------------------------------------------------------------------------//
PxVec3 Picking::unProject(int x, int y, float depth) const
{
SampleRenderer::Renderer* renderer = mFrame.getRenderer();
const SampleRenderer::RendererProjection& projection = mFrame.getCamera().getProjMatrix();
const PxTransform view = mFrame.getCamera().getViewMatrix().getInverse();
PxU32 windowWidth = 0;
PxU32 windowHeight = 0;
renderer->getWindowSize(windowWidth, windowHeight);
const PxF32 outX = (float)x / (float)windowWidth;
const PxF32 outY = (float)y / (float)windowHeight;
return SampleRenderer::unproject(projection, view, outX * 2 -1, outY * 2 -1, depth * 2 - 1);
}
//----------------------------------------------------------------------------//
void Picking::project(const physx::PxVec3& v, int& xi, int& yi, float& depth) const
{
SampleRenderer::Renderer* renderer = mFrame.getRenderer();
SampleRenderer::RendererProjection projection = mFrame.getCamera().getProjMatrix();
const PxTransform view = mFrame.getCamera().getViewMatrix().getInverse();
PxVec3 pos = SampleRenderer::project(projection, view, v);
///* Map x, y and z to range 0-1 */
pos.x = (pos.x + 1 ) * 0.5f;
pos.y = (pos.y + 1 ) * 0.5f;
pos.z = (pos.z + 1 ) * 0.5f;
PxU32 windowWidth = 0;
PxU32 windowHeight = 0;
renderer->getWindowSize(windowWidth, windowHeight);
/* Map x,y to viewport */
pos.x *= windowWidth;
pos.y *= windowHeight;
depth = (float)pos.z;
xi = (int)(pos.x + 0.5);
yi = (int)(pos.y + 0.5);
}

View File

@ -0,0 +1,121 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef PICKING_H
#define PICKING_H
#include "foundation/PxSimpleTypes.h"
#include "foundation/PxVec3.h"
#include "extensions/PxD6Joint.h"
#include "extensions/PxSphericalJoint.h"
#include "PhysXSample.h"
#include "RendererProjection.h"
#define USE_D6_JOINT_FOR_MOUSE 1 // PT: please keep it 0 for interactive tests where one needs to rotate objects
#define USE_SPHERICAL_JOINT_FOR_MOUSE 0
//#define VISUALIZE_PICKING_RAYS
namespace physx
{
class PxActor;
class PxDistanceJoint;
class PxRigidDynamic;
class PxScene;
class PxPhysics;
}
namespace physx {
struct PickingCommands
{
enum Enum
{
PICK_START, //Bound to mouse 1 down
PICK_STOP, //bound to mouse 1 up
SCREEN_MOTION_CURSOR, //See DefaultMovementStrategy
SCREEN_MOTION_CURSOR_DEPTH, //See DefaultMovementStrategy
};
};
class Picking
{
public:
Picking(PhysXSample& frame);
~Picking();
PX_FORCE_INLINE void lazyPick() { pick(mMouseScreenX, mMouseScreenY); }
bool isPicked() const;
bool pick(int x, int y);
void moveCursor(PxI32 x, PxI32 y);
// void moveCursor(PxReal deltaDepth);
void computeCameraRay(PxVec3& orig, PxVec3& dir, PxI32 x, PxI32 y) const;
// returns picked actor
PxActor* letGo();
void tick();
void project(const physx::PxVec3& v, int& xi, int& yi, float& depth) const;
#ifdef VISUALIZE_PICKING_RAYS
struct Ray
{
PxVec3 origin;
PxVec3 dir;
};
PX_FORCE_INLINE const std::vector<Ray>& getRays() const { return mRays; }
#endif
private:
void grabActor(const PxVec3& worldImpact, const PxVec3& rayOrigin);
void moveActor(int x, int y);
PxVec3 unProject( int x, int y, float depth) const;
PxActor* mSelectedActor;
#if USE_D6_JOINT_FOR_MOUSE
PxD6Joint* mMouseJoint; // was PxDistanceJoint, PxSphericalJoint, PxD6Joint
#elif USE_SPHERICAL_JOINT_FOR_MOUSE
PxSphericalJoint* mMouseJoint;
#else
PxDistanceJoint* mMouseJoint;
#endif
PxRigidDynamic* mMouseActor;
PxRigidDynamic* mMouseActorToDelete;
PxReal mDistanceToPicked;
int mMouseScreenX, mMouseScreenY;
PhysXSample& mFrame;
#ifdef VISUALIZE_PICKING_RAYS
std::vector<Ray> mRays;
#endif
};
}
#endif

View File

@ -0,0 +1,415 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
// PT: this file is a loader for "raw" binary files. It should NOT create SDK objects directly.
#include <stdio.h>
#include "foundation/PxPreprocessor.h"
#include "RawLoader.h"
#include "RendererColor.h"
#include "RendererMemoryMacros.h"
#include "SampleAllocatorSDKClasses.h"
#include "PxTkFile.h"
using namespace SampleRenderer;
RAWObject::RAWObject() : mName(NULL)
{
mTransform = PxTransform(PxIdentity);
}
RAWTexture::RAWTexture() :
mID (0xffffffff),
mWidth (0),
mHeight (0),
mHasAlpha (false),
mPixels (NULL)
{
}
RAWMesh::RAWMesh() :
mNbVerts (0),
mNbFaces (0),
mMaterialID (0xffffffff),
mVerts (NULL),
mVertexNormals (NULL),
mVertexColors (NULL),
mUVs (NULL),
mIndices (NULL)
{
}
RAWShape::RAWShape() :
mNbVerts (0),
mVerts (NULL)
{
}
RAWHelper::RAWHelper()
{
}
RAWMaterial::RAWMaterial() :
mID (0xffffffff),
mDiffuseID (0xffffffff),
mOpacity (1.0f),
mDoubleSided (false)
{
mAmbientColor = PxVec3(0);
mDiffuseColor = PxVec3(0);
mSpecularColor = PxVec3(0);
}
#if PX_INTEL_FAMILY
static const bool gFlip = false;
#elif PX_PPC
static const bool gFlip = true;
#elif PX_ARM_FAMILY
static const bool gFlip = false;
#else
#error Unknown platform!
#endif
PX_INLINE void Flip(PxU32& v)
{
PxU8* b = (PxU8*)&v;
PxU8 temp = b[0];
b[0] = b[3];
b[3] = temp;
temp = b[1];
b[1] = b[2];
b[2] = temp;
}
PX_INLINE void Flip(PxI32& v)
{
Flip((PxU32&)v);
}
PX_INLINE void Flip(PxF32& v)
{
Flip((PxU32&)v);
}
static PxU8 read8(File* fp)
{
PxU8 data;
size_t numRead = fread(&data, 1, 1, fp);
if(numRead != 1) { return 0; }
return data;
}
static PxU32 read32(File* fp)
{
PxU32 data;
size_t numRead = fread(&data, 1, 4, fp);
if(numRead != 4) { return 0; }
if(gFlip)
Flip(data);
return data;
}
static PxF32 readFloat(File* fp)
{
PxF32 data;
size_t numRead = fread(&data, 1, 4, fp);
if(numRead != 4) { return 0; }
if(gFlip)
Flip(data);
return data;
}
static PxTransform readTransform(File* fp, PxReal scale)
{
PxTransform tr;
tr.p.x = scale * readFloat(fp);
tr.p.y = scale * readFloat(fp);
tr.p.z = scale * readFloat(fp);
tr.q.x = readFloat(fp);
tr.q.y = readFloat(fp);
tr.q.z = readFloat(fp);
tr.q.w = readFloat(fp);
PX_ASSERT(tr.isValid());
return tr;
}
static void readVertexArray(File* fp, PxVec3* verts, PxU32 nbVerts)
{
const size_t size = 4*3*nbVerts;
size_t numRead = fread(verts, 1, size, fp);
if(numRead != size) { return; }
if(gFlip)
{
for(PxU32 j=0;j<nbVerts;j++)
{
Flip(verts[j].x);
Flip(verts[j].y);
Flip(verts[j].z);
}
}
}
static void readUVs(File* fp, PxReal* uvs, PxU32 nbVerts)
{
const size_t size = 4*2*nbVerts;
size_t numRead = fread(uvs, 1, size, fp);
if(numRead != size) { return; }
if(gFlip)
{
for(PxU32 j=0;j<nbVerts*2;j++)
Flip(uvs[j]);
}
}
static void readVertices(File* fp, PxVec3* verts, PxU32 nbVerts, PxReal scale)
{
readVertexArray(fp, verts, nbVerts);
for(PxU32 j=0;j<nbVerts;j++)
verts[j] *= scale;
}
static void readNormals(File* fp, PxVec3* verts, PxU32 nbVerts)
{
readVertexArray(fp, verts, nbVerts);
}
static void readVertexColors(File* fp, PxVec3* colors, PxU32 nbVerts)
{
readVertexArray(fp, colors, nbVerts);
}
static void readName(File* fp, char* objectName)
{
PxU32 offset=0;
char c;
do
{
size_t numRead = fread(&c, 1, 1, fp);
if(numRead != 1) { c = '\0';}
objectName[offset++] = c;
}while(c);
objectName[offset]=0;
}
bool loadRAWfile(const char* filename, RAWImportCallback& cb, PxReal scale)
{
File* fp = NULL;
PxToolkit::fopen_s(&fp, filename, "rb");
if(!fp)
return false;
// General info
const PxU32 tag = read32(fp);
const PxU32 generalVersion = read32(fp);
const PxU32 nbMaterials = read32(fp);
const PxU32 nbTextures = read32(fp);
const PxU32 nbMeshes = read32(fp);
const PxU32 nbShapes = read32(fp);
const PxU32 nbHelpers = read32(fp);
(void)tag;
(void)generalVersion;
char objectName[512];
// Textures
for(PxU32 i=0;i<nbTextures;i++)
{
RAWTexture data;
readName(fp, objectName);
data.mName = objectName;
data.mTransform = PxTransform(PxIdentity); // PT: texture transform not supported yet
data.mID = read32(fp);
RendererColorAlloc* pixels = NULL;
if(read8(fp))
{
data.mWidth = read32(fp);
data.mHeight = read32(fp);
data.mHasAlpha = read8(fp)!=0;
const PxU32 nbPixels = data.mWidth*data.mHeight;
pixels = SAMPLE_NEW(RendererColorAlloc)[nbPixels];
data.mPixels = pixels;
for(PxU32 i=0;i<nbPixels;i++)
{
pixels[i].r = read8(fp);
pixels[i].g = read8(fp);
pixels[i].b = read8(fp);
if(data.mHasAlpha)
pixels[i].a = read8(fp);
else
pixels[i].a = 0xff;
}
}
else
{
data.mWidth = 0;
data.mHeight = 0;
data.mHasAlpha = false;
data.mPixels = NULL;
}
cb.newTexture(data);
DELETEARRAY(pixels);
}
// Materials
for(PxU32 i=0;i<nbMaterials;i++)
{
RAWMaterial data;
data.mID = read32(fp);
data.mDiffuseID = read32(fp);
data.mOpacity = readFloat(fp);
data.mDoubleSided = read32(fp)!=0;
data.mAmbientColor.x = readFloat(fp);
data.mAmbientColor.y = readFloat(fp);
data.mAmbientColor.z = readFloat(fp);
data.mDiffuseColor.x = readFloat(fp);
data.mDiffuseColor.y = readFloat(fp);
data.mDiffuseColor.z = readFloat(fp);
data.mSpecularColor.x = readFloat(fp);
data.mSpecularColor.y = readFloat(fp);
data.mSpecularColor.z = readFloat(fp);
cb.newMaterial(data);
}
// Meshes
for(PxU32 i=0;i<nbMeshes;i++)
{
RAWMesh data;
readName(fp, objectName);
data.mName = objectName;
data.mTransform = readTransform(fp, scale);
//
data.mNbVerts = read32(fp);
data.mNbFaces = read32(fp);
const PxU32 hasVertexColors = read32(fp);
const PxU32 hasUVs = read32(fp);
data.mMaterialID = read32(fp);
PxVec3Alloc* tmpVerts = SAMPLE_NEW(PxVec3Alloc)[data.mNbVerts];
PxVec3Alloc* tmpNormals = SAMPLE_NEW(PxVec3Alloc)[data.mNbVerts];
PxVec3Alloc* tmpColors = NULL;
PxReal* tmpUVs = NULL;
data.mVerts = tmpVerts;
data.mVertexNormals = tmpNormals;
data.mVertexColors = NULL;
data.mUVs = NULL;
readVertices(fp, tmpVerts, data.mNbVerts, scale);
readNormals(fp, tmpNormals, data.mNbVerts);
if(hasVertexColors)
{
tmpColors = SAMPLE_NEW(PxVec3Alloc)[data.mNbVerts];
data.mVertexColors = tmpColors;
readVertexColors(fp, tmpColors, data.mNbVerts);
}
if(hasUVs)
{
tmpUVs = (PxReal*)SAMPLE_ALLOC(sizeof(PxReal)*data.mNbVerts*2);
data.mUVs = tmpUVs;
readUVs(fp, tmpUVs, data.mNbVerts);
}
PxU32* tmpIndices = (PxU32*)SAMPLE_ALLOC(sizeof(PxU32)*data.mNbFaces*3);
data.mIndices = tmpIndices;
const size_t size = 4*3*data.mNbFaces;
size_t numRead = fread(tmpIndices, 1, size, fp);
if(numRead != size)
{
SAMPLE_FREE(tmpIndices);
SAMPLE_FREE(tmpUVs);
DELETEARRAY(tmpColors);
DELETEARRAY(tmpNormals);
DELETEARRAY(tmpVerts);
return false;
}
if(gFlip)
{
for(PxU32 j=0;j<data.mNbFaces*3;j++)
{
Flip(tmpIndices[j]);
}
}
cb.newMesh(data);
SAMPLE_FREE(tmpIndices);
SAMPLE_FREE(tmpUVs);
DELETEARRAY(tmpColors);
DELETEARRAY(tmpNormals);
DELETEARRAY(tmpVerts);
}
// Shapes
for(PxU32 i=0;i<nbShapes;i++)
{
RAWShape data;
readName(fp, objectName);
data.mName = objectName;
data.mTransform = readTransform(fp, scale);
//
data.mNbVerts = read32(fp);
PxVec3Alloc* tmp = SAMPLE_NEW(PxVec3Alloc)[data.mNbVerts];
data.mVerts = tmp;
readVertices(fp, tmp, data.mNbVerts, scale);
cb.newShape(data);
DELETEARRAY(tmp);
}
// Helpers
for(PxU32 i=0;i<nbHelpers;i++)
{
RAWHelper data;
readName(fp, objectName);
data.mName = objectName;
data.mTransform = readTransform(fp, scale);
}
return true;
}

View File

@ -0,0 +1,120 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RAW_LOADER_H
#define RAW_LOADER_H
#include "SampleAllocator.h"
#include "foundation/PxTransform.h"
namespace SampleRenderer
{
class RendererColor;
}
class RAWObject : public SampleAllocateable
{
public:
RAWObject();
const char* mName;
PxTransform mTransform;
};
class RAWTexture : public RAWObject
{
public:
RAWTexture();
PxU32 mID;
PxU32 mWidth;
PxU32 mHeight;
bool mHasAlpha;
const SampleRenderer::RendererColor* mPixels;
};
class RAWMesh : public RAWObject
{
public:
RAWMesh();
PxU32 mNbVerts;
PxU32 mNbFaces;
PxU32 mMaterialID;
const PxVec3* mVerts;
const PxVec3* mVertexNormals;
const PxVec3* mVertexColors;
const PxReal* mUVs;
const PxU32* mIndices;
};
class RAWShape : public RAWObject
{
public:
RAWShape();
PxU32 mNbVerts;
const PxVec3* mVerts;
};
class RAWHelper : public RAWObject
{
public:
RAWHelper();
};
class RAWMaterial : public SampleAllocateable
{
public:
RAWMaterial();
PxU32 mID;
PxU32 mDiffuseID;
PxReal mOpacity;
PxVec3 mAmbientColor;
PxVec3 mDiffuseColor;
PxVec3 mSpecularColor;
bool mDoubleSided;
};
class RAWImportCallback
{
public:
virtual ~RAWImportCallback() {}
virtual void newMaterial(const RAWMaterial&) = 0;
virtual void newMesh(const RAWMesh&) = 0;
virtual void newShape(const RAWShape&) = 0;
virtual void newHelper(const RAWHelper&) = 0;
virtual void newTexture(const RAWTexture&) = 0;
};
bool loadRAWfile(const char* filename, RAWImportCallback& cb, PxReal scale);
#endif

View File

@ -0,0 +1,252 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RaycastCCD.h"
#include "geometry/PxBoxGeometry.h"
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxCapsuleGeometry.h"
#include "geometry/PxConvexMeshGeometry.h"
#include "geometry/PxConvexMesh.h"
#include "PxQueryReport.h"
#include "PxScene.h"
#include "PxRigidDynamic.h"
#include "extensions/PxShapeExt.h"
#include <stdio.h>
//#define RAYCAST_CCD_PRINT_DEBUG
PxVec3 getShapeCenter(PxRigidActor* actor, PxShape* shape, const PxVec3& localOffset)
{
PxVec3 offset = localOffset;
switch(shape->getGeometryType())
{
case PxGeometryType::eCONVEXMESH:
{
PxConvexMeshGeometry geometry;
bool status = shape->getConvexMeshGeometry(geometry);
PX_UNUSED(status);
PX_ASSERT(status);
PxReal mass;
PxMat33 localInertia;
PxVec3 localCenterOfMass;
geometry.convexMesh->getMassInformation(mass, localInertia, localCenterOfMass);
offset += localCenterOfMass;
}
break;
default:
break;
}
const PxTransform pose = PxShapeExt::getGlobalPose(*shape, *actor);
return pose.transform(offset);
}
static PxReal computeInternalRadius(PxRigidActor* actor, PxShape* shape, const PxVec3& dir, /*PxVec3& offset,*/ const PxVec3& centerOffset)
{
const PxBounds3 bounds = PxShapeExt::getWorldBounds(*shape, *actor);
const PxReal diagonal = (bounds.maximum - bounds.minimum).magnitude();
const PxReal offsetFromOrigin = diagonal * 2.0f;
PxTransform pose = PxShapeExt::getGlobalPose(*shape, *actor);
PxReal internalRadius = 0.0f;
const PxReal length = offsetFromOrigin*2.0f;
// PT: we do a switch here anyway since the code is not *exactly* the same all the time
{
switch(shape->getGeometryType())
{
case PxGeometryType::eBOX:
case PxGeometryType::eCAPSULE:
{
pose.p = PxVec3(0);
const PxVec3 virtualOrigin = pose.p + dir * offsetFromOrigin;
PxRaycastHit hit;
const PxHitFlags sceneQueryFlags = PxHitFlag::ePOSITION|PxHitFlag::eNORMAL;
PxU32 nbHits = PxGeometryQuery::raycast(virtualOrigin, -dir, shape->getGeometry().any(), pose, length, sceneQueryFlags, 1, &hit);
PX_UNUSED(nbHits);
PX_ASSERT(nbHits);
internalRadius = offsetFromOrigin - hit.distance;
// offset = PxVec3(0.0f);
}
break;
case PxGeometryType::eSPHERE:
{
PxSphereGeometry geometry;
bool status = shape->getSphereGeometry(geometry);
PX_UNUSED(status);
PX_ASSERT(status);
internalRadius = geometry.radius;
// offset = PxVec3(0.0f);
}
break;
case PxGeometryType::eCONVEXMESH:
{
/*PxVec3 saved = pose.p;
pose.p = PxVec3(0);
// pose.p = geometry.convexMesh->getCenterOfMass();
// const PxVec3 virtualOrigin = pose.p + dir * offsetFromOrigin;
// const PxVec3 localCenter = computeCenter(geometry.convexMesh);
// const PxVec3 localCenter = geometry.convexMesh->getCenterOfMass();
// const PxVec3 virtualOrigin = pose.rotate(localCenter) + dir * offsetFromOrigin;
const PxVec3 localCenter = pose.rotate(geometry.convexMesh->getCenterOfMass());
const PxVec3 virtualOrigin = localCenter + dir * offsetFromOrigin;
PxRaycastHit hit;
PxU32 nbHits = Gu::raycast_convexMesh(geometry, pose, virtualOrigin, -dir, length, 0xffffffff, 1, &hit);
PX_ASSERT(nbHits);
internalRadius = offsetFromOrigin - hit.distance;
pose.p = localCenter;
PxVec3 shapeCenter = getShapeCenter(shape);
offset = shapeCenter - saved;*/
PxVec3 shapeCenter = getShapeCenter(actor, shape, centerOffset);
shapeCenter -= pose.p;
pose.p = PxVec3(0);
const PxVec3 virtualOrigin = shapeCenter + dir * offsetFromOrigin;
PxRaycastHit hit;
const PxHitFlags sceneQueryFlags = PxHitFlag::ePOSITION|PxHitFlag::eNORMAL;
PxU32 nbHits = PxGeometryQuery::raycast(virtualOrigin, -dir, shape->getGeometry().any(), pose, length, sceneQueryFlags, 1, &hit);
PX_UNUSED(nbHits);
PX_ASSERT(nbHits);
internalRadius = offsetFromOrigin - hit.distance;
// offset = shapeCenter;
}
break;
default:
break;
}
}
return internalRadius;
}
static bool CCDRaycast(PxScene* scene, const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxRaycastHit& hit)
{
const PxHitFlags outputFlags = PxHitFlag::ePOSITION|PxHitFlag::eNORMAL;
PxQueryFilterData filterData;
filterData.flags = PxQueryFlag::eSTATIC;
PxQueryFilterCallback* filterCall = NULL;
PxRaycastBuffer buf1;
scene->raycast(origin, unitDir, distance, buf1, outputFlags, filterData, filterCall, NULL);
hit = buf1.block;
return buf1.hasBlock;
}
static PxRigidDynamic* canDoCCD(PxRigidActor& actor, PxShape* shape)
{
PxRigidDynamic* dyna = actor.is<PxRigidDynamic>();
if(!dyna)
return NULL; // PT: no need to do it for statics
const PxU32 nbShapes = dyna->getNbShapes();
if(nbShapes!=1)
return NULL; // PT: only works with simple actors for now
if(dyna->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC)
return NULL; // PT: no need to do it for kinematics
return dyna;
}
bool doRaycastCCD(PxRigidActor* actor, PxShape* shape, PxTransform& newPose, PxVec3& newShapeCenter, const PxVec3& ccdWitness, const PxVec3& ccdWitnessOffset)
{
PxRigidDynamic* dyna = canDoCCD(*actor, shape);
if(!dyna)
return true;
bool updateCCDWitness = true;
const PxVec3 offset = newPose.p - newShapeCenter;
const PxVec3& origin = ccdWitness;
const PxVec3& dest = newShapeCenter;
PxVec3 dir = dest - origin;
const PxReal length = dir.magnitude();
if(length!=0.0f)
{
dir /= length;
// Compute internal radius
const PxReal internalRadius = computeInternalRadius(actor, shape, dir, ccdWitnessOffset);
// Compute distance to impact
PxRaycastHit hit;
if(internalRadius!=0.0f && CCDRaycast(actor->getScene(), origin, dir, length, hit))
{
#ifdef RAYCAST_CCD_PRINT_DEBUG
static int count=0;
shdfnd::printFormatted("CCD hit %d\n", count++);
#endif
updateCCDWitness = false;
const PxReal radiusLimit = internalRadius * 0.75f;
if(hit.distance>radiusLimit)
{
newShapeCenter = origin + dir * (hit.distance - radiusLimit);
#ifdef RAYCAST_CCD_PRINT_DEBUG
shdfnd::printFormatted(" Path0: %f | %f\n", hit.distance, radiusLimit);
#endif
}
else
{
newShapeCenter = origin;
#ifdef RAYCAST_CCD_PRINT_DEBUG
shdfnd::printFormatted(" Path1: %f\n", hit.distance);
#endif
}
{
newPose.p = offset + newShapeCenter;
const PxTransform shapeLocalPose = shape->getLocalPose();
const PxTransform inverseShapeLocalPose = shapeLocalPose.getInverse();
PxTransform newGlobalPose = newPose * inverseShapeLocalPose;
dyna->setGlobalPose(newGlobalPose);
}
}
}
return updateCCDWitness;
}

View File

@ -0,0 +1,46 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RAYCAST_CCD_H
#define RAYCAST_CCD_H
#include "common/PxPhysXCommonConfig.h"
using namespace physx;
namespace physx
{
class PxShape;
class PxRigidActor;
}
PxVec3 getShapeCenter(PxRigidActor* actor, PxShape* shape, const PxVec3& localOffset);
bool doRaycastCCD(PxRigidActor* actor, PxShape* shape, PxTransform& pose, PxVec3& newShapeCenter, const PxVec3& ccdWitness, const PxVec3& ccdWitnessOffset);
#endif

View File

@ -0,0 +1,279 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "SamplePreprocessor.h"
#include "RenderBaseActor.h"
#include "RenderMaterial.h"
#include "RendererShape.h"
#include "Renderer.h"
#include "RendererMemoryMacros.h"
#include "extensions/PxShapeExt.h"
#include "RaycastCCD.h"
#include "RenderPhysX3Debug.h"
#include "PxRigidDynamic.h"
#include "PxArticulationLink.h"
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxBoxGeometry.h"
#include "RenderSphereActor.h"
#include "RenderCapsuleActor.h"
using namespace physx;
using namespace SampleRenderer;
static const bool gRaycastCCD = true;
RenderBaseActor::RenderBaseActor() :
mRendererShape (NULL),
mPhysicsShape (NULL),
mDynamicActor (NULL),
mArticulationLink (NULL),
mMaterial (NULL),
mEnableCCD (false),
mEnableRender (true),
mEnableDebugRender (true),
mEnableCameraCull (false)
{
mTransform = PxTransform(PxIdentity);
mWorldBounds = PxBounds3(PxVec3(0),PxVec3(0));
mCCDWitness = PxVec3(0);
mCCDWitnessOffset = PxVec3(0);
mPhysicsToGraphicsRot = PxQuat(PxIdentity);
updateScale();
}
RenderBaseActor::RenderBaseActor(const RenderBaseActor& src) : RenderBaseObject(src)
{
mEnableCCD = src.mEnableCCD;
mEnableRender = src.mEnableRender;
mEnableDebugRender = src.mEnableDebugRender;
mEnableCameraCull = src.mEnableCameraCull;
mTransform = src.getTransform();
mWorldBounds = PxBounds3(PxVec3(0.0f), PxVec3(0.0f));
mPhysicsShape = NULL; // PT: the physics shape is not cloned for now
mDynamicActor = NULL; // PT: the physics actor is not cloned for now
mArticulationLink = NULL; // PT: the articulation link is not cloned for now
mMaterial = src.getRenderMaterial();
mRendererShape = NULL;
setRenderShape(src.getRenderShape());
mPhysicsToGraphicsRot = src.mPhysicsToGraphicsRot;
mCCDWitness = src.mCCDWitness;
mCCDWitnessOffset = src.mCCDWitnessOffset;
mScaling = src.mScaling;
updateScale();
}
RenderBaseActor::~RenderBaseActor()
{
deleteRenderShape();
mMaterial = NULL; // PT: we don't own this
mPhysicsShape = NULL; // PT: we don't own this
mDynamicActor = NULL; // PT: we don't own this
}
void RenderBaseActor::update(float deltaTime)
{
// Setup render transform from physics transform, if physics object exists
if(mPhysicsShape)
{
if(!mArticulationLink && ( !mDynamicActor || mDynamicActor->isSleeping()))
return;
PxTransform newPose = PxShapeExt::getGlobalPose(*mPhysicsShape, *mPhysicsActor);
PxVec3 newShapeCenter = getShapeCenter(mPhysicsActor, mPhysicsShape, mCCDWitnessOffset);
bool updateCCDWitness = true;
if(gRaycastCCD && mEnableCCD)
updateCCDWitness = doRaycastCCD(mPhysicsActor, mPhysicsShape, newPose, newShapeCenter, mCCDWitness, mCCDWitnessOffset);
// Copy physics pose to graphics pose
setTransform(PxTransform(newPose.p, newPose.q * mPhysicsToGraphicsRot));
if(updateCCDWitness)
mCCDWitness = newShapeCenter;
setWorldBounds(PxShapeExt::getWorldBounds(*mPhysicsShape, *mPhysicsActor));
}
}
void RenderBaseActor::render(Renderer& renderer, RenderMaterial* material, bool wireFrame)
{
if(!mEnableRender)
return;
RenderMaterial* m = mMaterial ? mMaterial : material;
PX_ASSERT(m);
mRendererMeshContext.cullMode = m->mDoubleSided ? RendererMeshContext::NONE : RendererMeshContext::CLOCKWISE;
mRendererMeshContext.fillMode = wireFrame ? RendererMeshContext::LINE : RendererMeshContext::SOLID;
mRendererMeshContext.material = m->mRenderMaterial;
mRendererMeshContext.materialInstance = m->mRenderMaterialInstance;
mRendererMeshContext.mesh = mRendererShape->getMesh();
mRendererMeshContext.transform = &mScaledTransform;
renderer.queueMeshForRender(mRendererMeshContext);
}
PxBounds3 RenderBaseActor::getWorldBounds() const
{
return mWorldBounds;
}
void RenderBaseActor::setWorldBounds(const PxBounds3& bounds)
{
mWorldBounds = bounds;
}
void RenderBaseActor::updateScale()
{
if (!mScaling.isIdentity())
{
PxMat33 q = PxMat33(mTransform.q) * mScaling.toMat33();
mScaledTransform = PxMat44(q, mTransform.p);
mRendererMeshContext.negativeScale = mScaling.hasNegativeDeterminant();
}
else
{
mScaledTransform = PxMat44(mTransform);
}
}
void RenderBaseActor::setPhysicsShape(PxShape* shape, PxRigidActor* actor)
{
mPhysicsShape = shape;
mPhysicsActor = actor;
if(shape)
{
mCCDWitness = getShapeCenter(actor, shape, mCCDWitnessOffset);
const PxTransform newPose = PxShapeExt::getGlobalPose(*shape, *actor);
setTransform(PxTransform(newPose.p, newPose.q * mPhysicsToGraphicsRot));
PxRigidActor& ra = *actor;
mDynamicActor = ra.is<PxRigidDynamic>();
mArticulationLink = ra.is<PxArticulationLink>();
mWorldBounds = PxShapeExt::getWorldBounds(*mPhysicsShape, *mPhysicsActor);
}
else
{
mDynamicActor = NULL;
}
}
void RenderBaseActor::setRenderMaterial(RenderMaterial* material)
{
mMaterial = material;
}
void RenderBaseActor::setRenderShape(RendererShape* shape)
{
PX_ASSERT(!mRendererShape);
mRendererShape = shape;
if(shape)
{
// PT: we use the user-data as a ref-counter
size_t refCount = size_t(mRendererShape->m_userData);
refCount++;
mRendererShape->m_userData = (void*)refCount;
}
}
void RenderBaseActor::deleteRenderShape()
{
if(mRendererShape)
{
// PT: we use the user-data as a ref-counter
size_t refCount = size_t(mRendererShape->m_userData);
refCount--;
if(!refCount)
{
DELETESINGLE(mRendererShape);
}
else
{
mRendererShape->m_userData = (void*)refCount;
mRendererShape = NULL;
}
}
}
void RenderBaseActor::drawDebug(RenderPhysX3Debug* debug)
{
// return;
if(!mPhysicsShape)
return;
if(0 && mEnableCCD)
{
const PxBounds3 bounds = PxShapeExt::getWorldBounds(*mPhysicsShape, *mPhysicsActor);
const PxReal scale = (bounds.maximum - bounds.minimum).magnitude();
const PxTransform pose = PxShapeExt::getGlobalPose(*mPhysicsShape, *mPhysicsActor);
debug->addLine(pose.p, pose.p+PxVec3(scale, 0.0f, 0.0f), RendererColor(0, 255, 0));
debug->addLine(pose.p, pose.p+PxVec3(0.0f, scale, 0.0f), RendererColor(0, 255, 0));
debug->addLine(pose.p, pose.p+PxVec3(0.0f, 0.0f, scale), RendererColor(0, 255, 0));
const PxVec3 shapeCenter = getShapeCenter(mPhysicsActor, mPhysicsShape, mCCDWitnessOffset);
//shdfnd::printFormatted("Render: %f | %f | %f\n", shapeCenter.x, shapeCenter.y, shapeCenter.z);
debug->addLine(shapeCenter, shapeCenter+PxVec3(scale, 0.0f, 0.0f), RendererColor(255, 0, 0));
debug->addLine(shapeCenter, shapeCenter+PxVec3(0.0f, scale, 0.0f), RendererColor(255, 0, 0));
debug->addLine(shapeCenter, shapeCenter+PxVec3(0.0f, 0.0f, scale), RendererColor(255, 0, 0));
return;
}
/*
BasicRandom rnd(42);
const PxTransform globalShapePose = PxShapeExt::getGlobalPose(*mPhysicsShape);
const RendererColor colorPurple(255, 0, 255);
for(PxU32 i=0;i<50;i++)
{
PxVec3 dir;
rnd.unitRandomPt(dir);
PxVec3 localCenter;
const PxReal internalRadius = computeInternalRadius(mPhysicsShape, dir, localCenter, mCCDWitnessOffset);
const PxVec3 center = globalShapePose.transform(localCenter);
debug->addLine(center, center+dir*internalRadius, colorPurple);
}*/
}

View File

@ -0,0 +1,126 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_BASE_ACTOR_H
#define RENDER_BASE_ACTOR_H
#include "RendererMeshContext.h"
#include "common/PxPhysXCommonConfig.h"
#include "RenderBaseObject.h"
#include "geometry/PxMeshScale.h"
#include "foundation/PxBounds3.h"
namespace SampleRenderer
{
class RendererShape;
}
class RenderMaterial;
namespace physx
{
class PxShape;
class PxRigidActor;
class PxRigidDynamic;
class PxArticulationLink;
class PxMeshScale;
}
class RenderPhysX3Debug;
class RenderBaseActor : public RenderBaseObject
{
public:
RenderBaseActor();
RenderBaseActor(const RenderBaseActor&);
virtual ~RenderBaseActor();
virtual void update(float deltaTime);
virtual void render(SampleRenderer::Renderer& renderer, RenderMaterial* material=NULL, bool wireFrame = false);
virtual void drawDebug(RenderPhysX3Debug*);
PX_FORCE_INLINE void setTransform(const PxTransform& tr) { mTransform = tr; updateScale(); }
PX_FORCE_INLINE void setMeshScale(const PxMeshScale& scaling){ mScaling = scaling; updateScale(); }
void setPhysicsShape(PxShape* shape, PxRigidActor* actor);
void setRenderMaterial(RenderMaterial*);
PX_FORCE_INLINE const PxTransform& getTransform() const { return mTransform; }
PX_FORCE_INLINE PxShape* getPhysicsShape() const { return mPhysicsShape; }
PX_FORCE_INLINE PxRigidActor* getPhysicsActor() const { return mPhysicsActor; }
PX_FORCE_INLINE SampleRenderer::RendererShape* getRenderShape() { return mRendererShape; }
PX_FORCE_INLINE SampleRenderer::RendererShape* getRenderShape() const { return mRendererShape; }
PX_FORCE_INLINE RenderMaterial* getRenderMaterial() { return mMaterial; }
PX_FORCE_INLINE RenderMaterial* getRenderMaterial() const { return mMaterial; }
PxBounds3 getWorldBounds() const;
void setWorldBounds(const PxBounds3& bounds);
PX_FORCE_INLINE void setRaycastCCD(bool flag) { mEnableCCD = flag; }
PX_FORCE_INLINE void setCCDWitnessOffset(const PxVec3& offset) { mCCDWitnessOffset = offset; }
PX_FORCE_INLINE void setRendering(bool flag) { mEnableRender = flag; }
PX_FORCE_INLINE void setEnableDebugRender(bool flag) { mEnableDebugRender = flag; }
PX_FORCE_INLINE bool getEnableDebugRender() const { return mEnableDebugRender; }
PX_FORCE_INLINE void setEnableCameraCull(bool flag) { mEnableCameraCull = flag; }
PX_FORCE_INLINE bool getEnableCameraCull() const { return mEnableCameraCull; }
private:
SampleRenderer::RendererShape* mRendererShape;
PxMeshScale mScaling;
PxTransform mTransform;
PxBounds3 mWorldBounds;
protected:
SampleRenderer::RendererMeshContext mRendererMeshContext;
PxMat44 mScaledTransform;
PxQuat mPhysicsToGraphicsRot;
PxShape* mPhysicsShape;
PxRigidActor* mPhysicsActor;
PxRigidDynamic* mDynamicActor;
PxArticulationLink* mArticulationLink;
RenderMaterial* mMaterial;
PxVec3 mCCDWitness;
PxVec3 mCCDWitnessOffset;
bool mEnableCCD;
bool mEnableRender;
bool mEnableDebugRender;
bool mEnableCameraCull;
protected:
void setRenderShape(SampleRenderer::RendererShape*);
void deleteRenderShape();
private:
void updateScale();
};
#endif

View File

@ -0,0 +1,52 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RenderBaseObject.h"
#include <string.h>
RenderBaseObject::RenderBaseObject()
: mActive(true)
, mUserData (NULL)
{
mName[0] = 0;
}
RenderBaseObject::RenderBaseObject(const RenderBaseObject& src)
{
strcpy(mName, src.mName);
}
RenderBaseObject::~RenderBaseObject()
{
}
void RenderBaseObject::release()
{
delete this;
}

View File

@ -0,0 +1,49 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_BASE_OBJECT_H
#define RENDER_BASE_OBJECT_H
#include "SampleAllocator.h"
class RenderBaseObject : public SampleAllocateable
{
public:
RenderBaseObject();
RenderBaseObject(const RenderBaseObject&);
virtual ~RenderBaseObject();
virtual void release();
bool mActive;
void* mUserData;
char mName[512];
};
#endif

View File

@ -0,0 +1,48 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RenderBoxActor.h"
#include "RendererBoxShape.h"
using namespace physx;
using namespace SampleRenderer;
RenderBoxActor::RenderBoxActor(Renderer& renderer, const PxVec3& extents, const PxReal* uvs)
{
RendererShape* rs = new RendererBoxShape(renderer, extents, uvs);
setRenderShape(rs);
}
RenderBoxActor::RenderBoxActor(const RenderBoxActor& src) : RenderBaseActor(src)
{
}
RenderBoxActor::~RenderBoxActor()
{
}

View File

@ -0,0 +1,49 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_BOX_ACTOR_H
#define RENDER_BOX_ACTOR_H
#include "RenderBaseActor.h"
#include "foundation/PxVec3.h"
namespace SampleRenderer
{
class Renderer;
}
class RenderBoxActor : public RenderBaseActor
{
public:
RenderBoxActor(SampleRenderer::Renderer& renderer, const PxVec3& extents, const PxReal* uvs=NULL);
RenderBoxActor(const RenderBoxActor&);
virtual ~RenderBoxActor();
};
#endif

View File

@ -0,0 +1,58 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RenderCapsuleActor.h"
#include "RendererCapsuleShape.h"
#include "extensions/PxShapeExt.h"
using namespace physx;
using namespace SampleRenderer;
RenderCapsuleActor::RenderCapsuleActor(Renderer& renderer, PxReal radius, PxReal halfHeight)
{
RendererShape* rs = new RendererCapsuleShape(renderer, halfHeight, radius);
setRenderShape(rs);
// PT: seems there's a mismatch between the renderer's and the SDK's idea of what a default capsule pose should be
mPhysicsToGraphicsRot = PxQuat(PxHalfPi, PxVec3(0.0f, 0.0f, 1.0f));
}
void RenderCapsuleActor::setDimensions(PxReal halfHeight, PxReal radius0, PxReal radius1)
{
RendererCapsuleShape* capsuleShape = static_cast<RendererCapsuleShape*>(getRenderShape());
capsuleShape->setDimensions(halfHeight, radius0, radius1);
}
RenderCapsuleActor::RenderCapsuleActor(const RenderCapsuleActor& src) : RenderBaseActor(src)
{
}
RenderCapsuleActor::~RenderCapsuleActor()
{
}

View File

@ -0,0 +1,53 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_CAPSULE_ACTOR_H
#define RENDER_CAPSULE_ACTOR_H
#include "RenderBaseActor.h"
#include "foundation/PxSimpleTypes.h"
namespace SampleRenderer
{
class Renderer;
}
class RenderCapsuleActor : public RenderBaseActor
{
public:
RenderCapsuleActor(SampleRenderer::Renderer& renderer, PxReal radius, PxReal halfHeight);
// resize this capsule
void setDimensions(PxReal halfHeight, PxReal radius0, PxReal radius1);
RenderCapsuleActor(const RenderCapsuleActor&);
virtual ~RenderCapsuleActor();
};
#endif

View File

@ -0,0 +1,50 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RenderGridActor.h"
#include "RendererGridShape.h"
using namespace physx;
using namespace SampleRenderer;
RenderGridActor::RenderGridActor(Renderer& renderer, PxU32 size, PxReal cellSize, PxQuat v)
{
RendererShape* rs = new RendererGridShape(renderer, size, cellSize);
setRenderShape(rs);
mPhysicsToGraphicsRot = v;
}
RenderGridActor::~RenderGridActor()
{
}
void RenderGridActor::update(float deltaTime)
{
}

View File

@ -0,0 +1,49 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_GRID_ACTOR_H
#define RENDER_GRID_ACTOR_H
#include "RenderBaseActor.h"
namespace SampleRenderer
{
class Renderer;
}
class RenderGridActor : public RenderBaseActor
{
public:
RenderGridActor(SampleRenderer::Renderer& renderer, PxU32 size, PxReal cellSize, PxQuat v = PxQuat(PxIdentity));
virtual ~RenderGridActor();
virtual void update(float deltaTime);
};
#endif

View File

@ -0,0 +1,184 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "SamplePreprocessor.h"
#include "RenderMaterial.h"
#include "RenderTexture.h"
#include "RendererMaterialDesc.h"
#include "Renderer.h"
#include "RendererMaterial.h"
#include "RendererMaterialInstance.h"
#include "RendererMemoryMacros.h"
using namespace physx;
using namespace SampleRenderer;
const char* defaultMaterialLitVertexShader = "vertex/staticmesh.cg";
const char* defaultMaterialTexturedUnlitFragmentShader = "fragment/sample_diffuse_and_texture.cg";
const char* defaultMaterialTexturedLitFragmentShader = "fragment/sample_diffuse_and_texture.cg";
const char* defaultMaterialFragmentShader = "fragment/sample_diffuse_no_texture.cg";
RenderMaterial::RenderMaterial(Renderer& renderer, const PxVec3& diffuseColor, PxReal opacity, bool doubleSided, PxU32 id, RenderTexture* texture, bool lit, bool flat, bool instanced) :
mRenderMaterial (NULL),
mRenderMaterialInstance (NULL),
mID (id),
mDoubleSided (doubleSided),
mOwnsRendererMaterial (true)
{
RendererMaterialDesc matDesc;
if(lit)
matDesc.type = RendererMaterial::TYPE_LIT;
else
matDesc.type = RendererMaterial::TYPE_UNLIT;
matDesc.alphaTestFunc = RendererMaterial::ALPHA_TEST_ALWAYS;
matDesc.alphaTestRef = 0.0f;
if(opacity==1.0f)
{
matDesc.blending = false;
matDesc.srcBlendFunc = RendererMaterial::BLEND_ONE;
matDesc.dstBlendFunc = RendererMaterial::BLEND_ONE;
}
else
{
matDesc.type = RendererMaterial::TYPE_UNLIT;
matDesc.blending = true;
// matDesc.srcBlendFunc = RendererMaterial::BLEND_ONE;
// matDesc.dstBlendFunc = RendererMaterial::BLEND_ONE;
matDesc.srcBlendFunc = RendererMaterial::BLEND_SRC_ALPHA;
matDesc.dstBlendFunc = RendererMaterial::BLEND_ONE_MINUS_SRC_ALPHA;
}
if(instanced)
{
matDesc.instanced = true;
}
else
{
matDesc.instanced = false;
}
matDesc.geometryShaderPath = NULL;
matDesc.vertexShaderPath = defaultMaterialLitVertexShader;
if(texture)
{
if(lit)
{
matDesc.fragmentShaderPath = defaultMaterialTexturedLitFragmentShader;
}
else
{
matDesc.fragmentShaderPath = defaultMaterialTexturedUnlitFragmentShader;
}
}
else
{
matDesc.fragmentShaderPath = defaultMaterialFragmentShader;
}
PX_ASSERT(matDesc.isValid());
mRenderMaterial = renderer.createMaterial(matDesc);
mRenderMaterialInstance = new RendererMaterialInstance(*mRenderMaterial);
setDiffuseColor(PxVec4(diffuseColor.x, diffuseColor.y, diffuseColor.z, opacity));
setShadeMode(flat);
update(renderer);
if(texture)
{
const RendererMaterial::Variable* var = mRenderMaterialInstance->findVariable("diffuseTexture", RendererMaterial::VARIABLE_SAMPLER2D);
//PX_ASSERT(var);
if(var)
mRenderMaterialInstance->writeData(*var, &texture->mTexture);
}
}
RenderMaterial::RenderMaterial(Renderer& renderer, RendererMaterial* mat, RendererMaterialInstance* matInstance, PxU32 id) :
mRenderMaterial (mat),
mRenderMaterialInstance (matInstance),
mID (id),
mDoubleSided (false),
mOwnsRendererMaterial (false)
{
update(renderer);
}
void RenderMaterial::update(SampleRenderer::Renderer& renderer)
{
const RendererMaterial::Variable* var = mRenderMaterialInstance->findVariable("windowWidth", RendererMaterial::VARIABLE_FLOAT);
if(var)
{
PxU32 tmpWindowWidth, tmpWindowHeight;
renderer.getWindowSize(tmpWindowWidth, tmpWindowHeight);
const PxReal windowWidth = PxReal(tmpWindowWidth);
mRenderMaterialInstance->writeData(*var, &windowWidth);
}
}
void RenderMaterial::setParticleSize(const PxReal particleSize)
{
const RendererMaterial::Variable* var = mRenderMaterialInstance->findVariable("particleSize", RendererMaterial::VARIABLE_FLOAT);
if(var)
{
mRenderMaterialInstance->writeData(*var, &particleSize);
}
}
void RenderMaterial::setDiffuseColor(const PxVec4& color)
{
const RendererMaterial::Variable* var = mRenderMaterialInstance->findVariable("diffuseColor", RendererMaterial::VARIABLE_FLOAT4);
if(var)
{
const PxReal data[] = { color.x, color.y, color.z, color.w };
mRenderMaterialInstance->writeData(*var, data);
}
}
void RenderMaterial::setShadeMode(bool flat)
{
const RendererMaterial::Variable* var = mRenderMaterialInstance->findVariable("shadeMode", RendererMaterial::VARIABLE_FLOAT);
if(var)
{
float shadeMode = flat?1.0f:0.0f;
mRenderMaterialInstance->writeData(*var, &shadeMode);
}
}
RenderMaterial::~RenderMaterial()
{
if(mOwnsRendererMaterial)
{
DELETESINGLE(mRenderMaterialInstance);
SAFE_RELEASE(mRenderMaterial);
}
}

View File

@ -0,0 +1,78 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_MATERIAL_H
#define RENDER_MATERIAL_H
#include "RenderBaseObject.h"
#include "common/PxPhysXCommonConfig.h"
#include "foundation/PxVec3.h"
namespace SampleRenderer
{
class Renderer;
class RendererMaterial;
class RendererMaterialInstance;
}
class RenderTexture;
class RenderMaterial : public RenderBaseObject
{
public:
RenderMaterial(SampleRenderer::Renderer& renderer,
const PxVec3& diffuseColor,
PxReal opacity,
bool doubleSided,
PxU32 id,
RenderTexture* texture,
bool lit = true,
bool flat = false,
bool instanced = false);
RenderMaterial(SampleRenderer::Renderer& renderer,
SampleRenderer::RendererMaterial* mat,
SampleRenderer::RendererMaterialInstance* matInstance,
PxU32 id);
virtual ~RenderMaterial();
// the intent of this function is to update shaders variables, when needed (e.g. on resize)
virtual void update(SampleRenderer::Renderer& renderer);
void setDiffuseColor(const PxVec4& color);
void setParticleSize(const PxReal particleSize);
void setShadeMode(bool flat);
SampleRenderer::RendererMaterial* mRenderMaterial;
SampleRenderer::RendererMaterialInstance* mRenderMaterialInstance;
PxU32 mID;
bool mDoubleSided;
bool mOwnsRendererMaterial;
};
#endif

View File

@ -0,0 +1,68 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RenderMeshActor.h"
#include "RendererMeshShape.h"
#include "RendererMemoryMacros.h"
#include "extensions/PxSmoothNormals.h"
#include "SampleAllocatorSDKClasses.h"
using namespace physx;
using namespace SampleRenderer;
RenderMeshActor::RenderMeshActor( Renderer& renderer,
const PxVec3* verts, PxU32 numVerts,
const PxVec3* vertexNormals,
const PxReal* uvs,
const PxU16* faces16, const PxU32* faces32, PxU32 numFaces, bool flipWinding
)
{
PxVec3Alloc* normals = NULL;
if(!vertexNormals)
{
normals = SAMPLE_NEW(PxVec3Alloc)[numVerts];
PxBuildSmoothNormals(numFaces, numVerts, verts, faces32, faces16, normals, flipWinding);
vertexNormals = normals;
}
RendererShape* rs = new RendererMeshShape(renderer, verts, numVerts, vertexNormals, uvs, faces16, faces32, numFaces, flipWinding);
setRenderShape(rs);
DELETEARRAY(normals);
}
RenderMeshActor::RenderMeshActor(const RenderMeshActor& src) : RenderBaseActor(src)
{
}
RenderMeshActor::~RenderMeshActor()
{
}

View File

@ -0,0 +1,54 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_MESH_ACTOR_H
#define RENDER_MESH_ACTOR_H
#include "RenderBaseActor.h"
#include "foundation/PxVec3.h"
namespace SampleRenderer
{
class Renderer;
}
class RenderMeshActor : public RenderBaseActor
{
public:
RenderMeshActor(SampleRenderer::Renderer& renderer,
const PxVec3* verts, PxU32 numVerts,
const PxVec3* vertexNormals,
const PxReal* uvs,
const PxU16* faces16, const PxU32* faces32, PxU32 numFaces, bool flipWinding=false
);
RenderMeshActor(const RenderMeshActor&);
virtual ~RenderMeshActor();
};
#endif

View File

@ -0,0 +1,923 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RenderPhysX3Debug.h"
#include "RendererColor.h"
#include "common/PxRenderBuffer.h"
#include "foundation/PxSimpleTypes.h"
#include "SampleCamera.h"
#include "geometry/PxConvexMesh.h"
#include "geometry/PxConvexMeshGeometry.h"
#include "geometry/PxCapsuleGeometry.h"
#include "geometry/PxSphereGeometry.h"
#include "geometry/PxBoxGeometry.h"
#include "PsUtilities.h"
#include "PsString.h"
using namespace physx;
using namespace SampleRenderer;
using namespace SampleFramework;
RenderPhysX3Debug::RenderPhysX3Debug(Renderer& renderer, SampleAssetManager& assetmanager) :
SamplePointDebugRender (renderer, assetmanager),
SampleLineDebugRender (renderer, assetmanager),
SampleTriangleDebugRender (renderer, assetmanager)
{
}
RenderPhysX3Debug::~RenderPhysX3Debug()
{
}
void RenderPhysX3Debug::update(const PxRenderBuffer& debugRenderable)
{
// Points
const PxU32 numPoints = debugRenderable.getNbPoints();
if(numPoints)
{
const PxDebugPoint* PX_RESTRICT points = debugRenderable.getPoints();
checkResizePoint(numPoints);
for(PxU32 i=0; i<numPoints; i++)
{
const PxDebugPoint& point = points[i];
addPoint(point.pos, RendererColor(point.color));
}
}
// Lines
const PxU32 numLines = debugRenderable.getNbLines();
if(numLines)
{
const PxDebugLine* PX_RESTRICT lines = debugRenderable.getLines();
checkResizeLine(numLines * 2);
for(PxU32 i=0; i<numLines; i++)
{
const PxDebugLine& line = lines[i];
addLine(line.pos0, line.pos1, RendererColor(line.color0));
}
}
// Triangles
const PxU32 numTriangles = debugRenderable.getNbTriangles();
if(numTriangles)
{
const PxDebugTriangle* PX_RESTRICT triangles = debugRenderable.getTriangles();
checkResizeTriangle(numTriangles * 3);
for(PxU32 i=0; i<numTriangles; i++)
{
const PxDebugTriangle& triangle = triangles[i];
addTriangle(triangle.pos0, triangle.pos1, triangle.pos2, RendererColor(triangle.color0));
}
}
}
void RenderPhysX3Debug::update(const PxRenderBuffer& debugRenderable, const Camera& camera)
{
// Points
const PxU32 numPoints = debugRenderable.getNbPoints();
if(numPoints)
{
const PxDebugPoint* PX_RESTRICT points = debugRenderable.getPoints();
checkResizePoint(numPoints);
for(PxU32 i=0; i<numPoints; i++)
{
const PxDebugPoint& point = points[i];
addPoint(point.pos, RendererColor(point.color));
}
}
// Lines
const PxU32 numLines = debugRenderable.getNbLines();
if(numLines)
{
const PxDebugLine* PX_RESTRICT lines = debugRenderable.getLines();
checkResizeLine(numLines * 2);
PxU32 nbVisible = 0;
for(PxU32 i=0; i<numLines; i++)
{
const PxDebugLine& line = lines[i];
PxBounds3 b;
b.minimum.x = PxMin(line.pos0.x, line.pos1.x);
b.minimum.y = PxMin(line.pos0.y, line.pos1.y);
b.minimum.z = PxMin(line.pos0.z, line.pos1.z);
b.maximum.x = PxMax(line.pos0.x, line.pos1.x);
b.maximum.y = PxMax(line.pos0.y, line.pos1.y);
b.maximum.z = PxMax(line.pos0.z, line.pos1.z);
if(camera.cull(b)==PLANEAABB_EXCLUSION)
continue;
addLine(line.pos0, line.pos1, RendererColor(line.color0));
nbVisible++;
}
shdfnd::printFormatted("%f\n", float(nbVisible)/float(numLines));
}
// Triangles
const PxU32 numTriangles = debugRenderable.getNbTriangles();
if(numTriangles)
{
const PxDebugTriangle* PX_RESTRICT triangles = debugRenderable.getTriangles();
checkResizeTriangle(numTriangles * 3);
for(PxU32 i=0; i<numTriangles; i++)
{
const PxDebugTriangle& triangle = triangles[i];
addTriangle(triangle.pos0, triangle.pos1, triangle.pos2, RendererColor(triangle.color0));
}
}
}
void RenderPhysX3Debug::queueForRender()
{
queueForRenderPoint();
queueForRenderLine();
queueForRenderTriangle();
}
void RenderPhysX3Debug::clear()
{
clearPoint();
clearLine();
clearTriangle();
}
///////////////////////////////////////////////////////////////////////////////
#define NB_CIRCLE_PTS 20
void RenderPhysX3Debug::addBox(const PxVec3* pts, const RendererColor& color, PxU32 renderFlags)
{
if(renderFlags & RENDER_DEBUG_WIREFRAME)
{
const PxU8 indices[] = {
0, 1, 1, 2, 2, 3, 3, 0,
7, 6, 6, 5, 5, 4, 4, 7,
1, 5, 6, 2,
3, 7, 4, 0
};
for(PxU32 i=0;i<12;i++)
addLine(pts[indices[i*2]], pts[indices[i*2+1]], color);
}
if(renderFlags & RENDER_DEBUG_SOLID)
{
const PxU8 indices[] = {
0,2,1, 0,3,2,
1,6,5, 1,2,6,
5,7,4, 5,6,7,
4,3,0, 4,7,3,
3,6,2, 3,7,6,
5,0,1, 5,4,0
};
for(PxU32 i=0;i<12;i++)
addTriangle(pts[indices[i*3+0]], pts[indices[i*3+1]], pts[indices[i*3+2]], color);
}
}
void RenderPhysX3Debug::addCircle(PxU32 nbPts, const PxVec3* pts, const RendererColor& color, const PxVec3& offset)
{
for(PxU32 i=0;i<nbPts;i++)
{
const PxU32 j = (i+1) % nbPts;
addLine(pts[i]+offset, pts[j]+offset, color);
}
}
void RenderPhysX3Debug::addAABB(const PxBounds3& box, const RendererColor& color, PxU32 renderFlags)
{
const PxVec3& min = box.minimum;
const PxVec3& max = box.maximum;
// 7+------+6 0 = ---
// /| /| 1 = +--
// / | / | 2 = ++-
// / 4+---/--+5 3 = -+-
// 3+------+2 / y z 4 = --+
// | / | / | / 5 = +-+
// |/ |/ |/ 6 = +++
// 0+------+1 *---x 7 = -++
// Generate 8 corners of the bbox
PxVec3 pts[8];
pts[0] = PxVec3(min.x, min.y, min.z);
pts[1] = PxVec3(max.x, min.y, min.z);
pts[2] = PxVec3(max.x, max.y, min.z);
pts[3] = PxVec3(min.x, max.y, min.z);
pts[4] = PxVec3(min.x, min.y, max.z);
pts[5] = PxVec3(max.x, min.y, max.z);
pts[6] = PxVec3(max.x, max.y, max.z);
pts[7] = PxVec3(min.x, max.y, max.z);
addBox(pts, color, renderFlags);
}
void RenderPhysX3Debug::addBox(const PxBoxGeometry& bg, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
addOBB(tr.p, bg.halfExtents, PxMat33(tr.q), color, renderFlags);
}
void RenderPhysX3Debug::addOBB(const PxVec3& boxCenter, const PxVec3& boxExtents, const PxMat33& boxRot, const RendererColor& color, PxU32 renderFlags)
{
PxVec3 Axis0 = boxRot.column0;
PxVec3 Axis1 = boxRot.column1;
PxVec3 Axis2 = boxRot.column2;
// "Rotated extents"
Axis0 *= boxExtents.x;
Axis1 *= boxExtents.y;
Axis2 *= boxExtents.z;
// 7+------+6 0 = ---
// /| /| 1 = +--
// / | / | 2 = ++-
// / 4+---/--+5 3 = -+-
// 3+------+2 / y z 4 = --+
// | / | / | / 5 = +-+
// |/ |/ |/ 6 = +++
// 0+------+1 *---x 7 = -++
// Original code: 24 vector ops
/* pts[0] = mCenter - Axis0 - Axis1 - Axis2;
pts[1] = mCenter + Axis0 - Axis1 - Axis2;
pts[2] = mCenter + Axis0 + Axis1 - Axis2;
pts[3] = mCenter - Axis0 + Axis1 - Axis2;
pts[4] = mCenter - Axis0 - Axis1 + Axis2;
pts[5] = mCenter + Axis0 - Axis1 + Axis2;
pts[6] = mCenter + Axis0 + Axis1 + Axis2;
pts[7] = mCenter - Axis0 + Axis1 + Axis2;*/
// Rewritten: 12 vector ops
PxVec3 pts[8];
pts[0] = pts[3] = pts[4] = pts[7] = boxCenter - Axis0;
pts[1] = pts[2] = pts[5] = pts[6] = boxCenter + Axis0;
PxVec3 Tmp = Axis1 + Axis2;
pts[0] -= Tmp;
pts[1] -= Tmp;
pts[6] += Tmp;
pts[7] += Tmp;
Tmp = Axis1 - Axis2;
pts[2] += Tmp;
pts[3] += Tmp;
pts[4] -= Tmp;
pts[5] -= Tmp;
addBox(pts, color, renderFlags);
}
enum Orientation
{
ORIENTATION_XY,
ORIENTATION_XZ,
ORIENTATION_YZ,
ORIENTATION_FORCE_DWORD = 0x7fffffff
};
static bool generatePolygon(PxU32 nbVerts, PxVec3* verts, Orientation orientation, float amplitude, float phase, const PxTransform* transform=NULL)
{
if(!nbVerts || !verts)
return false;
const float step = PxTwoPi/float(nbVerts);
for(PxU32 i=0;i<nbVerts;i++)
{
const float angle = phase + float(i) * step;
const float y = sinf(angle) * amplitude;
const float x = cosf(angle) * amplitude;
if(orientation==ORIENTATION_XY) { verts[i] = PxVec3(x, y, 0.0f); }
else if(orientation==ORIENTATION_XZ) { verts[i] = PxVec3(x, 0.0f, y); }
else if(orientation==ORIENTATION_YZ) { verts[i] = PxVec3(0.0f, x, y); }
if(transform)
verts[i] = transform->transform(verts[i]);
}
return true;
}
// PT: this comes from RendererCapsuleShape.cpp. Maybe we could grab the data from there instead of duplicating. But it protects us from external changes.
static const PxVec3 gCapsuleVertices[] =
{
PxVec3(0.0000f, -2.0000f, -0.0000f),
PxVec3(0.3827f, -1.9239f, -0.0000f),
PxVec3(0.2706f, -1.9239f, 0.2706f),
PxVec3(-0.0000f, -1.9239f, 0.3827f),
PxVec3(-0.2706f, -1.9239f, 0.2706f),
PxVec3(-0.3827f, -1.9239f, -0.0000f),
PxVec3(-0.2706f, -1.9239f, -0.2706f),
PxVec3(0.0000f, -1.9239f, -0.3827f),
PxVec3(0.2706f, -1.9239f, -0.2706f),
PxVec3(0.7071f, -1.7071f, -0.0000f),
PxVec3(0.5000f, -1.7071f, 0.5000f),
PxVec3(-0.0000f, -1.7071f, 0.7071f),
PxVec3(-0.5000f, -1.7071f, 0.5000f),
PxVec3(-0.7071f, -1.7071f, -0.0000f),
PxVec3(-0.5000f, -1.7071f, -0.5000f),
PxVec3(0.0000f, -1.7071f, -0.7071f),
PxVec3(0.5000f, -1.7071f, -0.5000f),
PxVec3(0.9239f, -1.3827f, -0.0000f),
PxVec3(0.6533f, -1.3827f, 0.6533f),
PxVec3(-0.0000f, -1.3827f, 0.9239f),
PxVec3(-0.6533f, -1.3827f, 0.6533f),
PxVec3(-0.9239f, -1.3827f, -0.0000f),
PxVec3(-0.6533f, -1.3827f, -0.6533f),
PxVec3(0.0000f, -1.3827f, -0.9239f),
PxVec3(0.6533f, -1.3827f, -0.6533f),
PxVec3(1.0000f, -1.0000f, -0.0000f),
PxVec3(0.7071f, -1.0000f, 0.7071f),
PxVec3(-0.0000f, -1.0000f, 1.0000f),
PxVec3(-0.7071f, -1.0000f, 0.7071f),
PxVec3(-1.0000f, -1.0000f, -0.0000f),
PxVec3(-0.7071f, -1.0000f, -0.7071f),
PxVec3(0.0000f, -1.0000f, -1.0000f),
PxVec3(0.7071f, -1.0000f, -0.7071f),
PxVec3(1.0000f, 1.0000f, 0.0000f),
PxVec3(0.7071f, 1.0000f, 0.7071f),
PxVec3(-0.0000f, 1.0000f, 1.0000f),
PxVec3(-0.7071f, 1.0000f, 0.7071f),
PxVec3(-1.0000f, 1.0000f, -0.0000f),
PxVec3(-0.7071f, 1.0000f, -0.7071f),
PxVec3(0.0000f, 1.0000f, -1.0000f),
PxVec3(0.7071f, 1.0000f, -0.7071f),
PxVec3(0.9239f, 1.3827f, 0.0000f),
PxVec3(0.6533f, 1.3827f, 0.6533f),
PxVec3(-0.0000f, 1.3827f, 0.9239f),
PxVec3(-0.6533f, 1.3827f, 0.6533f),
PxVec3(-0.9239f, 1.3827f, -0.0000f),
PxVec3(-0.6533f, 1.3827f, -0.6533f),
PxVec3(0.0000f, 1.3827f, -0.9239f),
PxVec3(0.6533f, 1.3827f, -0.6533f),
PxVec3(0.7071f, 1.7071f, 0.0000f),
PxVec3(0.5000f, 1.7071f, 0.5000f),
PxVec3(-0.0000f, 1.7071f, 0.7071f),
PxVec3(-0.5000f, 1.7071f, 0.5000f),
PxVec3(-0.7071f, 1.7071f, 0.0000f),
PxVec3(-0.5000f, 1.7071f, -0.5000f),
PxVec3(0.0000f, 1.7071f, -0.7071f),
PxVec3(0.5000f, 1.7071f, -0.5000f),
PxVec3(0.3827f, 1.9239f, 0.0000f),
PxVec3(0.2706f, 1.9239f, 0.2706f),
PxVec3(-0.0000f, 1.9239f, 0.3827f),
PxVec3(-0.2706f, 1.9239f, 0.2706f),
PxVec3(-0.3827f, 1.9239f, 0.0000f),
PxVec3(-0.2706f, 1.9239f, -0.2706f),
PxVec3(0.0000f, 1.9239f, -0.3827f),
PxVec3(0.2706f, 1.9239f, -0.2706f),
PxVec3(0.0000f, 2.0000f, 0.0000f),
};
static const PxU8 gCapsuleIndices[] =
{
1, 0, 2, 2, 0, 3, 3, 0, 4, 4, 0, 5, 5, 0, 6, 6, 0, 7, 7, 0, 8,
8, 0, 1, 9, 1, 10, 10, 1, 2, 10, 2, 11, 11, 2, 3, 11, 3, 12,
12, 3, 4, 12, 4, 13, 13, 4, 5, 13, 5, 14, 14, 5, 6, 14, 6, 15,
15, 6, 7, 15, 7, 16, 16, 7, 8, 16, 8, 9, 9, 8, 1, 17, 9, 18,
18, 9, 10, 18, 10, 19, 19, 10, 11, 19, 11, 20, 20, 11, 12, 20, 12, 21,
21, 12, 13, 21, 13, 22, 22, 13, 14, 22, 14, 23, 23, 14, 15, 23, 15, 24,
24, 15, 16, 24, 16, 17, 17, 16, 9, 25, 17, 26, 26, 17, 18, 26, 18, 27,
27, 18, 19, 27, 19, 28, 28, 19, 20, 28, 20, 29, 29, 20, 21, 29, 21, 30,
30, 21, 22, 30, 22, 31, 31, 22, 23, 31, 23, 32, 32, 23, 24, 32, 24, 25,
25, 24, 17, 33, 25, 34, 34, 25, 26, 34, 26, 35, 35, 26, 27, 35, 27, 36,
36, 27, 28, 36, 28, 37, 37, 28, 29, 37, 29, 38, 38, 29, 30, 38, 30, 39,
39, 30, 31, 39, 31, 40, 40, 31, 32, 40, 32, 33, 33, 32, 25, 41, 33, 42,
42, 33, 34, 42, 34, 43, 43, 34, 35, 43, 35, 44, 44, 35, 36, 44, 36, 45,
45, 36, 37, 45, 37, 46, 46, 37, 38, 46, 38, 47, 47, 38, 39, 47, 39, 48,
48, 39, 40, 48, 40, 41, 41, 40, 33, 49, 41, 50, 50, 41, 42, 50, 42, 51,
51, 42, 43, 51, 43, 52, 52, 43, 44, 52, 44, 53, 53, 44, 45, 53, 45, 54,
54, 45, 46, 54, 46, 55, 55, 46, 47, 55, 47, 56, 56, 47, 48, 56, 48, 49,
49, 48, 41, 57, 49, 58, 58, 49, 50, 58, 50, 59, 59, 50, 51, 59, 51, 60,
60, 51, 52, 60, 52, 61, 61, 52, 53, 61, 53, 62, 62, 53, 54, 62, 54, 63,
63, 54, 55, 63, 55, 64, 64, 55, 56, 64, 56, 57, 57, 56, 49, 65, 57, 58,
65, 58, 59, 65, 59, 60, 65, 60, 61, 65, 61, 62, 65, 62, 63, 65, 63, 64,
65, 64, 57,
};
static const PxU32 gNumCapsuleIndices = PX_ARRAY_SIZE(gCapsuleIndices);
static PX_FORCE_INLINE void fixCapsuleVertex(PxVec3& p, PxF32 radius, PxF32 halfHeight)
{
const PxF32 sign = p.y > 0 ? 1.0f : -1.0f;
p.y -= sign;
p *= radius;
p.y += halfHeight*sign;
}
void RenderPhysX3Debug::addSphere(const PxSphereGeometry& sg, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
addSphere(tr.p, sg.radius, color, renderFlags);
}
void RenderPhysX3Debug::addSphere(const PxVec3& sphereCenter, float sphereRadius, const RendererColor& color, PxU32 renderFlags)
{
const PxU32 nbVerts = NB_CIRCLE_PTS;
PxVec3 pts[NB_CIRCLE_PTS];
if(renderFlags & RENDER_DEBUG_WIREFRAME)
{
generatePolygon(nbVerts, pts, ORIENTATION_XY, sphereRadius, 0.0f);
addCircle(nbVerts, pts, color, sphereCenter);
generatePolygon(nbVerts, pts, ORIENTATION_XZ, sphereRadius, 0.0f);
addCircle(nbVerts, pts, color, sphereCenter);
generatePolygon(nbVerts, pts, ORIENTATION_YZ, sphereRadius, 0.0f);
addCircle(nbVerts, pts, color, sphereCenter);
}
if(renderFlags & RENDER_DEBUG_SOLID)
{
const PxF32 halfHeight = 0.0f;
for(PxU32 i=0;i<gNumCapsuleIndices/3;i++)
{
const PxU32 i0 = gCapsuleIndices[i*3+0];
const PxU32 i1 = gCapsuleIndices[i*3+1];
const PxU32 i2 = gCapsuleIndices[i*3+2];
PxVec3 v0 = gCapsuleVertices[i0];
PxVec3 v1 = gCapsuleVertices[i1];
PxVec3 v2 = gCapsuleVertices[i2];
fixCapsuleVertex(v0, sphereRadius, halfHeight);
fixCapsuleVertex(v1, sphereRadius, halfHeight);
fixCapsuleVertex(v2, sphereRadius, halfHeight);
addTriangle(v0+sphereCenter, v1+sphereCenter, v2+sphereCenter, color);
}
}
}
#define MAX_TEMP_VERTEX_BUFFER 400
// creaet triangle strip of spheres
static bool generateSphere(PxU32 nbSeg, PxU32& nbVerts, PxVec3* verts, PxVec3* normals)
{
PxVec3 tempVertexBuffer[MAX_TEMP_VERTEX_BUFFER];
PxVec3 tempNormalBuffer[MAX_TEMP_VERTEX_BUFFER];
int halfSeg = nbSeg / 2;
int nSeg = halfSeg * 2;
if (((nSeg+1) * (nSeg+1)) > MAX_TEMP_VERTEX_BUFFER)
return false;
const float stepTheta = PxTwoPi / float(nSeg);
const float stepPhi = PxPi / float(nSeg);
// compute sphere vertices on the temporary buffer
nbVerts = 0;
for (int i = 0; i <= nSeg; i++)
{
const float theta = float(i) * stepTheta;
const float cosi = cos(theta);
const float sini = sin(theta);
for (int j = -halfSeg; j <= halfSeg; j++)
{
const float phi = float(j) * stepPhi;
const float sinj = sin( phi);
const float cosj = cos( phi);
const float y = cosj * cosi;
const float x = sinj;
const float z = cosj * sini;
tempVertexBuffer[nbVerts] = PxVec3(x,y,z);
tempNormalBuffer[nbVerts] = PxVec3(x,y,z).getNormalized();
nbVerts++;
}
}
nbVerts = 0;
// now create triangle soup data
for (int i = 0; i < nSeg; i++)
{
for (int j = 0; j < nSeg; j++)
{
// add one triangle
verts[nbVerts] = tempVertexBuffer[ (nSeg+1) * i + j];
normals[nbVerts] = tempNormalBuffer[ (nSeg+1) * i + j];
nbVerts++;
verts[nbVerts] = tempVertexBuffer[ (nSeg+1) * i + j+1];
normals[nbVerts] = tempNormalBuffer[ (nSeg+1) * i + j+1];
nbVerts++;
verts[nbVerts] = tempVertexBuffer[ (nSeg+1) * (i+1) + j+1];
normals[nbVerts] = tempNormalBuffer[ (nSeg+1) * (i+1) + j+1];
nbVerts++;
// add another triangle
verts[nbVerts] = tempVertexBuffer[ (nSeg+1) * i + j];
normals[nbVerts] = tempNormalBuffer[ (nSeg+1) * i + j];
nbVerts++;
verts[nbVerts] = tempVertexBuffer[ (nSeg+1) * (i+1) + j+1];
normals[nbVerts] = tempNormalBuffer[ (nSeg+1) * (i+1) + j+1];
nbVerts++;
verts[nbVerts] = tempVertexBuffer[ (nSeg+1) * (i+1) + j];
normals[nbVerts] = tempNormalBuffer[ (nSeg+1) * (i+1) + j];
nbVerts++;
}
}
return true;
}
void RenderPhysX3Debug::addSphereExt(const PxVec3& sphereCenter, float sphereRadius, const RendererColor& color, PxU32 renderFlags)
{
if(renderFlags & RENDER_DEBUG_WIREFRAME)
{
const PxU32 nbVerts = NB_CIRCLE_PTS;
PxVec3 pts[NB_CIRCLE_PTS];
generatePolygon(nbVerts, pts, ORIENTATION_XY, sphereRadius, 0.0f);
addCircle(nbVerts, pts, color, sphereCenter);
generatePolygon(nbVerts, pts, ORIENTATION_XZ, sphereRadius, 0.0f);
addCircle(nbVerts, pts, color, sphereCenter);
generatePolygon(nbVerts, pts, ORIENTATION_YZ, sphereRadius, 0.0f);
addCircle(nbVerts, pts, color, sphereCenter);
}
if(renderFlags & RENDER_DEBUG_SOLID)
{
static bool initDone = false;
static PxU32 nbVerts;
static PxVec3 verts[MAX_TEMP_VERTEX_BUFFER*6];
static PxVec3 normals[MAX_TEMP_VERTEX_BUFFER*6];
if (!initDone)
{
generateSphere(16, nbVerts, verts, normals);
initDone = true;
}
PxU32 i = 0;
while ( i < nbVerts )
{
addTriangle( sphereCenter + sphereRadius * verts[i], sphereCenter + sphereRadius * verts[i+1], sphereCenter + sphereRadius * verts[i+2],
normals[i], normals[i+1], normals[i+2], color);
i += 3;
}
}
}
#undef MAX_TEMP_VERTEX_BUFFFER
static inline PxU32 minArgument(const PxVec3 &v)
{
PxU32 j = 0;
if ( v[j] > v[1]) j = 1;
if ( v[j] > v[2]) j = 2;
return j;
}
static inline PxVec3 abs(const PxVec3 &v)
{
return PxVec3( PxAbs(v.x), PxAbs(v.y), PxAbs(v.z));
}
void RenderPhysX3Debug::addConeExt(float r0, float r1, const PxVec3& p0, const PxVec3& p1 , const RendererColor& color, PxU32 renderFlags)
{
PxVec3 axis = p1 - p0;
PxReal length = axis.magnitude();
PxReal rdiff = r0 - r1;
PxReal sinAngle = rdiff / length;
PxReal x0 = r0 * sinAngle;
PxReal x1 = r1 * sinAngle;
PxVec3 center = 0.5f * (p0 + p1);
if (length < fabs(rdiff))
return;
PxReal r0p = sqrt(r0 * r0 - x0 * x0);
PxReal r1p = sqrt(r1 * r1 - x1 * x1);
if (length == 0.0f)
axis = PxVec3(1,0,0);
else
axis.normalize();
PxVec3 axis1(0.0f);
axis1[minArgument(abs(axis))] = 1.0f;
axis1 = axis1.cross(axis);
axis1.normalize();
PxVec3 axis2 = axis.cross(axis1);
axis2.normalize();
PxMat44 m;
m.column0 = PxVec4(axis, 0.0f);
m.column1 = PxVec4(axis1, 0.0f);
m.column2 = PxVec4(axis2, 0.0f);
m.column3 = PxVec4(center, 1.0f);
PxTransform tr(m);
#define NUM_CONE_VERTS 72
const PxU32 nbVerts = NUM_CONE_VERTS;
PxVec3 pts0[NUM_CONE_VERTS] ;
PxVec3 pts1[NUM_CONE_VERTS];
PxVec3 normals[NUM_CONE_VERTS] ;
const float step = PxTwoPi / float(nbVerts);
for (PxU32 i = 0; i < nbVerts; i++)
{
const float angle = float(i) * step;
const float x = cosf(angle);
const float y = sinf(angle);
PxVec3 p = PxVec3(0.0f, x, y);
pts0[i] = tr.transform(r0p * p + PxVec3(-0.5f * length + x0,0,0));
pts1[i] = tr.transform(r1p * p + PxVec3(0.5f * length + x1, 0, 0));
normals[i] = tr.q.rotate(p.getNormalized());
normals[i] = x0 * axis + r0p * normals[i];
normals[i].normalize();
}
#undef NUM_CONE_VERTS
if(renderFlags & RENDER_DEBUG_WIREFRAME)
{
for(PxU32 i=0;i<nbVerts;i++)
{
addLine(pts1[i], pts0[i], color);
}
}
if(renderFlags & RENDER_DEBUG_SOLID)
{
for(PxU32 i=0;i<nbVerts;i++)
{
const PxU32 j = (i+1) % nbVerts;
addTriangle(pts0[i], pts1[j], pts0[j], normals[i], normals[j], normals[j], color);
addTriangle(pts0[i], pts1[i], pts1[j], normals[i], normals[i], normals[j], color);
}
}
}
void RenderPhysX3Debug::addCone(float radius, float height, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
const PxU32 nbVerts = NB_CIRCLE_PTS;
PxVec3 pts[NB_CIRCLE_PTS];
generatePolygon(nbVerts, pts, ORIENTATION_XZ, radius, 0.0f, &tr);
const PxVec3 tip = tr.transform(PxVec3(0.0f, height, 0.0f));
if(renderFlags & RENDER_DEBUG_WIREFRAME)
{
addCircle(nbVerts, pts, color, PxVec3(0));
for(PxU32 i=0;i<nbVerts;i++)
{
addLine(tip, pts[i], color); // side of the cone
addLine(tr.p, pts[i], color); // base disk of the cone
}
}
if(renderFlags & RENDER_DEBUG_SOLID)
{
for(PxU32 i=0;i<nbVerts;i++)
{
const PxU32 j = (i+1) % nbVerts;
addTriangle(tip, pts[i], pts[j], color);
addTriangle(tr.p, pts[i], pts[j], color);
}
}
}
void RenderPhysX3Debug::addCylinder(float radius, float height, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
const PxU32 nbVerts = NB_CIRCLE_PTS;
PxVec3 pts[NB_CIRCLE_PTS];
generatePolygon(nbVerts, pts, ORIENTATION_XZ, radius, 0.0f, &tr);
PxTransform tr2 = tr;
tr2.p = tr.transform(PxVec3(0.0f, height, 0.0f));
PxVec3 pts2[NB_CIRCLE_PTS];
generatePolygon(nbVerts, pts2, ORIENTATION_XZ, radius, 0.0f, &tr2);
if(renderFlags & RENDER_DEBUG_WIREFRAME)
{
for(PxU32 i=0;i<nbVerts;i++)
{
const PxU32 j = (i+1) % nbVerts;
addLine(pts[i], pts[j], color); // circle
addLine(pts2[i], pts2[j], color); // circle
}
for(PxU32 i=0;i<nbVerts;i++)
{
addLine(pts[i], pts2[i], color); // side
addLine(tr.p, pts[i], color); // disk
addLine(tr2.p, pts2[i], color); // disk
}
}
if(renderFlags & RENDER_DEBUG_SOLID)
{
for(PxU32 i=0;i<nbVerts;i++)
{
const PxU32 j = (i+1) % nbVerts;
addTriangle(tr.p, pts[i], pts[j], color);
addTriangle(tr2.p, pts2[i], pts2[j], color);
addTriangle(pts[i], pts[j], pts2[j], color);
addTriangle(pts[i], pts2[j], pts2[i], color);
}
}
}
void RenderPhysX3Debug::addStar(const PxVec3& p, const float size, const RendererColor& color )
{
const PxVec3 up(0.f, size, 0.f);
const PxVec3 right(size, 0.f, 0.f);
const PxVec3 forwards(0.f, 0.f, size);
addLine(p + up, p - up, color);
addLine(p + right, p - right, color);
addLine(p + forwards, p - forwards, color);
}
void RenderPhysX3Debug::addCapsule(const PxCapsuleGeometry& cg, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
PxTransform pose = PxTransform(PxVec3(0.f), PxQuat(PxPi/2, PxVec3(0,0,1)));
pose = tr * pose;
PxVec3 p0(0, -cg.halfHeight, 0);
PxVec3 p1(0, cg.halfHeight, 0);
p0 = pose.transform(p0);
p1 = pose.transform(p1);
pose.p = p0;
/*PxTransform pose = PxTransform(PxVec3(0.f), PxQuat(PxPi/2, PxVec3(0,0,1)));
pose = tr * pose;*/
//const PxReal height = cg.halfHeight;
//const PxVec3 p0 = tr.p - PxVec3(0, height, 0);
//const PxVec3 p1 = tr.p + PxVec3(0, height, 0);
addCapsule(p0, p1, cg.radius, 2*cg.halfHeight, pose, color, renderFlags);
}
void RenderPhysX3Debug::addCapsule(const PxVec3& p0, const PxVec3& p1, const float radius, const float height, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
addSphere(p0, radius, color, renderFlags);
addSphere(p1, radius, color, renderFlags);
addCylinder(radius, height, tr, color, renderFlags);
}
void RenderPhysX3Debug::addRectangle(float width, float length, const PxTransform& tr, const RendererColor& color)
{
PxMat33 m33 = PxMat33(tr.q);
PxVec3 Axis1 = m33.column1;
PxVec3 Axis2 = m33.column2;
Axis1 *= length;
Axis2 *= width;
PxVec3 pts[4];
pts[0] = tr.p + Axis1 + Axis2 ;
pts[1] = tr.p - Axis1 + Axis2 ;
pts[2] = tr.p - Axis1 - Axis2 ;
pts[3] = tr.p + Axis1 - Axis2 ;
addTriangle(pts[0], pts[1], pts[2], color);
addTriangle(pts[0], pts[2], pts[3], color);
}
void RenderPhysX3Debug::addGeometry(const PxGeometry& geom, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
switch(geom.getType())
{
case PxGeometryType::eBOX:
{
addBox(static_cast<const PxBoxGeometry&>(geom), tr, color, renderFlags);
}
break;
case PxGeometryType::eSPHERE:
{
addSphere(static_cast<const PxSphereGeometry&>(geom), tr, color, renderFlags);
}
break;
case PxGeometryType::eCAPSULE:
{
addCapsule(static_cast<const PxCapsuleGeometry&>(geom), tr, color, renderFlags);
}
break;
case PxGeometryType::eCONVEXMESH:
{
addConvex(static_cast<const PxConvexMeshGeometry&>(geom), tr, color, renderFlags);
}
break;
case PxGeometryType::ePLANE:
case PxGeometryType::eTRIANGLEMESH:
case PxGeometryType::eHEIGHTFIELD:
default:
{
PX_ASSERT(!"Not supported!");
break;
}
}
}
void RenderPhysX3Debug::addConvex(const PxConvexMeshGeometry& cg, const PxTransform& tr, const RendererColor& color, PxU32 renderFlags)
{
const PxConvexMesh& mesh = *cg.convexMesh;
const PxMat33 rot = PxMat33(tr.q) * cg.scale.toMat33();
// PT: you can't use PxTransform with a non-uniform scaling
const PxMat44 globalPose(rot, tr.p);
const PxU32 polygonCount = mesh.getNbPolygons();
const PxU8* indexBuffer = mesh.getIndexBuffer();
const PxVec3* vertexBuffer = mesh.getVertices();
if(renderFlags & RENDER_DEBUG_WIREFRAME)
{
for(PxU32 i=0; i<polygonCount; i++)
{
PxHullPolygon data;
mesh.getPolygonData(i, data);
const PxU32 vertexCount = data.mNbVerts;
PxU32 i0 = indexBuffer[vertexCount-1];
PxU32 i1 = *indexBuffer++;
addLine(globalPose.transform(vertexBuffer[i0]), globalPose.transform(vertexBuffer[i1]), color);
for(PxU32 j=1; j<vertexCount; j++)
{
i0 = indexBuffer[-1];
i1 = *indexBuffer++;
addLine(globalPose.transform(vertexBuffer[i0]), globalPose.transform(vertexBuffer[i1]), color);
}
}
}
if(renderFlags & RENDER_DEBUG_SOLID)
{
for(PxU32 i=0; i<polygonCount; i++)
{
PxHullPolygon data;
mesh.getPolygonData(i, data);
const PxU32 vertexCount = data.mNbVerts;
const PxVec3& v0 = vertexBuffer[indexBuffer[0]];
for(PxU32 j=0; j<vertexCount-2; j++)
{
const PxVec3& v1 = vertexBuffer[indexBuffer[j+1]];
const PxVec3& v2 = vertexBuffer[indexBuffer[j+2]];
addTriangle(globalPose.transform(v0), globalPose.transform(v1), globalPose.transform(v2), color);
}
indexBuffer += vertexCount;
}
}
}
void RenderPhysX3Debug::addArrow(const PxVec3& posA, const PxVec3& posB, const RendererColor& color)
{
const PxVec3 t0 = (posB - posA).getNormalized();
const PxVec3 a = PxAbs(t0.x)<0.707f ? PxVec3(1,0,0): PxVec3(0,1,0);
const PxVec3 t1 = t0.cross(a).getNormalized();
const PxVec3 t2 = t0.cross(t1).getNormalized();
addLine(posA, posB, color);
addLine(posB, posB - t0*0.15f + t1 * 0.15f, color);
addLine(posB, posB - t0*0.15f - t1 * 0.15f, color);
addLine(posB, posB - t0*0.15f + t2 * 0.15f, color);
addLine(posB, posB - t0*0.15f - t2 * 0.15f, color);
}

View File

@ -0,0 +1,100 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_PHYSX3_DEBUG_H
#define RENDER_PHYSX3_DEBUG_H
#include <SamplePointDebugRender.h>
#include <SampleLineDebugRender.h>
#include <SampleTriangleDebugRender.h>
#include "SampleAllocator.h"
enum RenderPhysX3DebugFlag
{
RENDER_DEBUG_WIREFRAME = (1<<0),
RENDER_DEBUG_SOLID = (1<<1),
RENDER_DEBUG_DEFAULT = RENDER_DEBUG_SOLID//RENDER_DEBUG_WIREFRAME//|RENDER_DEBUG_SOLID
};
namespace physx
{
class PxRenderBuffer;
class PxConvexMeshGeometry;
class PxCapsuleGeometry;
class PxSphereGeometry;
class PxBoxGeometry;
class PxGeometry;
}
class Camera;
class RenderPhysX3Debug : public SampleFramework::SamplePointDebugRender
, public SampleFramework::SampleLineDebugRender
, public SampleFramework::SampleTriangleDebugRender
, public SampleAllocateable
{
public:
RenderPhysX3Debug(SampleRenderer::Renderer& renderer, SampleFramework::SampleAssetManager& assetmanager);
virtual ~RenderPhysX3Debug();
void addAABB(const PxBounds3& box, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addOBB(const PxVec3& boxCenter, const PxVec3& boxExtents, const PxMat33& boxRot, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addSphere(const PxVec3& sphereCenter, float sphereRadius, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addBox(const PxBoxGeometry& bg, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addSphere(const PxSphereGeometry& sg, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addCone(float radius, float height, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addSphereExt(const PxVec3& sphereCenter, float sphereRadius, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addConeExt(float radius0, float radius1, const PxVec3& p0, const PxVec3& p1 , const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addCylinder(float radius, float height, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addStar(const PxVec3& p, const float size, const SampleRenderer::RendererColor& color );
void addCapsule(const PxVec3& p0, const PxVec3& p1, const float radius, const float height, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addCapsule(const PxCapsuleGeometry& cg, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addGeometry(const PxGeometry& geom, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addRectangle(float width, float length, const PxTransform& tr, const SampleRenderer::RendererColor& color);
void addConvex(const PxConvexMeshGeometry& cg, const PxTransform& tr, const SampleRenderer::RendererColor& color, PxU32 renderFlags = RENDER_DEBUG_DEFAULT);
void addArrow(const PxVec3& posA, const PxVec3& posB, const SampleRenderer::RendererColor& color);
void update(const PxRenderBuffer& debugRenderable);
void update(const PxRenderBuffer& debugRenderable, const Camera& camera);
void queueForRender();
void clear();
private:
void addBox(const PxVec3* pts, const SampleRenderer::RendererColor& color, PxU32 renderFlags);
void addCircle(PxU32 nbPts, const PxVec3* pts, const SampleRenderer::RendererColor& color, const PxVec3& offset);
};
#endif

View File

@ -0,0 +1,48 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "RenderSphereActor.h"
#include "RendererCapsuleShape.h"
using namespace physx;
using namespace SampleRenderer;
RenderSphereActor::RenderSphereActor(Renderer& renderer, PxReal radius)
{
RendererShape* rs = new RendererCapsuleShape(renderer, 0.0f, radius);
setRenderShape(rs);
}
RenderSphereActor::RenderSphereActor(const RenderSphereActor& src) : RenderBaseActor(src)
{
}
RenderSphereActor::~RenderSphereActor()
{
}

View File

@ -0,0 +1,44 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_SPHERE_ACTOR_H
#define RENDER_SPHERE_ACTOR_H
#include "RenderBaseActor.h"
#include "foundation/PxSimpleTypes.h"
class RenderSphereActor : public RenderBaseActor
{
public:
RenderSphereActor(SampleRenderer::Renderer& renderer, PxReal radius);
RenderSphereActor(const RenderSphereActor&);
virtual ~RenderSphereActor();
};
#endif

View File

@ -0,0 +1,103 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "SamplePreprocessor.h"
#include "RendererMemoryMacros.h"
#include "RenderTexture.h"
#include "Renderer.h"
#include "RendererTexture2DDesc.h"
using namespace physx;
using namespace SampleRenderer;
RenderTexture::RenderTexture(Renderer& renderer, PxU32 id, PxU32 width, PxU32 height, const void* data) :
mID (id),
mTexture (NULL),
mOwnsTexture (true)
{
RendererTexture2DDesc tdesc;
tdesc.format = RendererTexture2D::FORMAT_B8G8R8A8;
tdesc.width = width;
tdesc.height = height;
tdesc.numLevels = 1;
/*
tdesc.filter;
tdesc.addressingU;
tdesc.addressingV;
tdesc.renderTarget;
*/
PX_ASSERT(tdesc.isValid());
mTexture = renderer.createTexture2D(tdesc);
PX_ASSERT(mTexture);
const PxU32 componentCount = 4;
if(mTexture)
{
PxU32 pitch = 0;
void* buffer = mTexture->lockLevel(0, pitch);
PX_ASSERT(buffer);
if(buffer)
{
PxU8* levelDst = (PxU8*)buffer;
const PxU8* levelSrc = (PxU8*)data;
const PxU32 levelWidth = mTexture->getWidthInBlocks();
const PxU32 levelHeight = mTexture->getHeightInBlocks();
const PxU32 rowSrcSize = levelWidth * mTexture->getBlockSize();
PX_UNUSED(rowSrcSize);
PX_ASSERT(rowSrcSize <= pitch); // the pitch can't be less than the source row size.
for(PxU32 row=0; row<levelHeight; row++)
{
// copy per pixel to handle RBG case, based on component count
for(PxU32 col=0; col<levelWidth; col++)
{
*levelDst++ = levelSrc[0];
*levelDst++ = levelSrc[1];
*levelDst++ = levelSrc[2];
*levelDst++ = 0xFF; //alpha
levelSrc += componentCount;
}
}
}
mTexture->unlockLevel(0);
}
}
RenderTexture::RenderTexture(Renderer& renderer, PxU32 id, RendererTexture2D* texture) :
mID (id),
mTexture (texture),
mOwnsTexture (false)
{
}
RenderTexture::~RenderTexture()
{
if(mOwnsTexture)
SAFE_RELEASE(mTexture);
}

View File

@ -0,0 +1,55 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef RENDER_TEXTURE_H
#define RENDER_TEXTURE_H
#include "RenderBaseObject.h"
#include "common/PxPhysXCommonConfig.h"
#include "foundation/PxVec3.h"
#include <RendererTexture2D.h>
namespace SampleRenderer
{
class Renderer;
}
class RenderTexture : public RenderBaseObject
{
public:
RenderTexture(SampleRenderer::Renderer& renderer, PxU32 id, PxU32 width, PxU32 height, const void* data);
RenderTexture(SampleRenderer::Renderer& renderer, PxU32 id, SampleRenderer::RendererTexture2D* texture);
virtual ~RenderTexture();
PxU32 mID;
SampleRenderer::RendererTexture2D* mTexture;
bool mOwnsTexture;
};
#endif

View File

@ -0,0 +1,332 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include <stdio.h>
#include <assert.h>
#include "SampleAllocator.h"
#include "RendererMemoryMacros.h"
#include "foundation/PxAssert.h"
#include "foundation/PxErrorCallback.h"
#include "PsString.h"
PxErrorCallback& getSampleErrorCallback();
#if defined(WIN32)
// on win32 we only have 8-byte alignment guaranteed, but the CRT provides special aligned allocation
// fns
#include <malloc.h>
#include <crtdbg.h>
static void* platformAlignedAlloc(size_t size)
{
return _aligned_malloc(size, 16);
}
static void platformAlignedFree(void* ptr)
{
_aligned_free(ptr);
}
#elif PX_LINUX_FAMILY
static void* platformAlignedAlloc(size_t size)
{
return ::memalign(16, size);
}
static void platformAlignedFree(void* ptr)
{
::free(ptr);
}
#else
// on Win64 we get 16-byte alignment by default
static void* platformAlignedAlloc(size_t size)
{
void *ptr = ::malloc(size);
PX_ASSERT((reinterpret_cast<size_t>(ptr) & 15)==0);
return ptr;
}
static void platformAlignedFree(void* ptr)
{
::free(ptr);
}
#endif
#define DEBUG_IDENTIFIER 0xBeefBabe
#define DEBUG_DEALLOCATED 0xDeadDead
#define INVALID_ID 0xffffffff
#define MEMBLOCKSTART 64
#if PX_DEBUG || PX_PROFILE
static void print(const char* buffer)
{
shdfnd::printFormatted("%s", buffer);
#if PX_WINDOWS
if(buffer) { _RPT0(_CRT_WARN, buffer); }
#endif
}
#endif
#if PX_DEBUG || PX_PROFILE
struct DebugBlock
{
const char* mFilename;
#if !PX_P64_FAMILY
PxU32 mPad0;
#endif
const char* mHandle;
#if !PX_P64_FAMILY
PxU32 mPadHandle;
#endif
PxU32 mCheckValue;
PxU32 mSize;
PxU32 mSlotIndex;
PxU32 mLine;
};
PX_COMPILE_TIME_ASSERT(!(sizeof(DebugBlock)&15));
#endif
PxSampleAllocator::PxSampleAllocator() :
mMemBlockList (NULL),
mMemBlockListSize (0),
mFirstFree (INVALID_ID),
mMemBlockUsed (0),
mNbAllocatedBytes (0),
mHighWaterMark (0),
mTotalNbAllocs (0),
mNbAllocs (0)
{
#if PX_DEBUG || PX_PROFILE
// Initialize the Memory blocks list (DEBUG mode only)
mMemBlockList = (void**)::malloc(MEMBLOCKSTART*sizeof(void*));
memset(mMemBlockList, 0, MEMBLOCKSTART*sizeof(void*));
mMemBlockListSize = MEMBLOCKSTART;
#endif
}
PxSampleAllocator::~PxSampleAllocator()
{
#if PX_DEBUG || PX_PROFILE
char buffer[4096];
if(mNbAllocatedBytes)
{
sprintf(buffer, "Memory leak detected: %d bytes non released\n", mNbAllocatedBytes);
print(buffer);
}
if(mNbAllocs)
{
sprintf(buffer, "Remaining allocs: %d\n", mNbAllocs);
print(buffer);
}
sprintf(buffer, "Total nb alloc: %d\n", mTotalNbAllocs);
print(buffer);
sprintf(buffer, "High water mark: %d Kb\n", mHighWaterMark/1024);
print(buffer);
// Scanning for memory leaks
if(mMemBlockList && mNbAllocs)
{
PxU32 NbLeaks = 0;
sprintf(buffer, "\n\n SampleAllocator: Memory leaks detected :\n\n");
print(buffer);
for(PxU32 i=0; i<mMemBlockUsed; i++)
{
if(size_t(mMemBlockList[i])&1)
continue;
const DebugBlock* DB = (const DebugBlock*)mMemBlockList[i];
sprintf(buffer, " Address 0x%p, %d bytes, allocated in: %s(%d):\n\n", (void*)(DB+1), DB->mSize, DB->mFilename, DB->mLine);
print(buffer);
NbLeaks++;
}
sprintf(buffer, "\n Dump complete (%d leaks)\n\n", NbLeaks);
print(buffer);
}
// Free the Memory Block list
if(mMemBlockList) ::free(mMemBlockList);
mMemBlockList = NULL;
#endif
}
void* PxSampleAllocator::allocate(size_t size, const char* typeName, const char* filename, int line)
{
if(!size)
return NULL;
#if PX_DEBUG || PX_PROFILE
Ps::MutexT<Ps::RawAllocator>::ScopedLock lock(mMutex);
// Allocate one debug block in front of each real allocation
const size_t neededSize = size + sizeof(DebugBlock);
void* ptr = platformAlignedAlloc(neededSize);
if (NULL != ptr)
{
// Fill debug block
DebugBlock* DB = (DebugBlock*)ptr;
DB->mCheckValue = DEBUG_IDENTIFIER;
DB->mSize = PxU32(size);
DB->mLine = line;
DB->mSlotIndex = INVALID_ID;
DB->mFilename = filename;
DB->mHandle = typeName ? typeName : "";
// Update global stats
mTotalNbAllocs++;
mNbAllocs++;
mNbAllocatedBytes += PxU32(size);
if(mNbAllocatedBytes>mHighWaterMark)
mHighWaterMark = mNbAllocatedBytes;
// Insert the allocated block in the debug memory block list
if(mMemBlockList)
{
if(mFirstFree!=INVALID_ID)
{
// Recycle old location
PxU32 NextFree = (PxU32)(size_t)(mMemBlockList[mFirstFree]);
if(NextFree!=INVALID_ID)
NextFree>>=1;
mMemBlockList[mFirstFree] = ptr;
DB->mSlotIndex = mFirstFree;
mFirstFree = NextFree;
}
else
{
if(mMemBlockUsed==mMemBlockListSize)
{
// Allocate a bigger block
void** tps = (void**)::malloc((mMemBlockListSize+MEMBLOCKSTART)*sizeof(void*));
// Copy already used part
memcpy(tps, mMemBlockList, mMemBlockListSize*sizeof(void*));
// Initialize remaining part
void* Next = tps + mMemBlockListSize;
memset(Next, 0, MEMBLOCKSTART*sizeof(void*));
// Free previous memory, setup new pointer
::free(mMemBlockList);
mMemBlockList = tps;
// Setup new size
mMemBlockListSize += MEMBLOCKSTART;
}
mMemBlockList[mMemBlockUsed] = ptr;
DB->mSlotIndex = mMemBlockUsed++;
}
}
return ((PxU8*)ptr) + sizeof(DebugBlock);
}
#else
void* ptr = platformAlignedAlloc(size);
if (NULL != ptr)
return ptr;
#endif
getSampleErrorCallback().reportError(PxErrorCode::eOUT_OF_MEMORY, "NULL ptr returned\n", __FILE__, __LINE__);
return NULL;
}
void PxSampleAllocator::deallocate(void* memory)
{
if(!memory)
return;
#if PX_DEBUG || PX_PROFILE
Ps::MutexT<Ps::RawAllocator>::ScopedLock lock(mMutex);
DebugBlock* DB = ((DebugBlock*)memory)-1;
// Check we allocated it
if(DB->mCheckValue!=DEBUG_IDENTIFIER)
{
shdfnd::printFormatted("Error: free unknown memory!!\n");
// ### should we really continue??
return;
}
// Update global stats
mNbAllocatedBytes -= DB->mSize;
mNbAllocs--;
// Remove the block from the Memory block list
if(mMemBlockList)
{
PxU32 FreeSlot = DB->mSlotIndex;
assert(mMemBlockList[FreeSlot]==DB);
PxU32 NextFree = mFirstFree;
if(NextFree!=INVALID_ID)
{
NextFree<<=1;
NextFree|=1;
}
mMemBlockList[FreeSlot] = (void*)size_t(NextFree);
mFirstFree = FreeSlot;
}
// ### should be useless since we'll release the memory just afterwards
DB->mCheckValue = DEBUG_DEALLOCATED;
DB->mSize = 0;
DB->mHandle = 0;
DB->mFilename = NULL;
DB->mSlotIndex = INVALID_ID;
DB->mLine = INVALID_ID;
platformAlignedFree(DB);
#else
platformAlignedFree(memory);
#endif
}
static PxSampleAllocator* gAllocator = NULL;
void initSampleAllocator()
{
PX_ASSERT(!gAllocator);
gAllocator = new PxSampleAllocator;
}
void releaseSampleAllocator()
{
DELETESINGLE(gAllocator);
}
PxSampleAllocator* getSampleAllocator()
{
PX_ASSERT(gAllocator);
return gAllocator;
}

View File

@ -0,0 +1,87 @@
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// * Neither the name of NVIDIA CORPORATION nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#ifndef SAMPLE_ALLOCATOR_H
#define SAMPLE_ALLOCATOR_H
#include "foundation/PxAllocatorCallback.h"
#include "common/PxPhysXCommonConfig.h"
#include "PsMutex.h"
#include "PxTkNamespaceMangle.h"
using namespace physx;
class PxSampleAllocator : public PxAllocatorCallback
{
public:
PxSampleAllocator();
~PxSampleAllocator();
virtual void* allocate(size_t size, const char* typeName, const char* filename, int line);
void* allocate(size_t size, const char* filename, int line) { return allocate(size, NULL, filename, line); }
virtual void deallocate(void* ptr);
protected:
Ps::MutexT<Ps::RawAllocator> mMutex;
void** mMemBlockList;
PxU32 mMemBlockListSize;
PxU32 mFirstFree;
PxU32 mMemBlockUsed;
public:
PxI32 mNbAllocatedBytes;
PxI32 mHighWaterMark;
PxI32 mTotalNbAllocs;
PxI32 mNbAllocs;
};
void initSampleAllocator();
void releaseSampleAllocator();
PxSampleAllocator* getSampleAllocator();
class SampleAllocateable
{
public:
PX_FORCE_INLINE void* operator new (size_t, void* ptr) { return ptr; }
PX_FORCE_INLINE void* operator new (size_t size, const char* handle, const char * filename, int line) { return getSampleAllocator()->allocate(size, handle, filename, line); }
PX_FORCE_INLINE void* operator new[] (size_t size, const char* handle, const char * filename, int line) { return getSampleAllocator()->allocate(size, handle, filename, line); }
PX_FORCE_INLINE void operator delete (void* p) { getSampleAllocator()->deallocate(p); }
PX_FORCE_INLINE void operator delete (void* p, PxU32, const char*, int) { getSampleAllocator()->deallocate(p); }
PX_FORCE_INLINE void operator delete (void* p, const char*, const char *, int) { getSampleAllocator()->deallocate(p); }
PX_FORCE_INLINE void operator delete[] (void* p) { getSampleAllocator()->deallocate(p); }
PX_FORCE_INLINE void operator delete[] (void* p, PxU32, const char*, int) { getSampleAllocator()->deallocate(p); }
PX_FORCE_INLINE void operator delete[] (void* p, const char*, const char *, int) { getSampleAllocator()->deallocate(p); }
};
#define SAMPLE_ALLOC(x) getSampleAllocator()->allocate(x, 0, __FILE__, __LINE__)
#define SAMPLE_FREE(x) if(x) { getSampleAllocator()->deallocate(x); x = NULL; }
#define SAMPLE_NEW(x) new(#x, __FILE__, __LINE__) x
#endif

Some files were not shown because too many files have changed in this diff Show More