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

    Exampes of GetBitmap()?

    SDK Help
    0
    8
    1.1k
    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

      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

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

        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);  
                    }  
                  }  
                }  
              }
        
        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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!

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

            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

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

              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.

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

                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

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

                  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)

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

                    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

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