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

    Get UV of point in triangle with UVW and bary

    SDK Help
    0
    2
    235
    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
      Helper
      last edited by

      On 27/06/2013 at 16:57, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R13+ 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      This is driving me crazy.  Google isn't getting me results based on my inputs.

      A ray hits a triangle in a mesh.  My code gets the UVW coordinates for each point of the triangle in question from the UVWTag and UVWStruct (using the GeRayColResult.face_id).  I have the Barycentric coordinates of the hit point relative to the triangle from GeRayCollider/GeRayColResult.  How do I go about interpolating to the UVW coordinate in UVW space (not triangle space, i.e.: not barycentric) of the hit point given the triangle's three UVW coordinates and the hit point's Barycentric coordinate?

      To add, I have these two options (the only two so far) :

      // GetUVFromBarycentric  
      // - Given the Texture vertices of a triangle (UVW space) and the Barycentric coordinate of a point (P) within, return P's Texture coordinate  
      //*---------------------------------------------------------------------------*  
      Vector GetUVFromBarycentric(const Vector& vAUV, const Vector& vBUV, const Vector& vCUV, const Vector& vPBary)  
      //*---------------------------------------------------------------------------*  
      {  
        return    vAUV*vPBary.x + vBUV*vPBary.y + vCUV*vPBary.z;  
        //return    Vector(b0 * vA.x + vP.x * vB.x + vP.y * vC.x, b0 * vA.y + vP.x * vB.y + vP.y * vC.y, 0.0);  
      }
      

      I have not tried either yet but will soon.

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

        On 27/06/2013 at 18:14, xxxxxxxx wrote:

        The current UV calculation appears to be working.  Nice.

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