/// <summary>
        /// Adds the Shell modifier to the provided node (by handle).
        /// </summary>
        /// <param name="nodeHandle"> Input the node handle to add the modifier to. </param>
        /// <param name="shellAmount"> Input the amount of shell thickness as float. </param>
        /// <returns> Returns 1 if successful or -1 if not. </returns>
        static public int AddOsmShell(uint nodeHandle, float shellAmount)
        {
            try
            {
                IGlobal      global = Autodesk.Max.GlobalInterface.Instance;
                IInterface14 ip     = global.COREInterface14;

                IClass_ID cidOsmShell = global.Class_ID.Create(0x3b9b1a16, 0x6d84e8d0);
                AddOsmModifier(nodeHandle, cidOsmShell);

                IINode    node = ip.GetINodeByHandle(nodeHandle);
                IModifier mod  = GetModifier(node, cidOsmShell);
                if (mod != null)
                {
                    IIParamBlock2 pb = mod.GetParamBlock(0);
                    pb.SetValue(0, 0, shellAmount, 0); // innerAmount parameter is at index zero of the parameter block.
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                return(-1);
            }

            return(1);
        }
        /// <summary>
        /// Adds the Shell modifier to the provided node (by handle).
        /// </summary>
        /// <param name="nodeHandle"> Input the node handle to add the modifier to. </param>
        /// <param name="shellAmount"> Input the amount of shell thickness as float. </param>
        /// <returns> Returns 1 if successful or -1 if not. </returns>
        static public int AddOsmProoptimizer(IINode node, float VertexPercent, bool KeepNormals)
        {
            try
            {
                IGlobal      global = Autodesk.Max.GlobalInterface.Instance;
                IInterface14 ip     = global.COREInterface14;
                int          t      = ip.Time;

                // classID:#(1056067556, 1496462090)
                IClass_ID cidOsmProoptimizer = global.Class_ID.Create(0x3EF24FE4, 0x5932330A);
                AddOsmModifier(node, cidOsmProoptimizer);

                IModifier mod = GetModifier(node, cidOsmProoptimizer);
                if (mod != null)
                {
                    // In order to get the "Calculate" parameter to trigger the modifier to execute, we have to enable some UI elements.
                    ip.CmdPanelOpen = true;      // ensures the command panel in general is open
                    ip.SelectNode(node, true);   // Select the node to make it active
                    ip.CommandPanelTaskMode = 2; // TASK_MODE_MODIFY. This makes the modifier panel active.
                    // Now we can set the parameters on the modifier, and at end "calculate" the results.
                    IIParamBlock2 pb = mod.GetParamBlock(0);
                    pb.SetValue((int)ProOptimizerPBValues.optimizer_main_ratio, t, VertexPercent, 0);
                    pb.SetValue((int)ProOptimizerPBValues.optimizer_options_keep_uv, t, 1, 0);
                    pb.SetValue((int)ProOptimizerPBValues.optimizer_options_keep_normals, t, 0, 0);
                    // There is no true way to know if this was valid/invalid for the mesh, so we check the outer level routine on triobject for changes. **
                    pb.SetValue((int)ProOptimizerPBValues.optimizer_main_calculate, t, 1, 0);
                    ip.ClearNodeSelection(false);
                }
            }
            catch (Exception ex)
            {
                Debug.Print(ex.Message);
                return(-1);
            }

            return(1);
        }
Example #3
0
        public void SetValue(Object value, TimeValue time, int tabIndex)
        {
            switch (Def.def.Type)
            {
            case ParamType2.Index:
            case ParamType2.IndexTab:
            case ParamType2.Int:
            case ParamType2.IntTab:
            case ParamType2.RadiobtnIndex:
            case ParamType2.RadiobtnIndexTab:
                pb.SetValue(id, time, (int)value, tabIndex);
                break;

            case ParamType2.Float:
            case ParamType2.FloatTab:
            case ParamType2.Angle:
            case ParamType2.AngleTab:
            case ParamType2.Double:
            case ParamType2.DoubleTab:
            case ParamType2.World:
            case ParamType2.WorldTab:
            case ParamType2.PcntFrac:
            case ParamType2.PcntFracTab:
            {
                //IParamDimension dimension = parameters.GetParamDimension( parameters.IDtoIndex( this.paramID ) );
                IParamDimension dimension = Def.def.Dim;
                float           result    = pb.GetFloat(id, time, tabIndex);

                try
                {
                    pb.SetValue(id, time, dimension != null ? dimension.UnConvert(Utility.OToF(value)) : Utility.OToF(value), tabIndex);
                }
                // Happens sometimes?
                catch (AccessViolationException)
                {
                    // Plugin.Log(Plugin.LogType.Warning, "Error while using IParamDimension to unconvert value");
                    pb.SetValue(id, time, (float)value, tabIndex);
                }
            }
            break;

            case ParamType2.Bool:
            case ParamType2.BoolTab:
            case ParamType2.Bool2:
                pb.SetValue(id, time, (bool)value ? 1 : 0, tabIndex);
                break;

            case ParamType2.Rgba:
            case ParamType2.RgbaTab:
            case ParamType2.Color:
            case ParamType2.ColorTab:
                pb.SetValue(id, time, (IColor)value, tabIndex);
                break;

            case ParamType2.Frgba:
            case ParamType2.FrgbaTab:
                pb.SetValue(id, time, (IAColor)value, tabIndex);
                break;

            case ParamType2.Point3:
            case ParamType2.Point3Tab:
                pb.SetValue(id, time, value as IPoint3, tabIndex);
                break;

            case ParamType2.Tstr:
            case ParamType2.TstrTab:
            case ParamType2.String:
            case ParamType2.StringTab:
            case ParamType2.Filename:
            case ParamType2.FilenameTab:
            case ParamType2.Name:
            case ParamType2.NameTab:
                // I'm worried about this. What about AssetUser?
                pb.SetValue(id, time, (string)value, tabIndex);
                break;

            default:
                throw new Exception("parameter type " + Type + " is not supported");
            }
        }