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

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

?? cell.java

?? 使用Java3D編寫的生命棋游戲。可拖拽鼠標改變視角。
?? JAVA
字號:

// Cell.java
// Andrew Davison, July 2006, ad@fivedots.coe.psu.ac.th

/*  A cell is a coloured ball that may be 'alive' or 'dead'.
    When 'alive' the ball is visible, when 'dead' it's
    invisible. The cell also has an age which is gradually
    incremented from when it is born until it dies, and is
    reset to 0 if the cell is born again.

    CellsGrid can either change a cell's state or its visual
    appearance (its transparency or colour).

    When the cell's state changes from alive to dead it will switch
    it's visual state from VISIBLE to FADE_OUT. Subsequent visual
    changes by CellsGrid trigger a gradually fade out of the cell over 
    CellsGrid.MAX_TRANS updates until it switches its visual state
    from FADE_OUT to INVISIBLE.

    When the cell's state changes from dead to alive it will switch
    it's view state from INVISIBLE to FADE_IN. Subsequent visual
    changes by CellsGrid trigger a gradually fade in of the cell over 
    CellsGrid.MAX_TRANS updates until it switches its visual state
    from FADE_IN to VISIBLE.

    At certain ages the ball will change colour. A colour visual
    change is spread over CellsGrid.MAX_TRANS updates.
*/


import com.sun.j3d.utils.geometry.*;
import javax.media.j3d.*;
import javax.vecmath.*;


public class Cell
{
  // possible visual states for a cell
  private final static int INVISIBLE = 0;
  private final static int FADE_IN = 1;
  private final static int FADE_OUT = 2;
  private final static int VISIBLE = 3;

  // material colours
  private final static Color3f RED = new Color3f(1.0f, 0.0f, 0.0f);
  private final static Color3f ORANGE = new Color3f(1.0f, 0.5f, 0.0f);
  private final static Color3f YELLOW = new Color3f(1.0f, 1.0f, 0.0f);
  private final static Color3f GREEN = new Color3f(0.0f, 1.0f, 0.0f);
  private final static Color3f BLUE = new Color3f(0.0f, 0.0f, 1.0f);

  private final static Color3f BLACK = new Color3f(0.0f, 0.0f, 0.0f);
  private final static Color3f WHITE = new Color3f(0.9f, 0.9f, 0.9f);

  // length of cell side (== diameter when the cell is a ball)
  private final static float CELL_LEN = 0.5f;  

  // space between cells : a factor multiplied to CELL_LEN
  private final static float SPACING = 1.5f;

  // scene graph elements
  private TransformGroup cellTG;  

  // appearance elements
  private Appearance cellApp;
  private TransparencyAttributes transAtt;
  private Material material;
  private Color3f cellCol, oldCol, newCol;

  // cell state information
  private boolean isAlive, newAliveState;
  private int visualState;
  private int age = 0;
 


  public Cell(int x, int y, int z)
  /*  A cell is a shape below a TransformGroup which is used to
      position the cell in the cells grid. The scene branch is:
             cellTG --> cellShape --> Appearance
                                     {Material,Transparency}
  */
  { 
    isAlive = (Math.random() < 0.1) ? true : false;    
      // it's more likely that a cell is initially dead (invisible)

    // create appearance
    cellApp = new Appearance();
    makeMaterial();
    setVisibility();

    // the cell shape as a cube
    // Box cellShape = new Box( CELL_LEN/2, CELL_LEN/2, CELL_LEN/2, 
	//					Box.GENERATE_NORMALS, cellApp);

    // the cell chape as a sphere
    Sphere cellShape = new Sphere(CELL_LEN/2, Sphere.GENERATE_NORMALS, cellApp); 

    // fix cell's position
    Transform3D t3d = new Transform3D();
    double xPosn = x*CELL_LEN*SPACING; 
    double yPosn = y*CELL_LEN*SPACING; 
    double zPosn = z*CELL_LEN*SPACING; 
    t3d.setTranslation( new Vector3d(xPosn, yPosn, zPosn) );

    // build scene branch
    cellTG = new TransformGroup();
    cellTG.setTransform(t3d);
    cellTG.addChild(cellShape);
  }  // end of Cell()


