Java Code Examples for com.jme3.scene.Spatial#getNumControls()
The following examples show how to use
com.jme3.scene.Spatial#getNumControls() .
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: SpatialTreeNode.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) { final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class); final Spatial element = getElement(); final LightList lightList = element.getLocalLightList(); lightList.forEach(light -> { if (!(light instanceof InvisibleObject)) { result.add(FACTORY_REGISTRY.createFor(light)); } }); final int numControls = element.getNumControls(); for (int i = 0; i < numControls; i++) { final Control control = element.getControl(i); result.add(FACTORY_REGISTRY.createFor(control)); } return result; }
Example 2
Source File: ControlUtils.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Create control's stream by the spatial. * * @param spatial the spatial. * @return the control's stream. */ @FromAnyThread public static boolean has(@NotNull Spatial spatial, @NotNull Class<?> type) { var numControls = spatial.getNumControls(); if (numControls < 1) { return false; } for (var i = 0; i < numControls; i++) { if (type.isInstance(spatial.getControl(i))) { return true; } } return false; }
Example 3
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Add the specified object to this space. * * @param obj the PhysicsControl, Spatial-with-PhysicsControl, * PhysicsCollisionObject, or PhysicsJoint to add (not null, modified) */ public void add(Object obj) { if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(this); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { add(node.getControl(i)); } } } else if (obj instanceof PhysicsCollisionObject) { addCollisionObject((PhysicsCollisionObject) obj); } else if (obj instanceof PhysicsJoint) { addJoint((PhysicsJoint) obj); } else { throw (new UnsupportedOperationException("Cannot add this kind of object to the physics space.")); } }
Example 4
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Remove the specified object from this space. * * @param obj the PhysicsCollisionObject to add, or null (modified) */ public void remove(Object obj) { if (obj == null) return; if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(null); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { remove(node.getControl(i)); } } } else if (obj instanceof PhysicsCollisionObject) { removeCollisionObject((PhysicsCollisionObject) obj); } else if (obj instanceof PhysicsJoint) { removeJoint((PhysicsJoint) obj); } else { throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space.")); } }
Example 5
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * adds an object to the physics space * @param obj the PhysicsControl or Spatial with PhysicsControl to add */ public void add(Object obj) { if (obj == null) return; if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(this); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { add(node.getControl(i)); } } } else if (obj instanceof PhysicsCollisionObject) { addCollisionObject((PhysicsCollisionObject) obj); } else if (obj instanceof PhysicsJoint) { addJoint((PhysicsJoint) obj); } else { throw (new UnsupportedOperationException("Cannot add this kind of object to the physics space.")); } }
Example 6
Source File: PhysicsSpace.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * removes an object from the physics space * * @param obj the PhysicsControl or Spatial with PhysicsControl to remove */ public void remove(Object obj) { if (obj == null) return; if (obj instanceof PhysicsControl) { ((PhysicsControl) obj).setPhysicsSpace(null); } else if (obj instanceof Spatial) { Spatial node = (Spatial) obj; for (int i = 0; i < node.getNumControls(); i++) { if (node.getControl(i) instanceof PhysicsControl) { remove(node.getControl(i)); } } } else if (obj instanceof PhysicsCollisionObject) { removeCollisionObject((PhysicsCollisionObject) obj); } else if (obj instanceof PhysicsJoint) { removeJoint((PhysicsJoint) obj); } else { throw (new UnsupportedOperationException("Cannot remove this kind of object from the physics space.")); } }
Example 7
Source File: FocusManagerState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static FocusTarget findFocusTarget( Spatial s ) { if( s == null ) return null; for( int i = 0; i < s.getNumControls(); i++ ) { Control c = s.getControl(i); if( c instanceof FocusTarget ) return (FocusTarget)c; } return null; }
Example 8
Source File: FocusNavigationState.java From Lemur with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Utillity method to get the control for a spatial when we don't * care if the interface implements control. */ protected static <T> T getControl( Spatial s, Class<T> type ) { if( s == null ) { return null; } for( int i = 0; i < s.getNumControls(); i++ ) { Object c = s.getControl(i); if( type.isInstance(c) ) return type.cast(c); } return null; }
Example 9
Source File: RagUtils.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Find the index of the specified scene-graph control in the specified * spatial. * * @param spatial the spatial to search (not null, unaffected) * @param sgc the control to search for (not null, unaffected) * @return the index (≥0) or -1 if not found */ static int findIndex(Spatial spatial, Control sgc) { int numControls = spatial.getNumControls(); int result = -1; for (int controlIndex = 0; controlIndex < numControls; ++controlIndex) { Control control = spatial.getControl(controlIndex); if (control == sgc) { result = controlIndex; break; } } return result; }