Beispiel #1
0
void Floor::draw(glm::mat4 VP) {
    Matrices.model = glm::mat4(1.0f);
    glm::mat4 translate = glm::translate (this->position);    // glTranslatef
    glm::mat4 rotate    = glm::rotate((float) (this->rotation * M_PI / 180.0f), glm::vec3(0, 0, 1));
    rotate          = rotate * glm::translate(glm::vec3(0, 0, 0));
    Matrices.model *= (translate * rotate);
    glm::mat4 MVP = VP * Matrices.model;
    glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
    draw3DObject(this->object1);
    draw3DObject(this->object2);
}
Beispiel #2
0
void Monster::draw(glm::mat4 VP,Ball boat) {
    Matrices.model = glm::mat4(1.0f);
    glm::mat4 translate = glm::translate (this->position);    // glTranslatef
    float x1=position.x-boat.position.x;
    float y1=position.y-boat.position.y;
    this->rotation=atan2(y1,x1) - M_PI/2;
    glm::mat4 rotate    = glm::rotate((float) (this->rotation), glm::vec3(0, 0, 1));
    // No need as coords centered at 0, 0, 0 of cube arouund which we waant to rotate
    // rotate          = rotate * glm::translate(glm::vec3(0, -0.6, 0));
    Matrices.model *= (translate * rotate);
    glm::mat4 MVP = VP * Matrices.model;
    glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
    draw3DObject(this->object);
    draw3DObject(this->object2);
//    draw3DObject(this->object3);
}
Beispiel #3
0
	void drawTriangle (glm::mat4 VP)
	{
		glm::mat4 MVP;
		Matrices.model = glm::mat4(1.0f);
		MVP = VP * Matrices.model; // MVP = p * V * M
		glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
		draw3DObject(triangle);
	}
Beispiel #4
0
 void drawCube(glm::mat4 VP, GLfloat x = 0.0f, GLfloat y = 0.0f, GLfloat z = 0.0f) {
   glm::mat4 MVP;
   Matrices.model = glm::mat4(1.0f);
   glm::mat4 translateCube = glm::translate(glm::vec3(x, y, z));
   Matrices.model *= (translateCube);
   MVP = VP * Matrices.model;
   glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
   draw3DObject(cube);
 }
Beispiel #5
0
	void drawCuboid(glm::mat4 VP)
	{
		glm::mat4 MVP2;
		 
		Matrices.model = glm::mat4(1.0f);
      	GLfloat ang = 0;
      	//printf("%f\n", ang);
      	glm::mat4 translateCuboid = glm::translate (glm::vec3(centre_x, centre_y, centre_z)); // glTranslatef
      	//std::cout<<centre_x<<" "<<centre_y<<" "<<centre_z<<"\n";
      	//glm::mat4 rotateTriangle = glm::rotate(ang, glm::vec3(0,0,1));  // rotate about vector (0,0,1) Rotating about z-axis
      	//glm::mat4 translateTriangle2 = glm::translate (glm::vec3(centre_x, centre_y, centre_z)); // glTranslatef

      	Matrices.model *= (translateCuboid);
      	MVP2 = VP * Matrices.model; // MVP = p * V * M
      	glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP2[0][0]);
		draw3DObject(cuboid);
	}
	void drawRectangle (glm::mat4 VP)
	{
		//GLfloat rect_centre_x = (x1+x3)/2, rect_centre_y = (y1+y3)/2;
		GLfloat rect_centre_x = centre_x, rect_centre_y = centre_y;

		glm::mat4 MVP;
		Matrices.model = glm::mat4(1.0f);

		//glm::mat4 translateRectangle = glm::translate (glm::vec3(-rect_centre_x, -rect_centre_y, 0));        // glTranslatef, Translates and brings to origin
		//glm::mat4 rotateRectangle = glm::rotate(deg2rad(angle), glm::vec3(0, 0, 1));  // rotate about vector (0,0,1) Rotating about z-axis
		//glm::mat4 translateRectangle2 = glm::translate (glm::vec3(rect_centre_x, rect_centre_y, 0));        // glTranslatef, Translates and takes back to its original position
		
		//Matrices.model*= (translateRectangle2*rotateRectangle*translateRectangle);			// Right to left , i.e. operation appearing on the right is executed first

		MVP = VP * Matrices.model; // MVP = p * V * M
		glUniformMatrix4fv(Matrices.MatrixID, 1, GL_FALSE, &MVP[0][0]);
		draw3DObject(rectangle);
	}
