import vrml.*;
import vrml.field.*;
import vrml.node.*;

public class Clock extends Script
{
	private SFTime get_time;
	private SFNode second;
	private SFRotation second_set;
	private SFNode minute;
	private SFRotation minute_set;
	private SFNode hour;
	private SFRotation hour_set;
    private SFNode loop;
    private SFBool loop_set;
    float secondAdd[]={0f,0f,0f,0f};
    float minuteAdd[]={0f,0f,0f,0f};
    float hourAdd[]={0f,0f,0f,0f};
    
    public void initialize()
    {
    	second=(SFNode)getField("secondHand");
    	minute=(SFNode)getField("minuteHand");
    	hour=(SFNode)getField("hourHand");
    	loop=(SFNode)getField("loop_set");
    }
    
    public void processEvent(Event e)
    {
    	if(e.getName().equalsIgnoreCase("get_time")==true)
    	{
    		Node node_loop;
    		node_loop=(Node)(loop.getValue());
    		loop_set=(SFBool)(node_loop.getExposedField("loop"));
    	    loop_set.setValue(true);
    	    Node node_s;
    	    node_s=(Node)(second.getValue());
    	    second_set=(SFRotation)(node_s.getExposedField("rotation"));
    	    secondAdd[0]=0f;
    	    secondAdd[1]=1f;
    	    secondAdd[2]=0f;
    	    secondAdd[3]+=-0.1047f;
    	    second_set.setValue(secondAdd);
    	    Node node_m;
    	    node_m=(Node)(minute.getValue());
    	    minute_set=(SFRotation)(node_m.getExposedField("rotation"));
    	    minuteAdd[0]=0f;
    	    minuteAdd[1]=1f;
    	    minuteAdd[2]=0f;
    	    minuteAdd[3]+=-0.1047f/60f;
    	    minute_set.setValue(minuteAdd);
    	    Node node_h;
    	    node_h=(Node)(hour.getValue());
    	    hour_set=(SFRotation)(node_h.getExposedField("rotation"));
    	    hourAdd[0]=0f;
    	    hourAdd[1]=1f;
    	    hourAdd[2]=0f;
    	    hourAdd[3]+=-0.1047f/3600f;
    	    hour_set.setValue(hourAdd);
    	 }
    }
}