--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007- VTT Technical Research Centre of Finland.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.proconf.g3d.animation;\r
+\r
+import org.simantics.db.Graph;\r
+import org.simantics.db.Resource;\r
+\r
+public class ScaledResourceAnimationController extends ResourceAnimationController {\r
+ double min;\r
+ double max;\r
+ double irange;\r
+ \r
+ public ScaledResourceAnimationController(Resource source, double min, double max) {\r
+ super(source);\r
+ this.max = max;\r
+ this.min = min;\r
+ this.irange = 1.0/(max - min);\r
+ }\r
+\r
+ \r
+ @Override\r
+ public void updateAnimation(Graph graph, double frameTime) {\r
+ double d = (getValue(graph) - min) * irange;\r
+ if (d > 1.0) {\r
+ d = 1.0;\r
+ } else if (d < 0.0) {\r
+ d = 0.0;\r
+ }\r
+ for (Animatable a : animatables)\r
+ a.animate(d,frameTime);\r
+ }\r
+}\r