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

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

?? propmanager.java

?? java 3D
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:

// PropManager.java
// Andrew Davison, April 2005, ad@fivedots.coe.psu.ac.th

/* The user supplies the name of a 3D object file to be loaded.
   Its bounding sphere is automatically scaled to have a radius 
   of 1 unit, and rotated -90 around x-axis if it is a 3ds model.

   A large range of different 3D object formats can be loaded
   since we are using the Portfolio loaders.

   Once loaded, the image can be moved and rotated along the
   X, Y, and Z axes, and scaled. The resulting position, 
   rotation, and scaling information can be stored in a 
   'coords' file (which has the same name as the 3D file
   + "Coords.txt").

   The rotation information is stored as a series of rotation
   *numbers* which must be executed in order to get to the curent
   overall rotation:
      1 = positive ROT_INCR around x-axis
      2 = negative ROT_INCR around x-axis

      3 = positive ROT_INCR around y-axis
      4 = negative ROT_INCR around y-axis

      5 = positive ROT_INCR around z-axis
      6 = negative ROT_INCR around z-axis

   This approach is used to try to avoid the problem that a mix of
   rotations about diffrent axes do not produce the same result if
   carried out in different orders.

   The coordinates information can be loaded along with the object
   by using:
		java Loader3D -c <3D filename>

   The loaded object is hung off several TGs, and the top one can be
   accessed by calling getTG().

   Changes:
   - removed use of j3d-fly VRML loader and starfire 3DS loader
*/

import java.util.*;
import java.io.*;
import java.text.DecimalFormat;

import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.loaders.*;

// Portfolio loader packages
import ncsa.j3d.*;
import ncsa.j3d.loaders.*;


public class PropManager
{
  // for specifying moves and rotations
  private static final int X_AXIS = 0;
  private static final int Y_AXIS = 1;
  private static final int Z_AXIS = 2;
  private static final int INCR = 0;
  private static final int DECR = 1;

  private static final double MOVE_INCR = 0.1;   // move increment for an object
  private static final double ROT_INCR = 10;     // rotation increment (in degrees)
  private static final double ROT_AMT = Math.toRadians(ROT_INCR);    // in radians


  // TGs which the loaded object (the prop) hangs off: 
  //       moveTG-->rotTG-->scaleTG-->objBoundsTG-->obj
  private TransformGroup moveTG, rotTG, scaleTG;    
  private Transform3D t3d;           // for accessing a TG's transform
  private Transform3D chgT3d;        // holds current change to the posn, rot, or scale

  private String filename;           // of loaded object
  private double xRot, yRot, zRot;   // total of rotation angles carried out
  private ArrayList rotInfo;         // stores the sequence of rotation numbers 
  private double scale;              // current object scaling

  private DecimalFormat df;    // for debugging


  public PropManager(String loadFnm, boolean hasCoordsInfo)
  {
    filename = loadFnm;
    xRot = 0.0; yRot = 0.0; zRot = 0.0;    // initial loaded object settings
    rotInfo = new ArrayList();
    scale = 1.0;

    t3d = new Transform3D();     // setup reusable Transform3D objects
    chgT3d = new Transform3D();

    df = new DecimalFormat("0.###");  // 3 dp

    loadFile(loadFnm);
    if (hasCoordsInfo)     // load in coords info also
      getFileCoords(loadFnm);
  }  // end of PropManager()



