1 /*******************************************************************************
\r
2 * Copyright (c) 2007- VTT Technical Research Centre of Finland.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.proconf.g3d.shapeeditor.scenegraph;
\r
14 import org.simantics.db.Graph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.proconf.g3d.base.GeometryProviderRegistry;
\r
17 import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase;
\r
18 import org.simantics.proconf.g3d.scenegraph.IGraphicsNode;
\r
19 import org.simantics.proconf.g3d.scenegraph.ShapeNode;
\r
21 import com.jme.scene.Geometry;
\r
22 import com.jme.scene.state.AlphaState;
\r
23 import com.jme.scene.state.ZBufferState;
\r
27 public class CSGShapeNode extends ShapeNode{
\r
30 //protected Geometry axesGeometry = null;
\r
31 protected boolean axesVisible = false;
\r
33 public CSGShapeNode(ThreeDimensionalEditorBase editor,IGraphicsNode parent, Graph graph, Resource shapeResource) {
\r
34 super(editor,parent, graph,shapeResource);
\r
35 //axesGeometry = AxesShape.getShape(editor.getRenderingComponent().getDisplaySystem().getRenderer());
\r
36 ZBufferState zs = editor.getRenderingComponent().getDisplaySystem().getRenderer().createZBufferState();
\r
37 zs.setFunction(ZBufferState.CF_ALWAYS);
\r
38 AlphaState as = editor.getRenderingComponent().getDisplaySystem().getRenderer().createAlphaState();
\r
39 as.setBlendEnabled(true);
\r
40 as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
\r
41 as.setSrcFunction(AlphaState.DB_SRC_ALPHA);
\r
42 // axesGeometry.setRenderState(zs);
\r
43 // axesGeometry.setRenderState(as);
\r
44 // axesGeometry.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
\r
49 public Geometry[] getGeometry(Graph graph) {
\r
51 return GeometryProviderRegistry.getGeometry(getG3DNode(graph), false);
\r
54 public void updateAllGeometry() {
\r
55 //System.out.println("CSGSHapeNode.updateAllGeometry " + shapeResource.getResourceId());
\r
56 editor.getScenegraphAdapter().updateGeometry(shapeResource);
\r
57 if (parent != null && parent instanceof CSGShapeNode) {
\r
58 ((CSGShapeNode)parent).updateAllGeometry();
\r
64 public void updateGeometry(Graph graph) {
\r
65 super.updateGeometry(graph);
\r
66 if (isAxesVisible()) {
\r
67 //getGroup().attachChild(axesGeometry);
\r
69 //axesGeometry.removeFromParent();
\r
75 public boolean isAxesVisible() {
\r
79 public void setAxesVisible(boolean axesVisible) {
\r
81 if (this.axesVisible == axesVisible)
\r
83 this.axesVisible = axesVisible;
\r
84 if (isAxesVisible()) {
\r
85 //getGroup().getParent().attachChild(axesGeometry);
\r
86 //getGroup().attachChild(axesGeometry);
\r
88 //axesGeometry.removeFromParent();
\r
92 public void setSelected(boolean selected) {
\r
93 if (this.selected == selected)
\r
95 this.selected = selected;
\r
98 setSelectedVisible(true);
\r
99 setAxesVisible(true);
\r
100 setTransparentVisible(true);
\r
102 setSelectedVisible(false);
\r
103 setAxesVisible(false);
\r
104 setTransparentVisible(false);
\r