/******************************************************************************* * 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.shapeeditor.scenegraph; import org.simantics.db.Graph; import org.simantics.db.Resource; import org.simantics.proconf.g3d.base.GeometryProviderRegistry; import org.simantics.proconf.g3d.base.ThreeDimensionalEditorBase; import org.simantics.proconf.g3d.scenegraph.IGraphicsNode; import org.simantics.proconf.g3d.scenegraph.ShapeNode; import com.jme.scene.Geometry; import com.jme.scene.state.AlphaState; import com.jme.scene.state.ZBufferState; public class CSGShapeNode extends ShapeNode{ //protected Geometry axesGeometry = null; protected boolean axesVisible = false; public CSGShapeNode(ThreeDimensionalEditorBase editor,IGraphicsNode parent, Graph graph, Resource shapeResource) { super(editor,parent, graph,shapeResource); //axesGeometry = AxesShape.getShape(editor.getRenderingComponent().getDisplaySystem().getRenderer()); ZBufferState zs = editor.getRenderingComponent().getDisplaySystem().getRenderer().createZBufferState(); zs.setFunction(ZBufferState.CF_ALWAYS); AlphaState as = editor.getRenderingComponent().getDisplaySystem().getRenderer().createAlphaState(); as.setBlendEnabled(true); as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA); as.setSrcFunction(AlphaState.DB_SRC_ALPHA); // axesGeometry.setRenderState(zs); // axesGeometry.setRenderState(as); // axesGeometry.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT); } public Geometry[] getGeometry(Graph graph) { return GeometryProviderRegistry.getGeometry(getG3DNode(graph), false); } public void updateAllGeometry() { //System.out.println("CSGSHapeNode.updateAllGeometry " + shapeResource.getResourceId()); editor.getScenegraphAdapter().updateGeometry(shapeResource); if (parent != null && parent instanceof CSGShapeNode) { ((CSGShapeNode)parent).updateAllGeometry(); } } @Override public void updateGeometry(Graph graph) { super.updateGeometry(graph); if (isAxesVisible()) { //getGroup().attachChild(axesGeometry); } else { //axesGeometry.removeFromParent(); } } public boolean isAxesVisible() { return axesVisible; } public void setAxesVisible(boolean axesVisible) { if (this.axesVisible == axesVisible) return; this.axesVisible = axesVisible; if (isAxesVisible()) { //getGroup().getParent().attachChild(axesGeometry); //getGroup().attachChild(axesGeometry); } else { //axesGeometry.removeFromParent(); } } public void setSelected(boolean selected) { if (this.selected == selected) return; this.selected = selected; if (selected) { setSelectedVisible(true); setAxesVisible(true); setTransparentVisible(true); } else { setSelectedVisible(false); setAxesVisible(false); setTransparentVisible(false); } } }