| 125 | /////////////////////////////////////////////////////////////////////////////// |
| 126 | |
| 127 | void SampleSubmarine::onInit() |
| 128 | { |
| 129 | mNbThreads = PxMax(PxI32(shdfnd::Thread::getNbPhysicalCores())-1, 0); |
| 130 | |
| 131 | mCreateCudaCtxManager = true; |
| 132 | |
| 133 | PhysXSample::onInit(); |
| 134 | |
| 135 | PxSceneWriteLock scopedLock(*mScene); |
| 136 | |
| 137 | mSubmarineCameraController = SAMPLE_NEW(SubmarineCameraController)(); |
| 138 | setCameraController(mSubmarineCameraController); |
| 139 | |
| 140 | mApplication.setMouseCursorHiding(true); |
| 141 | mApplication.setMouseCursorRecentering(true); |
| 142 | mSubmarineCameraController->init(PxTransform(PxIdentity)); |
| 143 | mSubmarineCameraController->setMouseSensitivity(0.5f); |
| 144 | mSubmarineCameraController->setMouseLookOnMouseButton(false); |
| 145 | |
| 146 | getRenderer()->setAmbientColor(RendererColor(60, 60, 60)); |
| 147 | |
| 148 | PxMaterial& material = getDefaultMaterial(); |
| 149 | material.setRestitution(0); |
| 150 | material.setDynamicFriction(50.0f); |
| 151 | material.setStaticFriction(50.0f); |
| 152 | |
| 153 | // set gravity |
| 154 | getActiveScene().setGravity(PxVec3(0, -10.0f, 0)); |
| 155 | |
| 156 | createMaterials(); |
| 157 | |
| 158 | getRenderer()->setFog(SampleRenderer::RendererColor(16,16,40), 125.0f); |
| 159 | |
| 160 | PxRigidActor* heightField = loadTerrain("submarine_heightmap.bmp", 0.4f, 3.0f, 3.0f); |
| 161 | if (!heightField) fatalError("Sample can not load file submarine_heightmap.bmp\n"); |
| 162 | |
| 163 | setupFiltering(heightField, FilterGroup::eHEIGHTFIELD, FilterGroup::eCRAB); |
| 164 | |
| 165 | // create ceiling plane |
| 166 | PxReal d = 60.0f; |
| 167 | PxTransform pose = PxTransform(PxVec3(0.0f, d, 0.0f), PxQuat(PxHalfPi, PxVec3(0.0f, 0.0f, -1.0f))); |
| 168 | PxRigidStatic* plane = getPhysics().createRigidStatic(pose); |
| 169 | if(!plane) fatalError("createRigidStatic failed!"); |
| 170 | PxShape* shape = PxRigidActorExt::createExclusiveShape(*plane, PxPlaneGeometry(), material); |
| 171 | if(!shape) fatalError("createShape failed!"); |
| 172 | getActiveScene().addActor(*plane); |
| 173 | |
| 174 | resetScene(); |
| 175 | } |
| 176 | |
| 177 | void SampleSubmarine::createMaterials() |
| 178 | { |
nothing calls this directly
no test coverage detected