diff --git a/.travis.yml b/.travis.yml index 97df9a4..170d312 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,4 +33,8 @@ jobs: - cmake --build . - cmake --build . --target coveralls after_success: - - bash <(curl -s https://codecov.io/bash) \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) + +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install imagemagick; fi diff --git a/tests/uvmap_skybox.cpp b/tests/uvmap_skybox.cpp new file mode 100644 index 0000000..f463e92 --- /dev/null +++ b/tests/uvmap_skybox.cpp @@ -0,0 +1,72 @@ +/* + * DoRayMe - a quick and dirty Raytracer + * Skybox test for bonus chapter UV Mapping + * + * Created by Manoƫl Trapier + * Copyright (c) 2020 986-Studio. + * + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +int main() +{ + World w = World(); + + Light light = Light(POINT_LIGHT, Point(0, 100, 0), Colour(1, 1, 1)); + w.addLight(&light); + + Sphere sp = Sphere();; + sp.setTransform(translation(0, 0, 5) * scaling(0.75, 0.75, 0.75)); + sp.material.diffuse = 0.4; + sp.material.specular = 0.6; + sp.material.shininess = 20; + sp.material.reflective = 0.6; + sp.material.ambient = 0; + w.addObject(&sp); + + UVImage left = UVImage("negx.jpg"); + UVImage right = UVImage("posx.jpg"); + UVImage front = UVImage("posz.jpg"); + UVImage back = UVImage("negz.jpg"); + UVImage up = UVImage("posy.jpg"); + UVImage down = UVImage("negy.jpg"); + + Cube cb = Cube(); + TextureMap tm = TextureMap(CUBIC_MAP, nullptr); + tm.setCubePattern(&front, &left, &right, &back, &up, &down); + cb.material.pattern = &tm; + cb.material.diffuse = 0; + cb.material.specular = 0; + cb.material.ambient = 1; + cb.setTransform(scaling(1000, 1000, 1000)); + w.addObject(&cb); + + /* Set the camera */ + Camera camera = Camera(800, 400, 1.2); + camera.setTransform(viewTransform(Point(0, 0, 0), + Point(0, 0, 5), + Vector(0, 1, 0))); + + /* Now render it */ + Canvas image = camera.render(w); + + image.SaveAsPNG("uvmap_skybox.png"); + + return 0; +} \ No newline at end of file