  private void makeMaterial()
  /* Make a coloured material, which is originally blue. The
     ambient and diffuse components of the material can be changed
     at run time. */
  {
    cellCol = new Color3f();
    oldCol = new Color3f();
    newCol = new Color3f();

    // set material
    material = new Material(WHITE, BLACK, WHITE, WHITE, 100.f);
               // sets ambient, emissive, diffuse, specular, shininess

    material.setCapability(Material.ALLOW_COMPONENT_WRITE);
    material.setLightingEnable(true);
    resetColours();
    cellApp.setMaterial(material);
  }  // end of makeMaterial()


  private void resetColours()
  // intialization of the material's colour to blue
  {
    cellCol.set(BLUE);
    oldCol.set(cellCol);   // blue as well
    newCol.set(cellCol);

    setMatColours(cellCol);
  }  // end of resetColours()


  private void setMatColours(Color3f col)
  // the ambient colour is a darker shade of the diffuse colour
  {
    material.setAmbientColor(col.x/3.0f, col.y/3.0f, col.z/3.0f);
    material.setDiffuseColor(col);
  }  // end of setMatColours()


  private void setVisibility()
  /* A cell's transparency can change at run time, ranging from
     fully opaque when the cell is 'alive' to fully transparent
     when 'dead'. When the cell is coming to life or dieing, its
     transparency setting will be somewhere between these values. */
  {
    // let transparency value change at run time
    transAtt = new TransparencyAttributes();
    transAtt.setTransparencyMode(TransparencyAttributes.BLENDED);
    transAtt.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);

    if (isAlive) {
      visualState = VISIBLE;
      transAtt.setTransparency(0.0f);     // opaque
    }
    else  { // dead so invisible
      visualState = INVISIBLE;
      transAtt.setTransparency(1.0f);   // totally transparent
    }

