/******************************************************************************* * Copyright (c) 2007- VTT Technical Research Centre of Finland. * 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 java.util.ArrayList; import java.util.List; import org.simantics.db.Graph; import org.simantics.db.Resource; public class ResourceAnimationController implements AnimationController { List animatables = new ArrayList(); Resource source; public ResourceAnimationController(Resource source) { this.source = source; } public void addAnimatable(Animatable animatable) { animatables.add(animatable); } public void setAnimatable(Animatable animatable) { animatables.clear(); animatables.add(animatable); } protected double getValue(Graph graph) { //return PropertyUtils.getScalarDoubleValue(source); return graph.getScalarDouble(source); //source.getDoubleValue(); } public void updateAnimation(Graph graph, double frameTime) { double d = getValue(graph); d = d - Math.floor(d); if (d > 1.0) { d = 1.0; } else if (d < 0.0) { d = 0.0; } for (Animatable a : animatables) a.animate(d,frameTime); } public void dispose() { } }