コード例 #1
0
ファイル: MainState.cs プロジェクト: ezhangle/synthesis
        /// <summary>
        /// Loads the field from a given directory
        /// </summary>
        /// <param name="directory">field directory</param>
        /// <returns>whether the process was successful</returns>
        bool LoadField(string directory)
        {
            fieldPath = directory;

            fieldObject = new GameObject("Field");

            FieldDefinition.Factory = delegate(Guid guid, string name)
            {
                return(new UnityFieldDefinition(guid, name));
            };

            if (!File.Exists(directory + "\\definition.bxdf"))
            {
                return(false);
            }

            FieldDataHandler.Load(fieldPath);
            Controls.Init();

            string loadResult;

            fieldDefinition = (UnityFieldDefinition)BXDFProperties.ReadProperties(directory + "\\definition.bxdf", out loadResult);
            Debug.Log(loadResult);
            fieldDefinition.CreateTransform(fieldObject.transform);
            return(fieldDefinition.CreateMesh(directory + "\\mesh.bxda"));
        }
コード例 #2
0
    /// <summary>
    /// Loads the field from a given directory
    /// </summary>
    /// <param name="directory">field directory</param>
    /// <returns>whether the process was successful</returns>
    public static bool LoadField(string directory = null)
    {
        string               fieldPath;
        GameObject           fieldObject;
        UnityFieldDefinition fieldDefinition;

        if (directory == null)
        {
            directory = PlayerPrefs.GetString("simSelectedField");
        }

        fieldPath = directory;

        fieldObject = new GameObject("Field");

        FieldDefinition.Factory = delegate(Guid guid, string name)
        {
            return(new UnityFieldDefinition(guid, name));
        };

        string loadResult;

        fieldDefinition = (UnityFieldDefinition)BXDFProperties.ReadProperties(directory + "\\definition.bxdf", out loadResult);
        Debug.Log(loadResult);
        fieldDefinition.CreateTransform(fieldObject.transform);

        return(fieldDefinition.CreateMesh(directory + "\\mesh.bxda"));
    }
コード例 #3
0
ファイル: MatchManager.cs プロジェクト: ezhangle/synthesis
        public void UpdateFieldGuid()
        {
            if (fieldGuid.Length > 0)
            {
                return;
            }

            string fieldFile = PlayerPrefs.GetString("simSelectedField") + "\\definition.bxdf";

            if (!File.Exists(fieldFile))
            {
                CancelSync();
                return;
            }

            Task <FieldDefinition> loadingTask = new Task <FieldDefinition>(() => BXDFProperties.ReadProperties(fieldFile));

            loadingTask.ContinueWith(t =>
            {
                if (t.Result == null)
                {
                    CancelSync();
                    return;
                }

                fieldGuid = t.Result.GUID.ToString();
            });

            loadingTask.Start();
        }
コード例 #4
0
        /// <summary>
        /// Creates a new BulletFieldDefinition from a set of .bxda and .bxdf files
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static BulletFieldDefinition FromFile(string path)
        {
            Factory = delegate(Guid guid, string name) { return(new BulletFieldDefinition(guid, name)); };
            BulletFieldDefinition toReturn = (BulletFieldDefinition)BXDFProperties.ReadProperties(path + "definition.bxdf");

            toReturn.CreateMesh(path + "mesh.bxda");
            return(toReturn);
        }