  private void loadFile(String fnm)
  /* The 3D object file is loaded using a Portfolio loader.

     The loaded object has 4 transform groups above it -- objBoundsTG is
     for adjusting the object's bounded sphere so it is centered at
     (0,0,0) and has unit radius. 

     The other TGs are for doing separate moves, rotations, and scaling
     of the object.
        moveTG-->rotTG-->scaleTG-->objBoundsTG-->object
  */
  { System.out.println("Loading object file: models/" + fnm);

	Scene s = null;
    ModelLoader modelLoader = new ModelLoader();
	try {
	  s = modelLoader.load("models/"+fnm);   // handles many types of file
	}
	catch (Exception e) {
	  System.err.println(e);
	  System.exit(1);
	}

    // get the branch group for the loaded object
    BranchGroup sceneGroup = s.getSceneGroup();

    // create a transform group for the object's bounding sphere
    TransformGroup objBoundsTG = new TransformGroup();
    objBoundsTG.addChild( sceneGroup );

    // resize loaded object's bounding sphere (and maybe rotate)
    String ext = getExtension(fnm);
    BoundingSphere objBounds = (BoundingSphere) sceneGroup.getBounds();
    setBSPosn(objBoundsTG, objBounds.getRadius(), ext);

    // create a transform group for scaling the object
    scaleTG = new TransformGroup();
    scaleTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    scaleTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    scaleTG.addChild( objBoundsTG );

    // create a transform group for rotating the object
    rotTG = new TransformGroup();
    rotTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    rotTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    rotTG.addChild( scaleTG );

    // create a transform group for moving the object
    moveTG = new TransformGroup();
    moveTG.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    moveTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    moveTG.addChild( rotTG );

  } // end of loadFile()


  private String getExtension(String fnm)
  // return the extension of fnm, or "(none)"
  {
    int dotposn = fnm.lastIndexOf(".");
    if (dotposn == -1)  // no extension
      return "(none)";
    else
      return fnm.substring(dotposn+1).toLowerCase();
  }


  private void setBSPosn(TransformGroup objBoundsTG, 
					double radius, String ext)
  // Scale the object to unit radius, and rotate -90 around x-axis if the
  // file contains a 3ds model
  {
    Transform3D objectTrans = new Transform3D();
    objBoundsTG.getTransform( objectTrans );

    // System.out.println("radius: " + df.format(radius));

    // scale the object so its bounds are within a 1 unit radius sphere
    Transform3D scaleTrans = new Transform3D();
    double scaleFactor = 1.0/radius;
    // System.out.println("scaleFactor: " + df.format(scaleFactor) );
    scaleTrans.setScale( scaleFactor );

    // final transform = [original] * [scale] (and possible *[rotate])
    objectTrans.mul(scaleTrans);
    
    if (ext.equals("3ds")) {   // the file is a 3ds model
      // System.out.println("Rotating -90 around x-axis");
      Transform3D rotTrans = new Transform3D();
      rotTrans.rotX( -Math.PI/2.0 );    // 3ds models are often on their face; fix that
      objectTrans.mul(rotTrans);
    }

    objBoundsTG.setTransform(objectTrans);
  } // end of setBSPosn()


  public TransformGroup getTG()
  // used by WrapLoader3D to add object to 3D world
  {  return moveTG; }


  // ----------------------------------------------------------------
  // obtain coords file info and apply it to the loaded object


  private void getFileCoords(String fnm)
  /* Obtain coords info from the coordinates file for fnm.
     The coords file has the format:
         <3D object fnm>
         [-p px py pz]
         [-r sequence of numbers]
         [-s scale]
  */
  { 
    String coordFile = "models/" + getName(fnm) + "Coords.txt";
    try {
      BufferedReader br = new BufferedReader( new FileReader(coordFile));
      br.readLine();    // skip fnm line (we know this already)
      String line;
      char ch;
      while((line = br.readLine()) != null) {
        ch = line.charAt(1);
        if (ch == 'p')
          setCurrentPosn(line);
        else if (ch == 'r')
          setCurrentRotation(line);
        else if (ch == 's')
          setCurrentScale(line);
        else
          System.out.println(coordFile + ": did not recognise line: " + line);
      }
      br.close();
      System.out.println("Read in coords file: " + coordFile);
    } 
    catch (IOException e) 
    { System.out.println("Error reading coords file: " + coordFile);
      System.exit(1);
    }
  }  // end of getFileCoords()



