public int compare(final Light l1, final Light l2) { final double v1 = getValueFor(l1, _sp.getWorldBound()); final double v2 = getValueFor(l2, _sp.getWorldBound()); final double cmp = v1 - v2; if (0 > cmp) { return 1; } else if (0 < cmp) { return -1; } else { return 0; } } }
public int compare(final Light l1, final Light l2) { final double v1 = getValueFor(l1, _sp.getWorldBound()); final double v2 = getValueFor(l2, _sp.getWorldBound()); final double cmp = v1 - v2; if (0 > cmp) { return 1; } else if (0 < cmp) { return -1; } else { return 0; } } }
protected double calculateHandleScale(final InteractManager manager) { final Spatial target = manager.getSpatialTarget(); if (target != null && target.getWorldBound() != null) { final BoundingVolume bound = target.getWorldBound(); final ReadOnlyVector3 trans = target.getWorldTranslation(); return Math.max(AbstractInteractWidget.MIN_SCALE, bound.getRadius() + trans.subtract(bound.getCenter(), _calcVec3A).length()); } return 1.0; }
if (child != null && child.getWorldBound() != null && boundIsValid(child.getWorldBound())) { if (firstRun) { _receiverBounds.setCenter(child.getWorldBound().getCenter()); _receiverBounds.setXExtent(0); _receiverBounds.setYExtent(0); firstRun = false; _receiverBounds.mergeLocal(child.getWorldBound()); hasValidBounds = true; if (child != null && child.getWorldBound() != null && boundIsValid(child.getWorldBound())) { if (firstRun) { _receiverBounds.setCenter(child.getWorldBound().getCenter()); _receiverBounds.setXExtent(0); _receiverBounds.setYExtent(0); firstRun = false; _receiverBounds.mergeLocal(child.getWorldBound()); hasValidBounds = true;
worldBound.mergeLocal(child.getWorldBound()); if (child.getWorldBound() != null) { worldBound = child.getWorldBound().clone(_worldBound);
worldBound.mergeLocal(child.getWorldBound()); if (child.getWorldBound() != null) { worldBound = child.getWorldBound().clone(_worldBound);
/** * Calculates the distance from a spatial to the camera. Distance is a squared distance. * * @param spat * Spatial to check distance. * @return Distance from Spatial to current context's camera. */ protected double distanceToCam(final Spatial spat) { if (spat._queueDistance != Double.NEGATIVE_INFINITY) { return spat._queueDistance; } final Camera cam = Camera.getCurrentCamera(); if (spat.getWorldBound() != null && Vector3.isValid(spat.getWorldBound().getCenter())) { spat._queueDistance = spat.getWorldBound().distanceToEdge(cam.getLocation()); } else { final ReadOnlyVector3 spatPosition = spat.getWorldTranslation(); if (!Vector3.isValid(spatPosition)) { spat._queueDistance = Double.POSITIVE_INFINITY; } else { spat._queueDistance = cam.getLocation().distance(spatPosition); } } return spat._queueDistance; }
/** * Calculates the distance from a spatial to the camera. Distance is a squared distance. * * @param spat * Spatial to check distance. * @return Distance from Spatial to current context's camera. */ protected double distanceToCam(final Spatial spat) { if (spat._queueDistance != Double.NEGATIVE_INFINITY) { return spat._queueDistance; } final Camera cam = Camera.getCurrentCamera(); if (spat.getWorldBound() != null && Vector3.isValid(spat.getWorldBound().getCenter())) { spat._queueDistance = spat.getWorldBound().distanceToEdge(cam.getLocation()); } else { final ReadOnlyVector3 spatPosition = spat.getWorldTranslation(); if (!Vector3.isValid(spatPosition)) { spat._queueDistance = Double.POSITIVE_INFINITY; } else { spat._queueDistance = cam.getLocation().distance(spatPosition); } } return spat._queueDistance; }
if (se.getWorldBound() != null && se.getSceneHints().getCullHint() != CullHint.Always) { final Camera cam = Camera.getCurrentCamera(); final int state = cam.getPlaneState(); if (cam.contains(se.getWorldBound()) != Camera.FrustumIntersect.Outside) { drawBounds(se.getWorldBound(), r); } else { doChildren = false;
if (se.getWorldBound() != null && se.getSceneHints().getCullHint() != CullHint.Always) { final Camera cam = Camera.getCurrentCamera(); final int state = cam.getPlaneState(); if (cam.contains(se.getWorldBound()) != Camera.FrustumIntersect.Outside) { drawBounds(se.getWorldBound(), r); } else { doChildren = false;
/** * Finds a pick using the given ray starting at the scenegraph given as spatial. Results are stored in the given * results value. * * @param spatial * @param ray * @param results * @param ignoreCulled * if true, Spatials with CullHint ALWAYS will be skipped. */ public static void findPick(final Spatial spatial, final Ray3 ray, final PickResults results, final boolean ignoreCulled) { if (spatial == null || !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Pickable) || (ignoreCulled && spatial.getSceneHints().getCullHint() == CullHint.Always) || spatial.getWorldBound() == null || !spatial.getWorldBound().intersects(ray)) { return; } if (spatial instanceof Pickable) { results.addPick(ray, (Pickable) spatial); } else if (spatial instanceof Node) { final Node node = (Node) spatial; for (int i = node.getNumberOfChildren() - 1; i >= 0; i--) { findPick(node.getChild(i), ray, results, ignoreCulled); } } }
/** * Finds a pick using the given ray starting at the scenegraph given as spatial. Results are stored in the given * results value. * * @param spatial * @param ray * @param results * @param ignoreCulled * if true, Spatials with CullHint ALWAYS will be skipped. */ public static void findPick(final Spatial spatial, final Ray3 ray, final PickResults results, final boolean ignoreCulled) { if (spatial == null || !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Pickable) || (ignoreCulled && spatial.getSceneHints().getCullHint() == CullHint.Always) || spatial.getWorldBound() == null || !spatial.getWorldBound().intersects(ray)) { return; } if (spatial instanceof Pickable) { results.addPick(ray, (Pickable) spatial); } else if (spatial instanceof Node) { final Node node = (Node) spatial; for (int i = node.getNumberOfChildren() - 1; i >= 0; i--) { findPick(node.getChild(i), ray, results, ignoreCulled); } } }
public static void findCollisions(final Spatial spatial, final Spatial scene, final CollisionResults results) { if (spatial == scene || spatial.getWorldBound() == null || !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !scene.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return; } if (spatial instanceof Node) { final Node node = (Node) spatial; if (node.getWorldBound().intersects(scene.getWorldBound())) { // further checking needed. for (int i = 0; i < node.getNumberOfChildren(); i++) { PickingUtil.findCollisions(node.getChild(i), scene, results); } } } else if (spatial instanceof Mesh) { final Mesh mesh = (Mesh) spatial; if (mesh.getWorldBound().intersects(scene.getWorldBound())) { if (scene instanceof Node) { final Node parent = (Node) scene; for (int i = 0; i < parent.getNumberOfChildren(); i++) { PickingUtil.findCollisions(mesh, parent.getChild(i), results); } } else { results.addCollision(mesh, (Mesh) scene); } } } }
public static void findCollisions(final Spatial spatial, final Spatial scene, final CollisionResults results) { if (spatial == scene || spatial.getWorldBound() == null || !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !scene.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { return; } if (spatial instanceof Node) { final Node node = (Node) spatial; if (node.getWorldBound().intersects(scene.getWorldBound())) { // further checking needed. for (int i = 0; i < node.getNumberOfChildren(); i++) { PickingUtil.findCollisions(node.getChild(i), scene, results); } } } else if (spatial instanceof Mesh) { final Mesh mesh = (Mesh) spatial; if (mesh.getWorldBound().intersects(scene.getWorldBound())) { if (scene instanceof Node) { final Node parent = (Node) scene; for (int i = 0; i < parent.getNumberOfChildren(); i++) { PickingUtil.findCollisions(mesh, parent.getChild(i), results); } } else { results.addCollision(mesh, (Mesh) scene); } } } }
public static boolean hasCollision(final Spatial spatial, final Spatial scene, final boolean checkPrimitives) { if (spatial == scene || spatial.getWorldBound() == null || !spatial.getSceneHints().isPickingHintEnabled(PickingHint.Collidable) || !scene.getSceneHints().isPickingHintEnabled(PickingHint.Collidable)) { final Node node = (Node) spatial; if (node.getWorldBound().intersects(scene.getWorldBound())) { if (node.getNumberOfChildren() == 0 && !checkPrimitives) { return true; final Mesh mesh = (Mesh) spatial; if (mesh.getWorldBound().intersects(scene.getWorldBound())) { if (scene instanceof Node) { final Node parent = (Node) scene;
if (cam.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside) { SkeletalDebugger.drawSkeleton(pose, scene, renderer, showLabels); alreadyDrawn.add(pose.getSkeleton());
if (cam.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside) { SkeletalDebugger.drawSkeleton(pose, scene, renderer, showLabels); alreadyDrawn.add(pose.getSkeleton());
/** * Draw a single Joint using the given world-space joint transform. * * @param jntTransform * our joint transform * @param scene * @param renderer * the Renderer to draw with. */ private static void drawJoint(final Transform jntTransform, final Spatial scene, final Renderer renderer) { final BoundingVolume vol = scene.getWorldBound(); double size = 1.0; if (vol != null) { SkeletalDebugger.measureSphere.setCenter(vol.getCenter()); SkeletalDebugger.measureSphere.setRadius(0); SkeletalDebugger.measureSphere.mergeLocal(vol); size = SkeletalDebugger.BONE_RATIO * SkeletalDebugger.measureSphere.getRadius(); } scene.getWorldTransform().multiply(jntTransform, SkeletalDebugger.spTransform); SkeletalDebugger.spTransform.getMatrix().scale(new Vector3(size, size, size), SkeletalDebugger.spMatrix); SkeletalDebugger.spTransform.setRotation(SkeletalDebugger.spMatrix); SkeletalDebugger.joint.setWorldTransform(SkeletalDebugger.spTransform); SkeletalDebugger.joint.draw(renderer); }
/** * Draw a single Joint using the given world-space joint transform. * * @param jntTransform * our joint transform * @param scene * @param renderer * the Renderer to draw with. */ private static void drawJoint(final Transform jntTransform, final Spatial scene, final Renderer renderer) { final BoundingVolume vol = scene.getWorldBound(); double size = 1.0; if (vol != null) { SkeletalDebugger.measureSphere.setCenter(vol.getCenter()); SkeletalDebugger.measureSphere.setRadius(0); SkeletalDebugger.measureSphere.mergeLocal(vol); size = SkeletalDebugger.BONE_RATIO * SkeletalDebugger.measureSphere.getRadius(); } scene.getWorldTransform().multiply(jntTransform, SkeletalDebugger.spTransform); SkeletalDebugger.spTransform.getMatrix().scale(new Vector3(size, size, size), SkeletalDebugger.spMatrix); SkeletalDebugger.spTransform.setRotation(SkeletalDebugger.spMatrix); SkeletalDebugger.joint.setWorldTransform(SkeletalDebugger.spTransform); SkeletalDebugger.joint.draw(renderer); }
protected double getNewScale(final Vector2 oldMouse, final MouseState current, final Camera camera, final InteractManager manager) { // calculate a plane running through the Arrow and facing the camera. _calcVec3A.set(_handle.getWorldTranslation()); _calcVec3B.set(_calcVec3A).addLocal(camera.getLeft()); _calcVec3C.set(_calcVec3A).addLocal(_arrowDirection); final Plane pickPlane = new Plane().setPlanePoints(_calcVec3A, _calcVec3B, _calcVec3C); // find out where we were hitting the plane before getPickRay(oldMouse, camera); _calcRay.intersectsPlane(pickPlane, _calcVec3A); final double oldHeight = _calcVec3A.getY(); // find out where we are hitting the plane now getPickRay(new Vector2(current.getX(), current.getY()), camera); _calcRay.intersectsPlane(pickPlane, _calcVec3A); final double newHeight = _calcVec3A.getY(); // Use distance between points against arrow length to determine how big we need to grow our bounding radius final double delta = newHeight - oldHeight; final double oldRadius = manager.getSpatialTarget().getWorldBound().getRadius(); return manager.getSpatialTarget().getScale().getY() * (1.0 + delta / oldRadius); } }