michael.zhang Posted September 1, 2011 Posted September 1, 2011 Hello, I am struggling to understand how to use WidgetManipulators. I've tried imitating the editor code, but still not working: //init translator = new WidgetManipulatorTranslator(gui); engine.gui.addChild(translator, GUI_ALIGN_OVERLAP); translator.setModelview(player.getModelview()); translator.setProjection(player.getProjection()); // update if(!translator.isFocused()){ translator.setBasis(mat4_identity); translator.setTransform(mat4_identity); // just want this to show up at the origin at least } This does not cause any manipulators to be rendered at the origin. Can you explain how exactly this is mean to be used? What do the various functions need? What is basis, what is transform? What's the normal use case for moving a Node using a WidgetTranslator? Or, updating a vec3 position. Michael Zhang
manguste Posted September 5, 2011 Posted September 5, 2011 You need to set model-view and projection matrices EACH frame, otherwise it cannot be properly rendered when the camera has changed position. The basis of the manipulator is the basis of the coordinate system. It can either be the world coordinates (identity matrix, by default) or coordinates of the parent node if the manipulated node is a child. Transform is for transforming the node via the manipulator. Please check editor_nodes.h, the usage of these functions should be pretty much clear from this code.
michael.zhang Posted September 6, 2011 Author Posted September 6, 2011 Thanks Manguste. I've been using that as my template. The real problem was: Player player = engine.game.getPlayer(); // vs. Player player = engine.editor.getPlayer(); Must be careful which one you use.
frustum Posted September 6, 2011 Posted September 6, 2011 Use Unigine::getPlayer() function from "core/scripts/utils.h" file.
Recommended Posts