コード例 #1
0
  public static void recursiveHelper(RenderObject node) {
    // set the mWorldTransform
    if (node.parent == null) {
      node.mWorldTransform.set(node.sceneObject.transformation);

    } else {
      node.mWorldTransform
          .set(node.sceneObject.transformation)
          .mulAfter(node.parent.mWorldTransform);
    }

    // set the mWorldTransformIT
    Matrix4 normal = new Matrix4(node.mWorldTransform);
    normal.transpose().invert();
    normal.getAxes(node.mWorldTransformIT);

    // set the end of recursion
    if (node.children.size() == 0) {
      return;
    }

    for (RenderObject child : node.children) {
      recursiveHelper(child);
    }
  }
コード例 #2
0
  /**
   * Get the transformation that should be used to draw <manip> when it is being used to manipulate
   * <object>.
   *
   * <p>This is just the object's or parent's frame-to-world transformation, but with a rotation
   * appended on to orient the manipulator along the correct axis. One problem with the way this is
   * currently done is that the manipulator can appear very small or large, or very squashed, so
   * that it is hard to interact with.
   *
   * @param manip The manipulator to be drawn (one axis of the complete widget)
   * @param mViewProjection The camera (not needed for the current, simple implementation)
   * @param object The selected object
   * @return
   */
  public Matrix4 getTransformation(Manipulator manip, RenderCamera camera, RenderObject object) {
    Matrix4 mManip = new Matrix4();

    switch (manip.axis) {
      case Manipulator.Axis.X:
        Matrix4.createRotationY((float) (Math.PI / 2.0), mManip);
        break;
      case Manipulator.Axis.Y:
        Matrix4.createRotationX((float) (-Math.PI / 2.0), mManip);
        break;
      case Manipulator.Axis.Z:
        mManip.setIdentity();
        break;
    }
    if (parentSpace) {
      if (object.parent != null) mManip.mulAfter(object.parent.mWorldTransform);
    } else mManip.mulAfter(object.mWorldTransform);

    return mManip;
  }