Move a Parallel Camera
-
Does appending a call to view.refresh (at the end of the code,) have any effect ??
-
No, no difference.
I did notice that when I switch back to a Perspective Camera, the camera jumps way back.
-
OK.. and what happens when you switch back to Parallel ?
-
A few other questions:
Do these have any effect?
view.invalidate()
view.dynamic=true
-
Neither has nay effect.
-
Maybe change to perspective mode, then move, then jump back to parallel? Or do that on a camera that is not active_view and then apply that camera to the active view?
-
Yep, thanks. I can make something work. I guess at this point I am curious to understand what's going on.
-
-
Solved.
This code works no matter what mode the camera is in, AND resets the mode back to the previous mode. (See ### bracketed statements that I added.)
zoomtest.rb
<span class="syntaxdefault"></span><span class="syntaxcomment">#<br /><br /></span><span class="syntaxdefault">module SU_Test<br /><br /> </span><span class="syntaxcomment">#<br /><br /></span><span class="syntaxdefault"> def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">zoomtest</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> factor </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0.5<br /> model </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_model<br /> view </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> model</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">active_view<br /> c </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> view</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">camera<br /> </span><span class="syntaxcomment">###<br /></span><span class="syntaxdefault"> cp</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">c</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">perspective</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">###<br /></span><span class="syntaxdefault"> t </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> c</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">target<br /> e </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> c</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">eye<br /> up </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> c</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">up<br /> vec </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> t </span><span class="syntaxkeyword">-</span><span class="syntaxdefault"> e<br /> vec</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> vec</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">*</span><span class="syntaxdefault"> factor<br /> </span><span class="syntaxcomment">###<br /></span><span class="syntaxdefault"> c</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">perspective</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">true if cp</span><span class="syntaxkeyword">==</span><span class="syntaxdefault">false<br /> </span><span class="syntaxcomment">###<br /></span><span class="syntaxdefault"> c</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">set</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">vec</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> t</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> up</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">###<br /></span><span class="syntaxdefault"> c</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">perspective</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">false if cp</span><span class="syntaxkeyword">==</span><span class="syntaxdefault">false<br /> </span><span class="syntaxcomment">###<br /></span><span class="syntaxdefault"> end<br /><br /> unless defined</span><span class="syntaxkeyword">?(@</span><span class="syntaxdefault">LoadedOnce</span><span class="syntaxkeyword">)==</span><span class="syntaxstring">'instance-variable'<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">LoadedOnce</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">false<br /> end<br /><br /> def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">loaded_once</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">LoadedOnce<br /> end<br /> <br /> def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">loaded_once</span><span class="syntaxkeyword">=(</span><span class="syntaxdefault">arg</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@</span><span class="syntaxdefault">LoadedOnce</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">arg<br /> end<br /><br />end </span><span class="syntaxcomment"># module<br /><br /></span><span class="syntaxdefault"> unless SU_Test</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">loaded_once</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">menu</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'Plugins'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">add_item</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'Zoom Out Test'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> SU_Test</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">zoomtest</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> SU_Test</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">loaded_once</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">true<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end<br /></span>
-
You need to use camera.height in parallel mode.
-
Advertisement