Skip to content

Commit 54fcf8d

Browse files
author
BuildTools
committed
Added method renderGeometryFrame
1 parent bd8f71c commit 54fcf8d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

SphWaterfall/SphWaterfall/src/visualization/Camera.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Pixel Camera::castDebugRay(Ray ray, std::vector<DebugObject> particles) {
5353
DebugObject *hit = &hitObject;
5454
hit = nullptr;
5555

56+
//Calculate hit for every object
5657
for (int i = 0; i < particles.size(); i++) {
5758
DebugObject &obj = particles.at(i);
5859
double currDist = bestDistance;
@@ -119,6 +120,7 @@ Frame Camera::renderFrame(std::vector<ParticleObject> particles, int frameID) {
119120
Vector3 vec_u = findSkalarVectorWithYZero(this->direction).normalize();
120121
Vector3 vec_v = findUpVector(this->direction, vec_u).normalize();
121122

123+
//Cast ray for every pixel
122124
for (int x = 0; x < this->width; x++) {
123125
for (int y = 0; y < this->height; y++) {
124126
double u = l + (r - l) * (x + 0.5f) / this->width;
@@ -127,14 +129,23 @@ Frame Camera::renderFrame(std::vector<ParticleObject> particles, int frameID) {
127129
Vector3 vec_s = vec_u * u + vec_v * v + this->direction * d;
128130
Ray ray = Ray(vec_s, this->location);
129131

130-
132+
//Set pixel color in Frame
131133
frame.setPixel(x, y, castVolumeRay(ray, particles));
132134
}
133135
}
134136

135137
return frame;
136138
}
137139

140+
void Camera::renderGeometryFrame(Terrain t) {
141+
//TODO: implement rendering of the base Frame. See renderFrame(...) and castDebugRay(...)
142+
Frame frame;
143+
144+
145+
146+
this->baseFrame = frame;
147+
}
148+
138149
void Camera::outputDebugFrame(Frame f, const char* fileName) {
139150
writeFrameToBitmap(f, fileName, this->width, this->height);
140151
}

SphWaterfall/SphWaterfall/src/visualization/Camera.h

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "ParticleObject.h"
77
#include <vector>
88
#include <string>
9+
#include "../geometry/Terrain.h"
910

1011
class Camera {
1112
public:
@@ -14,6 +15,7 @@ class Camera {
1415
void debugRenderFrame(std::vector<DebugObject> particles, int frameID);
1516

1617
Frame renderFrame(std::vector<ParticleObject> particles, int frameID); //Vector is only a placeholder here as the data structure isnt decided yet
18+
void renderGeometryFrame(Terrain t);
1719

1820
void outputDebugFrame(Frame f, const char* fileName);
1921

@@ -25,6 +27,7 @@ class Camera {
2527
Pixel castDebugRay(Ray ray, std::vector<DebugObject> particles);
2628
Pixel castVolumeRay(Ray ray, std::vector<ParticleObject> particles);
2729

30+
Frame baseFrame;
2831
Vector3 location;
2932
Vector3 direction;
3033
unsigned int width;

0 commit comments

Comments
 (0)