Notifications
Clear all

[Closed] Material preview ball in sdk?

Hello world, I have an object plugin that holds a few materials in the pramblocks. Is there a way of getting a ball like preview of it?

I can’t find anything in the sdk, BUT I do remember coming across some code that talked about some of the features that each material editor slot had. I just can’t find it now.

any thoughts on this?

si

2 Replies

CreatePStamp maybe?

This code was from Klvnk. The problem comes when you use 3ds Max 2017 or 2018 zoomed in. The Problem come when QT does not resize PStamp

sz = 0 -> 3232
sz = 1-> 88
88
sz > 1 -> 24*24


//***********************************************  ***************************************
  // MtlPreviewToBitmap

  def_visible_primitive(MtlPreviewToBitmap, "MtlPreviewToBitmap");

  Value* MtlPreviewToBitmap_cf(Value** arg_list, int count)
{
   check_arg_count(MtlPreviewToBitmap, 2, count);

   MtlBase* mb = arg_list[0]->to_mtlbase();
   int sz = arg_list[1]->to_int();

   PStamp *ps = mb->CreatePStamp(sz,1);
   if(ps)
   {
      int d = PSDIM(sz);
      int scanw = ByteWidth(d);
      int nb = scanw*d;

      UBYTE *buf = new UBYTE[nb + sizeof(BITMAPINFOHEADER)];
      if(!buf)
          &undefined;

// get the image data

      ps->GetImage(&buf[sizeof(BITMAPINFOHEADER)]);

// and create the header info

      BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)buf;
      bih->biSize = sizeof(BITMAPINFOHEADER);
      bih->biWidth = d;
      bih->biHeight = d;
      bih->biPlanes = 1;
      bih->biBitCount = 24;
      bih->biCompression = BI_RGB;
      bih->biSizeImage = 0;

      Bitmap *map = TheManager->Create((PBITMAPINFO)buf);
      delete [] buf;

      if(map)
      {
         one_typed_value_local(MAXBitMap* mbm);
         vl.mbm = new MAXBitMap();
         vl.mbm->bi.CopyImageInfo(&map->Storage()->bi);
         vl.mbm->bi.SetFirstFrame(0);
         vl.mbm->bi.SetLastFrame(0);
         vl.mbm->bi.SetName("");
         vl.mbm->bi.SetDevice("");
         if(vl.mbm->bi.Type() > BMM_TRUE_64)
            vl.mbm->bi.SetType(BMM_TRUE_64);
         vl.mbm->bm = map;
         return_value(vl.mbm);
      }
   }
   return &undefined;
}


display (MtlPreviewToBitmap (getMeditMaterial 1) 0)

Si