GizmoManipulator (object)¶
バージョン 1.12.0 で追加.
The GizmoManipulator is used to propagate events to gizmos in the scene. A “Gizmo” is any InlineInstance that has a ‘GizmoHandler‘ attached as meta data.
Often only a single GizmoManipulator is registered for all visible gizmos. The GizmoManipulator then handles raycasting the visible gizmos in the scene to determine which should become the target of the manipulation
When the mouse is clicked down, the gizmos in the scene are raycast, and the hit gizmo becomes the active gizmo for the duration of the mouse action. All mouse move events are sent to the gizmo for processing. On mouse up, the gizmo is released and is no longer the active gizmo. How a gizmos handler reacts to mouse vents is completely up to the implementation of the gizmo handler.
/*
** Example: GizmoManipulator
*/
// Setup the gizmo manipulator
Ref<EventDispatcher> eventDispatcher = EventDispatcher_GetInstance();
eventDispatcher.registerManipulator(GizmoManipulator());
// activate the manipulator
eventDispatcher.pushManipulator('GizmoManipulator');
// setup the scene.
InlineDrawing drawing = OGLInlineDrawing_GetInstance();
InlineShader surfaceShader = drawing.registerShader(OGLSurfaceShader());
InlineMaterial phongMaterial = surfaceShader.getOrCreateMaterial("phong");
// create a shape
PolygonMesh gizmoMesh = PolygonMesh();
gizmoMesh.addCuboid(Xfo(), 1.0, 1.0, 1.0, true, false);
InlineShape shape = InlineMeshShape('gizmoMesh', gizmoMesh);
// The following code generates several different geometries to be used as
// gizmos, and
Integer index;
// Position Axis Gizmo X
{
InlineTransform transform = StaticInlineTransform('PositionAxisGizmoTransformX', drawing.getRoot(), Xfo(Vec3(Scalar(index)*4.0, 0.0, 0.0)));
InlineInstance instance = InlineInstance('PositionAxisGizmoX', transform, shape, phongMaterial);
instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(1.0, 0.0, 0.0)));
TransformManipulationCallback callback();
callback.addTarget(transform);// the gizmo only manipulates itself
PositionAxisGizmoHandler handler(instance, Vec3(1.0, 0.0, 0.0), callback);
index++;
}
// Position Axis Gizmo Y
{
InlineTransform transform = StaticInlineTransform('PositionAxisGizmoTransformY', drawing.getRoot(), Xfo(Vec3(Scalar(index)*4.0, 0.0, 0.0)));
InlineInstance instance = InlineInstance('PositionAxisGizmoY', transform, shape, phongMaterial);
instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(0.0, 1.0, 0.0)));
TransformManipulationCallback callback();
callback.addTarget(transform);// the gizmo only manipulates itself
PositionAxisGizmoHandler handler(instance, Vec3(0.0, 1.0, 0.0), callback);
index++;
}
// Position Axis Gizmo Z
{
InlineTransform transform = StaticInlineTransform('PositionAxisGizmoTransformZ', drawing.getRoot(), Xfo(Vec3(Scalar(index)*4.0, 0.0, 0.0)));
InlineInstance instance = InlineInstance('PositionAxisGizmoZ', transform, shape, phongMaterial);
instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(0.0, 0.0, 1.0)));
TransformManipulationCallback callback();
callback.addTarget(transform);// the gizmo only manipulates itself
PositionAxisGizmoHandler handler(instance, Vec3(0.0, 0.0, 1.0), callback);
index++;
}
// Position Planar Gizmo XY
{
InlineTransform transform = StaticInlineTransform('PositionPlanarGizmoHandlerXY', drawing.getRoot(), Xfo(Vec3(Scalar(index)*4.0, 0.0, 0.0)));
InlineInstance instance = InlineInstance('PositionAxisGizmoXY', transform, shape, phongMaterial);
instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(1.0, 1.0, 0.0)));
TransformManipulationCallback callback();
callback.addTarget(transform);// the gizmo only manipulates itself
PositionPlanarGizmoHandler handler(instance, Vec3(0.0, 1.0, 0.0), callback);
index++;
}
// Orientation Axis Gizmo X
{
InlineTransform transform = StaticInlineTransform('OrientationAxisGizmoTransformX', drawing.getRoot(), Xfo(Vec3(Scalar(index)*4.0, 0.0, 0.0)));
InlineInstance instance = InlineInstance('OrientationAxisGizmoX', transform, shape, phongMaterial);
instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(1.0, 0.0, 0.0)));
TransformManipulationCallback callback();
callback.addTarget(transform);// the gizmo only manipulates itself
OrientationAxisGizmoHandler handler(instance, Vec3(1.0, 0.0, 0.0), callback);
index++;
}
// Orientation Axis Gizmo Y
{
InlineTransform transform = StaticInlineTransform('OrientationAxisGizmoTransformY', drawing.getRoot(), Xfo(Vec3(Scalar(index)*4.0, 0.0, 0.0)));
InlineInstance instance = InlineInstance('OrientationAxisGizmoY', transform, shape, phongMaterial);
instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(0.0, 1.0, 0.0)));
TransformManipulationCallback callback();
callback.addTarget(transform);// the gizmo only manipulates itself
OrientationAxisGizmoHandler handler(instance, Vec3(0.0, 1.0, 0.0), callback);
index++;
}
// Orientation Spherical Gizmo
{
InlineTransform transform = StaticInlineTransform('OrientationSphericalGizmoTransform', drawing.getRoot(), Xfo(Vec3(Scalar(index)*4.0, 0.0, 0.0)));
InlineInstance instance = InlineInstance('OrientationSphericalGizmo', transform, shape, phongMaterial);
instance.setInstanceUniform(InlineUniform('u_diffuseColor', Color(0.7, 0.7, 0.7)));
TransformManipulationCallback callback();
callback.addTarget(transform);// the gizmo only manipulates itself
OrientationSphericalGizmoHandler handler(instance, 0.001, callback);
index++;
}
Members¶
Scalar | coneThreshold | |
GizmoHandler | activeGizmoHandler | |
GizmoHandler | mouseOverGizmoHandler | |
GizmoCollector | collector | |
InlineInstance[] | gizmos |
Methods¶
GizmoManipulator ( in GizmoManipulator other ) | |
GizmoManipulator () | |
GizmoManipulator | clone ? () |
onDisable ! () | |
onEnable ! () | |
onEvent ! ( io Event event ) |
Methods in detail¶
GizmoManipulator ( in GizmoManipulator other )
copy constructor
GizmoManipulator GizmoManipulator.clone? ()
clone method
GizmoManipulator.onDisable! ()
The callback fired when the GizmoManipulator is disabled
GizmoManipulator.onEnable! ()
The callback fired when the GizmoManipulator is enabled
注釈
The gizmos in the scene are collected at this point in preparation for interaction.
GizmoManipulator.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 |