亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? bbsjava1.txt

?? 標 題: Java example(1) 發信站: BBS 水木清華站
?? TXT
字號:
BBS水木清華站∶精華區
發信人: VolVis (arthur), 信區: Java 
標  題: Java example(1) 
發信站: BBS 水木清華站 (Fri Dec 25 13:36:27 1998) WWW-POST 
 
Dear Everyone:  
 
I just have read a java program to draw a 3d face was written by Daeron  
Meyer, The Geometry Center, University of Minnesota. I do think it is a good  
program to illustrate the java appletview and the 3d Graphics although it  
only draw a polygon without clipping and lingting. It inludes three class:  
Viewer3D, Matrix3D and OOGL_OFF. The most important class is OOGL_OFF, I  
will  
explain it and the other 2 class in the java program.The last part was one  
OFF  
format file and one html file.I hope it will be helpful to you.  
 
 
Yours VolVis  
Information Department of Peking University  
The following will give you a detailed explaination about the class OOGL_OFF  
(1) findBB() is to calculate the bounding box of the object  
    why? the answer is to put all the vertices in a box, so the coordinate  
    transform can the (0,0,0) to be the object center.  
(2) paint() is the most function in the class OOGL_OFF, for it using the  
    Painter's algorithm to paint the scenes. Do you know the Painter's  
    algorithm? The algorithm is to align the object in the reverse erder of  
    their distance from the eye. As common, the eye is placed in minus z  
axis,  
    so the sort the object according to object parameter depth. The the  
farther  
    object will be painted earlier, and the nearest object will be painted  
the  
    latest. Perhaps, the nearer object will hide the farther object. Let's  
see  
    the java program: At first, it will allocate the color for the face  
    gr[i] = new Color(face[i].cr, face[i].cg, face[i].cb) 0 <= i <= number  
of  
    faces. then quick sort the faces by the qs function whose algorithm is  
    the same asthe dividing method in data structure. At last paint the  
    faces by the function g.fillPolygon(vx, vy, face[i].nverts) and paint  
the  
    edges by the function g.drawLine(vx[v], vy[v], vx[v+1], vy[v+1])  
(3) the readObject function is to read the faces from the OFF file. The  
first  
    line of OFF file is the tag OFF, the following is number of vertices ,  
    number of faces, and number of edges. Then the three dimensional data of  
    vertices is following them. The next thing is data of faces, including  
the  
    number of vertices in the face, the vertex index, and the color of face.  
i  
    In the OFF file, you can add any comment with the head #. Now, if you  
are  
    familiar with the java, you can read the OFF file either. But I have to  
    remind you that the class StreamTokenizer is a good way to do this work.  
 
/**  
 *  
 * Author: Daeron Meyer  
 * Copyright (c) 1995 by The Geometry Center, University of Minnesota  
 * Distributed under the terms of the GNU Library General Public License  
 * 12-14-95  
 *  
 */  
 
import java.applet.Applet;  
import java.awt.Graphics;  
import java.awt.Color;  
import java.awt.Event;  
import java.lang.*;  
import java.io.StreamTokenizer;  
import java.io.InputStream;  
import java.io.IOException;  
import java.net.URL;  
 
/**  
 *  class Face: your basic storage class for polygonal face information.  
 */  
 
class Face {  
 
  public int nverts; // number of vertices  
  public int index[]; // array of indices  
  public int cr, cg, cb; // face color in RGB  
  public int zdepth; // z depth of furthest vertex  
 
  Face () {  
    nverts = 0;  
    index = null;  
    cr = 255; cg = 255; cb = 255;  
  }  
 
  Face (int nv) {  
    nverts = nv;  
    index = new int[nv];  
    cr = 255; cg = 255; cb = 255;  
  }  
 
  public void numVerts(int nv) {  
    nverts = nv;  
    index = new int[nv];  
  }  
}  
 
/**  
 *  class OOGL_OFF: a class for parsing, storing and rendering OFF 3D models  
 *  
 *  For more information about OFF files and other OOGL (Object Oriented  
 *  Graphics Library) file formats, check the following URL:  
 *  
 *  http://www.geom.umn.edu/software/geomview/docs/oogltour.html  
 */  
 
