]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/animation/ChanneledPositionInterpolator.java
b271d68dbfa8ed2c92838c1c1dbb7f86235f8295
[simantics/3d.git] / org.simantics.proconf.g3d / src / org / simantics / proconf / g3d / animation / ChanneledPositionInterpolator.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
3  * All rights reserved. This program and the accompanying materials\r
4  * are made available under the terms of the Eclipse Public License v1.0\r
5  * which accompanies this distribution, and is available at\r
6  * http://www.eclipse.org/legal/epl-v10.html\r
7  *\r
8  * Contributors:\r
9  *     VTT Technical Research Centre of Finland - initial API and implementation\r
10  *******************************************************************************/\r
11 package org.simantics.proconf.g3d.animation;\r
12 \r
13 \r
14 import com.jme.math.Vector3f;\r
15 import com.jme.scene.Node;\r
16 \r
17 \r
18 public class ChanneledPositionInterpolator implements Interpolator {\r
19     private ScalarInterpolator xInterpolator;\r
20     private ScalarInterpolator yInterpolator;\r
21     private ScalarInterpolator zInterpolator;\r
22 \r
23     Node node;\r
24     \r
25     public ChanneledPositionInterpolator(ScalarInterpolator xInterpolator, ScalarInterpolator yInterpolator, ScalarInterpolator zInterpolator) {\r
26         this.xInterpolator = xInterpolator;\r
27         this.yInterpolator = yInterpolator;\r
28         this.zInterpolator = zInterpolator;\r
29     }\r
30     \r
31     public void interpolate(double delta) {\r
32         double x = xInterpolator.evaluate(delta);\r
33         double y = yInterpolator.evaluate(delta);\r
34         double z = zInterpolator.evaluate(delta);\r
35 \r
36         node.setLocalTranslation(new Vector3f((float)x,(float)y,(float)z));\r
37     }\r
38     \r
39     public void setTarget(Object target) {\r
40         node = (Node)target;\r
41     }\r
42 \r
43 }\r