コード例 #1
0
        private void ApplyConfiguration(Importer importer, Property.Data data)
        {
            switch (data.propertyCategory)
            {
            case Property.Category.General_Options:
                switch (data.customOption)
                {
                case Property.SelfDefinedOption.ACTIVATE_LOGGING:
                    bool?activate_logging = Property.Data.GetBool(data);

                    if (activate_logging.HasValue && activate_logging.Value)
                    {
                        importer.Assimp.SetLogFile("import.log");
                    }

                    break;

                case Property.SelfDefinedOption.NONE:
                    ApplyAssimpConfiguration(importer, data);
                    break;
                }

                break;

            case Property.Category.Preprocess_Steps:
            case Property.Category.Extension_Related_Options:
                ApplyAssimpConfiguration(importer, data);
                break;
            }
        }
コード例 #2
0
        private aiPostProcessSteps GetFlags(Property.Data data)
        {
            aiPostProcessSteps flags = (aiPostProcessSteps)0;

            // Is the option related to an assimp property or the activation
            if (data.isStepFlag)
            {
                flags = (aiPostProcessSteps)Flags.Toogle((int)flags, (int)data.processStep, Convert.ToBoolean(data.currentValue));
            }

            return(flags);
        }
コード例 #3
0
 private void Save(Property.Data data)
 {
     if (data.customOption != Property.SelfDefinedOption.NONE)
     {
         PlayerPrefs.SetString(Enum.GetName(typeof(Property.SelfDefinedOption), data.customOption), data.currentValue);
     }
     else if (data.processStep != 0)
     {
         PlayerPrefs.SetString(Enum.GetName(typeof(aiPostProcessSteps), data.processStep), data.currentValue);
     }
     else if (data.propertyFlag.Length != 0)
     {
         PlayerPrefs.SetString(data.propertyFlag, data.currentValue);
     }
 }
コード例 #4
0
        private bool SetFlags(Property.Data data, aiPostProcessSteps flags)
        {
            bool set = false;

            // Is the option related to an assimp property or the activation
            if (data.isStepFlag)
            {
                string value = Flags.IsSet((int)flags, (int)data.processStep).ToString();

                if (data.currentValue.CompareTo(value) != 0)
                {
                    data.currentValue = value;

                    set = true;
                }
            }

            return(set);
        }
コード例 #5
0
        private void ApplyAssimpConfiguration(Importer importer, Property.Data data)
        {
            if (data.isStepFlag)
            {
                bool value_step;

                if (Boolean.TryParse(data.currentValue, out value_step))
                {
                    importer.Assimp.ChangeFlag(data.processStep, value_step);
                }
            }
            else
            {
                switch (data.propertyType)
                {
                case Property.Type.BOOL:
                    bool?value_bool = Property.Data.GetBool(data);

                    if (value_bool.HasValue)
                    {
                        importer.Assimp.SetProperty(data.propertyFlag, value_bool.Value);
                    }

                    break;

                case Property.Type.FLAG:
                case Property.Type.INT:
                    int?value_int = Property.Data.GetInt(data);

                    if (value_int.HasValue)
                    {
                        importer.Assimp.SetProperty(data.propertyFlag, value_int.Value);
                    }

                    break;

                case Property.Type.FLOAT:
                    float?value_float = Property.Data.GetFloat(data);

                    if (value_float.HasValue)
                    {
                        importer.Assimp.SetProperty(data.propertyFlag, value_float.Value);
                    }

                    break;

                case Property.Type.STRING:
                    importer.Assimp.SetProperty(data.propertyFlag, data.currentValue);

                    break;

                case Property.Type.MATRIX:
                    const int size = 9;

                    List <string> values_matrix_str = UI.List.Parse(data.currentValue);

                    if (values_matrix_str.Count == size)
                    {
                        float[] value_matrix = new float[size];

                        for (int i = 0; i < size; i++)
                        {
                            if (!float.TryParse(values_matrix_str[i], out value_matrix[i]))
                            {
                                Debug.LogWarning("Invalid value \"" + data.optionText + " = " + values_matrix_str[i] + "\": should be a float.");
                            }
                        }

                        Vector3    pos = new Vector3(value_matrix[0], value_matrix[1], value_matrix[2]);
                        Quaternion rot = new Quaternion();
                        rot.eulerAngles = new Vector3(value_matrix[3], value_matrix[4], value_matrix[5]);
                        Vector3 scale = new Vector3(value_matrix[6], value_matrix[7], value_matrix[8]);

                        using (aiVector3D scaling = Type.Assimp.Convert.UnityToAssimp.Vector3(scale))
                        {
                            using (aiQuaternion rotation = Type.Assimp.Convert.UnityToAssimp.Quaternion(rot))
                            {
                                using (aiVector3D position = Type.Assimp.Convert.UnityToAssimp.Vector3(pos))
                                {
                                    using (aiMatrix4x4 matrix = new aiMatrix4x4(scaling, rotation, position))
                                    {
                                        importer.Assimp.SetProperty(data.propertyFlag, matrix);
                                    }
                                }
                            }
                        }
                    }

                    break;

                default:
                    break;
                }
            }
        }