com.jme3.scene.Geometry.getControl()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中com.jme3.scene.Geometry.getControl()方法的一些代码示例,展示了Geometry.getControl()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Geometry.getControl()方法的具体详情如下:
包路径:com.jme3.scene.Geometry
类名称:Geometry
方法名:getControl

Geometry.getControl介绍

暂无

代码示例

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void addBrick(Vector3f ori) {
  Geometry reBoxg = new Geometry("brick", brick);
  reBoxg.setMaterial(mat);
  reBoxg.setLocalTranslation(ori);
  reBoxg.rotate(0f, (float)Math.toRadians(angle) , 0f );
  reBoxg.addControl(new RigidBodyControl(1.5f));
  reBoxg.setShadowMode(ShadowMode.CastAndReceive);
  reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f);
  this.batchNode.attachChild(reBoxg);
  this.getPhysicsSpace().add(reBoxg);
  nbBrick++;
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void addBrick(Vector3f ori) {
  Geometry reBoxg = new Geometry("brick", brick);
  reBoxg.setMaterial(mat);
  reBoxg.setLocalTranslation(ori);
  reBoxg.rotate(0f, (float)Math.toRadians(angle) , 0f );
  reBoxg.addControl(new RigidBodyControl(1.5f));
  reBoxg.setShadowMode(ShadowMode.CastAndReceive);
  reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f);
  this.rootNode.attachChild(reBoxg);
  this.getPhysicsSpace().add(reBoxg);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void addBrick(Vector3f ori) {
  Geometry reBoxg = new Geometry("brick", brick);
  reBoxg.setMaterial(mat);
  reBoxg.setLocalTranslation(ori);
  //for geometry with sphere mesh the physics system automatically uses a sphere collision shape
  reBoxg.addControl(new RigidBodyControl(1.5f));
  reBoxg.setShadowMode(ShadowMode.CastAndReceive);
  reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f);
  this.rootNode.attachChild(reBoxg);
  this.getPhysicsSpace().add(reBoxg);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void onAction(String binding, boolean value, float tpf) {
    if (binding.equals("shoot") && !value) {
      Geometry bulletg = new Geometry("bullet", bullet);
      bulletg.setMaterial(mat);
      bulletg.setName("bullet");
      bulletg.setLocalTranslation(cam.getLocation());
      bulletg.setShadowMode(ShadowMode.CastAndReceive);
      bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1));
      bulletg.getControl(RigidBodyControl.class).setCcdMotionThreshold(0.1f);
      bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
      rootNode.attachChild(bulletg);
      getPhysicsSpace().add(bulletg);
    } else if (binding.equals("shoot2") && !value) {
      Geometry bulletg = new Geometry("bullet", bullet);
      bulletg.setMaterial(mat2);
      bulletg.setName("bullet");
      bulletg.setLocalTranslation(cam.getLocation());
      bulletg.setShadowMode(ShadowMode.CastAndReceive);
      bulletg.addControl(new RigidBodyControl(bulletCollisionShape, 1));
      bulletg.getControl(RigidBodyControl.class).setLinearVelocity(cam.getDirection().mult(40));
      rootNode.attachChild(bulletg);
      getPhysicsSpace().add(bulletg);
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

public void initWall(float bLength, float bWidth, float bHeight) {
  Box brick = new Box(bLength, bHeight, bWidth);
  brick.scaleTextureCoordinates(new Vector2f(1f, .5f));
  Material mat2 = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
  TextureKey key = new TextureKey("Textures/Terrain/BrickWall/BrickWall.jpg");
  key.setGenerateMips(true);
  Texture tex = assetManager.loadTexture(key);
  mat2.setTexture("ColorMap", tex);
  
  float startpt = bLength / 4;
  float height = -5;
  for (int j = 0; j < 15; j++) {
    for (int i = 0; i < 4; i++) {
      Vector3f ori = new Vector3f(i * bLength * 2 + startpt, bHeight + height, -10);
      Geometry reBoxg = new Geometry("brick", brick);
      reBoxg.setMaterial(mat2);
      reBoxg.setLocalTranslation(ori);
      //for geometry with sphere mesh the physics system automatically uses a sphere collision shape
      reBoxg.addControl(new RigidBodyControl(1.5f));
      reBoxg.setShadowMode(ShadowMode.CastAndReceive);
      reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f);
      this.rootNode.attachChild(reBoxg);
      this.getPhysicsSpace().add(reBoxg);
    }
    startpt = -startpt;
    height += 2 * bHeight;
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

ballGeometry.getControl(RigidBodyControl.class).setRestitution(1);
rootNode.attachChild(ballGeometry);
space.add(ballGeometry);

代码示例来源:origin: org.cogchar/org.cogchar.lib.render.goody

@Override public void makeSpheres(Material mat) {
  for (int i = 0; i < 5; i++) {
    RigidBodyControl rbc = new RigidBodyControl(.001f);
    Sphere s = findOrMakeMeshShapeFacade(null).makeSphereMesh(16, 16, 0.5f);
    Geometry ballGeometry = findOrMakeSceneGeometryFacade(null).makeGeom( GeomFactory.GEOM_SOCCER_BALL, s, mat, rbc);            
    //RigidBodyControl automatically uses Sphere collision shapes when attached to single geometry with sphere mesh
    ballGeometry.getControl(RigidBodyControl.class).setRestitution(1);
    ballGeometry.setLocalTranslation(i, 2, -3);
    myParentNode.attachChild(ballGeometry);
    myPhysSpc.add(ballGeometry);
  }
}
@Override public void makeImmovableSphere(Material mat) {

相关文章