X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=org.simantics.proconf.g3d%2Fsrc%2Forg%2Fsimantics%2Fproconf%2Fg3d%2Fscenegraph%2FShapeNode.java;h=52afcbc7459cce33554ab471dfbf4d66aac860e2;hb=9ad91ae4a059a4c7b219d2560c5b8b8ed1c5f184;hp=b82265e4fce3653c36e5c4f2ae664c1a8c37560f;hpb=f9e3fe0569bf1cf3bbcdbc56fb81c736cba086f9;p=simantics%2F3d.git diff --git a/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/scenegraph/ShapeNode.java b/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/scenegraph/ShapeNode.java index b82265e4..52afcbc7 100644 --- a/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/scenegraph/ShapeNode.java +++ b/org.simantics.proconf.g3d/src/org/simantics/proconf/g3d/scenegraph/ShapeNode.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 VTT Technical Research Centre of Finland and others. + * 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 @@ -17,7 +17,7 @@ import java.util.List; import javax.vecmath.AxisAngle4d; import javax.vecmath.Quat4d; -import org.simantics.g2d.stubs.anim.Interpolator; +import org.simantics.animation.stubs.Interpolator; import org.simantics.animation.curve.SlerpCurve; import org.simantics.animation.curve.TCBCurve; import org.simantics.proconf.g3d.Resources; @@ -29,6 +29,8 @@ import org.simantics.proconf.g3d.animation.ConstantInterpolator; import org.simantics.proconf.g3d.animation.ScalarInterpolator; import org.simantics.proconf.g3d.animation.SlerpInterpolator; import org.simantics.proconf.g3d.animation.TCBInterpolator; +import org.simantics.proconf.g3d.base.AppearanceProvider; +import org.simantics.proconf.g3d.base.AppearanceProviderRegistry; import org.simantics.proconf.g3d.base.AppearanceTools; import org.simantics.proconf.g3d.base.G3DTools; import org.simantics.proconf.g3d.base.GeometryProvider; @@ -226,7 +228,7 @@ public class ShapeNode extends AbstractGraphicsNode implements Animatable, IGeom G3DNode shape = getG3DNode(graph); - if (renderStates == null) + //if (renderStates == null) updateAppearance(shape); if (isVisible()) { @@ -258,9 +260,9 @@ public class ShapeNode extends AbstractGraphicsNode implements Animatable, IGeom } protected void updateAppearance(IEntity shape) { - Collection appearanceResource; - if ((appearanceResource = shape.getRelatedObjects(Resources.g3dResource.HasAppearance)) != null && appearanceResource.size() > 0) { - renderStates = AppearanceTools.getAppearance(new Appearance(shape.getGraph(),appearanceResource.iterator().next().getResource()), editor.getRenderingComponent().getDisplaySystem().getRenderer()); + AppearanceProvider provider = AppearanceProviderRegistry.getAppearanceProvider(shape); + if (provider != null) { + renderStates = provider.getAppearanceFromResource(shape, editor.getRenderingComponent().getDisplaySystem().getRenderer()); } else { renderStates = getMaterial(); } @@ -461,14 +463,14 @@ public class ShapeNode extends AbstractGraphicsNode implements Animatable, IGeom body.attachChild(mesh); return false; } - org.simantics.g2d.stubs.anim.Animation animation = new org.simantics.g2d.stubs.anim.Animation(graph,res); + org.simantics.animation.stubs.Animation animation = new org.simantics.animation.stubs.Animation(graph,res); G3DNode shape = getG3DNode(graph); G3DNode modelResource = G3DTools.getModelFromResource(graph,shape.getResource()); assert (modelResource != null); G3DModel model = new G3DModel(graph,modelResource.getResource()); - Collection animations = model.getAnimation(); + Collection animations = model.getAnimation(); boolean found = false; - for (org.simantics.g2d.stubs.anim.Animation a : animations) { + for (org.simantics.animation.stubs.Animation a : animations) { if (a.getResource().equals(animation.getResource())) { found = true; break; @@ -478,10 +480,10 @@ public class ShapeNode extends AbstractGraphicsNode implements Animatable, IGeom ErrorLogger.getDefault().logWarning("Shape " + shape.getResource() + " cannot handle animation " + animation.getResource() + " because it isn't model's animation", null); return false; } - Collection interpolators = animation.getInterpolator(); - List handled = new ArrayList(); - List precalculated = new ArrayList(); - for (org.simantics.g2d.stubs.anim.Interpolator i : interpolators) { + Collection interpolators = animation.getInterpolator(); + List handled = new ArrayList(); + List precalculated = new ArrayList(); + for (org.simantics.animation.stubs.Interpolator i : interpolators) { IEntity target = i.getTarget(); if (G3DTools.hasProperty(graph,shape.getResource(),target.getResource())) handled.add(i); @@ -497,16 +499,16 @@ public class ShapeNode extends AbstractGraphicsNode implements Animatable, IGeom this.animation = new Animation(); - org.simantics.g2d.stubs.anim.Interpolator[] pos = new org.simantics.g2d.stubs.anim.Interpolator[3]; - org.simantics.g2d.stubs.anim.Interpolator[] ambient = new org.simantics.g2d.stubs.anim.Interpolator[3]; - org.simantics.g2d.stubs.anim.Interpolator[] diffuse = new org.simantics.g2d.stubs.anim.Interpolator[3]; - org.simantics.g2d.stubs.anim.Interpolator[] specular = new org.simantics.g2d.stubs.anim.Interpolator[3]; - org.simantics.g2d.stubs.anim.Interpolator[] emissive = new org.simantics.g2d.stubs.anim.Interpolator[3]; + org.simantics.animation.stubs.Interpolator[] pos = new org.simantics.animation.stubs.Interpolator[3]; + org.simantics.animation.stubs.Interpolator[] ambient = new org.simantics.animation.stubs.Interpolator[3]; + org.simantics.animation.stubs.Interpolator[] diffuse = new org.simantics.animation.stubs.Interpolator[3]; + org.simantics.animation.stubs.Interpolator[] specular = new org.simantics.animation.stubs.Interpolator[3]; + org.simantics.animation.stubs.Interpolator[] emissive = new org.simantics.animation.stubs.Interpolator[3]; Builtins builtins = graph.getBuiltins(); - for (org.simantics.g2d.stubs.anim.Interpolator i : handled) { + for (org.simantics.animation.stubs.Interpolator i : handled) { IEntity target = i.getTarget(); //if (target.isInstanceOf(Resources.g3dResource.LocalOrientation)) { if (target.isInstanceOf(Resources.g3dResource.Orientation) && target.getRelatedObjects(Resources.g3dResource.LocalOrientationOf).size() == 1) { @@ -530,7 +532,7 @@ public class ShapeNode extends AbstractGraphicsNode implements Animatable, IGeom ErrorLogger.getDefault().logWarning("Cannot map animation interpolator " + i.getResource() + " to target (Position ?)" + target.getResource(), null); } } else if (parent.isInstanceOf(Resources.g3dResource.Color)) { - org.simantics.g2d.stubs.anim.Interpolator[] color = null; + org.simantics.animation.stubs.Interpolator[] color = null; if (parent.isInstanceOf(Resources.g3dResource.Color) && parent.getRelatedObjects(Resources.g3dResource.AmbientColorOf).size() > 0) { color = ambient; } else if (parent.isInstanceOf(Resources.g3dResource.Color)&& parent.getRelatedObjects(Resources.g3dResource.DiffuseColorOf).size() > 0) { @@ -644,7 +646,7 @@ public class ShapeNode extends AbstractGraphicsNode implements Animatable, IGeom return true; } - private void addColorInterpolator(G3DNode shape, org.simantics.g2d.stubs.anim.Interpolator[] color, int type) { + private void addColorInterpolator(G3DNode shape, org.simantics.animation.stubs.Interpolator[] color, int type) { if (color[0] != null || color[1] != null || color[2] != null) { ScalarInterpolator xIp; ScalarInterpolator yIp;