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


Java BoundingSphere类代码示例

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


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

示例1: simpleUpdate

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
@Override
public void simpleUpdate(float tpf) {
	frame++;

	if(frame==2){

		modelNode.removeFromParent();
		final LightProbe probe=LightProbeFactory.makeProbe(stateManager.getState(EnvironmentCamera.class),rootNode,new JobProgressAdapter<LightProbe>(){

			@Override
			public void done(LightProbe result) {

			}

		});
		BoundingSphere s=(BoundingSphere)probe.getBounds();
		s.setRadius(100);
		rootNode.addLight(probe);

	}
	if(frame>10&&modelNode.getParent()==null){
		rootNode.attachChild(modelNode);
	}
}
 
开发者ID:riccardobl,项目名称:JMELink-SP,代码行数:25,代码来源:TestScene.java

示例2: actionPerformed

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    SceneApplication.getApplication().enqueue(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            EnvironmentCamera envCam = SceneApplication.getApplication().getStateManager().getState(EnvironmentCamera.class);
            SceneToolController toolController = SceneApplication.getApplication().getStateManager().getState(SceneToolController.class);
            if (toolController != null) {
                envCam.setPosition(toolController.getCursorLocation());
            } else {
                envCam.setPosition(new Vector3f(0, 0, 0));
            }
            LightProbe lightProbe = LightProbeFactory.makeProbe(envCam, node, new JmeLightProbeProgressHandler());
            lightProbe.setName("LightProbe");
            node.addLight(lightProbe);
            ((BoundingSphere) lightProbe.getBounds()).setRadius(10);
            node.updateModelBound();
            addLightUndo(node, lightProbe);
            setModified();

            return null;
        }
    });
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:25,代码来源:NewLightPopup.java

示例3: debugBounding

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
/**
 * 显示目标spatial的bounding
 * 暂支持:AABB,Sphere
 * @param debugId
 * @param spatial 
 */