Beispiel #7
0
/* Edit this function according to your assignment */
void draw ()
{

  Matrices.projection = glm::ortho(zoom*(-10.0f + pan),  zoom*(10.0f + pan), zoom*(-10.0f), zoom*(10.0f), 0.1f, 500.0f);
  // clear the color and depth in the frame buffer
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
  // use the loaded shader program
  // Don't change unless you know what you are doing
  glUseProgram (programID);

  // Eye - Location of camera. Don't change unless you are sure!!
  glm::vec3 eye ( 5*cos(camera_rotation_angle*M_PI/180.0f), 0, 5*sin(camera_rotation_angle*M_PI/180.0f) );
  // Target - Where is the camera looking at.  Don't change unless you are sure!!
  glm::vec3 target (0, 0, 0);
  // Up - Up vector defines tilt of camera.  Don't change unless you are sure!!
  glm::vec3 up (0, 1, 0);

  
  for(int i=0;i<BALL_CIRCLES;i++){
    ball_circles[i]->renderCircle();
    draw3DObject(ball_circles[i]->circle);
   

  }
  for(int i=chance_no;i<BALL_CIRCLES;i++){
     ball_fill_circles[i]->renderCircle();
    draw3DObject(ball_fill_circles[i]->circle);
  }

   back_floor->renderQuad();
   draw3DObject(back_floor->rectangle);
   obstacles[5]->renderQuad();
    draw3DObject(obstacles[5]->rectangle);
   for(int i=0;i<BACK_LINES;i++){
    back_lines[i]->renderQuad();
    draw3DObject(back_lines[i]->rectangle);
   }

   for(int i=0;i<PAINT;i++){
    paint[i]->renderLine();
    draw3DObject(paint[i]->line);
   }

   for(int i=0;i<CIRCLE;i++){
    back_circles[i]->renderCircle();
    draw3DObject(back_circles[i]->circle);
  }



   for(int i=0;i<STATIC_OBSTACLES - 1;i++){
    obstacles[i]->renderQuad();
    draw3DObject(obstacles[i]->rectangle);
  }
  
  hinge->renderCircle();
  draw3DObject(hinge->circle);
/*for(int j=0;j<BORDERS;j++){
  for(int i=0;i<4;i++){
    borders[j][i]->renderCircle();
    draw3DObject(borders[j][i]->circle);
  }
}*/

  canon->renderQuad();
  draw3DObject(canon->rectangle);
  base->renderQuad();
  draw3DObject(base->rectangle);

  button_base->renderQuad();
  draw3DObject(button_base->rectangle);


  button->renderQuad();
  draw3DObject(button->rectangle);

  tar->renderQuad();
  draw3DObject(tar->rectangle);

  for(int i=0;i<LINES;i++){
    lines[i]->renderLine();
    draw3DObject(lines[i]->line);
  }

  for(int i=0;i<=speed_level;i++){
        
      bar[i]->renderQuad();
      draw3DObject(bar[i]->rectangle);
  }

  jumper->renderCircle();
  draw3DObject(jumper->circle);

  if(motion_phase_projectile || can_roll){
    projectile->renderCircle();
    draw3DObject(projectile->circle);
  }
}
Beispiel #8
0
	void drawLine ()
	{
		    draw3DObject(line);
	}