Ejemplo n.º 1
0
int main() {
	spaceship* s = malloc(sizeof(spaceship));
	s->speed = 1;
	set_identity( &(s->heading) );
	
	int i = 0;
	for(; i < 10; i++) {
		print_spaceship( s );

		float yaw = 0.0;
		float pitch = 0.0;
		float roll = 0.2;

		rotation3 d_heading = get_rotation( yaw, pitch, roll );
		update_spaceship( s, d_heading );
		printf("\n");
		//gameloop( s, (circle3*)s );
	}

	vector2 v;
	v.x = 1;
	v.y = 10;
	vector2* w = clip_to_screen( &v, 6, 4 );
	printf( "%f \t%f\n", w->x, w->y );

	return;
};
Ejemplo n.º 2
0
/* draw the extrusion once */
ENTRYPOINT void
draw_extrusion(ModeInfo * mi)
{
  extrusionstruct *gp = &Extrusion[MI_SCREEN(mi)];
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);

  static const GLfloat color[4] = {0.6, 0.6, 0.4, 1.0};
  /* static const GLfloat spec[4]  = {0.6, 0.6, 0.6, 1.0}; */
  /* static const GLfloat shiny    = 40.0; */

  double x, y, z;

  if (!gp->glx_context)
	return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(gp->glx_context));

  glPushMatrix();

  gltrackball_rotate (gp->trackball);

  get_rotation (gp->rot, &x, &y, &z,
                !(gp->button_down_p || gp->button2_down_p));
  glRotatef (x * 360, 1.0, 0.0, 0.0);
  glRotatef (y * 360, 0.0, 1.0, 0.0);
  glRotatef (z * 360, 0.0, 0.0, 1.0);

  /* track the mouse only if a button is down. */
  if (gp->button2_down_p)
    {
      gp->mouse_dx += gp->mouse_x - gp->mouse_start_x;
      gp->mouse_dy += gp->mouse_y - gp->mouse_start_y;
      gp->mouse_start_x = gp->mouse_x;
      gp->mouse_start_y = gp->mouse_y;
    }

  {
    float scale = (max_lastx - min_lastx);
    get_position (gp->rot, &x, &y, &z,
                  !(gp->button_down_p || gp->button2_down_p));
    lastx = x * scale + min_lastx + gp->mouse_dx;
    lasty = y * scale + min_lasty + gp->mouse_dy;
  }

  glScalef(0.5, 0.5, 0.5);

  /* glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR,            spec); */
  /* glMateriali  (GL_FRONT_AND_BACK, GL_SHININESS,           shiny); */

  glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, color);
  glFrontFace(GL_CCW);

  funcs_ptr[gp->extrusion_number].DrawStuff();
	  
  glPopMatrix();

  if (mi->fps_p) do_fps (mi);
  glXSwapBuffers(display, window);
}
Ejemplo n.º 3
0
static Bool draw_main(commander_conf *cp) 
{
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  glTranslatef(0, 0, zpos);

  /* FIXME this is probably a good place to switch ships if
   * appropriate */
	{
		time_t now = time((time_t *) 0);
		if(cp->last_change_time == 0) { cp->last_change_time=now; }
		if(!cp->button_down_p && (now - cp->last_change_time >= duration)) {
			/* printf("change\n"); */
			cp->last_change_time = now;
		}
	}

  gltrackball_rotate (cp->trackball);
  get_rotation (cp->rot, &x, &y, &z, !cp->button_down_p);
  glRotatef (x * 360, 1.0, 0.0, 0.0);
  glRotatef (y * 360, 0.0, 1.0, 0.0);
  glRotatef (z * 360, 0.0, 0.0, 1.0);

  glCallList(cp->list);
  return True;
}
Ejemplo n.º 4
0
ENTRYPOINT void
draw_ball (ModeInfo *mi)
{
  ball_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glShadeModel(GL_SMOOTH);

  glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  glEnable(GL_CULL_FACE);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();

  glRotatef(current_device_rotation(), 0, 0, 1);

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 6,
                 (y - 0.5) * 6,
                 (z - 0.5) * 2);

    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  mi->polygon_count = 0;

  glRotatef (50, 1, 0, 0);

  glScalef (4, 4, 4);
  glRotatef (bp->th, 0, 0, 1);
  if (! bp->button_down_p)
    {
      bp->th += (bp->th > 0 ? speed : -speed);
      while (bp->th >  360) bp->th -= 360;
      while (bp->th < -360) bp->th += 360;
    }

  mi->polygon_count += draw_ball_1 (mi);
  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 5
0
ENTRYPOINT void
draw_moebius (ModeInfo * mi)
{
	moebiusstruct *mp;

	Display    *display = MI_DISPLAY(mi);
	Window      window = MI_WINDOW(mi);

        if (moebius == NULL)
	    return;
	mp = &moebius[MI_SCREEN(mi)];

	MI_IS_DRAWN(mi) = True;

	if (!mp->glx_context)
		return;

	glXMakeCurrent(display, window, *(mp->glx_context));

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();

	glTranslatef(0.0, 0.0, -10.0);

    /* Do it twice because we don't track the device's orientation. */
    glRotatef( current_device_rotation(), 0, 0, 1);
    gltrackball_rotate (mp->trackball);
    glRotatef(-current_device_rotation(), 0, 0, 1);

	if (!MI_IS_ICONIC(mi)) {
		glScalef(Scale4Window * mp->WindH / mp->WindW, Scale4Window, Scale4Window);
	} else {
		glScalef(Scale4Iconic * mp->WindH / mp->WindW, Scale4Iconic, Scale4Iconic);
	}

    {
      double x, y, z;
      get_rotation (mp->rot, &x, &y, &z, !mp->button_down_p);
      glRotatef (x * 360, 1.0, 0.0, 0.0);
      glRotatef (y * 360, 0.0, 1.0, 0.0);
      glRotatef (z * 360, 0.0, 0.0, 1.0);
    }

	/* moebius */
	if (!draw_moebius_strip(mi)) {
		release_moebius(mi);
		return;
	}

	glPopMatrix();

    if (MI_IS_FPS(mi)) do_fps (mi);
	glFlush();

	glXSwapBuffers(display, window);

	mp->step += 0.025;
}
Ejemplo n.º 6
0
Dictionary Node2D::_edit_get_state() const {

	Dictionary state;
	state["position"] = get_position();
	state["rotation"] = get_rotation();
	state["scale"] = get_scale();

	return state;
}
Ejemplo n.º 7
0
			inline void rebuild()
			{
				glm::mat4 matrix;

				matrix = glm::translate(get_translation());
				matrix *= glm::mat4(glm::mat3_cast(
					get_rotation()));
				matrix = glm::scale(matrix, get_scale());

				m_matrix = glm::mat4x3(matrix);
			}
