Exampes of GetBitmap()?



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

    On 17/03/2003 at 09:29, xxxxxxxx wrote:

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

    ---------
    Getting desparate.. can't seem to find any help anywhere in examples or the forum to my issue, so one last post...

    Does anyone have any sample code of getting an image/texture mapped onto the Diffuse channel (or any channel on a material) from a material channel? I have tried every way without success..

    BaseBitmap* GetBitmap(void)

    thanks, eric



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

    On 18/03/2003 at 10:43, xxxxxxxx wrote:

    I did some experimentation. Just like you, I couldn't get this to work:

        
        
          BaseMaterial* basemat = doc->GetFirstMaterial();  
          if (basemat && basemat->GetType() == Mmaterial)  
          {  
            Material* mat = static_cast<Material*>(basemat);  
            BaseChannel* basechan = mat->GetChannel(CHANNEL_COLOR);
        
        
        
        
            if (basechan)  
            {  
              BaseBitmap* bm = basechan->GetBitmap();  
              if (bm) ShowBitmap(bm);  
            }  
          }
    

    I've reported it as a bug. But you can hack your way to the bitmap:

        
        
          BaseMaterial* basemat = doc->GetFirstMaterial();  
          if (basemat && basemat->GetType() == Mmaterial)  
          {  
            Material* mat = static_cast<Material*>(basemat);  
            BaseChannel* basechan = mat->GetChannel(CHANNEL_COLOR);
        
        
        
        
            if (basechan)  
            {  
              Filename path;  
              if (GenerateTexturePath(doc->GetDocumentPath(),   
                  Filename(basechan->GetData().GetString(BASECHANNEL_TEXTURE)), &path))  
              {  
                AutoAlloc<BaseBitmap> bm;  
                if (bm)  
                {   
                  bm->Init(path);  
                  ShowBitmap(bm);  
                }  
              }  
            }  
          }
    


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

    On 18/03/2003 at 11:55, xxxxxxxx wrote:

    The BaseChannel::GetBitmap() bitmap can only be retrieved during rendering, i.e. after InitRender and before FreeRender!



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

    On 20/03/2003 at 00:02, xxxxxxxx wrote:

    Mikael,
    Thanks for the info.
    I tried to do the InitRender bit however I can't figure out how get InitRender going I guess it's something to do with the InitRenderStruct setup.
    The documentation says the Init Render struct is generated by Cinema4D? but I don;'t know how to get that data, where it comes from or use it successfully.. :/

    thanks though!
    -eric



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

    On 25/03/2003 at 12:00, xxxxxxxx wrote:

    Here's an example:

        
        
          BaseMaterial* basemat = doc->GetFirstMaterial();  
          if (basemat && basemat->GetType() == Mmaterial)  
          {  
            Material* mat = static_cast<Material*>(basemat);  
            BaseChannel* basechan = mat->GetChannel(CHANNEL_COLOR);
        
        
        
        
            if (basechan)  
            {  
              InitRenderStruct irs;  
              irs.version = GetC4DVersion();  
              irs.fps = doc->GetFps();  
              irs.time = doc->GetTime();  
              irs.docpath = const_cast<Filename*>(&doc->GetDocumentPath());  
                
              if (basechan->InitTexture(&irs) == LOAD_OK)  
              {  
                BaseBitmap* bm = basechan->GetBitmap();  
                if (bm) ShowBitmap(bm);
        
        
        
        
                Vector uvw = Vector(0.5, 0.5, 0.0);  
                Vector dlt = Vector(0.1);  
                Vector nn = Vector(0, 0, 1);
        
        
        
        
                Vector sample = basechan->Sample(NULL, &uvw, &dlt, &nn, 0.0, 0, 0.0, 1.0);  
                GePrint("sample: " + RealToString(sample.x) + ","   
                                   + RealToString(sample.y) + ","   
                                   + RealToString(sample.z));  
              }  
              basechan->FreeTexture();  
            }  
          }
    

    The GetBitmap() part will only work with real textures. The Sample() part works with shaders as well.



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

    On 19/05/2005 at 02:02, xxxxxxxx wrote:

    Hi,
    I'm using the above code posted by Mikael to get samples from shaders.

    Everything seems to be working fine EXCEPT that when using animated shaders (e.g. animated noise), the sample data always seems to be from time = 0.0, regardless of the setting of irs.time.

    So how do I tell the shader what time to render for?

    Cheers - Steve



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

    On 19/05/2005 at 09:08, xxxxxxxx wrote:

    irs.time = yourBaseTimeObject()
    should work.(at least I think it should)



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

    On 20/05/2005 at 11:27, xxxxxxxx wrote:

    Katachi: Thanks for replying, but that wasn't it.

    SOLVED:

    The call to 'sample' in the above example code is incorrect, as the fifth parameter specifies the time at which to sample (which I hadn't realised - D'OH), and is set here to 0.0.

    This is inconsistent with the value of irs.time in the example.

    So, why is the time specified in two different places?
    Well as far as I can tell irs.time is used to interpolate keyframed shader parameter values, whilst the time parameter passed to the shader tells the shader what time to render for for the parameter values it has been given For any shaders that aren't time varying, this second value doesn't matter, and only irs.time is needed.

    Cheers - Steve


Log in to reply