mr.setSchedulingBounds(new BoundingSphere()); lineGroup.addChild(mr); MouseZoom mz=new MouseZoom(); mz.setTransformGroup(objRotate); mz.setSchedulingBounds(new BoundingSphere()); lineGroup.addChild(mz); MouseTranslate msl=new MouseTranslate(); msl.setTransformGroup(objRotate); msl.setSchedulingBounds(new BoundingSphere()); lineGroup.addChild(msl); AmbientLight al=new AmbientLight(); al.setBounds(new BoundingSphere()); al.setEnable(true); al.setColor(new Color3f(1,1,1));
/** * Get the ViewPlatform's activation radius */ float getActivationRadius() { return (float) sphere.getRadius(); }
/** * Test for intersection with another bounds object. * @param boundsObject another bounds object * @return true or false indicating if an intersection occured */ @Override boolean intersect(Bounds boundsObject, Point4d position) { return intersect(boundsObject); }
Point3d sphCenter = ((BoundingSphere)bounds).getCenter(); double sphRadius = ((BoundingSphere)bounds).getRadius(); double sqDist = Utils.ptToRaySquare(sphCenter, origin, direction, null); if (sqDist <= (sphRadius+radius)*(sphRadius+radius)) { BoundingSphere bsphere = new BoundingSphere (bounds); bsphere.getCenter (sphCenter); double sphRadius = bsphere.getRadius();
newBoundSphere.set(null); return false; newBoundSphere.set(null); return false; else if( boundsObjects[i].boundId == BOUNDING_BOX) { BoundingBox box = (BoundingBox)boundsObjects[i]; if( this.intersect( box) ){ BoundingBox sbox = new BoundingBox( this ); // convert sphere to box newBoundSphere.combine( tbox ); } else { newBoundSphere.set( tbox ); // set sphere to the intersection of 2 boxesf status = true; } else if( dis+radius <= sphere.radius ) { // this sphere is contained within boundsObject if( status ) { newBoundSphere.combine( this ); } else { newBoundSphere.center.x = center.x; newBoundSphere.radius = radius; status = true; newBoundSphere.updateBoundsStates(); newBoundSphere.combine( sphere ); } else { newBoundSphere.center.x = center.x;
BoundingSphere tmpSphere = new BoundingSphere(boundsObject); tmpSphere.transform(matrix); this.set(tmpSphere);
getViewer().getView().setProjectionPolicy(UniverseSettings.projection); bounds = new BoundingSphere(); bounds.setRadius(Double.POSITIVE_INFINITY);
public void writeBounds( DataOutput out, Bounds bounds ) throws IOException { if (bounds==null) { out.writeInt( 0 ); } else if (bounds instanceof BoundingBox) { out.writeInt( 1 ); // Type Point3d p = new Point3d(); ((BoundingBox)bounds).getLower( p ); writePoint3d( out, p ); ((BoundingBox)bounds).getUpper( p ); writePoint3d( out, p ); } else if (bounds instanceof BoundingSphere) { out.writeInt( 2 ); // Type Point3d p = new Point3d(); ((BoundingSphere)bounds).getCenter( p ); writePoint3d( out, p ); out.writeDouble( ((BoundingSphere)bounds).getRadius() ); } else if (bounds instanceof BoundingPolytope ) { out.writeInt( 3 ); // Type Vector4d[] planes = new Vector4d[ ((BoundingPolytope)bounds).getNumPlanes() ]; ((BoundingPolytope)bounds).getPlanes( planes ); out.writeInt( planes.length ); for(int i=0; i<planes.length; i++) writeVector4d( out, planes[i] ); } else { throw new IOException( "Unsupported bounds class "+bounds.getClass().getName() ); } }
newBoundSphere.set(null); return false; newBoundSphere.set(boundsObject); return true; newBoundSphere.set(this); return true; BoundingBox tbox = new BoundingBox(); BoundingBox box = (BoundingBox)boundsObject; if( this.intersect( box) ){ BoundingBox sbox = new BoundingBox( this ); // convert sphere to box newBoundSphere.set( tbox ); // set sphere to the intersection of 2 boxes return true; } else { newBoundSphere.set(null); return false; (center.z-sphere.center.z)*(center.z-sphere.center.z) ); if ( dis > radius+sphere.radius) { newBoundSphere.set(null); return false; } else if( dis+radius <= sphere.radius ) { // this sphere is contained within boundsObject newBoundSphere.updateBoundsStates(); return true;
boolean intersect(Bounds region) { if (region == null) return false; ViewPlatformRetained vpLists[] = (ViewPlatformRetained []) viewPlatforms.toArray(false); for (int i=viewPlatforms.arraySize()- 1; i>=0; i--) { vpLists[i].schedSphere.getWithLock(tempSphere); if (tempSphere.intersect(region)) { return true; } } return false; }
/** * Set the ViewPlatform's activation radius */ void setActivationRadius(float activationRadius) { sphere.setRadius(activationRadius); if (source != null && source.isLive()) { repaint(); } // Notify behavior scheduler & RenderBin if (source.isLive()) { J3dMessage message = new J3dMessage(); message.type = J3dMessage.UPDATE_VIEWPLATFORM; message.threads = J3dThread.UPDATE_RENDER|J3dThread.UPDATE_BEHAVIOR; message.universe = universe; message.args[0] = this; message.args[1] = new Float(activationRadius); VirtualUniverse.mc.processMessage(message); } else { schedSphere.setRadius(activationRadius); } }
/** * if the passed the "region" is same type as this object * then do a copy, otherwise clone the Bounds and * return */ @Override Bounds copy(Bounds r) { if (r != null && this.boundId == r.boundId) { BoundingSphere region = (BoundingSphere)r; region.radius = radius; region.center.x = center.x; region.center.y = center.y; region.center.z = center.z; region.boundsIsEmpty = boundsIsEmpty; region.boundsIsInfinite = boundsIsInfinite; return region; } else { return (Bounds) this.clone(); } }
Point3d sphCenter = ((BoundingSphere)bounds).getCenter(); double sphRadius = ((BoundingSphere)bounds).getRadius(); double sqDist = Utils.ptToSegSquare(sphCenter, origin, end, null); if (sqDist <= (sphRadius+radius)*(sphRadius+radius)) { BoundingSphere bsphere = new BoundingSphere (bounds); bsphere.getCenter (sphCenter); double sphRadius = bsphere.getRadius();
BoundingSphere sphere = new BoundingSphere(boundsObject); sphere.transform(matrix); this.set(sphere); } else if( boundsObject.boundId == BOUNDING_BOX){
static boolean edgeIntersectSphere (BoundingSphere sphere, Point3d start, Point3d end) { double abLenSq, acLenSq, apLenSq, abDotAp, radiusSq; Vector3d ab = new Vector3d(); Vector3d ap = new Vector3d(); Point3d center = new Point3d(); sphere.getCenter (center); double radius = sphere.getRadius (); ab.x = end.x - start.x; ab.y = end.y - start.y; ab.z = end.z - start.z; ap.x = center.x - start.x; ap.y = center.y - start.y; ap.z = center.z - start.z; abDotAp = ab.dot(ap); if (abDotAp < 0.0) return false; // line segment points away from sphere. abLenSq = ab.lengthSquared(); acLenSq = abDotAp * abDotAp / abLenSq; if (acLenSq < abLenSq) return false; // C doesn't lies between end points of edge. radiusSq = radius * radius; apLenSq = ap.lengthSquared(); if ((apLenSq - acLenSq) <= radiusSq) return true; return false; }
ViewPlatformRetained() { this.nodeType = NodeRetained.VIEWPLATFORM; localBounds = new BoundingBox((Bounds)null); IndexedUnorderSet.init(this, TOTAL_INDEXED_UNORDER_SET_TYPES); schedSphere = (BoundingSphere) sphere.clone(); }
objRotate.addChild(light2); MouseRotate f1=new MouseRotate(); f1.setSchedulingBounds(new BoundingSphere()); f1.setTransformGroup(objRotate); lineGroup.addChild(f1);
Point3d sphCenter = ((BoundingSphere)bounds).getCenter(); double sphRadius = ((BoundingSphere)bounds).getRadius(); double sqDist = Utils.ptToRaySquare(sphCenter, origin, direction, rayPt); vector.sub (rayPt, origin); BoundingSphere bsphere = new BoundingSphere (bounds); bsphere.getCenter (sphCenter); double sphRadius = bsphere.getRadius();