Reverse operation of view.screen_coords
28 posts
• Page 1 of 1
Reverse operation of view.screen_coordsHow do you get 3-dimensional points @ each view.corners? Like an opposite method of view.screen_coords.
I am trying to automatically pan one screen at a time in x or y direction while in top view of a model (sort of like microfiche machine used to read newspaper articles in olden days!!!). I figure adjusting camera eye and target position by model width/height displayed on screen should accomplish this; but I can't seemed to find the method to do this. Is this possible? Sincerely, John
Re: Reverse operation of view.screen_coordsIf you get the view.camera, get its .eye and .target and change these points 'in tandem', then apply them to a new/updated camera etc then the view should 'pan'...
[I put that very simplistically but you ought to get the idea] So with eye.x=eye.x+10 and target.x=target.x+10 ... it should pan the camera by 10 to the right etc... TIG
Re: Reverse operation of view.screen_coords
? But, may I ask why you want to perform such pan? Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coords
He's trying to figure out how much he has to move the camera in order for it to shift by the size of the viewport. Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coords
Doesn't that risk it snapping to nearby geometry? That's why I was thinking a raytest would be safest as it would not be affected by inference. Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsHe can specify the view's inputpoint by using screen-coordinates (x,y) ?
And then get the inputpoint's position as a 3dPoint ?? That way he can get the screen width as with y at 0, and x at 0 and screen-width, gives two points - he can get the distance between them, then that's the amount to shunt the camera's eye/target across to pan a whole screen in the x-direction ? TIG
Re: Reverse operation of view.screen_coordsThis 'proof of concept' pans the whole screen to the right [in plan is easiest to see...]
TIG
Re: Reverse operation of view.screen_coords
But my concern was that InputPoint will return a 3D point affected by inference, ie it snaps to mid points or something, based onthe 2D point. Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsI see the point.
Here's a fuller version that avoids that [can you think of a better way?]
TIG
Re: Reverse operation of view.screen_coords
viewtopic.php?f=180&t=44290#p394956 Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsTherefore we can substitute
p0=view.pickray(0,0)[0] p1=view.pickray(view.vpwidth,0)[0] and get a simpler method because the ray's point doesn't get influenced by inferences and is made on the picture-plane, as it were...
TIG
Re: Reverse operation of view.screen_coordsAh, yes! Of course - no need to pick anything. I forgot that the ray contained a point that could be used directly.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsTwo brains are better than one [at least our combined IQs add up to around the average!!]
TIG
Re: Reverse operation of view.screen_coordsI've already determined that my brain is on timeshare lease...
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsTIG and thomthom,
Do you guys ever sleep!!?? You gave me a plenty of assignment for the weekend; to digest all that you posted. For your info, I am attempting to model a 'plan viewer' for blueprints which will become framework for architectural components Thanks guys John
Re: Reverse operation of view.screen_coords"Sl-eep"..?
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsJust finished reading up on view.pickray method and ran TIG's sample code. At first glance it should have worked but does not. In executing each line, I find that p0 and p1 return same value as camera eye position. See Ruby Console responses below:
p0=view.pickray(0,0)[0] Point3d(3255.11, 1479.16, 8761.61) p1=view.pickray(view.vpwidth,0)[0] Point3d(3255.11, 1479.16, 8761.61) p2=view.pickray(0,view.vpheight)[0] Point3d(3255.11, 1479.16, 8761.61) p3=view.pickray(view.vpwidth,view.vpheight)[0] Point3d(3255.11, 1479.16, 8761.61) cam=Sketchup.active_model.active_view.camera #<Sketchup::Camera:0x7ce5de0> cam.eye Point3d(3255.11, 1479.16, 8761.61) cam.target Point3d(3255.11, 1479.16, 127.281) cam.up Vector3d(0, 1, 0) How could this be? I thought I understood pickray method but NOT Off the topic note: where can I find instruction on how to annotate posting w/ codes, images, smiles, etc ... John
Re: Reverse operation of view.screen_coordsI added some 'ruby' tags to make it clearer...
I hope this is not ALL of the code... Have you set the view and so on earlier ? IF so... you don't use cam=Sketchup.active_model.active_view.camera but cam=view.camera ??? My code is a working example....... TIG
Re: Reverse operation of view.screen_coords
There is a "hard to find" link on each message "POST A REPLY" page, in the right column, beneath the "Smilies" list. Notice how the line "BBCode is ON" has a link ?? It leads you to a user guide for the code tags. Most of these usable tags have toolbar button "inserters" already set up for you to use. You just click the button, it inserts the tag. and positions the cursor between the tags so you can type text (or paste text,) into them.
Re: Reverse operation of view.screen_coords
Now I'm enlightened Thanks Dan
No this is an output of individual Ruby Console execution. This is my attempt to debug each line of your sample code to check each variable's current value. Programming is my hobby and I just picked up Sketchup and Ruby couple of months ago so I have a lot to learn. Back to pickray method - All screen postions (ie p0, p1, p2, and p3) return different value yet pickray method of these points return identical 3D point as camera eye position but with different vector. How come? John
Re: Reverse operation of view.screen_coordseh.. TIG, I think we both did a brain-fart. We have to do a raytest - otherwise the ray will return a point which is based on the camera eye... because all pickray origin from the camera eye.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsThough, at 2:30 it's hard to process these thigns...
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
Re: Reverse operation of view.screen_coordsHere's a much better version that uses planes, lines, vectors, and takes arguments to change panning from right/left and up/down etc - allowing a toolbar button set to be easily made...
TIG
Re: Reverse operation of view.screen_coordsTIG,
It works great and I actually understood your program steps. Now I need to dig into reference material to create tool bars. Thanks for your help John
Re: Reverse operation of view.screen_coordsInsert this whole block of code inside the mIN 'module' near the beginning - between
module TIG and def self.screenpan(direction=1) Then put the whole of the code in a file called 'TIG-screenpan.rb' in the Plugins folder and restart... Put your buttons icon .PNG files inside a subfolder in Plugins called 'TIG-screenpan'. Name then as shown, for small/large icons, for each of the 4 buttons, 8 PNGs in all... This is the menu code...
TIG
Re: Reverse operation of view.screen_coordsTIG
Once again, I thank you for your generous assistance With 1 minor correction, this is working as intended.
Changed add_item to add_submenu This is the only line of code I did not fully understand
I know this is to make sure the plugin load once, but can you explain 'basename(__FILE__)'? Moving onto to my next challenge, what method do I need to look at in order to display an area of image whose vertices are known (sort of like zoom window without maually selecting zoom area) John
Re: Reverse operation of view.screen_coordsAgain.... untested stupid typo !
Sorry! add_item adds a command directly to that menu sub=...add_submenu adds a 'submenu' to that menu, in which you can then use add_item... I changed original in case others copy it... The system variable __FILE__ gives the full-path of each loading .rb script [fails if compiled as a .rbs!]. There are many 'File' methods, so if it is say 'C:/Program Files/Google/Google SketchUp 8/Plugins/xxx.rb' File.basename(__FILE__) >>> 'xxx.rb' and also File.basename(__FILE__, '.*') >>> 'xxx' File.extname(__FILE__) >>> '.rb' File.dirname(__FILE__) >>> 'C:/Program Files/Google/Google SketchUp 8/Plugins' etc etc... Of course you can use it with and string that is a 'file-path' - like you'd get from an 'open' dialog etc... I'll sleep on your last question... TIG
28 posts
• Page 1 of 1
|