コード例 #1
0
ファイル: SubjectIdentifier.cs プロジェクト: scholtz/FastZep
 internal SubjectIdentifier(CAPI.CRYPTOAPI_BLOB issuer, CAPI.CRYPTOAPI_BLOB serialNumber)
 {
     bool flag = true;
     byte* numPtr = (byte*)(void*)serialNumber.pbData;
     for (uint index = 0U; index < serialNumber.cbData; ++index)
     {
         if ((int)*numPtr++ != 0)
         {
             flag = false;
             break;
         }
     }
     if (flag)
     {
         byte[] numArray = new byte[(IntPtr)issuer.cbData];
         Marshal.Copy(issuer.pbData, numArray, 0, numArray.Length);
         if (string.Compare("CN=Dummy Signer", new X500DistinguishedName(numArray).Name, StringComparison.OrdinalIgnoreCase) == 0)
         {
             this.Reset(SubjectIdentifierType.NoSignature, (object)null);
             return;
         }
     }
     if (flag)
     {
         this.m_type = SubjectIdentifierType.SubjectKeyIdentifier;
         this.m_value = (object)string.Empty;
         uint cbDecodedValue = 0U;
         SafeLocalAllocHandle decodedValue = SafeLocalAllocHandle.InvalidHandle;
         if (!CAPI.DecodeObject(new IntPtr(7L), issuer.pbData, issuer.cbData, out decodedValue, out cbDecodedValue))
             throw new CryptographicException(Marshal.GetLastWin32Error());
         using (decodedValue)
         {
             CAPI.CERT_NAME_INFO certNameInfo = (CAPI.CERT_NAME_INFO)Marshal.PtrToStructure(decodedValue.DangerousGetHandle(), typeof(CAPI.CERT_NAME_INFO));
             for (uint index1 = 0U; index1 < certNameInfo.cRDN; ++index1)
             {
                 CAPI.CERT_RDN certRdn = (CAPI.CERT_RDN)Marshal.PtrToStructure(new IntPtr((long)certNameInfo.rgRDN + (long)index1 * (long)Marshal.SizeOf(typeof(CAPI.CERT_RDN))), typeof(CAPI.CERT_RDN));
                 for (uint index2 = 0U; index2 < certRdn.cRDNAttr; ++index2)
                 {
                     CAPI.CERT_RDN_ATTR certRdnAttr = (CAPI.CERT_RDN_ATTR)Marshal.PtrToStructure(new IntPtr((long)certRdn.rgRDNAttr + (long)index2 * (long)Marshal.SizeOf(typeof(CAPI.CERT_RDN_ATTR))), typeof(CAPI.CERT_RDN_ATTR));
                     if (string.Compare("1.3.6.1.4.1.311.10.7.1", certRdnAttr.pszObjId, StringComparison.OrdinalIgnoreCase) == 0 && (int)certRdnAttr.dwValueType == 2)
                     {
                         byte[] numArray = new byte[(IntPtr)certRdnAttr.Value.cbData];
                         Marshal.Copy(certRdnAttr.Value.pbData, numArray, 0, numArray.Length);
                         this.Reset(SubjectIdentifierType.SubjectKeyIdentifier, (object)X509Utils.EncodeHexString(numArray));
                         return;
                     }
                 }
             }
         }
         throw new CryptographicException(-2146889715);
     }
     else
     {
         CAPI.CERT_ISSUER_SERIAL_NUMBER pIssuerAndSerial;
         pIssuerAndSerial.Issuer = issuer;
         pIssuerAndSerial.SerialNumber = serialNumber;
         this.Reset(SubjectIdentifierType.IssuerAndSerialNumber, (object)PkcsUtils.DecodeIssuerSerial(pIssuerAndSerial));
     }
 }
コード例 #2
0
ファイル: PublicKeyInfo.cs プロジェクト: scholtz/FastZep
 internal PublicKeyInfo(CAPI.CERT_PUBLIC_KEY_INFO keyInfo)
 {
     this.m_algorithm = new AlgorithmIdentifier(keyInfo);
     this.m_keyValue = new byte[(IntPtr)keyInfo.PublicKey.cbData];
     if (this.m_keyValue.Length <= 0)
         return;
     Marshal.Copy(keyInfo.PublicKey.pbData, this.m_keyValue, 0, this.m_keyValue.Length);
 }
コード例 #3
0
 internal AlgorithmIdentifier(CAPI.CERT_PUBLIC_KEY_INFO keyInfo)
 {
     SafeLocalAllocHandle localAllocHandle = CAPI.LocalAlloc(64U, new IntPtr(Marshal.SizeOf(typeof(CAPI.CERT_PUBLIC_KEY_INFO))));
     Marshal.StructureToPtr((object)keyInfo, localAllocHandle.DangerousGetHandle(), false);
     int keyLength = (int)CAPI.CAPISafe.CertGetPublicKeyLength(65537U, localAllocHandle.DangerousGetHandle());
     byte[] numArray = new byte[(IntPtr)keyInfo.Algorithm.Parameters.cbData];
     if (numArray.Length > 0)
         Marshal.Copy(keyInfo.Algorithm.Parameters.pbData, numArray, 0, numArray.Length);
     Marshal.DestroyStructure(localAllocHandle.DangerousGetHandle(), typeof(CAPI.CERT_PUBLIC_KEY_INFO));
     localAllocHandle.Dispose();
     this.Reset(new Oid(keyInfo.Algorithm.pszObjId), keyLength, numArray);
 }
コード例 #4
0
 internal KeyTransRecipientInfo(SafeLocalAllocHandle pRecipientInfo, CAPI.CERT_INFO certInfo, uint index)
     : base(RecipientInfoType.KeyTransport, RecipientSubType.Pkcs7KeyTransport, pRecipientInfo, (object)certInfo, index)
 {
     int version = 2;
     byte* numPtr = (byte*)(void*)certInfo.SerialNumber.pbData;
     for (int index1 = 0; (long)index1 < (long)certInfo.SerialNumber.cbData; ++index1)
     {
         if ((int)*numPtr++ != 0)
         {
             version = 0;
             break;
         }
     }
     this.Reset(version);
 }
コード例 #5
0
 internal SubjectIdentifierOrKey(CAPI.CERT_ID certId)
 {
     switch (certId.dwIdChoice)
     {
         case 1U:
             this.Reset(SubjectIdentifierOrKeyType.IssuerAndSerialNumber, (object)PkcsUtils.DecodeIssuerSerial(certId.Value.IssuerSerialNumber));
             break;
         case 2U:
             byte[] numArray = new byte[(IntPtr)certId.Value.KeyId.cbData];
             Marshal.Copy(certId.Value.KeyId.pbData, numArray, 0, numArray.Length);
             this.Reset(SubjectIdentifierOrKeyType.SubjectKeyIdentifier, (object)X509Utils.EncodeHexString(numArray));
             break;
         default:
             throw new CryptographicException(SecurityResources.GetResourceString("Cryptography_Cms_Invalid_Subject_Identifier_Type"), certId.dwIdChoice.ToString((IFormatProvider)CultureInfo.InvariantCulture));
     }
 }
