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=d345b8b416be11b73b7039b6c4bf3d0aa5e7ea1c;hb=3f308c5d93146caa14c544c4cc93076c4a38f8bb;hp=ef89c3a45dbcaae931b199ecb619f49379f2f58e;hpb=477a3eae417fe71addfcf8f87dab41f87151a384;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 ef89c3a4..d345b8b4 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 @@ -17,9 +17,9 @@ import java.util.List; import javax.vecmath.AxisAngle4d; import javax.vecmath.Quat4d; -import org.simantics.g2d.stubs.anim.Interpolator; -import org.simantics.proconf.animation.curve.SlerpCurve; -import org.simantics.proconf.animation.curve.TCBCurve; +import org.simantics.animation.stubs.Interpolator; +import org.simantics.animation.curve.SlerpCurve; +import org.simantics.animation.curve.TCBCurve; import org.simantics.proconf.g3d.Resources; import org.simantics.proconf.g3d.animation.Animatable; import org.simantics.proconf.g3d.animation.Animation; @@ -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; @@ -39,7 +41,7 @@ import org.simantics.proconf.g3d.stubs.Color; import org.simantics.proconf.g3d.stubs.G3DModel; import org.simantics.proconf.g3d.stubs.G3DNode; import org.simantics.proconf.g3d.stubs.Orientation; -import org.simantics.utils.ErrorLogger; +import org.simantics.utils.ui.ErrorLogger; import com.jme.bounding.BoundingBox; import com.jme.bounding.CollisionTreeManager; @@ -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;