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
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.processeditor.animations;
\r
13 import org.simantics.db.Graph;
\r
14 import org.simantics.db.Resource;
\r
15 import org.simantics.processeditor.stubs.PipeRun;
\r
16 import org.simantics.proconf.g3d.base.JmeRenderingComponent;
\r
18 import com.jme.renderer.ColorRGBA;
\r
21 // TODO : this class won't work with valueSets
\r
22 public class ResourcePipeAnimationController extends PipeAnimationController {
\r
26 ColorRGBA minColor = new ColorRGBA(0.f,0.f,1.f,1.f);
\r
27 ColorRGBA maxColor = new ColorRGBA(1.f,0.f,0.f,1.f);
\r
28 ColorRGBA currentColor = new ColorRGBA(1.f,1.f,1.f,1.f);
\r
37 public ResourcePipeAnimationController(JmeRenderingComponent component, PipeRun pipeline, Resource color,double colorMin, double colorMax, Resource velocity, double velMin, double velMax) {
\r
38 super(component, pipeline);
\r
40 this.velocity = velocity;
\r
42 this.colorMin = colorMin;
\r
43 this.colorMax = colorMax;
\r
44 this.iColorRange = 1.0/(colorMax-colorMin);
\r
45 this.velMin = velMin;
\r
46 this.velMax = velMax;
\r
47 this.iVelRange = 1.0/(velMax-velMin);
\r
50 private double getVelocity(Graph graph) {
\r
51 return graph.getScalarDouble(velocity);
\r
52 //velocity.getDoubleScalarValue();
\r
55 private double getColor(Graph graph) {
\r
56 return graph.getScalarDouble(color);
\r
58 public void updateAnimation(Graph g,double frameTime) {
\r
59 double d = (getVelocity(g)-velMin)*iVelRange;
\r
60 float f = (float)((getColor(g)-colorMin)*iColorRange);
\r
61 currentColor.interpolate(minColor, maxColor, f);
\r
62 for (PipeFlowAnimation a : animatables) {
\r
63 a.animate(d,frameTime);
\r
64 //a.getParticleGeometry().setDefaultColor(currentColor);
\r
65 a.getParticleGeometry().setStartColor(currentColor);
\r
66 a.getParticleGeometry().setEndColor(currentColor);
\r