public class OOGL_OFF {  
 
  Face face[]; // array of faces  
  boolean transformed, gothead;  
  Matrix3D mat; // applied 3D transformation  
  public float xmin, xmax, // bounding box parameters  
ymin, ymax,  
zmin, zmax;  
  float vert[]; // array of vertex coordinates  
  int nverts, nfaces, nedges, // # of vertices, faces, edges  
vx[], vy[], // coords for rendering faces  
tvert[], // transformed vertices  
findex[]; // indices into face list  
  Color gr[]; // face colors  
  final int MAX_VERTS = 100; // assume each polygonal face  
// has less than 100 vertices.  
    
  OOGL_OFF () {  
    mat = new Matrix3D();  
    vx = new int[MAX_VERTS];  
    vy = new int[MAX_VERTS];  
    nverts = 0;  
    nedges = 0;  
    nfaces = 0;  
    vert = null;  
    gr = null;  
    mat.xrot(0); mat.yrot(0);  
  }  
 
  OOGL_OFF (URL loc) { // read object from any URL  
 
    this();  
    try {  
      readObject(loc.openStream());  
    } catch (IOException e) {  
      System.out.println(e.getMessage());  
    }  
 
  }  
    
  OOGL_OFF (InputStream is) { // read object from a stream  
 
    this();  
    try {  
      readObject(is);  
    } catch (IOException e) {  
      System.out.println(e.getMessage());  
    }  
 
  }  
 
 
/* This method parses an OFF file. */  
 
  void readObject(InputStream is) throws IOException {  
 
    StreamTokenizer stream = new StreamTokenizer (is);  
 
    stream.eolIsSignificant(true);  
    stream.commentChar('#');  
    gothead = false;  
 
  scanhead: // read the header  
 
    while (!gothead) {  
 
      switch (stream.nextToken()) {  
 
      default:  
break scanhead;  
 
      case StreamTokenizer.TT_EOL:  
break;  
 
      case StreamTokenizer.TT_WORD:  
 
if ("OFF".equals(stream.sval)) {  
            
          System.out.println(stream.sval);  
 
  nverts = 0; nfaces = 0; nedges = 0;  
  while (stream.nextToken() == StreamTokenizer.TT_EOL) {};  
 
  if (stream.ttype == StreamTokenizer.TT_NUMBER) {  
 
    nverts = (int)stream.nval;  
    if (stream.nextToken() == StreamTokenizer.TT_NUMBER) {  
 
      nfaces = (int)stream.nval;  
      if (stream.nextToken() == StreamTokenizer.TT_NUMBER) {  
 
nedges = (int)stream.nval;  
gothead = true;  
 
      } else throw new IOException("Can't read OFF file");  
 
    } else throw new IOException("Can't read OFF file");  
 
  } else throw new IOException("Can't read OFF file");  
 
}  
break;  
 
      case StreamTokenizer.TT_NUMBER:  
break;  
 
      }  
 
    }  
 
    vert = new float[nverts * 3];  
    face = new Face[nfaces]; findex = new int[nfaces];  
 
    for (int i = 0; i < nfaces; i++) { findex[i] = i; }  
 
    int num = 0;   
    int coordnum = 0;  
 
  scanverts: // read the vertices  
 
    while (num < nverts) {  
 
      switch (stream.nextToken()) {  
 
        default:  
  break;  
 
case StreamTokenizer.TT_EOL:  
  if (coordnum > 2) {  
    coordnum = 0; num++;  
  }  
  break;  
 
case StreamTokenizer.TT_NUMBER:  
  if (coordnum < 3) {  
    vert[num*3 + coordnum] = (float)stream.nval;  
    coordnum++;  
  }  
 
      }  
 
    }  
 
    num = 0; coordnum = 0;  
    boolean gotnum = false;  
 
  scanfaces: // read the faces  
 
    while (num < nfaces) {  
 
      switch (stream.nextToken()) {  
 
        default:  
  break;  
 
case StreamTokenizer.TT_EOL:  
  if (gotnum) { num++; }  
  gotnum = false;  
  break;  
 
case StreamTokenizer.TT_NUMBER:  
  if (!gotnum) {  
 
    face[num] = new Face();  
    face[num].numVerts((int)stream.nval);  
    gotnum = true; coordnum = 0;  
 
  } else if (coordnum < face[num].nverts) {  
 
    face[num].index[coordnum] = 3 * (int)stream.nval;  
    coordnum++;  
 
  } else {  
 
    face[num].cr = 255; face[num].cg = 255; face[num].cb = 255;  
    float val = (float)stream.nval;  
 
    if (val <= 1) { val *= 255; }  
 
    face[num].cr = (int)val;  
 
    if (stream.nextToken() != StreamTokenizer.TT_EOL) {  
 
      val = (float)stream.nval;  
      if (val <= 1) { val *= 255; }  
      face[num].cg = (int)val;  
 
      if (stream.nextToken() != StreamTokenizer.TT_EOL) {  
 
val = (float)stream.nval;  
        if (val <= 1) { val *= 255; }  
face[num].cb = (int)val;  
 
      } else {  
 
face[num].cr = 255; face[num].cg = 255; face[num].cb = 255;  
num++; gotnum = false;  
 
      }  
 
    } else {  
 
face[num].cr = 255; face[num].cg = 255; face[num].cb = 255;  
num++; gotnum = false;  
 
      }  
  }  
 
  break;  
 
      }  
 
    }  
       
 
  }  
 
 
/* transform all points in model */  
 
