Get mouse x,y,z location other an with an Inputpoint?
-
@chris fullmer said:
I'll play with ray casting. I'll have to read over your ray casting thread and the workaround to see if I can get it to work at all.
Don't bother with the workaround - it's broken. Test in SU7 and wait for SU8 to be updated.
-
Chris...
try holding ALT while you point it around... the querry tool. see if that stops it from jumping.
-
@chris fullmer said:
Currently I am just ignoring the IP if it is not on a face. But that means that there are times when the user clicks and nothing happens. So it is just a little weird. But I can get over it if it is the best way to get a point3d object.
PickHelper.picked_face
would be what you want then - and then the pickray to get the 3d co-ordinate. -
@Kris - hmm, holding alt seems to do nothing on my computer in the query tool. Does it change the behavior for you I'm guessing?
-
well if you click alt while you're mousing around it will stick a little purple vertex mark in place where you were and the xyz location will hold.
-
What it looks like is happening to me is that when you hit alt, it is going into the menu system - "File" is highlighted. Once the menu system is activated, the dot stays in place until alt is pressed again getting out of the menu system. I also see this behavior with the native tools like the line tool. At least that is what I'm seeing.
-
Yea - Alt is Window' global hotkey to activate the menubar of the active window.
-
yes it is... but it also has the move on to extra plane and allow new faces to be created function. when I hit alt while querrying it hold the purple marker where ever I leave it and stays at a specific two coords. since one coord is already known I took it.
-
@krisidious said:
yes it is... but it also has the move on to extra plane and allow new faces to be created function. when I hit alt while querrying it hold the purple marker where ever I leave it and stays at a specific two coords. since one coord is already known I took it.
That is not a design by the tool - it's a side-effect from Windows sending the focus to the menubar. Don't think it behaves like this on OSX.
-
It is a cool side effect, but it is not quite what I am looking for though anyhow. Because the query tool is still snapping to edges more than I wish it was. I'll just implement the InputPoint 3d position method, and wait until they hopefully fix the pickray for version8. Thank guys,
Chris
-
@thomthom said:
But, yes, you can shoot a ray:
` ray = view.pickray(x, y)
result = model.ray_test( ray )TODO: Recast on hidden entities`
I have been using this method quite successfully but it does not work well if there is an 'out-of-context' face between the camera and the user's mouse position. This is even more of a problem if the user has 'Component Edit->Hide Rest of Model' The new raytest flag in SU8 that is supposed to ignore hidden geometry is not effective in this case. IMO it should also work for this situation.
-
Could you test if the hit entity is in the current context, and just ignore it if it is not? That seems like it might be a solid workaround? Though I suppose that might be overkill because in many cases the user will not have 'Hide Rest of Model' turned on. So in those cases, you might want the user to be able to pick points outside the current context....hhmmmm.
-
@chris fullmer said:
I have not looked too much into this yet, but is there a way to get the 3d position of the cursor other than using an inputpoint? I was wondering if casting a ray would work. Does that return a point3d object? If I go that route, do I need to sort through what objects are or are not hidden/visible? Also, if it matters, I am only concerned about 3d points on a face. So if the mouse is hovering over nothing, I do not need to determine a 3d point for that. Just returning "nil" in that scenario is fine.
Chris,
I typically use a combination of
InputPoint
, to get the (x, y) in 2D and the face, and thenview.Pickray
to intersect with the face and find the 3D point.This is more or less what I have used in FreeHand On Surface, in particular to get rid of the inferences.
Fredo
-
@chris fullmer said:
... Though I suppose that might be overkill because in many cases the user will not have 'Hide Rest of Model' turned on.
You can test that thru the
RenderingOptions
hash'sInactiveHidden
andInstanceHidden
attributes.<span class="syntaxdefault">if Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">rendering_options</span><span class="syntaxkeyword">[</span><span class="syntaxstring">'InactiveHidden'</span><span class="syntaxkeyword">]<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment"># do it this way<br /></span><span class="syntaxkeyword">else<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment"># do it that way<br /></span><span class="syntaxdefault">end</span>
-
Well there you have it! Glad you can test if they have Hide Rest of Model on or off. I had my doubts about truly being able to come up with a flawless solution to get 3dpoints from the cursor while ignoring inferencing, but this thread seems to indicate that its possible. I'll have to re-write my app I was making while I started this thread, because it currently just ignores the mouseclick anytime it gets inferred onto an edge. Very good, my little plugin might finally be useful
Chris
-
@chris fullmer said:
Well there you have it! Glad you can test if they have Hide Rest of Model on or off.
Just be aware that Scene (Pages) can also have their own
RendingOptions
hash instance.
Advertisement