UVW projections



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

    On 31/10/2006 at 06:03, xxxxxxxx wrote:

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

    ---------
    Hello,

    i'm trying to extract the UVW coordinates of a polygonal mesh. It all works fine when the texture tag has an "UVW mapping" projection, but I still haven't managed to retrieve the correct mapping coordinates when a Spherical or a Cubic projection is used.

    I'm trying to use the function
    **
    Bool ShdProjectPoint(VolumeData *sd, TexData *tdp, LONG lhit, const Vector &p;, const Vector &n;, Vector *uv)
    **
    referenced in TexData help:

    which extensively uses tdp->im (the inverse of the texture projection matrix).

    The problem is when I get the pointer to TexData:

    **
    TexData* pTexData = pVolumeData- >GetTexData(pObject, 0);     
    **

    the im field is not initialized, so I manually inverse the matrix:

    pTexData- >im = !pTexData->m;

    or, additionally:

    pTexData- >Initialize();

    However none of this seems to work, I get weird UVWs with any kind of projection (but "UVW mapping" one, which i'm retrieving via UVWTag::Get(polygonID) )

    Has anybody managed to do get UVW from Spherical/Cubic/... projections? any comments would be appreciated.

    Thanks



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

    On 31/10/2006 at 06:48, xxxxxxxx wrote:

    You don't use ShdProjectPoint(), it's a internal function. You should use ProjectPoint instead.

    Bool ProjectPoint(TexData* tdp, LONG global_id, const Vector & p, const Vector& n, Vector* uv)
    Compute the UVW coordinates for a texture.

    Return
    Bool
    Success of generating the UVW coordinate.

    Parameters
    TexData* tdp
    The texture to use for the UVW coordinates. The caller owns the pointed object.

    LONG global_id
    The global polygon ID for the UVW coordinates.

    const Vector & p
    The point for the UVW coordinate.

    const Vector & n
    The normal for the UVW coordinate.

    Vector* uv
    The returned UVW coordinate.

    Let me know if that helps, also at what point in the Videopost are you calling the function.

    cheers,
    Matthias



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

    On 31/10/2006 at 08:49, xxxxxxxx wrote:

    Thanks Matthias, I'm afraid it's not working though :(, it always returns FALSE. Here's how I'm using it:

    ... called from VidePostData::Execute(...) when vps->VP == VP_RENDER

    (simplified code)

    VolumeData* pVolumeData = vps->vd;
    RayObject* pObject = pVolumeData->GetObj(objID);
    TexData* pTexData = vps->vd->GetTexData(pObject, 0);

    Vector* pPolygonPointNormals = ...

    for (LONG p = 0; p < pObject->vcnt; p++)
    {
       RayPolygon polygon = pObject->vadr[ p ];               
       LONG polygonGlobalID = pVolumeData->Obj_to_ID(pObject) + p,

    Vector vA = pObject->padr[polygon.a];          
       Vector nA = !(ObjectRotationMatrix * pPolygonPointNormals[p * 4]); // normal in world space

    UVWStruct UVW;
    // assuming the object has a spherical mapping for instance
       Bool res = pVolumeData->ProjectPoint(pTexData , polygonGlobalID, vA, nA, &UVW.a;); // <-- returs false, UVW.a = {0,0,0}

    ...
    }



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

    On 01/11/2006 at 17:44, xxxxxxxx wrote:

    I found out why it's probably not working for you (actually I had trouble to get it to work too). You have to be in VP_INNER to get a result from ProjectPoint, took me some time to figure that out :) Anyway it's working for me, if you have still some problems don't hesitate to ask.

    cheers,
    Matthias



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

    On 02/11/2006 at 01:43, xxxxxxxx wrote:

    Phew Matthias, its working now ;) thank you so much, you ended up with 3 frustrating days of trial and error.

    cheers!



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

    On 21/12/2006 at 07:53, xxxxxxxx wrote:

    I all,

    i'm trying to get the projected UVW from volume data and texdata.. but always i'm getting this problem with the spherical projection.

    What's the correct way to get stored and prepared UVW in VP_INNER?

    I've used ProjectPoint and return me some artifact.

    Cheers
    Renato T.



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

    On 22/12/2006 at 15:46, xxxxxxxx wrote:

    What i mean is:

    When c4d prepare the geometry accessibile in the volumedata i imagine that store in UVW all kind of projection.
    But i don't understand how to get the "spherical" or "flat"   transformed UVW. GetUVW fill the UVW polyvector only for the UVW mapped object. I can't trust that ProjectPoint is called when rendering.

    thanks in advance and merry xmas to all :)
    Renato



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

    On 31/12/2006 at 05:45, xxxxxxxx wrote:

    and.. Happy New Year

    Renato



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

    On 02/01/2007 at 01:30, xxxxxxxx wrote:

    In my case I use ProjectPoint, but I haven't noticed any problem with spherical projections (?). In order to be able to retrieve UVW mapping, the object needs to have a Texture Tag, which you cand obtain like this:

      
    polygon is an own structure, where pParentObject is a RayObject*  
      
    VolumeData* pVD ...  
    for (LONG TextureID = 0; (!pAssignedMaterial) && (TextureID < polygon.pParentObject->texcnt); TextureID++)  
    {  
       TexData* pTexData = pVD->GetTexData(polygon.pParentObject, TextureID);  
       if (TextureAppliedOnPolygon(pTexData, polygon.localPolygonID, polygon.pParentObject, pVD))   
                   pAssignedMaterial = pTexData;  
    }  
    

    and then

      
    pVD->ProjectPoint(pAssignedMaterial, polygon.globalPolygonID, polygon.vA, polygon.nA, &pUVW-;>a);  
      
    same with b and c  
    

    where vA and nA are vectors (position and normal) of the 1st vertex

    TextureAppliedOnPolygon implementation is provided somewhere in the sdk

      
    BOOL TextureAppliedOnPolygon(TexData* pTexture, LONG localPolygonID, RayObject* pObject, VolumeData* pVD)  
    {  
    if (pTexture->restrict)  
         {  
              if (pObject->type != O_POLYGON ||   
                   pTexture->restrict >= pObject->rscnt ||   
                   !pObject->rsadr[pTexture->restrict]) return FALSE;  
      
            if (!(pObject->rsadr[pTexture->restrict][localPolygonID>>5]&(1<<(localPolygonID&31)))) return FALSE;  
        }  
         return TRUE;  
    }  
    

    hope it helps



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

    On 02/01/2007 at 09:39, xxxxxxxx wrote:

    Thanks Joesfer,

    but i've made exactly the same :)

    but maybe that i'm looking in the wrong place.

    Thanks
    Renato



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

    On 02/01/2007 at 09:45, xxxxxxxx wrote:

    well you've done a little progress in some sense, at least discarding one possible fail... :) luck!



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

    On 03/01/2007 at 12:10, xxxxxxxx wrote:

    Thanks!

    Renato


Log in to reply