/** * <code>detachChild</code> removes a given child from the node's list. This child will no longe be maintained. * * @param child * the child to remove. * @return the index the child was at. -1 if the child was not in the list. */ public int detachChild(final Spatial child) { if (child == null) { return -1; } if (child.getParent() == this) { final int index = _children.indexOf(child); if (index != -1) { detachChildAt(index); } return index; } return -1; }
/** * <code>detachChild</code> removes a given child from the node's list. This child will no longe be maintained. * * @param child * the child to remove. * @return the index the child was at. -1 if the child was not in the list. */ public int detachChild(final Spatial child) { if (child == null) { return -1; } if (child.getParent() == this) { final int index = _children.indexOf(child); if (index != -1) { detachChildAt(index); } return index; } return -1; }
/** * * <code>attachChildAt</code> attaches a child to this node at an index. This node becomes the child's parent. The * current number of children maintained is returned. <br> * If the child already had a parent it is detached from that former parent. * * @param child * the child to attach to this node. * @return the number of children maintained by this node. */ public int attachChildAt(final Spatial child, final int index) { if (child != null) { if (child == this || (child instanceof Node && hasAncestor((Node) child))) { throw new IllegalArgumentException("Child is already part of this hierarchy."); } if (child.getParent() != this) { if (child.getParent() != null) { child.getParent().detachChild(child); } child.setParent(this); _children.add(index, child); child.markDirty(DirtyType.Attached); if (logger.isLoggable(Level.FINE)) { logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")"); } } } return _children.size(); }
/** * * <code>attachChild</code> attaches a child to this node. This node becomes the child's parent. The current number * of children maintained is returned. <br> * If the child already had a parent it is detached from that former parent. * * @param child * the child to attach to this node. * @return the number of children maintained by this node. */ public int attachChild(final Spatial child) { if (child != null) { if (child == this || (child instanceof Node && hasAncestor((Node) child))) { throw new IllegalArgumentException("Child is already part of this hierarchy."); } if (child.getParent() != this) { if (child.getParent() != null) { child.getParent().detachChild(child); } child.setParent(this); _children.add(child); child.markDirty(DirtyType.Attached); if (logger.isLoggable(Level.FINE)) { logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")"); } } } return _children.size(); }
/** * * <code>attachChild</code> attaches a child to this node. This node becomes the child's parent. The current number * of children maintained is returned. <br> * If the child already had a parent it is detached from that former parent. * * @param child * the child to attach to this node. * @return the number of children maintained by this node. */ public int attachChild(final Spatial child) { if (child != null) { if (child == this || (child instanceof Node && hasAncestor((Node) child))) { throw new IllegalArgumentException("Child is already part of this hierarchy."); } if (child.getParent() != this) { if (child.getParent() != null) { child.getParent().detachChild(child); } child.setParent(this); _children.add(child); child.markDirty(DirtyType.Attached); if (logger.isLoggable(Level.FINE)) { logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")"); } } } return _children.size(); }
/** * * <code>attachChildAt</code> attaches a child to this node at an index. This node becomes the child's parent. The * current number of children maintained is returned. <br> * If the child already had a parent it is detached from that former parent. * * @param child * the child to attach to this node. * @return the number of children maintained by this node. */ public int attachChildAt(final Spatial child, final int index) { if (child != null) { if (child == this || (child instanceof Node && hasAncestor((Node) child))) { throw new IllegalArgumentException("Child is already part of this hierarchy."); } if (child.getParent() != this) { if (child.getParent() != null) { child.getParent().detachChild(child); } child.setParent(this); _children.add(index, child); child.markDirty(DirtyType.Attached); if (logger.isLoggable(Level.FINE)) { logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")"); } } } return _children.size(); }
/** * @param key * property key * @return true if we have the given key somewhere reachable in the scenegraph, based on our SceneHints. */ public boolean hasProperty(final String key) { final PropertyMode mode = getSceneHints().getPropertyMode(); final boolean hasLocal = hasLocalProperty(key); if (mode == PropertyMode.UseOwn) { return hasLocal; } final Node parent = getParent(); if (mode == PropertyMode.UseParentIfUnset) { return hasLocal || parent != null && parent.hasProperty(key); } if (mode == PropertyMode.UseOursLast) { final boolean parentHasProperty = parent != null && parent.hasProperty(key); return parentHasProperty || hasLocal; } return false; }
@Override public void processInput(final Canvas source, final TwoInputStates inputStates, final AtomicBoolean inputConsumed, final InteractManager manager) { final Camera camera = source.getCanvasRenderer().getCamera(); final MouseState current = inputStates.getCurrent().getMouseState(); final MouseState previous = inputStates.getPrevious().getMouseState(); // first process mouse over state checkMouseOver(source, current, manager); // Now check drag status if (!checkShouldDrag(camera, current, previous, inputConsumed, manager)) { return; } // act on drag if (_lastDragSpatial != null && _lastDragSpatial.getParent() instanceof InteractArrow) { final InteractArrow arrow = (InteractArrow) _lastDragSpatial.getParent(); _lastArrow = arrow; final Vector2 oldMouse = new Vector2(previous.getX(), previous.getY()); final Vector3 loc = getNewOffset(arrow, oldMouse, current, camera, manager); final Transform transform = manager.getSpatialState().getTransform(); transform.setTranslation(loc.addLocal(transform.getTranslation())); // apply our filters, if any, now that we've made updates. applyFilters(manager); } }
/** * Get a property from this spatial, optionally inheriting values from higher in the scenegraph based upon the * {@link PropertyMode} set in our scene hints. * * @param key * property key * @return the found property, cast to T * @throws ClassCastException * if property is not correct type */ public <T> T getProperty(final String key, final T defaultValue) { final PropertyMode mode = getSceneHints().getPropertyMode(); if (mode == PropertyMode.UseOwn) { return getLocalProperty(key, defaultValue); } final Node parent = getParent(); if (mode == PropertyMode.UseParentIfUnset) { if (hasLocalProperty(key)) { return getLocalProperty(key, defaultValue); } return parent != null ? parent.getProperty(key, defaultValue) : defaultValue; } if (mode == PropertyMode.UseOursLast) { if (parent.hasProperty(key)) { return parent.getProperty(key, defaultValue); } return getLocalProperty(key, defaultValue); } return defaultValue; }
protected Vector3 getNewOffset(final Vector2 oldMouse, final MouseState current, final Camera camera, final InteractManager manager) { // make plane object final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B, _calcVec3C); // find out where we were hitting the plane before getPickRay(oldMouse, camera); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3A)) { return _calcVec3A.zero(); } // find out where we are hitting the plane now getPickRay(new Vector2(current.getX(), current.getY()), camera); if (!_calcRay.intersectsPlane(pickPlane, _calcVec3B)) { return _calcVec3A.zero(); } // convert to target coord space final Node parent = manager.getSpatialTarget().getParent(); if (parent != null) { parent.getWorldTransform().applyInverse(_calcVec3A); parent.getWorldTransform().applyInverse(_calcVec3B); } return _calcVec3B.subtractLocal(_calcVec3A); } }
final Node parent = manager.getSpatialTarget().getParent(); if (parent != null) { parent.getWorldTransform().applyInverse(_calcVec3C);
final Node parent = manager.getSpatialTarget().getParent(); if (parent != null) { parent.getWorldTransform().applyInverse(_calcVec3A);
final Node parent = manager.getSpatialTarget().getParent(); if (parent != null) { parent.getWorldTransform().applyInverseVector(_calcVec3A);