コード例 #5
0
ファイル: PlayerIdentity.cs プロジェクト: ezhangle/synthesis
        /// <summary>
        /// Checks if the resources held by the other identity need to be transferred to
        /// this instance.
        /// </summary>
        public void CheckDependencies()
        {
            ReceivedFiles.Clear();
            dependencyCount = 0;

            List <int> unresolvedDependencies = new List <int>();

            RobotFolder = PlayerPrefs.GetString("simSelectedRobot");

            foreach (PlayerIdentity otherIdentity in FindObjectsOfType <PlayerIdentity>().Where(p => p.id != id))
            {
                string robotsDirectory = PlayerPrefs.GetString("RobotDirectory");
                otherIdentity.RobotFolder = string.Empty;

                foreach (string dir in Directory.GetDirectories(robotsDirectory, otherIdentity.robotName))
                {
                    RigidNode_Base root = BXDJSkeleton.ReadSkeleton(dir + "\\skeleton.bxdj");

                    if (root.GUID.ToString().Equals(otherIdentity.robotGuid))
                    {
                        otherIdentity.RobotFolder = dir;
                        break;
                    }
                }

                if (otherIdentity.RobotFolder.Length == 0)
                {
                    unresolvedDependencies.Add(otherIdentity.id);
                    otherIdentity.RobotFolder = robotsDirectory + "\\" + otherIdentity.robotName;
                }
            }

            string fieldsDirectory = PlayerPrefs.GetString("FieldDirectory");

            MatchManager.Instance.FieldFolder = string.Empty;

            foreach (string dir in Directory.GetDirectories(fieldsDirectory, MatchManager.Instance.FieldName))
            {
                FieldDefinition definition = BXDFProperties.ReadProperties(dir + "\\definition.bxdf");

                if (definition.GUID.ToString().Equals(MatchManager.Instance.FieldGuid))
                {
                    MatchManager.Instance.FieldFolder = dir;
                    break;
                }
            }

            if (MatchManager.Instance.FieldFolder.Length == 0)
            {
                unresolvedDependencies.Add(-1);
                MatchManager.Instance.FieldFolder = fieldsDirectory + "\\" + MatchManager.Instance.FieldName;
            }

            CmdAddDependencies(unresolvedDependencies.ToArray());
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: aaroncohen73/synthesis
    bool LoadField(string directory)
    {
        fieldObject = new GameObject("Field");

        FieldDefinition.Factory = delegate(Guid guid, string name)
        {
            return(new UnityFieldDefinition(guid, name));
        };

        string loadResult;

        fieldDefinition = (UnityFieldDefinition)BXDFProperties.ReadProperties(directory + "\\definition.bxdf", out loadResult);
        Debug.Log(loadResult);
        fieldDefinition.CreateTransform(fieldObject.transform);
        return(fieldDefinition.CreateMesh(directory + "\\mesh.bxda"));
    }
コード例 #7
0
ファイル: MainWindow.cs プロジェクト: xiaodelea/synthesis
        /// <summary>
        /// Exports the BXDF and BXDA files.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Exporter_DoWork(object sender, DoWorkEventArgs e)
        {
            if (FilePathTextBox.Text.Length == 0 || FileNameTextBox.Text.Length == 0 || FileNameTextBox.Text.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) >= 0)
            {
                e.Result = "Invalid Export Parameters.";
                return;
            }

            FieldDefinition fieldDefinition = new FieldDefinition(FileNameTextBox.Text);
            SurfaceExporter exporter        = new SurfaceExporter();

            ComponentOccurrencesEnumerator componentOccurrences = ((AssemblyDocument)Program.INVENTOR_APPLICATION.ActiveDocument).ComponentDefinition.Occurrences.AllLeafOccurrences;

            for (int i = 0; i < componentOccurrences.Count; i++)
            {
                progressWindow.Invoke(new Action(() =>
                {
                    progressWindow.ProcessInfoLabel.Text    = "Exporting: " + (Math.Round((i / (float)componentOccurrences.Count) * 100.0f, 2)).ToString() + "%";
                    progressWindow.ProcessProgressBar.Value = i;
                }));

                if (componentOccurrences[i + 1].Visible)
                {
                    exporter.Reset();
                    exporter.Export(componentOccurrences[i + 1], false, true); // Index starts at 1?

                    BXDAMesh output = exporter.GetOutput();

                    FieldNode outputNode = new FieldNode(componentOccurrences[i + 1].Name,
                                                         CollisionObjectsView.Nodes.Find(componentOccurrences[i + 1].Name, true).Length > 0 ?
                                                         FieldNodeCollisionType.MESH : FieldNodeCollisionType.NONE);

                    outputNode.AddSubMeshes(output);

                    fieldDefinition.AddChild(outputNode);
                }
            }

            BXDFProperties.WriteProperties(FilePathTextBox.Text + "\\" + FileNameTextBox.Text + ".bxdf", fieldDefinition);

            fieldDefinition.CreateMesh();
            fieldDefinition.GetMeshOutput().WriteToFile(FilePathTextBox.Text + "\\" + FileNameTextBox.Text + ".bxda");

            FieldDefinition_Base copyDefinition = BXDFProperties.ReadProperties(FilePathTextBox.Text + "\\" + FileNameTextBox.Text + ".bxdf");

            e.Result = "Export Successful!";
        }
