TransformManipulator (object)

バージョン 1.12.0 で追加.

The TransformManipulator combines a PositionGizmosManager and a OrientationGizmosManager to support translation and rotation in 3d.

The Transform manipulator displays a collection of different gizmos, each for manipulating the transforms in a different way.

When a TransformManipulator is constructed, it automatically constructs the PositionGizmosManager and OrientationGizmosManager, which in turn construct Gizmo manages for each axis and plane of manipulation.

The TransformManipulator can be used to manipulate a group of transforms via the GizmoManipulationCallback. As the gizmos are manipulated, the computed delta transforms that are then sent to the GizmoManipulationCallback callback for handling. It is the callbacks responsibility to apply the delta to the targets and generate the undo/redo objects.

/*
** Example: TransformManipulator-Example
*/

require InlineDrawing;

operator entry() {

  // this is a singleton
  InlineDrawing drawing = OGLInlineDrawing_GetInstance();


  InlineTransform groupTransform = StaticInlineTransform('groupTransform', Xfo(Vec3(0.0, 0.0, 0.0)));
  drawing.getRoot().addChild(groupTransform);

  // Setup the manipulator
  {
      Ref<EventDispatcher> eventDispatcher = EventDispatcher_GetInstance();

      TransformManipulationCallback callback();
      callback.addTarget(groupTransform);

      TransformManipulator transformManipulator = TransformManipulator(groupTransform, 140.0, callback);
      eventDispatcher.registerManipulator(transformManipulator);
  }
  {
    InlineShader surfaceShader = OGLSurfaceShader('surface');
    drawing.registerShader(surfaceShader);

    InlineMaterial phongMaterial = surfaceShader.getOrCreateMaterial("phong");

    Size offset;

    // create some spheres

    {
      PolygonMesh sphere();
      Size detail = 24;
      Scalar radius = 1.0;
      sphere.addSphere(Xfo(), radius, detail, true, true);

      InlineMeshShape shape = InlineMeshShape('sphere', sphere);
      drawing.registerShape(shape);

      {
        InlineTransform transform = StaticInlineTransform('sphereTransform', Xfo(Vec3(4.0, 0.0, 0.0)));
        groupTransform.addChild(transform);

        InlineInstance instance = InlineInstance('sphere1', transform, shape);
        instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(1.0, 0.0, 0.0)));

        instance.addMaterial(phongMaterial);
      }

      {
        InlineTransform transform = StaticInlineTransform('sphereTransform', Xfo(Vec3(0.0, 4.0, 0.0)));
        groupTransform.addChild(transform);

        InlineInstance instance = InlineInstance('sphere2', transform, shape);
        instance.setInstanceUniform(InlineUniform('u_diffuseColor',  Color(0.0, 1.0, 0.0)));

        instance.addMaterial(phongMaterial);

      }
      {
        InlineTransform transform = StaticInlineTransform('sphereTransform', Xfo(Vec3(0.0, 0.0, 4.0)));
        groupTransform.addChild(transform);

        InlineInstance instance = InlineInstance('sphere3', transform, shape);
        instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(0.0, 0.0, 1.0)));

        instance.addMaterial(phongMaterial);
      }
    }
  }
  {
    // activate the transform manipulator
    Ref<EventDispatcher> eventDispatcher = EventDispatcher_GetInstance();
    eventDispatcher.pushManipulator('TransformManipulator');
  }

}

/*
** Output:
(stdin):19:28: error: 'Ref<EventDispatcher>': type not registered
(stdin):21:7: error: 'TransformManipulationCallback': type not registered
(stdin):22:7: error: 'callback': symbol not found
(stdin):24:28: error: 'TransformManipulator': type not registered
(stdin):25:7: error: 'eventDispatcher': symbol not found
(stdin):79:26: error: 'Ref<EventDispatcher>': type not registered
(stdin):80:5: error: 'eventDispatcher': symbol not found


*/

TransformManipulator TransformManipulator TransformManipulator GizmoManipulator GizmoManipulator TransformManipulator->GizmoManipulator Manipulator Manipulator GizmoManipulator->Manipulator

Members

Scalar coneThreshold  
GizmoHandler activeGizmoHandler  
GizmoHandler mouseOverGizmoHandler  
GizmoCollector collector  
InlineInstance[] gizmos  
PositionGizmosManager positionGizmosManager The manager for the position gizmos
OrientationGizmosManager orientationGizmosManager The manager for the orientation gizmos
ManipulationMode mode The mode determining which gizmos are currently visible.

Methods

  TransformManipulator ( in TransformManipulator other )
  TransformManipulator ( io InlineTransform parent, in Scalar size, in GizmoManipulationCallback callback )
  TransformManipulator ()
TransformManipulator clone ? ()
  onDisable ! ()
  onEnable ! ()
  onEvent ! ( io Event event )
  setManipulationMode ! ( in ManipulationMode mode )

Methods in detail

TransformManipulator ( in TransformManipulator other )

copy constructor


TransformManipulator ( io InlineTransform parent, in Scalar size, in GizmoManipulationCallback callback )


TransformManipulator ()

default constructor


TransformManipulator TransformManipulator.clone? ()

clone method


TransformManipulator.onDisable! ()

When the manipulator is disabled, this callback function is invoked.


TransformManipulator.onEnable! ()

When the manipulator is enabled, this callback function is invoked.


TransformManipulator.onEvent! ( io Event event )

The event handler function for the GizmoManipulator. In this function the gizmos are raycast on mouse down, and if a gizmo is hit it becomes the active gizmo until the mouse is released. While a gizmo is active, all mouse events are sent to its gizmo event handler.

event The event propagated from the host DCC application


TransformManipulator.setManipulationMode! ( in ManipulationMode mode )

Sets the current manipulation mode, hiding/showing the appropriate gizmos

mode the bit set defining the visible manipulation gizmos