  void transform() {  
 
    if (transformed || nverts <= 0)  
      return;  
 
    if (tvert == null)  
      tvert = new int[nverts*3];  
 
    mat.transform(vert, tvert, nverts);  
    transformed = true;  
  }  
 
 
/**  
 *  The quick sort algorithm in this method is used for sorting faces  
 *  from back to front by z depth values.  
 */  
 
  void qs(int left, int right) {  
 
    int i, j, x, y;  
 
    i = left; j = right;  
    x = face[findex[(left+right)/2]].zdepth;  
 
    do {  
 
      while (face[findex[i]].zdepth > x && i < right) i++;  
      while (x > face[findex[j]].zdepth && j > left) j--;  
 
      if (i <= j) {  
y = findex[i];  
findex[i] = findex[j];  
findex[j] = y;  
i++; j--;  
      }  
 
    } while (i <= j);  
 
    if (left < j) qs(left, j);  
    if (i < right) qs(i, right);  
 
  }  
 
 
/* Paint myself to the graphics context. */  
 
  void paint(Graphics g) {  
 
    if (vert == null || nverts <= 0)  
      return;  
 
    transform();  
 
    if (gr == null) { // allocate colors if  
// they haven't been  
      gr = new Color[nfaces]; // allocated already  
 
      for (int i = 0; i < nfaces; i++) {  
 
gr[i] = new Color(face[i].cr, face[i].cg, face[i].cb);  
 
      }  
 
    }  
 
/**  
 *  Calculate the average z depth of faces and use this to sort them.  
 *  This is called the "Painter's algorithm" and although it works in  
 *  some case, does *not* always provide a correct ordering. Sometimes  
 *  a correct ordering is impossible, especially in the case of mutually  
 *  overlapping polygons.  
 */  
 
    for (int i = 0; i < nfaces; i++) {  
 
      face[i].zdepth = 0;  
 
      for (int c = 0; c < face[i].nverts; c++) {  
 
if (face[i].zdepth < tvert[face[i].index[c]+2])  
  face[i].zdepth = tvert[face[i].index[c]+2];  
      }  
 
    }  
 
    qs(0, nfaces-1); // quick sort the faces  
 
    for (int f = 0; f < nfaces; f++) {  
 
      int i = findex[f];  
      int v = 0;  
 
      for (int c = 0; c < face[i].nverts; c++) {  
vx[c] = tvert[face[i].index[c]];  
vy[c] = tvert[face[i].index[c]+1];  
      }  
 
      g.setColor(gr[i]);  
      g.fillPolygon(vx, vy, face[i].nverts); // draw each face  
 
      g.setColor(Color.black);  
 
      for (v = 0; v < (face[i].nverts-1); v++) {  
g.drawLine(vx[v], vy[v], vx[v+1], vy[v+1]); // draw the face edges  
      }  
 
      g.drawLine(vx[v], vy[v], vx[0], vy[0]);  
 
    }  
 
  }  
 
/* calculate the bounding box of our object: */  
 
