Getting Material in Video Post ExecutePixel



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

    On 24/03/2010 at 04:50, xxxxxxxx wrote:

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

    ---------
    I want to find the name of a material a pixel is being rendered in from a Video Post plugin. I have got code that works in some cases, but if there are different materials applied to selected faces of a cube I can't see how to get the right material.

    Here's what I'm doing

    if (pp->frag[0]->id.Content())
    {
        RayObject *obj=pp->frag[0]->id.GetObject(pp->vd);
        if (obj->texcnt)
        {
            GeListNode* mp=pp->vd->GetTexData(obj, 0)->mp;
            if (mp && mp->IsInstanceOf(Tbaselist2d))
            {
                BaseList2D *bmp=static_cast<BaseList2D*>(mp);
                name=bmp->GetName();

    but in the example I'm currently working on, obj->texcnt is 3 and the names I actually want are those from GetTexData(obj, 0), GetTexData(obj, 1) and GetTexData(obj, 2). Unfortunately I can't see any way to work out which index I need for a given pixel!

    I can get polygon index numbers, which are different on the 3 faces I can see, but can't see any way to map them to textures.

    Thanks,

    Arvan



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

    On 24/03/2010 at 06:59, xxxxxxxx wrote:

    You can access the current texture through BaseVolumeData::tex.

    Have a look at the example below.

      
    void VisualizePostData::ExecutePixel(PluginVideoPost *node, PixelPost *pp, LONG x, LONG subx, LONG suby)  
    {  
      if (pp->vd)  
      {  
          TexData *tex = NULL;  
          tex = pp->vd->tex; //the texture data of the current pixel  
      
          if (tex)  
          {  
              //render red if a texture has been found, just as example  
              pp->col[0] = 1.0;  
              pp->col[1] = 0.0;  
              pp->col[2] = 0.0;  
          }  
      }  
    }  
    

    cheers,
    Matthias


Log in to reply