import improv.actor.*;
import improv.actor.behavior.*;
import improv.util.*;
public class demo1 extends demo
{
	private Layer background,layer1,layer2;

	public void defBehavior() {

// Create Channels;

		SFVec3fChannel    rootTrans        = (SFVec3fChannel)    addChannel("ROOT","set_translation");
		SFRotationChannel rootRot          = (SFRotationChannel) addChannel("ROOT","set_rotation");
		SFRotationChannel bodyRot          = (SFRotationChannel) addChannel("Body","set_rotation");
		SFRotationChannel headRot          = (SFRotationChannel) addChannel("Head","set_rotation");
		SFRotationChannel leftEyeStalkRot  = (SFRotationChannel) addChannel("LeftEyeStalk","set_rotation");
		SFRotationChannel rightEyeStalkRot = (SFRotationChannel) addChannel("RightEyeStalk","set_rotation");
		SFRotationChannel leftEyeRot       = (SFRotationChannel) addChannel("LeftEye","set_rotation");
		SFRotationChannel rightEyeRot      = (SFRotationChannel) addChannel("RightEye","set_rotation");
		SFVec3fChannel    leftPupilScale   = (SFVec3fChannel)    addChannel("LeftPupil","set_scale");
		SFVec3fChannel    rightPupilScale  = (SFVec3fChannel)    addChannel("RightPupil","set_scale");

// Add the layers & states

		State bg,def,lookLeft,lookRight,forward,eyesIn,eyesLeft,eyesRight;
		background = actor.addLayer("Background");
		bg = new State("Background");
		bg.addFilter(new SFVec3fFilter(rootTrans,0,0,0));
		bg.addFilter(new SFRotationFilter(rootRot,0,0,0));
		bg.addFilter(new SFRotationFilter(bodyRot,0,0,0));
		bg.addFilter(new SFRotationFilter(headRot,0,0,0));
		bg.addFilter(new SFRotationFilter(leftEyeStalkRot,0,0,0));
		bg.addFilter(new SFRotationFilter(rightEyeStalkRot,0,0,0));
		bg.addFilter(new SFRotationFilter(leftEyeRot,0,0,0));
		bg.addFilter(new SFRotationFilter(rightEyeRot,0,0,0));
		bg.addFilter(new SFVec3fFilter(leftPupilScale,1,1,1));
		bg.addFilter(new SFVec3fFilter(rightPupilScale,1,1,1));
		background.addBehavior(bg);

		layer1 = actor.addLayer("Layer 1");
		def = new State("Default - Layer 1");
		layer1.addBehavior(def);
		
		lookLeft = new State("Look Left");
		lookLeft.addFilter(new SFRotationFilter(headRot,0,45,0));
		NoiseCurve nx1 = new NoiseCurve(-20,20,1);
		NoiseCurve nz1 = new NoiseCurve(20,-20,1);
		lookLeft.addFilter(new SFRotationFilter(leftEyeStalkRot,nx1,null,nz1));
		NoiseCurve nx2 = new NoiseCurve(20,-20,1);
		nx2.setOffset(.3);
		NoiseCurve nz2 = new NoiseCurve(-20,20,1);
		nz2.setOffset(.3);
		lookLeft.addFilter(new SFRotationFilter(rightEyeStalkRot,nx2,null,nz2));
		layer1.addBehavior(lookLeft);

		lookRight = new State("Look Right");
		lookRight.addFilter(new SFRotationFilter(headRot,0,-45,0));
		lookRight.addFilter(new SFRotationFilter(leftEyeStalkRot,nx2,null,nz2));
		lookRight.addFilter(new SFRotationFilter(rightEyeStalkRot,nx1,null,nz1));

		layer1.addBehavior(lookRight);
	}
}

