Navigation

    • Register
    • Login
    • Search
    1. Home
    2. WickedP
    3. Posts
    • Profile
    • More
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by WickedP

    RE: Rendering into Multipassbitmap a "Depth Matte" Layer

    Thanks @ferdinand, I don't expect you to do everything 🙂

    But I've reached a point where I've tried everything I can think of. I've spent too long going around in circles at this point. Here's what I'd like to get:

    A MultipassBitmap that I can pass to RenderDocument() that will give me

    • 1 layer for RGB (32bit)
    • 1 layer for alpha (32bit) <-- yes, I want a separate alpha layer
    • 1 layer for depth (32bit)

    for use with the standard renderer. For now, I must have these 3 layers.

    Here's some code I've experimented with to try and show you where I've been:

    MultipassBitmap *multi = MultipassBitmap::Alloc(width,height,COLORMODE_RGBf);
    
    if(multi)
    {
    	MultipassBitmap *colourMap = multi->GetLayerNum(0);
    
    	MultipassBitmap *alphaMap = multi->AddAlpha(nullptr,COLORMODE_GRAYf);
    							
    	if(alphaMap)
    	{
    		alphaMap->SetParameter(MPBTYPE_NAME,String("Alpha"));
    		alphaMap->SetParameter(MPBTYPE_USERID,VPBUFFER_ALPHA);
    		alphaMap->SetParameter(MPBTYPE_SAVE,TRUE);
    		alphaMap->SetParameter(MPBTYPE_SHOW,TRUE);
    	}
    
    	MultipassBitmap *depthMap = multi->AddAlpha(alphaMap,COLORMODE_GRAYf,FALSE);
    
    	if(depthMap)
    	{
    		depthMap->SetParameter(MPBTYPE_NAME,String("Depth"));
    		depthMap->SetParameter(MPBTYPE_USERID,VPBUFFER_DEPTH);
    		depthMap->SetParameter(MPBTYPE_SAVE,TRUE);
    		depthMap->SetParameter(MPBTYPE_SHOW,TRUE);
    	}
    
    	if(RenderDocument(doc,rdata,nullptr,nullptr,multi,RENDERFLAGS_0,nullptr) == RENDERRESULT_OK)
    	{
    		ShowBitmap(multi);
    	}
    }
    

    I've tried all sorts of variations of this, none of which produce the same as the Render to Picture Viewer command. Which is why I mentioned having that as an example would be useful.

    How do we do this?

    WP.

    posted in Cinema 4D SDK •
    Adding Layers to a MultipassBitmap

    Sorry folks, I keep spamming my topic! I've realised there's another issue. AddLayer() returns NULL, and from a topic I made previously (some time a go now) it was reported as a bug, but it's never been fixed by the looks of it.

    How can I add layers to a MultipassBitmap!? How does the command Render to Picture Viewer do it?

    WP.

    edit by @ferdinand : Forked from Render settings Multi-Pass flag. Please open new topics for new questions, your follow up questions were too broad to be put into the same topic.

    posted in Cinema 4D SDK •
    RE: Rendering into Multipassbitmap a "Depth Matte" Layer

    I may have resolved this. It seems like I have to use SetParameter() with the flags MPBTYPE_USERID and VPBUFFER_DEPTH. This wasn't clear in the docs (my docs at least).

    Just a suggestion, it might be useful to have an example reference somewhere of how to setup a MultipassBitmap for rendering with all the layers needed as per the render settings. Something like how the Render To Picture Viewer button might do it behind the scenes.

    WP.

    posted in Cinema 4D SDK •
    Rendering into Multipassbitmap a "Depth Matte" Layer

    I have a follow-up question to this. I can't see the link between making a MultipassBitmap (MPB) and having a depth matte render.

    For example; when I hit the render button, it renders with a depth matte and it displays in the picture viewer. But if I do it myself (C++) using the same render settings, I don't get any depth matte. I'm guessing it has something to do with setting up layers in the MPB. But I can't see how this is done. I know how to make a layer. But I don't know how to say "this layer is for the depth matte".

    For however it's done, is there an example of this somewhere?

    WP.

    edit by @ferdinand : Forked from Render settings Multi-Pass flag. Please open new topics for new questions, your follow up questions were too broad to be put into the same topic.

    posted in Cinema 4D SDK •
    RE: Render settings Multi-Pass flag

    Thanks @ferdinand,

    Didn't see the enable flag in the header file, needed to look a bit more! For anyone else, this flag needs to be set with SetParameter().

    Flag is turned on, thanks again.

    WP.

    posted in Cinema 4D SDK •
    Render settings Multi-Pass flag

    Hi folks,

    How does one turn on the Multi-Pass option in the render settings? This one:

    ea7a6f2c-fc95-48ef-adc3-01e129ea38a8-image.png

    WP.

    posted in Cinema 4D SDK •
    RE: GeClipMap and init(BaseBitmap)

    Sounds like what I'm doing should be OK then. If I run into any problems, I'll pop back in for further advice.

    Thanks @ferdinand, your help is always appreciated. We can close this one.

    WP.

    posted in Cinema 4D SDK •
    RE: GeClipMap and init(BaseBitmap)

    @ferdinand said in GeClipMap and init(BaseBitmap):

    Starting or stopping drawing operations for CA will have no impact on CB and vice versa

    This might be the answer. But just to be sure...

    The docs say that to use both Get/SetPixelRGBA() they have to be enclosed in BeginDraw/EndDraw(). So if we're handling two clip maps at the same time, for example reading from one and writing to another, can they both be 'active' between Begin/EndDraw() at the same time?

    In my case, something like this:

    /* pseudo code */
    
    GeClipMap *CA = GeClipMap::Alloc()...
    // init CA etc. We'll draw text into this one
    
    GeClipMap *CB = GeClipMap::Alloc()...
    CB->init(bmp); // init this one with another Bitmap
    
    CA->BeginDraw();
    CB->BeginDraw();
    
    /* Add some text into our first clip map */
    CA->SetColor(...);
    CA->TextAt(...);
    
    /* 'for' loop here to iterate over CA, and copy into CB if colour from CA is not black */
    LONG r,g,b,a;
    for(int rows = 0; etc...)
    {
        for(int cols = 0; etc...)
        {
            /* Get rgba from CA */
            CA->GetPixelRGBA(....);
    
            /* Check if red colour is greater than 0 */
            if(r != 0)
            {
                /* Set/blend pixel colour into CB */
                CB->SetRGBA(...);
            }
        }
    }
    
    CA->EndDraw();
    CB->EndDraw();
    

    In this case, we have to use GetPixelRGBA on the first clip map with the text, and are using SetPixelRGBA on the second clip map that's the BaseBitmap we're adding text into. They'd both be between Begin/EndDraw() at the same time in my example above. Is this OK?

    For what it's worth, it seems to work in my plugin. But I want to check that it's safe to do.

    WP.

    posted in Cinema 4D SDK •
    RE: GeClipMap and init(BaseBitmap)

    OK, I had to jump through some hoops for one solution here.

    I created a separate GeClipMap, just the size of the text width and height. I added the text into this in a white colour. I then iterated over this text map and if the pixel was greater than black, I blended it in with the main clip map and the text colour needed. Not an ideal solution as it involves creating another temporary clip map, but they're only the size of the text so fairly small.

    While I'm on this one, is it safe to have two clip maps inside the BeginDraw() and EndDraw() functions at the same time?

    WP.

    posted in Cinema 4D SDK •
    RE: GeClipMap and init(BaseBitmap)

    Leave it with me @ferdinand, I'll dig a bit more tomorrow and over the weekend, and if no luck I'll get back to you (or I'll try a different drawing method).

    I'll let you know.

    WP.

    posted in Cinema 4D SDK •
    RE: GeClipMap and init(BaseBitmap)

    Thanks @ferdinand, that's really helpful. Your words explain what I see.

    I dug a little deeper, and since found my issue was bit-depth related. I've changed my Bitmap to 32bit now. That's fixed that part.

    However, it's introduced another issue. If I put any text in the clip map it shows up as a blank rectangle full of the set colour. The text only appears if I do something like draw a FillRect() underneath it first. Is this bit-depth related as well?

    Text without FillRect():
    42676991-9fb3-4797-9e52-e855836343cd-image.png

    Text with FillRect():
    317230fa-9931-42f1-9bf4-e7057f4e97fc-image.png

    [Note: just to put the two images above into context for you, the second one is like a 'mouse-over' effect of the first. But the text only reads in the second one, when the FillRect() is drawn 'underneath', or before, the call to TextAt().]

    WP.

    posted in Cinema 4D SDK •
    GeClipMap and init(BaseBitmap)

    Hi folks,

    I'm working on an interface and am passing a Bitmap around to a number of separate objects, each with their own draw function. In doing so, I'm noticing some strange behaviour, and I think I may know what's causing it. But I'm seeking some guidance first in case it's something else.

    If I do this:

    BaseBitmap *bmp = etc..
    
    // then, I do this somewhere else
    GeClipMap *cm = GeClipMap::Alloc();
    cm->init(bmp);
    

    is this copying the bmp into the clip map? Or is the clip map now working on the original bitmap?

    If it is being copied, can we cast to a clip map instead so there's no copying, and where the original 'bmp' pointer remains in tack also?

    WP.

    posted in Cinema 4D SDK •
    RE: Getting keyboard commands in GeDialog()

    Thanks @ferdinand,

    I'll use the KEY_WXYZ as you pointed out, if that's the correct usage, I should use it. And the python code you shared gave me an idea to convert the ASCII numbers to a String() as well. Things now seem to work the way I had intended them to.

    I can appreciate not wanting to dig into old interface designs - it's what I'm attempting to rewrite at the moment! 🙂

    Solved.

    WP.

    posted in Cinema 4D SDK •
    RE: Getting keyboard commands in GeDialog()

    @ferdinand seems like we might be able to do this:

    LONG asciivalue = msg.GetLong(BFM_INPUT_CHANNEL);
    

    which will return the ascii value of the character. Instead of asking for the string, maybe this is a better way?

    I probably confused myself on that line of code @ferdinanrd, that said, I've used both ways in previous plugins, and both seem to work. I don't know if it's just dumb luck, or if they built a fail-safe in so that if you pass the flag BFM_INPUT_CHANNEL it returns the value of the KEY_WXYZ instead? Or maybe GetInputState() also sets the BFM_INPUT_QUALIFIER flag (it seems to on mine..), and not just true/false for a particular key. Maybe Maxon could clarify for future reference?

    I think the ascii route could work for me.

    WP.

    posted in Cinema 4D SDK •
    Getting keyboard commands in GeDialog()

    Hi folks,

    I'm wanting to get various CTRL+X key presses in my dialog. I can get keys without the ctrl, and I can get the ctrl without keys, but I can't get any ctrl+key presses. In the dialog's Message() function I've tried variations like:

    case BFM_INPUT:
    {
    BaseContainer KB;
    GetInputState(BFM_INPUT_KEYBOARD,BFM_INPUT_CHANNEL,KB);
    LONG qualifier = KB.GetLong(BFM_INPUT_QUALIFIER,NULL);
    String input = msg.GetString(BFM_INPUT_ASC,"");
    }
    

    but none work. They key is always blank if control is pressed.

    I've seen a couple of older posts that gave some suggestions, but nothing seemed to work.

    Is there a particular way we have to do this? Or does it just not work for our own dialogs?

    WP.

    posted in Cinema 4D SDK •
    RE: Right-mouse click on dialog tab

    Hi @ferdinand,

    I was wondering about dividing by the count as well. But not sure if that would work for tabs where there are different widths?

    I'll have a think about the gui design and layout. It probably doesn't matter how it looks, so long as it works. Thanks for the QuickTabCustomGui tip as well, I had completely forgotten they existed!

    I can probably live with the DIY bitmapbutton approach. It's still a tab system I guess, just not out of the box. But I can get a custom context menu for each 'tab' this way, so it kind of provides me with a solution, albeit with a bit more coding effort on my part.

    You can set answer and mark as solved. If I have any follow-up questions I'll pop back in.

    WP.

    posted in Cinema 4D SDK •
    RE: Right-mouse click on dialog tab

    Thanks for your efforts @ferdinand, and no probs with the python code, I can interpret (I see a lot of that here now!).

    I've tried all sorts of things (including some things from @ferdinand python code) but just can't seem to get a clean example going. So what I've done in the meantime, is to create a bunch of BitmapButtonCustomGui buttons and replace the TabGroupsBegin() with a normal GroupBegin() and just hide/unhide elements myself. It's not really ideal, as I've had to add a bunch of extra code to make this work, but it does kind of work the way I'm after. A right-click on the project 1 button brings up the project 1 settings menu:

    301e64bd-7e76-4869-8992-95acd43d0745-image.png

    @ferdinand not sure what you want to do with this topic. I'm happy for you to close it if it's easier. But if there is a solution that anyone does have using the standard TabGroupBegin() layout, I'd be really keen on seeing it.

    WP.

    posted in Cinema 4D SDK •
    RE: Right-mouse click on dialog tab

    Hi @ferdinand,

    yep, option 1 was what I was looking at. I have a dynamic series of TabGroupBegin() tabs, and would like to open a context menu on a right-click on them.

    I'd tried catching it in Command(), but it seems you can't test for mouse input there? Doing this inside the Command():

    if(GetInputState(BFM_INPUT_MOUSE,BFM_INPUT_MOUSERIGHT,MB))
    {
    	if(MB.GetLong(BFM_INPUT_VALUE) == 1)
    	{
    		GePrint("Right-click menu found..");
    	}
    	else
    	{
    		GePrint("NOT found.");
    	}
    }
    

    consistently returns "NOT found". I tried sending a Message() from inside Command() to the same dialog but that doesn't do it either. BFM_GETCURSORINFO will occasionally catch it, but you have to fiddle with the mouse to get the right catch.

    Update edit: as an additional attempt, I tried GetItemDim() on the tab, but that returns the entire tab area, not the tab 'button' itself.

    Seems like this is not really possible?

    WP.

    posted in Cinema 4D SDK •
    Right-mouse click on dialog tab

    Hi folks,

    is it possible to weave a way to catch a right-mouse click on a group of dialog tabs? C4D seems to have one when you click on tabs and other dialog-related areas. I'm referring to the menu that has "Undock" etc in it.

    d5d3e696-eea4-42b8-a02c-c86be3e720f8-image.png

    This menu doesn't appear in my dialog, so I'm hoping it means there's space for me to make one. I'd like to initiate a pop-up menu when the user right-clicks on one of the tabs.

    WP.

    posted in Cinema 4D SDK •
    RE: Matrix4

    Thanks @ferdinand,

    I've been trying to remove a matrix math library from my software, but having never been taught any of this before (code that is), I was fumbling around in the dark on how to re-assemble things. But I've managed to end up with a blend of C4D and my own functionality, which is fine.

    The image below probably won't mean much to you, but it tells me it's working correctly again.

    218e9cdd-fa5d-4f09-80b9-c2ddc191eb2a-image.png

    We can probably mark as solved.

    WP.

    posted in Cinema 4D SDK •