当前位置: 首页>>代码示例>>Java>>正文


Java BoundingSphere.getCenter方法代码示例

本文整理汇总了Java中com.jme.bounding.BoundingSphere.getCenter方法的典型用法代码示例。如果您正苦于以下问题:Java BoundingSphere.getCenter方法的具体用法?Java BoundingSphere.getCenter怎么用?Java BoundingSphere.getCenter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme.bounding.BoundingSphere的用法示例。


在下文中一共展示了BoundingSphere.getCenter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: encloses

import com.jme.bounding.BoundingSphere; //导入方法依赖的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;
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:22,代码来源:Math3DUtils.java

示例2: drawBounds

import com.jme.bounding.BoundingSphere; //导入方法依赖的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);
    }
}
 
开发者ID:josmas,项目名称:openwonderland,代码行数:50,代码来源:CellBoundsViewer.java

示例3: getVolumeAndCentroid

import com.jme.bounding.BoundingSphere; //导入方法依赖的package包/类
@Override
public float getVolumeAndCentroid(IFluidRegion region, Vector3f gravityUnit, Vector3f store) {
	BoundingSphere bound;
	
	try{
		bound = getCustomWorldBound();
	}catch(ClassCastException e)
	{
		throw new BoundClassException(e.getMessage());
	}

	Plane waterPlane = _plane;
	waterPlane.getNormal().set(gravityUnit);
	waterPlane.setConstant(region.getFluidHeight()); 
	float radius = bound.getRadius();

	Vector3f center = bound.getCenter(_temp3);
	
	//move the center down along gravity by the amount radius
	
	//intersect the line center, gravity unit with the plane
	Vector3f intersect = _temp;

	
	boolean result = intersectLineWithPlane(waterPlane, center, gravityUnit, true, intersect);
	if (!result)
		return 0;
	
	float height;//height here is relative to center, not to the end of the sphere. 
	intersect.subtractLocal(center);
	store.set(center);
	
	if ((height = intersect.length())>=radius)
	{
		
		
		if (intersect.dot(gravityUnit)>0)
			return 0;
		else 
			return super.getVolume();//the entire volume is submerged
	}
	
	height *= -FastMath.sign( intersect.dot(gravityUnit));//get the sign of the intersection relative to the opposite of gravity's vector
	   


	float totalVolume = 4f/3f * FastMath.PI * FastMath.pow(bound.radius, 3);
	
	float volumeBelowSurface =  volumeOfPartialSphere(radius, height,-radius);

//	intersect.normalizeLocal();
	centroidOfPartialSphere(radius,-height, -radius,volumeBelowSurface,gravityUnit,store);//invert this to get the centroid below surface
	store.addLocal(center);
	
	float ratio = volumeBelowSurface/totalVolume;
	return super.getVolume()*ratio;
}
 
开发者ID:sambayless,项目名称:golems,代码行数:58,代码来源:BuoyantSphere.java

示例4: applyFriction

import com.jme.bounding.BoundingSphere; //导入方法依赖的package包/类
public void applyFriction(IFluidRegion region, Vector3f gravityUnit, float tpf) {
	BoundingSphere bound;
	try{
		bound = getCustomWorldBound();
	}catch(ClassCastException e)
	{
		throw new BoundClassException(e.getMessage());
	}
	
	Plane waterPlane = _plane;
	waterPlane.getNormal().set(gravityUnit);
	waterPlane.setConstant(region.getFluidHeight()); 
	float radius = bound.getRadius();

	Vector3f center = bound.getCenter(_temp3);
	
	//move the center down along gravity by the amount radius
	
	//intersect the line center, gravity unit with the plane
	Vector3f intersect = _temp;

	
	boolean result = intersectLineWithPlane(waterPlane, center, gravityUnit, true, intersect);
	if (!result)
		return;
	
	float height;//height here is relative to center, not to the end of the sphere. 
	intersect.subtractLocal(center);

	
	if ((height = intersect.length())>=radius)
	{
		if (intersect.dot(gravityUnit)>0)
			return;
		else
			height = radius;
	}
	
	height *= -FastMath.sign( intersect.dot(gravityUnit));//get the sign of the intersection relative to the opposite of gravity's vector
	   
	float submergedRadius = radius;
	if (height < 0)
		submergedRadius = FastMath.sqrt(radius*radius - height * height);
	
	applyLinearFriction(region,submergedRadius,bound, tpf);
	applyRotationalFriction(region,bound,tpf);
}
 
开发者ID:sambayless,项目名称:golems,代码行数:48,代码来源:BuoyantSphere.java


注:本文中的com.jme.bounding.BoundingSphere.getCenter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。