Пример #1
0
        override public bool computeOutput(ConnectionPoint connPoint, OutputGenerationParams parms)
        {
            if (!verifyInputConnections())
            {
                return(false);
            }

            if (!gatherInputAndParameters(parms))
            {
                return(false);
            }

            if (!(connPoint.ParamType is FloatParam))
            {
                return(false);
            }

            FloatParam mp = ((FloatParam)(connPoint.ParamType));


            mp.Value = ((float)mRandVal.NextDouble());

            return(true);
        }
Пример #2
0
        protected void generateConnectionPoints()
        {
            List <string> usedDescriptions = new List <string>();

            //try to do this dynamically...
            Type type = GetType();// Get object type

            System.Reflection.PropertyInfo[] pi = type.GetProperties();
            for (int i = 0; i < pi.Length; i++)
            {
                System.Reflection.PropertyInfo prop = pi[i];

                object[] custAttrib = prop.GetCustomAttributes(false);
                if (custAttrib == null)
                {
                    continue;
                }

                ParamType pt  = null;
                Type      ptt = prop.PropertyType;
                if (ptt == typeof(float))
                {
                    pt = new FloatParam();
                }
                else if (ptt == typeof(int))
                {
                    pt = new IntParam();
                }
                else if (ptt == typeof(bool))
                {
                    pt = new BoolParam();
                }
                else if (ptt == typeof(DAGMask))
                {
                    pt = new MaskParam();
                }

                for (int k = 0; k < custAttrib.Length; k++)
                {
                    if (custAttrib[k] is ConnectionType)
                    {
                        ConnectionType ct = custAttrib[k] as ConnectionType;

                        //make sure this connection is unique
                        for (int j = 0; j < usedDescriptions.Count; j++)
                        {
                            if (ct.Description == usedDescriptions[j])
                            {
                                MessageBox.Show(type.FullName + " has already defined a connection value with description " + ct.Description);
                                System.Diagnostics.Debug.Assert(false);
                                return;
                            }
                        }

                        if (ct.ConnType == "Param")
                        {
                            addParamConnectionPoint(pt, ct.Description);
                        }
                        else if (ct.ConnType == "Input")
                        {
                            addInputConnectionPoint(pt, ct.Description, ct.Required);
                        }
                        else if (ct.ConnType == "Output")
                        {
                            addOutputConnectionPoint(pt, ct.Description);
                        }
                        else if (ct.ConnType == "Constraint")
                        {
                            addConstraintConnectionPoint(pt, ct.Description);
                        }
                        else
                        {
                            System.Diagnostics.Debug.Assert(false, "Unrecognized connection type listed for object " + type.FullName);
                        }

                        usedDescriptions.Add(ct.Description);
                        break;
                    }
                }
            }
        }