home *** CD-ROM | disk | FTP | other *** search
/ Sony Community Place / circus2e.exe / DATA.Z / circus.java < prev    next >
Text File  |  1996-09-25  |  40KB  |  1,541 lines

  1. /*
  2.  *    File    : circus.java (Circus Park 2 for Community Place)
  3.  *    Version : 2.0- 1996.09.10
  4.  *    Auther  : cori co.
  5.  *
  6.  *    Copyright(C) 1996 Sony Corporation. All rights reserved.
  7.  */
  8.  
  9. import vrml.*;
  10. import vrml.field.*;
  11. import vrml.node.*;
  12. import java.util.*;
  13. import vs.*;
  14.  
  15. public class circus extends Script {
  16.  
  17.     static int X = 0;
  18.     static int Y = 1;
  19.     static int Z = 2;
  20.     static int DEGREE = 3;
  21.     static int R = 0;
  22.     static int G = 1;
  23.     static int B = 2;
  24.  
  25.     float Radian = 180.0f / (float)Math.PI;
  26.  
  27.     /* Node */
  28.     SFNode WorldNode;
  29.  
  30.     /* World */
  31.     SFBool        WorldTimer;
  32.     MFColor        WorldSkyCol;
  33.     SFInt32        WorldLightSwitch;
  34.     //SFVec3f    RocketmanPos;
  35.     SFRotation    AirShipRot;
  36.  
  37.     /* Ferris */
  38.     SFColor        FerrisRideCol;
  39.     SFVec3f        FerrisRidePos;
  40.     SFVec3f        FerrisExitPos;
  41.     SFVec3f        FerrisWheelPos;
  42.     SFRotation    FerrisWheelRot;
  43.  
  44.     SFVec3f        GondolaFloorPos;
  45.     SFVec3f        GondolaFencePos;
  46.     SFTime        GondolaSound_start;
  47.     SFTime        GondolaSound_stop;
  48.     SFRotation    GondolaRot[] = new SFRotation[10];
  49.     SFVec3f        GondolaPos[] = new SFVec3f[10];
  50.  
  51.     /* view point */
  52.     SFBool        GondolaViewBind;
  53.     SFRotation    GondolaViewRot;
  54.  
  55.     /* parade sound */
  56.     SFRotation    ParadeStageRot;
  57.     SFVec3f        ParadeSoundPos;
  58.     SFTime        ParadeSound_start;
  59.     SFTime        ParadeSound_stop;
  60.  
  61.     /* Piero1 with Accordion */
  62.     SFBool        Piero1Sw;
  63.     SFTime        Piero1StartTime;
  64.     SFTime        Piero1StopTime;
  65.     SFVec3f        Piero1Pos;
  66.     SFRotation    Piero1Rot;
  67.  
  68.     SFVec3f        AccordionPos;
  69.     SFVec3f        Accordion1Pos;
  70.     SFVec3f        Accordion2Pos;
  71.     SFRotation    AccordionRot;
  72.  
  73.     /* Piero2 with Barrel */
  74.     SFBool        Piero2Sw;
  75.     SFTime        Piero2StartTime;
  76.     SFTime        Piero2StopTime;
  77.     SFVec3f        Piero2Pos;
  78.     SFRotation    Piero2Rot;
  79.  
  80.     SFVec3f        BarrelPos;
  81.     SFRotation    BarrelRot;
  82.  
  83.     /* Piero3 taller */
  84.     SFBool        Piero3Sw;
  85.     SFTime        Piero3StartTime;
  86.     SFTime        Piero3StopTime;
  87.     SFVec3f        Piero3Pos;
  88.     SFRotation    Piero3Rot;
  89.  
  90.     /* Kuma */
  91.     SFBool        KumaSw;
  92.     SFTime        KumaStartTime;
  93.     SFTime        KumaStopTime;
  94.     SFVec3f        KumaPos;
  95.     SFRotation    KumaRot;
  96.  
  97.     SFBool        KumaBicycleSw;
  98.  
  99.     /* Ashika */
  100.     SFBool        AshikaSw;
  101.     SFTime        AshikaStartTime;
  102.     SFTime        AshikaStopTime;
  103.     SFVec3f        AshikaPos;
  104.     SFRotation    AshikaRot;
  105.  
  106.     SFBool        AshikaBallSw;
  107.     SFVec3f        AshikaBallPos;
  108.     SFRotation    AshikaBallRot;
  109.     SFTime        AshikaSound_start;
  110.     SFTime        AshikaSound_stop;
  111.  
  112.  
  113.     /* World Val */
  114.     boolean WorldConstructorInvoked = false;
  115.     int WorldSkyFlg = 0;
  116.     int ParadeFlg = 0;
  117.  
  118.     int CurrentTime = 60;            // 4:00 start sunrise
  119.     /*
  120.      * this 'time' counts up every second.
  121.      * one actual second is 1/15 virtual hour.
  122.      *   0 = 0:00 (reset)
  123.      *  60 = 4:00 (start sunrise)
  124.      * 120 = 8:00 (end sunrise)
  125.      * 240 = 16:00(start sunset)
  126.      * 300 = 20:00(end sunset)
  127.      * 360 = 24:00(wind up the counter)
  128.      */
  129.  
  130.     int EclipseCnt = 0;
  131.  
  132.     int sunriseStartTime = 60;
  133.     int sunriseMidStartTime = 70;
  134.     int sunriseMidEndTime = 70;
  135.     int sunriseEndTime = 120;
  136.     int sunsetStartTime = 240;
  137.     int sunsetMidStartTime = 250;
  138.     int sunsetMidEndTime = 250;
  139.     int sunsetEndTime = 300;
  140.  
  141.     float nightColorR = 0.1f;
  142.     float nightColorG = 0.1f;
  143.     float nightColorB = 0.35f;
  144.  
  145.     float sunriseColorR = 0.60f;
  146.     float sunriseColorG = 0.10f;
  147.     float sunriseColorB = 0.08f;
  148.  
  149.     float daylightColorR = 0.44f;
  150.     float daylightColorG = 0.49f;
  151.     float daylightColorB = 1.0f;
  152.  
  153.     float sunsetColorR = 0.60f;
  154.     float sunsetColorG = 0.10f;
  155.     float sunsetColorB = 0.08f;
  156.  
  157.     int        IllumiNo = 0;
  158.     int        IllumiCnt = 0;
  159.     float    IllumiR = 1.0f;
  160.     float    IllumiG = 1.0f;
  161.     float    IllumiB = 1.0f;
  162.  
  163.     /* Ferris Val */
  164.     boolean    FerrisRideColorSw = true;
  165.     float    FerrisWheelR = ( 28.5f - 6.0f );
  166.     float    FerrisWheelY = 28.5f;
  167.     float    FerrisRotateAngle = 0.0f;
  168.     int        RideGondolaNum = 0;
  169.     int        RidePerson = 0;
  170.     int        RideSeat = 0;
  171.  
  172.  
  173.     /* Piero val */
  174.     boolean    Piero1MoveFlg = false;
  175.     boolean    Piero2MoveFlg = false;
  176.     boolean    Piero3MoveFlg = false;
  177.     int        Piero1Cnt = 0;
  178.     int        Piero2Cnt = 0;
  179.     int        Piero3Cnt = 0;
  180.  
  181.     int        Piero2Dir = 0;
  182.     float    Piero2PosZ = 0.0f;
  183.     float    Piero2RotD = 0.0f;
  184.  
  185.     /* Ashika */
  186.     boolean AshikaMoveFlg = false;
  187.     int        AshikaCnt = 0;            /* current position */
  188.     int        AshikaMode = 0;            /* current mode */
  189.     float    AshikaBallRotX = 0.0f;
  190.     float    AshikaBallRotZ = 0.0f;
  191.     float    AshikaBallData1[][] = {    /* original position <-> ashika */
  192.         {38.4f,0.4f},
  193.         {38.1f,0.9f},
  194.         {37.8f,1.25f},
  195.         {37.5f,1.5f},
  196.         {37.2f,1.6f},
  197.         {36.9f,1.8f},
  198.         {36.6f,1.9f},
  199.         {36.3f,1.9f},
  200.         {36.0f,1.8f},
  201.         {35.7f,1.6f},
  202.     };
  203.     float    AshikaBallData2[] = {    /* on the ashika */
  204.         1.6f,1.7f,1.8f,1.9f,2.0f,2.0f,1.9f,1.8f,1.7f,1.6f
  205.     };
  206.  
  207.     /* Kuma 8 */
  208.     boolean KumaMoveFlg = false;
  209.     float    KumaAng = 0.0f;
  210.     int        KumaCnt = 0;
  211.  
  212.     public void initialize() {
  213.         WorldNode            = (SFNode)getField( "WorldNode" );
  214.  
  215.         /* World */
  216.         WorldTimer            = (SFBool) getEventOut( "WorldTimer_enabled" );
  217.         WorldSkyCol            = (MFColor) getEventOut( "WorldSky_color" );
  218.         WorldLightSwitch    = (SFInt32) getEventOut( "WorldLight_switch" );
  219.         //RocketmanPos        = (SFVec3f) getEventOut( "WorldRocketman_position" );
  220.         AirShipRot            = (SFRotation) getEventOut( "Airship_rotation" );
  221.  
  222.         /* Ferris */
  223.         FerrisRideCol        = (SFColor) getEventOut( "FerrisRide_color" );
  224.         FerrisRidePos        = (SFVec3f) getEventOut( "FerrisRide_position" );
  225.         FerrisExitPos        = (SFVec3f) getEventOut( "FerrisExit_position" );
  226.         FerrisWheelPos        = (SFVec3f) getEventOut( "FerrisWheel_position" );
  227.         FerrisWheelRot        = (SFRotation) getEventOut( "FerrisWheel_rotation" );
  228.  
  229.         GondolaFloorPos        = (SFVec3f) getEventOut( "GondolaFloor_position" );
  230.         GondolaFencePos        = (SFVec3f) getEventOut( "GondolaFence_position" );
  231.         GondolaSound_start    = (SFTime) getEventOut( "GondolaSound_start" );
  232.         GondolaSound_stop    = (SFTime) getEventOut( "GondolaSound_stop" );
  233.  
  234.         GondolaViewBind        = (SFBool) getEventOut( "GondolaView_bind" );            //// 1996.08.29
  235.         GondolaViewRot        = (SFRotation) getEventOut( "GondolaView_rotation" );    //// 1996.09.12h
  236.  
  237.         /* parade sound */
  238.         ParadeStageRot        = (SFRotation) getEventOut( "ParadeStage_rotation" );
  239.         ParadeSoundPos        = (SFVec3f) getEventOut( "ParadeSound_position" );
  240.         ParadeSound_start    = (SFTime) getEventOut( "ParadeSound_start" );
  241.         ParadeSound_stop    = (SFTime) getEventOut( "ParadeSound_stop" );
  242.  
  243.         /* Piero1 with Accordion */
  244.         Piero1Sw            = (SFBool) getEventOut( "Piero1_sw" );
  245.         Piero1StartTime        = (SFTime) getEventOut( "Piero1_start" );
  246.         Piero1StopTime        = (SFTime) getEventOut( "Piero1_stop" );
  247.         Piero1Pos            = (SFVec3f) getEventOut( "Piero1_position" );
  248.         Piero1Rot            = (SFRotation) getEventOut( "Piero1_rotation" );
  249.  
  250.         AccordionPos        = (SFVec3f) getEventOut( "Piero1Accordion_position" );
  251.         Accordion1Pos        = (SFVec3f) getEventOut( "Piero1Accordion1_position" );
  252.         Accordion2Pos        = (SFVec3f) getEventOut( "Piero1Accordion2_position" );
  253.         AccordionRot        = (SFRotation) getEventOut( "Piero1Accordion_rotation" );
  254.  
  255.         /* Piero2 with Barrel */
  256.         Piero2Sw            = (SFBool) getEventOut( "Piero2_sw" );
  257.         Piero2StartTime        = (SFTime) getEventOut( "Piero2_start" );
  258.         Piero2StopTime        = (SFTime) getEventOut( "Piero2_stop" );
  259.         Piero2Pos            = (SFVec3f) getEventOut( "Piero2_position" );
  260.         Piero2Rot            = (SFRotation) getEventOut( "Piero2_rotation" );
  261.  
  262.         BarrelPos            = (SFVec3f) getEventOut( "Piero2Barrel_position" );
  263.         BarrelRot            = (SFRotation) getEventOut( "Piero2Barrel_rotation" );
  264.  
  265.         /* Piero3 taller */
  266.         Piero3Sw            = (SFBool) getEventOut( "Piero3_sw" );
  267.         Piero3StartTime        = (SFTime) getEventOut( "Piero3_start" );
  268.         Piero3StopTime        = (SFTime) getEventOut( "Piero3_stop" );
  269.         Piero3Pos            = (SFVec3f) getEventOut( "Piero3_position" );
  270.         Piero3Rot            = (SFRotation) getEventOut( "Piero3_rotation" );
  271.  
  272.         /* Kuma */
  273.         KumaSw                = (SFBool) getEventOut( "Kuma_sw" );
  274.         KumaStartTime        = (SFTime) getEventOut( "Kuma_start" );
  275.         KumaStopTime        = (SFTime) getEventOut( "Kuma_stop" );
  276.         KumaPos                = (SFVec3f) getEventOut( "Kuma_position" );
  277.         KumaRot                = (SFRotation) getEventOut( "Kuma_rotation" );
  278.  
  279.         KumaBicycleSw        = (SFBool) getEventOut( "Kuma_bicycle_sw" );
  280.  
  281.         /* Ashika */
  282.         AshikaSw            = (SFBool) getEventOut( "Ashika_sw" );
  283.         AshikaStartTime        = (SFTime) getEventOut( "Ashika_start" );
  284.         AshikaStopTime        = (SFTime) getEventOut( "Ashika_stop" );
  285.         AshikaPos            = (SFVec3f) getEventOut( "Ashika_position" );
  286.         AshikaRot            = (SFRotation) getEventOut( "Ashika_rotation" );
  287.  
  288.         AshikaBallSw        = (SFBool) getEventOut( "AshikaBall_sw" );
  289.         AshikaBallPos        = (SFVec3f) getEventOut( "AshikaBall_position" );
  290.         AshikaBallRot        = (SFRotation) getEventOut( "AshikaBall_rotation" );
  291.         AshikaSound_start    = (SFTime) getEventOut( "AshikaSound_start" );
  292.         AshikaSound_stop    = (SFTime) getEventOut( "AshikaSound_stop" );
  293.  
  294.     }
  295.  
  296.  
  297.     public void processEvent(Event e) {
  298.         String name = e.getName();
  299.         double now = e.getTimeStamp();
  300.  
  301.         /* World */
  302.         if ( name.equals( "WorldMove" )) {
  303.             WorldMove( (ConstSFTime)e.getValue(), now );
  304.         } else if ( name.equals( "WorldSync" )) {
  305.             WorldSync( (ConstSFString)e.getValue(), now );
  306.         } else if ( name.equals( "ShareFerrisRotate" )) {
  307.             ShareFerrisRotate( (ConstSFString)e.getValue(), now );
  308.         } else if ( name.equals( "ShareRidePerson" )) {
  309.             ShareRidePerson( (ConstSFString)e.getValue(), now );
  310.         } else if ( name.equals( "ShareCurrentTime" )) {
  311.             ShareCurrentTime( (ConstSFString)e.getValue(), now );
  312.         } else if ( name.equals( "FerrisRide" )) {
  313.             FerrisRide( (ConstSFString)e.getValue(), now );
  314.         } else if ( name.equals( "EclipsePick" )) {
  315.             EclipsePick( (ConstSFBool)e.getValue(), now );
  316.         } else if ( name.equals( "EclipsePickShare" )) {
  317.             EclipsePickShare( (ConstSFString)e.getValue(), now );
  318.         
  319.         /* Ferris */
  320.         } else if ( name.equals( "FerrisRidePick" )) {
  321.             FerrisRidePick( (ConstSFBool)e.getValue(), now );
  322.         } else if ( name.equals( "FerrisExitPick" )) {
  323.             FerrisExitPick( (ConstSFBool)e.getValue(), now );
  324.         
  325.         /* Piero */
  326.         } else if ( name.equals( "Piero1PickShare" )) {
  327.             Piero1PickShare( (ConstSFString)e.getValue(), now );
  328.         } else if ( name.equals( "Piero1Pick" )) {
  329.             Piero1Pick( (ConstSFBool)e.getValue(), now );
  330.         } else if ( name.equals( "Piero2PickShare" )) {
  331.             Piero2PickShare( (ConstSFString)e.getValue(), now );
  332.         } else if ( name.equals( "Piero2Pick" )) {
  333.             Piero2Pick( (ConstSFBool)e.getValue(), now );
  334.         } else if ( name.equals( "Piero3PickShare" )) {
  335.             Piero3PickShare( (ConstSFString)e.getValue(), now );
  336.         } else if ( name.equals( "Piero3Pick" )) {
  337.             Piero3Pick( (ConstSFBool)e.getValue(), now );
  338.  
  339.         /* Ashika */
  340.         } else if ( name.equals( "AshikaPickShare" )) {
  341.             AshikaPickShare( (ConstSFString)e.getValue(), now );
  342.         } else if ( name.equals( "AshikaPick" )) {
  343.             AshikaPick( (ConstSFBool)e.getValue(), now );
  344.         } else if ( name.equals( "AshikaBallMove" )) {
  345.             AshikaBallMove( (ConstSFTime)e.getValue(), now );
  346.         } else if ( name.equals( "AshikaBallPickShare" )) {
  347.             AshikaBallPickShare( (ConstSFString)e.getValue(), now );
  348.         } else if ( name.equals( "AshikaBallPick" )) {
  349.             AshikaBallPick( (ConstSFBool)e.getValue(), now );
  350.         
  351.         /* Kuma */
  352.         } else if ( name.equals( "KumaPickShare" )) {
  353.             KumaPickShare( (ConstSFString)e.getValue(), now );
  354.         } else if ( name.equals( "KumaPick" )) {
  355.             KumaPick( (ConstSFBool)e.getValue(), now );
  356.         } else if ( name.equals( "KumaBicycleMove" )) {
  357.             KumaBicycleMove( (ConstSFTime)e.getValue(), now );
  358.  
  359.         } else {
  360.             ;
  361.         }
  362.     }
  363.  
  364.  
  365.     /* --------------------------------------------------------------- */
  366.  
  367.     /*
  368.      * notice: in the constructor, you cannot send events to other nodes
  369.      *         using ROUTEs.
  370.      */
  371.     void world_constructor ( double now ) {
  372.  
  373.         GondolaRot[0] = (SFRotation) getEventOut( "Gondola0_rotation" );
  374.         GondolaRot[1] = (SFRotation) getEventOut( "Gondola1_rotation" );
  375.         GondolaRot[2] = (SFRotation) getEventOut( "Gondola2_rotation" );
  376.         GondolaRot[3] = (SFRotation) getEventOut( "Gondola3_rotation" );
  377.         GondolaRot[4] = (SFRotation) getEventOut( "Gondola4_rotation" );
  378.         GondolaRot[5] = (SFRotation) getEventOut( "Gondola5_rotation" );
  379.         GondolaRot[6] = (SFRotation) getEventOut( "Gondola6_rotation" );
  380.         GondolaRot[7] = (SFRotation) getEventOut( "Gondola7_rotation" );
  381.  
  382.         GondolaPos[0] = (SFVec3f)getEventOut( "Gondola0_position" );
  383.         GondolaPos[1] = (SFVec3f)getEventOut( "Gondola1_position" );
  384.         GondolaPos[2] = (SFVec3f)getEventOut( "Gondola2_position" );
  385.         GondolaPos[3] = (SFVec3f)getEventOut( "Gondola3_position" );
  386.         GondolaPos[4] = (SFVec3f)getEventOut( "Gondola4_position" );
  387.         GondolaPos[5] = (SFVec3f)getEventOut( "Gondola5_position" );
  388.         GondolaPos[6] = (SFVec3f)getEventOut( "Gondola6_position" );
  389.         GondolaPos[7] = (SFVec3f)getEventOut( "Gondola7_position" );
  390.  
  391.         ShapePosInit();
  392.         if ( Vscp.amIMaster()) {
  393.             /* don't share */
  394.         } else {
  395.             Vscp.sendApplSpecificMsgWithDist( WorldNode, "WorldSync", "dummy", Vscp.responderOnly );
  396.         }
  397.     }
  398.  
  399.  
  400.     /*
  401.      * share WorldValue
  402.      */
  403.     public void WorldSync ( ConstSFString shared_data, double now ) {
  404.         String s;
  405.         
  406.         if ( Vscp.amIMaster()) {
  407.             s = String.valueOf( FerrisRotateAngle );
  408.             Vscp.sendApplSpecificMsgWithDist( WorldNode, "ShareFerrisRotate", s, Vscp.allClientsExceptMe );
  409.             s = String.valueOf( RidePerson );
  410.             Vscp.sendApplSpecificMsgWithDist( WorldNode, "ShareRidePerson", s, Vscp.allClientsExceptMe );
  411.             s = String.valueOf( CurrentTime );
  412.             Vscp.sendApplSpecificMsgWithDist( WorldNode, "ShareCurrentTime", s, Vscp.allClientsExceptMe );
  413.         }
  414.     }
  415.  
  416.  
  417.     /*
  418.      *
  419.      */
  420.     public void ShareFerrisRotate ( ConstSFString shared_data, double now ) {
  421.         String s;
  422.  
  423.         s = shared_data.getValue();
  424.         FerrisRotateAngle = Float.valueOf( s ).floatValue();
  425.  
  426.         FerrisMove( now );
  427.     }
  428.  
  429.  
  430.     /*
  431.      * set ride
  432.      */
  433.     public void ShareRidePerson ( ConstSFString shared_data, double now ) {
  434.         String s;
  435.  
  436.         // < set world valiable >
  437.         s = shared_data.getValue();
  438.         RidePerson = Integer.valueOf( s ).intValue();
  439.  
  440.     }
  441.  
  442.  
  443.     /*
  444.      * set CurrentTime
  445.      */
  446.     public void ShareCurrentTime ( ConstSFString shared_data, double now ) {
  447.         String s;
  448.  
  449.         s = shared_data.getValue();
  450.         CurrentTime = Integer.valueOf( s ).intValue();
  451.  
  452.     }
  453.  
  454.  
  455.     /*
  456.      *
  457.      */
  458.     public void WorldMove ( ConstSFTime t, double now ) {
  459.         String s;
  460.  
  461.         /* this function should be invoked only once at the first time! */
  462.         if(false == WorldConstructorInvoked){
  463.             WorldTimer.setValue( false );
  464.             world_constructor( now );
  465.             WorldConstructorInvoked = true;
  466.             WorldTimer.setValue( true );
  467.         }
  468.  
  469.         /* change the color */
  470.         FerrisRideColor();
  471.  
  472.         if (( CurrentTime & 1 ) == 0 ) {
  473.             FerrisMove( now );
  474.         }
  475.         
  476.         /* Airship rotation */
  477.         if (( CurrentTime & 3 ) == 2 ) {
  478.             AirshipMove( t, now );
  479.             if ( Vscp.amIMaster()) {    ////960906c test
  480.                 Vscp.sendApplSpecificMsgWithDist( WorldNode, "WorldSync", "dummy", Vscp.responderOnly );
  481.             }
  482.         }
  483.         
  484.         if ( EclipseCnt > 0 ) {
  485.             EclipseCnt--;
  486.             if ( EclipseCnt <= 0 ) {
  487.                 EclipseReset();
  488.             }
  489.         } else {
  490.             ChangeBgColor( t, now );
  491.         }
  492.  
  493.         if ( CurrentTime == 90 ) {
  494.             WorldLightSwitch.setValue( 0 );
  495.         } else if ( CurrentTime == 270 ) {
  496.             WorldLightSwitch.setValue( 1 );
  497.             ParadeInit( now );
  498.             ParadeFlg = 1;
  499.         }
  500.         if ( ParadeFlg == 1 ) {
  501.             if ( CurrentTime > 270 && CurrentTime < 330 ) {
  502.                 ParadeMove( t, now );
  503.             } else if ( CurrentTime == 330 ) {
  504.                 ParadeEnd( now );
  505.                 ParadeFlg = 0;
  506.             }
  507.         } else {
  508.             if ( Piero1MoveFlg == true )    Piero1Move();
  509.             if ( Piero2MoveFlg == true )    Piero2Move();
  510.         }
  511.  
  512.         /* count up */
  513.         CurrentTime++;
  514.         if ( CurrentTime >= 360 ) {
  515.             CurrentTime = 0;
  516.             if ( Vscp.amIMaster()) {
  517.                 Vscp.sendApplSpecificMsgWithDist( WorldNode, "WorldSync", "dummy", Vscp.responderOnly );
  518.             }
  519.         }
  520.     }
  521.  
  522.     /*
  523.      *
  524.      */
  525.     void    FerrisRideColor() {
  526.         float col[] = new float[3];
  527.         
  528.         if ( FerrisRideColorSw == true ) {
  529.             col[R] = 1.0f;    col[G] = 0.0f;    col[B] = 0.0f;
  530.             FerrisRideColorSw = false;
  531.         } else {
  532.             col[R] = 0.0f;    col[G] = 1.0f;    col[B] = 0.0f;
  533.             FerrisRideColorSw = true;
  534.         }
  535.         FerrisRideCol.setValue( col );
  536.     }
  537.  
  538.  
  539.     /*
  540.      * Solar Eclipse / turn off the light
  541.      */
  542.     public void EclipsePick ( ConstSFBool state, double now ) {
  543.         if (state.getValue()) return;    /* mouseDown */
  544.  
  545.         Vscp.sendApplSpecificMsgWithDist( WorldNode, "EclipsePickShare", "", Vscp.responderOnly );
  546.         EclipseStart();
  547.     }
  548.  
  549.  
  550.     /*
  551.      *
  552.      */
  553.     public void EclipsePickShare ( ConstSFString userdata, double now ) {
  554.  
  555.         if ( Vscp.amIMaster()) {
  556.             Vscp.sendApplSpecificMsgWithDist( WorldNode, "EclipsePickShare", "", Vscp.allClientsExceptMe );
  557.         }
  558.         EclipseStart();
  559.  
  560.     }
  561.  
  562.  
  563.     /*
  564.      *
  565.      */
  566.     public void EclipseStart () {
  567.         float[][] col = new float[1][3];
  568.  
  569.         col[0][R] = (float)0.0;
  570.         col[0][G] = (float)0.0;
  571.         col[0][B] = (float)0.0;
  572.         WorldSkyCol.setValue( col );
  573.         EclipseCnt = 10;
  574.     }
  575.  
  576.  
  577.     /*
  578.      *
  579.      */
  580.     public void EclipseReset () {
  581.  
  582.         if ( CurrentTime >= 90  && CurrentTime < 270 ) {
  583.             WorldLightSwitch.setValue( 0 );
  584.         } else {
  585.             WorldLightSwitch.setValue( 1 );
  586.         }
  587.         //EclipseFlg = 0;
  588.         EclipseCnt = 0;
  589.     }
  590.  
  591.  
  592.     /*
  593.      *
  594.      */
  595.     public void ChangeBgColor ( ConstSFTime t, double now ) {
  596.         float red;
  597.         float green; 
  598.         float blue;
  599.         float[][] col = new float[1][3];
  600.  
  601.         // < decide bg color >
  602.         if ( CurrentTime < sunriseStartTime ) {
  603.             WorldSkyFlg++;
  604.  
  605.             red = nightColorR;
  606.             green = nightColorG;
  607.             blue = nightColorB;
  608.  
  609.         } else if ( CurrentTime < sunriseMidStartTime ) {
  610.             WorldSkyFlg = 0;
  611.  
  612.             // < sun rise. (night -> sunrise peak) >
  613.             red   = calcColorElm( CurrentTime, sunriseStartTime, sunriseMidStartTime, nightColorR, sunriseColorR );
  614.             green = calcColorElm( CurrentTime, sunriseStartTime, sunriseMidStartTime, nightColorG, sunriseColorG );
  615.             blue  = calcColorElm( CurrentTime, sunriseStartTime, sunriseMidStartTime, nightColorB, sunriseColorB );
  616.  
  617.         } else if ( CurrentTime < sunriseMidEndTime ) {
  618.             WorldSkyFlg++;
  619.  
  620.             // < sunrise peak.>
  621.             red = sunriseColorR;
  622.             green = sunriseColorG;
  623.             blue = sunriseColorB;
  624.  
  625.         } else if ( CurrentTime < sunriseEndTime ) {
  626.             WorldSkyFlg = 0;
  627.  
  628.             // < sun rise. (peak -> daylight) >
  629.             red   = calcColorElm( CurrentTime, sunriseMidEndTime, sunriseEndTime, sunriseColorR, daylightColorR );
  630.             green = calcColorElm( CurrentTime, sunriseMidEndTime, sunriseEndTime, sunriseColorG, daylightColorG );
  631.             blue  = calcColorElm( CurrentTime, sunriseMidEndTime, sunriseEndTime, sunriseColorB, daylightColorB );
  632.  
  633.         } else if ( CurrentTime < sunsetStartTime ) {
  634.             WorldSkyFlg++;
  635.  
  636.             // < daylight.>
  637.             red = daylightColorR;
  638.             green = daylightColorG;
  639.             blue = daylightColorB;
  640.  
  641.         } else if ( CurrentTime < sunsetMidStartTime ) {
  642.             WorldSkyFlg = 0;
  643.  
  644.             // < sunset. (daylight -> sunset peak) >
  645.             red   = calcColorElm( CurrentTime, sunsetStartTime, sunsetMidStartTime, daylightColorR, sunsetColorR );
  646.             green = calcColorElm( CurrentTime, sunsetStartTime, sunsetMidStartTime, daylightColorG, sunsetColorG );
  647.             blue  = calcColorElm( CurrentTime, sunsetStartTime, sunsetMidStartTime, daylightColorB, sunsetColorB );
  648.  
  649.         } else if ( CurrentTime < sunsetMidEndTime ) {
  650.             WorldSkyFlg++;
  651.  
  652.             // < sunset peak.>
  653.             red = sunsetColorR;
  654.             green = sunsetColorG;
  655.             blue = sunsetColorB;
  656.  
  657.         } else if ( CurrentTime < sunsetEndTime ) {
  658.             WorldSkyFlg = 0;
  659.  
  660.             // < sunset. (peak -> night) >
  661.             red   = calcColorElm( CurrentTime, sunsetMidEndTime, sunsetEndTime, sunsetColorR, nightColorR );
  662.             green = calcColorElm( CurrentTime, sunsetMidEndTime, sunsetEndTime, sunsetColorG, nightColorG );
  663.             blue  = calcColorElm( CurrentTime, sunsetMidEndTime, sunsetEndTime, sunsetColorB, nightColorB );
  664.  
  665.         } else {
  666.             WorldSkyFlg++;
  667.  
  668.             // < night.>
  669.             red = nightColorR;
  670.             green = nightColorG;
  671.             blue = nightColorB;
  672.  
  673.         }
  674.  
  675.         // set bg color
  676.         if ( WorldSkyFlg <= 1 ) {
  677.             col[0][R] = red;
  678.             col[0][G] = green;
  679.             col[0][B] = blue;
  680.             WorldSkyCol.setValue( col );
  681.         } else {
  682.             WorldSkyFlg = 2;
  683.         }
  684.     }
  685.  
  686.  
  687.     /*
  688.      *                 (endColor - startColor) x (time - startTime)
  689.      *    color = startColor + ----------------------------------------------------
  690.      *                        endTime - startTime
  691.      *
  692.      *        startColor x (endTime - time) + endColor x (time - startTime)
  693.      *      = ---------------------------------------------------------------------
  694.      *                   endTime - startTime
  695.      */
  696.     public float calcColorElm ( int time, int startTime, int endTime, float startColor, float endColor ) {
  697.         float col;
  698.  
  699.         col = (( startColor * ( float )( endTime - time )) + ( endColor * ( float )( time - startTime ))) / ( float )( endTime - startTime );
  700.  
  701.         return( col );
  702.     }
  703.  
  704.  
  705.     /*
  706.      * PARADE
  707.      */
  708.     public void ParadeInit ( double now ) {
  709.         float pos[] = new float[3];
  710.         float rot[] = new float[4];
  711.         double start_time, end_time;
  712.         double parade_time = 60;
  713.  
  714.         pos[X] = 15.0f;    pos[Y] = 2.5f;    pos[Z] = 0.0f;    ParadeSoundPos.setValue( pos );
  715.  
  716.         pos[X] = 13.0f;    pos[Y] = 2.5f;    pos[Z] = 4.0f;    Piero1Pos.setValue( pos );
  717.         pos[X] = 13.0f;    pos[Y] = 2.5f;    pos[Z] = 4.0f;    AccordionPos.setValue( pos );
  718.         
  719.         pos[X] = 14.3f;    pos[Y] = 2.9f;    pos[Z] = 2.0f;    Piero2Pos.setValue( pos );
  720.         pos[X] = 14.3f;    pos[Y] = 2.7f;    pos[Z] = 2.0f;    BarrelPos.setValue( pos );
  721.  
  722.         pos[X] = 15.0f;    pos[Y] = 2.5f;    pos[Z] = 0.0f;    Piero3Pos.setValue( pos );
  723.  
  724.         pos[X] = 14.3f;    pos[Y] = 2.0f;    pos[Z] = -2.0f;    AshikaPos.setValue( pos );
  725.  
  726.         pos[X] = 13.0f;    pos[Y] = 2.5f;    pos[Z] = -4.0f;    KumaPos.setValue( pos );
  727.  
  728.         rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;
  729.         rot[DEGREE] = -20.0f / Radian;        Piero1Rot.setValue( rot );
  730.                                             AccordionRot.setValue( rot );
  731.         rot[DEGREE] = -10.0f / Radian;        Piero2Rot.setValue( rot );
  732.                                             BarrelRot.setValue( rot );
  733.         rot[DEGREE] = 0.0f / Radian;        Piero3Rot.setValue( rot );
  734.         rot[DEGREE] = 10.0f / Radian;        AshikaRot.setValue( rot );
  735.         rot[DEGREE] = 25.0f / Radian;        KumaRot.setValue( rot );
  736.  
  737.         //start_time = now.getValue() + 1;
  738.         start_time = now + 1;
  739.         end_time = start_time + parade_time;
  740.         Piero1StartTime.setValue( start_time );    Piero1StopTime.setValue( end_time );
  741.         Piero2StartTime.setValue( start_time );    Piero2StopTime.setValue( end_time );
  742.         Piero3StartTime.setValue( start_time );    Piero3StopTime.setValue( end_time );
  743.         AshikaStartTime.setValue( start_time );    AshikaStopTime.setValue( end_time );
  744.         KumaStartTime.setValue( start_time );    KumaStopTime.setValue( end_time );
  745.         Piero1Sw.setValue( true );
  746.         Piero2Sw.setValue( true );
  747.         Piero3Sw.setValue( true );
  748.         AshikaSw.setValue( true );
  749.         KumaSw.setValue( true );
  750.  
  751.         /* sound on */
  752.         ParadeSound_start.setValue( now );
  753.  
  754.     }
  755.  
  756.  
  757.     /*
  758.      *
  759.      */
  760.     public void ParadeMove ( ConstSFTime t, double now ) {
  761.         float rot[] = new float[ 4 ];
  762.  
  763.         rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;    rot[DEGREE] = ((float)( CurrentTime - 270 ) * ( -6.0f )) / Radian;
  764.         ParadeStageRot.setValue( rot );
  765.         rot[X] = 1.0f;    rot[Y] = 0.0f;    rot[Z] = 0.0f;    rot[DEGREE] = 15.0f / Radian;
  766.         BarrelRot.setValue( rot );
  767.  
  768.     }
  769.  
  770.  
  771.     /*
  772.      *
  773.      */
  774.     public void ParadeEnd ( double now ) {
  775.         float rot[] = new float[ 4 ];
  776.  
  777.         rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;
  778.         rot[DEGREE] = 0.0f / Radian;;    ParadeStageRot.setValue( rot );
  779.                                         Piero1Rot.setValue( rot );
  780.                                         AccordionRot.setValue( rot );
  781.         rot[DEGREE] = -10.0f / Radian;    Piero2Rot.setValue( rot );
  782.                                         BarrelRot.setValue( rot );
  783.         rot[DEGREE] = -20.0f / Radian;    Piero3Rot.setValue( rot );
  784.         rot[DEGREE] = 0.0f / Radian;    AshikaRot.setValue( rot );    ////960906c
  785.         //rot[DEGREE] = -30.0f / Radian;    AshikaRot.setValue( rot );
  786.         rot[DEGREE] = 0.0f / Radian;    KumaRot.setValue( rot );
  787.         //rot[DEGREE] = -45.0f / Radian;    KumaRot.setValue( rot );
  788.  
  789.         InterpolatorPosInit();        /* set initial position */
  790.  
  791.         ParadeSound_stop.setValue( now );        /*  sound off */
  792.  
  793.     }
  794.  
  795.  
  796.     /*
  797.      *
  798.      */
  799.     public void PeriodicIllumi ( ConstSFTime t, ConstSFTime now ) {
  800.  
  801.         // < change color >
  802.         //set illumi [ vsGetObjByName "flagall.light0IllumiNo" ]
  803.         //?
  804.         //vsSetObjAllMaterial illumi vsDiffuse IllumiR IllumiG IllumiB
  805.         //?
  806.  
  807.         IllumiNo++;
  808.         if ( IllumiNo > 9 ) {
  809.             IllumiNo = 0;
  810.             IllumiCnt++;
  811.             if ( IllumiCnt > 3 ) {
  812.                 IllumiCnt = 0;
  813.             }
  814.  
  815.             // set illumination color
  816.             if ( IllumiCnt == 0 ) {
  817.                 IllumiR = 0.0f;
  818.                 IllumiG = 0.0f;
  819.                 IllumiB = 0.0f;
  820.             } else if ( IllumiCnt == 1 ) {
  821.                 IllumiR = 1.0f;
  822.                 IllumiG = 1.0f;
  823.                 IllumiB = 1.0f;
  824.             } else if ( IllumiCnt == 2 ) {
  825.                 IllumiR = 1.0f;
  826.                 IllumiG = 0.0f;
  827.                 IllumiB = 0.0f;
  828.             } else if ( IllumiCnt == 3 ) {
  829.                 IllumiR = 0.3f;
  830.                 IllumiG = 1.0f;
  831.                 IllumiB = 0.1f;
  832.             }
  833.         }
  834.     }
  835.  
  836.  
  837.     /*
  838.      * airship
  839.      */
  840.     public void AirshipMove ( ConstSFTime t, double now ) {
  841.         float rot[] = new float[4];
  842.  
  843.         //vsRotateAngle Airship  0.0 6.0 0.0 vsCSWorld vsRelative
  844.         rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;
  845.         rot[DEGREE] = ((float)CurrentTime) / Radian;
  846.         AirShipRot.setValue( rot );
  847.  
  848.     }
  849.  
  850.  
  851.     /*
  852.      *
  853.      */
  854.     public void InterpolatorPosInit () {
  855.         float pos[] = new float[3];
  856.  
  857.         Piero1PosInit();
  858.         Piero2PosInit();
  859.         Piero3PosInit();
  860.         AshikaPosInit();
  861.         KumaPosInit();
  862.         
  863.         pos[X] = 10.0f;        pos[Y] = 2.5f;        pos[Z] = 10.0f;
  864.         AccordionPos.setValue( pos );
  865.         Piero2Dir = 0;
  866.     }
  867.  
  868.  
  869.     /*
  870.      *
  871.      */
  872.     public void ShapePosInit() {
  873.         int i;
  874.         float pos[] = new float[3];
  875.         float angle;
  876.         float th;
  877.  
  878.         /* FerrisWheel */
  879.         pos[X] = 0.0f;    pos[Y] = 28.5f;    pos[Z] = 0.0f;
  880.         FerrisWheelPos.setValue( pos );
  881.  
  882.         for ( i = 0; i <= 7; i++ ) {
  883.             angle = (((float)i / 8.0f ) * 360.0f) + 90.0f;
  884.             //angle = ((float)i / 8.0f ) * 360.0f;
  885.             th = angle / Radian;
  886.             pos[X] = (float)Math.cos( th ) * FerrisWheelR;
  887.             pos[Y] = (float)Math.sin( th ) * FerrisWheelR;
  888.             pos[Z] = 0;
  889.             GondolaPos[i].setValue( pos );
  890.         }
  891.  
  892.         /* FerrisRide Plate */
  893.         pos[X] = 0.0f;    pos[Y] = 3.5f;    pos[Z] = 3.0f;
  894.         FerrisRidePos.setValue( pos );
  895.         /* FerrisExit Plate */
  896.         FerrisExitPosInit();
  897.  
  898.         /* Rocketman */
  899.         //pos[X] = 0.0f;    pos[Y] = 0.0f;    pos[Z] = -80.0f;
  900.         //RocketmanPos.setValue( pos );
  901.  
  902.         InterpolatorPosInit();
  903.     }
  904.  
  905.  
  906.     /*
  907.      *
  908.      */
  909.     float RotateToAngle ( float rotate ) {
  910.         float    angle;
  911.         
  912.         angle = ( rotate / 72.0f ) * 360.0f;
  913.         
  914.         return    angle;
  915.     }
  916.  
  917.  
  918.     /*
  919.      *
  920.      */
  921.     public void FerrisMove ( double now ) {
  922.         int no;
  923.         int val;
  924.         int i;
  925.         float x, y, z;
  926.         float pos[] = new float[3];
  927.         float rot[] = new float[4];
  928.         float rotate, gondola_rotate;
  929.         float angle;
  930.         float th;
  931.         String s;
  932.         //    Transform personTransform = (Transform)Browser.getPerson();
  933.  
  934.  
  935.         // set variable
  936.         FerrisRotateAngle = FerrisRotateAngle + 1.0f;
  937.         if ( FerrisRotateAngle >= 72.0f ) {
  938.             FerrisRotateAngle = 0.0f;
  939.         }
  940.         rotate = FerrisRotateAngle;
  941.  
  942.         /* next Gondola come, clear seat */
  943.         val = (int)( rotate % 9 );
  944.         if ( val == 0 ) {
  945.             RidePerson = 0;
  946.         }
  947.  
  948.         /* FerrisWheel */
  949.         angle = RotateToAngle( rotate );
  950.         th = angle / Radian;
  951.         rot[X] = 0.0f;  rot[Y] = 0.0f;  rot[Z] = 1.0f;    rot[DEGREE] = -th;
  952.         FerrisWheelRot.setValue( rot );
  953.  
  954.         /* Gondola */
  955.         rot[X] = 0.0f;  rot[Y] = 0.0f;  rot[Z] = 1.0f;    rot[DEGREE] = th;
  956.         for ( i = 0; i <= 7; i++ ) {
  957.             GondolaRot[i].setValue( rot );
  958.         }
  959.  
  960.         /* riding on Gondola */
  961.         if ( RideGondolaNum > 0 ) {
  962.             no = RideGondolaNum - 1;
  963.             gondola_rotate = (float)no * 9.0f;
  964.             if ( rotate == gondola_rotate ) {    /* check ride off */
  965.                 FerrisExitReset( now );        /* set exit panel to ground */
  966.                 return;
  967.  
  968.             }
  969.             angle = RotateToAngle( rotate - gondola_rotate ) + 90.0f;
  970.             th = angle / Radian;
  971.             x = ((float)Math.cos( -th ) * FerrisWheelR );
  972.             y = ((float)Math.sin( -th ) * FerrisWheelR ) + FerrisWheelY;
  973.             z = 0.0f;
  974.  
  975.             /* set person to obj position */
  976.             if ( RideSeat == 1 ) {
  977.                 pos[X] = x;    pos[Y] = y - 0.4f;    pos[Z] = z - 1.5f;
  978.                 FerrisExitPos.setValue( pos );
  979.                 pos[X] = x;    pos[Y] = y - 2.5f;    pos[Z] = z + 1.0f;
  980.                 //pos[X] = x;    pos[Y] = y - 2.2f;    pos[Z] = z + 1.0f;
  981.                 GondolaFloorPos.setValue( pos );
  982.                 pos[X] = 0.0f;    pos[Y] = 0.7f;    pos[Z] = 0.0f;
  983.                 GondolaFencePos.setValue( pos );
  984.  
  985.                 //pos[X] = x;    pos[Y] = y - 1.5f;    pos[Z] = z + 1.0f;
  986.                 //personTransform.translate( pos, personTransform.modeAbsolute );
  987.             } else {
  988.                 pos[X] = x;    pos[Y] = y - 0.4f;    pos[Z] = z + 1.5f;
  989.                 FerrisExitPos.setValue( pos );
  990.                 pos[X] = x;    pos[Y] = y - 2.5f;    pos[Z] = z - 1.0f;
  991.                 GondolaFloorPos.setValue( pos );
  992.                 pos[X] = 0.0f;    pos[Y] = 0.7f;    pos[Z] = 0.0f;
  993.                 GondolaFencePos.setValue( pos );
  994.                 //pos[X] = x;    pos[Y] = y - 1.5f;    pos[Z] = z - 1.0f;
  995.                 //personTransform.translate( pos, personTransform.modeAbsolute );
  996.             }
  997.         }
  998.  
  999.     }
  1000.  
  1001.  
  1002.     /*
  1003.      * ride on the Ferris
  1004.      */
  1005.     public void FerrisRidePick ( ConstSFBool state, double now ) {
  1006.         int        gondola_num;
  1007.         float    rotate;
  1008.         float    pos[] = new float[3];
  1009.         float    rot[] = new float[4];
  1010.         String    s;
  1011.         //    Transform personTransform = (Transform)Browser.getPerson();
  1012.  
  1013.         if (state.getValue()) return;    /* mouseDown */
  1014.  
  1015.         if ( RideGondolaNum > 0 ) {        /* already ride on */
  1016.             return;
  1017.         }
  1018.  
  1019.         if ( RidePerson >= 2 ) {
  1020.             return;
  1021.         }
  1022.  
  1023.         /* get available Gondola */
  1024.         rotate = FerrisRotateAngle;
  1025.         gondola_num = (int)( rotate / 9.0f );
  1026.         RideGondolaNum = gondola_num + 1;        // ride on
  1027.  
  1028.         GondolaSound_start.setValue( now );    // sound start
  1029.         GondolaSound_stop.setValue( -1L );
  1030.         /* select seat */
  1031.         if ( RidePerson == 0 ) {
  1032.             RideSeat = 1;
  1033.             RidePerson = 1;
  1034.             //rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;    rot[DEGREE] = 180.0f / Radian;
  1035.             rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;    rot[DEGREE] = 0.0f;
  1036.         } else {
  1037.             RideSeat = 2;
  1038.             RidePerson = 2;
  1039.             //rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;    rot[DEGREE] = 0.0f;
  1040.             rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;    rot[DEGREE] = 180.0f / Radian;
  1041.         }
  1042.         GondolaViewBind.setValue( true );    //// 1996.08.29
  1043. ////        GondolaViewRot.setValue( rot );        //// 1996.09.12h
  1044.         s = String.valueOf( RideSeat );
  1045.         Vscp.sendApplSpecificMsgWithDist ( WorldNode, "FerrisRide", s, Vscp.responderOnly );
  1046.  
  1047.     }
  1048.  
  1049.  
  1050.     /*
  1051.      * Share the status of a gondola seat
  1052.      */
  1053.     public void FerrisRide  ( ConstSFString shared_data, double now  ) {
  1054.         String s;
  1055.  
  1056.         if ( Vscp.amIMaster()) {
  1057.             s = shared_data.getValue();
  1058.             RidePerson = Integer.valueOf( s ).intValue();
  1059.             Vscp.sendApplSpecificMsgWithDist ( WorldNode, "ShareRidePerson", s, Vscp.allClientsExceptMe );
  1060.         }
  1061.     }
  1062.  
  1063.  
  1064.     /*
  1065.      *
  1066.      */
  1067.     public void FerrisExitPosInit () {
  1068.         float pos[] = new float[ 3 ];
  1069.  
  1070.         /* set exit panel to ground */
  1071.         pos[X] = 0.0f;    pos[Y] = 0.0f;    pos[Z] = 0.0f;
  1072.         FerrisExitPos.setValue( pos );
  1073.         //pos[X] = 0.0f;    pos[Y] = 0.0f;    pos[Z] = 0.0f;    ////960904c
  1074.         //pos[X] = 0.0f;    pos[Y] = 2.0f;    pos[Z] = 0.0f;    ////960909c
  1075.         pos[X] = 0.0f;    pos[Y] = 3.5f;    pos[Z] = -2.5f;    ////960912h
  1076.         GondolaFloorPos.setValue( pos );
  1077.         pos[X] = 0.0f;    pos[Y] = -1.0f;    pos[Z] = 0.0f;    ////960912h
  1078.         GondolaFencePos.setValue( pos );
  1079.  
  1080.     }
  1081.  
  1082.     /*
  1083.      *
  1084.      */
  1085.     public void FerrisExitReset ( double now ) {
  1086.  
  1087.         //    1996.08.27
  1088.         ////960904c GondolaViewBind.setValue( false );
  1089.  
  1090.         RideGondolaNum = 0;
  1091.         RideSeat = 0;
  1092.         FerrisExitPosInit();
  1093.         
  1094.         GondolaSound_stop.setValue( now );        /* sound off */
  1095.  
  1096.     }
  1097.  
  1098.  
  1099.     /*
  1100.      *
  1101.      */
  1102.     public void FerrisExitPick ( ConstSFBool state, double now ) {
  1103.         float pos[] = new float[ 3 ];
  1104.  
  1105.         if (state.getValue()) return;    /* mouseDown */
  1106.  
  1107.         FerrisExitReset( now );
  1108.  
  1109.     }
  1110.  
  1111.  
  1112.     /*
  1113.      * for PIERO1
  1114.      */
  1115.     public void Piero1PosInit () {
  1116.         float pos[] = new float[3];
  1117.  
  1118.         pos[X] = 10.0f;        pos[Y] = 2.5f;        pos[Z] = 10.0f;
  1119.         Piero1Pos.setValue( pos );
  1120.         
  1121.     }
  1122.  
  1123.  
  1124.     public void Piero1Pick ( ConstSFBool state, double now ) {
  1125.  
  1126.         if (state.getValue()) return;    /* mouseDown */
  1127.  
  1128.         Piero1Start( now );
  1129.         Vscp.sendApplSpecificMsgWithDist(WorldNode, "Piero1PickShare", "void", Vscp.allClientsExceptMe );
  1130.  
  1131.     }
  1132.  
  1133.  
  1134.     public void Piero1PickShare ( ConstSFString userdata, double now ) {
  1135.  
  1136.         Piero1Start( now );
  1137.  
  1138.     }
  1139.  
  1140.  
  1141.     /*
  1142.      *
  1143.      */
  1144.     public void Piero1Start ( double now ) {
  1145.         double time;
  1146.  
  1147.         time = now;                Piero1StartTime.setValue( time );
  1148.         //time += 5;            Piero1StopTime.setValue( time );
  1149.         time += 8;                Piero1StopTime.setValue( time );            //1996.08.26
  1150.         Piero1MoveFlg = true;
  1151.         Piero1Sw.setValue( true );
  1152.     }
  1153.  
  1154.  
  1155.     /*
  1156.      *
  1157.      */
  1158.     public void Piero1Move () {
  1159.         float pos[] = new float[3];
  1160.  
  1161.         if ( Piero1Cnt >= 8 ) {
  1162.             Piero1Sw.setValue( false );
  1163.             Piero1MoveFlg = false;
  1164.             Piero1Cnt = 0;
  1165.         } else {
  1166.             pos[X] = 0.0f;    pos[Y] = 0.0f;    pos[Z] = 0.0f;
  1167.             if (( Piero1Cnt & 1 ) == 0 ) {
  1168.                 pos[X] =  0.03f;    Accordion1Pos.setValue( pos );
  1169.                 pos[X] = -0.03f;    Accordion2Pos.setValue( pos );
  1170.             } else {
  1171.                 pos[X] = -0.03f;    Accordion1Pos.setValue( pos );
  1172.                 pos[X] =  0.03f;    Accordion2Pos.setValue( pos );
  1173.             }
  1174.             Piero1Cnt++;
  1175.         }
  1176.     }
  1177.  
  1178.  
  1179.     /*
  1180.      * PIERO2
  1181.      */
  1182.     public void Piero2PosInit () {
  1183.         float pos[] = new float[3];
  1184.  
  1185.         pos[X] = -10.0f;    pos[Y] = 2.9f;    pos[Z] = 5.0f;    Piero2Pos.setValue( pos );
  1186.         pos[X] = -10.0f;    pos[Y] = 2.7f;    pos[Z] = 5.0f;    BarrelPos.setValue( pos );
  1187.         Piero2PosZ = 0.0f;
  1188.     }
  1189.  
  1190.  
  1191.     public void Piero2Pick ( ConstSFBool state, double now ) {
  1192.  
  1193.         if (state.getValue()) return;    /* mouseDown */
  1194.  
  1195.         Piero2Start( now );
  1196.         Vscp.sendApplSpecificMsgWithDist( WorldNode, "Piero2PickShare", "void", Vscp.allClientsExceptMe );
  1197.  
  1198.     }
  1199.  
  1200.  
  1201.     /*
  1202.      *
  1203.      */
  1204.     public void Piero2PickShare ( ConstSFString userdata, double now ) {
  1205.  
  1206.         Piero2Start( now );
  1207.  
  1208.     }
  1209.  
  1210.  
  1211.     /*
  1212.      *
  1213.      */
  1214.     public void Piero2Start ( double now ) {
  1215.         double time;
  1216.  
  1217.         time = now;                Piero2StartTime.setValue( time );
  1218.         time += 4;                Piero2StopTime.setValue( time );
  1219.         Piero2Sw.setValue( true );
  1220.         Piero2MoveFlg = true;
  1221.         
  1222.     }
  1223.  
  1224.  
  1225.     /*
  1226.      *
  1227.      */
  1228.     public void Piero2Move () {
  1229.         float pos[] = new float[3];
  1230.         float rot[] = new float[4];
  1231.  
  1232.         if ( Piero2Cnt >= 8 ) {
  1233.             Piero2Cnt = 0;
  1234.  
  1235.             if ( Piero2Dir == 0 ) {
  1236.                 Piero2Dir = 1;
  1237.             } else {
  1238.                 Piero2Dir = 0;
  1239.             }
  1240.             Piero2MoveFlg = false;
  1241.             return;
  1242.         }
  1243.  
  1244.         if ( Piero2Dir == 0 ) {
  1245.             Piero2PosZ += 0.1f;
  1246.             Piero2RotD += 15.0f;
  1247.         } else {
  1248.             Piero2PosZ -= 0.1f;
  1249.             Piero2RotD -= 15.0f;
  1250.         }
  1251.         pos[X] = -10.0f;    pos[Y] = 2.9f;    pos[Z] = 5.0f + Piero2PosZ;    Piero2Pos.setValue( pos );
  1252.         pos[X] = -10.0f;    pos[Y] = 2.7f;    pos[Z] = 5.0f + Piero2PosZ;    BarrelPos.setValue( pos );
  1253.         rot[X] = 1.0f;    rot[Y] = 0.0f;    rot[Z] = 0.0f;    rot[DEGREE] = Piero2RotD / Radian;
  1254.         BarrelRot.setValue( rot );
  1255.  
  1256.         Piero2Cnt++;
  1257.     }
  1258.  
  1259.  
  1260.     /*
  1261.      * for PIERO3
  1262.      */
  1263.     public void Piero3PosInit () {
  1264.         float pos[] = new float[3];
  1265.  
  1266.         pos[X] = -3.0f;        pos[Y] = 0.8f;        pos[Z] = -40.0f;
  1267.         Piero3Pos.setValue( pos );
  1268.     }
  1269.  
  1270.  
  1271.     public void Piero3Pick ( ConstSFBool state, double now ) {
  1272.  
  1273.         if (state.getValue()) return;    /* mouseDown */
  1274.  
  1275.         Piero3Start( now );
  1276.         Vscp.sendApplSpecificMsgWithDist( WorldNode, "Piero3PickShare", "void", Vscp.allClientsExceptMe );
  1277.     }
  1278.  
  1279.  
  1280.     public void Piero3PickShare ( ConstSFString userdata, double now ) {
  1281.  
  1282.         Piero3Start( now );
  1283.  
  1284.     }
  1285.  
  1286.  
  1287.     /*
  1288.      *
  1289.      */
  1290.     public void Piero3Start ( double now ) {
  1291.         double time;
  1292.  
  1293.         time = now;                Piero3StartTime.setValue( time );
  1294.         time += 4;                Piero3StopTime.setValue( time );
  1295.         Piero3Sw.setValue( true );
  1296.  
  1297.     }
  1298.  
  1299.  
  1300.     /*
  1301.      * for KUMA
  1302.      */
  1303.     public void KumaPosInit () {
  1304.         float pos[] = new float[3];
  1305.  
  1306.         pos[X] = -30.0f;    pos[Y] = 0.2f;        pos[Z] = -30.0f;
  1307.         KumaPos.setValue( pos );
  1308.     }
  1309.  
  1310.  
  1311.     public void KumaPick ( ConstSFBool state, double now ) {
  1312.  
  1313.         if (state.getValue()) return;    /* mouseDown */
  1314.  
  1315.         KumaStart( now );
  1316.         Vscp.sendApplSpecificMsgWithDist( WorldNode, "KumaPickShare", "void", Vscp.allClientsExceptMe );
  1317.     }
  1318.  
  1319.  
  1320.     public void KumaPickShare ( ConstSFString userdata, double now ) {
  1321.  
  1322.         KumaStart( now );
  1323.  
  1324.     }
  1325.  
  1326.  
  1327.     /*
  1328.      *
  1329.      */
  1330.     public void KumaStart ( double now ) {
  1331.         double time;
  1332.  
  1333.         //1996.08.26
  1334.         if ( ParadeFlg != 1 ) {
  1335.             if (KumaCnt>0) {
  1336.                 return;
  1337.             } else {
  1338.                 KumaAng = 0.0f;
  1339.                 KumaCnt = 0;
  1340.                 time = now;                KumaStartTime.setValue( time );
  1341.                 //time += 36;            KumaStopTime.setValue( time );
  1342.                 time += 20;                KumaStopTime.setValue( time );            //1996.08.26
  1343.                 KumaSw.setValue( true );
  1344.                 KumaBicycleSw.setValue( true );
  1345.             }
  1346.         }
  1347.  
  1348.     }
  1349.  
  1350.  
  1351.     public void KumaBicycleMove ( ConstSFTime t, double now ) {
  1352.         float pos[] = new float[3];
  1353.         float rot[] = new float[4];
  1354.         float th;
  1355.         float kuma_x = -30f;
  1356.         float kuma_y = 0.2f;
  1357.         float kuma_z = -30f;
  1358.         float circle_r = 1.5f;
  1359.         String s;
  1360.  
  1361.         if ( ParadeFlg != 1 ) {    ////960904c
  1362.             if ( KumaCnt < 18 ) {
  1363.                 KumaAng += 20.0f;
  1364.                 th = KumaAng / Radian;
  1365.                 pos[X] = ((float)Math.cos( th ) * circle_r ) + kuma_x - circle_r;
  1366.                 pos[Z] = ((float)Math.sin( th ) * circle_r ) + kuma_z;
  1367.                 pos[Y] = kuma_y;
  1368.             } else if ( KumaCnt < 36 ) {
  1369.                 KumaAng -= 20.0f;
  1370.                 th = (KumaAng + 180.0f) / Radian;
  1371.                 pos[X] = ((float)Math.cos( th ) * circle_r ) + kuma_x + circle_r;
  1372.                 pos[Z] = ((float)Math.sin( th ) * circle_r ) + kuma_z;
  1373.                 pos[Y] = kuma_y;
  1374.             } else {
  1375.                 KumaAng = 0.0f;
  1376.                 KumaCnt = -1;
  1377.                 pos[X] = kuma_x;
  1378.                 pos[Z] = kuma_z;
  1379.                 pos[Y] = kuma_y;
  1380.                 KumaBicycleSw.setValue( false );
  1381.             }
  1382.             rot[X] = 0.0f;    rot[Y] = 1.0f;    rot[Z] = 0.0f;    rot[DEGREE] = -KumaAng / Radian;
  1383.             KumaRot.setValue( rot );
  1384.             KumaPos.setValue( pos );
  1385.             KumaCnt++;
  1386.         }    ////960904c
  1387.     }
  1388.  
  1389.  
  1390.     /*
  1391.      *  ASHIKA
  1392.      */
  1393.     public void AshikaPosInit () {
  1394.         float pos[] = new float[3];
  1395.  
  1396.         pos[X] = -60.0f;    pos[Y] = 0.0f;        pos[Z] = 35.0f;
  1397.         AshikaPos.setValue( pos );
  1398.     }
  1399.  
  1400.  
  1401.     public void AshikaPick ( ConstSFBool state, double now ) {
  1402.  
  1403.         if (state.getValue()) return;    /* mouseDown */
  1404.  
  1405.         AshikaStart( now );
  1406.         Vscp.sendApplSpecificMsgWithDist( WorldNode, "AshikaPickShare", "void", Vscp.allClientsExceptMe );
  1407.     }
  1408.  
  1409.  
  1410.     public void AshikaPickShare ( ConstSFString userdata, double now ) {
  1411.  
  1412.         AshikaStart( now );
  1413.  
  1414.     }
  1415.  
  1416.  
  1417.     /*
  1418.      *
  1419.      */
  1420.     public void AshikaStart ( double now ) {
  1421.         double time;
  1422.  
  1423.         time = now;
  1424.         AshikaStartTime.setValue( time );
  1425.         time += 1;
  1426.         AshikaStopTime.setValue( time );
  1427.         AshikaSw.setValue( true );
  1428.     }
  1429.  
  1430.  
  1431.     /*
  1432.      * ball clicked
  1433.      */
  1434.     public void AshikaBallPick ( ConstSFBool state, double now ) {
  1435.  
  1436.         if (state.getValue()) return;    /* mouseDown */
  1437.  
  1438.         Vscp.sendApplSpecificMsgWithDist( WorldNode, "AshikaBallPickShare", "void", Vscp.allClientsExceptMe );
  1439.         AshikaBallStart( now );
  1440.     }
  1441.  
  1442.  
  1443.     public void AshikaBallPickShare ( ConstSFString userdata, double now ) {
  1444.  
  1445.         AshikaBallStart( now );
  1446.  
  1447.     }
  1448.  
  1449.  
  1450.     public void AshikaBallStart ( double now ) {
  1451.     
  1452.         //1996.08.26
  1453.         if ( ParadeFlg != 1 ) {
  1454.             AshikaBallSw.setValue( true );
  1455.             //AshikaStart( now );
  1456.         }
  1457.     
  1458.     }
  1459.  
  1460.  
  1461.     /*
  1462.      * ashika sound on/off
  1463.      */
  1464.     public void AshikaSound( double now, boolean sw ) {
  1465.     
  1466.         if ( sw == true ) {
  1467.             AshikaSound_start.setValue( now );        /* start */
  1468.         } else {
  1469.             AshikaSound_stop.setValue( now );        /* stop */
  1470.         }
  1471.  
  1472.     }
  1473.  
  1474.  
  1475.     /*
  1476.      * ashika's show action
  1477.      */
  1478.     public void AshikaBallMove ( ConstSFTime t, double now ) {
  1479.         float pos[] = new float[3];
  1480.         float rot[] = new float[4];
  1481.         double time;
  1482.         int a;
  1483.  
  1484.         AshikaBallRotX -= 10.0f;
  1485.         AshikaBallRotZ += 20.0f;
  1486.         rot[X] = 1.0f;    rot[Y] = 0.0f;    rot[Z] = 0.0f;    rot[DEGREE] = AshikaBallRotX / Radian;
  1487.         AshikaBallRot.setValue( rot );
  1488.         rot[X] = 0.0f;    rot[Y] = 0.0f;    rot[Z] = 1.0f;    rot[DEGREE] = AshikaBallRotZ / Radian;
  1489.         AshikaBallRot.setValue( rot );
  1490.  
  1491.         AshikaStart( now );
  1492.  
  1493.         AshikaCnt++;
  1494.         if ( AshikaMode == 0 ) {
  1495.             if ( AshikaCnt > 10 ) {
  1496.                 AshikaCnt = 0;
  1497.                 AshikaMode++;
  1498.                 //AshikaStart( now );
  1499.                 AshikaSound( now, true );
  1500.             } else {
  1501.                 a = AshikaCnt - 1;
  1502.                 pos[0] = -60.0f;
  1503.                 pos[1] = AshikaBallData1[a][1];
  1504.                 pos[2] = AshikaBallData1[a][0];
  1505.                 AshikaBallPos.setValue( pos );
  1506.             }
  1507.         } else if ( AshikaMode == 1 ) {
  1508.             if ( AshikaCnt > 10 ) {
  1509.                 AshikaCnt = 0;
  1510.                 AshikaMode++;
  1511.                 AshikaSound( now, true );
  1512. AshikaSw.setValue( false );
  1513.             } else {
  1514.                 a = AshikaCnt - 1;
  1515.                 pos[X] = -60.0f;
  1516.                 pos[Y] = AshikaBallData2[a];
  1517.                 pos[Z] = 35.7f;
  1518.                 AshikaBallPos.setValue( pos );
  1519.             }
  1520.         } else if ( AshikaMode == 2 ) {
  1521.             if ( AshikaCnt == 0 ) {
  1522.                 AshikaSound( now, false );
  1523.             } else if ( AshikaCnt > 10 ) {
  1524.                 AshikaBallSw.setValue( false );
  1525.                 AshikaMode = 0;
  1526.                 AshikaCnt = 0;
  1527.             } else {
  1528.                 a = ( 10 - AshikaCnt );
  1529.                 pos[X] = -60.0f;
  1530.                 pos[Y] = AshikaBallData1[a][1];
  1531.                 pos[Z] = AshikaBallData1[a][0];
  1532.                 AshikaBallPos.setValue( pos );
  1533.             }
  1534.         }
  1535.     }
  1536. }
  1537.  
  1538.  
  1539.  
  1540.  
  1541.