예제 #1
0
 // Update is called once per frame
 void Update()
 {
     if (PluginFunctions.arwGetError() != 0)
     {
         JLogErr("NDK ARToolkit Has errcode: " + PluginFunctions.arwGetError());
     }
 }
예제 #2
0
    // We use Update() here, but be aware that unless ARController has been configured to
    // execute first (Unity Editor->Edit->Project Settings->Script Execution Order) then
    // state produced by this update may lag by one frame.
    void Update()
    {
        float[] matrixRawArray = new float[16];

        //ARController.Log(LogTag + "ARMarker.Update()");
        if (UID == NO_ID || !PluginFunctions.inited)
        {
            visible = false;
            return;
        }

        // Query visibility if we are running in the Player.
        if (Application.isPlaying)
        {
            visible = PluginFunctions.arwQueryMarkerTransformation(UID, matrixRawArray);
            //ARController.Log(LogTag + "ARMarker.Update() UID=" + UID + ", visible=" + visible);

            if (visible)
            {
                matrixRawArray[12] *= 0.001f;                 // Scale the position from ARToolKit units (mm) into Unity units (m).
                matrixRawArray[13] *= 0.001f;
                matrixRawArray[14] *= 0.001f;

                Matrix4x4 matrixRaw = ARUtilityFunctions.MatrixFromFloatArray(matrixRawArray);
                //ARController.Log("arwQueryMarkerTransformation(" + UID + ") got matrix: [" + Environment.NewLine + matrixRaw.ToString("F3").Trim() + "]");

                // ARToolKit uses right-hand coordinate system where the marker lies in x-y plane with right in direction of +x,
                // up in direction of +y, and forward (towards viewer) in direction of +z.
                // Need to convert to Unity's left-hand coordinate system where marker lies in x-y plane with right in direction of +x,
                // up in direction of +y, and forward (towards viewer) in direction of -z.
                transformationMatrix = ARUtilityFunctions.LHMatrixFromRHMatrix(matrixRaw);
            }
        }
    }
예제 #3
0
    void OnMouseDown()
    {
        StringBuilder builder = new StringBuilder();

        builder.AppendLine("AR Toolkit Version " + PluginFunctions.arwGetARToolKitVersion());
        builder.AppendLine("Running?: " + PluginFunctions.arwIsRunning());

        int    width;
        int    height;
        int    pixelSize;
        string pixelFormatString;

        PluginFunctions.arwGetVideoParams(out width, out height, out pixelSize, out pixelFormatString);
        builder.AppendLine("VideoParams: w:" + width + " h:" + height + " pixelSize:" + pixelSize + " formatStr:" + pixelFormatString);

        builder.AppendLine("Current ErrCode: " + PluginFunctions.arwGetError());


        using (AndroidJavaClass cls_UnityPlayer = new AndroidJavaClass("com.google.unity.UnityTangoARPlayer"))
        {
            JLog(cls_UnityPlayer.ToString());
            cls_UnityPlayer.CallStatic("foo");
//			using (AndroidJavaObject obj_Activity = cls_UnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
//			{
//				obj_Activity .CallStatic("foo");
//			}
        }
        builder.AppendLine("I Called UnityTangoARPlayer.foo()");

        debugAndToast(builder.ToString());
    }
예제 #4
0
    public bool SetupCamera(float nearClipPlane, float farClipPlane, Matrix4x4 projectionMatrix, ref bool opticalOut)
    {
        Camera c = this.gameObject.GetComponent <Camera>();

        // A perspective projection matrix from the tracker
        c.orthographic = false;

        // Shouldn't really need to set these, because they are part of the custom
        // projection matrix, but it seems that in the editor, the preview camera view
        // isn't using the custom projection matrix.
        c.nearClipPlane = nearClipPlane;
        c.farClipPlane  = farClipPlane;

        if (Optical)
        {
            float   fovy;
            float   aspect;
            float[] m = new float[16];
            float[] p = new float[16];
            opticalSetupOK = PluginFunctions.arwLoadOpticalParams(null, OpticalParamsFileContents, OpticalParamsFileContents.Length, out fovy, out aspect, m, p);
            if (!opticalSetupOK)
            {
                ARController.Log(LogTag + "Error loading optical parameters.");
                return(false);
            }
            m[12] *= 0.001f;
            m[13] *= 0.001f;
            m[14] *= 0.001f;
            ARController.Log(LogTag + "Optical parameters: fovy=" + fovy + ", aspect=" + aspect + ", camera position (m)={" + m[12].ToString("F3") + ", " + m[13].ToString("F3") + ", " + m[14].ToString("F3") + "}");

            c.projectionMatrix = ARUtilityFunctions.MatrixFromFloatArray(p);

            opticalViewMatrix = ARUtilityFunctions.MatrixFromFloatArray(m);
            if (OpticalEyeLateralOffsetRight != 0.0f)
            {
                opticalViewMatrix = Matrix4x4.TRS(new Vector3(-OpticalEyeLateralOffsetRight, 0.0f, 0.0f), Quaternion.identity, Vector3.one) * opticalViewMatrix;
            }
            // Convert to left-hand matrix.
            opticalViewMatrix = ARUtilityFunctions.LHMatrixFromRHMatrix(opticalViewMatrix);

            opticalOut = true;
        }
        else
        {
            c.projectionMatrix = projectionMatrix;
        }

        // Don't clear anything or else we interfere with other foreground cameras
        c.clearFlags = CameraClearFlags.Nothing;

        // Renders after the clear and background cameras
        c.depth = 2;

        c.transform.position   = new Vector3(0.0f, 0.0f, 0.0f);
        c.transform.rotation   = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f);
        c.transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);


        return(true);
    }
예제 #5
0
    // Use this for initialization
    void Start()
    {
        PluginFunctions.arwSetVideoDebugMode(true);
        PluginFunctions.arwSetLogLevel(5);

        PluginFunctions.LogCallback c = new PluginFunctions.LogCallback(this.JLog);
        PluginFunctions.arwRegisterLogCallback(c);


//		// pick a random color
//		Color newColor = new Color( UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value, 1.0f );
//		JLog ("Coloured the cube " + newColor.ToString() );
//		// apply it on current object's material
//		GetComponent<MeshRenderer>().material.color = newColor;
    }
예제 #6
0
 // Unload any underlying ARToolKit structures, and clear the UID.
 public void Unload()
 {
     lock (loadLock) {
         if (UID == NO_ID)
         {
             return;
         }
         // Remove the native trackable, unless arwShutdownAR() has already been called (as it will already have been removed.)
         if (PluginFunctions.inited)
         {
             PluginFunctions.arwRemoveMarker(UID);
         }
         uid      = NO_ID;
         patterns = null;             // Delete the patterns too.
     }
 }