コード例 #6
0
 public OvrAvatarAssetTexture(UInt64 _assetId, IntPtr asset) {
     assetID = _assetId:
     ovrAvatarTextureAssetData textureAssetData = CAPI.ovrAvatarAsset_GetTextureData(asset):
     TextureFormat format:
     IntPtr textureData = textureAssetData.textureData:
     int textureDataSize = (int)textureAssetData.textureDataSize:
     switch (textureAssetData.format)
     {
         case ovrAvatarTextureFormat.RGB24:
             format = TextureFormat.RGB24:
             break:
         case ovrAvatarTextureFormat.DXT1:
             format = TextureFormat.DXT1:
             break:
         case ovrAvatarTextureFormat.DXT5:
             format = TextureFormat.DXT5:
             break:
         case ovrAvatarTextureFormat.ASTC_RGB_6x6:
             format = TextureFormat.ASTC_RGB_6x6:
             textureData = new IntPtr(textureData.ToInt64() + ASTCHeaderSize):
             textureDataSize -= ASTCHeaderSize:
             break:
         case ovrAvatarTextureFormat.ASTC_RGB_6x6_MIPMAPS:
             format = TextureFormat.ASTC_RGB_6x6:
             break:
         default:
             throw new NotImplementedException(
                 string.Format("Unsupported texture format {0}",
                               textureAssetData.format.ToString())):
     }
     texture = new Texture2D(
         (int)textureAssetData.sizeX, (int)textureAssetData.sizeY,
         format, textureAssetData.mipCount > 1, false):
     texture.LoadRawTextureData(textureData, textureDataSize):
     texture.Apply(true, false):
 }
コード例 #7
0
ファイル: OvrAvatar.cs プロジェクト: siruvia/DokoLab
    private bool AddRenderParts(OvrAvatarComponent ovrComponent, ovrAvatarComponent component, Transform parent)
    {
        bool combineMeshes = true;

        for (UInt32 renderPartIndex = 0; renderPartIndex < component.renderPartCount; renderPartIndex++)
        {
            GameObject renderPartObject = new GameObject();
            renderPartObject.name = GetRenderPartName(component, renderPartIndex);
            renderPartObject.transform.SetParent(parent);
            IntPtr renderPart             = GetRenderPart(component, renderPartIndex);
            ovrAvatarRenderPartType  type = CAPI.ovrAvatarRenderPart_GetType(renderPart);
            OvrAvatarRenderComponent ovrRenderPart;
            switch (type)
            {
            case ovrAvatarRenderPartType.SkinnedMeshRender:
                ovrRenderPart = AddSkinnedMeshRenderComponent(renderPartObject, CAPI.ovrAvatarRenderPart_GetSkinnedMeshRender(renderPart));
                break;

            case ovrAvatarRenderPartType.SkinnedMeshRenderPBS:
                ovrRenderPart = AddSkinnedMeshRenderPBSComponent(renderPartObject, CAPI.ovrAvatarRenderPart_GetSkinnedMeshRenderPBS(renderPart));
                break;

            case ovrAvatarRenderPartType.ProjectorRender:
                combineMeshes = false;
                ovrRenderPart = AddProjectorRenderComponent(renderPartObject, CAPI.ovrAvatarRenderPart_GetProjectorRender(renderPart));
                break;

            default:
                throw new NotImplementedException(string.Format("Unsupported render part type: {0}", type.ToString()));
            }

            ovrComponent.RenderParts.Add(ovrRenderPart);
        }

        return(combineMeshes);
    }
