Exemple #1
0
        private void Configure()
        {
#if AGXUNITY_UPDATING
            throw new AGXUnity.Exception("AGX Dynamics for Unity is updating and AGX Dynamics " +
                                         "binaries shouldn't be loaded into the process.");
#else
            if (Application.isEditor)
            {
                // This case is handled by AGXUnityEditor.Manager.
            }
            // Running build with environment set. Use default environment setup.
            // This can be useful to debug an application, being able to attach
            // to a process with AGX Dynamics + AGXUnity.
            else if (IO.Environment.IsSet(IO.Environment.Variable.AGX_DEPENDENCIES_DIR))
            {
            }
            // Running build without environment, assuming all binaries are
            // present in this process. Setup RUNTIME_PATH to Components in
            // the data agx directory. RESOURCE_PATH is where the license
            // file is assumed to be located.
            else
            {
                var dataPath           = Application.dataPath;
                var dataPluginsPath    = IO.Environment.GetPlayerPluginPath(dataPath);
                var dataAGXRuntimePath = IO.Environment.GetPlayerAGXRuntimePath(dataPath);

                IO.Environment.AddToPath(dataPluginsPath);

                var envInstance = agxIO.Environment.instance();

                // In case of installed AGX Dynamics, agxIO.Environment.instance() will
                // read data from the registry and add runtime and resource paths to
                // the installed version. Clear all, from registry, added paths since
                // we assume all data needed is present in this runtime.
                for (int i = 0; i < (int)agxIO.Environment.Type.NUM_TYPES; ++i)
                {
                    envInstance.getFilePath((agxIO.Environment.Type)i).clear();
                }

                envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(".");
                envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(dataPath);
                envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(dataPluginsPath);
                envInstance.getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(dataAGXRuntimePath);
                envInstance.getFilePath(agxIO.Environment.Type.RUNTIME_PATH).pushbackPath(dataAGXRuntimePath);

                if (string.IsNullOrEmpty(envInstance.findComponent("Referenced.agxEntity")))
                {
                    throw new AGXUnity.Exception("Unable to find Components directory in RUNTIME_PATH.");
                }
            }

            agx.agxSWIG.setEntityCreationThreadSafe(true);

            m_ai = new agx.AutoInit();

            agx.agxSWIG.setNumThreads(4);

            Initialized = true;
#endif
        }
Exemple #2
0
        private void ConfigureAgX()
        {
            string binaryPath = FindBinaryPath();

            // Check if agxDotNet.dll is in path.
            if (!ExistInPath("agxDotNet.dll"))
            {
                // If it is not in path, lets look in the registry
                binaryPath = FindRuntimePathFromRegistry();

                // If no luck, then we need to bail out
                if (binaryPath.Length == 0)
                {
                    throw new AgXUnity.Exception("Unable to find agxDotNet.dll - part of the AgX installation.");
                }
                else
                {
                    AddToPath(binaryPath);
                }
            }

            string pluginPath = binaryPath + @"\plugins";
            string dataPath   = binaryPath + @"\data";
            string cfgPath    = dataPath + @"\cfg";

            try {
                // Components are initialized in parallel and destroy is executed
                // from other worker threads. Enable local entity storages.
                agx.agxSWIG.setEntityCreationThreadSafe(true);

                m_ai = new agx.AutoInit();

                agx.Thread.registerAsAgxThread();

                agx.agxSWIG.setNumThreads(4);

                agxIO.Environment.instance().getFilePath(agxIO.Environment.Type.RUNTIME_PATH).pushbackPath(binaryPath);
                agxIO.Environment.instance().getFilePath(agxIO.Environment.Type.RUNTIME_PATH).pushbackPath(pluginPath);

                agxIO.Environment.instance().getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(binaryPath);
                agxIO.Environment.instance().getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(pluginPath);
                agxIO.Environment.instance().getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(dataPath);
                agxIO.Environment.instance().getFilePath(agxIO.Environment.Type.RESOURCE_PATH).pushbackPath(cfgPath);
            }
            catch (System.Exception e) {
                throw new AgXUnity.Exception("Unable to instantiate first AgX object. Some dependencies seems missing: " + e.ToString());
            }
        }