  void findBB() {  
    if (nverts <= 0)  
      return;  
 
    float v[] = vert;  
    float xmin = v[0], xmax = xmin;  
    float ymin = v[1], ymax = ymin;  
    float zmin = v[2], zmax = zmin;  
 
    for (int i = nverts * 3; (i -= 3) > 0;) {  
 
      float x = v[i];  
      if (x < xmin)  
xmin = x;  
      if (x > xmax)  
xmax = x;  
      float y = v[i + 1];  
      if (y < ymin)  
ymin = y;  
      if (y > ymax)  
ymax = y;  
      float z = v[i + 2];  
      if (z < zmin)  
zmin = z;  
      if (z > zmax)  
zmax = z;  
 
    }  
 
    this.xmax = xmax;  
    this.xmin = xmin;  
    this.ymax = ymax;  
    this.ymin = ymin;  
    this.zmax = zmax;  
    this.zmin = zmin;  
 
  }  
 
}  
 
 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色狠狠一区二区| 一区二区三区欧美在线观看| 一区二区三区四区精品在线视频| 国产在线视频不卡二| 日韩亚洲欧美在线观看| 亚洲成人激情av| 欧美一区二区视频在线观看2020| 成人欧美一区二区三区黑人麻豆| 国产精品亚洲成人| 精品日韩一区二区三区| 日本不卡视频在线| 欧美亚洲一区二区在线观看| 国产欧美视频在线观看| 风流少妇一区二区| 中文字幕在线观看不卡| av激情成人网| 夜夜亚洲天天久久| 在线看国产一区二区| 国产精品乱人伦中文| 成人性生交大片| 视频在线观看91| 在线一区二区三区四区| 日韩精品乱码av一区二区| 日韩三级高清在线| 成人av在线观| 日韩电影在线观看网站| 中文av字幕一区| 欧美日韩国产一区二区三区地区| 成年人国产精品| 亚洲va欧美va人人爽午夜| 日韩一区二区麻豆国产| 国产一区视频在线看| 亚洲欧洲精品天堂一级 | 国产精品久久毛片| 欧美日韩午夜精品| 国产一区二区三区观看| 亚洲444eee在线观看| 最近日韩中文字幕| 久久精品亚洲精品国产欧美| 欧美亚洲国产bt| 国产一区二区三区四| 日韩国产高清在线| 亚洲伊人伊色伊影伊综合网| 精品88久久久久88久久久| 色哟哟欧美精品| 久久精品理论片| 日韩精品91亚洲二区在线观看| 久久精品综合网| 91麻豆精品91久久久久久清纯| 91视频com| 91久久精品一区二区| 欧美高清dvd| 日本高清视频一区二区| gogogo免费视频观看亚洲一| 国产美女主播视频一区| 精品一区二区三区在线观看国产| 老司机免费视频一区二区| 奇米精品一区二区三区在线观看| 亚洲国产aⅴ成人精品无吗| 综合av第一页| 亚洲成人一二三| 视频一区视频二区中文字幕| 亚洲国产sm捆绑调教视频 | 欧美日韩亚洲国产综合| 欧美优质美女网站| 日韩欧美国产一区在线观看| 欧美不卡123| 国产精品国产馆在线真实露脸| 国产精品妹子av| 亚洲精品视频在线观看网站| 欧美午夜精品久久久久久孕妇| 成人午夜电影久久影院| 成人国产精品免费观看| 99这里只有精品| 欧美丝袜丝交足nylons图片| 欧美一区国产二区| 久久综合网色—综合色88| 国产精品久久综合| 亚洲一区二区欧美日韩 | 中文字幕五月欧美| 一区二区欧美国产| 美国欧美日韩国产在线播放| 国产**成人网毛片九色| 精品视频在线免费| 久久美女高清视频| 亚洲国产精品麻豆| 国产成人av电影在线观看| 91女人视频在线观看| 日韩欧美亚洲一区二区| 国产精品久久久久久久第一福利| 亚洲va国产va欧美va观看| 国产麻豆视频一区二区| 在线一区二区三区| 久久久99精品免费观看不卡| 一区二区三区波多野结衣在线观看 | 国产精品资源在线| 欧美丝袜丝交足nylons图片| 国产网红主播福利一区二区| 亚洲国产综合在线| 成人免费视频视频在线观看免费 | 色av一区二区| 久久亚洲精品国产精品紫薇| 一区二区三区精品在线观看| 国内国产精品久久| 欧美三级日韩三级国产三级| 日本一区二区高清| 久久99精品视频| 日韩一级成人av| 亚洲国产成人av| 99国产精品一区| 久久免费视频色| 美女爽到高潮91| 欧美亚洲国产一区在线观看网站| 国产精品人妖ts系列视频| 麻豆久久一区二区| 欧美日韩国产免费一区二区| 亚洲私人影院在线观看| 懂色av中文字幕一区二区三区| 日韩欧美高清dvd碟片| 亚洲成在线观看| 在线视频欧美精品| 亚洲男人电影天堂| 99久久久精品免费观看国产蜜| 久久久久久久电影| 蜜臀久久99精品久久久久久9 | 国产日韩精品视频一区| 久88久久88久久久| 日韩三级av在线播放| 日韩精品一二三| 欧美日本一区二区在线观看| 亚洲宅男天堂在线观看无病毒| 99免费精品在线观看| 国产精品全国免费观看高清| 色婷婷综合久久久中文一区二区| 亚洲欧美在线观看| 国产精品福利av| 日韩不卡一区二区三区| 欧美裸体bbwbbwbbw| 亚洲一区二区在线视频| 色婷婷精品久久二区二区蜜臀av | 久久精品久久99精品久久| 欧美顶级少妇做爰| 天天色 色综合| 欧美日韩免费观看一区二区三区| 一片黄亚洲嫩模| 欧美日韩在线观看一区二区 | 蜜桃av一区二区| 日韩你懂的电影在线观看| 久久精品国产在热久久| 精品国产凹凸成av人导航| 国产自产2019最新不卡| 国产人妖乱国产精品人妖| 成人在线视频一区| 综合久久久久久| 欧美日韩中文国产| 久久激情五月激情| 久久久不卡网国产精品一区| 成人毛片在线观看| 一区二区高清免费观看影视大全| 在线免费不卡视频| 人人爽香蕉精品| 国产香蕉久久精品综合网| 成人av片在线观看| 亚洲国产精品久久一线不卡| 日韩女优av电影| av电影天堂一区二区在线| 亚洲一区二区在线视频| 日韩欧美自拍偷拍| 成人免费毛片片v| 亚洲国产成人av网| 午夜激情久久久| 精品免费一区二区三区| av影院午夜一区| 日韩国产高清在线| 中文字幕免费在线观看视频一区| 色综合色综合色综合色综合色综合 | 91.com视频| 丰满放荡岳乱妇91ww| 亚洲在线中文字幕| 久久久久久亚洲综合| 在线观看一区不卡| 国产一区二区成人久久免费影院| 亚洲三级久久久| 精品国产亚洲在线| 91黄色在线观看| 国产一区二区三区视频在线播放| 日韩美女精品在线| 日韩精品一区二区三区中文不卡 | 国产精品水嫩水嫩| 在线成人免费观看| 成人午夜电影久久影院| 日韩专区一卡二卡| 综合在线观看色| 久久这里只有精品视频网| 91国产免费看| 国产宾馆实践打屁股91| 日韩激情一二三区| 中文字幕在线播放不卡一区| 91精品在线麻豆| 91丨九色丨黑人外教|