本文整理汇总了Java中com.jme.bounding.BoundingBox.getExtent方法的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox.getExtent方法的具体用法?Java BoundingBox.getExtent怎么用?Java BoundingBox.getExtent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme.bounding.BoundingBox
的用法示例。
在下文中一共展示了BoundingBox.getExtent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSpatializer
import com.jme.bounding.BoundingBox; //导入方法依赖的package包/类
private Spatializer getSpatializer(BoundingBox bounds) {
BoundingBox boundingBox = (BoundingBox) bounds;
Vector3f center = boundingBox.getCenter();
Vector3f extent = boundingBox.getExtent(null);
double lowerLeftX = center.getX() - extent.getX();
double lowerLeftY = center.getY() - extent.getY();
double lowerLeftZ = center.getZ() - extent.getZ();
double upperRightX = center.getX() + extent.getX();
double upperRightY = center.getY() + extent.getY();
double upperRightZ = center.getZ() + extent.getZ();
return new AmbientSpatializer(lowerLeftX, lowerLeftY, lowerLeftZ,
upperRightX, upperRightY, upperRightZ);
}
示例2: encloses
import com.jme.bounding.BoundingBox; //导入方法依赖的package包/类
/**
* Returns true if the parent bounds fully encloses the child
*/
public static boolean encloses(BoundingBox parent, BoundingSphere child) {
Vector3f pCenter = parent.getCenter();
Vector3f pExtent = parent.getExtent(null);
Vector3f cCenter = child.getCenter();
float radius= child.getRadius();
if (cCenter.x+radius > pCenter.x + pExtent.x ||
cCenter.y+radius > pCenter.y + pExtent.y ||
cCenter.z+radius > pCenter.z + pExtent.z)
return false;
if (cCenter.x-radius < pCenter.x - pExtent.x ||
cCenter.y-radius < pCenter.y - pExtent.y ||
cCenter.z-radius < pCenter.z - pExtent.z)
return false;
return true;
}
示例3: contains
import com.jme.bounding.BoundingBox; //导入方法依赖的package包/类
private boolean contains(BoundingBox bounds, Vector3f point) {
Vector3f center = bounds.getCenter();
Vector3f extent = bounds.getExtent(null);
return FastMath.abs(center.x - point.x) - extent.x <= .01
&& FastMath.abs(center.y - point.y) - extent.y <= .01
&& FastMath.abs(center.z - point.z) - extent.z <= .01;
}
示例4: drawBounds
import com.jme.bounding.BoundingBox; //导入方法依赖的package包/类
private void drawBounds(BoundingVolume bounds, Graphics2D g, boolean fill, Color color) {
Color current = g.getColor();
if (bounds instanceof BoundingBox) {
BoundingBox box = (BoundingBox)bounds;
center = box.getCenter(center);
extent = box.getExtent(extent);
if (extent.x==Float.POSITIVE_INFINITY)
return;
g.setColor(color);
if (fill) {
g.fillRect((int)((center.x-extent.x)*scale),
(int)((center.z-extent.z)*scale),
(int)((extent.x*2)*scale),
(int)((extent.z*2)*scale));
} else {
g.drawRect((int)((center.x-extent.x)*scale),
(int)((center.z-extent.z)*scale),
(int)((extent.x*2)*scale),
(int)((extent.z*2)*scale));
}
g.setColor(current);
} else if (bounds instanceof BoundingSphere) {
BoundingSphere sphere = (BoundingSphere)bounds;
center = sphere.getCenter(center);
float radius = sphere.getRadius();
if (radius==Float.POSITIVE_INFINITY)
return;
g.setColor(color);
if (fill) {
g.fillOval((int)((center.x-radius)*scale),
(int)((center.z-radius)*scale),
(int)((radius*2)*scale),
(int)((radius*2)*scale));
} else {
g.drawOval((int)((center.x-radius)*scale),
(int)((center.z-radius)*scale),
(int)((radius*2)*scale),
(int)((radius*2)*scale));
}
g.setColor(current);
} else {
logger.warning("Unsupported bounds type "+bounds);
}
}