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

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

?? javashili.txt

?? javashili 摘自清華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一区二区三区免费野_久草精品视频
热久久一区二区| 欧美日韩在线综合| 欧美日韩在线三级| 欧美国产日本韩| 视频一区在线播放| 91性感美女视频| 久久综合九色欧美综合狠狠 | 久久综合九色综合久久久精品综合| 国产精品久久久久久久裸模| 久久精品99久久久| 欧美日韩电影一区| 亚洲精品va在线观看| 高清视频一区二区| 久久久无码精品亚洲日韩按摩| 亚洲一区二区免费视频| heyzo一本久久综合| 久久精品一区四区| 麻豆一区二区三区| 日韩一区二区三区视频在线观看| 洋洋成人永久网站入口| 99精品黄色片免费大全| 中文字幕av一区 二区| 国产精品一二三四| 国产夜色精品一区二区av| 九九久久精品视频| 精品日韩在线观看| 久色婷婷小香蕉久久| 91精品国产综合久久婷婷香蕉| 午夜国产精品一区| 欧美精品一卡两卡| 喷水一区二区三区| 日韩欧美久久久| 九九视频精品免费| 久久久久久毛片| 成人高清免费观看| 亚洲欧美国产77777| 91国产免费观看| 性做久久久久久免费观看欧美| 7777精品伊人久久久大香线蕉的 | 欧美日韩精品综合在线| 亚洲成人av免费| 日韩三级精品电影久久久| 青青草国产精品亚洲专区无| 精品日本一线二线三线不卡| 久草中文综合在线| 中文字幕日韩av资源站| 91成人在线精品| 欧美96一区二区免费视频| 欧美精品一区二区三区蜜臀| 国产成人综合网站| 亚洲欧美在线另类| 欧美日韩亚洲高清一区二区| 老汉av免费一区二区三区| 久久久久久久久久美女| 色综合中文字幕| 视频一区二区不卡| 国产欧美一区二区三区网站| 99久久免费国产| 日本中文字幕不卡| 国产精品系列在线| 欧美亚洲高清一区二区三区不卡| 天堂精品中文字幕在线| 久久网站最新地址| 欧美性极品少妇| 韩国欧美国产1区| 亚洲精品成人少妇| 久久尤物电影视频在线观看| 91久久免费观看| 精品午夜久久福利影院| 亚洲欧美一区二区久久| 日韩片之四级片| 91成人免费电影| 国产sm精品调教视频网站| 午夜精品一区在线观看| 欧美激情一区二区三区四区| 欧美乱妇15p| 不卡高清视频专区| 久久机这里只有精品| 亚洲精品国产成人久久av盗摄 | 中文字幕一区二区三区av| 欧美一区二区三区色| 色综合天天综合网天天狠天天| 国产又粗又猛又爽又黄91精品| 一区二区在线免费观看| 国产精品色噜噜| 欧美成人精精品一区二区频| 欧美日韩在线播放一区| 成人国产精品免费观看视频| 免费欧美在线视频| 午夜精品影院在线观看| 一区二区三区不卡在线观看| 国产午夜亚洲精品午夜鲁丝片| 91精品国产福利在线观看| 一本一本久久a久久精品综合麻豆| 国内精品写真在线观看| 日本伊人色综合网| 亚洲成人免费看| 一区二区三区产品免费精品久久75| 欧美国产乱子伦| 337p日本欧洲亚洲大胆色噜噜| 欧美人与性动xxxx| 欧美丝袜丝交足nylons图片| 99re在线精品| a在线播放不卡| 99国产麻豆精品| 99精品在线免费| 99视频在线观看一区三区| 国产精品一区二区久久不卡| 国产一区二区三区在线观看精品| 老司机一区二区| 国产一区二区三区最好精华液| 免费高清不卡av| 精品一区二区三区视频在线观看| 免费成人在线网站| 另类成人小视频在线| 精品一区二区久久久| 韩国精品久久久| 欧美日韩亚洲综合| 欧美精品一卡两卡| 欧美一级理论性理论a| 日韩欧美一区中文| 久久亚洲综合色一区二区三区| 久久午夜国产精品| 国产精品美女久久久久久久| 国产精品久久久99| 一区二区三区四区在线播放| 亚洲成av人影院| 久久精品久久99精品久久| 九九九精品视频| 高清不卡一二三区| 在线免费亚洲电影| 91精品欧美一区二区三区综合在| 精品第一国产综合精品aⅴ| 亚洲国产精品av| 亚洲影院在线观看| 蜜桃在线一区二区三区| 大尺度一区二区| 99久久精品免费看| 欧美男生操女生| 国产日产亚洲精品系列| 亚洲另类中文字| 久久爱www久久做| 99免费精品视频| 欧美一卡二卡三卡| 国产精品你懂的| 日韩精品欧美精品| 成人sese在线| 日韩一区二区三区高清免费看看| 久久精品亚洲一区二区三区浴池| 亚洲色图视频免费播放| 久久成人羞羞网站| 色哟哟亚洲精品| 久久久久久久综合色一本| 亚洲成人免费看| 波多野洁衣一区| 精品国产露脸精彩对白 | 在线中文字幕一区| 日韩一区二区视频| 亚洲欧美日本韩国| 精品在线播放免费| 在线日韩国产精品| 久久久天堂av| 秋霞影院一区二区| 欧美性受xxxx黑人xyx性爽| 久久综合久久久久88| 午夜激情一区二区| 色综合久久久久综合体| 久久久久久久久久美女| 水蜜桃久久夜色精品一区的特点| 91丨九色丨黑人外教| 欧美精品一区二区三| 日韩精品午夜视频| 在线视频国内自拍亚洲视频| 久久精品人人做人人爽97| 天堂资源在线中文精品| 91女人视频在线观看| 国产精品私人影院| 精品一区二区三区的国产在线播放| 欧美性猛片aaaaaaa做受| 亚洲精品综合在线| 成人h版在线观看| 国产女主播一区| 国产乱理伦片在线观看夜一区| 日韩免费高清电影| 五月天一区二区三区| 色狠狠综合天天综合综合| 中文字幕一区二区三区在线播放| 国产电影一区二区三区| 欧美精品一区二区三区一线天视频| 日韩电影在线一区二区三区| 欧美视频完全免费看| 夜夜嗨av一区二区三区中文字幕 | 亚洲视频一区在线| av电影在线观看完整版一区二区| 欧美高清在线一区二区| 懂色av一区二区三区免费看| 国产精品色婷婷久久58| 成人精品免费看| 日韩理论片一区二区| 91成人免费在线视频|