com.jme3.scene.AssetLinkNode Java Examples
The following examples show how to use
com.jme3.scene.AssetLinkNode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MaterialTreeNode.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) { super.fillContextMenu(nodeTree, items); final Material material = getElement(); final TreeNode<?> parent = notNull(getParent()); final Object parentElement = parent.getElement(); final Object linkNode = parentElement instanceof Spatial ? NodeUtils.findParent((Spatial) parentElement, AssetLinkNode.class::isInstance) : null; if (linkNode == null) { items.add(new SaveAsMaterialAction(nodeTree, this)); } if (material.getKey() != null) { items.add(new MakeAsEmbeddedMaterialAction(nodeTree, this)); } }
Example #2
Source File: NodeTreeNode.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Add the external object to this node. * * @param node this node. * @param cons the change consumer. * @param path the path to the external object. */ @FxThread protected void dropExternalObject(@NotNull final T node, @NotNull final ChangeConsumer cons, @NotNull final Path path) { final SceneLayer defaultLayer = getDefaultLayer(cons); final Path assetFile = notNull(getAssetFile(path), "Not found asset file for " + path); final String assetPath = toAssetPath(assetFile); final ModelKey modelKey = new ModelKey(assetPath); final AssetManager assetManager = EditorUtil.getAssetManager(); final Spatial loadedModel = assetManager.loadModel(assetPath); final AssetLinkNode assetLinkNode = new AssetLinkNode(modelKey); assetLinkNode.attachLinkedChild(loadedModel, modelKey); if (defaultLayer != null) { SceneLayer.setLayer(defaultLayer, loadedModel); } cons.execute(new AddChildOperation(assetLinkNode, node)); }
Example #3
Source File: SpawnToolControl.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Create an asset link node for the spatial. * * @param spatial the spatial. * @return the asset link node. */ @JmeThread protected @NotNull AssetLinkNode linkSpatial(@NotNull Spatial spatial) { var linkNode = new AssetLinkNode(); linkNode.setLocalTranslation(spatial.getLocalTranslation()); linkNode.setName(spatial.getName()); linkNode.setLocalScale(getMinScale()); linkNode.attachLinkedChild(getAssetManager(), (ModelKey) spatial.getKey()); return linkNode; }
Example #4
Source File: DefaultTreeNodeFactory.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FxThread public <T, V extends TreeNode<T>> @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof LayersRoot) { return unsafeCast(new LayersRootTreeNode((LayersRoot) element, objectId)); } else if (element instanceof TerrainGrid) { return unsafeCast(new TerrainGridTreeNode((TerrainGrid) element, objectId)); } else if (element instanceof TerrainQuad) { return unsafeCast(new TerrainQuadTreeNode((TerrainQuad) element, objectId)); } else if (element instanceof SceneNode) { return unsafeCast(new SceneNodeTreeNode((SceneNode) element, objectId)); } else if (element instanceof SceneLayer) { return unsafeCast(new SceneLayerTreeNode((SceneLayer) element, objectId)); } else if (element instanceof Mesh) { return unsafeCast(new MeshTreeNode((Mesh) element, objectId)); } else if (element instanceof Geometry) { return unsafeCast(new GeometryTreeNode<>((Geometry) element, objectId)); } else if (element instanceof AudioNode) { return unsafeCast(new AudioTreeNode((AudioNode) element, objectId)); } else if (element instanceof AssetLinkNode) { return unsafeCast(new AssetLinkNodeTreeNode((AssetLinkNode) element, objectId)); } else if (element instanceof Node) { return unsafeCast(new NodeTreeNode<>((Node) element, objectId)); } else if (element instanceof Material) { return unsafeCast(new MaterialTreeNode((Material) element, objectId)); } else if (element instanceof SceneFiltersNode) { return unsafeCast(new SceneFiltersTreeNode((SceneFiltersNode) element, objectId)); } else if (element instanceof SceneAppStatesNode) { return unsafeCast(new SceneAppStatesTreeNode((SceneAppStatesNode) element, objectId)); } else if (element instanceof Filter) { return unsafeCast(new SceneFilterTreeNode((Filter) element, objectId)); } else if (element instanceof SceneAppState) { return unsafeCast(new SceneAppStateTreeNode((SceneAppState) element, objectId)); } return null; }
Example #5
Source File: LinkModelAction.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * The process of opening file. * * @param file the file */ @FxThread protected void processOpen(@NotNull final Path file) { final NodeTree<?> nodeTree = getNodeTree(); final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer()); final SceneLayer defaultLayer = EditorUtil.getDefaultLayer(consumer); final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file); final String assetPath = toAssetPath(assetFile); final ModelKey modelKey = new ModelKey(assetPath); final AssetManager assetManager = EditorUtil.getAssetManager(); final Spatial loadedModel = assetManager.loadModel(modelKey); final AssetLinkNode assetLinkNode = new AssetLinkNode(modelKey); assetLinkNode.attachLinkedChild(loadedModel, modelKey); assetLinkNode.setUserData(KEY_LOADED_MODEL, true); if (defaultLayer != null) { SceneLayer.setLayer(defaultLayer, assetLinkNode); } final TreeNode<?> treeNode = getNode(); final Node parent = (Node) treeNode.getElement(); consumer.execute(new AddChildOperation(assetLinkNode, parent)); }
Example #6
Source File: AbstractSceneFileEditor.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Apply a new material from an asset tree. * * @param dragEvent the drag event. * @param file the file. */ @FxThread private void applyMaterial(@NotNull final DragEvent dragEvent, @NotNull final Path file) { final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file); final String assetPath = toAssetPath(assetFile); final MA editor3DState = getEditor3DPart(); final MaterialKey materialKey = new MaterialKey(assetPath); final Camera camera = editor3DState.getCamera(); final BorderPane area = get3DArea(); final Point2D areaPoint = area.sceneToLocal(dragEvent.getSceneX(), dragEvent.getSceneY()); EXECUTOR_MANAGER.addJmeTask(() -> { final Geometry geometry = editor3DState.getGeometryByScreenPos((float) areaPoint.getX(), camera.getHeight() - (float) areaPoint.getY()); if (geometry == null) return; final Object linkNode = findParent(geometry, AssetLinkNode.class::isInstance); if (linkNode != null) return; final AssetManager assetManager = EditorUtil.getAssetManager(); final Material material = assetManager.loadAsset(materialKey); final PropertyOperation<ChangeConsumer, Geometry, Material> operation = new PropertyOperation<>(geometry, Messages.MODEL_PROPERTY_MATERIAL, material, geometry.getMaterial()); operation.setApplyHandler(Geometry::setMaterial); execute(operation); }); }
Example #7
Source File: GeomUtils.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Check a possibility to attach the spatial to the node. * * @param node the node. * @param spatial the spatial. * @param isCopy true if the spatial need to copy.. * @return true if the spatial can be attached to the node. */ @FromAnyThread public static boolean canAttach(@NotNull Node node, @NotNull Spatial spatial, boolean isCopy) { if (spatial.getParent() == node && !isCopy) { return false; } else if (node instanceof AssetLinkNode) { return false; } var linkNode = isCopy ? null : NodeUtils.<AssetLinkNode>findParent(spatial.getParent(), AssetLinkNode.class::isInstance); return linkNode == null; }
Example #8
Source File: JmeAssetLinkNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected Sheet createSheet() { Sheet sheet = super.createSheet(); Sheet.Set set = Sheet.createPropertiesSet(); set.setDisplayName("AssetLinkNode"); set.setName(AssetLinkNode.class.getName()); AssetLinkNode obj = geom;//getLookup().lookup(Spatial.class); if (obj == null) { return sheet; } sheet.put(set); return sheet; }
Example #9
Source File: JmeAssetLinkNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected Node[] createNodes(Object key) { if (key instanceof ModelKey) { ModelKey assetKey = (ModelKey) key; return new Node[]{new JmeAssetLinkChild(assetKey, (AssetLinkNode) spatial)}; } return null; }
Example #10
Source File: AssetLinkNodeTreeNode.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
public AssetLinkNodeTreeNode(@NotNull final AssetLinkNode element, final long objectId) { super(element, objectId); }
Example #11
Source File: SpatialTreeNode.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
@Override @FxThread public void fillContextMenu(@NotNull final NodeTree<?> nodeTree, @NotNull final ObservableList<MenuItem> items) { if (!(nodeTree instanceof ModelNodeTree)) { return; } final T element = getElement(); final AssetLinkNode linkNode = findParent(element, AssetLinkNode.class::isInstance); if (linkNode == null) { final Menu createMenu = createCreationMenu(nodeTree); if (createMenu != null) { createMenu.getItems().sort(ACTION_COMPARATOR); items.add(createMenu); } final Menu toolMenu = createToolMenu(nodeTree); if (toolMenu != null) { toolMenu.getItems().sort(ACTION_COMPARATOR); items.add(toolMenu); } } if (linkNode == null || element == linkNode) { items.add(new AddUserDataAction(nodeTree, this)); } if (canRemove()) { items.add(new RemoveNodeAction(nodeTree, this)); } NodeUtils.children(element) .flatMap(ControlUtils::controls) .filter(control -> !ControlUtils.isEnabled(control)) .findAny() .ifPresent(c -> items.add(new EnableAllControlsAction(nodeTree, this))); NodeUtils.children(element) .flatMap(ControlUtils::controls) .filter(ControlUtils::isEnabled) .findAny() .ifPresent(c -> items.add(new DisableAllControlsAction(nodeTree, this))); super.fillContextMenu(nodeTree, items); }
Example #12
Source File: JmeAssetLinkNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public JmeAssetLinkNode(AssetLinkNode spatial, JmeSpatialChildren children) { super(spatial, new AssetLinkChildren(spatial)); getLookupContents().add(spatial); this.geom = spatial; setName(spatial.getName()); }
Example #13
Source File: JmeAssetLinkNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public Class getExplorerObjectClass() { return AssetLinkNode.class; }
Example #14
Source File: JmeAssetLinkNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public org.openide.nodes.Node[] createNodes(Object key, DataObject key2, boolean cookie) { JmeSpatialChildren children = new JmeSpatialChildren((com.jme3.scene.Spatial) key); children.setReadOnly(cookie); children.setDataObject(key2); return new org.openide.nodes.Node[]{new JmeAssetLinkNode((AssetLinkNode) key, children).setReadOnly(cookie)}; }
Example #15
Source File: JmeAssetLinkNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public AssetLinkChildren(AssetLinkNode spatial) { super(spatial); }
Example #16
Source File: JmeAssetLinkNode.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
public JmeAssetLinkChild(ModelKey key, AssetLinkNode linkNode) { super(Children.LEAF); this.key = key; this.linkNode = linkNode; this.setName(key.getName()); }