Ejemplo n.º 8
0
ENTRYPOINT void
draw_hexstrut (ModeInfo *mi)
{
  hexstrut_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glShadeModel(GL_SMOOTH);

  glDisable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  glDisable(GL_CULL_FACE);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 6,
                 (y - 0.5) * 6,
                 (z - 0.5) * 12);

    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  mi->polygon_count = 0;

  glScalef (30, 30, 30);

  if (! bp->button_down_p)
    tick_triangles (mi);
  draw_triangles (mi);

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 9
0
transform()
{
  int i,k;
  Vertex *vert;
  float x,y,z;
  float xx,yy,zz;
  float angle;
  gtMatrix rmat;

  for (k = 0; k < num_trans; k++) {

    x = transforms[k].x;
    y = transforms[k].y;
    z = transforms[k].z;
    angle = transforms[k].angle;

    switch (transforms[k].type) {
      case TRANSLATE:
        for (i = 0; i < nverts; i++) {
          vert = vlist[i];
          vert->x += x;
          vert->y += y;
          vert->z += z;
        }
        break;
      case SCALE:
        for (i = 0; i < nverts; i++) {
          vert = vlist[i];
          vert->x *= x;
          vert->y *= y;
          vert->z *= z;
        }
        break;
      case ROTATE:
        get_rotation (angle, x, y, z, rmat);
        for (i = 0; i < nverts; i++) {
          vert = vlist[i];
          xx = vert->x;
          yy = vert->y;
          zz = vert->z;
          vert->x = xx * rmat[0][0] + yy * rmat[1][0] + zz * rmat[2][0];
          vert->y = xx * rmat[0][1] + yy * rmat[1][1] + zz * rmat[2][1];
          vert->z = xx * rmat[0][2] + yy * rmat[1][2] + zz * rmat[2][2];
        }
        break;
    }
  }
}
Ejemplo n.º 10
0
static void
draw_floater (ModeInfo *mi, floater *f)
{
  cube_configuration *bp = &bps[MI_SCREEN(mi)];
  GLfloat n;
  double x, y, z;

  get_position (f->rot, &x, &y, &z, !bp->button_down_p);

  glPushMatrix();
  glTranslatef (f->x, f->y, f->z);

  if (do_wander)
    glTranslatef (x, y, z);

  if (do_spin)
    get_rotation (f->rot, &x, &y, &z, !bp->button_down_p);

  if (do_spin || f->spinner_p)
    {
      glRotatef (x * 360, 1, 0, 0);
      glRotatef (y * 360, 0, 1, 0);
      glRotatef (z * 360, 0, 0, 1);
    }
  else
    {
      glRotatef (f->zr * 360, 0, 1, 0);
    }

  n = 1.5;
  if      (bp->nfloaters > 99) n *= 0.05;
  else if (bp->nfloaters > 25) n *= 0.18;
  else if (bp->nfloaters > 9)  n *= 0.3;
  else if (bp->nfloaters > 1)  n *= 0.7;

  n *= 2;

  if ((do_spin || do_wander) && bp->nfloaters > 1)
    n *= 0.7;

  glScalef(n, n, n);

  glCallList (bp->dlists[FULL_CUBE]);
  mi->polygon_count += bp->cube_polys;
/*  build_cube (mi);*/

  glPopMatrix();
}
Ejemplo n.º 11
0
static Bool 
draw_main(ModeInfo *mi, rubikblocks_conf *cp) 
{
  int i;
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();

  get_position(cp->rot, &x, &y, &z, !cp->button_down);
  glTranslatef((x-0.5)*6, (y-0.5)*6, -20);

  gltrackball_rotate(cp->trackball);

  get_rotation(cp->rot, &x, &y, &z, !cp->button_down);
  glRotatef(x*360, 1, 0, 0);
  glRotatef(y*360, 0, 1, 0);
  glRotatef(z*360, 0, 0, 1);
  glScalef(size, size, size);

# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
  {
    GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
    int o = (int) current_device_rotation();
    if (o != 0 && o != 180 && o != -180)
      glScalef (1/h, 1/h, 1/h);
  }
# endif

  if(cp->wire) glColor3f(0.7, 0.7, 0.7);
  if(!cp->pause)
    for(i = 0; i < 27; i++)
      if(cp->pieces[i].act)
        mult_quat(cp->qfram, cp->pieces[i].qr);
  for(i = 0; i < 27; i++) 
  {
    glPushMatrix();
    if(fabs(cp->pieces[i].qr[0]) < 1)
      glRotatef(360/M_PI*acos(cp->pieces[i].qr[0]),
          cp->pieces[i].qr[1], cp->pieces[i].qr[2], cp->pieces[i].qr[3]);
    glCallList(cp->list_base + i);
    glPopMatrix();
  }
  if((cp->t += tspeed) > cp->tmax) finish(cp);
  return True;
}
Ejemplo n.º 12
0
static Bool draw_main(cubicgrid_conf *cp) 
{
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT);
  glLoadIdentity();
  glTranslatef(0, 0, zpos);

  glScalef(size/ticks, size/ticks, size/ticks);
  gltrackball_rotate (cp->trackball);
  get_rotation (cp->rot, &x, &y, &z, !cp->button_down_p);
  glRotatef (x * 360, 1.0, 0.0, 0.0);
  glRotatef (y * 360, 0.0, 1.0, 0.0);
  glRotatef (z * 360, 0.0, 0.0, 1.0);

  glTranslatef(-ticks/2.0, -ticks/2.0, -ticks/2.0);
  glCallList(cp->list);

  return True;
}
Ejemplo n.º 13
0
void XFormNode::calc_matrix(long time)
{
    Vector3 tmp_pos;
    Quaternion tmp_rot;
    Vector3 tmp_scaling;

    long t = (time - anim_start_time) * get_anim_speed();

    tmp_pos = get_position(t);
    tmp_rot = get_rotation(t).normalized();
    tmp_scaling = get_scaling(t);

    xform_mat.reset_identity();
    xform_mat.translate(tmp_pos);
    xform_mat.rotate(tmp_rot);
    xform_mat.scale(Vector4(tmp_scaling));
	xform_mat = local_mat * xform_mat;

	if(parent){
        xform_mat = parent->xform_mat * xform_mat;
	}
}
Ejemplo n.º 14
0
static Bool 
draw_main(ModeInfo *mi, rubikblocks_conf *cp) 
{
  int i;
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();
  get_position(cp->rot, &x, &y, &z, !cp->button_down);
  glTranslatef((x-0.5)*6, (y-0.5)*6, -20);

  /* Do it twice because we don't track the device's orientation. */
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate(cp->trackball);
  glRotatef(-current_device_rotation(), 0, 0, 1);

  get_rotation(cp->rot, &x, &y, &z, !cp->button_down);
  glRotatef(x*360, 1, 0, 0);
  glRotatef(y*360, 0, 1, 0);
  glRotatef(z*360, 0, 0, 1);
  glScalef(size, size, size);

  if(cp->wire) glColor3f(0.7, 0.7, 0.7);
  if(!cp->pause)
    for(i = 0; i < 27; i++)
      if(cp->pieces[i].act)
        mult_quat(cp->qfram, cp->pieces[i].qr);
  for(i = 0; i < 27; i++) 
  {
    glPushMatrix();
    if(fabs(cp->pieces[i].qr[0]) < 1)
      glRotatef(360/M_PI*acos(cp->pieces[i].qr[0]),
          cp->pieces[i].qr[1], cp->pieces[i].qr[2], cp->pieces[i].qr[3]);
    glCallList(cp->list_base + i);
    glPopMatrix();
  }
  if((cp->t += tspeed) > cp->tmax) finish(cp);
  return True;
}
Ejemplo n.º 15
0
static Bool draw_main(ModeInfo *mi)
{
  cubicgrid_conf *cp = &cubicgrid[MI_SCREEN(mi)];
  double x, y, z;

  glClear(GL_COLOR_BUFFER_BIT);
  glLoadIdentity();

  glRotatef (180, 1, 0, 0);  /* Make trackball track the right way */
  glRotatef (180, 0, 1, 0);

  glTranslatef(0, 0, zpos);

  glScalef(size/ticks, size/ticks, size/ticks);


# ifdef HAVE_MOBILE	/* Keep it the same relative size when rotated. */
  {
    GLfloat h = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
    int o = (int) current_device_rotation();
    if (o != 0 && o != 180 && o != -180)
      glScalef (1/h, 1/h, 1);
  }
# endif

  gltrackball_rotate (cp->trackball);

  get_rotation (cp->rot, &x, &y, &z, !cp->button_down_p);
  glRotatef (-x * 360, 1.0, 0.0, 0.0);
  glRotatef (-y * 360, 0.0, 1.0, 0.0);
  glRotatef (-z * 360, 0.0, 0.0, 1.0);

  glTranslatef(-ticks/2.0, -ticks/2.0, -ticks/2.0);
  glCallList(cp->list);
  return True;
}
Ejemplo n.º 16
0
ENTRYPOINT void
draw_carousel (ModeInfo *mi)
{
  carousel_state *ss = &sss[MI_SCREEN(mi)];
  int i;

  if (!ss->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(ss->glx_context));

  if (ss->awaiting_first_images_p)
    if (!load_initial_images (mi))
      return;

  /* Only check the wall clock every 10 frames */
  {
    if (ss->now == 0 || ss->draw_tick++ > 10)
      {
        ss->now = time((time_t *) 0);
        if (ss->last_time == 0) ss->last_time = ss->now;
        ss->draw_tick = 0;
      }
  }


  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix();


  /* Run the startup "un-shrink" animation.
   */
  switch (ss->mode)
    {
    case IN:
      if (--ss->mode_tick <= 0)
        {
          ss->mode = NORMAL;
          ss->last_time = time((time_t *) 0);
        }
      break;
    case NORMAL:
      break;
    default:
      abort();
    }


  /* Scale as per the startup "un-shrink" animation.
   */
  if (ss->mode != NORMAL)
    {
      GLfloat s = (ss->mode == OUT
                   ? ss->mode_tick / (fade_ticks / speed)
                   : (((fade_ticks / speed) - ss->mode_tick + 1) /
                      (fade_ticks / speed)));
      glScalef (s, s, s);
    }

  /* Rotate and tilt as per the user, and the motion modeller.
   */
  {
    double x, y, z;
    gltrackball_rotate (ss->trackball);

    /* Tilt the tube up or down by up to 30 degrees */
    get_position (ss->rot, &x, &y, &z, !ss->button_down_p);
    if (tilt_x_p)
      glRotatef (15 - (x * 30), 1, 0, 0);
    if (tilt_y_p)
      glRotatef (7  - (y * 14), 0, 0, 1);

    /* Only use the Y component of the rotator. */
    get_rotation (ss->rot, &x, &y, &z, !ss->button_down_p);
    glRotatef (y * 360, 0, 1, 0);
  }

  /* First draw each image, then draw the titles.  GL insists that you
     draw back-to-front in order to make alpha blending work properly,
     so we need to draw all of the 100% opaque images before drawing
     any of the not-100%-opaque titles.
   */
  for (i = 0; i < ss->nframes; i++)
    draw_frame (mi, ss->frames[i], ss->now, True);
  if (titles_p)
    for (i = 0; i < ss->nframes; i++)
      draw_frame (mi, ss->frames[i], ss->now, False);

  glPopMatrix();

  if (mi->fps_p) do_fps (mi);
  glFinish();
  glXSwapBuffers (MI_DISPLAY (mi), MI_WINDOW(mi));
}
Ejemplo n.º 17
0
void get_phys_rotation(dBodyID body, float *r)
{
    get_rotation(r, dBodyGetRotation(body));
}
Ejemplo n.º 18
0
ENTRYPOINT void
draw_molecule (ModeInfo *mi)
{
  time_t now = time ((time_t *) 0);
  GLfloat speed = 4.0;  /* speed at which the zoom out/in happens */

  molecule_configuration *mc = &mcs[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!mc->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(mc->glx_context));

  if (mc->draw_time == 0)
    {
      pick_new_molecule (mi, mc->draw_time);
      mc->draw_time = now;
    }
  else if (mc->mode == 0)
    {
      if (mc->draw_tick++ > 10)
        {
          time_t now = time((time_t *) 0);
          if (mc->draw_time == 0) mc->draw_time = now;
          mc->draw_tick = 0;

          if (!mc->button_down_p &&
              mc->nmolecules > 1 &&
              mc->draw_time + timeout <= now)
            {
              /* randomize molecules every -timeout seconds */
              mc->mode = 1;    /* go out */
              mc->mode_tick = 10 * speed;
              mc->draw_time = now;
            }
        }
    }
  else if (mc->mode == 1)   /* out */
    {
      if (--mc->mode_tick <= 0)
        {
          mc->mode_tick = 10 * speed;
          mc->mode = 2;  /* go in */
          pick_new_molecule (mi, mc->draw_time);
          mc->draw_time = now;
        }
    }
  else if (mc->mode == 2)   /* in */
    {
      if (--mc->mode_tick <= 0)
        mc->mode = 0;  /* normal */
    }
  else
    abort();

  glPushMatrix ();
  glScalef(1.1, 1.1, 1.1);

  {
    double x, y, z;
    get_position (mc->rot, &x, &y, &z, !mc->button_down_p);
    glTranslatef((x - 0.5) * 9,
                 (y - 0.5) * 9,
                 (z - 0.5) * 9);

    gltrackball_rotate (mc->trackball);

    get_rotation (mc->rot, &x, &y, &z, !mc->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if (mc->mode != 0)
    {
      GLfloat s = (mc->mode == 1
                   ? mc->mode_tick / (10 * speed)
                   : ((10 * speed) - mc->mode_tick + 1) / (10 * speed));
      glScalef (s, s, s);
    }

  glPushMatrix();
  glCallList (mc->molecule_dlist);

  if (mc->mode == 0)
    {
      molecule *m = &mc->molecules[mc->which];

      draw_labels (mi);

      /* This can't go in the display list, or the characters are spaced
         wrongly when the window is resized. */
      if (do_titles && m->label && *m->label)
        {
          set_atom_color (mi, 0, True, 1);
          print_gl_string (mi->dpy, mc->xfont3, mc->font3_dlist,
                           mi->xgwa.width, mi->xgwa.height,
                           10, mi->xgwa.height - 10,
                           m->label, False);
        }
    }
  glPopMatrix();

  if (do_shells)
    {
      glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
      glPushMatrix();
      glCallList (mc->shell_dlist);
      glPopMatrix();
      glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

      glDepthFunc (GL_EQUAL);
      glEnable (GL_BLEND);
      glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glPushMatrix();
      glCallList (mc->shell_dlist);
      glPopMatrix();
      glDepthFunc (GL_LESS);
      glDisable (GL_BLEND);
    }

  glPopMatrix ();

  mi->polygon_count = mc->polygon_count;

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 19
0
ENTRYPOINT void
draw_bit (ModeInfo *mi)
{
  bit_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);
  int wire = MI_IS_WIREFRAME(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if (!wire)
    {
      GLfloat pos[4] = {1.0, 1.0, 1.0, 0.0};
      GLfloat amb[4] = {0.0, 0.0, 0.0, 1.0};
      GLfloat dif[4] = {1.0, 1.0, 1.0, 1.0};
      GLfloat spc[4] = {0.0, 1.0, 1.0, 1.0};

      glEnable(GL_LIGHTING);
      glEnable(GL_LIGHT0);
      glLightfv(GL_LIGHT0, GL_POSITION, pos);
      glLightfv(GL_LIGHT0, GL_AMBIENT,  amb);
      glLightfv(GL_LIGHT0, GL_DIFFUSE,  dif);
      glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
    }

  glPushMatrix ();
  glRotatef(current_device_rotation(), 0, 0, 1);
  glScalef(1.1, 1.1, 1.1);

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 11,
                 (y - 0.5) * 5,
                 (z - 0.5) * 3);
    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  mi->polygon_count = 0;

  glScalef (6, 6, 6);

  {
    int nmodel = bp->history [bp->history_fp];
    int omodel = bp->history [bp->history_fp > 0
                              ? bp->history_fp-1
                              : countof(bp->history)-1];
    double now = double_time();
    double ratio = 1 - ((bp->last_time + bp->frequency) - now) / bp->frequency;
    if (ratio > 1) ratio = 1;
    mi->polygon_count += draw_histogram (mi, ratio);
    mi->polygon_count += animate_bits (mi, omodel, nmodel, ratio);
    tick_bit (mi, now);
  }
  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 20
0
static void
draw (ModeInfo *mi)
{
  lament_configuration *lc = &lcs[MI_SCREEN(mi)];
  Bool wire = MI_IS_WIREFRAME(mi);

  mi->polygon_count = 0;

  if (!wire)
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  else
    glClear(GL_COLOR_BUFFER_BIT);

  glPushMatrix();

  gltrackball_rotate (lc->trackball);

  /* Make into the screen be +Y, right be +X, and up be +Z. */
  glRotatef (-90.0, 1.0, 0.0, 0.0);

  scale_for_window (mi);

  /* Apply rotation to the object. */
  if (lc->type != LAMENT_LID_ZOOM)
    get_rotation (lc->rot, &lc->rotx, &lc->roty, &lc->rotz,
                  !lc->button_down_p);
# ifdef DEBUG_MODE
  lc->rotx = 0.18;
  lc->roty = 0.22;
  lc->rotx = lc->roty = 0;
  lc->rotz = 0;
# endif

  glRotatef (lc->rotx * 360, 1, 0, 0);
  glRotatef (lc->roty * 360, 0, 1, 0);
  glRotatef (lc->rotz * 360, 0, 0, 1);

  glScalef (0.5, 0.5, 0.5);

  switch (lc->type)
    {
    case LAMENT_BOX:
      glCallList (lc->dlists[OBJ_BOX]);
      mi->polygon_count += lc->polys[OBJ_BOX];
      break;

    case LAMENT_STAR_OUT:
    case LAMENT_STAR_ROT:
    case LAMENT_STAR_ROT_IN:
    case LAMENT_STAR_ROT_OUT:
    case LAMENT_STAR_UNROT:
    case LAMENT_STAR_IN:
      glTranslatef (0.0, 0.0, lc->anim_z/2);
      glRotatef (lc->anim_r/2, 0.0, 0.0, 1.0);
      glCallList (lc->dlists[OBJ_STAR_U]);
      mi->polygon_count += lc->polys[OBJ_STAR_U];

      glTranslatef (0.0, 0.0, -lc->anim_z);
      glRotatef (-lc->anim_r, 0.0, 0.0, 1.0);
      glCallList (lc->dlists[OBJ_STAR_D]);
      mi->polygon_count += lc->polys[OBJ_STAR_D];
      break;

    case LAMENT_TETRA_UNE:
    case LAMENT_TETRA_USW:
    case LAMENT_TETRA_DWN:
    case LAMENT_TETRA_DSE:
      {
        int magic;
        GLfloat x, y, z;
        switch (lc->type) {
        case LAMENT_TETRA_UNE: magic = OBJ_TETRA_UNE; x= 1; y= 1; z= 1; break;
        case LAMENT_TETRA_USW: magic = OBJ_TETRA_USW; x= 1; y= 1; z=-1; break;
        case LAMENT_TETRA_DWN: magic = OBJ_TETRA_DWN; x= 1; y=-1; z= 1; break;
        case LAMENT_TETRA_DSE: magic = OBJ_TETRA_DSE; x=-1; y= 1; z= 1; break;
        default: abort(); break;
        }
        glCallList(lc->dlists[OBJ_TETRA_BASE]);
        mi->polygon_count += lc->polys[OBJ_TETRA_BASE];
        if (magic != OBJ_TETRA_UNE) glCallList (lc->dlists[OBJ_TETRA_UNE]);
        if (magic != OBJ_TETRA_USW) glCallList (lc->dlists[OBJ_TETRA_USW]);
        if (magic != OBJ_TETRA_DWN) glCallList (lc->dlists[OBJ_TETRA_DWN]);
        if (magic != OBJ_TETRA_DSE) glCallList (lc->dlists[OBJ_TETRA_DSE]);
        glRotatef (lc->anim_r, x, y, z);
        glCallList (lc->dlists[magic]);
        mi->polygon_count += lc->polys[magic] * 3;
      }
      break;

    case LAMENT_LID_OPEN:
    case LAMENT_LID_CLOSE:
    case LAMENT_LID_ZOOM:
      {
        GLfloat d = 0.21582;
        int i;
        const int lists[4] = { OBJ_LID_A, OBJ_LID_B, OBJ_LID_C, OBJ_LID_D };

        lc->facing_p = facing_screen_p (mi);

        if (lc->anim_z < 0.5)
          glTranslatef (0, -30 * lc->anim_z, 0);    /* zoom */
        else
          glTranslatef (8 * (0.5 - (lc->anim_z - 0.5)), 0, 0);

        glCallList (lc->dlists[OBJ_LID_BASE]);
        mi->polygon_count += lc->polys[OBJ_LID_BASE];
        for (i = 0; i < countof(lists); i++)
          {
            glPushMatrix();
            glRotatef (90 * i, 0, 1, 0);
            glTranslatef (-d, -0.5, d);
            glRotatef (-45, 0, 1, 0);
            glRotatef (-lc->anim_r, 1, 0, 0);
            glRotatef (45, 0, 1, 0);
            glTranslatef (d, 0.5, -d);
            glRotatef (-90 * i, 0, 1, 0);
            glCallList (lc->dlists[lists[i]]);
            mi->polygon_count += lc->polys[lists[i]];
            glPopMatrix();
          }

# ifdef DEBUG_MODE
        if (lc->facing_p)
          {
            glColor3f(1, 0, 0);
            glBegin (wire ? GL_LINE_LOOP : GL_QUADS);
            glVertex3f (-0.49, 0.49, -0.49);
            glVertex3f ( 0.49, 0.49, -0.49);
            glVertex3f ( 0.49, 0.49,  0.49);
            glVertex3f (-0.49, 0.49,  0.49);
            glEnd();
            mi->polygon_count++;
          }
# endif /* DEBUG_MODE */
      }
      break;

    case LAMENT_TASER_OUT:
    case LAMENT_TASER_SLIDE:
    case LAMENT_TASER_SLIDE_IN:
    case LAMENT_TASER_IN:

      glTranslatef (0, -lc->anim_z/2, 0);
      glCallList (lc->dlists[OBJ_TASER_BASE]);
      mi->polygon_count += lc->polys[OBJ_TASER_BASE];

      glTranslatef (0, lc->anim_z, 0);
      glCallList (lc->dlists[OBJ_TASER_A]);
      mi->polygon_count += lc->polys[OBJ_TASER_A];

      glTranslatef (lc->anim_y, 0, 0);
      glCallList (lc->dlists[OBJ_TASER_B]);
      mi->polygon_count += lc->polys[OBJ_TASER_B];
      break;

    case LAMENT_PILLAR_OUT:
    case LAMENT_PILLAR_SPIN:
    case LAMENT_PILLAR_IN:

      glCallList (lc->dlists[OBJ_PILLAR_BASE]);
      mi->polygon_count += lc->polys[OBJ_PILLAR_BASE];

      glPushMatrix();
      if (lc->anim_z == 1 || lc->anim_z == 3)
        {
          glRotatef (lc->anim_r, 0, 0, 1);
          glTranslatef (0, 0, lc->anim_y);
        }
      glCallList (lc->dlists[OBJ_PILLAR_A]);
      mi->polygon_count += lc->polys[OBJ_PILLAR_A];
      glPopMatrix();

      glPushMatrix();
      if (lc->anim_z == 2 || lc->anim_z == 3)
        {
          glRotatef (lc->anim_r, 0, 0, 1);
          glTranslatef (0, 0, -lc->anim_y);
        }
      glCallList (lc->dlists[OBJ_PILLAR_B]);
      mi->polygon_count += lc->polys[OBJ_PILLAR_B];
      glPopMatrix();
      break;

    case LAMENT_SPHERE_OUT:
    case LAMENT_SPHERE_IN:
      mi->polygon_count += lament_sphere (mi, lc->anim_y);
      break;

    case LAMENT_LEVIATHAN_SPIN:
    case LAMENT_LEVIATHAN_UNSPIN:
    case LAMENT_LEVIATHAN_FADE:
    case LAMENT_LEVIATHAN_UNFADE:
    case LAMENT_LEVIATHAN_TWIST:
    case LAMENT_LEVIATHAN_UNTWIST:
      {
        /* These normals are hard to compute, so I pulled them from the
           model. */
        const GLfloat axes[6][4] =
          {{ OBJ_ISO_UNE,  0.633994, 0.442836,   0.633994 },
           { OBJ_ISO_USW,  0.442836,  0.633994, -0.633994 },
           { OBJ_ISO_DSE, -0.633994,  0.633994,  0.442836 },
           { OBJ_ISO_SWD, -0.633994, -0.442836, -0.633994 },
           { OBJ_ISO_DEN, -0.442836, -0.633994,  0.633994 },
           { OBJ_ISO_UNW,  0.633994, -0.633994, -0.442836 }};
        int i;

        GLfloat s = (1 - lc->anim_z);
        GLfloat s2 = MAX (0, 360 - lc->anim_r) / 360.0;
        Bool blendp = 0;

        switch (lc->type) {
        case LAMENT_LEVIATHAN_SPIN: break;
        case LAMENT_LEVIATHAN_UNSPIN: s2 = 1 - s2; break;
        default: s2 = 0; blendp = 1; break;
        }

        if (wire) blendp = 0;

        s  = (s * 0.6) + 0.4;

        leviathan (mi, 1 - s2, 1, True);
        glCallList (lc->dlists[OBJ_ISO_BASE_A]);
        mi->polygon_count += lc->polys[OBJ_ISO_BASE_A];

        glPushMatrix();
        glScalef (s2, s2, s2);
        glCallList (lc->dlists[OBJ_ISO_USE]);
        mi->polygon_count += lc->polys[OBJ_ISO_USE];
        glPopMatrix();

        glPushMatrix();
        glRotatef (lc->anim_y, 1, -1, 1);
        glCallList (lc->dlists[OBJ_ISO_BASE_B]);
        mi->polygon_count += lc->polys[OBJ_ISO_BASE_B];
        leviathan (mi, 1 - s2, 1, False);
        glPopMatrix();

        if (blendp)
          {
# ifndef HAVE_JWZGLES /* no glBlendColor */
            glEnable (GL_BLEND);
            glBlendFunc (GL_CONSTANT_ALPHA, GL_SRC_ALPHA);
            glBlendColor (1, 1, 1, MAX(0, 1-(lc->anim_z * 3)));
# endif
          }

        for (i = 0; i < countof(axes); i++)
          {
            glPushMatrix();
            glRotatef (lc->anim_r, axes[i][1], axes[i][2], axes[i][3]);
            glScalef (s, s, s);
            glCallList (lc->dlists[(int) axes[i][0]]);
            mi->polygon_count += lc->polys[(int) axes[i][0]];
            glPopMatrix();
            if (i == 2)
              glRotatef (lc->anim_y, 1, -1, 1);
          }

        if (blendp) glDisable (GL_BLEND);

        glPushMatrix();
        glScalef (s2, s2, s2);
        glCallList (lc->dlists[OBJ_ISO_DWN]);
        mi->polygon_count += lc->polys[OBJ_ISO_DWN];
        glPopMatrix();
      }
      break;

    case LAMENT_LEVIATHAN_COLLAPSE:
    case LAMENT_LEVIATHAN_EXPAND:
      {
        glPushMatrix();
        leviathan (mi, 1, lc->anim_y, True);
        glRotatef (180, 1, -1, 1);
        leviathan (mi, 1, lc->anim_y, False);
        glPopMatrix();
        folding_walls (mi, lc->anim_y, True);
        folding_walls (mi, lc->anim_y, False);
      }
      break;

    default:
      abort();
      break;
    }

  glPopMatrix();
}
Ejemplo n.º 21
0
ENTRYPOINT void
draw_ball (ModeInfo *mi)
{
  ball_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);
  int c2;

  static const GLfloat bspec[4]  = {1.0, 1.0, 1.0, 1.0};
  static const GLfloat sspec[4]  = {0.0, 0.0, 0.0, 1.0};
  static const GLfloat bshiny    = 128.0;
  static const GLfloat sshiny    = 0.0;

  GLfloat bcolor[4] = {0.0, 0.0, 0.0, 1.0};
  GLfloat scolor[4] = {0.0, 0.0, 0.0, 1.0};

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glShadeModel(GL_SMOOTH);

  glEnable(GL_DEPTH_TEST);
  glEnable(GL_NORMALIZE);
  glEnable(GL_CULL_FACE);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();

  glScalef(1.1, 1.1, 1.1);

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 8,
                 (y - 0.5) * 8,
                 (z - 0.5) * 15);

    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  bcolor[0] = bp->colors[bp->ccolor].red   / 65536.0;
  bcolor[1] = bp->colors[bp->ccolor].green / 65536.0;
  bcolor[2] = bp->colors[bp->ccolor].blue  / 65536.0;

  c2 = (bp->ccolor + bp->color_shift) % bp->ncolors;
  scolor[0] = bp->colors[c2].red   / 65536.0;
  scolor[1] = bp->colors[c2].green / 65536.0;
  scolor[2] = bp->colors[c2].blue  / 65536.0;

  bp->ccolor++;
  if (bp->ccolor >= bp->ncolors) bp->ccolor = 0;

  mi->polygon_count = 0;

  glScalef (2.0, 2.0, 2.0);

  move_spikes (mi);

  glMaterialfv (GL_FRONT, GL_SPECULAR,            bspec);
  glMateriali  (GL_FRONT, GL_SHININESS,           bshiny);
  glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, bcolor);
  glCallList (bp->ball_list);
  mi->polygon_count += (SPHERE_SLICES * SPHERE_STACKS);

  glMaterialfv (GL_FRONT, GL_SPECULAR,            sspec);
  glMaterialf  (GL_FRONT, GL_SHININESS,           sshiny);
  glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, scolor);
  draw_spikes (mi);
  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 22
