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

x33g5p2x  于2022-01-30 转载在 其他  
字(13.1k)|赞(0)|评价(0)|浏览(105)

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

Spatial.setName介绍

[英]Sets the name of this spatial.
[中]设置此空间文件的名称。

代码示例

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

/**
 * Instantiate an enabled control to visualize the specified character.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body the character to visualize (not null, alias created)
 */
public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_PINK);
}

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

/**
 * Instantiate an enabled control to visualize the specified character.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body the character to visualize (not null, alias created)
 */
public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_PINK);
}

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

/**
 * Instantiate an enabled control to visualize the specified ghost object.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body which object to visualize (not null, alias created)
 */
public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_YELLOW);
}

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

/**
 * Instantiate an enabled control to visualize the specified body.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body which body to visualize (not null, alias created)
 */
public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_BLUE);
}

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

/**
 * Instantiate an enabled control to visualize the specified ghost object.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body which object to visualize (not null, alias created)
 */
public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_YELLOW);
}

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

/**
 * Instantiate an enabled control to visualize the specified body.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body which body to visualize (not null, alias created)
 */
public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_BLUE);
}

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

spatial.setName(readMeshName(meshIndex));
spatial.setName(getAsString(nodeData.getAsJsonObject(), "name"));

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

/**
 * Update this control. Invoked once per frame during the logical-state
 * update, provided the control is enabled and added to a scene. Should be
 * invoked only by a subclass or by AbstractControl.
 *
 * @param tpf the time interval between frames (in seconds, ≥0)
 */
@Override
protected void controlUpdate(float tpf) {
  CollisionShape newShape = body.getCollisionShape();
  Vector3f newScale = newShape.getScale();
  if (myShape != newShape || !oldScale.equals(newScale)) {
    myShape = newShape;
    oldScale.set(newScale);
    Node node = (Node) spatial;
    node.detachChild(geom);
    geom = DebugShapeFactory.getDebugShape(myShape);
    geom.setName(body.toString());
    node.attachChild(geom);
  }
  geom.setMaterial(debugAppState.DEBUG_PINK);
  body.getPhysicsLocation(location);
  applyPhysicsTransform(location, Quaternion.IDENTITY);
}

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

/**
 * Update this control. Invoked once per frame during the logical-state
 * update, provided the control is enabled and added to a scene. Should be
 * invoked only by a subclass or by AbstractControl.
 *
 * @param tpf the time interval between frames (in seconds, ≥0)
 */
@Override
protected void controlUpdate(float tpf) {
  CollisionShape newShape = body.getCollisionShape();
  Vector3f newScale = newShape.getScale();
  if (myShape != newShape || !oldScale.equals(newScale)) {
    myShape = newShape;
    oldScale.set(newScale);
    Node node = (Node) spatial;
    node.detachChild(geom);
    geom = DebugShapeFactory.getDebugShape(myShape);
    geom.setName(body.toString());
    node.attachChild(geom);
  }
  geom.setMaterial(debugAppState.DEBUG_PINK);
  body.getPhysicsLocation(location);
  applyPhysicsTransform(location, Quaternion.IDENTITY);
}

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

/**
 * Update this control. Invoked once per frame during the logical-state
 * update, provided the control is enabled and added to a scene. Should be
 * invoked only by a subclass or by AbstractControl.
 *
 * @param tpf the time interval between frames (in seconds, ≥0)
 */
@Override
protected void controlUpdate(float tpf) {
  CollisionShape newShape = body.getCollisionShape();
  Vector3f newScale = newShape.getScale();
  if (myShape != newShape || !oldScale.equals(newScale)) {
    myShape = newShape;
    oldScale.set(newScale);
    Node node = (Node) spatial;
    node.detachChild(geom);
    geom = DebugShapeFactory.getDebugShape(myShape);
    geom.setName(body.toString());
    node.attachChild(geom);
  }
  geom.setMaterial(debugAppState.DEBUG_YELLOW);
  body.getPhysicsLocation(location);
  body.getPhysicsRotation(rotation);
  applyPhysicsTransform(location, rotation);
}

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

/**
 * Update this control. Invoked once per frame during the logical-state
 * update, provided the control is enabled and added to a scene. Should be
 * invoked only by a subclass or by AbstractControl.
 *
 * @param tpf the time interval between frames (in seconds, ≥0)
 */
@Override
protected void controlUpdate(float tpf) {
  CollisionShape newShape = body.getCollisionShape();
  Vector3f newScale = newShape.getScale();
  if (myShape != newShape || !oldScale.equals(newScale)) {
    myShape = newShape;
    oldScale.set(newScale);
    Node node = (Node) spatial;
    node.detachChild(geom);
    geom = DebugShapeFactory.getDebugShape(myShape);
    geom.setName(body.toString());
    node.attachChild(geom);
  }
  geom.setMaterial(debugAppState.DEBUG_YELLOW);
  body.getPhysicsLocation(location);
  body.getPhysicsRotation(rotation);
  applyPhysicsTransform(location, rotation);
}

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

/**
 * Update this control. Invoked once per frame during the logical-state
 * update, provided the control is enabled and added to a scene. Should be
 * invoked only by a subclass or by AbstractControl.
 *
 * @param tpf the time interval between frames (in seconds, ≥0)
 */
