lightmap Posted January 10, 2019 Share Posted January 10, 2019 Hello When manipulator changing node transform by ManipulatorCallback, at each transform change, node MUST correct its transform by snapping rule (node must slide along arc) because of that manipulator axis do not match with node transform. how to do manipulator.setTransform(transformation) without releasing mouse button (when I hold mouse button setTransform has no effect) thanks Link to comment
morbid Posted January 10, 2019 Share Posted January 10, 2019 Hi lightmap, I'm sorry but right now it's unclear what issue you're struggling with. Can you send us a test scene and describe expected behavior? Thank you. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
lightmap Posted January 10, 2019 Author Share Posted January 10, 2019 Hello, here demonstration of behavior https://drive.google.com/file/d/182kqdd-ZFcN8u42irg5KQxbP6zKb86TB/view plane mode - ok axis mode - not ok here manipulator wrapper protected virtual void OnMatrixChanged(Matrix4x4 transformation) { MatrixChanged?.Invoke(this, transformation); } public event Action<GizmoRenderController, Matrix4x4> MatrixChanged; private Matrix4x4 _transformation = Matrix4x4.Identity; private bool _transformationSetted; public Matrix4x4 Transformation { get => _transformation; private set { if (value != _transformation) { _transformation = value; OnMatrixChanged(_transformation); } } } public void SetTransformation(Matrix4x4 transformation) { //if (_manipulator==null || _manipulator.isFocusAxis() == 0) return; _transformation = transformation; _transformationSetted = false; } private void ManipulatorCallback() { var transformation = _manipulator.getTransform(); var rotation = new mat4(transformation.getRotate(), vec3.ZERO); //_manipulator.setBasis(rotation); Transformation = transformation.ToMatrix(); } private void UpdateTarget(IRender render) { if (_transformationSetted == false) { _transformationSetted = true; var transformation = _transformation.ToMat4(); var rotation = new mat4(transformation.getRotate(), vec3.ZERO); _manipulator.setCallbackEnabled(Gui.CHANGED, 0); _manipulator.setBasis(rotation); _manipulator.setTransform(transformation); _manipulator.setCallbackEnabled(Gui.CHANGED, 1); } } public virtual void OnUpdate(IRender render) { UpdateTarget(render); if (render?.CurrentCamera is UnigineCamera camera) { Player p = camera.Player; if (p == null) return; _manipulator?.setProjection(p.getProjection()); _manipulator?.setModelview(p.getIWorldTransform()); } } public virtual void OnRender(IRender render) { } public virtual void OnAdded(IRender render) { IsAdded = true; if (_manipulator == null) { _manipulator = _manipulatorFactory.Create(); _manipulator.setSize(64); Gui.get().addChild(_manipulator, Gui.ALIGN_OVERLAP); _manipulator.setHidden(1); _manipulator.setCallback0(Gui.CHANGED, ManipulatorCallback); } Show(); } public void Show() { _manipulator?.setHidden(0); } public virtual void OnRemoved(IRender render) { IsAdded = false; Hide(); } public void Hide() { _manipulator?.setHidden(1); } no test scene Link to comment
ded Posted January 11, 2019 Share Posted January 11, 2019 Hi lightmap, The manipulator is bound to the mouse cursor when you use it, trying to cheat it with the setTransform() or any other way won't work. I think it's just not the right tool for the task. Consider implementing custom manipulator with the desired behavior. In the Unigine Editor we use WidgetCanvas for manipulators. If you'll go this way, you may find useful these samples in your SDK: data/samples/widgets/canvas_03 data/samples/widgets/canvas_04 Link to comment
lightmap Posted January 11, 2019 Author Share Posted January 11, 2019 (edited) ok, thanks, there no canvas_04, implied 02, 03? also why manipulator.setEnabled(0); may not hide it? ok setHidden Edited January 11, 2019 by lightmap Link to comment
ded Posted January 11, 2019 Share Posted January 11, 2019 Yes, you're right, it's canvas_02 and canvas_03. Widget::setEnabled() is meant for disabling an interaction with the widget, think of read-only WidgetEditLine for example. To hide/show a widget there is Widget::setHidden(), you figured out right. Link to comment
Recommended Posts