-/*******************************************************************************\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.processeditor.animations;\r
-\r
-import org.simantics.db.Graph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.processeditor.stubs.PipeRun;\r
-import org.simantics.proconf.g3d.base.JmeRenderingComponent;\r
-\r
-import com.jme.renderer.ColorRGBA;\r
-\r
-\r
-// TODO : this class won't work with valueSets\r
-public class ResourcePipeAnimationController extends PipeAnimationController {\r
- Resource color;\r
- Resource velocity;\r
- \r
- ColorRGBA minColor = new ColorRGBA(0.f,0.f,1.f,1.f);\r
- ColorRGBA maxColor = new ColorRGBA(1.f,0.f,0.f,1.f);\r
- ColorRGBA currentColor = new ColorRGBA(1.f,1.f,1.f,1.f);\r
- \r
- double colorMin;\r
- double colorMax;\r
- double iColorRange;\r
- \r
- double velMin;\r
- double velMax;\r
- double iVelRange;\r
- public ResourcePipeAnimationController(JmeRenderingComponent component, PipeRun pipeline, Resource color,double colorMin, double colorMax, Resource velocity, double velMin, double velMax) {\r
- super(component, pipeline);\r
- this.color = color;\r
- this.velocity = velocity;\r
- \r
- this.colorMin = colorMin;\r
- this.colorMax = colorMax;\r
- this.iColorRange = 1.0/(colorMax-colorMin);\r
- this.velMin = velMin;\r
- this.velMax = velMax;\r
- this.iVelRange = 1.0/(velMax-velMin);\r
- }\r
- \r
- private double getVelocity(Graph graph) {\r
- return graph.getScalarDouble(velocity);\r
- //velocity.getDoubleScalarValue();\r
- }\r
- \r
- private double getColor(Graph graph) {\r
- return graph.getScalarDouble(color);\r
- }\r
- public void updateAnimation(Graph g,double frameTime) {\r
- double d = (getVelocity(g)-velMin)*iVelRange;\r
- float f = (float)((getColor(g)-colorMin)*iColorRange);\r
- currentColor.interpolate(minColor, maxColor, f);\r
- for (PipeFlowAnimation a : animatables) {\r
- a.animate(d,frameTime); \r
- //a.getParticleGeometry().setDefaultColor(currentColor);\r
- a.getParticleGeometry().setStartColor(currentColor);\r
- a.getParticleGeometry().setEndColor(currentColor);\r
- }\r
- }\r
- \r
- \r
-\r
-}\r