Java Code Examples for com.jme3.scene.control.Control#setSpatial()

The following examples show how to use com.jme3.scene.control.Control#setSpatial() . 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: Spatial.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the first control that is an instance of the given class.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public void removeControl(Class<? extends Control> controlType) {
    boolean before = requiresUpdates();
    for (int i = 0; i < controls.size(); i++) {
        if (controlType.isAssignableFrom(controls.get(i).getClass())) {
            Control control = controls.remove(i);
            control.setSpatial(null);
            break; // added to match the javadoc  -pspeed
        }
    }
    boolean after = requiresUpdates();
    // If the requirement to be updated has changed
    // then we need to let the parent node know so it
    // can rebuild its update list.
    if( parent != null && before != after ) {
        parent.invalidateUpdateList();
    }
}
 
Example 2
Source File: Spatial.java    From jmonkeybuilder with Apache License 2.0 6 votes vote down vote up
/**
 * Removes the given control from this spatial's controls.
 *
 * @param control The control to remove
 * @return True if the control was successfully removed. False if the
 * control is not assigned to this spatial.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public boolean removeControl(Control control) {
    boolean before = requiresUpdates();
    boolean result = controls.remove(control);
    if (result) {
        control.setSpatial(null);
    }

    boolean after = requiresUpdates();
    // If the requirement to be updated has changed
    // then we need to let the parent node know so it
    // can rebuild its update list.
    if( parent != null && before != after ) {
        parent.invalidateUpdateList();
    }
    return result;
}
 
Example 3
Source File: Spatial.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Removes the first control that is an instance of the given class.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public void removeControl(Class<? extends Control> controlType) {
    boolean before = requiresUpdates();
    for (int i = 0; i < controls.size(); i++) {
        if (controlType.isAssignableFrom(controls.get(i).getClass())) {
            Control control = controls.remove(i);
            control.setSpatial(null);
            break; // added to match the javadoc  -pspeed
        }
    }
    boolean after = requiresUpdates();
    // If the requirement to be updated has changed
    // then we need to let the parent node know so it
    // can rebuild its update list.
    if (parent != null && before != after) {
        parent.invalidateUpdateList();
    }
}
 
Example 4
Source File: Spatial.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Removes the given control from this spatial's controls.
 *
 * @param control The control to remove
 * @return True if the control was successfully removed. False if the
 * control is not assigned to this spatial.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control)
 */
public boolean removeControl(Control control) {
    boolean before = requiresUpdates();
    boolean result = controls.remove(control);
    if (result) {
        control.setSpatial(null);
    }

    boolean after = requiresUpdates();
    // If the requirement to be updated has changed
    // then we need to let the parent node know so it
    // can rebuild its update list.
    if (parent != null && before != after) {
        parent.invalidateUpdateList();
    }
    return result;
}
 
Example 5
Source File: Spatial.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Add a control to the list of controls.
 * @param control The control to add.
 *
 * @see Spatial#removeControl(java.lang.Class)
 */
public void addControl(Control control) {
    boolean before = requiresUpdates();
    controls.add(control);
    control.setSpatial(this);
    boolean after = requiresUpdates();
    // If the requirement to be updated has changed
    // then we need to let the parent node know so it
    // can rebuild its update list.
    if( parent != null && before != after ) {
        parent.invalidateUpdateList();
    }
}
 
Example 6
Source File: Spatial.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Add a control to the list of controls.
 *
 * @param control The control to add.
 *
 * @see Spatial#removeControl(java.lang.Class)
 */
public void addControl(Control control) {
    boolean before = requiresUpdates();
    controls.add(control);
    control.setSpatial(this);
    boolean after = requiresUpdates();
    // If the requirement to be updated has changed
    // then we need to let the parent node know so it
    // can rebuild its update list.
    if (parent != null && before != after) {
        parent.invalidateUpdateList();
    }
}
 
Example 7
Source File: Spatial.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Removes the first control that is an instance of the given class.
 *
 * @see Spatial#addControl(com.jme3.scene.control.Control) 
 */
public void removeControl(Class<? extends Control> controlType) {
    for (int i = 0; i < controls.size(); i++) {
        if (controlType.isAssignableFrom(controls.get(i).getClass())) {
            Control control = controls.remove(i);
            control.setSpatial(null);
        }
    }
}
 
Example 8
Source File: Spatial.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
/**
 *  The old clone() method that did not use the new Cloner utility.
 */
public Spatial oldClone(boolean cloneMaterial) {
    try {
        Spatial clone = (Spatial) super.clone();
        if (worldBound != null) {
            clone.worldBound = worldBound.clone();
        }
        clone.worldLights = worldLights.clone();
        clone.localLights = localLights.clone();

        // Set the new owner of the light lists
        clone.localLights.setOwner(clone);
        clone.worldLights.setOwner(clone);

        clone.worldOverrides = new SafeArrayList<>(MatParamOverride.class);
        clone.localOverrides = new SafeArrayList<>(MatParamOverride.class);

        for (MatParamOverride override : localOverrides) {
            clone.localOverrides.add((MatParamOverride) override.clone());
        }

        // No need to force cloned to update.
        // This node already has the refresh flags
        // set below so it will have to update anyway.
        clone.worldTransform = worldTransform.clone();
        clone.localTransform = localTransform.clone();

        if (clone instanceof Node) {
            Node node = (Node) this;
            Node nodeClone = (Node) clone;
            nodeClone.children = new SafeArrayList<Spatial>(Spatial.class);
            for (Spatial child : node.children) {
                Spatial childClone = child.clone(cloneMaterial);
                childClone.parent = nodeClone;
                nodeClone.children.add(childClone);
            }
        }

        clone.parent = null;
        clone.setBoundRefresh();
        clone.setTransformRefresh();
        clone.setLightListRefresh();
        clone.setMatParamOverrideRefresh();

        clone.controls = new SafeArrayList<Control>(Control.class);
        for (int i = 0; i < controls.size(); i++) {
            Control newControl = controls.get(i).cloneForSpatial(clone);
            newControl.setSpatial(clone);
            clone.controls.add(newControl);
        }

        if (userData != null) {
            clone.userData = (HashMap<String, Savable>) userData.clone();
        }

        return clone;
    } catch (CloneNotSupportedException ex) {
        throw new AssertionError();
    }
}
 
Example 9
Source File: Spatial.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Removes the given control from this spatial's controls.
 * 
 * @param control The control to remove
 * @return True if the control was successfuly removed. False if 
 * the control is not assigned to this spatial.
 * 
 * @see Spatial#addControl(com.jme3.scene.control.Control) 
 */
public boolean removeControl(Control control) {
    boolean result = controls.remove(control);
    if (result) {
        control.setSpatial(null);
    }

    return result;
}
 
Example 10
Source File: Spatial.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Add a control to the list of controls.
 * @param control The control to add.
 *
 * @see Spatial#removeControl(java.lang.Class) 
 */
public void addControl(Control control) {
    controls.add(control);
    control.setSpatial(this);
}