-
Notifications
You must be signed in to change notification settings - Fork 10
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
Assignment #6 #3
base: main
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -5,8 +5,16 @@ | |
class CCameraTarget : public CCameraPerspective { | ||
public: | ||
// --- PUT YOUR CODE HERE --- | ||
//CCameraTarget(Size resolution, const Vec3f& pos, const Vec3f& target, const Vec3f& up, float angle) ... | ||
|
||
CCameraTarget(Size resolution, const Vec3f& pos, const Vec3f& target, const Vec3f& up, float angle) : CCameraPerspective(resolution, pos, normalize(target - pos), up, angle) | ||
{ | ||
m_target = target; | ||
} | ||
|
||
// virtual void setPosition(const Vec3f& pos) override { pos = m_target; } | ||
|
||
virtual void setTarget(const Vec3f& target) { m_target = target; } | ||
|
||
Vec3f getTarget(void) const { return m_target; } | ||
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 also need to override method setPosition() because it affects direction of the target camera |
||
private: | ||
Vec3f m_target; ///< Camera target point in WCS | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,11 +48,8 @@ Mat RenderFrame(void) | |
scene.add(cam1); | ||
scene.add(cam2); | ||
|
||
#ifdef WIN32 | ||
const std::string dataPath = "../data/"; | ||
#else | ||
const std::string dataPath = "../../../data/"; | ||
#endif | ||
|
||
|
||
// Textures | ||
Mat imgEarth = imread(dataPath + "earth_8k.jpg"); | ||
|
@@ -99,8 +96,10 @@ Mat RenderFrame(void) | |
|
||
// --- PUT YOUR CODE HERE --- | ||
// derive the transormation matrices here | ||
Mat earthTransform = Mat::eye(4, 4, CV_32FC1); | ||
Mat moonTransform = Mat::eye(4, 4, CV_32FC1); | ||
|
||
CTransform T; | ||
Mat earthTransform = transform.rotate(Vec3f(0.399f, 0.917, 0), 360.0f / nFrames).get(); | ||
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. From where did you take these numbers? What does they mean? |
||
Mat moonTransform = transform.rotate(Vec3f(0, 1, 0), 13.2f / nFrames).get(); | ||
|
||
for (size_t frame = 0; frame < nFrames; frame++) { | ||
// Build BSPTree | ||
|
@@ -127,8 +126,10 @@ Mat RenderFrame(void) | |
|
||
// --- PUT YOUR CODE HERE --- | ||
// Apply transforms here | ||
Mat rotationAroundTheSun = Mat::eye(4, 4, CV_32FC1); | ||
Vec3f earthPivot = earth.getPivot(); | ||
Mat rotationAroundTheSun = transform.translate(earthPivot).rotate(Vec3f(0, 1, 0), 1.0f / nFrames).translate(-earthPivot).get(); | ||
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. What does 1.0f / nFrames mean? How did you achieve this formula? |
||
earth.transform(rotationAroundTheSun * earthTransform); | ||
moon.setPivot(earth.getPivot()); | ||
moon.transform(rotationAroundTheSun * moonTransform); | ||
|
||
// --- PUT YOUR CODE HERE --- | ||
|
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.
You need to update direction also here