MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / onInit

Method onInit

deps/physx/physx/samples/samplesubmarine/SampleSubmarine.cpp:127–175  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125///////////////////////////////////////////////////////////////////////////////
126
127void 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
177void SampleSubmarine::createMaterials()
178{

Callers

nothing calls this directly

Calls 15

PxMaxFunction · 0.85
getNbPhysicalCoresFunction · 0.85
fatalErrorFunction · 0.85
setupFilteringFunction · 0.85
setMouseCursorHidingMethod · 0.80
setMouseSensitivityMethod · 0.80
setAmbientColorMethod · 0.80
setFogMethod · 0.80
PxTransformClass · 0.50
RendererColorClass · 0.50
PxVec3Class · 0.50

Tested by

no test coverage detected