Announcement

Collapse
No announcement yet.

dotNet C# GammaMgr

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dotNet C# GammaMgr

    Probably that I do that not correctly? I can't control/assign value to GammaMgr.DisplayGamma
    Via MaxScript - no problem, but it is desirable to use whenever possible less MaxscriptSDK.ExecuteMaxscriptCommand...

    Part of code:
    Code:
    if (...)
                    {
                        global.GammaMgr.Enable = (sender as ToggleButton).IsChecked.Value;
                        if ((sender as ToggleButton).IsChecked == true)
                        {
                            IInterface13 Core = global.COREInterface13;
                            IRenderer vrender = Core.GetCurrentRenderer(false);
                            IIParamBlock2 pb2 = vrender.GetParamBlock(11);
    
                            float gval = Convert.ToSingle(this.numCMgamma.Value);
    
                            global.GammaMgr.FileInGamma = global.GammaMgr.DisplayGamma = gval; //Zero attention from 3ds Max - DisplayGamma
                            global.GammaMgr.FileOutGamma = 1.0f;
    
                            pb2.SetValue(265, Core.Time, gval, 0); //colorMapping_gamma
    
                            if (Core.RenderDialogOpen) { Core.UpdateRenderDialogParameters(); }
                        }
                    }
    global.GammaMgr.FileInGamma; global.GammaMgr.FileOutGamma; works Ok
    Regimantas Valiukas
    SIGER STUDIO
    www.sigerstudio.eu

  • #2
    Additional question...
    A half of night I tried to find in what case a problem. Piece of code (not finished):
    Code:
    public static void SetPBValSelNodeColor(IGlobal global, IInterface13 Core, short pid, System.Drawing.Color val, string classname, int pb2Id)
            {
                IINode snode = Core.GetSelNode(0);
                if (snode != null && NodeClassNameIs(Core, snode, classname))
                {
                    IObject objectRef = snode.ObjectRef;
                    IObject baseObj = objectRef.FindBaseObject();
                    IIParamBlock2 pb2 = baseObj.GetParamBlock(pb2Id);
                    IColor col = global.Color.Create((byte)~val.R+1, (byte)~val.G+1, (byte)~val.B+1); // Problem
                    pb2.SetValue(pid, Core.Time, col, 0);
                }
            }
    When I try:
    Code:
    IColor col = global.Color.Create((byte)val.R, (byte)val.G, (byte)val.B);
    to pass parameter Color to ParamBlock2 of VRayPhysicalCamera White Balance - ParamBlock2 WB param receives negative/inverted color.
    Regimantas Valiukas
    SIGER STUDIO
    www.sigerstudio.eu

    Comment


    • #3
      Did you try to use floats for creating the IColor or IAColor? Something like.
      Code:
      IColor col = global.Color.Create((float)val.R/255.0f, (float)val.G/255.0f, (float)val.B/255.0f);
      Best regards,
      Daniel
      Daniel Santana | Co-Founder / Technical Director
      You can do it! VFX
      Lisbon/Porto - Portugal
      http://www.ycdivfx.com

      Comment


      • #4
        Originally posted by dgsantana View Post
        Did you try to use floats for creating the IColor or IAColor? Something like.
        Code:
        IColor col = global.Color.Create((float)val.R/255.0f, (float)val.G/255.0f, (float)val.B/255.0f);
        Best regards,
        Daniel
        Many Thanks, Daniel! Your solution work properly!
        At the same I share the reverse conversion (IColor to System.Drawing.Color):
        Code:
        public static System.Drawing.Color GetPBValSelNodeColor(IInterface13 Core, short pid, string classname, int pb2Id) // Get Color Value from BP2(Id)
                {
                    IINode snode = Core.GetSelNode(0);
                    System.Drawing.Color cval = System.Drawing.Color.White;
                    if (snode != null && NodeClassNameIs(Core, snode, classname))
                    {
                        IObject objectRef = snode.ObjectRef;
                        IObject baseObj = objectRef.FindBaseObject();
                        IIParamBlock2 pb2 = baseObj.GetParamBlock(pb2Id);
                        IColor icval = pb2.GetColor(pid, Core.Time, 0);
        
                        double c1Rne = Math.Max(0.0f, Math.Min(1.0f, icval.R)); // Force that icval.R really is 0 <= icval.R <= 1 to avoid incorrect behaviour due to rounding errors
                        int c1R = (int)Math.Floor(c1Rne == 1.0f ? 255 : c1Rne * 256.0f);
        
                        double c1Gne = Math.Max(0.0f, Math.Min(1.0f, icval.G)); // Force that icval.G really is 0 <= icval.G <= 1 to avoid incorrect behaviour due to rounding errors
                        int c1G = (int)Math.Floor(c1Gne == 1.0f ? 255 : c1Gne * 256.0f);
        
                        double c1Bne = Math.Max(0.0f, Math.Min(1.0f, icval.B)); // Force that icval.B really is 0 <= icval.B <= 1 to avoid incorrect behaviour due to rounding errors
                        int c1B = (int)Math.Floor(c1Bne == 1.0f ? 255 : c1Bne * 256.0f);
        
                        cval = System.Drawing.Color.FromArgb(c1R, c1G, c1B);
                    }
                    return cval;
                }
        Last edited by Siger; 03-07-2014, 06:35 PM.
        Regimantas Valiukas
        SIGER STUDIO
        www.sigerstudio.eu

        Comment

        Working...
        X