Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

viewport functionality - feature request to allow it to be programmatically set [$5] #293

Closed
davidbuzz opened this Issue · 25 comments

8 participants

@davidbuzz

the object/s I work with are large/huge/enormous as compared to the normal OpenSCAD default view, and every time I open a file, I see nothing until I "zoom out" to a "distance" of approx 10000 or more.

I see some old discussion about this at : #16 and at http://rocklinux.net/pipermail/openscad/2011-July/001225.html but there doesn't seem to be any resolution to the issue ( despite being closed ) , and none of the 3 set/s of patches discussed on the mailinglist appear to have been included.

Additionally, the animation code would greatly benefit from being able to "move the camera" during animation/s with this viewport code.

Did you help close this issue? Go claim the $5 bounty on Bountysource.

@kintel
Owner

Don (who initially suggested those patches) recently cleaned up the viewport code in #288, so perhaps this is a good time to revisit this issue as well. See comments in #288 for some ideas about viewport control.

Also, when using the new png output from the cmd-line, the default viewport is set to show the entire model. Could you try that and see if that works for you, just as a general sanity-check? (the latest Mac development snapshot includes this functionality)

@davidbuzz

Sorry, I can't test latest mac development snapshot on the command line, as it errors. see #294

@davidbuzz

I just tried the latest git code, and ( after re-running dependancies script, and doing a 'make distclean' ) I got this error output from "make":

/usr/local/Cellar/qt/4.8.4/bin/uic src/MainWindow.ui -o objects/ui_MainWindow.h
/usr/local/Cellar/qt/4.8.4/bin/uic src/Preferences.ui -o objects/ui_Preferences.h
/usr/local/Cellar/qt/4.8.4/bin/uic src/OpenCSGWarningDialog.ui -o objects/ui_OpenCSGWarningDialog.h
/usr/local/Cellar/qt/4.8.4/bin/uic src/AboutDialog.ui -o objects/ui_AboutDialog.h
/usr/local/Cellar/qt/4.8.4/bin/uic src/ProgressWidget.ui -o objects/ui_ProgressWidget.h
clang -c -pipe -O2 -arch x86_64 -Wall -W -DOPENSCAD_VERSION=2013.03.08 -DOPENSCAD_YEAR=2013.0 -DOPENSCAD_MONTH=03.0 -DOPENSCAD_DAY=08.0 -DDEBUG -DENABLE_MDI -DUSE_PROGRESSWIDGET -DENABLE_CGAL -DENABLE_OPENCSG -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Cellar/qt/4.8.4/mkspecs/unsupported/macx-clang -I. -I/usr/local/Cellar/qt/4.8.4/lib/QtCore.framework/Versions/4/Headers -I/opt/local/include/eigen2 -I/usr/local/Cellar/qt/4.8.4/lib/QtCore.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.4/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.4/lib/QtGui.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.4/lib/QtOpenGL.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.4/lib/QtOpenGL.framework/Versions/4/Headers -I/usr/local/Cellar/qt/4.8.4/include -Isrc -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -Iobjects -Iobjects -I/opt/local/include -F/usr/local/Cellar/qt/4.8.4/lib src/OffscreenContextCGL.mm -o objects/OffscreenContextCGL.o
In file included from src/OffscreenContextCGL.mm:1:
In file included from src/OffscreenContext.h:11:
In file included from src/fbo.h:4:
src/system-gl.h:4:10: fatal error: 'GL/glew.h' file not found
#include
^
1 error generated.
make: *** [objects/OffscreenContextCGL.o] Error 1

@kintel
Owner

It looks like you didn't set the correct environment variables to point the build system to the libraries you built. See README.md "### Building for Mac OS X".
The giveaway is the -I/opt/local/include - it's trying to use the MacPorts version of the dependencies instead of the ones you built (we default to using MacPorts if no custom libraries are provided).

@donbright
Collaborator

what if we make it so that every time the user opens a file, it zooms to show the entire object?

@kintel
Owner

That sounds like a good idea.
Note: make sure it isn't reset when doing reload&compile or auto-reload.

@davidbuzz

executing "latest mac development snapshot on the command line" worked.

