public void tileAttached(Vector3f cell, TerrainQuad quad) { while(quad.getControl(RigidBodyControl.class)!=null){ quad.removeControl(RigidBodyControl.class); } quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); }
public void tileAttached(Vector3f cell, TerrainQuad quad) { while(quad.getControl(RigidBodyControl.class)!=null){ quad.removeControl(RigidBodyControl.class); } quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); }
public void tileAttached(Vector3f cell, TerrainQuad quad) { //workaround for bugged test j3o's while(quad.getControl(RigidBodyControl.class)!=null){ quad.removeControl(RigidBodyControl.class); } quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); }
if (spatial instanceof TerrainQuad) { TerrainQuad terrain = (TerrainQuad) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof TerrainPatch) { TerrainPatch terrain = (TerrainPatch) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof Geometry) { return createSingleMeshShape((Geometry) spatial, spatial);
if (spatial instanceof TerrainQuad) { TerrainQuad terrain = (TerrainQuad) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof TerrainPatch) { TerrainPatch terrain = (TerrainPatch) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof Geometry) { return createSingleMeshShape((Geometry) spatial, spatial);
public void tileAttached(Vector3f cell, TerrainQuad quad) { Texture alpha = null; try { alpha = assetManager.loadTexture("TerrainAlphaTest/alpha_" + (int)cell.x+ "_" + (int)cell.z + ".png"); } catch (Exception e) { alpha = assetManager.loadTexture("TerrainAlphaTest/alpha_default.png"); } quad.getMaterial().setTexture("AlphaMap", alpha); if (usePhysics) { quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0)); bulletAppState.getPhysicsSpace().add(quad); } updateMarkerElevations(); }
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), trans.getScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix()); shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix());
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), trans.getScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix()); shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix());
/** * This type of collision shape is mesh-accurate and meant for immovable "world objects". * Examples include terrain, houses or whole shooter levels.<br/> * Objects with "mesh" type collision shape will not collide with each other.<br/> * Creates a HeightfieldCollisionShape if the supplied spatial is a TerrainQuad. * @return A MeshCollisionShape or a CompoundCollisionShape with MeshCollisionShapes as children if the supplied spatial is a Node. A HeightieldCollisionShape if a TerrainQuad was supplied. */ public static CollisionShape createMeshShape(Spatial spatial) { if (spatial instanceof TerrainQuad) { TerrainQuad terrain = (TerrainQuad) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof TerrainPatch) { TerrainPatch terrain = (TerrainPatch) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof Geometry) { return createSingleMeshShape((Geometry) spatial, spatial); } else if (spatial instanceof Node) { return createMeshCompoundShape((Node) spatial); } else { throw new IllegalArgumentException("Supplied spatial must either be Node or Geometry!"); } }
if (spatial instanceof TerrainQuad) { TerrainQuad terrain = (TerrainQuad) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof TerrainPatch) { TerrainPatch terrain = (TerrainPatch) spatial; return new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()); } else if (spatial instanceof Geometry) { return createSingleMeshShape((Geometry) spatial, spatial);
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), trans.getScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix()); shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix());
shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), trans.getScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix()); shape.addChildShape(new HeightfieldCollisionShape(terrain.getHeightMap(), terrain.getLocalScale()), trans.getTranslation(), trans.getRotation().toRotationMatrix());