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