Thanks Chris,
@chris fullmer said:
It does not entirely make sense based on the description of what you need it for.
I had a hunch that my description of how to use it to visualize where the polyline should go, based on projecting between the camera and the background/watermark, might be a little confusing. I kept getting confused just trying to visualize it enough to place guide planes to draw on.
@unknownuser said:
But you just want a tool that draws a line from the camere eye to a point you click on?
Actually, I asked for a construction line, not "a line". But a line to an existing something was a fall-back and I'll take what I can get.
Thomthom's version creates a cline
using camera.eye
for a point and camera.direction
for a vector.
At first I thought that I might be able to just change add_line
to add_cline
. My thought was that view.inputpoint(x,y).position
might be a vector because it takes screen coordinates x,y
, but a line cannot be drawn using a vector and a point as arguments, it will need two two points, so for @ip.position
to be a point, then view.inputpoint(x,y)
must return the 3D position of whatever is under the mouse at screen position x,y
.
A cline
would definitely be preferable, so I would need a function that returns an x,y
screen direction from the camera from a 3D postion returned by view.inputpoint
. Or maybe there's a method for view
that does that in one step. Thinking about it another second or two, a method of view
using x,y
makes sense, and then I would not need an object under the cursor just to throw away its z
position.
I'll look up view
methods (unless you have it at your fingertips?)
@unknownuser said:
Here is a one-liner that will do just that.
Thank you. I'll give it a try.
@unknownuser said:
I even made it use inferencing and draw the inference dots onto the screen for you.
Is that the onMouseMove
function? I don't grok the @
, is an operator or a convention or what?
@unknownuser said:
Let me know if this is not what you had in mind.
Not having tested it yet, it looks like it's getting most of the way there. It does not look like it draws a ray into empty space but rather requires something to exist under the mouse, but either I can recode that or just put in a bunch of temporary lines and use their endpoints.
@unknownuser said:
OH, and one note about the script. The line that is drawn is not visible until you shift the camera because it is shooting exactly out of the location of the camera, in the direction the camera is looking. So run the code, then lick where you want and orbit to see the line that was drawn.
The need to orbit makes lots of sense. That's where I would be using the results.
@unknownuser said:
If you need this script to be more easily accessible, I can put it into a menu.
There are examples of adding functions to menus in the Examples/*.rb
provided by Google and elsewhere. You can leave this as "an exercise for the student" unless you get inspired. If I get stuck, I'll ask. I'm sure there are lots of folks who can help with that piece.
@unknownuser said:
And remember, this is a single line of code and should be pasted into the ruby console.
I've saved it as [ruby:3qi7vzlz]Plugins/ray[/ruby:3qi7vzlz], no [ruby:3qi7vzlz].rb[/ruby:3qi7vzlz] suffix. I think I can just type "[ruby:3qi7vzlz]load ray[/ruby:3qi7vzlz]" or "[ruby:3qi7vzlz]run ray[/ruby:3qi7vzlz]" in the console. I also added line breaks and indents so I can follow it. I couldn't remember if Ruby requires semi-colons at statement/commend line ends, but I seem to recall that they are optional, Ruby being a very Tim Toady (TIMTOWTDI) kind of language, so I left them in.
If my comments above make sense to you, or anyone, and you get inspired or just feel like playing (if it's play for you) please feel free.
I probably won't be picking this up for a few days. I'm flying to Denver on Sunday (with Saturday being the day before Mother's Day, there are NO seats available) in hopes of getting to Colorado Springs before my Mother passes. She appears to have had a stroke this morning and was already not well.
Thanks again, Chris and Thomthom, and I will be checking back later.
August