X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.processeditor%2Fsrc%2Forg%2Fsimantics%2Fprocesseditor%2Fanimations%2FPipeAnimationController.java;fp=org.simantics.processeditor%2Fsrc%2Forg%2Fsimantics%2Fprocesseditor%2Fanimations%2FPipeAnimationController.java;h=0000000000000000000000000000000000000000;hb=6b6fcff5d6c326feef07ccf8401f97911778fffe;hp=2231e5a47d3f3213f3ee0473c96fc85c8240d7c1;hpb=504c111db40d78f4913badddd126b283b5504dbb;p=simantics%2F3d.git diff --git a/org.simantics.processeditor/src/org/simantics/processeditor/animations/PipeAnimationController.java b/org.simantics.processeditor/src/org/simantics/processeditor/animations/PipeAnimationController.java deleted file mode 100644 index 2231e5a4..00000000 --- a/org.simantics.processeditor/src/org/simantics/processeditor/animations/PipeAnimationController.java +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************************************* - * 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.processeditor.animations; - -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Path; -import org.simantics.db.Graph; -import org.simantics.layer0.utils.IEntity; -import org.simantics.processeditor.Activator; -import org.simantics.processeditor.ProcessResource; -import org.simantics.processeditor.stubs.PipeRun; -import org.simantics.processeditor.stubs.VariableLengthInlineComponent; -import org.simantics.proconf.g3d.animation.Animatable; -import org.simantics.proconf.g3d.animation.AnimationController; -import org.simantics.proconf.g3d.base.JmeRenderingComponent; - -import com.jme.bounding.BoundingBox; -import com.jme.image.Texture; -import com.jme.intersection.PickResults; -import com.jme.math.Ray; -import com.jme.renderer.Renderer; -import com.jme.scene.Node; -import com.jme.scene.state.AlphaState; -import com.jme.scene.state.TextureState; -import com.jme.scene.state.ZBufferState; -import com.jme.util.TextureManager; -import com.jmex.effects.particles.ParticleGeometry; - - - -public class PipeAnimationController implements AnimationController { - private List pipeAnimations = new ArrayList(); - - List animatables = new ArrayList(); - - private double d = Math.random(); - private double delta = 0.01; - - AlphaState as1; - TextureState ts; - Node particleNode = new Node() { - private static final long serialVersionUID = 7477121374264124684L; - - // Without this picking code tries to pick particles which doesn't work (Causes class cast exception) - public void findPick(Ray toTest, PickResults results) { - return; - } - }; - - public PipeAnimationController(JmeRenderingComponent component, PipeRun pipeline) { - as1 = component.getDisplaySystem().getRenderer().createAlphaState(); - as1.setBlendEnabled(true); - as1.setSrcFunction(AlphaState.SB_SRC_ALPHA); - as1.setDstFunction(AlphaState.DB_ONE); - //as1.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA); - as1.setTestEnabled(true); - as1.setTestFunction(AlphaState.TF_GREATER); - as1.setEnabled(true); - - TextureState ts = component.getDisplaySystem().getRenderer().createTextureState(); - //URL url = FileLocator.find(com.jme.eclipse.Activator.getDefault().getBundle(),new Path("data/textures/flaresmall.jpg"),null); - URL url = FileLocator.find(Activator.getDefault().getBundle(),new Path("icons/bubble.png"),null); - - ts.setTexture( - TextureManager.loadTexture(url, - Texture.MM_LINEAR_LINEAR, - Texture.FM_LINEAR)); - ts.setEnabled(true); - - ZBufferState zs = component.getDisplaySystem().getRenderer().createZBufferState(); - zs.setFunction(ZBufferState.CF_LEQUAL); - zs.setWritable(false); - //zs.setFunction(ZBufferState.CF_ALWAYS); - particleNode.setRenderState(as1); - particleNode.setRenderState(ts); - particleNode.setRenderState(zs); - particleNode.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT); - component.getShadowRoot().attachChild(particleNode); - createAnimations(pipeline); - } - - public void addAnimatable(Animatable animatable) { - animatables.add((PipeFlowAnimation)animatable); - - } - - public void setAnimatable(Animatable animatable) { - animatables.clear(); - animatables.add((PipeFlowAnimation)animatable); - - } - - - public void updateAnimation(Graph g, double frameTime) { - d += delta; - if (d > 1.0) { - d = 1.0; - delta = -delta; - } else if (d < 0.0) { - delta = -delta; - d = 0.0; - } - for (Animatable a : animatables) - a.animate(d,frameTime); - } - - public void dispose() { - for (ParticleGeometry p : pipeAnimations) - p.removeFromParent(); - pipeAnimations.clear(); - - } - - private void createAnimations(PipeRun pipeline) { - List straights = new ArrayList(); - for (IEntity t : pipeline.getChild()) { - if (t.isInstanceOf(ProcessResource.plant3Dresource.VariableLengthInlineComponent)) - straights.add(t); - } - - for (IEntity r : straights) { - animatables.add(new PipeFlowAnimation(pipeAnimations, particleNode, new VariableLengthInlineComponent(r),false)); - } - particleNode.setModelBound(new BoundingBox()); - particleNode.updateModelBound(); - particleNode.updateRenderState(); - } - -}