  private String getName(String fnm)
  // extract name before the final '.' suffix
  {
    int dotposn = fnm.lastIndexOf(".");
    if (dotposn == -1)  // no extension
      return fnm;
    else
      return fnm.substring(0, dotposn);
  }


  private void setCurrentPosn(String line)
  // extract the (x,y,z) position info from the coords file,
  // then apply it to the loaded object
  {
    double vals[] = new double[3];            // for the position data
    vals[0] = 0; vals[1] = 0; vals[2] = 0;    // represents (x,y,z)

    StringTokenizer tokens = new StringTokenizer(line);
    String token = tokens.nextToken();    // skip command label
    int count = 0;
    while (tokens.hasMoreTokens()) {
      token = tokens.nextToken();
      try {
        vals[count] = Double.parseDouble(token);
        count++;
      }
      catch (NumberFormatException ex){ 
        System.out.println("Incorrect format for position data in coords file"); 
        break;
      }

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
波多野结衣的一区二区三区| 欧美激情在线免费观看| 国产亚洲一区二区在线观看| 亚洲区小说区图片区qvod| 久久99精品久久久久久国产越南 | 欧美一区二区私人影院日本| 中文字幕精品一区二区三区精品| 天堂资源在线中文精品| 91啦中文在线观看| 久久久99精品免费观看不卡| 日韩黄色免费电影| 欧美性受xxxx| 亚洲欧美日韩久久| 不卡电影一区二区三区| 久久久一区二区三区捆绑**| 麻豆一区二区三| 欧美一区二区视频观看视频 | 韩国欧美国产一区| 欧美精品视频www在线观看| 中文字幕亚洲在| 国产成人午夜高潮毛片| 日韩精品一区二区三区中文精品| 天天影视网天天综合色在线播放| 欧美色视频一区| 亚洲一区二区三区自拍| 91麻豆免费在线观看| 国产精品久久久久久久久久免费看 | 亚洲第一狼人社区| 在线观看日韩电影| 亚洲精品国产a| 欧日韩精品视频| 亚洲综合视频在线观看| 日本韩国欧美在线| 亚洲夂夂婷婷色拍ww47| 欧美三区在线视频| 日韩制服丝袜先锋影音| 在线视频国内自拍亚洲视频| 亚洲黄网站在线观看| 欧美日韩综合在线免费观看| 亚洲成人久久影院| 欧美大肚乱孕交hd孕妇| 国模无码大尺度一区二区三区| 精品国产网站在线观看| 国产一区二区在线视频| 欧美激情资源网| 91久久国产综合久久| 亚洲一区av在线| 欧美伦理视频网站| 久久国产综合精品| 国产情人综合久久777777| av不卡免费在线观看| 亚洲一级片在线观看| 欧美一区二区三区免费| 日本亚洲天堂网| 欧美国产精品专区| 色噜噜狠狠成人网p站| 午夜激情一区二区| 久久久久青草大香线综合精品| 99视频一区二区三区| 亚洲国产成人va在线观看天堂| 日韩欧美色电影| 99久久久无码国产精品| 五月天网站亚洲| 国产欧美日韩一区二区三区在线观看| 岛国一区二区三区| 亚洲风情在线资源站| 欧美精品一区二区三区蜜桃| 成人动漫视频在线| 蜜桃视频一区二区三区在线观看| 欧美韩国日本一区| 6080国产精品一区二区| 国产成人激情av| 亚洲电影一级黄| 久久精品日韩一区二区三区| 色婷婷av一区二区三区软件| 麻豆精品视频在线观看免费| 国产精品免费视频观看| 91精品国产一区二区人妖| 成人激情综合网站| 久久国产乱子精品免费女| 亚洲丝袜另类动漫二区| 欧美v国产在线一区二区三区| 成人短视频下载| 九九精品一区二区| 亚洲午夜一区二区| 亚洲欧美自拍偷拍| 久久中文娱乐网| 欧美日韩精品二区第二页| 国产69精品久久777的优势| 日日噜噜夜夜狠狠视频欧美人| 亚洲欧洲99久久| 欧美国产日韩a欧美在线观看| 欧美一区二区免费视频| 色综合久久综合网欧美综合网| 经典三级视频一区| 日韩电影在线一区| 亚洲国产一区二区在线播放| 亚洲欧美偷拍三级| 国产精品久久久久永久免费观看| 日韩欧美国产系列| 欧美一二区视频| 欧美精品一卡二卡| 在线精品观看国产| 色成年激情久久综合| 成人黄色网址在线观看| 国产精品77777| 国模少妇一区二区三区| 麻豆成人av在线| 美女任你摸久久| 蜜乳av一区二区三区| 婷婷久久综合九色综合绿巨人 | 中文一区二区完整视频在线观看| 欧美成人性战久久| 日韩一本二本av| 日韩欧美一区中文| 欧美电影免费观看高清完整版在线观看 | 久久影院视频免费| 久久久亚洲精品石原莉奈| 久久老女人爱爱| 久久精品亚洲精品国产欧美kt∨| 久久蜜桃一区二区| 中文字幕欧美日韩一区| 国产精品色一区二区三区| 国产精品嫩草影院av蜜臀| 亚洲欧洲成人自拍| 亚洲一区二区偷拍精品| 天天综合日日夜夜精品| 麻豆91精品91久久久的内涵| 韩国精品久久久| eeuss影院一区二区三区| 色噜噜狠狠色综合欧洲selulu| 欧美日韩日日夜夜| 日韩免费成人网| 国产女人18水真多18精品一级做| 久久丝袜美腿综合| 亚洲精品国产a久久久久久| 爽好多水快深点欧美视频| 老司机午夜精品| 成人ar影院免费观看视频| 欧美色综合影院| 26uuu国产在线精品一区二区| 国产欧美精品一区二区三区四区| 一区二区三区精品在线| 日韩国产欧美在线视频| 国产福利一区二区三区| 欧美在线观看视频一区二区三区| 3atv在线一区二区三区| 国产日韩欧美精品一区| 亚洲123区在线观看| 国产麻豆欧美日韩一区| 欧美性猛交xxxx乱大交退制版| 久久亚洲影视婷婷| 又紧又大又爽精品一区二区| 九一九一国产精品| 欧美色区777第一页| 国产欧美日韩综合精品一区二区 | 国产精品视频线看| 午夜精品久久久久久久| 国产伦精品一区二区三区免费迷 | 国产欧美精品一区| 日韩黄色一级片| 国产欧美日韩另类视频免费观看| 国产精品一区专区| 色系网站成人免费| 欧美一级在线观看| 亚洲欧美成人一区二区三区| 麻豆精品视频在线观看视频| 一本到不卡免费一区二区| 精品国产青草久久久久福利| 亚洲精品视频免费看| 国产真实乱子伦精品视频| 欧美性大战久久| 成人免费在线播放视频| 国产一区福利在线| 欧美一区三区四区| 亚洲激情在线激情| 丁香亚洲综合激情啪啪综合| 日韩一区二区视频| 丝袜亚洲另类欧美综合| 欧洲精品视频在线观看| 亚洲免费观看视频| 成人免费毛片app| 久久久久久97三级| 狠狠色丁香久久婷婷综合丁香| 欧美日韩精品福利| 亚洲v中文字幕| 欧美亚洲另类激情小说| 亚洲精品国产视频| 91免费国产在线观看| 综合av第一页| 99久久免费视频.com| 中文字幕在线观看不卡| 成人免费视频一区| 国产欧美一区二区精品性色| 国产一区日韩二区欧美三区| 精品sm捆绑视频| 国产精品一级二级三级| 国产丝袜欧美中文另类| 国产一区二区三区黄视频 | 91久久精品日日躁夜夜躁欧美|