Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Get 2D position in Camera Image

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 421 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 16/10/2015 at 15:39, xxxxxxxx wrote:

      Hello

      I like to get the 2D Position of a Object from a Camera Picture. The Editor is not use this camera.

      I don`t get the right idea of CW and WS. And with the position I like to get the Color in a Shader of this Position like a camera mapping with single colors .

      Thanks

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 16/10/2015 at 20:42, xxxxxxxx wrote:

        I think you need to cast a ray from the required camera "pos" with a direction "specified by camera Z vector with an offset to the required pixel"

        search in the Python documentation about c4d.utils.GeRayCollider

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 19/10/2015 at 02:29, xxxxxxxx wrote:

          Hello,

          you have to differentiate between object space, world space, camera space and screen space. A BaseView represents a editor view. So if you use your camera to define that view, it uses the camera's setting to build its projection matrix. Then you can use BaseView.WS() to transform coordinates from world space to screen space. With that screen space coordinates you could build a set of UV coordinates to sample your shader.

          It seems that there is no function to get the projection matrix of an arbitrary camera so you have to use your camera as the active camera to work with BaseView.

          Best wishes,
          Sebastian

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 19/10/2015 at 09:31, xxxxxxxx wrote:

            Hey Sebastian,

            that would be a great function to calculate that - or ?

            have you an idea for a workaround ? - The way with GeRayCollider sound a bit wired for me

            Thanks

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 20/10/2015 at 01:58, xxxxxxxx wrote:

              Hello,

              the only solution that comes to mind would be to take an existing BaseDraw and re-initialize it with your camera settings with InitView(). Then you could use WS(). But I cannot guarantee that this will always be safe.

              Best wishes,
              Sebastian

              1 Reply Last reply Reply Quote 0
              • First post
                Last post