-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
submission hw3 #11
base: master
Are you sure you want to change the base?
submission hw3 #11
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,8 +43,12 @@ class CPrimPlane : public IPrim | |
|
||
virtual CBoundingBox getBoundingBox(void) const override | ||
{ | ||
CBoundingBox bounds; | ||
CBoundingBox bounds = CBoundingBox(m_origin,m_origin); | ||
// --- PUT YOUR CODE HERE --- | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The case when the plane is orthogonal to one of the axises? |
||
bounds.m_minPoint = std::numeric_limits<Vec3f>::infinity() * (-1); | ||
bounds.m_maxPoint = std::numeric_limits<Vec3f>::infinity(); | ||
|
||
return bounds; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,9 @@ class CPrimSphere : public IPrim | |
{ | ||
CBoundingBox res; | ||
// --- PUT YOUR CODE HERE --- | ||
res.extend(m_origin + Vec3f(m_radius, m_radius, m_radius)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to add the -radius as well |
||
res.m_minPoint = std::numeric_limits<Vec3f>::infinity(); | ||
res.m_maxPoint = std::numeric_limits<Vec3f>::infinity() * (-1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add these two lines ? |
||
return res; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,8 +68,16 @@ class CPrimTriangle : public IPrim | |
|
||
virtual CBoundingBox getBoundingBox(void) const override | ||
{ | ||
|
||
|
||
|
||
CBoundingBox res; | ||
// --- PUT YOUR CODE HERE --- | ||
res.extend(m_a); | ||
res.extend(m_b); | ||
res.extend(m_c); | ||
res.m_minPoint = std::numeric_limits<Vec3f>::infinity(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add these two lines ? |
||
res.m_maxPoint = std::numeric_limits<Vec3f>::infinity() * (-1); | ||
return res; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,10 @@ Mat RenderFrame(void) | |
{ | ||
// Camera resolution | ||
const Size resolution(800, 600); | ||
|
||
// Define a scene | ||
CScene scene; | ||
|
||
// Add camera to scene | ||
scene.add(std::make_shared<CCameraPerspective>(resolution, Vec3f(0, 3.5f, -13), Vec3f(0, 0, 1), Vec3f(0, 1, 0), 60)); | ||
|
||
|
@@ -39,25 +39,27 @@ Mat RenderFrame(void) | |
|
||
// Build BSPTree | ||
scene.buildAccelStructure(20, 3); | ||
|
||
Vec3f pointLightIntensity(3, 3, 3); | ||
Vec3f lightPosition2(-3, 5, 4); | ||
Vec3f lightPosition3(0, 1, 4); | ||
|
||
scene.add(std::make_shared<CLightOmni>(pointLightIntensity, lightPosition2)); | ||
scene.add(std::make_shared<CLightOmni>(pointLightIntensity, lightPosition3)); | ||
|
||
Mat img(resolution, CV_32FC3); // image array | ||
Ray ray; // primary ray | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ray should lie inside the parallel part of the code |
||
|
||
for (int y = 0; y < img.rows; y++) | ||
for (int x = 0; x < img.cols; x++) { | ||
scene.getActiveCamera()->InitRay(ray, x, y); // initialize ray | ||
img.at<Vec3f>(y, x) = scene.RayTrace(ray); | ||
} | ||
|
||
parallel_for_(cv::Range(0, img.rows), [&](const Range& r) { | ||
for (int y = r.start; y < r.end; y++) | ||
for (int x = 0; x < img.cols; x++) { | ||
scene.getActiveCamera()->InitRay(ray, x, y); // initialize ray | ||
img.at<Vec3f>(y, x) = scene.RayTrace(ray); | ||
} | ||
}); | ||
img.convertTo(img, CV_8UC3, 255); | ||
return img; | ||
|
||
} | ||
|
||
int main(int argc, char* argv[]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you delete this line ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because I was using one of the private variables in another class and it was not accessible. I know I could have used static casting or get method, but this was giving me an error at submission