Esempio n. 1
0
        internal static SukiSchema CreateSchema(SukiSchemaInfo info)
        {
            SukiSchema ret = null;

            switch (info.SchemaMetric)
            {
            case NodeMetric.SingleNodePosition:
                ret = new SingleNodePositionSchema(info);
                break;

            case NodeMetric.SingleJointAngle:
                ret = new SingleJointAngleSchema(info);
                break;

            case NodeMetric.MultiNodeVectorBetween:
                ret = new MultiNodeVectorBetweenSchema(info);
                break;

            case NodeMetric.MultiNodeAngleBetween:
                ret = new MultiNodeAngleBetweenSchema(info);
                break;

            default:
                throw new System.Exception("Invalid Schem Node Metric");
            }
            return(ret);
        }
Esempio n. 2
0
        protected override void Setup(SukiSchemaInfo info)
        {
            if (info.SchemaMetric != NodeMetric.SingleJointAngle)
            {
                throw new System.Exception("Schema does not match node metric.");
            }
            if (null == info.BodyAngles || info.BodyAngles.Count != 1)
            {
                throw new System.Exception("SingleJointAngleSchema requires one angle.");
            }
            target = info.BodyAngles[0];

            base.Setup(info);
        }
Esempio n. 3
0
        protected override void Setup(SukiSchemaInfo info)
        {
            if (info.SchemaMetric != NodeMetric.MultiNodeVectorBetween)
            {
                throw new System.Exception("Schema does not match node metric.");
            }
            if (null == info.BodyNodes || info.BodyNodes.Count != 2)
            {
                throw new System.Exception("MultiNodeVectorBetweenSchema requires two nodes.");
            }
            first  = info.BodyNodes[0];
            second = info.BodyNodes[1];

            base.Setup(info);
        }
Esempio n. 4
0
        /*  public void ReadConfigFiles()
         * {
         *    List<string> schemaFiles = SukiSchemaList.Instance.GetAllSchemaFiles();
         *    if (schemaFiles.Count <= 0)
         *    {
         *        //				throw new System.Exception("No Schema Files specified");
         *
         *        print("No Schema Files specified.  Loading default.");
         *        schemaFiles.Add("suki/default.suki.json");
         *    }
         *    foreach (string filename in schemaFiles)
         *        {
         *        Debug.Log("Loading SUKI JSON file: " + filename);
         *        string json = File.ReadAllText(filename);
         *        SukiSchemaInfo newSchemaInfo = SukiSchemaInfo.Deserialize(json);
         *        SukiSchema newSchema = SukiSchema.CreateSchema(newSchemaInfo);
         *        schemas.Add(newSchema);
         *        }
         * }*/


        public void ReadConfigFiles()
        {
            List <string> schemaFiles = SukiSchemaList.Instance.GetAllSchemaFiles();

            if (schemaFiles.Count <= 0)
            {
                print("No Schema Files specified.  Loading default.");
                //                    string defaultSuki = "suki/default.suki";//has to be json, so this doesn't work.
                string defaultSuki = Application.streamingAssetsPath + "/Suki/default.suki";
                SukiSchemaList.Instance.AddFile(defaultSuki);
                schemaFiles = SukiSchemaList.Instance.GetAllSchemaFiles();
                //sukiParam = ((GenericParameter<string>)ParameterHandler.Instance.AllParameters[0].GetParameter(ParameterStrings.SUKI_PARAM_FILE));
            }
            foreach (string filename in schemaFiles)
            {
                Debug.Log("Loading SUKI JSON file: " + filename);
                string json;

                string url;
                url = filename;
                url = url.Replace('\\', '/');
                //#if !UNITY_ANDROID || UNITY_EDITOR
                if (Application.platform != RuntimePlatform.Android)
                {
                    Debug.Log("Not Android Platform: adding file:// to url.");
                    url = "file://" + url;
                }
                //#endif
                string sukitext;
                Debug.Log("suki json url=" + url);
                WWW localFile = GetWWW(url);
                json = localFile.text;
                Debug.Log("sukifile=" + json);


                //json = File.ReadAllText(filename);
                SukiSchemaInfo newSchemaInfo = SukiSchemaInfo.Deserialize(json);
                SukiSchema     newSchema     = SukiSchema.CreateSchema(newSchemaInfo);
                schemas.Add(newSchema);
            }
        }
Esempio n. 5
0
 internal MultiNodeAngleBetweenSchema(SukiSchemaInfo info) : base(info)
 {
 }
Esempio n. 6
0
 internal MultiNodeVectorBetweenSchema(SukiSchemaInfo info) : base(info)
 {
 }
Esempio n. 7
0
 internal SingleJointAngleSchema(SukiSchemaInfo info) : base(info)
 {
 }
Esempio n. 8
0
 internal SingleNodePositionSchema(SukiSchemaInfo info) : base(info)
 {
 }
Esempio n. 9
0
        protected virtual void Setup(SukiSchemaInfo info)
        {
            _id        = info._id;
            name       = info.SchemaName;
            resolution = info.SchemaResolution;
            device     = info.SchemaDevice;
            metric     = info.SchemaMetric;

            if (null != info.CalculationInfo)
            {
                SetCalculationFunction(info.CalculationInfo.calculationOperator, info.CalculationInfo.vectorOperand);
            }
            if (null != info.ReductionInfo)
            {
                SetReductionFunction(info.ReductionInfo.reductionOperator, info.ReductionInfo.vectorOperand);
            }
            if (null != info.ConditionInfo)
            {
                SetConditionFunction(info.ConditionInfo.conditionOperator, info.ConditionInfo.scalarOperand, info.ConditionInfo.extentPercentage);
            }
            if (null != info.FloatBoundsInfo)
            {
                SetFloatBoundsFunction(info.FloatBoundsInfo.lowBounds, info.FloatBoundsInfo.highBounds, info.FloatBoundsInfo.useExtents, info.FloatBoundsInfo.reverse);
            }
            if (null != info.Vector2BoundsInfo)
            {
                SetVector2BoundsFunction(info.Vector2BoundsInfo.lowBounds, info.Vector2BoundsInfo.highBounds, info.Vector2BoundsInfo.useExtents, info.Vector2BoundsInfo.reverse);
            }
            if (null != info.Vector3BoundsInfo)
            {
                SetVector3BoundsFunction(info.Vector3BoundsInfo.lowBounds, info.Vector3BoundsInfo.highBounds);
            }

            switch (info.SchemaResolution)
            {
            case InputResolution.Trigger:
                data.CreateTrigger(name, false);
                break;

            case InputResolution.Signal:
                data.CreateSignal(name, false);
                break;

            case InputResolution.Range:
                data.CreateRange(name, 0.5f);
                break;

            case InputResolution.Location2D:
                data.CreateLocation2D(name, Vector2.zero);
                break;

            case InputResolution.Location3D:
                data.CreateLocation3D(name, Vector3.zero);
                break;

            default:
                throw new System.Exception("Invalid Schema Resolution");
            }

            GetSchemaExtentsFromServer();
        }
Esempio n. 10
0
 internal SukiSchema(SukiSchemaInfo info)
     : this()
 {
     Setup(info);
 }