public static void debugBounding(String debugId, Spatial spatial) {
    BoundingVolume bv = spatial.getWorldBound();
    Geometry geo = null;
    if (bv.getType() == BoundingVolume.Type.AABB) {
        BoundingBox bb = (BoundingBox) bv;
        geo = DebugUtils.createWireBox(bb.getXExtent(), bb.getYExtent(), bb.getZExtent(), ColorRGBA.Blue);
    } else if (bv.getType() == BoundingVolume.Type.Sphere) {
        BoundingSphere bs = (BoundingSphere) bv;
        geo = DebugUtils.createWireSphere(bs.getRadius(), ColorRGBA.Blue);
    }
    if (geo != null) {
        geo.setLocalTranslation(bv.getCenter());
        addDebugObject("debugBounding_" + debugId, geo, false);
    }
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:22,代码来源:DebugDynamicUtils.java

示例4: getBoundTopPosition

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
/**
 * 获取一个对象的bound的顶部的世界位置,主要是计算bound的中心点世界坐标
 * 加上YExtend(box)或radius(sphere)即为该bound的top坐标。
 * @param spatial
 * @param store 存放结果(not null)
 * @return 
 */
public static Vector3f getBoundTopPosition(Spatial spatial, Vector3f store) {
    BoundingVolume bv = spatial.getWorldBound();
    // 要注意:一些没有mesh的Spatial可能没有包围盒
    if (bv == null) {
        return store;
    }
    if (bv.getType() == Type.AABB) {
        BoundingBox bb = (BoundingBox) bv;
        store.set(bb.getCenter()).addLocal(0, bb.getYExtent(), 0);
    } else if (bv.getType() == Type.Sphere) {
        BoundingSphere bs = (BoundingSphere) bv;
        store.set(bs.getCenter()).addLocal(0, bs.getRadius(), 0);
    } else {
        LOG.log(Level.WARNING, "Unsupported BoundingVolume type={0}", bv.getType());
    }
    return store;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:25,代码来源:GeometryUtils.java

示例5: construct

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
private void construct(float timeInterval, float randomFactor, float rotationFactor) {
    if (timeInterval <= 0) {
        throw new SteeringExceptions.NegativeValueException("The time interval must be possitive." + timeInterval);
    } else if (randomFactor < 0 || randomFactor > 1) {
        throw new SteeringExceptions.IllegalIntervalException("random", randomFactor);
    } else if (rotationFactor < 0 || rotationFactor > 1) {
        throw new SteeringExceptions.IllegalIntervalException("rotation", rotationFactor);
    }

    this.timeInterval = timeInterval;
    this.time = this.timeInterval;
    this.randomFactor = randomFactor;
    this.wanderSphere = new BoundingSphere(this.sphereRadius, Vector3f.ZERO);
    this.targetPosition = this.wanderSphere.getCenter();
    this.randomDirection = new Vector2f();
    this.maxRandom = this.sphereRadius - SphereWanderBehavior.RANDOM_OFFSET;
    this.rotationFactor = rotationFactor;
    this.maxRandom *= this.rotationFactor;
}
 
开发者ID:QuietOne,项目名称:MonkeyBrains,代码行数:20,代码来源:SphereWanderBehavior.java

示例6: setRadius

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
/**
 * Set the radius of the light probe.
 *
 * @param radius the radius.
 */
public void setRadius(final float radius) {

    final BoundingVolume bounds = lightProbe.getBounds();

    if (bounds instanceof BoundingSphere) {
        ((BoundingSphere) bounds).setRadius(radius);
    }
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:14,代码来源:StaticLightProbeSceneAppState.java

示例7: getRadius

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
/**
 * Get the radius of the light probe.
 *
 * @return the radius.
 */
public float getRadius() {

    final BoundingVolume bounds = lightProbe.getBounds();

    if (bounds instanceof BoundingSphere) {
        return ((BoundingSphere) bounds).getRadius();
    }

    return 1F;
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:16,代码来源:StaticLightProbeSceneAppState.java

示例8: SkySpatial

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
public SkySpatial(
		SkyComponent skyComponent,
		JmeResourceManager resourceManager,
		AssetManager assetManager) {
	super(
			skyComponent.getName(),
			(float)skyComponent.getOrder(),
			resourceManager,
			assetManager);
	
	setCullHint(Spatial.CullHint.Never);
	setQueueBucket(Bucket.Sky);
	
	texture = new TextureCubeMap();
	texture.setMagFilter(Texture.MagFilter.Nearest);
	texture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
	texture.setAnisotropicFilter(0);
	texture.setWrap(Texture.WrapMode.EdgeClamp);
	
	material = new Material(assetManager, "/assets/shaders/sky/Sky.j3md");
	material.setVector4("Color", new Vector4f(0.0f, 0.0f, 0.0f, 0.0f));
	material.setInt("ColorBlendMode", ShaderUtil.getColorBlendModeAsInteger(ColorBlendMode.NORMAL));
	material.setVector3("NormalScale", Vector3f.UNIT_XYZ);
	material.setTexture("Texture", texture);
	material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
	
	sphere = new Sphere(8, 8, 10, false, true);
	
	geometry = new Geometry();
	geometry.setMaterial(material);
	geometry.setMesh(sphere);
	geometry.setModelBound(new BoundingSphere(Float.POSITIVE_INFINITY, Vector3f.ZERO));
	
	attachChild(geometry);
	
	addControl(new CameraAttachingControl());
}
 
开发者ID:quadracoatl,项目名称:quadracoatl,代码行数:38,代码来源:SkySpatial.java

示例9: simpleInitApp

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
@Override
    public void simpleInitApp() {
//        flyCam.setEnabled(false);

        // load material
        Material mat = (Material) assetManager.loadAsset(new AssetKey("Interface/Logo/Logo.j3m"));

        Mesh q = new Mesh();
        q.setBuffer(Type.Position, 3, new float[]
        {
            1, 0, 0,
            0, 1.5f, 0,
            -1, 0, 0
        }
        );
        q.setBuffer(Type.Index, 3, new int[]{ 0, 1, 2 });
        q.setBound(new BoundingSphere());
        q.updateBound();
//        Geometry teapot = new Geometry("MyGeom", q);

        teapot = assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
//        teapot.scale(2f, 2f, 2f);
//        teapot.move(2f, 2f, -.5f);
        teapot.rotate(FastMath.HALF_PI, FastMath.HALF_PI, FastMath.HALF_PI);
        teapot.setMaterial(mat);
        rootNode.attachChild(teapot);

//        cam.setLocation(cam.getLocation().add(0,1,0));
//        cam.lookAt(teapot.getWorldBound().getCenter(), Vector3f.UNIT_Y);

        tracer = new RayTrace(rootNode, cam, 160, 128);
        tracer.show();
        tracer.update();
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:35,代码来源:TestRayCasting.java

示例10: collideWithBoundingVolume

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
private int collideWithBoundingVolume(BoundingVolume boundingVolume, CollisionResults results) {
    if (boundingVolume instanceof BoundingBox)
        return collideWithBoundingBox((BoundingBox)boundingVolume, results);
    else if(boundingVolume instanceof BoundingSphere) {
        BoundingSphere sphere = (BoundingSphere) boundingVolume;
        BoundingBox bbox = new BoundingBox(boundingVolume.getCenter().clone(), sphere.getRadius(),
                                                       sphere.getRadius(),
                                                       sphere.getRadius());
        return collideWithBoundingBox(bbox, results);
    }
    return 0;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:TerrainPatch.java

示例11: calcScreenArea

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
private static float calcScreenArea(BoundingSphere bound, float distance, float screenWidth) {
    // Where is the center point and a radius point that lies in a plan parallel to the view plane?
//    // Calc radius based on these two points and plug into circle area formula.
//    Vector2f centerSP = null;
//    Vector2f outerSP = null;
//    float radiusSq = centerSP.subtract(outerSP).lengthSquared();
      float radius = (bound.getRadius() * screenWidth) / (distance * 2);
      return radius * radius * FastMath.PI;
  }
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:AreaUtils.java

示例12: hasVolume

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
public static boolean hasVolume(BoundingVolume bv) {
    if(bv.getVolume() != 0) {
        return true;
    }

    if(bv instanceof BoundingBox) {
        return ((BoundingBox) bv).getXExtent() != 0 || ((BoundingBox) bv).getYExtent() != 0 || ((BoundingBox) bv).getZExtent() != 0;
    } else if(!(bv instanceof BoundingSphere)) {
        new UnsupportedOperationException("Bounding volume type not supported: " + bv.getClass()).printStackTrace();
    }

    return false;
}
 
开发者ID:NemesisMate,项目名称:UtilJME3-Debug,代码行数:14,代码来源:DebugBoundsState.java

示例13: controlUpdate

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
@Override
protected void controlUpdate(float f) {
    Geometry probeGeom = (Geometry) ((Node) getSpatial()).getChild(0);
    Material m = probeGeom.getMaterial();
    
    if (jmeProbe.getLightProbe().isReady()) {            
        m.setTexture("CubeMap", jmeProbe.getLightProbe().getPrefilteredEnvMap());            
    }
    
    Geometry probeRadius = (Geometry) ((Node) getSpatial()).getChild(1);
    probeRadius.setLocalScale(((BoundingSphere) jmeProbe.getLightProbe().getBounds()).getRadius());
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:13,代码来源:LightProbeUpdate.java

示例14: getRadius

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
protected float getRadius() {
    if (lightProbe.isReady()) {
        return ((BoundingSphere)lightProbe.getBounds()).getRadius();
    } else {
        return 0f;
    }
}
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:8,代码来源:LightProbeGizmo.java

示例15: getBoundingVolumeZExtent

import com.jme3.bounding.BoundingSphere; //导入依赖的package包/类
/**
 * 获取包围盒的z向长度,
 * 1.如果是AABB则取ZExtent。
 * 2.如果是Sphere则取半径
 * 3.其它不支持,一率返回0
 * @param spatial
 * @return 
 */
public static float getBoundingVolumeZExtent(Spatial spatial) {
    BoundingVolume bv = spatial.getWorldBound();
    float zExtent = 0;
    if (bv.getType() == BoundingVolume.Type.AABB) {
        zExtent = ((BoundingBox) bv).getZExtent();
    } else if (bv.getType() == BoundingVolume.Type.Sphere) {
        zExtent = ((BoundingSphere) bv).getRadius();
    } else {
        Logger.getLogger(GeometryUtils.class.getName())
                .log(Level.WARNING, "Unsupported BoundingVolume type:{0}", bv.getType());
    }
    return zExtent;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:22,代码来源:GeometryUtils.java


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