-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* DoRayMe - a quick and dirty Raytracer | ||
* UV Align Check test pattern header | ||
* | ||
* Created by Manoël Trapier | ||
* Copyright (c) 2020 986-Studio. | ||
* | ||
*/ | ||
#ifndef DORAYME_UV_ALIGNCHECK_H | ||
#define DORAYME_UV_ALIGNCHECK_H | ||
|
||
class UVAlignCheck : public UVPattern | ||
{ | ||
public: | ||
Colour ul, ur, bl, br; | ||
|
||
UVAlignCheck(Colour main, Colour ul, Colour ur, Colour bl, Colour br) : UVPattern(1, 1, main, main), | ||
ul(ul), ur(ur), bl(bl), br(br) {}; | ||
|
||
Colour uvPatternAt(double u, double v) { | ||
/* Remember that v=0 is at the bottom, v=1 at the top */ | ||
if (v > 0.8) | ||
{ | ||
if (u < 0.2) { return this->ul; } | ||
if (u > 0.8) { return this->ur; } | ||
} | ||
else if (v < 0.2) | ||
{ | ||
if (u < 0.2) { return this->bl; } | ||
if (u > 0.8) { return this->br; } | ||
} | ||
|
||
/* main is stored in A or B */ | ||
return this->a; | ||
}; | ||
}; | ||
|
||
|
||
#endif /* DORAYME_UV_ALIGNCHECK_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* DoRayMe - a quick and dirty Raytracer | ||
* Render test for chapter 10 | ||
* | ||
* Created by Manoël Trapier | ||
* Copyright (c) 2020 986-Studio. | ||
* | ||
*/ | ||
#include <world.h> | ||
#include <light.h> | ||
#include <sphere.h> | ||
#include <plane.h> | ||
#include <material.h> | ||
#include <colour.h> | ||
#include <canvas.h> | ||
#include <camera.h> | ||
|
||
#include <pattern.h> | ||
#include <texturemap.h> | ||
#include <uv_checkers.h> | ||
#include <uv_aligncheck.h> | ||
|
||
#include <transformation.h> | ||
|
||
int main() | ||
{ | ||
World w = World(); | ||
|
||
Light light = Light(POINT_LIGHT, Point(-10, 10, -10), Colour(1, 1, 1)); | ||
w.addLight(&light); | ||
|
||
Plane sp = Plane(); | ||
UVAlignCheck checkers = UVAlignCheck(Colour(1, 1, 1), | ||
Colour(1, 0, 0), | ||
Colour(1, 1, 0), | ||
Colour(0, 1, 0), | ||
Colour(0, 1, 1) | ||
); | ||
TextureMap tm = TextureMap(PLANAR_MAP, &checkers); | ||
sp.material.pattern = &tm; | ||
sp.material.ambient = 0.1; | ||
sp.material.diffuse = 0.8; | ||
|
||
w.addObject(&sp); | ||
|
||
/* Set the camera */ | ||
Camera camera = Camera(400, 400, 0.5); | ||
camera.setTransform(viewTransform(Point(1, 2, -5), | ||
Point(0, 0, 0), | ||
Vector(0, 1, 0))); | ||
|
||
/* Now render it */ | ||
Canvas image = camera.render(w); | ||
|
||
image.SaveAsPNG("uvmap_aligncheckplane.png"); | ||
|
||
return 0; | ||
} |