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:
By specifying custom meshes it's possible to change its appearance:
Code:
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();
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
That's really cool but I need to also set ObjectManipulator.Translate.Selectable to True and/or False and it does not seem to work.
It only works if I place this in the Forms Sub New() but no where else. Any ideas as to how i could programmatically turn on or off the Translate.Selectable or the RotateX,Y,Z.Selectable as the application is being used just not when its initialized?
Please sign in to leave a comment.