We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Interface object in Ortho view

Home Forums General Questions Interface object in Ortho view

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #78692
    David Duperron
    Customer

    Hi there!
    I’ve got some interface objects (a North indicator) parented to an Orthographic camera, that I want to display on the top left corner.
    I use the “fit to camera edge” feature in Blender that appears when an object is parented to a camera.
    The object is then visible in this corner, but its scale varies when zooming in or out!
    How can I keep it to a constant size??
    Thanks for the help!

    David

    #78698
    xeon
    Customer

    The indicator should be:
    1. Parented to the ortho camera
    2. Have its parent inverse cleared
    3. Then repositioned to desired location if needed

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #78699
    David Duperron
    Customer

    Thanks Xeon, I will try again, even if I think I did all this the first time… will keep you posted!

    #78709
    xeon
    Customer

    Even if you parented the object to the camera…it should stay locked to the camera regardless of zoom and movement of the camera. So it shouldn’t scale….but when you use Fit to Edge the clearing of the Clear Parent Inverse will make it behave correctly.

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #78737
    David Duperron
    Customer

    Hi Xeon,
    Tried it several times but it does not work for me… when I parent an object to an ortho camera, and use the “fit to camera” option, the object scales like the main scene when I zoom in/out, no matter what…
    With perspective cameras it works without any issue, but not with ortho cameras… would be curious to have the developpers point of view about that?? @yuri?

    #78739
    kdv
    Participant

    With perspective cameras it works without any issue

    because perspective cameras instead of zooming just move along their Y axis back an forth. on the contrary, ortho cameras are using real zooming.

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #78741
    David Duperron
    Customer

    Hi @kdv! Yes I noticed this difference. But I don’t know how to counteract the zoom effect on the object that is parented to the camera.
    I thought I could play on the scale of the object, that would be “linked” to the ortho zoom factor, but I cannot make it work…
    I guess I will have to fall back to an HTML overlay when in Ortho mode.

    #78742
    kdv
    Participant

    smth like this can do the trick

      function setObjectScale(mesh, factor) {
        if (app.camera.isOrthographicCamera)
          factor = ((app.camera.top - app.camera.bottom) / app.camera.zoom) / factor;
        else
          factor = (mesh.position.distanceTo(app.camera.position) * Math.tan(Math.PI * app.camera.fov / 360) * 2) / factor;
        mesh.scale.set(1, 1, 1).multiplyScalar(factor);
      }

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #78751
    David Duperron
    Customer

    Hi @kdv!
    Yes I did not think about this function! You’re right we are almost there. I can keep the object to a constant scale relative to the viewport with this, but the offset from the left edge (and top edge) of the window is also scaled. I need to find where I can adjust this distance… if this is possible…

    #78757
    David Duperron
    Customer

    Maybe I can play on the “offset” value of the constraint applied to the object with a modified function.

    #78765
    kdv
    Participant

    but the offset from the left edge (and top edge) of the window is also scaled

    I don’t see this happening :unsure:

    Puzzles and JS coding. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.

    #78802
    David Duperron
    Customer

    I don’t know why but my object’s offset is linked to the zoom factor of the Ortho camera…
    The good news is: I managed to couteract this effect by multiplying by the same “factor” as the object’s scale… just one more line in the function…

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.