Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to get Pixel Coordinates of Spline point on 2D render canvas?

    General Talk
    3
    5
    906
    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.
    • constantine_sazonovC
      constantine_sazonov
      last edited by

      Hi everyone,

      • Let's say I have a render settings at 1920x1080.
      • In front of a camera there is a spline rectangle shape.
      • It has 4 points.

      Is there a way to get pixel coordinates of those points on 2D canvas?

      In the end I wanted to get a list of pixel coordinates for those 4 points, that will represent where those points will be located on final render.

      I tried to find corresponding function in API Doc, but no luck unfortunately.

      Would be awesome to know the answer!
      Have a great day everyone!

      pixel-coordinates-of-points.png

      C4DSC ferdinandF 2 Replies Last reply Reply Quote 0
      • C4DSC
        C4DS @constantine_sazonov
        last edited by C4DS

        @constantine_sazonov
        You will want to use

         BaseView.WS(self, p)
        

        Converts p from world space to screen space (pixels relative to the view)

        Or maybe better: Camera to screen conversion

        BaseView.CS(self, p, z_inverse)
        
        constantine_sazonovC 1 Reply Last reply Reply Quote 0
        • constantine_sazonovC
          constantine_sazonov @C4DS
          last edited by

          @c4ds Oh, wow, thank you so much!

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @constantine_sazonov
            last edited by ferdinand

            Hello @constantine_sazonov,

            thank you for reaching out to us. And thank you again @C4DS for providing an answer. The conversion methods to convert between different coordinate systems are attached to c4d.BaseView as demonstrated by @C4DS. Depending on the concrete implementation, you might have to take care of safe frames though, since screen space does not imply them, but is simply all visible area of the view, i.e., the view frame.

            There has been this topic in the past which was similar in nature where I also did provide some code.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            constantine_sazonovC 1 Reply Last reply Reply Quote 0
            • constantine_sazonovC
              constantine_sazonov @ferdinand
              last edited by

              @ferdinand Thank you very much for the info!

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