Constructor
| 41 | |
| 42 | // Constructor |
| 43 | SceneDemo::SceneDemo(const std::string& name, EngineSettings& settings, reactphysics3d::PhysicsCommon& physicsCommon, bool isPhysicsWorldSimulated, bool isShadowMappingEnabled) |
| 44 | : Scene(name, settings, isShadowMappingEnabled), mBackgroundColor(0.75, 0.75, 0.75, 1), |
| 45 | mIsShadowMappingInitialized(false), |
| 46 | mDepthShader("shaders/depth.vert", "shaders/depth.frag"), |
| 47 | mPhongShader("shaders/phong.vert", "shaders/phong.frag"), |
| 48 | mColorShader("shaders/color.vert", "shaders/color.frag"), |
| 49 | mQuadShader("shaders/quad.vert", "shaders/quad.frag"), |
| 50 | mVBOQuad(GL_ARRAY_BUFFER), mDebugVBOLinesVertices(GL_ARRAY_BUFFER), mDebugVBOTrianglesVertices(GL_ARRAY_BUFFER), |
| 51 | mMeshFolderPath("meshes/"), mPhysicsCommon(physicsCommon), mPhysicsWorld(nullptr), mIsPhysicsWorldSimulated(isPhysicsWorldSimulated), |
| 52 | mIsMovingBody(false), mMovingBody(nullptr), mCameraRotationAngle(0) { |
| 53 | |
| 54 | shadowMapTextureLevel++; |
| 55 | |
| 56 | // Move the lights |
| 57 | float lightsRadius = 80.0f; |
| 58 | float lightsHeight = 50.0f; |
| 59 | mLight0.translateWorld(Vector3(0.4f * lightsRadius, 0.6 * lightsHeight, 0.4f * lightsRadius)); |
| 60 | mLight1.translateWorld(Vector3(-0.4 * lightsRadius, 0.6 * lightsHeight, 0.4 * lightsRadius)); |
| 61 | mLight2.translateWorld(Vector3(0, 0.6 * lightsHeight, -0.4f * lightsRadius)); |
| 62 | |
| 63 | // Set the lights colors |
| 64 | float lightIntensity = 0.5; |
| 65 | Color lightColor(lightIntensity * 1.0, lightIntensity * 1.0f, lightIntensity * 1.0f, 1.0f); |
| 66 | float lightIntensity2 = 0.1; |
| 67 | Color lightColor2(lightIntensity2 * 1.0, lightIntensity2 * 1.0f, lightIntensity2 * 1.0f, 1.0f); |
| 68 | mLight0.setDiffuseColor(lightColor); |
| 69 | mLight1.setDiffuseColor(lightColor); |
| 70 | mLight2.setDiffuseColor(lightColor2); |
| 71 | |
| 72 | mShadowMapLightCameras[0].translateWorld(mLight0.getOrigin()); |
| 73 | mShadowMapLightCameras[0].rotateLocal(Vector3(1, 0, 0), -PI / 4.0f); |
| 74 | mShadowMapLightCameras[0].rotateLocal(Vector3(0, 1, 0), PI / 4.0f); |
| 75 | |
| 76 | mShadowMapLightCameras[1].translateWorld(mLight1.getOrigin()); |
| 77 | mShadowMapLightCameras[1].rotateLocal(Vector3(1, 0, 0), -PI/4.0f); |
| 78 | mShadowMapLightCameras[1].rotateLocal(Vector3(0, 1, 0), -PI / 4.0f); |
| 79 | |
| 80 | for (int i = 0; i < NB_SHADOW_MAPS; i++) { |
| 81 | mShadowMapLightCameras[i].setDimensions(SHADOWMAP_WIDTH, SHADOWMAP_HEIGHT); |
| 82 | mShadowMapLightCameras[i].setFieldOfView(100.0f); |
| 83 | mShadowMapLightCameras[i].setSceneRadius(100); |
| 84 | } |
| 85 | |
| 86 | mShadowMapBiasMatrix.setAllValues(0.5, 0.0, 0.0, 0.5, |
| 87 | 0.0, 0.5, 0.0, 0.5, |
| 88 | 0.0, 0.0, 0.5, 0.5, |
| 89 | 0.0, 0.0, 0.0, 1.0); |
| 90 | |
| 91 | // Create the Shadow map FBO and texture |
| 92 | if (mIsShadowMappingEnabled) { |
| 93 | createShadowMapFBOAndTexture(); |
| 94 | } |
| 95 | |
| 96 | createQuadVBO(); |
| 97 | |
| 98 | createDebugVBO(); |
| 99 | |
| 100 | // Init rendering for the AABBs |
nothing calls this directly
no test coverage detected