コード例 #8
0
ファイル: Init.cs プロジェクト: solomondg/synthesis
    private void TryLoadField()
    {
        activeField = new GameObject("Field");

        FieldDefinition.Factory = delegate(Guid guid, string name)
        {
            return(new UnityFieldDefinition(guid, name));
        };

        Debug.Log(filePath);
        string loadResult;

        field = (UnityFieldDefinition)BXDFProperties.ReadProperties(filePath + "definition.bxdf", out loadResult);
        Debug.Log(loadResult);
        field.CreateTransform(activeField.transform);
        fieldLoaded = field.CreateMesh(filePath + "mesh.bxda");
    }
コード例 #9
0
    private void TryLoadField()
    {
        activeField = new GameObject("Field");

        FieldDefinition.Factory = delegate(Guid guid, string name)
        {
            return(new UnityFieldDefinition(guid, name));
        };
        try
        {
            string loadResult;
            UnityFieldDefinition field = (UnityFieldDefinition)BXDFProperties.ReadProperties(Application.dataPath + "//resources//ConfigurationEnvironment//definition.bxdf", out loadResult);
            Debug.Log(loadResult);
            field.CreateTransform(activeField.transform);
            bool fieldLoaded = field.CreateMesh(Application.dataPath + "//resources//ConfigurationEnvironment//mesh.bxda");
        }
        catch
        {
            Debug.Log("Field loading failed!");
        }
    }
コード例 #10
0
        /// <summary>
        /// Loads the field from a given directory
        /// </summary>
        /// <param name="directory">field directory</param>
        /// <returns>whether the process was successful</returns>
        bool LoadField(string directory)
        {
            if (string.IsNullOrEmpty(directory))
            {
                UserMessageManager.Dispatch("Field not found", 7);
            }
            fieldPath = directory;

            fieldObject = new GameObject("Field");

            FieldDefinition.Factory = delegate(Guid guid, string name)
            {
                return(new UnityFieldDefinition(guid, name));
            };

            bool isEmptyGrid = directory == "" || new DirectoryInfo(directory).Name == UnityFieldDefinition.EmptyGridName;

            if (!File.Exists(directory + Path.DirectorySeparatorChar + "definition.bxdf") && !isEmptyGrid)
            {
                return(false);
            }

            FieldDataHandler.LoadFieldMetaData(fieldPath);

            Controls.Load();
            Controls.UpdateFieldControls();
            if (!Controls.HasBeenSaved())
            {
                Controls.Save(true);
            }

            if (isEmptyGrid)
            {
                return(true);
            }
            fieldDefinition = (UnityFieldDefinition)BXDFProperties.ReadProperties(directory + Path.DirectorySeparatorChar + "definition.bxdf", out string loadResult);
            // Debug.Log("Field load result: " + loadResult);
            fieldDefinition.CreateTransform(fieldObject.transform);
            return(fieldDefinition.CreateMesh(directory + Path.DirectorySeparatorChar + "mesh.bxda"));
        }