MrScienceOfficer Posted July 17, 2015 Share Posted July 17, 2015 Hi, I'm trying to attach an MSS_SingleOpBaseState to an OBJ HDA, I know I can attach to an SOP HDA without trouble but the OBJ isn't working. I have PI_NETMASK_OBJ set for the Pi_Template and it does attach but it doesn't call mouseEvent or keyEvent etc.. It looks like MSS classes are more aimed for SOPs, Do i need to inherit from a BM_State in order to get the mouse events? Thanks Quote Link to comment Share on other sites More sharing options...
edward Posted July 18, 2015 Share Posted July 18, 2015 Object's use an analogue of MSS which isn't exposed in the HDK. So yeah, if you really need to do this you might need to inherit from BM_SingleOpState perhaps. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 18, 2015 Author Share Posted July 18, 2015 (edited) Yeah that was my thought, it attached, but had same issue. But that's seems to be uncharted territory from an outsiders perspective, so I'll have to study the headers and see if I can find any clues as to what it wants. Attaching to a SOP as a workaround shouldn't make any difference, even if I'm working with OBJ_Nodes, at least I don't see how it could. Well I'll find out shortly. Thanks, it s nice to know I'm not just being stupid for once. Edited July 18, 2015 by captain Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 18, 2015 Author Share Posted July 18, 2015 (edited) Okay, shot in the dark here, so please correct me if I'm wrong but manipulating OBJs will probably work but the MSS state won't call doRender unless, the Sop changes? Is there way to force it, or like mark it dirty? Or would it be better to use a RenderHook? Edit: Using a RenderHook seems to have the same flaw. There has to be some way to force rendering right? Okay, attaching the MSS to a faux SOP and forcing it to cook solved the problem Edited July 18, 2015 by captain Quote Link to comment Share on other sites More sharing options...
edward Posted July 19, 2015 Share Posted July 19, 2015 Er, what exactly is the thing that you're trying to accomplish with this object tool? Changing a node won't cause doRender() to be called unless the viewport needs to redraw. And the viewport typically only needs to redraw for objects when their world transform changes AND its displaying some type of geometry. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 20, 2015 Author Share Posted July 20, 2015 Well if you must know This is in particular applies to a bone drawing tool, that raycasts at the character so I can get the exact placement the first time. So I need to draw a manipulator and update it with the mouse. As well as a slew of other tools, I've been working on for an animation and rigging plug in, and an API I designed that basically allows me to attach an event loop to an HDA and make it interactive, with interchangeable mouse events, a UI that renders in the view port and attempts to handles all the issues that come from non procedural editing of geometry in Houdini. The MSS stuff is admittedly less then ideal, but inheriting from a BM_State seems to be pretty complicated without a sample or anything. Quote Link to comment Share on other sites More sharing options...
edward Posted July 20, 2015 Share Posted July 20, 2015 Maybe try calling BM_State::wantLocates(true) in your subclass constructor. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) How do you mean? Inherit from BM_State directly, register with a PI_StateTemplate and then just call WantsLocates()? Would it be that simple to get an event loop? I haven't tried that. Or call BM_State::wantLocates because MSS overrides it? I did try that just now and it doesn't call doRender() that way. Attaching an MSS to a subnet SOP doesn't seem to create any side effect though. The only other issue I do have is getting unfiltered keyboard input, I know I can override it through the interface or python, I forget how I've done it. But I can't seem to figure out what I need to call through the HDK. I can live without it or use looks and feels if I really needed typed input, but I would love to know how to do it. Edited July 20, 2015 by captain Quote Link to comment Share on other sites More sharing options...
edward Posted July 20, 2015 Share Posted July 20, 2015 No, I was thinking of inheriting from BM_SingleOpState, and then having it set wantLocates(true) so that you get mouse move events in your handleMouseEvent() override. Now, you can call redrawScene() (inherited from BM_SimpleState) to cause the viewport to redraw whenever the mouse moves. PS. Make sure you read the comments in the header source itself, and not just look at it from the doxygen docs. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) That was the first thing I tried when you suggested it, it still didn't allow me to attach to OBJs,, at least it still didn't get mouse events. I even checked hasLocates() and it was setting it to true but it wouldn't call handleMouseEvent. My thought is either PI_State needs more then just PI_NETMASK_OBJ, or getType.. something or another, the pure virtual function in BM_SingleOpState. I returned "MSS" I realized this was not correct, but I would have no idea what the OBJ analogue of MSS what be called, or even if its actually using it that way, which didn't seem likely. However I'm hopefully ~two weeks from having a working version of the API and the prototyped plug in, so I'm likely going to wait on this. Probably until I attempt to create python binding for the code that defines the event loops, so I could create tool states directly in Houdini with Python, but still have it run native code. Yup, I pretty much only use the doxygen pages for searching now, it sounds like I may need to reopen some older issues. Thank you for your help, I really appreciate it redrawScene() was exactly what I needed for the rendering, it's mentioned like six times in my code too, silly, silly. Edited July 20, 2015 by captain Quote Link to comment Share on other sites More sharing options...
edward Posted July 20, 2015 Share Posted July 20, 2015 Did you name your state the same as your object type's name? I believe that's how the default behaviour of matchesNode() works. You should override it and make sure that it's being called and that the base class is returning what you want/expect. As for the getChosenOp() virtual, here's a sample implementation: OP_Node * MyObjState::getChosenOp() const { OP_Network *network = (OP_Network*)viewer().getNetwork(); OP_Node *node = NULL; UT_ASSERT(network->getChildTypeID() == OBJ_OPTYPE_ID); if (network) node = network->getCurrentNodePtr(); // If we don't have a current node pointer for this network, then fall back // on the last selected object. if (!node) { node = OPgetDirector()->getLastPickedNode(); if (node && node->getOpTypeID() != OBJ_OPTYPE_ID) node = NULL; } return node; } Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) Sorry, I was referring to virtual const char *getPresetTypeName() const { return "MSS"; } Which is a pure virtual in BM_ParmState. And yes your right, I didn't have the class itself named the same, I forgot about that, however ::myConstructor did return the name of the Node I want to attach to, and with SOP nodes I never had an issue. The OBJ code may have enforce this where the SOP didn't. The OBJ state code did attach though, perhaps some where, some one is rejecting me before the mouseEvent gets called because the name wasn't set right. I'm going to try this now. Edited July 20, 2015 by captain Quote Link to comment Share on other sites More sharing options...
edward Posted July 20, 2015 Share Posted July 20, 2015 The class name is irrelevant, I meant the name when you create your PI_StateTemplate. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) Oh yes, that was correct, or it couldn't attach. It just wouldn't call handleMouseEvent, everything else appeared to be working. Or handleKeyEvent, doRender() etc.. I think I implemented getChoosenOp incorrectly. That sounds promising. Edited July 20, 2015 by captain Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) In your implementation of getChoosenOp where is "viewer()" coming from? I think I would have to implement that myself. I'm not sure about the differences with BM_OpView and JEDI_View neither seem to be documented. Will it convert implicitly? Apparently not. Well this works now Thank you very much for your time Edited July 20, 2015 by captain Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 20, 2015 Author Share Posted July 20, 2015 (edited) Okay wait hang on a second here, this is a bit above my pay grade, but BM_OpView isn't exposed to me so/and I can't include it or compile any usage of it. But without it, it looks like I have no access to what I assume is some pretty important data inside. I would assume that's where I could get the view port camera matrices? But I should be able to get them through some other means? Outside of OP_Director I wouldn't know where to look, and I didn't see it there. Edited July 20, 2015 by captain Quote Link to comment Share on other sites More sharing options...
edward Posted July 21, 2015 Share Posted July 21, 2015 Hmm ... In that case, you could try skipping that part and just use getLastPickedNode() and/or getLastPickedNode()->getParent(). It'll probably work most of the time. Another hacky workaround might be to override BM_State::handleOpNetChange() and/or handleOpNetClear() to see if you can catch which network is being used. Make sure you also delegate to the base class. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 21, 2015 Author Share Posted July 21, 2015 (edited) Just getting the network isn't too bad, I already found an okay work around for that. But in order to do integrate this with my code, I need the camera matrices, so I can project my cursor into the scene, mapToWorld is an MSS function. Maybe I'm just missing it but outside of the HOM lib, I don't see them anywhere. It looks to me that getting the active view port "camera" is not exposed to the HDK in any way, that being said, I don't believe my profile picture could be any more apt then it is right now. Edited July 21, 2015 by captain Quote Link to comment Share on other sites More sharing options...
edward Posted July 21, 2015 Share Posted July 21, 2015 I wonder if you can just create a dummy MSS_SingleOpBaseState member in your constructor to use. Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted July 21, 2015 Author Share Posted July 21, 2015 (edited) Yeah, I had been kinda thinking the same thing, but I was planning on sticking with MSS_SingleOpState for a bit. It kinda seemed like it wouldn't work, but i guess as long as the PI_State_Template gets empty string arguments there shouldn't be a problem, maybe. Nevermind, as long as I don't register it, it makes no difference. But actually that would be ideal, I get the all the MSS functionality but I'm no longer bound to it. I'm going to see if I can get it to construct. Edited July 21, 2015 by captain Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.