//=================================================================== //=================================================================== public override void ProcessParametersString(string parametersString) { string[] parameters = parametersString.Split(','); ParameterGroup grainParameters = new ParameterGroup(parameters); amplitudeRange = grainParameters.GetRange("Amplitude"); frequencyRange = grainParameters.GetRange("Frequency"); lacunarityRange = grainParameters.GetRange("Lacunarity"); octaveCountRange = grainParameters.GetRange("OctaveCount"); persistenceRange = grainParameters.GetRange("Persistence"); resizeType = grainParameters.getEnum <ResizeType>("ResizeType"); if (parameters.Length > 6) { seed = grainParameters.getInteger("Seed"); } else { seed = Mathf.RoundToInt(Random.value * 1000000); } }
//=================================================================== //=================================================================== public void LoadConfigurationFile() { string folderPath = FileOperations.GetApplicationDirectory(); string parameterFilePath = folderPath + configFileName; //uiText.GetComponent<UnityEngine.UI.Text>().text = parameterFilePath; ParameterGroup configFile = new ParameterGroup(parameterFilePath); // Project projectNotes = configFile.getString("Notes"); // Container containerType = configFile.getEnum <ContainerType>("Container Type"); ContainerScale = configFile.getVector3("Container Scale"); containerDynamicFriction = configFile.getFloat("Container Dynamic Friction"); containerStaticFriction = configFile.getFloat("Container Static Friction"); containerBounciness = configFile.getFloat("Container Bounciness"); modifyScaleAutomatically = configFile.getBoolean("Modify Scale Automatically"); bufferLength = configFile.getFloat("Buffer Length"); estimatedPorosity = configFile.getFloat("Estimated Porosity"); // Simulation FixedDeltaTime = configFile.getFloat("Fixed Delta Time"); SolverIterationCount = configFile.getInteger("Solver Iteration Count"); velocitySolverIterationCount = configFile.getInteger("Velocity Solver Iteration Count"); SleepThreshold = configFile.getFloat("Sleep Threshold"); BounceThreshold = configFile.getFloat("Bounce Threashold"); TimeScale = configFile.getFloat("Time Scale"); TargetFrameRate = configFile.getInteger("Target Frame Rate"); contactOffset = configFile.getFloat("Contact Offset"); // Shaking shakeTransversly = configFile.getBoolean("Shake Transversly"); shakeRotationaly = configFile.getBoolean("Shake Rotationally"); stabilizeCamera = configFile.getBoolean("Stabilize Camera"); ShakingFraction = configFile.getFloat("Shaking Fracton"); ShakingRotationFraction = configFile.getFloat("Shaking Roation Fraction"); // Folder projectFolderPath = configFile.getString("Project Folder Path"); pdfFolderName = configFile.getString("PDF Folder Name"); saveFolderName = configFile.getString("Save Folder Name"); createNewFolderAutomatically = configFile.getBoolean("Create New Folder Automatically"); overrideOutputFolder = configFile.getBoolean("Override Output Folder"); // Particle Groups useVolumeProportion = configFile.getBoolean("Use Volume Proportion"); grainCountGoal = configFile.getInteger("Grain Count Goal"); int nbeds = configFile.getInteger("Number of Beds"); beds = new Bed[nbeds]; for (int bedNumber = 0; bedNumber < nbeds; bedNumber++) { int bedNumberOne = bedNumber + 1; beds[bedNumber] = new Bed(); beds[bedNumber].bedName = configFile.getString("Bed " + bedNumberOne + " Name"); beds[bedNumber].proportion = configFile.getFloat("Bed " + bedNumberOne + " Proportion"); beds[bedNumber].waitAfterDepostion = configFile.getInteger("Bed " + bedNumberOne + " Wait After Deposition"); beds[bedNumber].cementAfterDeposition = configFile.getBoolean("Bed " + bedNumberOne + " Cement After Deposition"); beds[bedNumber].disappearAfterDeposition = configFile.getBoolean("Bed " + bedNumberOne + " Disappear After Deposition"); int nGrainGroups = configFile.getInteger("Bed " + bedNumberOne + " Number of Grains"); if (nGrainGroups > 0) { Grain[] grains = new Grain[nGrainGroups]; for (int grainGroupNumber = 0; grainGroupNumber < nGrainGroups; grainGroupNumber++) { int grainGroupNumberOne = grainGroupNumber + 1; grains[grainGroupNumber] = new Grain(); grains[grainGroupNumber].grainName = configFile.getString("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Name"); grains[grainGroupNumber].Type = configFile.getEnum <Grain.GrainType>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Type"); grains[grainGroupNumber].parameters = configFile.getString("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Parameters"); grains[grainGroupNumber].PDF = configFile.getString("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " PDF"); grains[grainGroupNumber].PDFMultiplier = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " PDF Multiplier"); grains[grainGroupNumber].PDFOffset = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " PDF Offset"); grains[grainGroupNumber].density = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Density"); grains[grainGroupNumber].exactVerticalCreation = configFile.getBoolean("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Disappear At Bottom"); grains[grainGroupNumber].disappearAtBottom = configFile.getBoolean("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Exact Vertical Creation"); grains[grainGroupNumber].proportion = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Proportion"); grains[grainGroupNumber].depostionType = configFile.getEnum <Grain.DepostionType>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Deposition Type"); grains[grainGroupNumber].dynamicFriction = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Dynamic Friction"); grains[grainGroupNumber].staticFriction = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Static Friction"); grains[grainGroupNumber].bounciness = configFile.getFloat("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Bounciness"); grains[grainGroupNumber].frictionCombine = configFile.getEnum <PhysicMaterialCombine>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Friction Combine"); grains[grainGroupNumber].bounceCombine = configFile.getEnum <PhysicMaterialCombine>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Bounce Combine"); grains[grainGroupNumber].colorType = configFile.getEnum <Grain.GrainColorType>("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Color Type"); grains[grainGroupNumber].baseColor = configFile.getColor("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Base Color"); grains[grainGroupNumber].secondaryColor = configFile.getColor("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Secondary Color"); grains[grainGroupNumber].scale = configFile.getVector3("Bed " + bedNumberOne + " Grain " + grainGroupNumberOne + " Scale"); } beds[bedNumber].grains = grains; } } // Deposition automaticDepostion = configFile.getBoolean("Automatic Deposition"); depostionRatePerSec = configFile.getFloat("Deposition Rate Per Sec"); // Saving saveRockAutomatically = configFile.getBoolean("Save Rock Automatically"); saveDataFile = configFile.getBoolean("Save Data File"); saveRockFile = configFile.getBoolean("Save Rock File"); saveGrainsFile = configFile.getBoolean("Save Grains File"); exitAutomatically = configFile.getBoolean("Exit Automatically"); }