Skip to content

Commit

Permalink
Fix render clothsim in Ubuntu 20 and change camera view.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblanm committed Jun 11, 2021
1 parent 02a2898 commit e810634
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions render/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ void Camera::move_forward(const double dist) {
}

void Camera::rotate_by(const double dPhi, const double dTheta) {
phi = clamp(phi + dPhi, 0.0, (double)PI);
theta += dTheta;
this->phi = clamp(phi + dPhi, 0.0, (double)PI);
this->theta += dTheta;
compute_position();
}

Expand All @@ -96,8 +96,9 @@ void Camera::compute_position() {
phi += EPS_F;
sinPhi = sin(phi);
}
const Vector3D dirToCamera(r * sinPhi * sin(theta), r * cos(phi),
r * sinPhi * cos(theta));
//const Vector3D dirToCamera(r * sinPhi * sin(theta), r * cos(phi),
// r * sinPhi * cos(theta));
const Vector3D dirToCamera(r* sinPhi* sin(theta), r* cos(phi) , r * sinPhi);
pos = targetPos + dirToCamera;
Vector3D upVec(0, sinPhi > 0 ? 1 : -1, 0);
Vector3D screenXDir = cross(upVec, dirToCamera);
Expand Down
4 changes: 2 additions & 2 deletions render/src/clothSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void ClothSimulator::loadCollisionObjects(vector<CollisionObject *> *objects) {
void ClothSimulator::init() {
// Initialize GUI
initGUI(screen);
screen->setSize(default_window_size);
// screen->setSize(default_window_size);

// Initialize camera

Expand Down Expand Up @@ -101,7 +101,7 @@ void ClothSimulator::init() {
canonicalCamera.configure(camera_info, screen_w, screen_h);

// added by @ryanhoque: rotate camera so you can see the fold better. adjust as necessary
camera.rotate_by(1, 0.0); // Ryan used (2, 0.0)
camera.rotate_by(2, 0.0); // Ryan used (2, 0.0)
camera.move_forward(-0.5); // Ryan used -0.5
}

Expand Down
4 changes: 2 additions & 2 deletions render/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void createGLContexts() {
glfwWindowHint(GLFW_RESIZABLE, GL_TRUE);

// Create a GLFWwindow object
window = glfwCreateWindow(800, 800, "Cloth Simulator", nullptr, nullptr);
window = glfwCreateWindow(1024, 800, "Cloth Simulator", nullptr, nullptr);
if (window == nullptr) {
std::cout << "Failed to create GLFW window" << std::endl;
glfwTerminate();
Expand Down Expand Up @@ -391,7 +391,7 @@ int main(int argc, char **argv) {
subscriber.connect("tcp://localhost:" + to_string(port));
subscriber.setsockopt(ZMQ_SUBSCRIBE, "", 0);

glfwSetErrorCallback(error_callback);
// glfwSetErrorCallback(error_callback);

createGLContexts();

Expand Down

0 comments on commit e810634

Please sign in to comment.