-
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
5 changed files
with
77 additions
and
3 deletions.
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
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,28 @@ | ||
/* | ||
* DoRayMe - a quick and dirty Raytracer | ||
* UV Pattern header | ||
* | ||
* Created by Manoël Trapier | ||
* Copyright (c) 2020 986-Studio. | ||
* | ||
*/ | ||
#ifndef DORAYME_UV_PATTERN_H | ||
#define DORAYME_UV_PATTERN_H | ||
|
||
#include <colour.h> | ||
|
||
class UVPattern | ||
{ | ||
public: | ||
Colour a; | ||
Colour b; | ||
double width; | ||
double height; | ||
|
||
UVPattern(double width, double height, Colour a, Colour b) : a(a), b(b), | ||
width(width), height(height) {}; | ||
|
||
virtual Colour uvPatternAt(double u, double v) = 0; | ||
}; | ||
|
||
#endif /* DORAYME_UV_PATTERN_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* DoRayMe - a quick and dirty Raytracer | ||
* UV Checkers header | ||
* | ||
* Created by Manoël Trapier | ||
* Copyright (c) 2020 986-Studio. | ||
* | ||
*/ | ||
#ifndef DORAYME_UV_CHECKERS_H | ||
#define DORAYME_UV_CHECKERS_H | ||
|
||
#include <uv_pattern.h> | ||
#include <math.h> | ||
|
||
class UVCheckers : public UVPattern | ||
{ | ||
public: | ||
UVCheckers(double width, double height, Colour a, Colour b) : UVPattern(width, height, a, b) {}; | ||
|
||
Colour uvPatternAt(double u, double v) { | ||
double u2 = floor(u * this->width); | ||
double v2 = floor(v * this->width); | ||
|
||
if (fmod((u2 + v2), 2) == 0) | ||
{ | ||
return this->a; | ||
} | ||
return this->b; | ||
}; | ||
}; | ||
|
||
#endif /* DORAYME_UV_CHECKERS_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