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


Java BoundingSphere.getCenter方法代码示例

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


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

示例1: if

import com.jme3.bounding.BoundingSphere; //导入方法依赖的package包/类
/**
 * This method returns the bounding box of the given mesh.
 * 
 * @param mesh
 *            the mesh
 * @return bounding box of the given mesh
 */
/* package */static BoundingBox getBoundingBox(Mesh mesh) {
    mesh.updateBound();
    BoundingVolume bv = mesh.getBound();
    if (bv instanceof BoundingBox) {
        return (BoundingBox) bv;
    } else if (bv instanceof BoundingSphere) {
        BoundingSphere bs = (BoundingSphere) bv;
        float r = bs.getRadius();
        return new BoundingBox(bs.getCenter(), r, r, r);
    } else {
        throw new IllegalStateException("Unknown bounding volume type: " + bv.getClass().getName());
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:21,代码来源:UVCoordinatesGenerator.java

示例2: sphereProjection

import com.jme3.bounding.BoundingSphere; //导入方法依赖的package包/类
/**
 * Sphere projection for 2D textures.
 * 
 * @param positions
 *            points to be projected
 * @param bb
 *            the bounding box for projecting
 * @return UV coordinates after the projection
 */
public static float[] sphereProjection(float[] positions, BoundingSphere bs) {// TODO: rotate it to be vertical
    float[] uvCoordinates = new float[positions.length / 3 * 2];
    Vector3f v = new Vector3f();
    float cx = bs.getCenter().x, cy = bs.getCenter().y, cz = bs.getCenter().z;
    Vector3f uBase = new Vector3f(0, -1, 0);
    Vector3f vBase = new Vector3f(0, 0, -1);

    for (int i = 0, j = 0; i < positions.length; i += 3, j += 2) {
        // calculating U
        v.set(positions[i] - cx, positions[i + 1] - cy, 0);
        v.normalizeLocal();
        float angle = v.angleBetween(uBase);// result between [0; PI]
        if (v.x < 0) {// the angle should be greater than PI, we're on the other part of the image then
            angle = FastMath.TWO_PI - angle;
        }
        uvCoordinates[j] = angle / FastMath.TWO_PI;

        // calculating V
        v.set(positions[i] - cx, positions[i + 1] - cy, positions[i + 2] - cz);
        v.normalizeLocal();
        angle = v.angleBetween(vBase);// result between [0; PI]
        uvCoordinates[j + 1] = angle / FastMath.PI;
    }

    // looking for splitted triangles
    Triangle triangle = new Triangle();
    for (int i = 0; i < positions.length; i += 9) {
        triangle.set(0, positions[i], positions[i + 1], positions[i + 2]);
        triangle.set(1, positions[i + 3], positions[i + 4], positions[i + 5]);
        triangle.set(2, positions[i + 6], positions[i + 7], positions[i + 8]);
        float sgn1 = Math.signum(triangle.get1().x - cx);
        float sgn2 = Math.signum(triangle.get2().x - cx);
        float sgn3 = Math.signum(triangle.get3().x - cx);
        float xSideFactor = sgn1 + sgn2 + sgn3;
        float ySideFactor = Math.signum(triangle.get1().y - cy) + Math.signum(triangle.get2().y - cy) + Math.signum(triangle.get3().y - cy);
        if ((xSideFactor > -3 || xSideFactor < 3) && ySideFactor < 0) {// the triangle is on the splitting plane
            if (sgn1 == 1.0f) {
                uvCoordinates[i / 3 * 2] += 1.0f;
            }
            if (sgn2 == 1.0f) {
                uvCoordinates[(i / 3 + 1) * 2] += 1.0f;
            }
            if (sgn3 == 1.0f) {
                uvCoordinates[(i / 3 + 2) * 2] += 1.0f;
            }
        }
    }
    return uvCoordinates;
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:59,代码来源:UVProjectionGenerator.java

示例3: fromBoundingSphere

import com.jme3.bounding.BoundingSphere; //导入方法依赖的package包/类
/**
 * Create a WireSphere from a BoundingSphere
 *
 * @param bsph
 *     BoundingSphere used to create the WireSphere
 *
 */
public void fromBoundingSphere(BoundingSphere bsph) {
	Vector3f c = bsph.getCenter();
    updatePositions(c.x, c.y, c.z, bsph.getRadius());
}
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:12,代码来源:MyWireSphere.java


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