• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Plane类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Add some entities
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))),
            new Name("floor"));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape(),
            new Name("box1"));

    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape(),
            new Name("box2"));

    entityData.setComponent(box, new Force(new Vector3f(100,100,100), new Vector3f()));

    colliding = entityData.getEntities(Collision.class, Name.class);
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:27,代码来源:CollisionExample.java


示例2: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Same setup as in BasicExample
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,0,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());


    //Add two custom impulses. They are only applied once. You could play with the values..
    entityData.setComponent(box, new CombinedImpulses(new Vector3f(100, 0,0), new Vector3f()));
    //for the second one we have to update the CombinedImpulses component.
    entityData.setComponent(box, entityData.getComponent(box, CombinedImpulses.class).addImpulse(new Vector3f(-150, 0, 0), new Vector3f()));

    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);
    });
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:27,代码来源:CombinedImpulsesExample.java


示例3: onAnalog

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void onAnalog( String name, float value, float tpf ) {
	CollisionResult cr = getClicked();

	Vector3f pos = null;
	
	if (cr != null) 
		pos = cr.getContactPoint();
	
	
	if (pos == null) {
		Vector3f dir = cam.getWorldCoordinates( getInputManager().getCursorPosition(), -10 );
		dir.subtractLocal( cam.getLocation() );
		new Ray( cam.getLocation(), dir ).intersectsWherePlane( new Plane(Jme3z.UP, 0), pos = new Vector3f() );
	}
	
	cursorPosition = Jme3z.from( pos );
	
	if (pos != null)
		point.setPosition( pos.add ( cam.getDirection().mult( -0.3f ) ));
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:22,代码来源:Tweed.java


示例4: getSurfaceSelected

import com.jme3.math.Plane; //导入依赖的package包/类
private Vector3f getSurfaceSelected(float dist) {
	CollisionResult cr = getClicked();
	
	Vector3f pos = null;
	
	if (cr != null) 
		pos = cr.getContactPoint();
	
	
	if (pos == null) {
		Vector3f dir = cam.getWorldCoordinates( getInputManager().getCursorPosition(), -dist );
		dir.subtractLocal( cam.getLocation() );
		new Ray( cam.getLocation(), dir ).intersectsWherePlane( new Plane(Jme3z.UP, 0), pos = new Vector3f() );
	}
	return pos;
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:17,代码来源:Tweed.java


示例5: whichSide

import com.jme3.math.Plane; //导入依赖的package包/类
/**
 * <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;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:BoundingBox.java


示例6: onAction

import com.jme3.math.Plane; //导入依赖的package包/类
public void onAction(String name, boolean isPressed, float tpf) {
    operation = name;
    if (isPressed) {
        supportedOperations.get(operation).setEnabled(true);
        Vector2f click2d = MonkeyBrainsAppState.getInstance().getApp().getInputManager().getCursorPosition();
        Vector3f click3d = agent.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 0f).clone();
        Vector3f dir = agent.getCamera().getWorldCoordinates(new Vector2f(click2d.x, click2d.y), 1f).subtractLocal(click3d).normalizeLocal();
        Ray ray = new Ray(click3d, dir);
        Plane ground = new Plane(Vector3f.UNIT_Y, 0);
        Vector3f groundpoint = new Vector3f();
        ray.intersectsWherePlane(ground, groundpoint);
        ((SimpleAttackBehavior) supportedOperations.get(operation)).setTarget(groundpoint);
    } else {
        operation = null;
    }
}
 
开发者ID:QuietOne,项目名称:MonkeyBrains,代码行数:17,代码来源:SimplePlayerAttackBehavior.java


示例7: loadLevel

import com.jme3.math.Plane; //导入依赖的package包/类
public void loadLevel() {
        worldRoot = (Node) assetManager.loadModel("Scenes/PillarArena.j3o");
//        worldRoot = (Node) assetManager.loadModel(
//                "Scenes/LavaArenaWithFogWalls.j3o");
        fakeWorldRoot = new Node("fake-world-root");

        RigidBodyControl physics = new RigidBodyControl(
                new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y, 0)), 0);
        physics.setFriction(1f);
        physics.setRestitution(0f);
        physics.setCollideWithGroups(CollisionGroups.NONE);

        worldRoot.getChild("Ground").addControl(physics);

//        Spatial groundGeom = worldRoot.getChild("GroundGeom");
//        LodControl lod = groundGeom.getControl(LodControl.class);
//
//        if (lod == null) {
//            lod = new LodControl();
//            groundGeom.addControl(lod);
//            lod.setTrisPerPixel(0);
//        }
        worldRoot.setName("world-root");

        arena.readWorld(this, assetManager);
    }
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:27,代码来源:World.java


示例8: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    System.out.println("Press and hold SPACE to move box up!");
    //Add some entities
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape());

    getInputManager().addMapping("Push", new KeyTrigger(KeyInput.KEY_SPACE));
    getInputManager().addListener((AnalogListener) (name, time, tpf) -> {
        //100 Newton  are needed to lift the box up against the gravity (10kg * 9.81m/s^2 < 100N)
        entityData.setComponent(box, new Force(new Vector3f(0,100,0), new Vector3f()));
    }, "Push");

}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:28,代码来源:InputExample.java


示例9: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    getCamera().setLocation(new Vector3f(-5.6461415f, -0.026447738f, 5.5127993f));
    getCamera().setAxes(new Vector3f(-0.6044954f, 4.827976E-6f, -0.7966085f),
            new Vector3f(-0.19503751f, 0.9695639f, 0.14800741f),
            new Vector3f(0.7723636f, 0.24483837f, -0.5860959f));

    //Add some entities
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape());

    EntityId ghost = entityData.createEntity();
    entityData.setComponents(ghost,
            new SphereShape(1f),
            new GhostObject());

    //apply some force at the beginning
    entityData.setComponent(box, new Force(new Vector3f(100,100,100), new Vector3f()));

    ghostEntity = entityData.watchEntity(ghost, Collision.class);
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:35,代码来源:GhostObjectExample.java


示例10: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Same setup as in BasicExample
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    //Add two custom forces. You could play with the values..
    entityData.setComponents(box, new PushForce(10), new PullForce(10));

    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);

        //register the component definitions to make the physics system aware of them
        esBulletState.getBulletSystem().getForceSystem().registerForce(PullForce.class);
        esBulletState.getBulletSystem().getForceSystem().registerForce(PushForce.class);
    });
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:28,代码来源:CustomForceExample.java


示例11: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new Friction(0),
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new Friction(0),
            new WarpPosition(new Vector3f(0,1,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape(),
            new WarpVelocity(new Vector3f(1,0,0), new Vector3f()));

    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);
    });

    getInputManager().addMapping("JUMP", new KeyTrigger(KeyInput.KEY_SPACE));
    getInputManager().addListener((ActionListener) (name, isPressed, tpf) -> {
        if(isPressed){
            entityData.setComponent(box, new Impulse(new Vector3f(0, 20,0), new Vector3f()));
        }
    }, "JUMP");
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:30,代码来源:VelocityImpulseTest.java


示例12: Camera

import com.jme3.math.Plane; //导入依赖的package包/类
/**
 * Serialization only. Do not use.
 */
public Camera() {
    worldPlane = new Plane[MAX_WORLD_PLANES];
    for (int i = 0; i < MAX_WORLD_PLANES; i++) {
        worldPlane[i] = new Plane();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:10,代码来源:Camera.java


示例13: clone

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public Camera clone() {
    try {
        Camera cam = (Camera) super.clone();
        cam.viewportChanged = true;
        cam.planeState = 0;

        cam.worldPlane = new Plane[MAX_WORLD_PLANES];
        for (int i = 0; i < worldPlane.length; i++) {
            cam.worldPlane[i] = worldPlane[i].clone();
        }

        cam.coeffLeft = new float[2];
        cam.coeffRight = new float[2];
        cam.coeffBottom = new float[2];
        cam.coeffTop = new float[2];

        cam.location = location.clone();
        cam.rotation = rotation.clone();

        if (projectionMatrixOverride != null) {
            cam.projectionMatrixOverride = projectionMatrixOverride.clone();
        }

        cam.viewMatrix = viewMatrix.clone();
        cam.projectionMatrix = projectionMatrix.clone();
        cam.viewProjectionMatrix = viewProjectionMatrix.clone();

        cam.update();

        return cam;
    } catch (CloneNotSupportedException ex) {
        throw new AssertionError();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:36,代码来源:Camera.java


示例14: contains

import com.jme3.math.Plane; //导入依赖的package包/类
/**
     * <code>contains</code> tests a bounding volume against the planes of the
     * camera's frustum. The frustums planes are set such that the normals all
     * face in towards the viewable scene. Therefore, if the bounding volume is
     * on the negative side of the plane is can be culled out.
     *
     * NOTE: This method is used internally for culling, for public usage,
     * the plane state of the bounding volume must be saved and restored, e.g:
     * <code>BoundingVolume bv;<br/>
     * Camera c;<br/>
     * int planeState = bv.getPlaneState();<br/>
     * bv.setPlaneState(0);<br/>
     * c.contains(bv);<br/>
     * bv.setPlaneState(plateState);<br/>
     * </code>
     *
     * @param bound the bound to check for culling
     * @return See enums in <code>FrustumIntersect</code>
     */
    public FrustumIntersect contains(BoundingVolume bound) {
        if (bound == null) {
            return FrustumIntersect.Inside;
        }

        int mask;
        FrustumIntersect rVal = FrustumIntersect.Inside;

        for (int planeCounter = FRUSTUM_PLANES; planeCounter >= 0; planeCounter--) {
            if (planeCounter == bound.getCheckPlane()) {
                continue; // we have already checked this plane at first iteration
            }
            int planeId = (planeCounter == FRUSTUM_PLANES) ? bound.getCheckPlane() : planeCounter;
//            int planeId = planeCounter;

            mask = 1 << (planeId);
            if ((planeState & mask) == 0) {
                Plane.Side side = bound.whichSide(worldPlane[planeId]);

                if (side == Plane.Side.Negative) {
                    //object is outside of frustum
                    bound.setCheckPlane(planeId);
                    return FrustumIntersect.Outside;
                } else if (side == Plane.Side.Positive) {
                    //object is visible on *this* plane, so mark this plane
                    //so that we don't check it for sub nodes.
                    planeState |= mask;
                } else {
                    rVal = FrustumIntersect.Intersects;
                }
            }
        }

        return rVal;
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:55,代码来源:Camera.java


示例15: postQueue

import com.jme3.math.Plane; //导入依赖的package包/类
public void postQueue(RenderQueue rq) {
    //we need special treatement for the sky because it must not be clipped
    rm.getRenderer().setFrameBuffer(reflectionBuffer);
    reflectionCam.setProjectionMatrix(null);
    rm.setCamera(reflectionCam, false);
    rm.getRenderer().clearBuffers(true, true, true);
    //Rendering the sky whithout clipping
    rm.getRenderer().setDepthRange(1, 1);
    vp.getQueue().renderQueue(RenderQueue.Bucket.Sky, rm, reflectionCam, true);
    rm.getRenderer().setDepthRange(0, 1);
    //setting the clip plane to the cam
    reflectionCam.setClipPlane(reflectionClipPlane, Plane.Side.Positive);//,1
    rm.setCamera(reflectionCam, false);

}
 
开发者ID:mleoking,项目名称:PhET,代码行数:16,代码来源:ReflectionProcessor.java


示例16: whichSide

import com.jme3.math.Plane; //导入依赖的package包/类
/**
 * <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.
 * @return side
 */
public Plane.Side whichSide(Plane plane) {
    float distance = plane.pseudoDistance(center);

    if (distance <= -radius) {
        return Plane.Side.Negative;
    } else if (distance >= radius) {
        return Plane.Side.Positive;
    } else {
        return Plane.Side.None;
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:BoundingSphere.java


示例17: usewater

import com.jme3.math.Plane; //导入依赖的package包/类
/**
     * @todo consume too much fps :'(
     * @todo move this to hexGrid or builder / should not be there.
     */
    private void usewater() {
        bufferFXNode.attachChild(SkyFactory.createSky(
                app.getAssetManager(), "org/hexgridapi/assets/Textures/BrightSky.dds", false));

        // we create a water processor
        SimpleWaterProcessor waterProcessor = new SimpleWaterProcessor(app.getAssetManager());
//        waterProcessor.setReflectionScene(spatial.getParent());
        waterProcessor.setReflectionScene(collisionNode.getParent().getParent());//rootNode

        // we set the water plane
        Vector3f waterLocation = new Vector3f(0, 0, 0);
        waterProcessor.setPlane(new Plane(Vector3f.UNIT_Y, waterLocation.dot(Vector3f.UNIT_Y)));
        app.getViewPort().addProcessor(waterProcessor);

        // we set wave properties
        waterProcessor.setWaterDepth(-4);         // transparency of water
        waterProcessor.setDistortionScale(0.05f); // strength of waves
        waterProcessor.setWaveSpeed(0.01f);       // speed of waves
        waterProcessor.setWaterTransparency(0.2f);
        waterProcessor.setRenderSize(256, 256);

        // we define the wave size by setting the size of the texture coordinates
        Quad quad = new Quad(200, 200);
        quad.scaleTextureCoordinates(new Vector2f(6f, 6f));

        // we create the water geometry from the quad
        Geometry water = new Geometry("water", quad);
        water.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
        water.setLocalTranslation(-100, 0.01f, 125);
//        water.setShadowMode(RenderQueue.ShadowMode.Receive);
        water.setMaterial(waterProcessor.getMaterial());
        bufferFXNode.attachChild(water);
        ((Node) spatial).attachChild(bufferFXNode);
//        collisionNode.getParent().attachChild(bufferFXNode);
    }
 
开发者ID:MultiverseKing,项目名称:HexGrid_JME,代码行数:40,代码来源:BufferedChunk_old.java


示例18: setupStrengthControl

import com.jme3.math.Plane; //导入依赖的package包/类
/**
 * @see AbstractStrengthSteeringBehavior#setupStrengthControl(float)
 * @see
 * AbstractStrengthSteeringBehavior#setupStrengthControl(com.jme3.math.Plane)
 */
public void setupStrengthControl(Plane plane, float scalar) {
    this.validateScalar(scalar);
    this.scalar = scalar;
    this.plane = plane;
    this.type = SteerStrengthType.PLANE;
}
 
开发者ID:QuietOne,项目名称:MonkeyBrains,代码行数:12,代码来源:AbstractStrengthSteeringBehavior.java


示例19: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    //Add some entities

    //This should be a rigid body with mass 0 and it should be dynamic (not kinematic).
    //The definition is the same as in bullet.
    //Every rigid body needs a collision shape. There exists no shape component for
    //planes yet. As a consequence we have to create a CustomShape component and attach
    //a PlaneCollisionShape to it. There is a factory in the background which converts this
    //collision shapes automatically to rigid objects. This collision shape could be very heavy (e.g. Terrain).
    //To circumvent this situation you could attach a custom factory and use small definition
    //objects. Examples concerning custom shape factories and more shape components will come.
    EntityId plane = entityData.createEntity();
    entityData.setComponents(plane,
            new RigidBody(false, 0),
            new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));

    //Here a simple box is created. The box should fall down and therefore it has a mass of 10kg.
    //It will be spawned at the WarpPosition. The shape is a simple box with size 1x1x1m.
    EntityId box = entityData.createEntity();
    entityData.setComponents(box,
            new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
            new RigidBody(false, 10),
            new BoxShape());

    //This is nearly the same as above. The box is spawned at (0,0,0) and it will be static
    //because it has no mass. It will have the same size as the other box because the half extents are
    //equal to the default ones.
    EntityId box2 = entityData.createEntity();
    entityData.setComponents(box2,
            new RigidBody(false, 0),
            new BoxShape(new Vector3f(0.5f, 0.5f, 0.5f)));

    //We could add a little force at the beginning to push the falling box slightly away.
    //The force is 10m/s^2 in each direction because the mass of the box is 10kg.
    //uncomment this line and notice the difference
    //entityData.setComponent(box, new Force(new Vector3f(100,100,100), new Vector3f()));

    //As you can see the whole system works unnoticeable in the background.
    //You add components and read components (e.g. PhysicsPosition) and you don't need to care anymore
    //how the physics is processed. Of course the physics system is accessible and
    //modifiable if you have advanced needs.

    //To see something we have to attach the bullet debug view. I didn't spend time to add fancy objects
    //which made things more complicated but there is a fancy debug view.
    //This is a very dirty way to attach the bullet debug view but we have to wait until
    //the ESBulletState is initialized. The task is called right after initialization of the esBulletState.
    ESBulletState esBulletState = stateManager.getState(ESBulletState.class);
    esBulletState.onInitialize(() -> {
        //Add Debug State to debug physics
        //As you see there are getters for physics space and so on.
        BulletDebugAppState debugAppState = new BulletDebugAppState(esBulletState.getPhysicsSpace());
        getStateManager().attach(debugAppState);
    });
}
 
开发者ID:jvpichowski,项目名称:ZayES-Bullet,代码行数:56,代码来源:BasicExample.java


示例20: simpleInitApp

import com.jme3.math.Plane; //导入依赖的package包/类
@Override
    public void simpleInitApp() {
        bulletAppState = new BulletAppState();
        stateManager.attach(bulletAppState);
        bulletAppState.getPhysicsSpace().enableDebug(assetManager);

        // Add a physics sphere to the world
        Node physicsSphere = PhysicsTestHelper.createPhysicsTestNode(assetManager, new SphereCollisionShape(1), 1);
        physicsSphere.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(3, 6, 0));
        rootNode.attachChild(physicsSphere);
        getPhysicsSpace().add(physicsSphere);

        // Add a physics sphere to the world using the collision shape from sphere one
        Node physicsSphere2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, physicsSphere.getControl(RigidBodyControl.class).getCollisionShape(), 1);
        physicsSphere2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(4, 8, 0));
        rootNode.attachChild(physicsSphere2);
        getPhysicsSpace().add(physicsSphere2);

        // Add a physics box to the world
        Node physicsBox = PhysicsTestHelper.createPhysicsTestNode(assetManager, new BoxCollisionShape(new Vector3f(1, 1, 1)), 1);
        physicsBox.getControl(RigidBodyControl.class).setFriction(0.1f);
        physicsBox.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(.6f, 4, .5f));
        rootNode.attachChild(physicsBox);
        getPhysicsSpace().add(physicsBox);

        // Add a physics cylinder to the world
        Node physicsCylinder = PhysicsTestHelper.createPhysicsTestNode(assetManager, new CylinderCollisionShape(new Vector3f(1f, 1f, 1.5f)), 1);
        physicsCylinder.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2, 2, 0));
        rootNode.attachChild(physicsCylinder);
        getPhysicsSpace().add(physicsCylinder);

        // an obstacle mesh, does not move (mass=0)
        Node node2 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new MeshCollisionShape(new Sphere(16, 16, 1.2f)), 0);
        node2.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(2.5f, -4, 0f));
        rootNode.attachChild(node2);
        getPhysicsSpace().add(node2);

        // the floor mesh, does not move (mass=0)
        Node node3 = PhysicsTestHelper.createPhysicsTestNode(assetManager, new PlaneCollisionShape(new Plane(new Vector3f(0, 1, 0), 0)), 0);
        node3.getControl(RigidBodyControl.class).setPhysicsLocation(new Vector3f(0f, -6, 0f));
        rootNode.attachChild(node3);
        getPhysicsSpace().add(node3);

        // Join the physics objects with a Point2Point joint
//        PhysicsPoint2PointJoint joint=new PhysicsPoint2PointJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0));
//        PhysicsHingeJoint joint=new PhysicsHingeJoint(physicsSphere, physicsBox, new Vector3f(-2,0,0), new Vector3f(2,0,0), Vector3f.UNIT_Z,Vector3f.UNIT_Z);
//        getPhysicsSpace().add(joint);

    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:50,代码来源:TestSimplePhysics.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ManagedBean类代码示例发布时间:2022-05-21
下一篇:
Java MesosExecutorDriver类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap