Cursor coordinates



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2007 at 02:07, xxxxxxxx wrote:

    What are you trying to achieve? Do you need the mouse coords only once you call the plugin? Or is this some sort of non-modal dialog and you want to check constantly for mouse corrds? You probably have to use a scenehook for this.

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2007 at 03:04, xxxxxxxx wrote:

    <<<and get the mouse coordinates using BaseDraw::WS(). >>>
    What? I think you not understand me. I need just cursor position in screen. 2d coordinates of cursor.
     
    <<<Do you need the mouse coords only once you call the plugin?>>>
    Yes. I need them once. When my command-plugin executes.
     
    <<<What are you trying to achieve?>>>
    I want to write CommandPlugin, assign it to some shortcut, and when I press that shortcut - loop selection jumps towards the cursor.
    So I need to get cursor position in screen coordinates. I neet get it in "Execute" method of my CommandData.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2007 at 03:10, xxxxxxxx wrote:

    When in cinema4d I make right double-click - executes some "ray selection" command.
    How that command gets cursor positions relative to active viewport?
    Is it possible via plugin?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/05/2007 at 10:44, xxxxxxxx wrote:

    Oh, I completely understand you. You need the cursor position on the screen - in the active viewport.

    WS = World to Screen coordinates. This takes a point in the 3D viewport and converts it to 2D screen coordinates - these are the cursor coordinates within the viewport.

    There is no other way that I know of to get the mouse cursor coordinates using the SDK (unlike Tool plugins and GUI (dialog) elements). There is no GetMousePos() type method in any of the viewport classes.

    GetInputEvent()/GetInputState() are only usable with GeDialog and GeUserArea (they're out). There are generalized versions of these two methods, but haven't tried them in the way that you require.

    ToolData::GetCursorInfo() is, as you mentioned, only usable with Tool plugins.

    As mentioned, a SceneHook plugin has exactly what you need: SceneHookData::GetCursorInfo() and SceneHookData::MouseInput(). Tie it to the Command plugin and 'fake' it. :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/06/2007 at 13:13, xxxxxxxx wrote:

    I return to work on that plugin now. And Im trying your advises.
    I have no dialogs or any GUI. So the only way is to implement SceneHookData::GetCursorInfo()
    And I see a problem here. When I register SceneHookData with GetCursorInfo() then all ToolData plugins which uses GetCursorInfo() not works!
    Is there way around?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/06/2007 at 13:23, xxxxxxxx wrote:

    And one more question plz
    In API documentation "SceneHookData" -> "GetCursorInfo" there are words: "Make sure that you only use this function when the user is somehow working with your plugin, so that other plugins can also use this hook when it's their turn"
    Supposed that I can use this function sometimes, and some timese not. How can I temporary not use this function ?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 04/06/2007 at 13:24, xxxxxxxx wrote:

    The SDK Docs say this for SceneHookData::MouseInput() and GetCursorInfo() :

    Note: Make sure that you only use this function when the user is somehow working with your plugin, so that other plugins can also use this hook when it's their turn.

    Sort of vague but it means that, yes, you need to find a way to allow Tools to do their thing despite the SceneHook plugin being there. What worries me is that the cursor/mouse could be being 'gobbled up' by the SceneHook and never passing the information to the Tools.
    Maybe Matthias can provide a methodology for doing this?

    At first blush, InitSceneHook() and FreeSceneHook() might provide a framing wherein you should care about mouse-input/cursor positioning - allowing the Tools to work outside of that framing (before InitSceneHook and after FreeSceneHook).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/06/2007 at 08:04, xxxxxxxx wrote:

    <<<the cursor/mouse could be being 'gobbled up' by the SceneHook and never passing the information to the Tools>>>
    Sure it does. I have checked it. Tool plugins not works with such sceneHook.
    Furthermore InitSceneHook and FreeSceneHook functions are not for "turn hook on" or "turn hook off". Look what documentation say: <<<InitSceneHook ... Called before all scene hooks and expressions in a scene are calculated. Here you can allocate temporary data in the node>>>
    <<<FreeSceneHook ... Called after all scene hooks and expressions in a scene are calculated, before the drawing starts. Here you can free temporary data allocated in InitSceneHook().>>>
    Thus question is still open.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 07/06/2007 at 08:38, xxxxxxxx wrote:

    InitSceneHook/FreeSceneHook are certainly not 'turn hook on or off'. But did you consider that these might be called just before/after the hook is executed and you will only be caring about mouse/cursor while the SceneHook is in execution so that tools get the mouse/cursor when not being executed (before InitSceneHook is called and after FreeSceneHook). It is a good bet that the SceneHook is only doing its thing inbetween these two calls - otherwise Cinema 4D tools wouldn't work at all I would suspect. :)

    In InitSceneHook, you set a Boolean to TRUE to signify that your SceneHook is about to be executed and you set it to FALSE in FreeSceneHook to signify that it is now finished executing. In your code to track the cursor position (in GetCursorInfo() for instance), you check that Boolean before doing anything - and return FALSE otherwise (see Thread 1 below).

    Now, I can't say if this will work or not as I haven't needed to resort to a SceneHook yet and, as I mentioned, that Note is about as vague as you can get.

    Thread 1

    Thread 2

    As mentioned other times and often, a SceneHook example in the cinema4Dsdk folder would be a very welcomed thing especially for something as dangerous as this.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/06/2007 at 00:49, xxxxxxxx wrote:

    A scenehook definetly does work with a tool.
    A scenehook is there all the time. The thing is not to think of "when can I NOT use it" but rather "when can I use it".

    I used a scenehook for my RulerTools plugin. I used it for drawing the ruler lines etc. and used MouseInput when my helpline tool was used (simply check which tool is currently active and if it´s yours), which was perfect because I needed it just before a redraw happened as there was nothing to change in the scene actually but only the helpline draw data.
    That´s how I´ve done it and it worked charmingly. There´s no magic to it. Simply do your stuff in the according scenehook functions when your tool is used.

    However, I really don´t see the point in having a commanddata working with cursor information. What´s the point in that?? This is a job for a tool plugin, not for a command data pluggy.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/06/2007 at 12:55, xxxxxxxx wrote:

    oh yes. Thanks a lot, guys.
    I just was confused by this words from documentation:
    <<< Return: FALSE If a problem occured during this function>>>
    So I even not tryed to return FALSE ;)
     
    ...
    <<<What´s the point in that?? This is a job for a tool plugin, not for a command data pluggy.>>>
    There is a point. I want to write a command-plugin that works according cursor position. If I made it via tool, it needs 3 clicks for use (choose tool, click, choose previous tool). Command needs only one click :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/06/2007 at 07:30, xxxxxxxx wrote:

    hehe, true, that´s a point. BUT (there´s always a but ;-) how does the user choose the command if he doesn´t do it with the mouse? Which means he cannot click on the command with the mouse as it has to be at the location where he wants to use it. Imo, this is unintuitive. And especially when he wants to use it several times. A tool would be more intuitive and faster to handle several situations.

    But hey, that´s just my opinion. go for it, curious to see what you are doing. :-)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/06/2007 at 10:33, xxxxxxxx wrote:

    Yes, right. Such command can only be used via keyboard shortcut.
    Yes, it is not good for novice users. But really handy for pro.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/06/2007 at 11:08, xxxxxxxx wrote:

    Howdy,

    Try this in your Execute function:

      
    BaseContainer state;  
    GetInputState(BFM_INPUT_MOUSE, BFM_INPUT_MOUSELEFT, state);  
    Real mx = state.GetReal(BFM_INPUT_X);  
    Real my = state.GetReal(BFM_INPUT_Y);  
    GePrint("Cursor coordinates: x = "+RealToString(mx)+"; y = "+RealToString(my));  
    

    Although, that will return coordinates for the entire screen, not just the active view.

    Adios,
    Cactus Dan



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/06/2007 at 13:08, xxxxxxxx wrote:

    It is just I looked for !
    Using this I neednt add any SceneHooks into my CommandData plugin.
    Thank you a lot !



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 12/06/2007 at 13:14, xxxxxxxx wrote:

    Howdy,

    You're welcome. ;o)

    Adios,
    Cactus Dan


Log in to reply