예제 #7
0
    public ARPattern(int markerID, int patternID)
    {
        float[] matrixRawArray = new float[16];
        float   widthRaw       = 0.0f;
        float   heightRaw      = 0.0f;

        // Get the pattern local transformation and size.
        if (!PluginFunctions.arwGetMarkerPatternConfig(markerID, patternID, matrixRawArray, out widthRaw, out heightRaw, out imageSizeX, out imageSizeY))
        {
            throw new ArgumentException("Invalid argument", "markerID,patternID");
        }
        width  = widthRaw * 0.001f;
        height = heightRaw * 0.001f;

        matrixRawArray[12] *= 0.001f;         // Scale the position from ARToolKit units (mm) into Unity units (m).
        matrixRawArray[13] *= 0.001f;
        matrixRawArray[14] *= 0.001f;

        Matrix4x4 matrixRaw = ARUtilityFunctions.MatrixFromFloatArray(matrixRawArray);

        //ARController.Log("arwGetMarkerPatternConfig(" + markerID + ", " + patternID + ", ...) got matrix: [" + Environment.NewLine + matrixRaw.ToString("F3").Trim() + "]");

        // ARToolKit uses right-hand coordinate system where the marker lies in x-y plane with right in direction of +x,
        // up in direction of +y, and forward (towards viewer) in direction of +z.
        // Need to convert to Unity's left-hand coordinate system where marker lies in x-y plane with right in direction of +x,
        // up in direction of +y, and forward (towards viewer) in direction of -z.
        matrix = ARUtilityFunctions.LHMatrixFromRHMatrix(matrixRaw);

        // Handle pattern image.
        if (imageSizeX > 0 && imageSizeY > 0)
        {
            // Allocate a new texture for the pattern image
            texture            = new Texture2D(imageSizeX, imageSizeY, TextureFormat.RGBA32, false);
            texture.filterMode = FilterMode.Point;
            texture.wrapMode   = TextureWrapMode.Clamp;
            texture.anisoLevel = 0;

            // Get the pattern image data and load it into the texture
            Color[] colors = new Color[imageSizeX * imageSizeY];
            if (PluginFunctions.arwGetMarkerPatternImage(markerID, patternID, colors))
            {
                texture.SetPixels(colors);
                texture.Apply();
            }
        }
    }
예제 #8
0
    public ARPattern(int markerID, int patternID)
    {
        float[] matrixRawArray = new float[16];
        float   widthRaw       = 0.0f;
        float   heightRaw      = 0.0f;

        // Get the pattern local transformation and size.
        if (!PluginFunctions.arwGetTrackableAppearanceConfig(markerID, patternID, matrixRawArray, out widthRaw, out heightRaw, out imageSizeX, out imageSizeY))
        {
            throw new System.ArgumentException("Invalid argument", "markerID,patternID");
        }

        width  = widthRaw * ARTrackable.UNITY_TO_ARTOOLKIT;
        height = heightRaw * ARTrackable.UNITY_TO_ARTOOLKIT;
        // Scale the position from ARToolKit units (mm) into Unity units (m).
        matrixRawArray[12] *= ARTrackable.UNITY_TO_ARTOOLKIT;
        matrixRawArray[13] *= ARTrackable.UNITY_TO_ARTOOLKIT;
        matrixRawArray[14] *= ARTrackable.UNITY_TO_ARTOOLKIT;

        Matrix4x4 matrixRaw = ARUtilityFunctions.MatrixFromFloatArray(matrixRawArray);

        // ARToolKit uses right-hand coordinate system where the marker lies in x-y plane with right in direction of +x,
        // up in direction of +y, and forward (towards viewer) in direction of +z.
        // Need to convert to Unity's left-hand coordinate system where marker lies in x-y plane with right in direction of +x,
        // up in direction of +y, and forward (towards viewer) in direction of -z.
        matrix = ARUtilityFunctions.LHMatrixFromRHMatrix(matrixRaw);

        // Handle pattern image.
        if (imageSizeX > 0 && imageSizeY > 0)
        {
            // Allocate a new texture for the pattern image
            texture            = new Texture2D(imageSizeX, imageSizeY, TextureFormat.RGBA32, false);
            texture.filterMode = FilterMode.Point;
            texture.wrapMode   = TextureWrapMode.Clamp;
            texture.anisoLevel = 0;

            // Get the pattern image data and load it into the texture
            Color32[] colors32 = new Color32[imageSizeX * imageSizeY];
            if (PluginFunctions.arwGetTrackableAppearanceImage(markerID, patternID, colors32))
            {
                texture.SetPixels32(colors32);
                texture.Apply();
            }
        }
    }
예제 #9
0
    // We use Update() here, but be aware that unless ARController has been configured to
    // execute first (Unity Editor->Edit->Project Settings->Script Execution Order) then
    // state produced by this update may lag by one frame.
    void Update()
    {
        float[] matrixRawArray = new float[16];

        ARController.Log(LogTag + "ARMarker.Update()");
        if (UID == NO_ID || !PluginFunctions.inited)
        {
            visible = false;
            return;
        }

        // Query visibility if we are running in the Player.
        if (Application.isPlaying)
        {
            visible = PluginFunctions.arwQueryMarkerTransformation(UID, matrixRawArray);
            ARController.Log(LogTag + "ARMarker.Update() UID=" + UID + ", visible=" + visible);

            if (visible)
            {
                matrixRawArray[12] *= 0.001f;                 // Scale the position from ARToolKit units (mm) into Unity units (m).
                matrixRawArray[13] *= 0.001f;
                matrixRawArray[14] *= 0.001f;

                Matrix4x4 matrixRaw = ARUtilityFunctions.MatrixFromFloatArray(matrixRawArray);
                //ARController.Log("arwQueryMarkerTransformation(" + UID + ") got matrix: [" + Environment.NewLine + matrixRaw.ToString("F3").Trim() + "]");

                // ARToolKit uses right-hand coordinate system where the marker lies in x-y plane with right in direction of +x,
                // up in direction of +y, and forward (towards viewer) in direction of +z.
                // Need to convert to Unity's left-hand coordinate system where marker lies in x-y plane with right in direction of +x,
                // up in direction of +y, and forward (towards viewer) in direction of -z.
                transformationMatrix = ARUtilityFunctions.LHMatrixFromRHMatrix(matrixRaw);

                // Output current position: Added by Kazu on Apr 2 2016
                Vector3 position = ARUtilityFunctions.PositionFromMatrix(transformationMatrix);
                print("Position of Barcode ID #" + BarcodeID + ": (" + position.x * 1000 + ", " + position.y * 1000 + ", " + position.z * 1000 + ")");
//				print ("position.x [mm]: "+ position.x * 1000);
//				print ("position.y [mm]: "+ position.y * 1000);
//				print ("position.z [mm]: "+ position.z * 1000);
//				If you need quaternion, you can use the followings.
//				Quaternion orientation = ARUtilityFunctions.QuaternionFromMatrix(transformationMatrix);
            }
        }
    }
예제 #10
0
    // Unload any underlying ARToolKit structures, and clear the UID.
    public void Unload()
    {
        //ARController.Log(LogTag + "ARMarker.Unload()");

        if (UID == NO_ID)
        {
            //ARController.Log(LogTag + "Marker already unloaded.");
            return;
        }

        if (PluginFunctions.inited)
        {
            // Remove any currently loaded ARToolKit marker.
            PluginFunctions.arwRemoveMarker(UID);
        }

        UID = NO_ID;

        patterns = null;         // Delete the patterns too.
    }
