| 21 | #include <Qt3DRaytraceExtras/qfirstpersoncameracontroller.h> |
| 22 | |
| 23 | static Qt3DCore::QEntity *createScene() |
| 24 | { |
| 25 | auto *rootEntity = new Qt3DCore::QEntity; |
| 26 | |
| 27 | auto *camera = new Qt3DRaytrace::QCamera(rootEntity); |
| 28 | camera->setPosition({0.0f, 0.0f, 4.0f}); |
| 29 | camera->setExposure(1.0f); |
| 30 | camera->setFieldOfView(60.0f); |
| 31 | |
| 32 | auto *cameraController = new Qt3DRaytraceExtras::QFirstPersonCameraController(rootEntity); |
| 33 | cameraController->setCamera(camera); |
| 34 | cameraController->setMoveSpeed(2.0f); |
| 35 | cameraController->setLookSpeed(180.0f); |
| 36 | |
| 37 | auto *renderSettings = new Qt3DRaytrace::QRenderSettings; |
| 38 | renderSettings->setCamera(camera); |
| 39 | renderSettings->setSkyColor(QColor("#00C5FF")); |
| 40 | renderSettings->setSkyIntensity(0.5f); |
| 41 | rootEntity->addComponent(renderSettings); |
| 42 | |
| 43 | auto *sunEntity = new Qt3DCore::QEntity(rootEntity); |
| 44 | { |
| 45 | auto *sunTransform = new Qt3DCore::QTransform; |
| 46 | sunTransform->setRotationX(60.0f); |
| 47 | sunTransform->setRotationZ(35.0f); |
| 48 | |
| 49 | auto *sunLight = new Qt3DRaytrace::QDistantLight; |
| 50 | sunLight->setColor(Qt3DRaytrace::to_sRgb(QColor::fromRgbF(1.0f, 0.9f, 0.8f))); |
| 51 | sunLight->setIntensity(4.0f); |
| 52 | |
| 53 | sunEntity->addComponent(sunTransform); |
| 54 | sunEntity->addComponent(sunLight); |
| 55 | } |
| 56 | |
| 57 | auto *monkeyEntity = new Qt3DCore::QEntity(rootEntity); |
| 58 | { |
| 59 | auto *monkeyMaterial = new Qt3DRaytrace::QMaterial; |
| 60 | monkeyMaterial->setAlbedo(QColor("crimson")); |
| 61 | monkeyMaterial->setRoughness(0.5f); |
| 62 | |
| 63 | auto *monkeyMesh = new Qt3DRaytrace::QMesh; |
| 64 | monkeyMesh->setSource(QUrl("qrc:/monkey.obj")); |
| 65 | |
| 66 | monkeyEntity->addComponent(monkeyMaterial); |
| 67 | monkeyEntity->addComponent(monkeyMesh); |
| 68 | } |
| 69 | |
| 70 | auto *groundEntity = new Qt3DCore::QEntity(rootEntity); |
| 71 | { |
| 72 | auto *groundTransform = new Qt3DCore::QTransform; |
| 73 | groundTransform->setTranslation({0.0f, -1.0f, 0.0f}); |
| 74 | groundTransform->setScale(10.0f); |
| 75 | |
| 76 | auto *groundMaterial = new Qt3DRaytrace::QMaterial; |
| 77 | groundMaterial->setAlbedo(QColor("white")); |
| 78 | |
| 79 | auto *groundMesh = new Qt3DRaytrace::QMesh; |
| 80 | groundMesh->setSource(QUrl("qrc:/plane.obj")); |
no test coverage detected