/** * Instantiate the configured shape in Bullet. */ protected void createShape() { objectId = createShape(plane.getNormal(), plane.getConstant()); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId)); // objectId = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant()); // objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setMargin(margin); setScale(scale); setMargin(margin); }
private boolean insidePlane(Plane p, Vector3f axis1, Vector3f axis2, Vector3f axis3, Vector3f tn) { // transform the plane normal in the box local space. tn.set(axis1.dot(p.getNormal()), axis2.dot(p.getNormal()), axis3.dot(p.getNormal())); // distance check float radius = FastMath.abs(tn.x) + FastMath.abs(tn.y) + FastMath.abs(tn.z); float distance = p.pseudoDistance(transform.getTranslation()); if (distance < -radius) { return false; } return true; }
/** * <code>whichSide</code> takes a plane (typically provided by a view * frustum) to determine which side this bound is on. * * @param plane * the plane to check against. */ public Plane.Side whichSide(Plane plane) { float radius = FastMath.abs(xExtent * plane.getNormal().getX()) + FastMath.abs(yExtent * plane.getNormal().getY()) + FastMath.abs(zExtent * plane.getNormal().getZ()); float distance = plane.pseudoDistance(center); //changed to < and > to prevent floating point precision problems if (distance < -radius) { return Plane.Side.Negative; } else if (distance > radius) { return Plane.Side.Positive; } else { return Plane.Side.None; } }
/** * * @param p * @param loc * @return true if the ray collides with the given Plane */ public boolean intersectsWherePlane(Plane p, Vector3f loc) { float denominator = p.getNormal().dot(direction); if (denominator > -FastMath.FLT_EPSILON && denominator < FastMath.FLT_EPSILON) { return false; // coplanar } float numerator = -(p.getNormal().dot(origin) - p.getConstant()); float ratio = numerator / denominator; if (ratio < FastMath.FLT_EPSILON) { return false; // intersects behind origin } loc.set(direction).multLocal(ratio).addLocal(origin); return true; }
/** * Set the water plane for this processor. * @param plane */ public void setPlane(Plane plane) { this.plane.setConstant(plane.getConstant()); this.plane.setNormal(plane.getNormal()); updateClipPlanes(); }
protected void createShape() { cShape = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant()); cShape.setLocalScaling(Converter.convert(getScale())); cShape.setMargin(margin); }
Vector3f point = clipPlane.getNormal().mult(clipPlane.getConstant(), vars.vect1); Vector3f pp = ivm.mult(point, vars.vect2); Vector3f pn = ivm.multNormal(clipPlane.getNormal(), vars.vect3); Vector4f clipPlaneV = vars.vect4f1.set(pn.x * sideFactor, pn.y * sideFactor, pn.z * sideFactor, -(pp.dot(pn)) * sideFactor);
Vector3f leftPlaneNormal = worldPlane[LEFT_PLANE].getNormal(); leftPlaneNormal.x = left.x * coeffLeft[0]; leftPlaneNormal.y = left.y * coeffLeft[0]; Vector3f rightPlaneNormal = worldPlane[RIGHT_PLANE].getNormal(); rightPlaneNormal.x = left.x * coeffRight[0]; rightPlaneNormal.y = left.y * coeffRight[0]; Vector3f bottomPlaneNormal = worldPlane[BOTTOM_PLANE].getNormal(); bottomPlaneNormal.x = up.x * coeffBottom[0]; bottomPlaneNormal.y = up.y * coeffBottom[0]; Vector3f topPlaneNormal = worldPlane[TOP_PLANE].getNormal(); topPlaneNormal.x = up.x * coeffTop[0]; topPlaneNormal.y = up.y * coeffTop[0];
Vector3f perpDirection = vars.vect2.set(direction).crossLocal(plane.getNormal()).normalizeLocal().crossLocal(direction);
this.viewportChanged = true; for (int i = 0; i < MAX_WORLD_PLANES; ++i) { worldPlane[i].setNormal(cam.worldPlane[i].getNormal()); worldPlane[i].setConstant(cam.worldPlane[i].getConstant());
@Override public void simpleUpdate(float tpf) { TempVars vars = TempVars.get(); boolean intersect = spotLight.intersectsFrustum(frustumCam, vars); if (intersect) { geom.getMaterial().setColor("Diffuse", ColorRGBA.Green); } else { geom.getMaterial().setColor("Diffuse", ColorRGBA.White); } Vector3f farPoint = vars.vect1.set(spotLight.getPosition()).addLocal(vars.vect2.set(spotLight.getDirection()).multLocal(spotLight.getSpotRange())); //computing the radius of the base disc float farRadius = (spotLight.getSpotRange() / FastMath.cos(spotLight.getSpotOuterAngle())) * FastMath.sin(spotLight.getSpotOuterAngle()); //computing the projection direction : perpendicular to the light direction and coplanar with the direction vector and the normal vector Vector3f perpDirection = vars.vect2.set(spotLight.getDirection()).crossLocal(frustumCam.getWorldPlane(3).getNormal()).normalizeLocal().crossLocal(spotLight.getDirection()); //projecting the far point on the base disc perimeter Vector3f projectedPoint = vars.vect3.set(farPoint).addLocal(perpDirection.multLocal(farRadius)); vars.release(); // boxGeo.setLocalTranslation(spotLight.getPosition()); // boxGeo.setLocalTranslation(projectedPoint); } }
protected void createShape() { objectId = createShape(plane.getNormal(), plane.getConstant()); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId)); // objectId = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant()); // objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setMargin(margin); setScale(scale); setMargin(margin); }
protected void createShape() { objectId = createShape(plane.getNormal(), plane.getConstant()); Logger.getLogger(this.getClass().getName()).log(Level.FINE, "Created Shape {0}", Long.toHexString(objectId)); // objectId = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant()); // objectId.setLocalScaling(Converter.convert(getScale())); // objectId.setMargin(margin); setScale(scale); setMargin(margin); }
/** * * @param p * @param loc * @return true if the ray collides with the given Plane */ public boolean intersectsWherePlane(Plane p, Vector3f loc) { float denominator = p.getNormal().dot(direction); if (denominator > -FastMath.FLT_EPSILON && denominator < FastMath.FLT_EPSILON) { return false; // coplanar } float numerator = -(p.getNormal().dot(origin) - p.getConstant()); float ratio = numerator / denominator; if (ratio < FastMath.FLT_EPSILON) { return false; // intersects behind origin } loc.set(direction).multLocal(ratio).addLocal(origin); return true; }
/** * * @param p * @param loc * @return true if the ray collides with the given Plane */ public boolean intersectsWherePlane(Plane p, Vector3f loc) { float denominator = p.getNormal().dot(direction); if (denominator > -FastMath.FLT_EPSILON && denominator < FastMath.FLT_EPSILON) { return false; // coplanar } float numerator = -(p.getNormal().dot(origin) - p.getConstant()); float ratio = numerator / denominator; if (ratio < FastMath.FLT_EPSILON) { return false; // intersects behind origin } loc.set(direction).multLocal(ratio).addLocal(origin); return true; }
/** * Set the water plane for this processor. * @param plane */ public void setPlane(Plane plane) { this.plane.setConstant(plane.getConstant()); this.plane.setNormal(plane.getNormal()); updateClipPlanes(); }
/** * Set the water plane for this processor. * @param plane */ public void setPlane(Plane plane) { this.plane.setConstant(plane.getConstant()); this.plane.setNormal(plane.getNormal()); updateClipPlanes(); }
/** * Set the water plane for this processor. * @param plane */ public void setPlane(Plane plane) { this.plane.setConstant(plane.getConstant()); this.plane.setNormal(plane.getNormal()); updateClipPlanes(); }
protected void createShape() { cShape = new StaticPlaneShape(Converter.convert(plane.getNormal()),plane.getConstant()); cShape.setLocalScaling(Converter.convert(getScale())); cShape.setMargin(margin); }