66 lines
2 KiB
C++
66 lines
2 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
|
|
#include "camera/perspectivecamera.h"
|
|
|
|
#include "scene/fastscene.h"
|
|
#ifdef SUPERRENDERER_FOUND
|
|
|
|
#include "renderer/superrenderer.h"
|
|
|
|
#endif
|
|
|
|
|
|
#include "light/ambientlight.h"
|
|
#include "light/pointlight.h"
|
|
#include "shader/toneshader.h"
|
|
#include "primitive/infiniteplane.h"
|
|
#include "shader/simpleshadowshader.h"
|
|
#include "primitive/box.h"
|
|
#include "shader/cloudshader.h"
|
|
|
|
int main()
|
|
{
|
|
FastScene scene;
|
|
scene.setBackgroundColor(Color(0.529f, 0.808f, 0.922f));
|
|
|
|
// Add lights
|
|
auto mainLight = std::make_shared<PointLight>(Vector3d(5.0f, 10.0f, 0.0f), 100.0f);
|
|
scene.add(mainLight);
|
|
scene.add(std::make_shared<AmbientLight>(0.3f));
|
|
|
|
// Add the bus
|
|
auto busShader = std::make_shared<ToneShader>(mainLight);
|
|
scene.addObj("data/Bus/source/T07-11M.obj", Vector3d(1.0f, 1.0f, 1.0f), Vector3d(10.0f, 0.0f, 10.0f),
|
|
busShader);
|
|
|
|
// Add floor
|
|
auto floorShader = std::make_shared<SimpleShadowShader>(Color(0.9f, 0.9f, 0.9f));
|
|
scene.add(std::make_shared<InfinitePlane>(Vector3d(0.0f, 0.0f, 0.0f), Vector3d(0.0f, 1.0f, 0.0f),
|
|
floorShader));
|
|
|
|
// Add box for volume shader
|
|
auto cloudSettings = CloudSettings();
|
|
cloudSettings.scale = 0.2f;
|
|
cloudSettings.densityIntensity = 2.0f;
|
|
cloudSettings.densityTreshold = 0.55f;
|
|
auto cloudShader = std::make_shared<CloudShader>(cloudSettings);
|
|
scene.add(std::make_shared<Box>(Vector3d(5.0f, 6.0f, 5.0f), Vector3d(6.0f, 4.0f, 6.0f), cloudShader));
|
|
|
|
// build the tree
|
|
scene.buildTree();
|
|
|
|
// Set up the camera
|
|
PerspectiveCamera camera;
|
|
camera.setPosition(Vector3d(0.0f, 3.0f, 0.0f));
|
|
camera.setForwardDirection(normalized(Vector3d(1.0f, 0.15f, 0.6f)));
|
|
camera.setUpDirection(normalized(Vector3d(0.0f, 1.0f, 0.0f)));
|
|
camera.setFovAngle(90.0f);
|
|
|
|
// Render the scene
|
|
SuperRenderer sr;
|
|
sr.setSuperSamplingFactor(1);
|
|
sr.renderImage(scene, camera, 1024, 1024).save("result.png");
|
|
|
|
return 0;
|
|
}
|