home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Windows 95.com 1996 December
/
WIN95_DEC_1996_1.ISO
/
vrml
/
cp2b2x.exe
/
DATA.Z
/
tv.java
< prev
next >
Wrap
Text File
|
1996-06-21
|
7KB
|
247 lines
/*-----------------------------------------------------------------------------
* Copyright(C) 1995,1996 Sony Corporation
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Sony Corporation;
* the contents of this file is not to be disclosed to third parties, copied
* or duplicated in any form, in whole or in part, without the prior written
* permission of Sony Corporation.
*
* File: tv.java
* Auther: sugino
*----------------------------------------------------------------------------*/
import vrml.*;
public class tv extends Script {
/* propertys */
/*************************/
/* channels/volume array */
/*************************/
SFFloat channels[] = new SFFloat[3]; /* channelp number shapes */
SFFloat volumes[] = new SFFloat[10]; /* volume indicater shapes */
SFColor powerBtn; /* power button */
SFFloat chs[] = new SFFloat[3]; /* monitor faces */
int MaxVolume ; /* volume max */
int MaxChannel; /* channel max */
int volume ; /* sound volume (0-9) */
int channel ; /* channel no(0-2) */
boolean powerOn ; /* true the power is on */
int ignoreTimer ;
SFBool tglTm = (SFBool)getEventOut("tglTm");
SFTime bgm1Start = (SFTime) getEventOut("bgm1Start");
SFTime bgm1Stop = (SFTime) getEventOut("bgm1Stop");
SFTime kachiStart = (SFTime) getEventOut("kachiStart");
SFFloat bgmVol = (SFFloat) getEventOut("bgmVol");
/*************************************************
* constructor
*************************************************/
public tv() {
MaxVolume =10; /* volume max */
MaxChannel=3 ; /* channel max */
volume = 8 ; /* sound volume (0-9) */
channel = 0; /* channel no(0-2) */
powerOn = false;/* true the power is on */
/* ---------------------------------------------
* initialize
* ------------------------------------------- */
/* reference to Channnel shapes */
channels[0] = (SFFloat)getEventOut("ch1Shape");
channels[1] = (SFFloat)getEventOut("ch2Shape");
channels[2] = (SFFloat)getEventOut("ch3Shape");
chs[0] = (SFFloat)getEventOut("ch1");
chs[1] = (SFFloat)getEventOut("ch2");
chs[2] = (SFFloat)getEventOut("ch3");
/* reference to vol indicater shapes */
volumes[0] = (SFFloat)getEventOut("vol1Shape");
volumes[1] = (SFFloat)getEventOut("vol2Shape");
volumes[2] = (SFFloat)getEventOut("vol3Shape");
volumes[3] = (SFFloat)getEventOut("vol4Shape");
volumes[4] = (SFFloat)getEventOut("vol5Shape");
volumes[5] = (SFFloat)getEventOut("vol6Shape");
volumes[6] = (SFFloat)getEventOut("vol7Shape");
volumes[7] = (SFFloat)getEventOut("vol8Shape");
volumes[8] = (SFFloat)getEventOut("vol9Shape");
volumes[9] = (SFFloat)getEventOut("vol10Shape");
/* reference to Power buttn shapes */
powerBtn = (SFColor)getEventOut("powerShape");
bgmVol.setValue((float)volume*0.1f);
}
/*************************************************
* script methods
*************************************************/
public void volDown (ConstSFBool b, ConstSFTime t){
if(!powerOn) return ;
if(b.getValue()){return;}
/* System.out.println("volDown"); */
volume--;
setVolume(volume);
showInfo();
/* TODO Ä└ì█é╔ë╣é≡âZâbâgé╖éΘ */
bgmVol.setValue((float)volume*0.1f);
}
public void volUp (ConstSFBool b, ConstSFTime t){
if(!powerOn) return ;
if(b.getValue()){return;}
/* System.out.println("volUp"); */
volume++;
setVolume(volume);
showInfo();
bgmVol.setValue((float)volume*0.1f);
/* TODO Ä└ì█é╔ë╣é≡âZâbâgé╖éΘ */
}
public void chUp (ConstSFBool b, ConstSFTime t){
if(!powerOn) return ;
if(b.getValue()){return;}
/* System.out.println("chUp"); */
channel++;
setChannel(channel);
playTv();
showInfo();
}
public void chDown (ConstSFBool b, ConstSFTime t){
if(!powerOn) return ;
if(b.getValue()){return;}
/* System.out.println("chDown"); */
channel--;
setChannel(channel);
playTv();
showInfo();
}
public void tglPower (ConstSFBool b, ConstSFTime t){
if(b.getValue()){return;}
float f[] = new float[3];
f[0]=f[1]=f[2]=0.0f;
if(powerOn) {
/* turn Off power */
powerOn = false ;
f[0]=1.0f;
clearTv();
clearInfo();
bgm1Stop.setValue(t.getValue());
}
else {
powerOn = true ;
f[1]=1.0f;
playTv();
showInfo();
bgm1Start.setValue(t.getValue());
}
powerBtn.setValue(f);
/* System.out.println("tglPower" + ff[0] + " " +
ff[1] + " " + ff[2] ); */
kachiStart.setValue(t.getValue()+1);
}
public void turnOffInfo (ConstSFTime time, ConstSFTime t){
if(0<ignoreTimer){
ignoreTimer--;
return ;
}
tglTm.setValue(false);
clearInfo();
clearVolume();
}
void clearInfo(){
clearChannel();
clearVolume();
}
/*************************************************
* showInfo()
*************************************************/
void showInfo(){
setChannel(channel);
setVolume(volume);
ignoreTimer = 1;
tglTm.setValue(true);
}
/*************************************************
* Clear TV
*************************************************/
void clearTv(){
for (int i=0;i<MaxChannel;i++){
chs[i].setValue(1.0f);
}
}
/*************************************************
* playTv
*************************************************/
void playTv(){
clearTv();
chs[channel].setValue(0.0f);
}
/*************************************************
* Clear Channel shape
*************************************************/
void clearChannel(){
for (int i=0;i<MaxChannel;i++){
channels[i].setValue(1.0f);
}
}
/*************************************************
* set volume shape
*************************************************/
void setChannel(int ch){
if(ch<0){ch =MaxChannel-1;}
if(ch>=MaxChannel){ch=0;}
channel = ch ;
clearChannel();
channels[ch].setValue(0.0f);
}
/*************************************************
* Clear Volume shape
*************************************************/
void clearVolume(){
for(int i=0;i<MaxVolume;i++){
/* disable volume */
volumes[i].setValue(1.0f);
}
}
/*************************************************
* set volume shape
*************************************************/
void setVolume(int vol){
if(vol<0){vol =0;}
if(vol>MaxVolume){vol=MaxVolume;}
volume = vol ;
clearVolume();
for(int i=0;i<vol;i++){
volumes[i].setValue(0.0f);
}
}
}