예제 #11
0
        public void ProcessRequest(HttpContext context)
        {
            #region "Initialize"

            var strOut = "** No Action **";

            var paramCmd       = Utils.RequestQueryStringParam(context, "cmd");
            var itemId         = Utils.RequestQueryStringParam(context, "itemid");
            var ctlType        = Utils.RequestQueryStringParam(context, "ctltype");
            var idXref         = Utils.RequestQueryStringParam(context, "idxref");
            var xpathpdf       = Utils.RequestQueryStringParam(context, "pdf");
            var xpathref       = Utils.RequestQueryStringParam(context, "pdfref");
            var lang           = Utils.RequestQueryStringParam(context, "lang");
            var language       = Utils.RequestQueryStringParam(context, "language");
            var moduleId       = Utils.RequestQueryStringParam(context, "mid");
            var moduleKey      = Utils.RequestQueryStringParam(context, "mkey");
            var parentid       = Utils.RequestQueryStringParam(context, "parentid");
            var entryid        = Utils.RequestQueryStringParam(context, "entryid");
            var entryxid       = Utils.RequestQueryStringParam(context, "entryxid");
            var catid          = Utils.RequestQueryStringParam(context, "catid");
            var catxid         = Utils.RequestQueryStringParam(context, "catxid");
            var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix");
            var value          = Utils.RequestQueryStringParam(context, "value");
            var itemListName   = Utils.RequestQueryStringParam(context, "listname");
            if (itemListName == "")
            {
                itemListName = "ItemList";
            }
            if (itemListName == "*")
            {
                itemListName = "ItemList";
            }

            #region "setup language"

            // because we are using a webservice the system current thread culture might not be set correctly,
            _uilang = NBrightBuyUtils.SetContextLangauge(context);
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            _editlang = NBrightBuyUtils.GetEditLang(ajaxInfo, _uilang);

            #endregion

            Logging.Debug($"XmlConnector called with: paramCmd='{paramCmd}', itemId='{itemId}', itemListName='{itemListName}'");

            #endregion

            try
            {
                #region "Do processing of command"

                if (paramCmd.StartsWith("client."))
                {
                    strOut = ClientFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("orderadmin_"))
                {
                    strOut = OrderFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("payment_"))
                {
                    strOut = PaymentFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("product_"))
                {
                    ProductFunctions.EntityTypeCode = "PRD";
                    strOut = ProductFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("category_"))
                {
                    CategoryFunctions.EntityTypeCode = "CATEGORY";
                    strOut = CategoryFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("property_"))
                {
                    PropertyFunctions.EntityTypeCode = "CATEGORY";
                    strOut = PropertyFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("itemlist_"))
                {
                    strOut = ItemListsFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("addressadmin_"))
                {
                    strOut = AddressAdminFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("plugins_"))
                {
                    strOut = PluginFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("cart_"))
                {
                    strOut = CartFunctions.ProcessCommand(paramCmd, context);
                }
                else
                {
                    switch (paramCmd)
                    {
                    case "test":
                        strOut = "<root>" + UserController.Instance.GetCurrentUserInfo().Username + "</root>";
                        break;

                    case "setdata":
                        break;

                    case "deldata":
                        break;

                    case "getdata":
                        strOut = GetReturnData(context);
                        break;

                    case "fileupload":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = FileUpload(context);
                        }
                        break;

                    case "fileclientupload":
                        if (StoreSettings.Current.GetBool("allowupload"))
                        {
                            strOut = FileUpload(context, itemId);
                        }
                        break;

                    case "docdownload":

                        var fname   = Utils.RequestQueryStringParam(context, "filename");
                        var filekey = Utils.RequestQueryStringParam(context, "key");
                        if (filekey != "")
                        {
                            var uData = new UserData();
                            if (uData.HasPurchasedDocByKey(filekey))
                            {
                                fname = uData.GetPurchasedFileName(filekey);
                            }
                            fname = StoreSettings.Current.FolderDocuments + "/" + fname;
                        }
                        if (fname != "")
                        {
                            strOut = fname;     // return this is error.
                            var downloadname = Utils.RequestQueryStringParam(context, "downloadname");
                            var fpath        = HttpContext.Current.Server.MapPath(fname);
                            if (downloadname == "")
                            {
                                downloadname = Path.GetFileName(fname);
                            }
                            try
                            {
                                Utils.ForceDocDownload(fpath, downloadname, context.Response);
                            }
                            catch (Exception ex)
                            {
                                // ignore, robots can cause error on thread abort.
                                //Exceptions.LogException(ex);
                                Logging.Debug($"XmlConnector.ProcessRequest exception for {paramCmd} which is ignored because bots tend to cause these on thread abort: {ex.Message}.");
                            }
                        }
                        break;

                    case "printproduct":
                        break;

                    case "renderpostdata":
                        strOut = RenderPostData(context);
                        break;

                    case "getsettings":
                        strOut = GetSettings(context);
                        break;

                    case "savesettings":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = SaveSettings(context);
                        }
                        break;

                    case "updateprofile":
                        strOut = UpdateProfile(context);
                        break;

                    case "dosearch":
                        strOut = DoSearch(context);
                        break;

                    case "resetsearch":
                        strOut = ResetSearch(context);
                        break;

                    case "orderby":
                        strOut = DoOrderBy(context);
                        break;

                    case "renderthemefolders":
                        strOut = RenderThemeFolders(context);
                        break;
                    }
                }

                if (strOut == "** No Action **")
                {
                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetAjaxProviders();
                    foreach (var d in provList)
                    {
                        if (paramCmd.ToLower().StartsWith(d.Key.ToLower() + "_") || paramCmd.ToLower().StartsWith("cmd" + d.Key.ToLower() + "_"))
                        {
                            var ajaxprov = AjaxInterface.Instance(d.Key);
                            if (ajaxprov != null)
                            {
                                strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                strOut = ex.ToString();
                Logging.LogException(ex);
                //Exceptions.LogException(ex);
            }


            #region "return results"

            //send back xml as plain text
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(strOut);
            context.Response.End();

            #endregion
        }
예제 #12
0
        public void ProcessRequest(HttpContext context)
        {
            #region "Initialize"

            var strOut = "** No Action **";

            var paramCmd       = Utils.RequestQueryStringParam(context, "cmd");
            var itemId         = Utils.RequestQueryStringParam(context, "itemid");
            var ctlType        = Utils.RequestQueryStringParam(context, "ctltype");
            var idXref         = Utils.RequestQueryStringParam(context, "idxref");
            var xpathpdf       = Utils.RequestQueryStringParam(context, "pdf");
            var xpathref       = Utils.RequestQueryStringParam(context, "pdfref");
            var lang           = Utils.RequestQueryStringParam(context, "lang");
            var language       = Utils.RequestQueryStringParam(context, "language");
            var moduleId       = Utils.RequestQueryStringParam(context, "mid");
            var moduleKey      = Utils.RequestQueryStringParam(context, "mkey");
            var parentid       = Utils.RequestQueryStringParam(context, "parentid");
            var entryid        = Utils.RequestQueryStringParam(context, "entryid");
            var entryxid       = Utils.RequestQueryStringParam(context, "entryxid");
            var catid          = Utils.RequestQueryStringParam(context, "catid");
            var catxid         = Utils.RequestQueryStringParam(context, "catxid");
            var templatePrefix = Utils.RequestQueryStringParam(context, "tprefix");
            var value          = Utils.RequestQueryStringParam(context, "value");
            var itemListName   = Utils.RequestQueryStringParam(context, "listname");
            if (itemListName == "")
            {
                itemListName = "ItemList";
            }
            if (itemListName == "*")
            {
                itemListName = "ItemList";
            }

            #region "setup language"

            // because we are using a webservice the system current thread culture might not be set correctly,
            NBrightBuyUtils.SetContextLangauge(context);
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            _editlang = NBrightBuyUtils.GetEditLang(ajaxInfo, Utils.GetCurrentCulture());

            #endregion

            Logging.Debug($"XmlConnector called with: paramCmd='{paramCmd}', itemId='{itemId}', itemListName='{itemListName}'");

            #endregion

            try
            {
                #region "Do processing of command"

                if (paramCmd.StartsWith("client."))
                {
                    strOut = ClientFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("orderadmin_"))
                {
                    strOut = OrderFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("payment_"))
                {
                    strOut = PaymentFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("product_"))
                {
                    var productFunctions = new ProductFunctions();
                    strOut = productFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("category_"))
                {
                    var categoryFunctions = new CategoryFunctions();
                    strOut = categoryFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("property_"))
                {
                    var propertyFunctions = new PropertyFunctions();
                    strOut = propertyFunctions.ProcessCommand(paramCmd, context, _editlang);
                }
                else if (paramCmd.StartsWith("itemlist_"))
                {
                    strOut = ItemListsFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("addressadmin_"))
                {
                    strOut = AddressAdminFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("plugins_"))
                {
                    strOut = PluginFunctions.ProcessCommand(paramCmd, context);
                }
                else if (paramCmd.StartsWith("cart_"))
                {
                    strOut = CartFunctions.ProcessCommand(paramCmd, context);
                }
                else
                {
                    switch (paramCmd)
                    {
                    case "test":
                        strOut = "<root>" + UserController.Instance.GetCurrentUserInfo().Username + "</root>";
                        break;

                    case "setdata":
                        break;

                    case "deldata":
                        break;

                    case "getdata":
                        strOut = GetReturnData(context);
                        break;

                    case "fileupload":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = FileUpload(context);
                        }
                        break;

                    case "fileclientupload":
                        if (StoreSettings.Current.GetBool("allowupload"))
                        {
                            strOut = FileUpload(context, itemId);
                        }
                        break;

                    case "docdownload":
                        strOut = DownloadSystemFile(paramCmd, context);
                        break;

                    case "printproduct":
                        break;

                    case "renderpostdata":
                        strOut = RenderPostData(context);
                        break;

                    case "getsettings":
                        strOut = GetSettings(context);
                        break;

                    case "savesettings":
                        if (NBrightBuyUtils.CheckRights())
                        {
                            strOut = SaveSettings(context);
                        }
                        break;

                    case "updateprofile":
                        strOut = UpdateProfile(context);
                        break;

                    case "dosearch":
                        strOut = DoSearch(context);
                        break;

                    case "resetsearch":
                        strOut = ResetSearch(context);
                        break;

                    case "orderby":
                        strOut = DoOrderBy(context);
                        break;

                    case "renderthemefolders":
                        strOut = RenderThemeFolders(context);
                        break;
                    }
                }

                if (strOut == "** No Action **")
                {
                    var ajaxprovider = ajaxInfo.GetXmlProperty("genxml/hidden/ajaxprovider");
                    if (ajaxprovider == "")
                    {
                        ajaxprovider = Utils.RequestQueryStringParam(context, "ajaxprovider");
                    }

                    var pluginData = new PluginData(PortalSettings.Current.PortalId);
                    var provList   = pluginData.GetAjaxProviders();
                    if (ajaxprovider != "")
                    {
                        strOut = "Ajax Provider not found: " + ajaxprovider;
                        if (provList.ContainsKey(ajaxprovider))
                        {
                            var ajaxprov = AjaxInterface.Instance(ajaxprovider);
                            if (ajaxprov != null)
                            {
                                strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                            }
                        }
                    }
                    else
                    {
                        foreach (var d in provList)
                        {
                            if (paramCmd.ToLower().StartsWith(d.Key.ToLower() + "_") || paramCmd.ToLower().StartsWith("cmd" + d.Key.ToLower() + "_"))
                            {
                                var ajaxprov = AjaxInterface.Instance(d.Key);
                                if (ajaxprov != null)
                                {
                                    strOut = ajaxprov.ProcessCommand(paramCmd, context, _editlang);
                                }
                            }
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                strOut = ex.ToString();
                Logging.LogException(ex);
                //Exceptions.LogException(ex);
            }


            #region "return results"

            //send back xml as plain text
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(strOut);
            context.Response.End();

            #endregion
        }
예제 #13
0
//	private Guid   cacheGuid               = Guid.Empty;
//	// When indexes update, there are three likely scenarios:
//	//     1) ID has not changed.
//	//     2) ID has shifted by a few values due to sorting.
//	//     3) Content has been removed, and therefore there is no ID.
//	private int ReassociateContentID(int index, TrackableType markerType, string content) {
//		if (string.CompareOrdinal(ARToolKitAssetManager.AllMarkers[index], content) == 0) {
//			return index;
//		} else {
//			for (int i = 0; i < ARToolKitAssetManager.
//		}
//	}

    public override void OnInspectorGUI()
    {
        // Get the ARMarker that this panel will edit.
        ARTrackable arMarker = (ARTrackable)target;

        if (null == arMarker)
        {
            return;
        }
        // Attempt to load. Might not work out if e.g. for a single marker, pattern hasn't been
        // assigned yet, or for an NFT marker, dataset hasn't been specified.
        if (arMarker.UID == ARTrackable.NO_ID)
        {
            PluginFunctions.arwInitialiseAR();
            arMarker.Load();
        }

        // Check if a new image was dropped into the Project directory
        string        path = Application.streamingAssetsPath + "/" + ARToolKitAssetManager.IMAGES_DIRECTORY_NAME;
        DirectoryInfo dir  = new DirectoryInfo(path);

        FileInfo[] imageFileList = dir.GetFiles("*.jpg").Union(dir.GetFiles("*.jpeg")).ToArray();
        if (imageFileList != null && ARToolKitAssetManager.Images != null && imageFileList.Length != ARToolKitAssetManager.Images.Length)
        {
            if (imageFileList.Length < ARToolKitAssetManager.Images.Length)
            {
                //An image was deleted from the file system so we might have an empty ARTrackable now
                ARController.Log("Warning: Trackable image removed. Please check all ARTrackables and make sure that they have an image assigned.");
            }
            //We found a new trackable in the file system or a trackable was removed lets reload the trackables.
            ARToolKitAssetManager.Reload();
        }

        // Draw the drag n drop area
        DropAreaGUI();

        int selectedMarker = ArrayUtility.IndexOf(ARToolKitAssetManager.AllMarkers, arMarker.EditorMarkerName);

        arMarker.EditorMarkerIndex = EditorGUILayout.Popup("Marker", selectedMarker, ARToolKitAssetManager.AllMarkers);

        bool newSelection = false;

        if (arMarker.EditorMarkerIndex < 0)
        {
            //An image was deleted from the file system so we have an empty ARTrackable now
            ARController.Log("Warning: Trackable image removed. Please check the ARTrackable and make sure that is has an image assigned.");
            return;
        }
        else
        {
            if (string.CompareOrdinal(arMarker.EditorMarkerName, ARToolKitAssetManager.AllMarkers[arMarker.EditorMarkerIndex]) != 0)
            {
                newSelection = true;
                arMarker.EditorMarkerName = ARToolKitAssetManager.AllMarkers[arMarker.EditorMarkerIndex];
            }
        }

        ARTrackable.TrackableType markerType = DetermineTrackableType(arMarker.EditorMarkerIndex);
        if (arMarker.Type != markerType)
        {
            arMarker.ClearUnusedValues();
            arMarker.Type = markerType;
            UpdatePatternDetectionMode();
        }

        EditorGUILayout.LabelField("Type ", ARTrackable.TrackableTypeNames[arMarker.Type]);

        EditorGUILayout.LabelField("Unique ID", (arMarker.UID == ARTrackable.NO_ID ? "Not Loaded": arMarker.UID.ToString()));

        EditorGUILayout.BeginHorizontal();
        // Draw all the marker images
        if (arMarker.Patterns != null)
        {
            for (int i = 0; i < arMarker.Patterns.Length; ++i)
            {
                EditorGUILayout.Separator();
                GUILayout.Label(new GUIContent(string.Format("Pattern {0}, {1}m", i, arMarker.Patterns[i].width.ToString("n3")), arMarker.Patterns[i].texture), GUILayout.ExpandWidth(false));                 // n3 -> 3 decimal places.
            }
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        switch (arMarker.Type)
        {
        case ARTrackable.TrackableType.TwoD:
            if (newSelection)
            {
                arMarker.TwoDImageName = ARToolKitAssetManager.AllMarkers[arMarker.EditorMarkerIndex];
            }
            float twoDImageHeight = EditorGUILayout.FloatField("Image height", arMarker.TwoDImageHeight);
            if (twoDImageHeight != arMarker.TwoDImageHeight)
            {
                EditorUtility.SetDirty(arMarker);
                arMarker.TwoDImageHeight = twoDImageHeight;
            }

            float   width = 0.0f, height = 0.0f;
            int     imageWidth = 0, imageHeight = 0;
            float[] transformation = new float[16];

            if (PluginFunctions.arwGetTrackableAppearanceConfig(arMarker.UID, 0, transformation, out width, out height, out imageWidth, out imageHeight))
            {
                Color32[] imagePixels = new Color32[imageWidth * imageHeight];
                if (PluginFunctions.arwGetTrackableAppearanceImage(arMarker.UID, 0, imagePixels))
                {
                    //Set the texture with the trackable appearance.
                    Texture2D texture = new Texture2D(imageWidth, imageHeight, TextureFormat.RGBA32, true);
                    texture.SetPixels32(imagePixels);
                    texture.Apply();

                    //Display label and texture to the user
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label("Trackable Appearance");

                    //Resize texture for viewport with max with and height
                    GUILayout.Label(ARTrackableAppearanceScale.BilinearWithMaxSize(texture, 200, 200));
                    EditorGUILayout.EndHorizontal();
                }
            }
            break;

        case ARTrackable.TrackableType.Square:
            if (newSelection)
            {
                arMarker.PatternContents = GetPatternContents(ARToolKitAssetManager.AllMarkers[arMarker.EditorMarkerIndex]);
            }
            arMarker.PatternWidth          = EditorGUILayout.FloatField("Pattern Width (m)", arMarker.PatternWidth);
            arMarker.UseContPoseEstimation = EditorGUILayout.Toggle("Contstant Pose Estimation", arMarker.UseContPoseEstimation);
            break;

        case ARTrackable.TrackableType.SquareBarcode:
            if (newSelection)
            {
                string[] idArray = ARToolKitAssetManager.AllMarkers[arMarker.EditorMarkerIndex].Split(' ');
                arMarker.BarcodeID = int.Parse(idArray[idArray.Length - 1]);
            }
            arMarker.PatternWidth          = EditorGUILayout.FloatField("Pattern Width (m)", arMarker.PatternWidth);
            arMarker.UseContPoseEstimation = EditorGUILayout.Toggle("Contstant Pose Estimation", arMarker.UseContPoseEstimation);
            break;

        case ARTrackable.TrackableType.Multimarker:
            if (newSelection)
            {
                arMarker.MultiConfigFile = ARToolKitAssetManager.AllMarkers[arMarker.EditorMarkerIndex];
            }
            break;
        }

        EditorGUILayout.Separator();

        arMarker.Filtered = EditorGUILayout.Toggle("Filter Pose", arMarker.Filtered);
        if (arMarker.Filtered)
        {
            arMarker.FilterSampleRate = EditorGUILayout.Slider("Sample Rate", arMarker.FilterSampleRate, 1.0f, 30.0f);
            arMarker.FilterCutoffFreq = EditorGUILayout.Slider("Cutoff Frequency", arMarker.FilterCutoffFreq, 1.0f, 30.0f);
        }

        if (arMarker.Type == ARTrackable.TrackableType.Square || arMarker.Type == ARTrackable.TrackableType.SquareBarcode || arMarker.Type == ARTrackable.TrackableType.Multimarker)
        {
            showGlobalSquareOptions = EditorGUILayout.Foldout(showGlobalSquareOptions, "Global Square Tracking Options");
            if (showGlobalSquareOptions)
            {
                ARController.Instance.TemplateSize = EditorGUILayout.IntSlider("Template Size (bits)", ARController.Instance.TemplateSize, 16, 64);

                int currentTemplateCountMax = ARController.Instance.TemplateCountMax;
                int newTemplateCountMax     = EditorGUILayout.IntField("Maximum Template Count", currentTemplateCountMax);
                if (newTemplateCountMax != currentTemplateCountMax && newTemplateCountMax > 0)
                {
                    ARController.Instance.TemplateCountMax = newTemplateCountMax;
                }

                bool trackInColor = EditorGUILayout.Toggle("Track Templates in Color", ARController.Instance.trackTemplatesInColor);
                if (trackInColor != ARController.Instance.trackTemplatesInColor)
                {
                    ARController.Instance.trackTemplatesInColor = trackInColor;
                    UpdatePatternDetectionMode();
                }

                ARController.Instance.BorderSize    = UnityEngine.Mathf.Clamp(EditorGUILayout.FloatField("Border Size (%)", ARController.Instance.BorderSize), 0.0f, 0.5f);
                ARController.Instance.LabelingMode  = (ARController.ARToolKitLabelingMode)EditorGUILayout.EnumPopup("Marker Border Color", ARController.Instance.LabelingMode);
                ARController.Instance.ImageProcMode = (ARController.ARToolKitImageProcMode)EditorGUILayout.EnumPopup("Image Processing Mode", ARController.Instance.ImageProcMode);
            }
        }

        var obj  = new SerializedObject(arMarker);
        var prop = obj.FindProperty("eventReceivers");

        EditorGUILayout.PropertyField(prop, new GUIContent("Event Receivers"), true);
        obj.ApplyModifiedProperties();
    }
예제 #14
0
 private static void Bootstrap(PluginFunctions pluginFunctions, ref PluginCallbacks pluginCallbacks)
 {
     PluginFunctions = pluginFunctions;
     BindCallbacks(ref pluginCallbacks);
 }
예제 #15
0
    // Load the underlying ARToolKit marker structure(s) and set the UID.
    public void Load()
    {
        lock (loadLock) {
            if (UID != NO_ID)
            {
                return;
            }
            if (!PluginFunctions.inited)
            {
                // If arwInitialiseAR() has not yet been called, we can't load the native trackable yet.
                // ARController.InitialiseAR() will call this again when arwInitialiseAR() has been called.
                return;
            }
            // Work out the configuration string to pass to ARToolKit.
            string assetDirectory = Application.streamingAssetsPath;
            string configuration  = string.Empty;
            string path           = string.Empty;

            switch (Type)
            {
            case TrackableType.TwoD:
                if (string.IsNullOrEmpty(TwoDImageName))
                {
                    ARController.Log(string.Format(LOAD_FAILURE, "2D image trackable due to no TwoDImageName"));
                    return;
                }
                path = Path.Combine(TWOD_FORMAT, TwoDImageName);
                if (!ARUtilityFunctions.GetFileFromStreamingAssets(path, out assetDirectory))
                {
                    ARController.Log(string.Format(LOAD_FAILURE, TwoDImageName));
                    return;
                }
                if (!string.IsNullOrEmpty(assetDirectory))
                {
                    configuration = string.Format(TWOD_CONFIG, assetDirectory, TwoDImageHeight * ARTOOLKIT_TO_UNITY);
                }
                break;

            case TrackableType.Square:
                // Multiply width by 1000 to convert from metres to ARToolKit's millimetres.
                configuration = string.Format(SINGLE_BUFFER_CONFIG, PatternWidth * ARTOOLKIT_TO_UNITY, PatternContents);
                break;

            case TrackableType.SquareBarcode:
                // Multiply width by 1000 to convert from metres to ARToolKit's millimetres.
                configuration = string.Format(SINGLE_BARCODE_CONFIG, BarcodeID, PatternWidth * ARTOOLKIT_TO_UNITY);
                break;

            case TrackableType.Multimarker:
                if (string.IsNullOrEmpty(MultiConfigFile))
                {
                    ARController.Log(string.Format(LOAD_FAILURE, "multimarker due to no MultiConfigFile"));
                    return;
                }
                path = Path.Combine(MULTI_FORMAT, MultiConfigFile + MULTI_EXT);
                ARUtilityFunctions.GetFileFromStreamingAssets(path, out assetDirectory);
                if (!string.IsNullOrEmpty(assetDirectory))
                {
                    configuration = string.Format(MULTI_CONFIG, assetDirectory);
                }
                break;

            default:
                // Unknown marker type?
                ARController.Log(string.Format(LOAD_FAILURE, "due to unknown marker"));
                return;
            }

            // If a valid config. could be assembled, get ARToolKit to process it, and assign the resulting ARMarker UID.
            if (string.IsNullOrEmpty(configuration))
            {
                ARController.Log(LOG_TAG + "trackable configuration is null or empty.");
                return;
            }

            uid = PluginFunctions.arwAddMarker(configuration);
            if (UID == NO_ID)
            {
                ARController.Log(LOG_TAG + "Error loading trackable.");
                return;
            }

            // Trackable loaded. Do any additional configuration.
            if (Type == TrackableType.Square || Type == TrackableType.SquareBarcode)
            {
                UseContPoseEstimation = currentUseContPoseEstimation;
            }

            Filtered         = currentFiltered;
            FilterSampleRate = currentFilterSampleRate;
            FilterCutoffFreq = currentFilterCutoffFreq;

            // Retrieve any required information from the configured ARTrackable.
            if (Type == TrackableType.TwoD)
            {
                int   dummyImageSizeX, dummyImageSizeY;
                float dummyTwoDImageHeight;
                PluginFunctions.arwGetTrackableAppearanceConfig(UID, 0, null, out TwoDImageWidth, out dummyTwoDImageHeight, out dummyImageSizeX, out dummyImageSizeY);
                TwoDImageWidth *= UNITY_TO_ARTOOLKIT;
            }
            else
            {
                // Create array of patterns. A single marker will have array length 1.
                int numPatterns = PluginFunctions.arwGetTrackableAppearanceCount(UID);
                if (numPatterns > 0)
                {
                    patterns = new ARPattern[numPatterns];
                    for (int i = 0; i < numPatterns; ++i)
                    {
                        patterns[i] = new ARPattern(UID, i);
                    }
                }
            }
        }
    }
예제 #16
0
    // 1 - Query for visibility.
    // 2 - Determine if visibility state is new.
    // 3 - If visible, calculate marker pose.
    // 4 - If visible, set marker pose.
    // 5 - If visibility state is new, notify event receivers via "OnMarkerFound" or "OnMarkerLost".
    // 6 - If visibility state is new, set appropriate active state for marker children.
    // 7 - If visible, notify event receivers that the marker's pose has been updated via "OnMarkerTracked".
    protected virtual void LateUpdate()
    {
        if (!Application.isPlaying)
        {
            return;
        }

        float[] matrixRawArray = new float[16];
        lock (loadLock) {
            if (UID == NO_ID || !PluginFunctions.inited)
            {
                visible = false;
                return;
            }

            Vector3 storedScale = transform.localScale;
            transform.localScale = Vector3.one;

            // 1 - Query for visibility.
            bool nowVisible = PluginFunctions.arwQueryMarkerTransformation(UID, matrixRawArray);

            // 2 - Determine if visibility state is new.
            bool notify = (nowVisible != visible);
            visible = nowVisible;

            // 3 - If visible, calculate marker pose.
            if (visible)
            {
                // Scale the position from ARToolKit units (mm) into Unity units (m).
                matrixRawArray[12] *= UNITY_TO_ARTOOLKIT;
                matrixRawArray[13] *= UNITY_TO_ARTOOLKIT;
                matrixRawArray[14] *= UNITY_TO_ARTOOLKIT;

                Matrix4x4 matrixRaw = ARUtilityFunctions.MatrixFromFloatArray(matrixRawArray);
                // ARToolKit uses right-hand coordinate system where the marker lies in x-y plane with right in direction of +x,
                // up in direction of +y, and forward (towards viewer) in direction of +z.
                // Need to convert to Unity's left-hand coordinate system where marker lies in x-y plane with right in direction of +x,
                // up in direction of +y, and forward (towards viewer) in direction of -z.
                transformationMatrix = ARUtilityFunctions.LHMatrixFromRHMatrix(matrixRaw);

                // 4 - If visible, set marker pose.
                Matrix4x4 pose = ARStaticCamera.Instance.transform.localToWorldMatrix * transformationMatrix;
                transform.position   = ARUtilityFunctions.PositionFromMatrix(pose);
                transform.rotation   = ARUtilityFunctions.RotationFromMatrix(pose);
                transform.localScale = storedScale;
            }

            // 5 - If visibility state is new, notify event receivers via "OnMarkerFound" or "OnMarkerLost".
            if (notify)
            {
                if (null != eventReceivers && eventReceivers.Count > 0)
                {
                    if (visible)
                    {
                        eventReceivers.ForEach(x => x.OnMarkerFound(this));
                    }
                    else
                    {
                        eventReceivers.ForEach(x => x.OnMarkerLost(this));
                    }
                }
                // 6 - If visibility state is new, set appropriate active state for marker children.
                for (int i = 0; i < transform.childCount; ++i)
                {
                    transform.GetChild(i).gameObject.SetActive(visible);
                }
            }

            if (visible)
            {
                // 7 - If visible, notify event receivers that the marker's pose has been updated via "OnMarkerTracked".
                if (null != eventReceivers && eventReceivers.Count > 0)
                {
                    eventReceivers.ForEach(x => x.OnMarkerTracked(this));
                }
            }
        }
    }
예제 #17
0
    // Load the underlying ARToolKit marker structure(s) and set the UID.
    public void Load()
    {
        //ARController.Log(LogTag + "ARMarker.Load()");
        if (UID != NO_ID)
        {
            //ARController.Log(LogTag + "Marker already loaded.");
            return;
        }

        if (!PluginFunctions.inited)
        {
            return;
        }

        // Work out the configuration string to pass to ARToolKit.
        string dir = Application.streamingAssetsPath;
        string cfg = "";

        switch (MarkerType)
        {
        case MarkerType.Square:
            // Multiply width by 1000 to convert from metres to ARToolKit's millimetres.
            cfg = "single_buffer;" + PatternWidth * 1000.0f + ";buffer=" + PatternContents;
            break;

        case MarkerType.SquareBarcode:
            // Multiply width by 1000 to convert from metres to ARToolKit's millimetres.
            cfg = "single_barcode;" + BarcodeID + ";" + PatternWidth * 1000.0f;
            break;

        case MarkerType.Multimarker:
                                #if !UNITY_METRO
            if (dir.Contains("://"))
            {
                // On Android, we need to unpack the StreamingAssets from the .jar file in which
                // they're archived into the native file system.
                dir = Application.temporaryCachePath;
                if (!unpackStreamingAssetToCacheDir(MultiConfigFile))
                {
                    dir = "";
                }
                else
                {
                    //string[] unpackFiles = getPatternFiles;
                    //foreach (string patternFile in patternFiles) {
                    //if (!unpackStreamingAssetToCacheDir(patternFile)) {
                    //    dir = "";
                    //    break;
                    //}
                }
            }
                                #endif

            if (!string.IsNullOrEmpty(dir) && !string.IsNullOrEmpty(MultiConfigFile))
            {
                cfg = "multi;" + System.IO.Path.Combine(dir, MultiConfigFile);
            }
            break;


        case MarkerType.NFT:
                                #if !UNITY_METRO
            if (dir.Contains("://"))
            {
                // On Android, we need to unpack the StreamingAssets from the .jar file in which
                // they're archived into the native file system.
                dir = Application.temporaryCachePath;
                foreach (string ext in NFTDataExts)
                {
                    string basename = NFTDataName + "." + ext;
                    if (!unpackStreamingAssetToCacheDir(basename))
                    {
                        dir = "";
                        break;
                    }
                }
            }
                                #endif

            if (!string.IsNullOrEmpty(dir) && !string.IsNullOrEmpty(NFTDataName))
            {
                cfg = "nft;" + System.IO.Path.Combine(dir, NFTDataName);
            }
            break;

        default:
            // Unknown marker type?
            break;
        }

        // If a valid config. could be assembled, get ARToolKit to process it, and assign the resulting ARMarker UID.
        if (!string.IsNullOrEmpty(cfg))
        {
            UID = PluginFunctions.arwAddMarker(cfg);
            if (UID == NO_ID)
            {
                ARController.Log(LogTag + "Error loading marker.");
            }
            else
            {
                // Marker loaded. Do any additional configuration.
                //ARController.Log("Added marker with cfg='" + cfg + "'");

                if (MarkerType == MarkerType.Square || MarkerType == MarkerType.SquareBarcode)
                {
                    UseContPoseEstimation = currentUseContPoseEstimation;
                }
                Filtered         = currentFiltered;
                FilterSampleRate = currentFilterSampleRate;
                FilterCutoffFreq = currentFilterCutoffFreq;
                if (MarkerType == MarkerType.NFT)
                {
                    NFTScale = currentNFTScale;
                }

                // Retrieve any required information from the configured ARToolKit ARMarker.
                if (MarkerType == MarkerType.NFT)
                {
                    int imageSizeX, imageSizeY;
                    PluginFunctions.arwGetMarkerPatternConfig(UID, 0, null, out NFTWidth, out NFTHeight, out imageSizeX, out imageSizeY);
                    NFTWidth  *= 0.001f;
                    NFTHeight *= 0.001f;
                    //ARController.Log("Got NFTWidth=" + NFTWidth + ", NFTHeight=" + NFTHeight + ".");
                }
                else
                {
                    // Create array of patterns. A single marker will have array length 1.
                    int numPatterns = PluginFunctions.arwGetMarkerPatternCount(UID);
                    //ARController.Log("Marker with UID=" + UID + " has " + numPatterns + " patterns.");
                    if (numPatterns > 0)
                    {
                        patterns = new ARPattern[numPatterns];
                        for (int i = 0; i < numPatterns; i++)
                        {
                            patterns[i] = new ARPattern(UID, i);
                        }
                    }
                }
            }
        }
    }
예제 #18
0
 internal Server(PluginFunctions pluginFunctions)
 {
     _pluginFunctions = pluginFunctions;
 }
예제 #19
0
    IEnumerator Load(CanvasGroup landingPageCG)
    {
        int loadingCount = 0;

        LoadingText.text = "0%";
        if (arMarkers.Length > 0)
        {
            foreach (ARMarker marker in arMarkers)
            {
                if (!marker.isActiveAndEnabled)
                {
                    marker.enabled = true;
                }
                loadingCount++;
                LoadingText.text = ((loadingCount * 100) / (arMarkers.Length + 1)).ToString() + "%";
                yield return(new WaitForSeconds(0.7f));
            }
        }

        Debug.Log(arController.enabled + " : " + !arController.IsRunning);
        //yield return new WaitForSeconds(5);
        if (!arController.enabled)
        {
            arController.enabled = true;
        }
        else
        {
            if (!arController.IsRunning)
            {
                arController.StartAR();
            }
        }

        MarkerTagToVideo = new Dictionary <string, string>();
        MarkerTagToVideo.Add("1-A", "SmartLab02");
        MarkerTagToVideo.Add("1-B", "SmartLab02");
        MarkerTagToVideo.Add("2-A", "SmartLab08");
        MarkerTagToVideo.Add("2-B", "SmartLab08");
        MarkerTagToVideo.Add("3-A", "SmartLab07");
        MarkerTagToVideo.Add("3-B", "SmartLab07");
        MarkerTagToVideo.Add("4-A", "SmartLab01");
        MarkerTagToVideo.Add("4-B", "SmartLab01");
        MarkerTagToVideo.Add("5-A", "SmartLab03");
        MarkerTagToVideo.Add("5-B", "SmartLab03");
        MarkerTagToVideo.Add("6-A", "SmartLab05");
        MarkerTagToVideo.Add("6-B", "SmartLab05");
        MarkerTagToVideo.Add("7-A", "SmartLab04");
        MarkerTagToVideo.Add("7-B", "SmartLab04");
        MarkerTagToVideo.Add("8-A", "SmartLab06");
        MarkerTagToVideo.Add("8-B", "SmartLab06");
        MarkerTagToVideo.Add("8-C", "SmartLab06");



        //Destroy(LoadingPanel);
        //yield return new WaitUntil(() => arController.IsRunning);PluginFunctions.arwIsRunning()

        yield return(new WaitUntil(() => PluginFunctions.arwIsRunning()));

        LoadingText.text = "100%";
        yield return(new WaitForSeconds(0.4f));

        LoadingPanel.SetActive(false);
        landingPageCG.alpha = 0;
        //yield return new WaitForSeconds(0.01f);
    }
예제 #20
0
        /// <summary>
        ///     Parses the .xml file and performs the actions specified
        /// </summary>
        /// <param name="name">Scanner name</param>
        /// <param name="pluginFile">Path to .xml file</param>
        public void ScanPlugin(string name, string pluginFile)
        {
            if (!File.Exists(pluginFile))
            {
                return;
            }

            var pluginFunctions = new PluginFunctions();

            try
            {
                using (var xmlReader = XmlReader.Create(pluginFile))
                {
                    while (xmlReader.ReadToFollowing("IsRunning"))
                    {
                        if (CancellationToken.IsCancellationRequested)
                        {
                            return;
                        }

                        var procName = xmlReader.ReadElementContentAsString();

                        if (RunningMsg.DisplayRunningMsg(name, procName).GetValueOrDefault() == false)
                        {
                            return;
                        }
                    }
                }

                using (var xmlReader = XmlReader.Create(pluginFile))
                {
                    if (xmlReader.ReadToFollowing("Action"))
                    {
                        while (xmlReader.Read())
                        {
                            if (CancellationToken.IsCancellationRequested)
                            {
                                return;
                            }

                            if (xmlReader.NodeType != XmlNodeType.Element)
                            {
                                continue;
                            }

                            if (xmlReader.Name == "DeleteKey")
                            {
                                var regPath = xmlReader.ReadElementContentAsString();
                                var regKey  = Utils.RegOpenKey(regPath);
                                var recurse = xmlReader.GetAttribute("Recursive") == "Y";

                                pluginFunctions.DeleteKey(regKey, recurse);
                            }

                            if (xmlReader.Name == "DeleteValue")
                            {
                                var regPath        = xmlReader.GetAttribute("RegKey");
                                var valueNameRegEx = xmlReader.GetAttribute("ValueName");

                                var regKey = Utils.RegOpenKey(regPath, false);

                                pluginFunctions.DeleteValue(regKey, valueNameRegEx);
                            }

                            if (xmlReader.Name == "DeleteFile")
                            {
                                var filePath = MiscFunctions.ExpandVars(xmlReader.ReadElementContentAsString());

                                pluginFunctions.DeleteFile(filePath);
                            }

                            if (xmlReader.Name == "DeleteFolder")
                            {
                                var folderPath = MiscFunctions.ExpandVars(xmlReader.ReadElementContentAsString());
                                var recurse    = xmlReader.GetAttribute("Recursive") == "Y";

                                pluginFunctions.DeleteFolder(folderPath, recurse);
                            }

                            if (xmlReader.Name == "DeleteFileList")
                            {
                                var searchPath        = MiscFunctions.ExpandVars(xmlReader.GetAttribute("Path"));
                                var searchText        = xmlReader.GetAttribute("SearchText");
                                var includeSubFolders = xmlReader.GetAttribute("IncludeSubFolders") == "Y"
                                    ? SearchOption.AllDirectories
                                    : SearchOption.TopDirectoryOnly;

                                pluginFunctions.DeleteFileList(searchPath, searchText, includeSubFolders);
                            }

                            if (xmlReader.Name == "DeleteFolderList")
                            {
                                var searchPath        = MiscFunctions.ExpandVars(xmlReader.GetAttribute("Path"));
                                var searchText        = xmlReader.GetAttribute("SearchText");
                                var includeSubFolders = xmlReader.GetAttribute("IncludeSubFolders") == "Y"
                                    ? SearchOption.AllDirectories
                                    : SearchOption.TopDirectoryOnly;

                                pluginFunctions.DeleteFolderList(searchPath, searchText, includeSubFolders);
                            }

                            if (xmlReader.Name == "FindRegKey")
                            {
                                var regKey         = xmlReader.GetAttribute("RegKey");
                                var includeSubKeys = xmlReader.GetAttribute("IncludeSubKeys") == "Y";

                                var rk          = Utils.RegOpenKey(regKey, false);
                                var xmlChildren = xmlReader.ReadSubtree();

                                pluginFunctions.DeleteFoundRegKeys(rk, includeSubKeys, xmlChildren);
                            }

                            if (xmlReader.Name == "FindPath")
                            {
                                var searchPath        = MiscFunctions.ExpandVars(xmlReader.GetAttribute("Path"));
                                var searchText        = xmlReader.GetAttribute("SearchText");
                                var includeSubFolders = xmlReader.GetAttribute("IncludeSubFolders") == "Y"
                                    ? SearchOption.AllDirectories
                                    : SearchOption.TopDirectoryOnly;

                                var xmlChildren = xmlReader.ReadSubtree();

                                pluginFunctions.DeleteFoundPaths(searchPath, searchText, includeSubFolders, xmlChildren);
                            }

                            if (xmlReader.Name == "RemoveINIValue")
                            {
                                var filePath     = MiscFunctions.ExpandVars(xmlReader.GetAttribute("Path"));
                                var sectionRegEx = xmlReader.GetAttribute("Section");
                                var valueRegEx   = xmlReader.GetAttribute("Name");

                                pluginFunctions.DeleteIniValue(filePath, sectionRegEx, valueRegEx);
                            }

                            if (xmlReader.Name == "RemoveINISection")
                            {
                                var filePath     = MiscFunctions.ExpandVars(xmlReader.GetAttribute("Path"));
                                var sectionRegEx = xmlReader.GetAttribute("Section");

                                pluginFunctions.DeleteIniSection(filePath, sectionRegEx);
                            }

                            if (xmlReader.Name == "RemoveXML")
                            {
                                var filePath = MiscFunctions.ExpandVars(xmlReader.GetAttribute("Path"));
                                var xPath    = xmlReader.GetAttribute("XPath");

                                pluginFunctions.DeleteXml(filePath, xPath);
                            }
                        }
                    }
                }
            }
            catch (SecurityException ex)
            {
                Debug.WriteLine("The following error occurred: {0}\nUnable to load plugin file ({1})", ex.Message,
                                pluginFile);
            }
            catch (UriFormatException ex)
            {
                Debug.WriteLine("The following error occurred: {0}\nUnable to load plugin file ({1})", ex.Message,
                                pluginFile);
            }

            if (pluginFunctions.RegistrySubKeys.Count > 0)
            {
                Wizard.StoreBadRegKeySubKeys(name, pluginFunctions.RegistrySubKeys);
            }

            if (pluginFunctions.RegistryValueNames.Count > 0)
            {
                Wizard.StoreBadRegKeyValueNames(name, pluginFunctions.RegistryValueNames);
            }

            if (pluginFunctions.FilePaths.Count > 0)
            {
                Wizard.StoreBadFileList(name, pluginFunctions.FilePaths.ToArray());
            }

            if (pluginFunctions.Folders.Count > 0)
            {
                Wizard.StoreBadFolderList(name, pluginFunctions.Folders);
            }

            if (pluginFunctions.IniList.Count > 0)
            {
                Wizard.StoreIniKeys(name, pluginFunctions.IniList.ToArray());
            }

            if (pluginFunctions.XmlPaths.Count > 0)
            {
                Wizard.StoreXml(name, pluginFunctions.XmlPaths);
            }
        }
예제 #21
0
 public PluginWithMetaData(Foo plugin)
 {
     Plugin = plugin;
     MD5    = PluginFunctions.GetMD5(plugin);
 }