@Override
protected void controlUpdate(float tpf) {
  CollisionShape newShape = body.getCollisionShape();
  Vector3f newScale = newShape.getScale();
  if (myShape != newShape || !oldScale.equals(newScale)) {
    myShape = newShape;
    oldScale.set(newScale);
    Node node = (Node) spatial;
    node.detachChild(geom);
    geom = DebugShapeFactory.getDebugShape(myShape);
    geom.setName(body.toString());
    node.attachChild(geom);
  }
  if(body.isActive()){
    geom.setMaterial(debugAppState.DEBUG_MAGENTA);
  }else{
    geom.setMaterial(debugAppState.DEBUG_BLUE);
  }
  body.getPhysicsLocation(location);
  body.getPhysicsRotation(rotation);
  applyPhysicsTransform(location, rotation);
}

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

/**
 * Update this control. Invoked once per frame during the logical-state
 * update, provided the control is enabled and added to a scene. Should be
 * invoked only by a subclass or by AbstractControl.
 *
 * @param tpf the time interval between frames (in seconds, ≥0)
 */
@Override
protected void controlUpdate(float tpf) {
  CollisionShape newShape = body.getCollisionShape();
  Vector3f newScale = newShape.getScale();
  if (myShape != newShape || !oldScale.equals(newScale)) {
    myShape = newShape;
    oldScale.set(newScale);
    Node node = (Node) spatial;
    node.detachChild(geom);
    geom = DebugShapeFactory.getDebugShape(myShape);
    geom.setName(body.toString());
    node.attachChild(geom);
  }
  if(body.isActive()){
    geom.setMaterial(debugAppState.DEBUG_MAGENTA);
  }else{
    geom.setMaterial(debugAppState.DEBUG_BLUE);
  }
  body.getPhysicsLocation(location);
  body.getPhysicsRotation(rotation);
  applyPhysicsTransform(location, rotation);
}

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

public void makeMissile() {
  Vector3f pos = spaceCraft.getWorldTranslation().clone();
  Quaternion rot = spaceCraft.getWorldRotation();
  Vector3f dir = rot.getRotationColumn(2);
  Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml");
  missile.scale(0.5f);
  missile.rotate(0, FastMath.PI, 0);
  missile.updateGeometricState();
  BoundingBox box = (BoundingBox) missile.getWorldBound();
  final Vector3f extent = box.getExtent(null);
  BoxCollisionShape boxShape = new BoxCollisionShape(extent);
  missile.setName("Missile");
  missile.rotate(rot);
  missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0));
  missile.setLocalRotation(hoverControl.getPhysicsRotation());
  missile.setShadowMode(ShadowMode.Cast);
  RigidBodyControl control = new BombControl(assetManager, boxShape, 20);
  control.setLinearVelocity(dir.mult(100));
  control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03);
  missile.addControl(control);
  rootNode.attachChild(missile);
  getPhysicsSpace().add(missile);
}

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

private void createScene() {
  Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
  mat.setFloat("Shininess", 1f);
  mat.setBoolean("UseMaterialColors", true);
  mat.setColor("Ambient", ColorRGBA.Black);
  mat.setColor("Diffuse", ColorRGBA.DarkGray);
  mat.setColor("Specular", ColorRGBA.White.mult(0.6f));
  Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
  matSoil.setBoolean("UseMaterialColors", true);
  matSoil.setColor("Ambient", ColorRGBA.Black);
  matSoil.setColor("Diffuse", ColorRGBA.Black);
  matSoil.setColor("Specular", ColorRGBA.Black);
  teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
  teapot.setName("Teapot");
  teapot.setLocalScale(3);
  teapot.setMaterial(mat);
  rootNode.attachChild(teapot);
  Geometry soil = new Geometry("soil", new Box(50, 1, 50));
  soil.setLocalTranslation(0, -1, 0);
  soil.setMaterial(matSoil);
  rootNode.attachChild(soil);
  DirectionalLight light = new DirectionalLight();
  light.setDirection(new Vector3f(0, -1, 0).normalizeLocal());
  light.setColor(ColorRGBA.White.mult(1.5f));
  rootNode.addLight(light);
}

代码示例来源:origin: org.jmonkeyengine/jme3-bullet

public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape());
  this.geom.setName(body.toString());
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_YELLOW);
}

代码示例来源:origin: org.jmonkeyengine/jme3-bullet

public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  this.geom = DebugShapeFactory.getDebugShape(body.getCollisionShape());
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_BLUE);
}

代码示例来源:origin: org.jmonkeyengine/jme3-jbullet

/**
 * Instantiate an enabled control to visualize the specified body.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body which body to visualize (not null, alias created)
 */
public BulletRigidBodyDebugControl(BulletDebugAppState debugAppState, PhysicsRigidBody body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_BLUE);
}

代码示例来源:origin: org.jmonkeyengine/jme3-jbullet

/**
 * Instantiate an enabled control to visualize the specified ghost object.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body which object to visualize (not null, alias created)
 */
public BulletGhostObjectDebugControl(BulletDebugAppState debugAppState, PhysicsGhostObject body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_YELLOW);
}

代码示例来源:origin: org.jmonkeyengine/jme3-jbullet

/**
 * Instantiate an enabled control to visualize the specified character.
 *
 * @param debugAppState which app state (not null, alias created)
 * @param body the character to visualize (not null, alias created)
 */
public BulletCharacterDebugControl(BulletDebugAppState debugAppState, PhysicsCharacter body) {
  super(debugAppState);
  this.body = body;
  myShape = body.getCollisionShape();
  oldScale.set(myShape.getScale());
  this.geom = DebugShapeFactory.getDebugShape(myShape);
  this.geom.setName(body.toString());
  geom.setMaterial(debugAppState.DEBUG_PINK);
}

相关文章

Spatial类方法