It looks like you're new here. If you want to get involved, click one of these buttons!
When you initialize an OrbitViewer you can tell it what position to orbit, and the allowable range of distance from that position, and the starting distance from that position.
But can you tell it where to position itself to start the scene?
For example say I have a plane like the ground in the Learn Craft project, and I want to use an OrbitViewer in the scene, but I want the camera to start the scene at a position high above the plane, looking down on it.
Can that be done?
No matter how I define its position beforehand, in setup or in parameters or what have you, OrbitViewer seems to always set itself back to 0,0,0 when a scene starts.
Comments
@UberGoober
Try looking at this:
dave1707 physics demo
from @dave1707 demo
@Bri_G I may be missing something but it seems as if you thought I was asking how to use the OrbitViewer at all, which I wasn't.
Unless I'm missing it, that project does not set a custom location for the OrbitViewer, it just uses it in its default position.
Maybe I stated my problem unclearly, I will try to edit it to phrase it more clearly.
Try setting ‘viewer.rx’ and ‘viewer.ry’. These control the viewer rotation which is used to place it as well.
@UberGoober,
My bad, did kinda miss the point. Only other place might help is in one of the demos supplied -
Which looks like the centre point of any model, but that’s not to say it’s working properly. Have you tried using this approach?
@Bri_G I agree that's the natural place to start experimenting. I wasn't able to get anywhere with it.
@John here’s what I’ve tried, which should be correct:
It moves the viewer, but not to the right place.
Here’s what I want:
Can you suggest how I get the viewer at that location and direction?
As for positioning I can think of a kludge where I set the center of the orbit viewer to be an invisible entity that's exactly where I want the viewer, and then set all of the proximity values to 0...
But then I have to change it once the scene starts, is that possible?
@Bri_G , @John:
reporting from the field:
Years later I’ve figured this out.
Where
targetPosition
is a vec3 location for the OrbitViewer to point at.The startZoom, minZoom, and maxZoom numbers at the end of the
camera:add
command can of course be customized too.Not to beat a dead horse here, but I spent so much time struggling with this that I hope I can help someone else get a handle on it as fast possible.
To which end I'm attaching a project that demonstrates how to do this. Position the camera anywhere you like, then tap the “save position” button and exit. When you restart, the camera will be in the same position as it was when you quit.
@UberGoober The saveprojecttab causes an error.
@UberGoober Apparently you have to import the zip file into Codea for it to work. If you unzip the file in the Files app and run the program from there, you get the above error.
That makes sense.