//// // The Correlator is a simple click and drop // interface that allows users to easy specify important // blend points or a FaceBlend, like eyes and so forth // it gives the user a nice starting point //// class Correlator{ // statics PFont markerFont; public final int MAX_BLEND_MARKERS = 128; private BlendMarker[] markers; private int markerCount; private BlendMarker dragMarker; //// // Constructors //// public Correlator(){ this.markerFont = loadFont("markerFont.vlw"); this.markers = new BlendMarker[MAX_BLEND_MARKERS]; this.markerCount = 0; this.dragMarker = null; } //// // Draw! //// public void draw(){ // draw those suckers! for(int i = 0; i < this.markerCount; i++){ this.markers[i].draw(); } } //// // Mouse Pressed //// public void mousePressed(){ boolean inputUsed = false; Point mouse = new Point(mouseX, mouseY); for(int i = 0; i < this.markerCount; i++){ inputUsed = this.markers[i].canUseInput(mouse); if(inputUsed){ dragMarker = this.markers[i]; inputUsed = true; break; } } if(!inputUsed){ this.addNextPoint(); } } //// // And then the release //// public void mouseReleased(){ if(dragMarker != null){ dragMarker.releaseInput(); } } //// // Adds a new point, whatever that means //// public void addNextPoint(){ if(this.markerCount == 0){ this.markers[this.markerCount] = new BlendMarker(this.markerCount, this.markerFont); this.markers[this.markerCount].setInitialMark(new Point(mouseX, mouseY)); this.markerCount ++; }else if(this.markerCount < this.markers.length){ BlendMarker lastMarker = this.markers[this.markerCount - 1]; if(lastMarker.getFinalMark() == null){ // we need to set the final for this blendmarker lastMarker.setFinalMark(new Point(mouseX, mouseY)); } else { this.markers[this.markerCount] = new BlendMarker(this.markerCount, this.markerFont); this.markers[this.markerCount].setInitialMark(new Point(mouseX, mouseY)); this.markerCount ++; } } } //// // Takes in the draw coord basis for each of the // positioning sets //// public void normalizeMarkers(Point iPoint, Point fPoint){ for(int m = 0; m < this.markerCount; m++){ if(this.markers[m].isComplete()){ this.markers[m].setInitialMark(this.markers[m].getInitialMark().subPoint(iPoint)); this.markers[m].setFinalMark(this.markers[m].getFinalMark().subPoint(fPoint)); } } } public int getMarkerCount(){ return this.markerCount; } public BlendMarker getMarker(int i){ return this.markers[i]; } }