/******************************************************************************* * 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 com.jme.renderer.ColorRGBA; import com.jme.scene.state.MaterialState; public class ChanneledColorInterpolator implements Interpolator { private ScalarInterpolator rInterpolator; private ScalarInterpolator gInterpolator; private ScalarInterpolator bInterpolator; //Material m = null; MaterialState m = null; int type = 1; public static final int AMBIENT = 0; public static final int DIFFUSE = 1; public static final int SPECULAR = 2; public static final int EMISSIVE = 3; public ChanneledColorInterpolator(ScalarInterpolator rInterpolator, ScalarInterpolator gInterpolator, ScalarInterpolator bInterpolator) { this.rInterpolator = rInterpolator; this.gInterpolator = gInterpolator; this.bInterpolator = bInterpolator; } public void interpolate(double delta) { double r = rInterpolator.evaluate(delta); double g = gInterpolator.evaluate(delta); double b = bInterpolator.evaluate(delta); ColorRGBA c = new ColorRGBA((float)r, (float)g, (float)b,0.f); switch (type) { case AMBIENT : m.setAmbient(c); break; case DIFFUSE: m.setDiffuse(c); break; case SPECULAR: m.setSpecular(c); break; case EMISSIVE: m.setEmissive(c); break; } } public void setTarget(Object target) { // m = (Material)target; m = (MaterialState)target; } public void setType(int type) { this.type = type; } }