Skip to content

Commit

Permalink
fixed swimming
Browse files Browse the repository at this point in the history
  • Loading branch information
ikrysinska committed Sep 7, 2016
1 parent 680d759 commit c6999cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions szkielet1/Fish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Fish::Fish (std::string path, float radius) {
setPath(path);
this->radius = radius;
}

Fish::Fish() {
Expand Down
22 changes: 12 additions & 10 deletions szkielet1/main_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,13 @@ int main()
// Fish swimming
static double prev_time = glfwGetTime();
double act_time = glfwGetTime();
double elapsed_time = actual_time - prev_time;
double elapsed_time = act_time - prev_time;

if (elapsed_time > 0.01)
{
prev_time = act_time;
angle += 1;
std::cout << fish01.radius *cos(angle * PI / 180.0) << std::endl;

x_trans = fish01.radius * cos(angle * PI / 180.0);
y_trans = fish01.radius * sin(angle * PI / 180.0);
Expand All @@ -410,8 +411,7 @@ int main()
}
int phi = angle % 360;
float phis = -phi * PI / 180.0;

fish02.translate_matrix = glm::translate(glm::mat4(1.0), glm::vec3(fish02.radius * cos(angle*PI/180.0), 0.0, fish02.radius * sin(angle*PI / 180.0)));
fish02.translate_matrix = glm::translate(glm::mat4(1.0), glm::vec3(x_trans, 0.0, y_trans));
fish02.rotate_matrix = glm::rotate(fish02.translate_matrix, phis, glm::vec3(0, 1, 0));
// PIERWSZA RYBKA:
// UP AND DOWN
Expand All @@ -429,13 +429,8 @@ int main()
//h = sin(count);
count++;


//Draw aquarium
aquariumGlass.sendMatrix(view_matrix, perspective);
aquariumGlass.drawModel();

aquariumBase.sendMatrix(view_matrix, perspective);
aquariumBase.drawModel();



//Draw Fish
fish01.sendMatrix(view_matrix,perspective);
Expand All @@ -444,6 +439,13 @@ int main()
fish02.sendMatrix(view_matrix, perspective);
fish02.drawModel();

//Draw aquarium
aquariumBase.sendMatrix(view_matrix, perspective);
aquariumBase.drawModel();
aquariumGlass.sendMatrix(view_matrix, perspective);
aquariumGlass.drawModel();


processWindowEvents();
}

Expand Down

0 comments on commit c6999cc

Please sign in to comment.