Get 2D position in Camera Image



  • 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



  • 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



  • 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



  • 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



  • 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


Log in to reply