Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: down & adjust events (metool)

  1. #1

    down & adjust events (metool)

    How can I determine if a handle was pressed in the "down" event?
    I'm trying to do one thing (new handle) if there was a click anywhere but on a handle and another thing (move it) if a handle was clicked.

  2. #2
    Registered User adamredwoods's Avatar
    Join Date
    Jul 2006
    Location
    San Francisco, CA
    Posts
    2,030
    I don't know for sure since I work more in Layout, but according to the SDK:

    hnum = start( instance, eventinfo )
    Take an initial mouse-down position and return the index of the handle that should be dragged.


    domouse = down( instance, eventinfo )
    Process a mouse-down event. If this function returns 0, handle processing will be done instead of raw mouse event processing.
    So you would check first for _domouse, and if _domouse is >0 then its a mouse-down event. If _domouse ==0, then processing is handed to the handle, which then you would check _hnum for the handle index number.
    // To draw is to think and discover.

  3. #3
    My problem is that down seems to be always called before hadle processing. During "down" I cannot (or I do not know how to) determine if a handle was pressed. If I delegate the processing to handle (by returning 0), it is called only if actual handle was pressed. Otherwise my click is not being registered because I skipped processing it in the down event by returning 0.

    Apparently it is doable because LW's native bezier tool does just that (there probably are other examples too)

  4. #4
    Upon further inspection i see that it is adjust that is not being called, not handle. I think I'm onto something. Thanks for pointing me into the right direction

  5. #5
    Well, I'm still stuck. Any other ideas? Anyone?

  6. #6
    Registered User
    Join Date
    Nov 2007
    Location
    Japan
    Posts
    22
    I have written my independent processing to do it in the down event.
    Convert modeler world position of a handle into event local position that defined "event->axis" as z-axis, and check if a handle was clicked.

    But, there is a problem a little ...
    I want the viewing position in modeler ...
    Give me it ...

  7. #7
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129
    Have you looked at /lwsdk/html/articles/box4.html? Ernie gives a good explanation of how the MeshEditTools work there. And if you compile the lwsdk/sample/Modeler/CommandSequence/boxes/Box4 example plugin using wdtool.c and wdbui.c, you can get a runtime Trace of all the callbacks which is very useful for learning how Tool system works.

    -Steve

  8. #8
    Member
    Join Date
    Feb 2003
    Location
    Unknown Cavern
    Posts
    930
    Yes, the tutorial in the SDK does layout how to do what you asked above, like hurley pointed out. I have read it a couple times, soon going to try it.
    Current system Specs:
    4gb ddr2 1066
    dual 9600 gt (512mb each) running SLI
    9600 black edition amd
    780a nvidia chipset
    XP Pro or XP Pro 64 or Windows 7

  9. #9
    I've looked at it before (and compiled it) when I took interest in building my own tools. It does not seem to discuss the "down" function but I'll have another look in case I missed something.

  10. #10
    Member PICTRIX's Avatar
    Join Date
    Jan 2005
    Location
    Nerima, Japan
    Posts
    299
    The "Down callback" cannot obtain Handle information.
    It can know Handle information by the "Adjust callback".
    However, when Handle is not clicked, the "Adjust callback" will not be called.
    I have the possibility of misunderstanding it possibly.

  11. #11
    Hello master pictrix! This is EXACTLY how I understand it too and this is my problem (or I am not seeing clearly). If an empty space is clicked (not a handle) I want to create a new handle there and if a handle is clicked I want to adjust it. I cannot perform the "new handle" action in the adjust function because it is not called at all if empty space is clicked. I could do it in down function, but in down function I cannot tell if a handle was clicked or not. I could probably test proximity to existing handles, but maybe there is some more direct way of doing it.
    As I said before, the built in bezier tool seems to do it. For the time being I add new handles with the right mouse click, but I'd be still happy to hear how to do it properly.

  12. #12
    Member PICTRIX's Avatar
    Join Date
    Jan 2005
    Location
    Nerima, Japan
    Posts
    299
    Hi art ,

    It is the order of calling the callback.
    ....
    Down
    Count
    Handle
    Adjust : if Handle click
    ....
    Test
    Build : if update == LWT_TEST_UPDATE
    Draw
    ....

    Coordinates of the down of the mouse are recorded by the "Down callback".
    It sets it in newHandleFlag (your private variable)= turning ON.
    To call the "Build callback", update=LWT_TEST_UPDATE is set.

    If the "Adjust callback" is called, Handle is processed.
    And, it sets it in newHandleFlag=OFF.

    When the "Build callback" is called, newHandleFlag is examined.
    If it is ON, new Handle is made in the recorded coordinate value.

  13. #13
    I knew it would be simple. Thank you for explanation pictrix. Now I have a lightbulb flashing over my head (again)

  14. #14
    Super Member
    Join Date
    Jul 2003
    Location
    somewhere
    Posts
    1,129
    I've always used Art's method of adding new handles with the right mouse and I was hoping that Pictrix's method would work. But I can only get that method to create 1 handle. Once there's handles in the system, Modeler only seems to call Dirty and Test if Adjust is called first. So the next Down event will not call Build to create another handle.

    I made a little bare bones C++ plugin to for testing here if anyone is interested.

    -Steve

  15. #15
    Member PICTRIX's Avatar
    Join Date
    Jan 2005
    Location
    Nerima, Japan
    Posts
    299
    Quote Originally Posted by hurley
    Once there's handles in the system, Modeler only seems to call Dirty and Test if Adjust is called first. So the next Down event will not call Build to create another handle.

    -Steve
    I'm sorry. It is my mistake.

    I am writing the program without using "Count, Handle, Start, and Adjust" callback.

    The function that replaces it is made and executed.

    Function to know click and drug of user handles.
    This is used from the Down callback.
    Function equal with Adjust callback.
    It uses it from Move callback and the Up callback.

    Flexibility is very obtained.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •