01: /*
02: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/visualtools/PathInterpolatorVisualTool.java,v 1.1 2005/04/20 22:21:29 paulby Exp $
03: *
04: * Sun Public License Notice
05: *
06: * The contents of this file are subject to the Sun Public License Version
07: * 1.0 (the "License"). You may not use this file except in compliance with
08: * the License. A copy of the License is available at http://www.sun.com/
09: *
10: * The Original Code is the Java 3D(tm) Scene Graph Editor.
11: * The Initial Developer of the Original Code is Paul Byrne.
12: * Portions created by Paul Byrne are Copyright (C) 2002.
13: * All Rights Reserved.
14: *
15: * Contributor(s): Paul Byrne.
16: *
17: **/
18: package org.jdesktop.j3dedit.scenegrapheditor.visualtools;
19:
20: import javax.vecmath.Point3f;
21:
22: /**
23: * @author Paul Byrne
24: * @version 1.8, 01/18/02
25: */
26: public class PathInterpolatorVisualTool extends VisualTool {
27:
28: private PointHighlightControl pointHighlights;
29:
30: /** Creates new PathInterpolatorVisualTool */
31: public PathInterpolatorVisualTool(PointSelectionListener listener) {
32: pointHighlights = new PointHighlightControl(listener);
33: this .addChild(pointHighlights);
34: pointHighlights.setPointSize(1f);
35: }
36:
37: /**
38: * Set the point selection listener
39: */
40: public void setPointSelectionListener(
41: PointSelectionListener listener) {
42: pointHighlights.setPointSelectionListener(listener);
43: }
44:
45: /**
46: * Set the interpolator on which this tool acts
47: */
48: public void setInterpolator(
49: javax.media.j3d.PositionPathInterpolator interp) {
50: System.out.println("setting interpolator ");
51: pointHighlights.clear();
52: pointHighlights.setTarget(interp.getTarget());
53: Point3f pos = new Point3f();
54: for (int i = 0; i < interp.getArrayLengths(); i++) {
55: interp.getPosition(i, pos);
56: pointHighlights.addPoint(pos);
57: }
58: }
59:
60: /**
61: * Update the visual of this interpolator.
62: * startIndex, endIndex are the range of KeyFrames that have changed
63: */
64: public void updateInterpolator(
65: javax.media.j3d.PositionPathInterpolator interp,
66: int startIndex, int endIndex) {
67: Point3f pos = new Point3f();
68: for (int i = startIndex; i <= endIndex; i++) {
69: interp.getPosition(i, pos);
70: pointHighlights.movePoint(i, pos);
71: }
72: }
73:
74: public void selectPoint(int index) {
75: pointHighlights.selectPoint(index);
76: }
77:
78: public void reset() {
79: pointHighlights.clear();
80: }
81:
82: }
|