]> gerrit.simantics Code Review - simantics/3d.git/blob - dev/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/animation/TestAnimationController.java
Release
[simantics/3d.git] / dev / org.simantics.proconf.g3d / src / org / simantics / proconf / g3d / animation / TestAnimationController.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\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 import java.util.ArrayList;\r
14 import java.util.List;\r
15 \r
16 import org.simantics.db.Graph;\r
17 \r
18 public class TestAnimationController implements AnimationController {\r
19         List<Animatable> animatables = new ArrayList<Animatable>();\r
20         \r
21         private double d = 0.0;\r
22     private double delta = 0.01;\r
23     \r
24         public void addAnimatable(Animatable animatable) {\r
25                 animatables.add(animatable);\r
26                 \r
27         }\r
28         \r
29         public void setAnimatable(Animatable animatable) {\r
30                 animatables.clear();\r
31                 animatables.add(animatable);\r
32                 \r
33         }\r
34         \r
35         public void updateAnimation(Graph graph, double frameTime) {\r
36                 d += delta;\r
37         if (d > 1.0) {\r
38             d = 1.0;\r
39             delta = -delta;\r
40         } else if (d < 0.0) {\r
41             delta = -delta;\r
42             d = 0.0;\r
43         }\r
44         for (Animatable a : animatables)\r
45             a.animate(d,frameTime);\r
46         }\r
47         \r
48         public void dispose() {\r
49                 \r
50         }\r
51         \r
52         \r
53         \r
54 \r
55 }\r