home *** CD-ROM | disk | FTP | other *** search
/ The Best of Windows 95.com 1996 September / WIN95_09962.iso / vrml / cp2b2x.exe / DATA.Z / bird.java < prev    next >
Text File  |  1996-06-21  |  2KB  |  81 lines

  1. /*-----------------------------------------------------------------------------
  2.  * Copyright(C) 1995,1996 Sony Corporation
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Sony Corporation;
  6.  * the contents of this file is not to be disclosed to third parties, copied
  7.  * or duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Sony Corporation.
  9.  *
  10.  * File:   bird.java
  11.  * Auther: sugino
  12.  *---------------------------------------------------------------------------*/
  13.  
  14. import vs.*;
  15. import vrml.*;
  16.  
  17. public class bird extends Script { 
  18.  
  19.     static String bodys[] = {
  20.     "models/bird0.wrl.gz",
  21.     "models/bird1.wrl.gz",
  22.     "models/bird2.wrl.gz",
  23.     "models/bird3.wrl.gz",
  24.     "models/bird4.wrl.gz"};
  25.     
  26.     SFBool enable = (SFBool) getEventOut("enable");
  27.  
  28.     Kinemation birds[];
  29.     float rotateArg[] = new float[4];
  30.     int birdMax ;
  31.  
  32.     public bird () {
  33.     
  34.     SFNode t ;
  35.     float f[] = new float[4];
  36.     birds = new Kinemation[5];
  37.     String[] s = new String[1];
  38.  
  39.     /* setup rotate argument */
  40.         rotateArg[0]=rotateArg[2]=0.0f;
  41.     rotateArg[1]=1.0f;
  42.     rotateArg[3]=2.0f;
  43.  
  44.  
  45.     f[1]=1.7f;
  46.  
  47.     for(int i=0;i<bodys.length;i++){
  48.         s[0] = bodys[i];
  49.         birds[i] = (Kinemation) Browser.createVrmlFromURL(s);
  50.         birds[i].translate(f,birds[i].modeRelative);
  51.         for(int j=0;j<20;j++){
  52.         rotate();
  53.         }
  54.     }
  55.     enable.setValue(true);
  56.     }
  57.  
  58.     void rotate(){
  59.     for (int i=0;i<bodys.length;i++){
  60.         if(null != birds[i]){
  61.         float nowf[] = 
  62.           birds[i].getWorldTranslation();
  63.         birds[i].worldRotateDegree(rotateArg, 
  64.                        birds[i].modeRelative); 
  65.         
  66.         birds[i].worldTranslate(nowf,birds[i].modeAbsolute);
  67.         birds[i].setNextPosture();
  68.         }
  69.     }
  70.     }
  71.  
  72.     public void fly(ConstSFTime t, ConstSFTime now){
  73.     rotate();
  74.     }
  75. }
  76.  
  77.     
  78.  
  79.  
  80.  
  81.