Hello,
Does anyone have any advice about zooming in on the arcball while already in the scene? I don't want to just change the perspective, I want the user to be able to zoom in and out of the current scene.
Thanks!
You can follow this pattern for both scale and translate. The arcball holds some state information, so you don't want to destroy it and recreate it. I made two sliders, one outside of the arcball and one inside. The outer one scales the arcball, the inner just the arcball's content. (Modified from the HelloWorld sample script.)
// Show some text in an ArcBall Names Default To Here( 1 ); // this tiny list is rebuilt when the inside slider moves scaleinside=1; scaleinsideList = scenedisplaylist(); scaleinsideList<<scale(scaleinside,scaleinside,scaleinside); greeting = Scene Display List(); // place the call to the inside list inside the arcball greeting<<calllist(scaleinsideList); greeting << color( .9, .9, .9 ); // .1,.1,.1 = almost black .9,.9,.9 = almost white greeting << Text( center, middle, .3, "Hello 3D World" ); // this tiny list is rebuilt when the outside slider moves scaleoutside=1; scaleoutsideList = scenedisplaylist(); scaleoutsideList<<scale(scaleoutside,scaleoutside,scaleoutside); // this is the main list, built one time Scene = Scene Box( 600, 600 ); Scene << backgroundcolor( 0 ); // black=0, gray=1, white=2 Scene << showarcball( always ); Scene << perspective( 45, .2, 20 ); Scene << Translate( 0.0, 0.0, -4.5 ); //by placing this call before the arcball, it scales the arcball too scene<<calllist(scaleoutsideList); Scene << arcball( greeting, 1.5 ); Scene << update; // the window contains a 3D display and two sliders New Window( "x", Scene// ,// sliderbox(.5,2,scaleinside, scaleinsideList<<clear; scaleinsideList<<scale(scaleinside,scaleinside,scaleinside); Scene << update; )// ,// sliderbox(.5,2,scaleoutside, scaleoutsideList<<clear; scaleoutsideList<<scale(scaleoutside,scaleoutside,scaleoutside); Scene << update; ) ; );
The script is organized so only the least part of the script needs to be rebuilt by the slider callbacks.