コード例 #8
0
        /// <summary>
        /// Example code to call Rosette API to get linked (against Wikipedia) entities from a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //entities_linked yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   EntitiesLinkedCAPI        = new CAPI(apikey);
                string entities_linked_text_data = @"Last month director Paul Feig announced the movie will have an all-star female cast including Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon.";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> EntitiesLinkedResult = EntitiesLinkedCAPI.EntitiesLinked(entities_linked_text_data);
                Console.WriteLine(new JavaScriptSerializer().Serialize(EntitiesLinkedResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #9
0
        private static unsafe SafeLocalAllocHandle EncodePublicKey(PublicKey key)
        {
            SafeLocalAllocHandle publicKeyInfo = SafeLocalAllocHandle.InvalidHandle;

            CAPI.CERT_PUBLIC_KEY_INFO2 *pPublicKeyInfo = null;
            string objId = key.Oid.Value;

            byte[] encodedParameters = key.EncodedParameters.RawData;
            byte[] encodedKeyValue   = key.EncodedKeyValue.RawData;

            uint cbPublicKeyInfo = (uint)(Marshal.SizeOf(typeof(CAPI.CERT_PUBLIC_KEY_INFO2)) +
                                          X509Utils.AlignedLength((uint)(objId.Length + 1)) +
                                          X509Utils.AlignedLength((uint)encodedParameters.Length) +
                                          encodedKeyValue.Length);

            publicKeyInfo  = CAPI.LocalAlloc(CAPI.LPTR, new IntPtr(cbPublicKeyInfo));
            pPublicKeyInfo = (CAPI.CERT_PUBLIC_KEY_INFO2 *)publicKeyInfo.DangerousGetHandle();
            IntPtr pszObjId     = new IntPtr((long)pPublicKeyInfo + Marshal.SizeOf(typeof(CAPI.CERT_PUBLIC_KEY_INFO2)));
            IntPtr pbParameters = new IntPtr((long)pszObjId + X509Utils.AlignedLength(((uint)(objId.Length + 1))));
            IntPtr pbPublicKey  = new IntPtr((long)pbParameters + X509Utils.AlignedLength((uint)encodedParameters.Length));

            pPublicKeyInfo->Algorithm.pszObjId = pszObjId;
            byte[] szObjId = new byte[objId.Length + 1];
            Encoding.ASCII.GetBytes(objId, 0, objId.Length, szObjId, 0);
            Marshal.Copy(szObjId, 0, pszObjId, szObjId.Length);
            if (encodedParameters.Length > 0)
            {
                pPublicKeyInfo->Algorithm.Parameters.cbData = (uint)encodedParameters.Length;
                pPublicKeyInfo->Algorithm.Parameters.pbData = pbParameters;
                Marshal.Copy(encodedParameters, 0, pbParameters, encodedParameters.Length);
            }
            pPublicKeyInfo->PublicKey.cbData = (uint)encodedKeyValue.Length;
            pPublicKeyInfo->PublicKey.pbData = pbPublicKey;
            Marshal.Copy(encodedKeyValue, 0, pbPublicKey, encodedKeyValue.Length);
            return(publicKeyInfo);
        }
コード例 #10
0
        /// <summary>
        /// Example code to call Rosette API to get Chinese readings for words in a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //morphology_han_readings yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   MorphologyCAPI = new CAPI(apikey);
                string morphology_han_readings_data = @"北京大学生物系主任办公室内部会议";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> MorphologyResult = MorphologyCAPI.Morphology(morphology_han_readings_data, null, null, null, null, "han-readings");
                Console.WriteLine(new JavaScriptSerializer().Serialize(MorphologyResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #11
0
ファイル: relationships.cs プロジェクト: fhasanaj/csharp
        /// <summary>
        /// Example code to call Rosette API to get sentences in a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //relationships yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   RelationshipsCAPI       = new CAPI(apikey);
                string relationships_text_data = @"Bill Murray is in the new Ghostbusters film!";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> RelationshipsResult = RelationshipsCAPI.Relationships(relationships_text_data);
                Console.WriteLine(new JavaScriptSerializer().Serialize(RelationshipsResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #12
0
        internal static unsafe X509IssuerSerial DecodeIssuerSerial(CAPI.CERT_ISSUER_SERIAL_NUMBER pIssuerAndSerial)
        {
            SafeLocalAllocHandle invalidHandle = SafeLocalAllocHandle.InvalidHandle;
            uint csz = CAPI.CAPISafe.CertNameToStrW(65537U, new IntPtr((void *)&pIssuerAndSerial.Issuer), 33554435U, invalidHandle, 0U);

            if (csz <= 1U)
            {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }
            SafeLocalAllocHandle psz = CAPI.LocalAlloc(0U, new IntPtr((long)(2U * csz)));

            if (CAPI.CAPISafe.CertNameToStrW(65537U, new IntPtr((void *)&pIssuerAndSerial.Issuer), 33554435U, psz, csz) <= 1U)
            {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }
            X509IssuerSerial x509IssuerSerial = new X509IssuerSerial();

            x509IssuerSerial.IssuerName = Marshal.PtrToStringUni(psz.DangerousGetHandle());
            byte[] numArray = new byte[(IntPtr)pIssuerAndSerial.SerialNumber.cbData];
            Marshal.Copy(pIssuerAndSerial.SerialNumber.pbData, numArray, 0, numArray.Length);
            x509IssuerSerial.SerialNumber = X509Utils.EncodeHexStringFromInt(numArray);
            psz.Dispose();
            return(x509IssuerSerial);
        }
コード例 #13
0
        internal static unsafe CryptographicAttributeObjectCollection GetUnprotectedAttributes(SafeCryptMsgHandle safeCryptMsgHandle)
        {
            uint num = 0U;
            CryptographicAttributeObjectCollection objectCollection = new CryptographicAttributeObjectCollection();
            SafeLocalAllocHandle invalidHandle = SafeLocalAllocHandle.InvalidHandle;

            if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle, 37U, 0U, invalidHandle, new IntPtr((void *)&num)) && Marshal.GetLastWin32Error() != -2146889713)
            {
                PkcsUtils.checkErr(Marshal.GetLastWin32Error());
            }
            if (num > 0U)
            {
                SafeLocalAllocHandle localAllocHandle;
                using (localAllocHandle = CAPI.LocalAlloc(64U, new IntPtr((long)num)))
                {
                    if (!CAPI.CAPISafe.CryptMsgGetParam(safeCryptMsgHandle, 37U, 0U, localAllocHandle, new IntPtr((void *)&num)))
                    {
                        PkcsUtils.checkErr(Marshal.GetLastWin32Error());
                    }
                    objectCollection = new CryptographicAttributeObjectCollection(localAllocHandle);
                }
            }
            return(objectCollection);
        }
コード例 #14
0
ファイル: translated-name.cs プロジェクト: fhasanaj/csharp
        /// <summary>
        /// Example code to call Rosette API to translate a name from language to another.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //translated_name yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI TranslatedNameCAPI = new CAPI(apikey);
                string translated_name_data = @"معمر محمد أبو منيار القذاف";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary<string, Object> TranslatedNameResult = TranslatedNameCAPI.TranslatedName("translated_name_data, null, null, "eng", null, null, null, "PERSON");
                Console.WriteLine(new JavaScriptSerializer().Serialize(TranslatedNameResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
    public void UpdateAvatar(IntPtr nativeComponent)
    {
        CAPI.ovrAvatarComponent_Get(nativeComponent, false, ref nativeAvatarComponent);

        OvrAvatar.ConvertTransform(nativeAvatarComponent.transform, transform);

        for (UInt32 renderPartIndex = 0; renderPartIndex < nativeAvatarComponent.renderPartCount; renderPartIndex++)
        {
            if (RenderParts.Count <= renderPartIndex)
            {
                break;
            }

            OvrAvatarRenderComponent renderComponent = RenderParts[(int)renderPartIndex];
            IntPtr renderPart            = OvrAvatar.GetRenderPart(nativeAvatarComponent, renderPartIndex);
            ovrAvatarRenderPartType type = CAPI.ovrAvatarRenderPart_GetType(renderPart);
            // Debug.Log("Updating avatar");
            switch (type)
            {
            case ovrAvatarRenderPartType.SkinnedMeshRender:
                ((OvrAvatarSkinnedMeshRenderComponent)renderComponent).UpdateSkinnedMeshRender(this, owner, renderPart);
                break;

            case ovrAvatarRenderPartType.SkinnedMeshRenderPBS:
                ((OvrAvatarSkinnedMeshRenderPBSComponent)renderComponent).UpdateSkinnedMeshRenderPBS(owner, renderPart, renderComponent.mesh.sharedMaterial);
                break;

            case ovrAvatarRenderPartType.SkinnedMeshRenderPBS_V2:
                ((OvrAvatarSkinnedMeshPBSV2RenderComponent)renderComponent).UpdateSkinnedMeshRender(this, owner, renderPart);
                break;

            default:
                break;
            }
        }
    }
コード例 #16
0
    private void LoadBlendShapes(IntPtr asset, long vertexCount)
    {
        UInt32 blendShapeCount = CAPI.ovrAvatarAsset_GetMeshBlendShapeCount(asset);
        IntPtr blendShapeVerts = CAPI.ovrAvatarAsset_GetMeshBlendShapeVertices(asset);

        AvatarLogger.Log("LoadBlendShapes: " + blendShapeCount);

        if (blendShapeVerts != IntPtr.Zero)
        {
            long offset                 = 0;
            long blendVertexSize        = (long)Marshal.SizeOf(typeof(ovrAvatarBlendVertex));
            long blendVertexBufferStart = blendShapeVerts.ToInt64();

            for (UInt32 blendIndex = 0; blendIndex < blendShapeCount; blendIndex++)
            {
                Vector3[] blendVerts    = new Vector3[vertexCount];
                Vector3[] blendNormals  = new Vector3[vertexCount];
                Vector3[] blendTangents = new Vector3[vertexCount];

                for (long i = 0; i < vertexCount; i++)
                {
                    ovrAvatarBlendVertex vertex = (ovrAvatarBlendVertex)Marshal.PtrToStructure(new IntPtr(blendVertexBufferStart + offset), typeof(ovrAvatarBlendVertex));
                    blendVerts[i]    = new Vector3(vertex.x, vertex.y, -vertex.z);
                    blendNormals[i]  = new Vector3(vertex.nx, vertex.ny, -vertex.nz);
                    blendTangents[i] = new Vector4(vertex.tx, vertex.ty, -vertex.tz);

                    offset += blendVertexSize;
                }

                IntPtr      namePtr     = CAPI.ovrAvatarAsset_GetMeshBlendShapeName(asset, blendIndex);
                string      name        = Marshal.PtrToStringAnsi(namePtr);
                const float frameWeight = 100f;
                mesh.AddBlendShapeFrame(name, frameWeight, blendVerts, blendNormals, blendTangents);
            }
        }
    }
コード例 #17
0
        /// <summary>
        /// Example code to call Rosette API to get sentences in a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //sentences yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   SentencesCAPI  = new CAPI(apikey);
                string sentences_data = @"This land is your land. This land is my land\nFrom California to the New York island;\nFrom the red wood forest to the Gulf Stream waters\n\nThis land was made for you and Me.\n\nAs I was walking that ribbon of highway,\nI saw above me that endless skyway:\nI saw below me that golden valley:\nThis land was made for you and me.";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> SentencesResult = SentencesCAPI.Sentences(sentences_data);
                Console.WriteLine(new JavaScriptSerializer().Serialize(SentencesResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #18
0
        private void DecodeExtension()
        {
            uint cbDecoded = 0;
            SafeLocalAllocHandle decoded = null;

            SafeLocalAllocHandle pb = X509Utils.StringToAnsiPtr(CAPI.szOID_SUBJECT_KEY_IDENTIFIER);
            bool result             = CAPI.DecodeObject(pb.DangerousGetHandle(),
                                                        m_rawData,
                                                        out decoded,
                                                        out cbDecoded);

            if (!result)
            {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }

            CAPI.CRYPTOAPI_BLOB pSubjectKeyIdentifier = (CAPI.CRYPTOAPI_BLOB)Marshal.PtrToStructure(decoded.DangerousGetHandle(), typeof(CAPI.CRYPTOAPI_BLOB));
            byte[] hexArray = CAPI.BlobToByteArray(pSubjectKeyIdentifier);
            m_subjectKeyIdentifier = X509Utils.EncodeHexString(hexArray);

            m_decoded = true;
            decoded.Dispose();
            pb.Dispose();
        }
コード例 #19
0
    public void UpdateSkinnedMeshRender(
        OvrAvatarComponent component,
        OvrAvatar avatar,
        IntPtr renderPart)
    {
        ovrAvatarVisibilityFlags visibilityMask
            = CAPI.ovrAvatarSkinnedMeshRenderPBSV2_GetVisibilityMask(renderPart);

        ovrAvatarTransform localTransform
            = CAPI.ovrAvatarSkinnedMeshRenderPBSV2_GetTransform(renderPart);

        UpdateSkinnedMesh(avatar, bones, localTransform, visibilityMask, renderPart);

        bool isActive = gameObject.activeSelf;

        if (mesh != null && !previouslyActive && isActive)
        {
            if (!isCombinedMaterial)
            {
                InitializeSingleComponentMaterial(renderPart, (int)avatar.LevelOfDetail - 1);
            }
        }

        if (blendShapeCount > 0)
        {
            const float BLEND_MULTIPLIER = 100.0f;
            CAPI.ovrAvatarSkinnedMeshRender_GetBlendShapeParams(renderPart, ref blendShapeParams);
            for (uint i = 0; i < blendShapeParams.blendShapeParamCount && i < blendShapeCount; i++)
            {
                float value = blendShapeParams.blendShapeParams[i];
                mesh.SetBlendShapeWeight((int)i, value * BLEND_MULTIPLIER);
            }
        }

        previouslyActive = isActive;
    }
コード例 #20
0
        /// <summary>
        /// Example code to call Rosette API to get tokens (words) in a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //tokens yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   TokensCAPI  = new CAPI(apikey);
                string tokens_data = @"北京大学生物系主任办公室内部会议";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> TokensResult = TokensCAPI.Tokens(tokens_data, null, null, "sentence", null);
                Console.WriteLine(new JavaScriptSerializer().Serialize(TokensResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #21
0
ファイル: x509store.cs プロジェクト: wparad/referencesource
        public void Open(OpenFlags flags)
        {
            if (m_location != StoreLocation.CurrentUser && m_location != StoreLocation.LocalMachine)
            {
                throw new ArgumentException(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.Arg_EnumIllegalVal), "m_location"));
            }

            uint storeFlags = X509Utils.MapX509StoreFlags(m_location, flags);

            if (!m_safeCertStoreHandle.IsInvalid)
            {
                // Free the current store handle
                m_safeCertStoreHandle.Dispose();
            }

            m_safeCertStoreHandle = CAPI.CertOpenStore(new IntPtr(CAPI.CERT_STORE_PROV_SYSTEM),
                                                       CAPI.X509_ASN_ENCODING | CAPI.PKCS_7_ASN_ENCODING,
                                                       IntPtr.Zero,
                                                       storeFlags,
                                                       m_storeName);

            if (m_safeCertStoreHandle == null || m_safeCertStoreHandle.IsInvalid)
            {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }

            //
            // We want the store to auto-resync when requesting a snapshot so that
            // updates to the store will be taken into account.
            //

            CAPI.CertControlStore(m_safeCertStoreHandle,
                                  0,
                                  CAPI.CERT_STORE_CTRL_AUTO_RESYNC,
                                  IntPtr.Zero);
        }
コード例 #22
0
ファイル: x509store.cs プロジェクト: wparad/referencesource
        //
        // private static methods
        //

        private static void RemoveCertificateFromStore(SafeCertStoreHandle safeCertStoreHandle, SafeCertContextHandle safeCertContext)
        {
            if (safeCertContext == null || safeCertContext.IsInvalid)
            {
                return;
            }

            if (safeCertStoreHandle == null || safeCertStoreHandle.IsInvalid || safeCertStoreHandle.IsClosed)
            {
                throw new CryptographicException(SR.GetString(SR.Cryptography_X509_StoreNotOpen));
            }

            // Find the certificate in the store.
            SafeCertContextHandle safeCertContext2 = CAPI.CertFindCertificateInStore(safeCertStoreHandle,
                                                                                     CAPI.X509_ASN_ENCODING | CAPI.PKCS_7_ASN_ENCODING,
                                                                                     0,
                                                                                     CAPI.CERT_FIND_EXISTING,
                                                                                     safeCertContext.DangerousGetHandle(),
                                                                                     SafeCertContextHandle.InvalidHandle);

            // The certificate is not present in the store, simply return.
            if (safeCertContext2 == null || safeCertContext2.IsInvalid)
            {
                return;
            }

            // CertDeleteCertificateFromStore always releases the context regardless of success
            // or failure so we don't need to manually release it
            GC.SuppressFinalize(safeCertContext2);

            // Remove from the store.
            if (!CAPI.CertDeleteCertificateFromStore(safeCertContext2))
            {
                throw new CryptographicException(Marshal.GetLastWin32Error());
            }
        }
コード例 #23
0
ファイル: OvrAvatar.cs プロジェクト: gitGfish/VR-Climbe
    void InitPostLoad()
    {
        ExpressiveGlobalInit();

        ConfigureHelpers();

        if (GetComponent <OvrAvatarLocalDriver>() != null)
        {
            // Use mic.
            lipsyncContext.audioLoopback = false;
            if (CanOwnMicrophone && IsValidMic())
            {
                micInput = MouthAnchor.gameObject.AddComponent <OVRLipSyncMicInput>();
                micInput.enableMicSelectionGUI = false;
                micInput.MicFrequency          = 44100;
                micInput.micControl            = OVRLipSyncMicInput.micActivation.ConstantSpeak;
            }

            // Set lipsync animation parameters in SDK
            CAPI.ovrAvatar_SetActionUnitOnsetSpeed(sdkAvatar, ACTION_UNIT_ONSET_SPEED);
            CAPI.ovrAvatar_SetActionUnitFalloffSpeed(sdkAvatar, ACTION_UNIT_FALLOFF_SPEED);
            CAPI.ovrAvatar_SetVisemeMultiplier(sdkAvatar, VISEME_LEVEL_MULTIPLIER);
        }
    }
コード例 #24
0
ファイル: OvrAvatar.cs プロジェクト: AldeRoberge/AG-LNL-Test
    void AvatarSpecificationCallback(IntPtr avatarSpecification)
    {
        sdkAvatar = CAPI.ovrAvatar_Create(avatarSpecification, Capabilities);
        ShowLeftController(showLeftController);
        ShowRightController(showRightController);

        // Pump the Remote driver once to push the controller type through
        if (Driver != null)
        {
            Driver.UpdateTransformsFromPose(sdkAvatar);
        }

        //Fetch all the assets that this avatar uses.
        UInt32 assetCount = CAPI.ovrAvatar_GetReferencedAssetCount(sdkAvatar);

        for (UInt32 i = 0; i < assetCount; ++i)
        {
            UInt64 id = CAPI.ovrAvatar_GetReferencedAsset(sdkAvatar, i);
            if (OvrAvatarSDKManager.Instance.GetAsset(id) == null)
            {
                OvrAvatarSDKManager.Instance.BeginLoadingAsset(
                    id,
                    LevelOfDetail,
                    AssetLoadedCallback);

                assetLoadingIds.Add(id);
            }
        }

        if (CombineMeshes)
        {
            OvrAvatarSDKManager.Instance.RegisterCombinedMeshCallback(
                sdkAvatar,
                CombinedMeshLoadedCallback);
        }
    }
コード例 #25
0
        private void AvatarSpecificationCallback(IntPtr avatarSpecification)
        {
#if (VIU_OCULUSVR_1_32_0_OR_NEWER || VIU_OCULUSVR_1_36_0_OR_NEWER || VIU_OCULUSVR_1_37_0_OR_NEWER) && VIU_OCULUSVR_AVATAR
            sdkAvatar = CAPI.ovrAvatar_Create(avatarSpecification, ovrAvatarCapabilities.All);
            CAPI.ovrAvatar_SetLeftControllerVisibility(sdkAvatar, true);
            CAPI.ovrAvatar_SetRightControllerVisibility(sdkAvatar, true);

            //Fetch all the assets that this avatar uses.
            UInt32 assetCount = CAPI.ovrAvatar_GetReferencedAssetCount(sdkAvatar);
            for (UInt32 i = 0; i < assetCount; ++i)
            {
                UInt64 id = CAPI.ovrAvatar_GetReferencedAsset(sdkAvatar, i);
                if (OvrAvatarSDKManager.Instance.GetAsset(id) == null)
                {
                    OvrAvatarSDKManager.Instance.BeginLoadingAsset(
                        id,
                        ovrAvatarAssetLevelOfDetail.Highest,
                        AssetLoadedCallback);

                    assetLoadingIds.Add(id);
                }
            }
#endif
        }
コード例 #26
0
        /// <summary>
        /// Example code to call Rosette API to get part-of-speech tags for words a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //morphology_parts_of_speech yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   MorphologyCAPI = new CAPI(apikey);
                string morphology_parts_of_speech_data = @"The fact is that the geese just went back to get a rest and I'm not banking on their return soon";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> MorphologyResult = MorphologyCAPI.Morphology(morphology_parts_of_speech_data, null, null, null, null, "parts-of-speech");
                Console.WriteLine(new JavaScriptSerializer().Serialize(MorphologyResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #27
0
    private void DispatchAvatarSpecificationRequest(AvatarSpecRequestParams avatarSpecRequest)
    {
        textureCopyManager.CheckFallbackTextureSet(avatarSpecRequest._lod);
        CAPI.ovrAvatar_SetForceASTCTextures(avatarSpecRequest._forceMobileTextureFormat);

        HashSet <specificationCallback> callbackSet;

        if (!specificationCallbacks.TryGetValue(avatarSpecRequest._userId, out callbackSet))
        {
            callbackSet = new HashSet <specificationCallback>();
            specificationCallbacks.Add(avatarSpecRequest._userId, callbackSet);

            IntPtr specRequest = CAPI.ovrAvatarSpecificationRequest_Create(avatarSpecRequest._userId);
            CAPI.ovrAvatarSpecificationRequest_SetLookAndFeelVersion(specRequest, avatarSpecRequest._lookVersion);
            CAPI.ovrAvatarSpecificationRequest_SetFallbackLookAndFeelVersion(specRequest, avatarSpecRequest._fallbackVersion);
            CAPI.ovrAvatarSpecificationRequest_SetLevelOfDetail(specRequest, avatarSpecRequest._lod);
            CAPI.ovrAvatarSpecificationRequest_SetCombineMeshes(specRequest, avatarSpecRequest._useCombinedMesh);
            CAPI.ovrAvatarSpecificationRequest_SetExpressiveFlag(specRequest, avatarSpecRequest._enableExpressive);
            CAPI.ovrAvatar_RequestAvatarSpecificationFromSpecRequest(specRequest);
            CAPI.ovrAvatarSpecificationRequest_Destroy(specRequest);
        }

        callbackSet.Add(avatarSpecRequest._callback);
    }
コード例 #28
0
        /// <summary>
        /// Example code to call Rosette API to get de-compounded words from a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //morphology_compound_components yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   MorphologyCAPI = new CAPI(apikey);
                string morphology_compound_components_data = @"Rechtsschutzversicherungsgesellschaften";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> MorphologyResult = MorphologyCAPI.Morphology(morphology_compound_components_data, null, null, null, null, "compound-components");
                Console.WriteLine(new JavaScriptSerializer().Serialize(MorphologyResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #29
0
        /// <summary>
        /// Example code to call Rosette API to detect possible languages for a piece of text.
        /// Requires Nuget Package:
        /// rosette_api
        /// </summary>
        static void Main(string[] args)
        {
            //To use the C# API, you must provide an API key
            string apikey = "Your API key";

            //You may set the API key via command line argument:
            //language yourapikeyhere
            if (args.Length != 0)
            {
                apikey = args[0];
            }
            try
            {
                CAPI   LanguageCAPI  = new CAPI(apikey);
                string language_data = @"Por favor Señorita, says the man.";
                //The results of the API call will come back in the form of a Dictionary
                Dictionary <string, Object> LanguageResult = LanguageCAPI.Language(language_data);
                Console.WriteLine(new JavaScriptSerializer().Serialize(LanguageResult));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }
コード例 #30
0
 internal KeyTransRecipientInfo(SafeLocalAllocHandle pRecipientInfo, CAPI.CMSG_KEY_TRANS_RECIPIENT_INFO keyTrans, uint index)
     : base(RecipientInfoType.KeyTransport, RecipientSubType.CmsKeyTransport, pRecipientInfo, (object)keyTrans, index)
 {
     this.Reset((int)keyTrans.dwVersion);
 }
コード例 #31
0
 internal SubjectIdentifierOrKey(CAPI.CERT_PUBLIC_KEY_INFO publicKeyInfo)
 {
     this.Reset(SubjectIdentifierOrKeyType.PublicKeyInfo, (object)new PublicKeyInfo(publicKeyInfo));
 }
コード例 #32
0
 public SdkAccount(IntPtr o)
 {
     AccountType = CAPI.ovr_SdkAccount_GetAccountType(o);
     UserId      = CAPI.ovr_SdkAccount_GetUserId(o);
 }
コード例 #33
0
 internal KeyAgreeRecipientInfo(SafeLocalAllocHandle pRecipientInfo, CAPI.CMSG_KEY_AGREE_PUBLIC_KEY_RECIPIENT_INFO publicKeyRecipient, uint index, uint subIndex)
     : base(RecipientInfoType.KeyAgreement, RecipientSubType.PublicKeyAgreement, pRecipientInfo, (object)publicKeyRecipient, index)
 {
     CAPI.CMSG_RECIPIENT_ENCRYPTED_KEY_INFO encryptedKeyInfo = (CAPI.CMSG_RECIPIENT_ENCRYPTED_KEY_INFO)Marshal.PtrToStructure(Marshal.ReadIntPtr(new IntPtr((long)publicKeyRecipient.rgpRecipientEncryptedKeys + (long)subIndex * (long)Marshal.SizeOf(typeof(IntPtr)))), typeof(CAPI.CMSG_RECIPIENT_ENCRYPTED_KEY_INFO));
     this.Reset(2U, publicKeyRecipient.dwVersion, encryptedKeyInfo, subIndex);
 }
コード例 #34
0
 private void Reset(uint originatorChoice, uint version, CAPI.CMSG_RECIPIENT_ENCRYPTED_KEY_INFO encryptedKeyInfo, uint subIndex)
 {
     this.m_encryptedKeyInfo = encryptedKeyInfo;
     this.m_originatorChoice = originatorChoice;
     this.m_version = (int)version;
     this.m_originatorIdentifier = (SubjectIdentifierOrKey)null;
     this.m_userKeyMaterial = new byte[0];
     this.m_encryptionAlgorithm = (AlgorithmIdentifier)null;
     this.m_recipientIdentifier = (SubjectIdentifier)null;
     this.m_encryptedKey = new byte[0];
     this.m_date = DateTime.MinValue;
     this.m_otherKeyAttribute = (CryptographicAttributeObject)null;
     this.m_subIndex = subIndex;
 }
コード例 #35
0
 internal AlgorithmIdentifier(CAPI.CRYPT_ALGORITHM_IDENTIFIER algorithmIdentifier)
 {
     int keyLength = 0;
     uint cbDecodedValue = 0U;
     SafeLocalAllocHandle decodedValue = SafeLocalAllocHandle.InvalidHandle;
     byte[] numArray = new byte[0];
     uint num = X509Utils.OidToAlgId(algorithmIdentifier.pszObjId);
     switch (num)
     {
         case 26114U:
             if (algorithmIdentifier.Parameters.cbData > 0U)
             {
                 if (!CAPI.DecodeObject(new IntPtr(41L), algorithmIdentifier.Parameters.pbData, algorithmIdentifier.Parameters.cbData, out decodedValue, out cbDecodedValue))
                     throw new CryptographicException(Marshal.GetLastWin32Error());
                 CAPI.CRYPT_RC2_CBC_PARAMETERS rc2CbcParameters = (CAPI.CRYPT_RC2_CBC_PARAMETERS)Marshal.PtrToStructure(decodedValue.DangerousGetHandle(), typeof(CAPI.CRYPT_RC2_CBC_PARAMETERS));
                 switch (rc2CbcParameters.dwVersion)
                 {
                     case 52U:
                         keyLength = 56;
                         break;
                     case 58U:
                         keyLength = 128;
                         break;
                     case 160U:
                         keyLength = 40;
                         break;
                 }
                 if (rc2CbcParameters.fIV)
                 {
                     numArray = (byte[])rc2CbcParameters.rgbIV.Clone();
                     break;
                 }
                 else
                     break;
             }
             else
                 break;
         case 26625U:
         case 26113U:
         case 26115U:
             if (algorithmIdentifier.Parameters.cbData > 0U)
             {
                 if (!CAPI.DecodeObject(new IntPtr(25L), algorithmIdentifier.Parameters.pbData, algorithmIdentifier.Parameters.cbData, out decodedValue, out cbDecodedValue))
                     throw new CryptographicException(Marshal.GetLastWin32Error());
                 if (cbDecodedValue > 0U)
                 {
                     if ((int)num == 26625)
                     {
                         CAPI.CRYPTOAPI_BLOB cryptoapiBlob = (CAPI.CRYPTOAPI_BLOB)Marshal.PtrToStructure(decodedValue.DangerousGetHandle(), typeof(CAPI.CRYPTOAPI_BLOB));
                         if (cryptoapiBlob.cbData > 0U)
                         {
                             numArray = new byte[(IntPtr)cryptoapiBlob.cbData];
                             Marshal.Copy(cryptoapiBlob.pbData, numArray, 0, numArray.Length);
                         }
                     }
                     else
                     {
                         numArray = new byte[(IntPtr)cbDecodedValue];
                         Marshal.Copy(decodedValue.DangerousGetHandle(), numArray, 0, numArray.Length);
                     }
                 }
             }
             keyLength = (int)num != 26625 ? ((int)num != 26113 ? 192 : 64) : 128 - numArray.Length * 8;
             break;
         default:
             if (algorithmIdentifier.Parameters.cbData > 0U)
             {
                 numArray = new byte[(IntPtr)algorithmIdentifier.Parameters.cbData];
                 Marshal.Copy(algorithmIdentifier.Parameters.pbData, numArray, 0, numArray.Length);
                 break;
             }
             else
                 break;
     }
     this.Reset(new Oid(algorithmIdentifier.pszObjId), keyLength, numArray);
     decodedValue.Dispose();
 }
コード例 #36
0
ファイル: SubjectIdentifier.cs プロジェクト: scholtz/FastZep
 internal SubjectIdentifier(CAPI.CERT_INFO certInfo)
     : this(certInfo.Issuer, certInfo.SerialNumber)
 {
 }
コード例 #37
0
    void Update()
    {
        if (Instance == null)
        {
            return;
        }
#if AVATAR_DEBUG
        // Call before ovrAvatarMessage_Pop which flushes the state
        CAPI.ovrAvatar_DrawDebugLines();
#endif

        // Dispatch waiting avatar spec request
        if (avatarSpecificationQueue.Count > 0 &&
            (avatarSpecRequestAvailable ||
             Time.time - lastDispatchedAvatarSpecRequestTime >= AVATAR_SPEC_REQUEST_TIMEOUT))
        {
            avatarSpecRequestAvailable = false;
            AvatarSpecRequestParams avatarSpec = avatarSpecificationQueue.Dequeue();
            DispatchAvatarSpecificationRequest(avatarSpec);
            lastDispatchedAvatarSpecRequestTime = Time.time;
            AvatarLogger.Log("Avatar spec request dispatched: " + avatarSpec._userId);
        }

        IntPtr message = CAPI.ovrAvatarMessage_Pop();
        if (message == IntPtr.Zero)
        {
            return;
        }

        ovrAvatarMessageType messageType = CAPI.ovrAvatarMessage_GetType(message);
        switch (messageType)
        {
        case ovrAvatarMessageType.AssetLoaded:
        {
            ovrAvatarMessage_AssetLoaded assetMessage = CAPI.ovrAvatarMessage_GetAssetLoaded(message);
            IntPtr             asset       = assetMessage.asset;
            UInt64             assetID     = assetMessage.assetID;
            ovrAvatarAssetType assetType   = CAPI.ovrAvatarAsset_GetType(asset);
            OvrAvatarAsset     assetData   = null;
            IntPtr             avatarOwner = IntPtr.Zero;

            switch (assetType)
            {
            case ovrAvatarAssetType.Mesh:
                assetData = new OvrAvatarAssetMesh(assetID, asset, ovrAvatarAssetType.Mesh);
                break;

            case ovrAvatarAssetType.Texture:
                assetData = new OvrAvatarAssetTexture(assetID, asset);
                break;

            case ovrAvatarAssetType.Material:
                assetData = new OvrAvatarAssetMaterial(assetID, asset);
                break;

            case ovrAvatarAssetType.CombinedMesh:
                avatarOwner = CAPI.ovrAvatarAsset_GetAvatar(asset);
                assetData   = new OvrAvatarAssetMesh(assetID, asset, ovrAvatarAssetType.CombinedMesh);
                break;

            case ovrAvatarAssetType.FailedLoad:
                AvatarLogger.LogWarning("Asset failed to load from SDK " + assetID);
                break;

            default:
                throw new NotImplementedException(string.Format("Unsupported asset type format {0}", assetType.ToString()));
            }

            HashSet <assetLoadedCallback> callbackSet;
            if (assetType == ovrAvatarAssetType.CombinedMesh)
            {
                if (!assetCache.ContainsKey(assetID))
                {
                    assetCache.Add(assetID, assetData);
                }

                combinedMeshLoadedCallback callback;
                if (combinedMeshLoadedCallbacks.TryGetValue(avatarOwner, out callback))
                {
                    callback(asset);
                    combinedMeshLoadedCallbacks.Remove(avatarOwner);
                }
                else
                {
                    AvatarLogger.LogWarning("Loaded a combined mesh with no owner: " + assetMessage.assetID);
                }
            }
            else
            {
                if (assetData != null && assetLoadedCallbacks.TryGetValue(assetMessage.assetID, out callbackSet))
                {
                    assetCache.Add(assetID, assetData);

                    foreach (var callback in callbackSet)
                    {
                        callback(assetData);
                    }

                    assetLoadedCallbacks.Remove(assetMessage.assetID);
                }
            }
            break;
        }

        case ovrAvatarMessageType.AvatarSpecification:
        {
            avatarSpecRequestAvailable = true;
            ovrAvatarMessage_AvatarSpecification spec = CAPI.ovrAvatarMessage_GetAvatarSpecification(message);
            HashSet <specificationCallback>      callbackSet;
            if (specificationCallbacks.TryGetValue(spec.oculusUserID, out callbackSet))
            {
                foreach (var callback in callbackSet)
                {
                    callback(spec.avatarSpec);
                }

                specificationCallbacks.Remove(spec.oculusUserID);
            }
            else
            {
                AvatarLogger.LogWarning("Error, got an avatar specification callback from a user id we don't have a record for: " + spec.oculusUserID);
            }
            break;
        }

        default:
            throw new NotImplementedException("Unhandled ovrAvatarMessageType: " + messageType);
        }
        CAPI.ovrAvatarMessage_Free(message);
    }
コード例 #38
0
ファイル: Room.cs プロジェクト: boadle/CCTV-VR
 public Room(IntPtr o)
 {
     ApplicationID = CAPI.ovr_Room_GetApplicationID(o);
     DataStore     = CAPI.DataStoreFromNative(CAPI.ovr_Room_GetDataStore(o));
     Description   = CAPI.ovr_Room_GetDescription(o);
     ID            = CAPI.ovr_Room_GetID(o);
     {
         var pointer = CAPI.ovr_Room_GetInvitedUsers(o);
         InvitedUsers = new UserList(pointer);
         if (pointer == IntPtr.Zero)
         {
             InvitedUsersOptional = null;
         }
         else
         {
             InvitedUsersOptional = InvitedUsers;
         }
     }
     IsMembershipLocked = CAPI.ovr_Room_GetIsMembershipLocked(o);
     JoinPolicy         = CAPI.ovr_Room_GetJoinPolicy(o);
     Joinability        = CAPI.ovr_Room_GetJoinability(o);
     {
         var pointer = CAPI.ovr_Room_GetMatchedUsers(o);
         MatchedUsers = new MatchmakingEnqueuedUserList(pointer);
         if (pointer == IntPtr.Zero)
         {
             MatchedUsersOptional = null;
         }
         else
         {
             MatchedUsersOptional = MatchedUsers;
         }
     }
     MaxUsers = CAPI.ovr_Room_GetMaxUsers(o);
     Name     = CAPI.ovr_Room_GetName(o);
     {
         var pointer = CAPI.ovr_Room_GetOwner(o);
         Owner = new User(pointer);
         if (pointer == IntPtr.Zero)
         {
             OwnerOptional = null;
         }
         else
         {
             OwnerOptional = Owner;
         }
     }
     {
         var pointer = CAPI.ovr_Room_GetTeams(o);
         Teams = new TeamList(pointer);
         if (pointer == IntPtr.Zero)
         {
             TeamsOptional = null;
         }
         else
         {
             TeamsOptional = Teams;
         }
     }
     Type = CAPI.ovr_Room_GetType(o);
     {
         var pointer = CAPI.ovr_Room_GetUsers(o);
         Users = new UserList(pointer);
         if (pointer == IntPtr.Zero)
         {
             UsersOptional = null;
         }
         else
         {
             UsersOptional = Users;
         }
     }
     Version = CAPI.ovr_Room_GetVersion(o);
 }
コード例 #39
0
 public LivestreamingVideoStats(IntPtr o)
 {
     CommentCount  = CAPI.ovr_LivestreamingVideoStats_GetCommentCount(o);
     ReactionCount = CAPI.ovr_LivestreamingVideoStats_GetReactionCount(o);
     TotalViews    = CAPI.ovr_LivestreamingVideoStats_GetTotalViews(o);
 }
コード例 #40
0
ファイル: CAPI.cs プロジェクト: scholtz/FastZep
 internal static byte[] BlobToByteArray(CAPI.CRYPTOAPI_BLOB blob)
 {
     if ((int)blob.cbData == 0)
         return new byte[0];
     byte[] destination = new byte[blob.cbData];
     Marshal.Copy(blob.pbData, destination, 0, destination.Length);
     return destination;
 }
コード例 #41
0
ファイル: UserReportID.cs プロジェクト: Alex666-sup/SASKA
 public UserReportID(IntPtr o)
 {
     DidCancel = CAPI.ovr_UserReportID_GetDidCancel(o);
     ID        = CAPI.ovr_UserReportID_GetID(o);
 }
コード例 #42
0
ファイル: SubjectIdentifier.cs プロジェクト: scholtz/FastZep
 internal SubjectIdentifier(CAPI.CMSG_SIGNER_INFO signerInfo)
     : this(signerInfo.Issuer, signerInfo.SerialNumber)
 {
 }
コード例 #43
0
    public OvrAvatarAssetMesh(UInt64 _assetId, IntPtr asset, ovrAvatarAssetType meshType)
    {
        assetID   = _assetId;
        mesh      = new Mesh();
        mesh.name = "Procedural Geometry for asset " + _assetId;

        switch (meshType)
        {
        case ovrAvatarAssetType.Mesh:
        {
            ovrAvatarMeshAssetData meshAssetData = CAPI.ovrAvatarAsset_GetMeshData(asset);

            AvatarLogger.Log(
                "OvrAvatarAssetMesh: "
                + _assetId
                + " "
                + meshType.ToString()
                + " VertexCount:"
                + meshAssetData.vertexCount);


            long         vertexCount = (long)meshAssetData.vertexCount;
            Vector3[]    vertices    = new Vector3[vertexCount];
            Vector3[]    normals     = new Vector3[vertexCount];
            Vector4[]    tangents    = new Vector4[vertexCount];
            Vector2[]    uv          = new Vector2[vertexCount];
            Color[]      colors      = new Color[vertexCount];
            BoneWeight[] boneWeights = new BoneWeight[vertexCount];

            long vertexSize        = (long)Marshal.SizeOf(typeof(ovrAvatarMeshVertex));
            long vertexBufferStart = meshAssetData.vertexBuffer.ToInt64();

            for (long i = 0; i < vertexCount; i++)
            {
                long offset = vertexSize * i;

                ovrAvatarMeshVertex vertex = (ovrAvatarMeshVertex)Marshal.PtrToStructure(new IntPtr(vertexBufferStart + offset), typeof(ovrAvatarMeshVertex));
                vertices[i] = new Vector3(vertex.x, vertex.y, -vertex.z);
                normals[i]  = new Vector3(vertex.nx, vertex.ny, -vertex.nz);
                tangents[i] = new Vector4(vertex.tx, vertex.ty, -vertex.tz, vertex.tw);
                uv[i]       = new Vector2(vertex.u, vertex.v);
                colors[i]   = new Color(0, 0, 0, 1);

                boneWeights[i].boneIndex0 = vertex.blendIndices[0];
                boneWeights[i].boneIndex1 = vertex.blendIndices[1];
                boneWeights[i].boneIndex2 = vertex.blendIndices[2];
                boneWeights[i].boneIndex3 = vertex.blendIndices[3];
                boneWeights[i].weight0    = vertex.blendWeights[0];
                boneWeights[i].weight1    = vertex.blendWeights[1];
                boneWeights[i].weight2    = vertex.blendWeights[2];
                boneWeights[i].weight3    = vertex.blendWeights[3];
            }

            mesh.vertices    = vertices;
            mesh.normals     = normals;
            mesh.uv          = uv;
            mesh.tangents    = tangents;
            mesh.boneWeights = boneWeights;
            mesh.colors      = colors;

            skinnedBindPose = meshAssetData.skinnedBindPose;

            ulong   indexCount     = meshAssetData.indexCount;
            Int16[] indices        = new Int16[indexCount];
            IntPtr  indexBufferPtr = meshAssetData.indexBuffer;
            Marshal.Copy(indexBufferPtr, indices, 0, (int)indexCount);
            Int32[] triangles = new Int32[indexCount];
            for (ulong i = 0; i < indexCount; i += 3)
            {
                triangles[i + 2] = (Int32)indices[i];
                triangles[i + 1] = (Int32)indices[i + 1];
                triangles[i]     = (Int32)indices[i + 2];
            }
            mesh.triangles = triangles;

            UInt32 jointCount = skinnedBindPose.jointCount;
            jointNames = new string[jointCount];
            for (UInt32 i = 0; i < jointCount; i++)
            {
                jointNames[i] = Marshal.PtrToStringAnsi(skinnedBindPose.jointNames[i]);
            }
        }
        break;

        case ovrAvatarAssetType.CombinedMesh:
        {
            ovrAvatarMeshAssetDataV2 meshAssetData = CAPI.ovrAvatarAsset_GetCombinedMeshData(asset);

            AvatarLogger.Log(
                "OvrAvatarAssetMesh: "
                + _assetId
                + " "
                + meshType.ToString()
                + " VertexCount:"
                + meshAssetData.vertexCount);

            long         vertexCount = (long)meshAssetData.vertexCount;
            Vector3[]    vertices    = new Vector3[vertexCount];
            Vector3[]    normals     = new Vector3[vertexCount];
            Vector4[]    tangents    = new Vector4[vertexCount];
            Vector2[]    uv          = new Vector2[vertexCount];
            Color[]      colors      = new Color[vertexCount];
            BoneWeight[] boneWeights = new BoneWeight[vertexCount];

            long vertexSize        = (long)Marshal.SizeOf(typeof(ovrAvatarMeshVertexV2));
            long vertexBufferStart = meshAssetData.vertexBuffer.ToInt64();

            for (long i = 0; i < vertexCount; i++)
            {
                long offset = vertexSize * i;

                ovrAvatarMeshVertexV2 vertex = (ovrAvatarMeshVertexV2)Marshal.PtrToStructure(new IntPtr(vertexBufferStart + offset), typeof(ovrAvatarMeshVertexV2));
                vertices[i] = new Vector3(vertex.x, vertex.y, -vertex.z);
                normals[i]  = new Vector3(vertex.nx, vertex.ny, -vertex.nz);
                tangents[i] = new Vector4(vertex.tx, vertex.ty, -vertex.tz, vertex.tw);
                uv[i]       = new Vector2(vertex.u, vertex.v);
                colors[i]   = new Color(vertex.r, vertex.g, vertex.b, vertex.a);

                boneWeights[i].boneIndex0 = vertex.blendIndices[0];
                boneWeights[i].boneIndex1 = vertex.blendIndices[1];
                boneWeights[i].boneIndex2 = vertex.blendIndices[2];
                boneWeights[i].boneIndex3 = vertex.blendIndices[3];
                boneWeights[i].weight0    = vertex.blendWeights[0];
                boneWeights[i].weight1    = vertex.blendWeights[1];
                boneWeights[i].weight2    = vertex.blendWeights[2];
                boneWeights[i].weight3    = vertex.blendWeights[3];
            }

            mesh.vertices    = vertices;
            mesh.normals     = normals;
            mesh.uv          = uv;
            mesh.tangents    = tangents;
            mesh.boneWeights = boneWeights;
            mesh.colors      = colors;

            skinnedBindPose = meshAssetData.skinnedBindPose;

            ulong   indexCount     = meshAssetData.indexCount;
            Int16[] indices        = new Int16[indexCount];
            IntPtr  indexBufferPtr = meshAssetData.indexBuffer;
            Marshal.Copy(indexBufferPtr, indices, 0, (int)indexCount);
            Int32[] triangles = new Int32[indexCount];
            for (ulong i = 0; i < indexCount; i += 3)
            {
                triangles[i + 2] = (Int32)indices[i];
                triangles[i + 1] = (Int32)indices[i + 1];
                triangles[i]     = (Int32)indices[i + 2];
            }
            mesh.triangles = triangles;

            UInt32 jointCount = skinnedBindPose.jointCount;
            jointNames = new string[jointCount];
            for (UInt32 i = 0; i < jointCount; i++)
            {
                jointNames[i] = Marshal.PtrToStringAnsi(skinnedBindPose.jointNames[i]);
            }
        }
        break;

        default:
            throw new Exception("Bad Mesh Asset Type");
        }
    }
コード例 #44
0
ファイル: CAPI.cs プロジェクト: scholtz/FastZep
 internal CMSG_STREAM_INFO(uint cbContent, CAPI.PFN_CMSG_STREAM_OUTPUT pfnStreamOutput, IntPtr pvArg)
 {
     this.cbContent = cbContent;
     this.pfnStreamOutput = pfnStreamOutput;
     this.pvArg = pvArg;
 }