home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-05 | 1.2 KB | 67 lines |
- /*
- * File : sphere.java (Script for Community Place)
- * Version : 2.0- 1996.09.11
- * Auther : cori co.
- *
- * Copyright(C) 1996,1997 Sony Corporation. All rights reserved.
- */
-
- import vrml.*;
- import vrml.field.*;
- import vrml.node.*;
- import java.util.*;
- //import vs.*;
-
-
- /* This is a sample script for event handler.*/
- public class sphere extends Script {
- SFColor SphereDiffuseColor;
- boolean SphereColorFlg = false;
-
-
- /*
- * Initialize
- */
- public void initialize() {
- SphereDiffuseColor = (SFColor)getEventOut( "SphereDiffuseColor" );
- }
-
-
- /*
- * eventIn
- */
- public void processEvent( Event e ) {
- String name = e.getName();
-
- if ( name.equals( "SphereClicked" )) {
- SphereClicked( (ConstSFBool)e.getValue() );
- }
- }
-
-
- /*
- * Clicked on the sphere
- */
- void SphereClicked( ConstSFBool state ) {
- float col[] = new float[3];
-
- if ( !state.getValue() ) { /* != mouseDown */
- if ( SphereColorFlg == false ) {
- col[0] = 1.0f;
- col[1] = 0.0f;
- col[2] = 0.0f;
- SphereColorFlg = true;
- } else {
- col[0] = 0.0f;
- col[1] = 0.8f;
- col[2] = 0.8f;
- SphereColorFlg = false;
- }
- SphereDiffuseColor.setValue( col );
- }
- }
- }
-
-
-
-