01: /*
02: * $Header: /cvs/j3dfly/J3dEditor/src/org/jdesktop/j3dedit/scenegrapheditor/visualtools/RotPosPathInterpolatorVisualTool.java,v 1.1 2005/04/20 22:21:30 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.6, 01/18/02
25: */
26: public class RotPosPathInterpolatorVisualTool extends VisualTool {
27:
28: private PointHighlightControl pointHighlights;
29:
30: /** Creates new PathInterpolatorVisualTool */
31: public RotPosPathInterpolatorVisualTool(
32: PointSelectionListener pointSelectionListener) {
33: pointHighlights = new PointHighlightControl(
34: pointSelectionListener);
35: this .addChild(pointHighlights);
36: pointHighlights.setPointSize(1f);
37: }
38:
39: /**
40: * Set the point selection listener
41: */
42: public void setPointSelectionListener(
43: PointSelectionListener listener) {
44: pointHighlights.setPointSelectionListener(listener);
45: }
46:
47: /**
48: * Set the interpolator on which this tool acts
49: */
50: public void setInterpolator(
51: javax.media.j3d.RotPosPathInterpolator interp) {
52: pointHighlights.clear();
53: pointHighlights.setTarget(interp.getTarget());
54: Point3f pos = new Point3f();
55: for (int i = 0; i < interp.getArrayLengths(); i++) {
56: interp.getPosition(i, pos);
57: pointHighlights.addPoint(pos);
58: }
59: }
60:
61: /**
62: * Update the visual of this interpolator.
63: * startIndex, endIndex are the range of KeyFrames that have changed
64: */
65: public void updateInterpolator(
66: javax.media.j3d.RotPosPathInterpolator interp,
67: int startIndex, int endIndex) {
68: Point3f pos = new Point3f();
69: for (int i = startIndex; i <= endIndex; i++) {
70: interp.getPosition(i, pos);
71: pointHighlights.movePoint(i, pos);
72: }
73: }
74:
75: public void selectPoint(int index) {
76: pointHighlights.selectPoint(index);
77: }
78:
79: public void reset() {
80: pointHighlights.clear();
81: }
82:
83: }
|