my command: /Applications/OpenSCAD-2013-03-06-dev.app/Contents/MacOS/OpenSCAD --render -o ~/Documents/reprap_uav/out.png ~/Documents/reprap_uav/parts.scad

it output a PNG with an appropriate zoom level ( attached, if you are interested )
out

I like the "every time the user opens a file, it zooms to show the entire object? " option, it's a good start. ( it would be nice to have a user control for it, but I'll take what I can get ) .

@dirkse

Is there a command I could type to do the viewport setting?

@kintel
Owner
$ ./OpenSCAD.app/Contents/MacOS/OpenSCAD -h
Usage: ./OpenSCAD.app/Contents/MacOS/OpenSCAD [ -o output_file [ -d deps_file ] ]\
                                              [ -m make_command ] [ -D var=val [..] ] [ --render ] \
                                              [ --camera=translatex,y,z,rotx,y,z,dist | \
                                                --camera=eyex,y,z,centerx,y,z ] \
                                              [ --imgsize=width,height ] [ --projection=(o)rtho|(p)ersp] \
                                              filename
@dirkse

Thanks, I found the command View Centre, that brings back the viewport to 0,0,0. Working with a stubborn mouse made me lose my rendering outside of the viewport, and if you cannot see it it is doubly difficult to bring it back.

Custom views from the menu would be nice to have.

@kintel
Owner

I agree - it would be nice to be able to specify one or more viewpoints in the .scad file and make them accessible from the GUI (as well as from the cmd-line).

@TakeItAndRun
@kintel
Owner
@tbuser
@donbright
Collaborator
@tbuser
@donbright
Collaborator

no, as noted above auto zoom is requested feature....

Marius already wrote code to do this for the test png programs, someone just needs to add the elbow grease to move it to the normal program.

@davidbuzz davidbuzz changed the title from viewport functionality - feature request to allow it to be programmatically set to viewport functionality - feature request to allow it to be programmatically set [$5]
@davidbuzz davidbuzz added the Bounty label
@t-paul
Owner

Implemented in current master:

  • ViewAll for both GUI and Command Line (not available from scad script).
  • $vpt, $vpr and $vpd are writable on script top-level to set translation, rotation and distance.
@t-paul t-paul closed this
@MichaelAtOz

ViewAll - is that center and auto zoom?

Why only "writable on script top-level"?
I can see animation where setting these in a module would be handy.

@t-paul
Owner

I think ViewAll is currently really only auto-zoom, which probably is the reason for #854. So it may need some adjustments.

Only writable at top-level because
a) it's much easier to get the values from a specific level :)
b) you can't have multiple values anyway so overwriting inside modules would be a problem. restricting to top-level limits automatically to a single value.

@MichaelAtOz

Using 2014.06.27, the $vpd is not working, it is being written to as it is echoed with the updated value, but the screen image does not change. The distance reported in the status bar, is constant (changes if you manually zoom).

Try the following with animation on. (1 FPS & 10 steps is good)

echo(version=version());
module difference_cube()
{

    difference() {
        cube(30, center = true);
        sphere(20);
    }
}
$vpt=[10*$t,10*$t,10*$t];
$vpr=[90*$t,90*$t,90*$t];
d=130;
$vpd=20+d*$t;
echo(d=d,"$vpr=",$vpr,"$vpd=",$vpd,"$vpt=",$vpt);
difference_cube();

(based on examples/difference_cube)

@MichaelAtOz

Correction. Details to follow.

@MichaelAtOz

The above code gets "WARNING: Ignoring unknown variable 'd'."
Even though d and the modified $vpd are both echo()'ed, it doesn't change the viewport.
Change it to $vpd=20+130*$t; and it works.
Suggests it is a scope issue. I would expect the original code to work.

@MichaelAtOz

Same scope issue affects $vpt & $vpr too. ie

t=10;
$vpt=[t*$t,t*$t,t*$t];
r=90;
$vpr=[r*$t,r*$t,r*$t];
d=130;
$vpd=20+d*$t;
echo(d=d,"$vpr=",$vpr,"$vpd=",$vpd,"$vpt=",$vpt);
@t-paul
Owner

Scoping issues should be fixed with #856. There seems to be still an issue with the orthogonal camera.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.