Get material name in VideoPost plugin



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

    On 02/10/2003 at 05:55, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.200 
    Platform:   Windows  ;   
    Language(s) :   C.O.F.F.E.E  ;  C++  ;

    ---------
    I'm trying to write a plugin to allow Cinema 4D to produce EPix files for Piranesi, these are raster images with depth and material channels and camera projection information. I'm doing it as a Video Post plugin, and am recording the depths and materials in the ExecutePixel method.
    The material channel is a tag for each pixel and a list of names to associate with each tag.  I would like the tags to correspond to Cinema 4D materials and the names to be the names of those materials.

        
        
          
        void EpixWriterData::ExecutePixel(PluginVideoPost *node, PixelPost *pp, LONG x, LONG subx, LONG suby)  
        {  
            if (pp->frag[0])  
            {  
                if (pp->vd->lhit)  
                {  
                    LONG vind;  
                    RayObject *obj=pp->vd->ID_to_Obj(pp->vd->lhit, &vind);
        
        
        
        
                        if (obj->texcnt)  
                        {  
        use tag based on void* mp=pp->vd->GetTexData(obj, 0)->mp and name it with (BaseMaterial* )mp->GetName();  
                        }  
                        else if (obj->texture_link)  
                        {  
        use tag based on obj->texture_link named obj->texture_link->GetName()  
                        }  
                        else if (obj->link)  
                        {  
        use tag based on obj->link named obj->link->GetName()  
                        }  
                        else  
                        {  
        use tag based on obj address with generated name  
                        }  
                    }  
                }  
                else  
                {  
        use fixed tag with fixed name  
                }  
            }  
            else  
            {  
        use special tag value for nothing there  
            }  
        }  
        
    

    I have two problems I know of here.

    • I'm using the TexData mp field which is documented as internal use only - what is the supported way to get to the material name?
    • If the ray to this pixel is reflected I get the depth of the object seen directly in pp->frag[0]->z, but pp->vd->lhit refers to the object whose reflection I can see. How do I get at the object corresponding to pp->frag[0]?

    Thanks,
    Arvan



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

    On 12/10/2003 at 02:35, xxxxxxxx wrote:

    1. I don't think there's a supported way, but I'll ask the programmers if what you do is dangerous.
    2. Probably the lhit is undefined at this stage and just happens to be the last intersection used for the pixel. I think you'll have to use GetRay() for the current pixel and TraceGeometry().



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

    On 12/10/2003 at 04:26, xxxxxxxx wrote:

    1. It should be fairly safe to use the pointer in this way, but the type is GeListNode. So you have to use IsInstanceOf(Mbase) before casting any further.
    2. Indeed 'lhit' isn't defined in ExecutePixel. That's why there's an 'id' field inside the PixelFragment. This is the hit id of that fragment.
    So your first case should be:

        
        
        if (pp->frag[0])  
        {  
          LONG id = pp->frag[0]->id;  
          if (id)  
          {  
            LONG vind;  
            RayObject *obj=pp->vd->ID_to_Obj(id, &vind);
        
        
        
        
            if (obj->texcnt)  
            {  
              GeListNode *mp = (GeListNode* )pp->vd->GetTexData(obj, 0)->mp;  
              if (mp && mp->IsInstanceOf(Mbase))  
              {  
                name = ((BaseMaterial* )mp)->GetName();  
              }  
            }  
            //...  
          }  
        }
    


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

    On 14/10/2003 at 07:04, xxxxxxxx wrote:

    Thanks Mikael,
    It seems to be working fine.
    Where do I file a request for a supported way to get the material name?
    Arvan



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

    On 14/10/2003 at 13:24, xxxxxxxx wrote:

    In the next version of the API the pointer won't be void anymore, but you can consider the solution to be supported* already since it was the developers who came up with the solution.
    * In the limited sense that any part of the API is supported.


Log in to reply