Navigation

    • Register
    • Login
    • Search
    • Categories
    1. Home
    2. Danchyg1337
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Danchyg1337

    @Danchyg1337

    3
    Reputation
    39
    Posts
    46
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Danchyg1337 Follow

    Posts made by Danchyg1337

    • RE: Get viewport image of inactive document.

      @m_adam Thanks for your help. That made things clear.

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • RE: Get viewport image of inactive document.

      @m_adam Unfortunately, we are looking for real-time performance. RenderDocument is fast only on light projects.
      We are also looking for a workaround.
      We are trying to create plugin which tracks switching between documents. What is the most efficient way to catch last image of document viewport before switching the document? There is MSG_DOCUMENTINFO_TYPE_SETACTIVE, but as i understand, it will be too late to get viewport image after that event.

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • RE: Get viewport image of inactive document.

      @m_adam Thanks for your reply.
      As many as there opened documents.
      Context is CommandData.

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • Get viewport image of inactive document.

      Hello! I asked about GetViewportImage() in this topic few days ago. Code worked as it should, but it seems like it only gets image from active document, even tho BaseDraw is different.
      Here is my code.

      BaseDocument* doc = GetFirstDocument();
      		while (doc) {
      			BaseDraw* bd = doc->GetActiveBaseDraw();
      			if (!bd) {
      				doc = doc->GetNext();
      				continue;
      			}
      	                AutoAlloc<BaseBitmap> bitmap;
      			// Get the viewport image from the viewport renderer
      			maxon::ImageRef img;
      			bd->GetViewportImage(img);
      
      
      			if (img == nullptr) {
      				doc = doc->GetNext();
      				continue;
      			}
      
      			// Transform ImageRef to BaseBitmap in order to show it in the PictureViewer
      			const Int w = img.GetWidth();
      			const Int h = img.GetHeight();
      			
      
      
      			maxon::PixelFormat rgbf = img.GetPixelFormat();
      			Int32 bitsPerColor = (Int32)(rgbf.GetBitsPerPixel().Get() / rgbf.GetChannelCount());
      			bitmap->Init((Int32)w, (Int32)h, bitsPerColor == 32 ? 96 : 32);
      
      			maxon::BaseArray<UChar> line;
      			line.Resize(w * rgbf.GetBitsPerPixel().GetBytes()).GetValue();
      
      			maxon::PixelMutableBuffer imageBuffer(line.GetFirst(), rgbf.GetBitsPerPixel());
      			maxon::GetPixelHandlerStruct getpixel = img.GetPixelHandler(rgbf, rgbf.GetChannelOffsets(), maxon::ColorProfile(), maxon::GETPIXELHANDLERFLAGS::NONE, nullptr).GetValue();
      
      			for (Int y = 0; y < h; y++)
      			{
      				getpixel.GetPixel(maxon::ImagePos(0, y, w), imageBuffer, maxon::GETPIXELFLAGS::NONE).GetValue();
      				bitmap->SetPixelCnt(0, (Int32)y, (Int32)w, line.GetFirst(), (Int32)rgbf.GetBitsPerPixel().GetBytes(), bitsPerColor == 32 ? COLORMODE::RGBf : COLORMODE::RGB, PIXELCNT::NONE);
      			}
      	                ShowBitmap(bitmap);
      			doc = doc->GetNext();
      		}
      

      Each showed bitmap contains only active document viewport.
      I also tried to switch document with SetActiveDocument() and then call DrawViews() before getting viewport image, but that didnt work.
      Is there a way to get viewpirt image of inactive documents?

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • RE: Using GetViewportImage()

      @m_magalhaes Thanks a lot! That makes things clear.

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • Using GetViewportImage()

      Hello! In R23 we got an interesting feature to play with, but there is not much of an info about how to use it properly. Im talking about BaseDraw::GetViewportImage().

      This is what i tried.

      AutoAlloc<BaseBitmap> bmp;
      maxon::ImageRef imgr = maxon::ImageClasses::IMAGE().Create() iferr_return;
      const maxon::PixelFormat rgbFormat = maxon::PixelFormats::RGB::U8();
      const auto storageType = maxon::ImagePixelStorageClasses::Normal();
      
      imgr.Init(optW, optH, storageType, rgbFormat) iferr_return;
      bmp->Init(optW, optH);
      bmp->GetImageRef(SAVEBIT::NONE, true, imgr);
      doc->GetActiveBaseDraw()->GetViewportImage(imgr);
      
      ShowBitmap(bmp);
      

      Bitmap is just black, which leads me to conclusion that im using it the wrong way.
      How to use this new function properly and save to bitmap?

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • Accessing object container in C++.

      Hello! How can i do the same in C++?
      4727d1e4-611b-473e-b695-f6352e8f42c1-image.png
      The point is to set specific data by DescID. In python i can simply do what is on screenshot.

      But for C++ case isn't that simple.
      What i've tried already:

      • GetDataInstance();
        In this case i can only access Object Properties container, but not Coordinates.

      19131513-1e1e-4043-9ca4-9df7a5c64cc2-image.png

      • GetDescription();
        Also tried to use GetDescription(); and go through using GetNext();, but the problem is that BaseContaner is const, so i can't modify it.

      How to properly access any container of object?
      Thanks!

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • Possibility of using ExecuteSubID with ToolData.

      Hello! I'm looking for a way to launch my ToolData plugin with preset.
      Example:
      43d8797e-8cf9-4393-9162-6d35f70d86b2-image.png

      How can i do it? Should i create and register CommandData plugin in my ToolData plugin project? Or there is another way to do it?

      Thanks!

      posted in General Programming & Plugin Discussions
      Danchyg1337
    • RE: TreeView Multiple Selection With LMB

      @m_adam Now i see the problem. Thanks alot for helping!

      posted in Cinema 4D Development
      Danchyg1337