0
ENTRYPOINT void
draw_hypnowheel (ModeInfo *mi)
{
  hypnowheel_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);
  int i;

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(bp->glx_context));

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, True);
    glTranslatef((x - 0.5) * 8,
                 (y - 0.5) * 8,
                 0);

    get_rotation (bp->rot, &x, &y, &z, True);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  mi->polygon_count = 0;

  glScalef (45, 45, 45);

  for (i = 0; i < nlayers; i++)
    {
      disc *d = &bp->discs[i];
      double x, y, z;
      rotator *rot = (do_symmetric ? bp->discs[(i & ~0x1)].rot : d->rot);
      Bool tick = (!do_symmetric || i == 0);

      glPushMatrix();

      d->color++;
      if (d->color >= bp->ncolors)
        d->color = 0;

      get_position (rot, &x, &y, &z, tick);
      x -= 0.5;
      y -= 0.5;
      x *= 0.1;
      y *= 0.1;

      glTranslatef (x, y, 0);
      d->twist = (z * twistiness *
                  ((i & 1) ? 1 : -1));

      get_rotation (rot, &x, &y, &z, tick);

      glRotatef (360 * z, 0, 0, 1);  /* rotation of this disc */

      draw_spiral (mi, &bp->discs[i]);
      glPopMatrix();
    }

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 23
0
ENTRYPOINT void
draw_unicrud (ModeInfo *mi)
{
  unicrud_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *bp->glx_context);

  glShadeModel (GL_FLAT);
  glEnable (GL_NORMALIZE);
  glDisable (GL_CULL_FACE);
  glDisable (GL_LIGHTING);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  if (! bp->button_down_p)
    switch (bp->state) {
    case IN:     bp->ratio += speed * 0.05;  break;
    case OUT:    bp->ratio += speed * 0.05;  break;
    case LINGER: bp->ratio += speed * 0.005; break;
    default:     abort();
    }

  if (bp->ratio > 1.0)
    {
      bp->ratio = 0;
      switch (bp->state) {
      case IN:
        bp->state = LINGER;
        break;
      case LINGER:
        bp->state = OUT;
        bp->spin_direction = (random() & 1) ? 1 : -1;
        break;
      case OUT:
        bp->state = IN;
        pick_unichar(mi);
        break;
      default:     abort();
      }
    }

  glPushMatrix ();

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 6,
                 (y - 0.5) * 6,
                 (z - 0.5) * 6);

    gltrackball_rotate (bp->trackball);

    get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
    x = y = 0;
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

