+++ /dev/null
-package fi.vtt.simantics.processeditor.scenegraph;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-import java.util.List;\r
-\r
-import javax.vecmath.AxisAngle4d;\r
-import javax.vecmath.Quat4d;\r
-\r
-import org.simantics.db.Graph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.layer0.utils.EntityFactory;\r
-import org.simantics.layer0.utils.IEntity;\r
-import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;\r
-import org.simantics.proconf.g3d.scenegraph.IGraphicsNode;\r
-import org.simantics.proconf.g3d.scenegraph.ShapeNode;\r
-\r
-import com.jme.math.Quaternion;\r
-import com.jme.renderer.ColorRGBA;\r
-import com.jme.scene.Geometry;\r
-import com.jme.scene.state.MaterialState;\r
-import com.jme.scene.state.RenderState;\r
-\r
-import fi.vtt.simantics.processeditor.ProcessResource;\r
-import fi.vtt.simantics.processeditor.common.ControlPointTools;\r
-import fi.vtt.simantics.processeditor.common.PipingTools;\r
-import fi.vtt.simantics.processeditor.stubs.CodedComponent;\r
-import fi.vtt.simantics.processeditor.stubs.PipeControlPoint;\r
-import fi.vtt.simantics.processeditor.stubs.Plant3DResource;\r
-import fi.vtt.simantics.processeditor.stubs.SizeChangeControlPoint;\r
-\r
-\r
-/**\r
- * This is for hard-coded geometries\r
- * TODO : we need an extension point for geometries,\r
- * so that other code-based geometries can be supported\r
- * \r
- * \r
- * @author Marko Luukkainen <Marko.Luukkainen@vtt.fi>\r
- *\r
- */\r
-public class PipeComponentNode extends ShapeNode {\r
- \r
- enum Type{ELBOW,STRAIGHT,REDUCER};\r
- \r
- Type type;\r
- Resource controlPoint;\r
-\r
- \r
- public PipeComponentNode(ThreeDimensionalEditorBase editor, IGraphicsNode parent, Graph graph, Resource resource) {\r
- super(editor, parent, graph, resource);\r
- CodedComponent component = new CodedComponent(graph,resource);\r
- PipeControlPoint cp = component.getControlPoint();\r
- Plant3DResource p3r = ProcessResource.plant3Dresource;\r
- controlPoint = cp.getResource();\r
- \r
- if (component.isInstanceOf(p3r.Elbow)) {\r
- type = Type.ELBOW; \r
- } else if (component.isInstanceOf(p3r.Straight)) {\r
- type = Type.STRAIGHT;\r
- } else if (component.isInstanceOf(p3r.Elbow)) {\r
- type = Type.REDUCER;\r
- }\r
- \r
- \r
- }\r
- \r
- @Override\r
- public Collection<RenderState> getMaterial() {\r
- MaterialState ms = null;\r
- ms = editor.getRenderingComponent().getDisplaySystem().getRenderer().createMaterialState();\r
- ms.setEmissive(new ColorRGBA(0.f,0.f,0.f,0.f));\r
- ms.setSpecular(new ColorRGBA(1.f,1.f,1.f,1.f));\r
- ms.setEnabled(true);\r
- ms.setShininess(128.f);\r
- if (type == Type.ELBOW) {\r
- ms.setDiffuse(new ColorRGBA(0.5f,0.5f,0.5f,0.f));\r
- ms.setAmbient(new ColorRGBA(0.5f,0.5f,0.5f,0.f));\r
- } else if (type == Type.STRAIGHT) {\r
- ms.setDiffuse(new ColorRGBA(0.75f,0.75f,0.75f,0.f));\r
- ms.setAmbient(new ColorRGBA(0.75f,0.75f,0.75f,0.f));\r
- } else {\r
- ms.setDiffuse(new ColorRGBA(0.6f,0.6f,0.6f,0.f));\r
- ms.setAmbient(new ColorRGBA(0.6f,0.6f,0.6f,0.f));\r
- } \r
- List<RenderState> states = new ArrayList<RenderState>();\r
- states.add(ms);\r
- return states;\r
- }\r
- \r
- \r
- @Override\r
- public void updateTransform(Graph graph) {\r
- if (type == Type.REDUCER) {\r
- SizeChangeControlPoint sccp = new SizeChangeControlPoint(graph, controlPoint);\r
- Quat4d q = ControlPointTools.getControlPointLocalOrientationQuat(sccp, sccp.getRotationAngle()[0], true);\r
- update(q);\r
- } \r
- if (type != Type.STRAIGHT) {\r
- super.updateTransform(graph);\r
- } else {\r
- transform.setLocalTranslation(0.f,0.f,0.f);\r
- transform.setLocalRotation(new Quaternion());\r
- }\r
- }\r
-\r
-}\r