Beispiel #1
0
float   inter_plan(t_sphere *sphere, t_expose *expose)
{
  float	result;

  sphere->z1 -= Z_PLAN;
  sphere->x1 -= X_1;
  sphere->y1 -= Y_1;
  rotation_x(sphere, PLAN_ROTX);
  rotation_y(sphere, PLAN_ROTY);
  rotation_z(sphere, PLAN_ROTZ);
  if (sphere->z1 == 0)
    return (0);
  sphere->k = - (sphere->zo / sphere->z1);
  rotation_x(sphere, -(PLAN_ROTX));
  rotation_y(sphere, -(PLAN_ROTY));
  rotation_z(sphere, -(PLAN_ROTZ));
  sphere->z1 += Z_PLAN;
  sphere->x1 += X_1;
  sphere->y1 += Y_1;
  result = create_paralel(expose);
  if (sphere->k < 0)
    return (sphere->k1);
  //  else if (result != -1)
  // return (sphere->k);
  else
    return (0);
}
Beispiel #2
0
float   create_cone(t_sphere *sphere)
{
  float	k;

  sphere->x1 -= X_CONE;
  sphere->y1 -= Y_CONE;
  sphere->z1 -= Z_CONE;
  rotation_x(sphere, CONE_ROTX);
  rotation_y(sphere, CONE_ROTY);
  rotation_z(sphere, CONE_ROTZ);
  sphere->a = powf(sphere->x1, 2) + powf(sphere->y1, 2)
    - (powf(sphere->z1, 2) / powf(tanf(RAD * ANGLE_CONE), 2));
  sphere->b = 2 * ((sphere->xo * sphere->x1) + (sphere->yo * sphere->y1)
		   - (powf(sphere->zo, 2) / powf(tanf(RAD * ANGLE_CONE), 2)));
  sphere->c = powf(sphere->xo, 2) + powf(sphere->yo, 2)
    - (powf(sphere->zo, 2) / powf(tanf(RAD * ANGLE_CONE), 2));
  rotation_x(sphere, -(CONE_ROTX));
  rotation_y(sphere, -(CONE_ROTY));
  rotation_z(sphere, -(CONE_ROTZ));
  sphere->x1 += X_CONE;
  sphere->y1 += Y_CONE;
  sphere->z1 += Z_CONE;
  sphere->delta = powf(sphere->b, 2) - (4 * sphere->a * sphere->c);
  k = create_cone_follow(sphere);
  return (k);
}
Beispiel #3
0
float   create_sphere(t_sphere *sphere)
{
  float k;

  sphere->x1 -= X_SPHERE;
  sphere->y1 -= Y_SPHERE;
  sphere->z1 -= Z_SPHERE;
  rotation_x(sphere, SPHERE_ROTX);
  rotation_y(sphere, SPHERE_ROTY);
  rotation_z(sphere, SPHERE_ROTZ);
  sphere->a = powf(sphere->x1, 2) + powf(sphere->y1, 2) + powf(sphere->z1, 2);
  sphere->b = 2 * ((sphere->xo * sphere->x1)
		   + (sphere->yo * sphere->y1) + (sphere->zo * sphere->z1));
  sphere->c = powf(sphere->xo, 2) + powf(sphere->yo, 2)
    + powf(sphere->zo, 2) - powf(R_SPHERE, 2);
  rotation_x(sphere, -(PLAN_ROTX));
  rotation_y(sphere, -(PLAN_ROTY));
  rotation_z(sphere, -(PLAN_ROTZ));
  sphere->x1 += X_SPHERE;
  sphere->y1 += Y_SPHERE;
  sphere->z1 += Z_SPHERE;
  sphere->delta = powf(sphere->b, 2) - (4 * sphere->a * sphere->c);
  k = create_sphere_follow(sphere);
  return (k);
}
Beispiel #4
0
void CShape::Do(void)
{
	m_bRun = true;
	m_bThread = true;

	for (int i = 0; ; i++)//i < 360*3
	{
		rotation_y(i);
		rotation_x(i);

		show_xy_face();

		::Sleep(30);

		if (!m_bRun)
		{
			break;
		}
		
		clear();

		SetData();
	}

	m_bRun = false;
	m_bThread = false;
}
Beispiel #5
0
void		cam::look_right(double a)
{
  _r.z -= a;
  _v = _vi;
  rotation_x(_r.x, _v);
  rotation_y(_r.y, _v);
  rotation_z(_r.z, _v);
}
Beispiel #6
0
void EditorCamera::Draw()
{
	Mat4 to_look_at = rotation_y(DegToRad(m_yaw)) * rotation_x(DegToRad(m_pitch));
	Vec3 vec = m_zoom * get_column(to_look_at, 2);               
	m_camera.SetPosition(m_target+vec);
	m_camera.SetLookDir(-vec);
	m_camera.Draw();
}
Beispiel #7
0
void		cam::look_left(double a)
{
  _r.z += a;
  _v = _vi;
  rotation_x(_r.x, _v);
  rotation_y(_r.y, _v);
  rotation_z(_r.z, _v);
}
Beispiel #8
0
void update_status_turtleroll(void)
   {
   if (current_mode == perspectivemode)
      sprintf(YABuffer, "%1.2f", rotation_y());
   else
      sprintf(YABuffer, "%1.2f", 0.0);
   MainWindowx->StatusWindow->
      SendDlgItemMsg(ID_TURTLEROLL, WM_SETTEXT, 0, (DWORD) YABuffer);
   }
