Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

OrbitViewer question: you can set what it orbits, but can you set where it starts?

edited October 2017 in Questions Posts: 557

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.

Tagged:

Comments

  • Posts: 1,141

    @UberGoober
    Try looking at this:

    dave1707 physics demo

    from @dave1707 demo

  • edited October 2017 Posts: 557

    @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.

  • JohnJohn Admin Mod
    Posts: 564
    @UberGoober
    Try setting ‘viewer.rx’ and ‘viewer.ry’. These control the viewer rotation which is used to place it as well.
  • JohnJohn Admin Mod
    Posts: 564
    Oh btw these are angles in degrees
  • Posts: 1,141

    @UberGoober,

    My bad, did kinda miss the point. Only other place might help is in one of the demos supplied -


    viewer = scene.camera:add(OrbitViewer, myEntity.model.bounds.center, 30, 20, 100)

    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?

  • edited October 2017 Posts: 557

    @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:

        viewer.rx = -12.237
        viewer.ry = -22.515
        viewer.rz = 2.033
    

    It moves the viewer, but not to the right place.

    Here’s what I want:

        myScene.camera.position = vec3(41.482,-7.358,-0.811)
        myScene.camera.eulerAngles = vec3(-12.237,-22.515, -0.0)
    

    Can you suggest how I get the viewer at that location and direction?

  • edited October 2017 Posts: 557
    @John how do I convert degrees to Euler angles?

    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:

    • The kludge works. Define an invisible entity and initialize the viewer at 0 distance from it, and presto, viewer is in custom position.
    • Note: I actually had to define it as 0.05 from it with minimum distance at 0.005, or else the viewer would not zoom.
    • viewer.rx and viewer.ry seem to work as expected in this situation--meaning they work exactly like eulerAngles. Whatever values they are set to will become the main camera entity's eulerAngles.
    • You cannot apparently change a viewer's center on the fly, so whatever starting position you set, you're stuck with
    • If you replace the viewer with a different viewer, the camera's position resets. So unless that's the effect you want, you're still stuck with whatever position you start with.
Sign In or Register to comment.