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

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

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

Geometry.getParent介绍

暂无

代码示例

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

private void pickGamePad(Vector2f mouseLoc){
  if (lastButton != null) {
    CollisionResults cresults = pick(cam, mouseLoc, gamepad);
    for (CollisionResult cr : cresults) {
      Node n = cr.getGeometry().getParent();
      if (n != null && (n instanceof ButtonView)) {
        String b = ((ButtonView) n).getName().substring("Button:".length());
        String name = lastButton.getJoystick().getName().replaceAll(" ", "\\\\ ");
        String id = lastButton.getLogicalId().replaceAll(" ", "\\\\ ");
        System.out.println(name + "." + id + "=" + b);
        return;
      }
    }
  }
}

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

@Override
protected void doDisplayFrustumDebug(int shadowMapIndex) {
  if (frustums == null) {
    frustums = new Geometry[CAM_NUMBER];
    Vector3f[] points = new Vector3f[8];
    for (int i = 0; i < 8; i++) {
      points[i] = new Vector3f();
    }
    for (int i = 0; i < CAM_NUMBER; i++) {
      ShadowUtil.updateFrustumPoints2(shadowCams[i], points);
      frustums[i] = createFrustum(points, i);
    }
  }
  if (frustums[shadowMapIndex].getParent() == null) {
    ((Node) viewPort.getScenes().get(0)).attachChild(frustums[shadowMapIndex]);
  }
}

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