# define SINOID(N) (sin(M_PI - (N) / 2 * M_PI))
  {
    GLfloat s;
    switch (bp->state) {
    case IN:  s = SINOID (bp->ratio);   break;
    case OUT: s = SINOID (1-bp->ratio); break;
    default:  s = 1; break;
    }
    glScalef (s, s, s);
    glRotatef (360 * s * bp->spin_direction * (bp->state == IN ? -1 : 1),
               0, 0, 1);
  }

  draw_unichar (mi);

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 24
0
Vector3 Spatial::_get_rotation_deg() const {

	return get_rotation() * 180.0 / Math_PI;
}
Ejemplo n.º 25
0
ENTRYPOINT void
draw_spheremonics (ModeInfo *mi)
{
  spheremonics_configuration *cc = &ccs[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!cc->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *(cc->glx_context));

  gl_init(mi);

  glShadeModel(GL_SMOOTH);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();

  glScalef(1.1, 1.1, 1.1);

  {
    double x, y, z;
    get_position (cc->rot, &x, &y, &z, !cc->button_down_p);
    glTranslatef((x - 0.5) * 8,
                 (y - 0.5) * 6,
                 (z - 0.5) * 8);

    gltrackball_rotate (cc->trackball);

    get_rotation (cc->rot, &x, &y, &z, !cc->button_down_p);
    glRotatef (x * 360, 1.0, 0.0, 0.0);
    glRotatef (y * 360, 0.0, 1.0, 0.0);
    glRotatef (z * 360, 0.0, 0.0, 1.0);
  }

  glScalef(7,7,7);

  mi->polygon_count = 0;

  glScalef (cc->scale, cc->scale, cc->scale);
  glCallList (cc->dlist);
  mi->polygon_count += cc->polys1;

  if (cc->mesher >= 0 /* || cc->button_down_p */)
    {
      glDisable (GL_LIGHTING);
      glCallList (cc->dlist2);
      mi->polygon_count += cc->polys2;
      if (cc->mesher >= 0)
        cc->mesher--;
    }
  do_tracer(mi);


  if (cc->button_down_p)
    {
      char buf[200];
      sprintf (buf,
               ((cc->m[0]<10 && cc->m[1]<10 && cc->m[2]<10 && cc->m[3]<10 &&
                 cc->m[4]<10 && cc->m[5]<10 && cc->m[6]<10 && cc->m[7]<10)
                ? "%d%d%d%d%d%d%d%d"
                : "%d %d %d %d %d %d %d %d"),
               cc->m[0], cc->m[1], cc->m[2], cc->m[3],
               cc->m[4], cc->m[5], cc->m[6], cc->m[7]);

      glColor3f(1.0, 1.0, 0.0);
      print_texture_label (mi->dpy, cc->font_data,
                           mi->xgwa.width, mi->xgwa.height,
                           1, buf);
    }

  if (!static_parms)
    {
      if (cc->change_tick++ >= duration && !cc->button_down_p)
        {
          generate_spheremonics(mi);
          cc->change_tick = 0;
          cc->mesher = -1;  /* turn off the mesh when switching objects */
        }
    }

  glPopMatrix();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}