Beispiel #9
0
void		cam::look_down(double a)
{
  _r.x -= a;
  if (_r.x <= -PI / 2)
    _r.x = -PI / 2 + 0.001;
  _v = _vi;
  rotation_x(_r.x, _v);
  rotation_y(_r.y, _v);
  rotation_z(_r.z, _v);
}
Beispiel #10
0
void		cam::look_up(double a)
{
  _r.x += a;
  if (_r.x >= PI / 2)
    _r.x = PI / 2 - 0.001;
  _v = _vi;
  rotation_x(_r.x, _v);
  rotation_y(_r.y, _v);
  rotation_z(_r.z, _v);
}
Beispiel #11
0
void		cam::right(double k)
{
  sf::Vector3f	t;

  t = _vi;
  rotation_z(-PI / 2, t);
  rotation_x(_r.x, t);
  rotation_y(_r.y, t);
  rotation_z(_r.z, t);

  _c.x += t.x * k;
  _c.y += t.y * k;
  _c.z += t.z * k;
}
Beispiel #12
0
void	rotate_caster(t_caster *caster, t_object *object)
{
  double	*z_rotate;
  double	*x_rotate;
  double	*y_rotate;

  x_rotate = rotation_x(object->rotation.x);
  y_rotate = rotation_y(object->rotation.y);
  z_rotate = rotation_z(object->rotation.z);
  rotate_coordinate(&caster->temp_vec, z_rotate);
  rotate_coordinate(&caster->temp_vec, y_rotate);
  rotate_coordinate(&caster->temp_vec, x_rotate);
  free(z_rotate);
  free(y_rotate);
  free(x_rotate);
}
Beispiel #13
0
void redraw()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // clear color, and reset the z-buffer
	glEnable(GL_DEPTH_TEST);                             // enable z-buffer test

	mat4x4 P = perspective(-1,1,-1,1,-1,-10);
	mat4x4 M = translation(0,0,-3)*rotation_z(angle)*rotation_y(2*angle);

	// Bind our vertices, texture, and GLSL program
	glBindBuffer(GL_ARRAY_BUFFER,mesh_vbo);
	glBindTexture(GL_TEXTURE_2D,texid);
	glUseProgram(program);

	// Initialize the GLSL uniform variables
	glUniformMatrix4fv(glGetUniformLocation(program,"P"),1,GL_TRUE,P.ptr());
	glUniformMatrix4fv(glGetUniformLocation(program,"M"),1,GL_TRUE,M.ptr());
	// Since our fragment shader also has a uniform (a 'sampler2D' texture index name 'texmap'),
	// we should tell our fragment shader that 'texmap' was bound to "texture unit 0" (the default)
	glUniform1i(glGetUniformLocation(program,"texmap"),0);

	int ploc = glGetAttribLocation(program,"p");  // index of position attribute in GLSL program
	int cloc = glGetAttribLocation(program,"c");  // index of colour attribute
	int tloc = glGetAttribLocation(program,"t");  // index of texcoord attribute

	// Each vertex contains a position, colour, and texcoord, so we must
	// tell OpenGL exactly how the memory of our vertex buffer is layed out.
	// sizeof(vertex) = 16 + 16 + 8 = 40 bytes
	//   position: "4 floats, 40 bytes apart, with offset 0 bytes"
	//   colour:   "4 floats, 40 bytes apart, with offset 16 bytes"
	//   colour:   "2 floats, 40 bytes apart, with offset 32 bytes"
	glVertexAttribPointer(ploc,4,GL_FLOAT,GL_FALSE,sizeof(vertex),OFFSET(vertex,p));
	glVertexAttribPointer(cloc,4,GL_FLOAT,GL_FALSE,sizeof(vertex),OFFSET(vertex,c));
	glVertexAttribPointer(tloc,2,GL_FLOAT,GL_FALSE,sizeof(vertex),OFFSET(vertex,t));
	glEnableVertexAttribArray(ploc); // don't forget to enable each one!
	glEnableVertexAttribArray(cloc);
	glEnableVertexAttribArray(tloc);

	// RASTERIZE!
	glDrawArrays(GL_TRIANGLE_STRIP,0,4);	
	
	// OPTIONAL
	glUseProgram(0);
	glBindBuffer(GL_ARRAY_BUFFER,0);

	glFlush();
}
Beispiel #14
0
cam::cam()
{
  _c.x = 0;
  _c.y = 0;
  _c.z = 0;

  _r.x = -0.74;
  _r.y = 0;
  _r.z = 2.40159;

  _vi.x = 0;
  _vi.y = 1;
  _vi.z = 0;

  _v = _vi;

  rotation_x(_r.x, _v);
  rotation_y(_r.y, _v);
  rotation_z(_r.z, _v);
}