|| targetGeometry.getParent() == attachParent
&& targetGeometry.getLocalTransform().isIdentity()) {

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

float back_wheel_h = (wheelRadius * 1.7f) - 1f;
float front_wheel_h = (wheelRadius * 1.9f) - 1f;
player.addWheel(wheel_fr.getParent(), box.getCenter().add(0, -front_wheel_h, 0),
    wheelDirection, wheelAxle, 0.2f, wheelRadius, true);
wheel_fl.center();
box = (BoundingBox) wheel_fl.getModelBound();
player.addWheel(wheel_fl.getParent(), box.getCenter().add(0, -front_wheel_h, 0),
    wheelDirection, wheelAxle, 0.2f, wheelRadius, true);
wheel_br.center();
box = (BoundingBox) wheel_br.getModelBound();
player.addWheel(wheel_br.getParent(), box.getCenter().add(0, -back_wheel_h, 0),
    wheelDirection, wheelAxle, 0.2f, wheelRadius, false);
wheel_bl.center();
box = (BoundingBox) wheel_bl.getModelBound();
player.addWheel(wheel_bl.getParent(), box.getCenter().add(0, -back_wheel_h, 0),
    wheelDirection, wheelAxle, 0.2f, wheelRadius, false);

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

Node attachParent = attachNode.getParent();
if (attachParent == null || targetGeometry == null
    || targetGeometry.getParent() == attachParent
    && targetGeometry.getLocalTransform().isIdentity()) {

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

Geometry g2 = (Geometry) g.deepClone();
g2.move(5, 0, 0);
g.getParent().attachChild(g2);

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

protected Bone select(Geometry g) {
  Node parentNode = g.getParent();
  if (parent != null) {
    Bone b = nodeBones.get(parentNode);
    if (b != null) {
      selectedNode = parentNode;
    }
    return b;
  }
  return null;
}

代码示例来源:origin: jMonkeyEngine-Contributions/Lemur

protected float calculateEffectiveLayer(Geometry g) {
  Integer childLayer = g.getUserData(LAYER);
  float layer = childLayer != null ? (childLayer + 1) : 1;
  for( Spatial s = g.getParent(); s != null; s = s.getParent() ) {
    Integer i = s.getUserData(LAYER);
    // I'm not sure skipping a null layer is right but it's 
    // been this way for a while without obvious issue.  It
    // seems like skipping it might cause two separate objects
    // with sparse hierarchies to sort incorrectly.  I'm
    // leaving it for now.
    if (i == null)
      continue;
    // Should really base the divisor on the number
    // of children... since right now if we exceed more
    // than 10 layers under a parent then we overflow
    layer = layer * 0.1F;
    layer += i != null ? (i + 1) : 1;
  }
  return layer;
}

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

@Override
protected void doDisplayFrustumDebug(int shadowMapIndex) {
  if (frustums == null) {
    frustums = new Geometry[CAM_NUMBER];
    Vector3f[] points = new Vector3f[8];
    for (int i = 0; i < 8; i++) {
      points[i] = new Vector3f();
    }
    for (int i = 0; i < CAM_NUMBER; i++) {
      ShadowUtil.updateFrustumPoints2(shadowCams[i], points);
      frustums[i] = createFrustum(points, i);
    }
  }
  if (frustums[shadowMapIndex].getParent() == null) {
    ((Node) viewPort.getScenes().get(0)).attachChild(frustums[shadowMapIndex]);
  }
}

代码示例来源:origin: us.ihmc/ihmc-jmonkey-engine-toolkit

public double getPickDistance(Node rootNode, Vector3D normalToPack, Point3D closestPoint)
{
 results.clear();
 rootNode.collideWith(collidable, results);
 for (CollisionResult collisionResult : results)
 {
   Geometry geometry = collisionResult.getGeometry();
   String userDataRayCastOpacity = JMERayCollisionAdapter.searchForUserData(geometry.getParent(), JMERayCastOpacity.USER_DATA_FIELD);
   if (DEBUG)
    System.out.println("JMERayCollisionAdapter: userDataRayCastOpacity = " + userDataRayCastOpacity);
   if (JMERayCastOpacity.OPAQUE.toString().equals(userDataRayCastOpacity))
   {
    if (normalToPack != null)
    {
      packInSCSCoordinates(collisionResult.getContactNormal(), normalToPack);
    }
    if (closestPoint != null)
    {
      packInSCSCoordinates(collisionResult.getContactPoint(), closestPoint);
    }
    return collisionResult.getDistance();
   }
 }
 return Double.NaN;
}

代码示例来源:origin: us.ihmc/IHMCJMonkeyEngineToolkit

public double getPickDistance(Node rootNode, Vector3d normalToPack, Point3d closestPoint)
{
 results.clear();
 rootNode.collideWith(collidable, results);
 for (CollisionResult collisionResult : results)
 {
   Geometry geometry = collisionResult.getGeometry();
   String userDataRayCastOpacity = JMERayCollisionAdapter.searchForUserData(geometry.getParent(), JMERayCastOpacity.USER_DATA_FIELD);
   if (DEBUG)
    System.out.println("JMERayCollisionAdapter: userDataRayCastOpacity = " + userDataRayCastOpacity);
   if (JMERayCastOpacity.OPAQUE.toString().equals(userDataRayCastOpacity))
   {
    if (normalToPack != null)
    {
      packInSCSCoordinates(collisionResult.getContactNormal(), normalToPack);
    }
    if (closestPoint != null)
    {
      packInSCSCoordinates(collisionResult.getContactPoint(), closestPoint);
    }
    return collisionResult.getDistance();
   }
 }
 return Double.NaN;
}

代码示例来源:origin: net.sf.phat/phat-devices

private void fixScreen(Spatial device) {
  List<Spatial> screens = SpatialUtils.getSpatialsByRole(device, "Screen");
    if (screens.size() > 0) {
      Geometry geo = (Geometry) screens.get(0);
      Node p = geo.getParent();
      geo.removeFromParent();
      geo = new Geometry("Screen", new Quad(1f, 0.6f));
      geo.setUserData("ID", "Screen1");
      geo.setUserData("ROLE", "Screen");
      Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
      mat.setTexture("ColorMap", assetManager.loadTexture("Textures/FrontSmartPhone.jpg"));
      geo.setMaterial(mat);
      geo.move(-1.4f, 0f, -0.6f);
      geo.rotate(-FastMath.HALF_PI, 0f, 0f);
      geo.setLocalScale(Vector3f.UNIT_XYZ.divide(p.getWorldScale()));
      p.attachChild(geo);
      setState(State.Success);
      return;
    }
}

代码示例来源:origin: us.ihmc/IHMCJMonkeyEngineToolkit

Node parentNode = closest.getGeometry().getParent();

代码示例来源:origin: us.ihmc/ihmc-jmonkey-engine-toolkit

Node parentNode = closest.getGeometry().getParent();

代码示例来源:origin: net.sf.phat/phat-devices

@Override
public void runCommand(Application app) {
  DevicesAppState devicesAppState = app.getStateManager().getState(DevicesAppState.class);
  Node device = devicesAppState.getDevice(deviceId);
  if (device != null) {
    List<Spatial> screens = SpatialUtils.getSpatialsByRole(device, "Screen");
    if (screens.size() > 0) {
      Geometry geo = (Geometry) screens.get(0);
      Node p = geo.getParent();
      geo.removeFromParent();
      geo = new Geometry("Screen", new Quad(1f, 0.6f));
      geo.setUserData("ID", "Screen1");
      geo.setUserData("ROLE", "Screen");
      Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
      mat.setTexture("ColorMap", assetManager.loadTexture(imagePath));
      geo.setMaterial(mat);
      geo.move(-1.4f, 0f, -0.6f);
      geo.rotate(-FastMath.HALF_PI, 0f, 0f);
      geo.setLocalScale(Vector3f.UNIT_XYZ.divide(p.getWorldScale()));
      p.attachChild(geo);
      setState(State.Success);
      return;
    }
  }
  setState(State.Fail);
}

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

/**
 * Update the local transform of the attachments node.
 */
private void updateAttachNode() {
  Node attachParent = attachNode.getParent();
  if (attachParent == null || targetGeometry == null
      || targetGeometry.getParent() == attachParent
      && targetGeometry.getLocalTransform().isIdentity()) {
    /*
     * The animated meshes are in the same coordinate system as the
     * attachments node: no further transforms are needed.
     */
    attachNode.setLocalTranslation(modelPos);
    attachNode.setLocalRotation(modelRot);
    attachNode.setLocalScale(modelScale);
  } else {
    Spatial loopSpatial = targetGeometry;
    Transform combined = new Transform(modelPos, modelRot, modelScale);
    /*
     * Climb the scene graph applying local transforms until the 
     * attachments node's parent is reached.
     */
    while (loopSpatial != attachParent && loopSpatial != null) {
      Transform localTransform = loopSpatial.getLocalTransform();
      combined.combineWithParent(localTransform);
      loopSpatial = loopSpatial.getParent();
    }
    attachNode.setLocalTransform(combined);
  }
}

代码示例来源:origin: tonihele/OpenKeeper

FrontEndLevelControl controller = results.getCollision(i).getGeometry().getParent().getParent().getControl(FrontEndLevelControl.class);
if (controller != null) {

代码示例来源:origin: tonihele/OpenKeeper

private void updateInteractiveObjectOnCursor() {
  // See if we hit a creature/object
  CollisionResults results = new CollisionResults();
  // Convert screen click to 3D position
  Vector3f click3d = app.getCamera().getWorldCoordinates(
      new Vector2f(mousePosition.x, mousePosition.y), 0f);
  Vector3f dir = app.getCamera().getWorldCoordinates(
      new Vector2f(mousePosition.x, mousePosition.y), 1f).subtractLocal(click3d);
  // Aim the ray from the mouse spot forwards
  Ray ray = new Ray(click3d, dir);
  // Collect intersections between ray and all nodes in results list
  getWorldHandler().getThingsNode().collideWith(ray, results);
  // See the results so we see what is going on
  Node object;
  for (int i = 0; i < results.size(); i++) {
    // TODO: Now just creature control, but all interaction objects
    object = results.getCollision(i).getGeometry().getParent().getParent();
    IInteractiveControl control = object.getControl(IInteractiveControl.class);
    if (control != null) {
      setInteractiveControl(control);
      return;
    }
  }
  setInteractiveControl(null);
}

相关文章