Ejemplo n.º 26
0
float Node2D::get_rotation_degrees() const {

	return Math::rad2deg(get_rotation());
}
Ejemplo n.º 27
0
ENTRYPOINT void
draw_planet (ModeInfo * mi)
{
  planetstruct *gp = &planets[MI_SCREEN(mi)];
  Display    *display = MI_DISPLAY(mi);
  Window      window = MI_WINDOW(mi);
  double x, y, z;

  if (!gp->glx_context)
	return;

  glDrawBuffer(GL_BACK);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glXMakeCurrent (display, window, *(gp->glx_context));

  mi->polygon_count = 0;

  if (do_stars)
    {
      draw_stars (mi);
      mi->polygon_count += NUM_STARS;
    }

  if (do_light)   glEnable(GL_LIGHTING);
  if (do_texture) glEnable(GL_TEXTURE_2D);

  glEnable (GL_LINE_SMOOTH);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);
  glCullFace(GL_BACK); 

  glPushMatrix();

  get_position (gp->rot, &x, &y, &z, !gp->button_down_p);
  glTranslatef((x - 0.5) * 15,
               (y - 0.5) * 15,
               (z - 0.5) * 8);

  /* Do it twice because we don't track the device's orientation. */
  glRotatef( current_device_rotation(), 0, 0, 1);
  gltrackball_rotate (gp->trackball);
  glRotatef(-current_device_rotation(), 0, 0, 1);

  glRotatef (90,1,0,0);

  if (do_roll)
    {
      get_rotation (gp->rot, &x, &y, 0, !gp->button_down_p);
      glRotatef (x * 360, 1.0, 0.0, 0.0);
      glRotatef (y * 360, 0.0, 1.0, 0.0);
    }

  glLightfv (GL_LIGHT0, GL_POSITION, gp->sunpos);

  glRotatef (gp->z * 360, 0.0, 0.0, 1.0);
  if (do_rotate && !gp->button_down_p)
    {
      gp->z -= 0.005;     /* the sun sets in the west */
      if (gp->z < 0) gp->z += 1;
    }

  glCallList (gp->platelist);
  mi->polygon_count += resolution*resolution;

  if (gp->button_down_p)
    {
      glCallList (gp->latlonglist);
      mi->polygon_count += 24*24;
    }
  glPopMatrix();

  if (mi->fps_p) do_fps (mi);
  glFinish();
  glXSwapBuffers(display, window);

  gp->star_theta += star_spin;
}
Ejemplo n.º 28
0
void
SWFMatrix::set_scale(double xscale, double yscale)
{
    const double rotation = get_rotation();
    set_scale_rotation(xscale, yscale, rotation); 
}
Ejemplo n.º 29
0
void Node2D::rotate(float p_radians) {

	set_rotation(get_rotation() + p_radians);
}
Ejemplo n.º 30
0
ENTRYPOINT void
draw_splitflap (ModeInfo *mi)
{
  splitflap_configuration *bp = &bps[MI_SCREEN(mi)];
  Display *dpy = MI_DISPLAY(mi);
  Window window = MI_WINDOW(mi);

  if (!bp->glx_context)
    return;

  glXMakeCurrent(MI_DISPLAY(mi), MI_WINDOW(mi), *bp->glx_context);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glPushMatrix ();
  glRotatef(current_device_rotation(), 0, 0, 1);

  glScalef (0.1, 0.1, 0.1);  /* because of gluLookAt */

  {
    double x, y, z;
    get_position (bp->rot, &x, &y, &z, !bp->button_down_p);
    glTranslatef((x - 0.5) * 8,
                 (y - 0.5) * 8,
                 (z - 0.5) * 8);

    gltrackball_rotate (bp->trackball);

    if (face_front_p)
      {
        double maxx = 120;
        double maxy = 60;
        double maxz = 45;
        get_position (bp->rot2, &x, &y, &z, !bp->button_down_p);
        if (bp->spinx) glRotatef (maxy/2 - x*maxy, 1, 0, 0);
        if (bp->spiny) glRotatef (maxx/2 - y*maxx, 0, 1, 0);
        if (bp->spinz) glRotatef (maxz/2 - z*maxz, 0, 0, 1);
      }
    else
      {
        get_rotation (bp->rot, &x, &y, &z, !bp->button_down_p);
        glRotatef (x * 360, 1, 0, 0);
        glRotatef (y * 360, 0, 1, 0);
        glRotatef (z * 360, 0, 0, 1);
      }
  }

  /* Fit the whole grid on the screen */
  {
    GLfloat r = MI_HEIGHT(mi) / (GLfloat) MI_WIDTH(mi);
    int cells = (grid_width > grid_height
                 ? grid_width * r
                 : grid_height);
    GLfloat s = 8;
# ifdef HAVE_MOBILE
    s *= 2; /* #### What. Why is this necessary? */
#endif
    s /= cells;
    glScalef (s, s, s);
  }

  mi->polygon_count = 0;
  mi->polygon_count += draw_component (mi, SPLITFLAP_OUTER_FRAME);

  {
    GLfloat xoff = (bp->clock_p == 12 ? COLON_WIDTH * 3 :
                    bp->clock_p == 24 ? COLON_WIDTH * 2 :
                    0);
    glTranslatef (1 - (grid_width + xoff), 1 - grid_height, 0);
  }

  /* We must render all text after all polygons, or alpha blending
     doesn't work right. */
  draw_flappers (mi, False);
  draw_flappers (mi, True);

  glPopMatrix ();

  if (mi->fps_p) do_fps (mi);
  glFinish();

  glXSwapBuffers(dpy, window);
}