本文整理汇总了Java中com.jme3.math.Plane类的典型用法代码示例。如果您正苦于以下问题:Java Plane类的具体用法?Java Plane怎么用?Java Plane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Plane类属于com.jme3.math包,在下文中一共展示了Plane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
});
}
示例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 ) ));
}
示例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;
}
示例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;
}
}
示例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;
}
}
示例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);
}
示例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");
}
示例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);
}
示例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);
});
}
示例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");
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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);
}