ObjectManipulator customization

In build 9.0.293 has been introduced the possibility to customize the ObjectManipulator by specifying custom meshes, thanks to the ObjectManipulator.Entities property.

The standard appearance of the ObjectManipulator is this one:

Capture.PNG

By specifiying custom meshes it's possible to change its appearance:

Capture2.PNG

 

Code:

var vp = viewportLayout1;

vp.ObjectManipulator.Entities.Clear();

var orig = Mesh.CreateBox(1.6, 1.6, 1.6);
orig.Translate(-0.8, -0.8, -0.8);
vp.ObjectManipulator.Entities.Add(orig);
            
var meshX = Mesh.CreateArrow(0.4, 15, 0.6, 3, 10, Mesh.natureType.Smooth);
meshX.Translate(-7.5, 0, 0);
            
var meshY = (Mesh)meshX.Clone();
meshY.Rotate(Math.PI / 2, Vector3D.AxisZ);

var meshZ = Mesh.CreateArrow(0.4, 7.5, 0.6, 3, 10, Mesh.natureType.Smooth);
meshZ.Rotate(-Math.PI / 2, Vector3D.AxisY);

vp.ObjectManipulator.Entities.Add(meshX);
vp.ObjectManipulator.Entities.Add(meshY);
vp.ObjectManipulator.Entities.Add(meshZ);

vp.ObjectManipulator.TranslateX.Color = Color.Pink;
vp.ObjectManipulator.TranslateY.Color = Color.Orange;
vp.ObjectManipulator.TranslateZ.Color = Color.Aquamarine;
vp.ObjectManipulator.Translate.Color = Color.Chocolate;

var reg = new Region(new Circle(5, 0, 0, 0.4));
var arcY = reg.RevolveAsMesh(0, Math.PI, -1 * Vector3D.AxisY, Point3D.Origin, 10, 0.1, Mesh.natureType.Smooth);

var arcX = (Mesh)arcY.Clone();
arcX.Rotate(Math.PI / 2, Vector3D.AxisZ);

reg = new Region(new Circle(5, 0, 0, 0.4));
var arcZ = reg.RevolveAsMesh(0, 2 * Math.PI, Vector3D.AxisY, Point3D.Origin, 20, 0.1, Mesh.natureType.Smooth);
arcZ.Rotate(Math.PI / 2, Vector3D.AxisZ);
arcZ.Rotate(Math.PI / 2, Vector3D.AxisY);

vp.ObjectManipulator.Entities.Add(arcX);
vp.ObjectManipulator.Entities.Add(arcY);
vp.ObjectManipulator.Entities.Add(arcZ);

vp.ObjectManipulator.RotateX.Color = Color.Pink;
vp.ObjectManipulator.RotateY.Color = Color.Orange;
vp.ObjectManipulator.RotateZ.Color = Color.Aquamarine;

vp.CompileUserInterfaceElements();
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

3 comments
  • Hi Luca

    Is it possible to make the colours of the meshes transparent? I tried making the colours ARGB with a low alpha but it did not seem to do anything.

    Do I need to do it through a colour on the mesh and change the color settings?

     

    Thanks

  • Hi Martin,

     

    you can try with this override:

     

    class MyOM : ObjectManipulator
    {
       public MyOM()
       {
       }

       public override void Draw(RenderParams data)
       {
          data.RenderContext.SetState(blendStateType.Blend);
          base.Draw(data);
          data.RenderContext.SetState(blendStateType.NoBlend);

       }
    }

    viewportLayout1.ObjectManipulator = new MyOM();
    viewportLayout1.ObjectManipulator.ArrowColorX = Color.FromArgb(50, Color.Red);
    viewportLayout1.ObjectManipulator.ArrowColorY = Color.FromArgb(50, Color.Green);
    viewportLayout1.ObjectManipulator.ArrowColorZ = Color.FromArgb(50, Color.Blue);
    viewportLayout1.ObjectManipulator.Enable(new Identity(), true);
    viewportLayout1.CompileUserInterfaceElements();

  • That works great thanks

Please sign in to leave a comment.