    cellApp.setTransparencyAttributes(transAtt);
  }  // end of setVisibility()


  public TransformGroup getTG()
  // called by CellsGrid
  {  return cellTG;  }


  // ----------- get/set methods for cell's life ---------------------


  public boolean isAlive()
  {  return isAlive;  }

  public void newAliveState(boolean b)
  {  newAliveState = b;  } 


  // -------------------------- state update --------------------------

  public void updateState()
  /* If the cell is coming alive or dieing then its visual state
     must be altered, so it will fade into/out of view.

     If the cell's life state isn't changing, and it's alive,
     then it's colour may change if it's old enough.
  */
  {
    if (isAlive != newAliveState) {  // there's a state change
      if (isAlive && !newAliveState)  // alive --> dead (die)
        visualState = FADE_OUT;   // from VISIBLE      
      else {  // dead --> alive (birth)
        visualState = FADE_IN;    // from INVISIBLE
        age = 0;    // reset age since born again
        resetColours();
      }
    }
    else { // current and new states are the same
      if (isAlive) {   // cell stays alive (survives)
        age++;   // get older
        ageSetColour();
      }
    }
  }  // end of updateState()


  private void ageSetColour()
  // hardwired age values for setting the cell's new colour
  {
    if (age > 16)
      newCol.set(RED);
    else if (age > 8)
      newCol.set(ORANGE);
    else if (age > 4)
      newCol.set(YELLOW);
    else if (age > 2)
      newCol.set(GREEN);
    else
      newCol.set(BLUE);
  }  // end of ageSetColour()


  // -------------------------- visual update --------------------------

  public void visualChange(int transCounter)
  /* A cell is in one of the folowing visual states:
      * FADE_OUT, where the cell gradually disappears;
      * FADE_IN, where the cell gradually apppears;
      * VISIBLE, where the cell's colour may gradually change;
      * INVISIBLE, where nothing happens to the cell's appearance.
  */
  {
    float transFrac = ((float)transCounter)/CellsGrid.MAX_TRANS;

    if(visualState == FADE_OUT) 
      transAtt.setTransparency(transFrac);  // 1.0f is totally transparent   
    else if (visualState == FADE_IN)
      transAtt.setTransparency(1.0f-transFrac);
    else if (visualState == VISIBLE) 
      changeColour(transFrac);
    else if (visualState == INVISIBLE) {}
      // do nothing
    else
      System.out.println("Error in visualState");

    if (transCounter == CellsGrid.MAX_TRANS)
      endVisualTransition();
  }  // end of visualChange()


  private void changeColour(float transFrac)
  /* the current cell's colour is a mix of its old and
     new colours (if the two are different) */
  {
    if (!oldCol.equals(newCol)) {  // if colours are different
      float redFrac = oldCol.x*(1.0f-transFrac) + newCol.x*transFrac;
      float greenFrac = oldCol.y*(1.0f-transFrac) + newCol.y*transFrac;
      float blueFrac = oldCol.z*(1.0f-transFrac) + newCol.z*transFrac;

      cellCol.set(redFrac, greenFrac, blueFrac);
      setMatColours(cellCol);
    }
  }  // end of changeColour()


  private void endVisualTransition()
  /* At the end of a transition, the final colour is
     stored, the new cell's life state is stored, and
     the visual state is changed to VISIBLE or INVISIBLE.
  */
  {
    // store current colour as both the old and new colours;
    // used when fading in and when visible
    oldCol.set(cellCol);
    newCol.set(cellCol);

    isAlive = newAliveState;   // update alive state

    if (visualState == FADE_IN)
      visualState = VISIBLE;
    else if (visualState == FADE_OUT)
      visualState = INVISIBLE;
  }  // end of endVisualTransition()


}  // end of Cell class

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久久久影院色老大| 国产精品乱码人人做人人爱| 91蜜桃在线观看| 日本韩国欧美三级| 精品国产百合女同互慰| 日韩av午夜在线观看| 欧美一级电影网站| 亚洲人成精品久久久久| 日本韩国欧美一区| 欧美韩日一区二区三区四区| 成人免费精品视频| 久久久久国产精品麻豆| 国产91清纯白嫩初高中在线观看 | 久久综合色鬼综合色| 欧美日韩在线三区| 日本一道高清亚洲日美韩| 懂色av一区二区夜夜嗨| 亚洲欧美日韩人成在线播放| 欧美男人的天堂一二区| 久久99在线观看| 国产欧美日韩三区| 欧美视频你懂的| 成人免费一区二区三区视频 | 激情五月播播久久久精品| 久久久久久久久久久黄色 | 欧美做爰猛烈大尺度电影无法无天| 亚洲国产成人av| 久久日韩精品一区二区五区| av在线播放成人| 日韩精品一区二区三区四区视频 | 成人av网站大全| 欧美r级电影在线观看| 国产v日产∨综合v精品视频| 亚洲第一综合色| 欧美女孩性生活视频| 国产精品亚洲视频| 亚洲成人在线观看视频| 久久久久久毛片| 国产伦精品一区二区三区免费| 国产精品久久夜| 99精品热视频| 韩国三级电影一区二区| 亚洲一区二区欧美| 国产欧美精品一区| av网站免费线看精品| 久久国产人妖系列| 亚洲无人区一区| 亚洲欧洲国产日本综合| 成人国产视频在线观看| 久久国产尿小便嘘嘘尿| 久久久久久久久久久久电影| 欧美日韩三级视频| 日韩av一区二区在线影视| 亚洲欧洲av色图| 久久久久国产精品厨房| 日韩三级免费观看| 欧美日韩的一区二区| 午夜免费欧美电影| 亚洲免费高清视频在线| 欧美精品xxxxbbbb| 在线亚洲一区二区| 处破女av一区二区| 亚洲素人一区二区| 欧美精品一二三四| 国产在线播放一区| 美女一区二区视频| 午夜精品123| 国产欧美日韩卡一| 精品电影一区二区三区| 欧美一卡二卡三卡| 国产·精品毛片| 国产精品18久久久| 国产综合久久久久久鬼色 | 国产一区二区h| 亚洲精品一二三四区| 中文字幕一区在线| 91精品蜜臀在线一区尤物| 欧美日韩国产不卡| 国产成人免费视频网站高清观看视频| 极品瑜伽女神91| 亚洲黄色在线视频| 欧美日韩国产一二三| 欧美日韩电影在线播放| 蜜桃久久久久久久| 久久99热狠狠色一区二区| 久久成人综合网| 国产一区二区美女| 亚洲伦理在线免费看| 亚洲综合久久av| 天天免费综合色| 一本色道久久综合精品竹菊| 国产成人在线免费| 国产精品福利影院| 日韩电影免费在线观看网站| 亚洲精品视频在线观看网站| 性久久久久久久| 亚洲国产精华液网站w| ...av二区三区久久精品| 亚洲一区二区在线视频| 另类调教123区 | 亚洲另类春色校园小说| 亚洲国产日日夜夜| 精品一区二区三区香蕉蜜桃| 丁香天五香天堂综合| 欧洲另类一二三四区| av不卡一区二区三区| 欧美三级资源在线| 久久亚洲欧美国产精品乐播| 666欧美在线视频| 欧美色窝79yyyycom| 日韩免费一区二区| 欧美精品xxxxbbbb| 久久精品视频免费| 夜夜精品浪潮av一区二区三区| 日韩成人伦理电影在线观看| 国产电影一区在线| 日本大香伊一区二区三区| 日韩欧美在线综合网| 欧美片网站yy| 欧美日韩午夜在线视频| 欧美视频一区在线| 国产亚洲综合性久久久影院| 一区二区三区四区精品在线视频| 久久蜜桃香蕉精品一区二区三区| 自拍偷拍国产精品| 久久国内精品自在自线400部| 久久精品国产精品青草| 97久久超碰精品国产| 日韩一区二区三区免费看 | 一区二区三区 在线观看视频| 国产精品二区一区二区aⅴ污介绍| 欧美国产乱子伦| 精品无人区卡一卡二卡三乱码免费卡 | 久久国产夜色精品鲁鲁99| 一区二区三区欧美| 国产成人午夜99999| 日韩成人免费在线| av资源网一区| 日本成人中文字幕| 成a人片亚洲日本久久| 91在线免费看| 在线观看日韩精品| 色先锋久久av资源部| 久久精子c满五个校花| 青青草91视频| 免费成人深夜小野草| 日本高清不卡aⅴ免费网站| 欧美人牲a欧美精品| 亚洲人成影院在线观看| 亚洲精品国产一区二区三区四区在线 | 欧美日韩精品免费观看视频| 久久一区二区视频| 日本亚洲欧美天堂免费| 欧美性色欧美a在线播放| 亚洲天堂中文字幕| 午夜欧美在线一二页| 久久精品国产第一区二区三区| 欧美精品三级在线观看| 成人综合在线观看| 精品视频在线免费看| 中文字幕中文字幕一区二区| 国产精品久久久久久久久图文区| 精品一区二区三区视频在线观看| 在线成人av影院| 久久婷婷国产综合精品青草| 美国十次综合导航| 成人av网站在线观看| 欧美日韩大陆在线| 亚洲成人免费观看| 欧美乱熟臀69xxxxxx| 亚洲国产aⅴ天堂久久| 欧美美女黄视频| 久久久久亚洲蜜桃| 国产福利91精品一区| 国产清纯在线一区二区www| 丰满放荡岳乱妇91ww| 中文字幕制服丝袜一区二区三区| 丝袜美腿高跟呻吟高潮一区| 国产一区在线精品| 26uuu亚洲| 亚洲午夜av在线| 成人精品免费视频| 国产精品免费人成网站| 99国产精品久久| 精品国产一区二区三区忘忧草| 美女被吸乳得到大胸91| 色就色 综合激情| 亚洲国产wwwccc36天堂| 成人国产视频在线观看| 一区二区日韩av| 欧美一区国产二区| 激情五月婷婷综合| 国产精品美女久久久久久2018 | 蜜桃视频第一区免费观看| 精品不卡在线视频| 天堂在线一区二区| 久久亚洲精华国产精华液 | 日本一区二区高清| 美女爽到高潮91| 国产精品美女久久久久久|