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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Target expression with up vector

    Scheduled Pinned Locked Moved SDK Help
    3 Posts 0 Posters 291 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

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 09/12/2011 at 16:23, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   12 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :   C.O.F.F.E.E  ;    PYTHON  ;

      ---------
      From the Target node in Xpresso, I got the target expression.
      But I would like to know if there is any expression that would return the rotation of the object to make it point to a target and also consider an upvector, just like the Target tag has.
      Also, is there any such thing already in the python SDK? I searched by "target" and "upvector" and I got no results 😞

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 13/12/2011 at 08:57, xxxxxxxx wrote:

        I could figure out how to make a Target expression in python:

        vec3=(pos2-pos1).GetNormalized()
        vec2=vec3.Cross(c4d.Vector(0,1,0)).GetNormalized()
        vec1=vec3.Cross(c4d.Vector(1,0,0)).GetNormalized()
        new_mx=c4d.Matrix(pos1,vec1,vec2,vec3)

        But, how could I make it also respond to an up vector?
        I mean, I have the matrix applied to point pos1 , with its Z axis pointing to point pos2.
        How could I make its Y axis, for example, also point in the general direction of a third point, pos3 ?

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 14/12/2011 at 07:02, xxxxxxxx wrote:

          Howdy,

          You'd do the same thing to get a vector to pos3 as you did to get a vector to pos2. This would only be a temporary vector so you can use the cross product to determine vec1. Once you get vec1 you use it with vec3 to square up vec2. this will give you an affine (square) matrix.

          Remember this about matrix XYZ axes:
          xAxis = yAxis cross zAxis
          yAxis = zAxis cross xAxis
          zAxis = xAxis cross yAxis

          Adios,
          Cactus Dan

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