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

    MatPreview Popup: show custom scenes

    SDK Help
    0
    3
    567
    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

      On 27/09/2015 at 01:05, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   13-16 
      Platform:      
      Language(s) :     C++  ;

      ---------
      Hi,

      Is it possible to show only some custom scenes in the material preview? It is easy to just add custom scenes, but i want to get rid of all the others. Using MATPREVIEW_GET_POPUP_OPTIONS gives me a submenu which i also do not want. Here is a little illustration:

      and my code, straight from the SDK Examples:

        
      Bool RegisterAtmosphereMaterialData(void)   
      {   
      // decide by name if the plugin shall be registered - just for user convenience   
      String name=GeLoadString(IDS_ATMOSPHERE); if (!name.Content()) return TRUE;   
      name = GeGetDefaultFilename(DEFAULTFILENAME_SHADER_VOLUME)+name; // place in default Shader section   
        
      String previewName = GeLoadString(IDS_ATMOSPHERE_MATPREVIEW);   
      AddUserPreviewScene(GeGetPluginPath() + String("res") + String("scene") + String("Atmosphere Preview.c4d"), ID_ATMOSPHERE2, &previewName;);   
        
      previewName = GeLoadString(IDS_ATMOSPHERE_MATPREVIEW2);   
      AddUserPreviewScene(GeGetPluginPath() + String("res") + String("scene") + String("Atmosphere Low.c4d"), ID_ATMOSPHERE2, &previewName;);   
        
      previewName = GeLoadString(IDS_ATMOSPHERE_MATPREVIEW3);   
      AddUserPreviewScene(GeGetPluginPath() + String("res") + String("scene") + String("Atmosphere Ground.c4d"), ID_ATMOSPHERE2, &previewName;);   
        
      return RegisterMaterialPlugin(ID_ATMOSPHERE2,name,0,AtmosphereMaterialData::Alloc,"Mplanetatmosphere2",0);   
      }   
      
        
      Bool AtmosphereMaterialData::Message(GeListNode *node, LONG type, void *data)   
      {   
      if (type == MSG_UPDATE)   
          updatecount++;   
        
      switch(type)   
      {   
          case MSG_DESCRIPTION_VALIDATE:   
          {   
            UpdateGuiValues((BaseMaterial* )node);   
            return TRUE;   
          }   
          break;   
          case MATPREVIEW_GET_PREVIEW_ID:   
          {   
            *((LONG* )data) = MAT_PREVIEW;   
            return TRUE;   
          }   
          break;   
          case MATPREVIEW_GET_OBJECT_INFO:   
          {   
            MatPreviewObjectInfo* info = (MatPreviewObjectInfo* )data;   
            info->bHandlePreview = TRUE; // own preview handling   
            info->bNeedsOwnScene = TRUE;   
            info->bNoStandardScene = FALSE;   
            info->lFlags = MATPREVIEW_FLAG_HIDE_SCENES; //MATPREVIEW_FLAG_HIDE_SCENE_SETTINGS;   
            return TRUE;   
          }   
          break;   
          case MATPREVIEW_MODIFY_CACHE_SCENE:   
          {   
              return TRUE;   
          }   
          break;   
          case MATPREVIEW_PREPARE_SCENE:   
          {   
            auto* preparescene = static_cast<MatPreviewPrepareScene*>(data);   
        
            AutoAlloc<AliasTrans> trans;   
            if (!trans)   
              return FALSE;   
            if (!trans->Init(GetActiveDocument()))   
              return FALSE;   
            BaseMaterial* matclone = (BaseMaterial* )(Get()->GetClone(COPYFLAGS_0, trans));   
            preparescene->pDoc->InsertMaterial(matclone);   
            trans->Translate(TRUE);   
            if (preparescene->pLink) preparescene->pLink->SetLink(matclone); // necessary   
        
            BaseObject* obj = preparescene->pDoc->SearchObject("Object");   
            if (obj)   
            {   
              TextureTag* textag = (TextureTag* )obj->GetTag(Ttexture);   
              if (textag)   
                textag->SetMaterial(matclone);   
            }   
        
            const Real radius_in_preview_scene = 100.;   
            SetParameter(matclone, RADIUS_UNITS, GeData(radius_in_preview_scene));   
            SetParameter(matclone, ORIGIN_AT_SURFACE, GeData(FALSE));   
        
            preparescene->bScenePrepared = TRUE; // inform the preview that the scene is prepared now   
            return TRUE;   
          }   
          break;   
          case MATPREVIEW_GET_POPUP_OPTIONS:   
          {   
            BaseContainer* bc = (BaseContainer* )data;   
            bc->SetString(MATPREVIEW_POPUP_NAME, GeLoadString(IDS_ATMOSPHERE));   
            bc->SetString(1, GeLoadString(IDS_ATMOSPHERE_MATPREVIEW));   
            bc->SetString(2, GeLoadString(IDS_ATMOSPHERE_MATPREVIEW2));   
            bc->SetString(3, GeLoadString(IDS_ATMOSPHERE_MATPREVIEW3));   
            return TRUE;   
          }   
          break;   
          case MATPREVIEW_GENERATE_IMAGE:   
          {   
            MatPreviewGenerateImage* image = (MatPreviewGenerateImage* )data;   
            if (image->pDoc)   
            {   
              if (!image->bEditorPreview)   
              {   
                // we don't calculate a preview map for the editor   
                LONG w = image->pDest->GetBw();   
                LONG h = image->pDest->GetBh();   
                BaseContainer bcRender = image->pDoc->GetActiveRenderData()->GetData();   
                bcRender.SetReal(RDATA_XRES, w);   
                bcRender.SetReal(RDATA_YRES, h);   
                bcRender.SetLong(RDATA_ANTIALIASING, ANTI_GEOMETRY);   
                if (image->bLowQuality)   
                  bcRender.SetBool(RDATA_RENDERENGINE, RDATA_RENDERENGINE_PREVIEWSOFTWARE);   
                image->pDest->Clear(0, 0, 0);   
                image->lResult = RenderDocument(image->pDoc, bcRender, NULL, NULL, image->pDest,   
                  RENDERFLAGS_EXTERNAL | RENDERFLAGS_PREVIEWRENDER, image->pThread);   
              }   
            }   
            return TRUE;   
          }   
          break;   
      }   
      return MaterialData::Message(node, type, data);   
      }   
      
      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 28/09/2015 at 02:31, xxxxxxxx wrote:

        Hi Michael,

        unfortunately that's not possible. On the one hand display of the user scenes is hard coded in conjunction with the standard preview scenes. And on the other hand popup options are a hard coded submenu.
        Sorry 😢

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

          On 28/09/2015 at 04:42, xxxxxxxx wrote:

          No problem. It's just a cosmetical issue after all.

          Thanks for the quick reply.

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