예제 #1
0
void FPS::prepare() {
  if (!displayed()) return;
  ++loop_count;
  double curtime = time_of_day();
  // force a redraw....
  need_matrix_recalc();
  // but don't redraw indicator more than twice per second
  if (curtime - last_update < 0.5) return;
  double rate = loop_count / (curtime - last_update);
  last_update = curtime;
  loop_count = 0;

  reset_disp_list();
  append(DMATERIALOFF);

  float asp = disp->aspect();
  float poscale = 1.2f;
  float pos[3];
  pos[0] = asp * poscale;
  pos[1] = poscale;
  pos[2] = 0;
  
  DispCmdColorIndex cmdColor;
  cmdColor.putdata(usecolor, cmdList);

  DispCmdText cmdText;
  char buf[20];
  sprintf(buf, "%5.2f", rate);
  cmdText.putdata(pos, buf, 1.0f, cmdList);
}
예제 #2
0
void VMDTitle::redraw_list(void) {
  reset_disp_list();
  float x;  // offset to center VMD
  x = letter_V_width() + STROKE_WIDTH/2.0f + 
      letter_M_width() + STROKE_WIDTH/2.0f +
      letter_V_width(); // same width as 'V'
  x=x/2; // center on the screen

  append(DMATERIALON);
  color.putdata(REGRED, cmdList);
  draw_letter_V(-x, -0.4f, cmdList);
  color.putdata(REGGREEN, cmdList);
  draw_letter_M(-x + STROKE_WIDTH/2.0f + letter_V_width(), -0.4f, cmdList);
  color.putdata(REGBLUE, cmdList);
  draw_letter_D(-x + STROKE_WIDTH/2.0f + letter_V_width() +
                     STROKE_WIDTH/2.0f + letter_M_width(), -0.4f, cmdList);
  append(DMATERIALOFF);

  if (letterson) {
    color.putdata(REGWHITE, cmdList);
    float pos[3];
    pos[0] =    -x; 
    pos[1] = -0.6f; 
    pos[2] =  0.0f;

    DispCmdText txt;
    txt.putdata(pos, "Theoretical and Computational Biophysics Group", cmdList);
    pos[1] -= 0.1f;
    txt.putdata(pos, "NIH Resource for Macromolecular Modeling and Bioinformatics", cmdList);
    pos[1] -= 0.1f;
    txt.putdata(pos, "University of Illinois at Urbana-Champaign", cmdList);
    pos[1] -= 0.1f;
    txt.putdata(pos, VMD_AUTHORS_LINE1, cmdList);
    pos[1] -= 0.1f;
    txt.putdata(pos, VMD_AUTHORS_LINE2, cmdList);
    pos[1] -= 0.1f;
    txt.putdata(pos, VMD_AUTHORS_LINE3, cmdList);
  }
}
예제 #3
0
void MoleculeGraphics::create_cmdlist(void) {
  reset_disp_list();
  // set the default values
  DispCmdTriangle triangle;
  DispCmdCylinder cylinder;
  DispCmdPoint point;
  DispCmdLine line;
  DispCmdCone cone;
  DispCmdColorIndex color;
  DispCmdLineType linetype;
  DispCmdLineWidth linewidth;
  DispCmdSphere sphere;
  DispCmdSphereRes sph_res;
  //DispCmdComment comment;
  DispCmdPickPoint cmdPickPoint;

  append(DMATERIALON);
  color.putdata(0, cmdList);     // use the first color by default (blue)
  int last_res = -1;             // default sphere resolution

  int last_line = ::SOLIDLINE;       // default for lines
  linetype.putdata(last_line, cmdList); // solid and
  int last_width = 1;
  linewidth.putdata(last_width, cmdList);  //  of width 1

  // go down the list and draw things
  int num = num_elements();
  ShapeClass *shape;
  for (int i=0; i<num; i++) {
    shape = &(shapes[i]);
    switch (shape->shape) {
    case NONE: {
      break;
    }
    case POINT: {
      append(DMATERIALOFF);
      point.putdata(shape->data+0, cmdList);
      append(DMATERIALON);
      break;
    }
    case PICKPOINT: 
      cmdPickPoint.putdata(shape->data, (int)shape->data[3], cmdList);
      break;
    case LINE: {
      append(DMATERIALOFF);
      int style = int(shape->data[6]);
      int width = int(shape->data[7]);
      if (style != last_line) {
        linetype.putdata(style, cmdList);
        last_line = style;
      }
      if (width != last_width) {
        linewidth.putdata(width, cmdList);
        last_width = width;
      }
      line.putdata(shape->data+0, shape->data+3, cmdList);
      append(DMATERIALON);
      break;
    }
    case TRIANGLE: {
      triangle.putdata(shape->data+0, shape->data+3, shape->data+6, cmdList);
      break;
    }
    case TRINORM: {
      triangle.putdata(shape->data+0, shape->data+3 , shape->data+6, 
                       shape->data+9, shape->data+12, shape->data+15, cmdList);
      break;
    }
    case TRICOLOR: 
      {
        // compute rgb colors from indices
        float colors[9];
        for (int i=0; i<3; i++) {
          int c = (int)shape->data[18+i];
          c = clamp_int(c, 0, MAXCOLORS-1);
          vec_copy(colors+3*i, scene->color_value(c));
        }
        const float *verts = shape->data+0;
        const float *norms = shape->data+9;
        int facets[3] = { 0,1,2 };
        DispCmdTriMesh::putdata(verts, norms, colors, 3, facets, 1, 0, cmdList);
      }
      break;
    case CYLINDER: {
      cylinder.putdata(shape->data+0, shape->data+3, shape->data[6], 
                       int(shape->data[7]), 
                       (int (shape->data[8])) ? 
                         CYLINDER_TRAILINGCAP | CYLINDER_LEADINGCAP : 0, 
                       cmdList);
      break;
    }
    case CONE: {
      cone.putdata(shape->data+0, shape->data+3, shape->data[6], 
                   shape->data[8], int(shape->data[7]), cmdList);
      break;
    }
    case TEXT: {
      append(DMATERIALOFF);
      DispCmdText text;
      DispCmdTextSize textSize;
      textSize.putdata(shape->data[3], cmdList);
      text.putdata(shape->data, shapetext[(int)shape->data[5]], shape->data[4], cmdList);
      append(DMATERIALON);
      break;
    }
#if 0
    // these aren't supported yet
    case DBEGINREPGEOMGROUP: {
      char *s = (char *) (shape);
      beginrepgeomgroup.putdata(s,cmdList);
      break;
    }
    case DCOMMENT: {
      char *s = (char *) (shape);
      comment.putdata(s,cmdList);
      break;
    }
#endif
    case SPHERE: {
      int res = int (shape->data[4]);
      if (res != last_res) {
        sph_res.putdata(res, cmdList);
        last_res = res;
      }
      sphere.putdata(shape->data+0, shape->data[3], cmdList);
      break;
    }
    case MATERIALS: {
      if (shape->data[0] == 0) append(DMATERIALOFF);
      else append(DMATERIALON);
      break;
    }
    case MATERIAL: {
      const float *data = shape->data;
      cmdList->ambient = data[0];
      cmdList->specular = data[1];
      cmdList->diffuse = data[2];
      cmdList->shininess = data[3];
      cmdList->mirror = data[4];
      cmdList->opacity = data[5];
      cmdList->outline = data[6];
      cmdList->outlinewidth = data[7];
      cmdList->transmode = data[8];
      cmdList->materialtag = (int)data[9];
      break;
    }
    case COLOR: {
      color.putdata(int(shape->data[0]), cmdList);
      break;
    }
    default:
      msgErr << "Sorry, can't draw that" << sendmsg;
    }
  }
  needRegenerate = 0;
}