当前位置: 首页>>代码示例>>C#>>正文


C# ReceiveDataReader.ReadBuffer方法代码示例

本文整理汇总了C#中ReceiveDataReader.ReadBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# ReceiveDataReader.ReadBuffer方法的具体用法?C# ReceiveDataReader.ReadBuffer怎么用?C# ReceiveDataReader.ReadBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReceiveDataReader的用法示例。


在下文中一共展示了ReceiveDataReader.ReadBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCookedTriangleMeshFromCache

        byte[] GetCookedTriangleMeshFromCache( Vec3[] vertices, int[] indices, short[] materialIndices )
        {
            try
            {
                string cacheDirectory = "user:Caches\\PhysXCookedTriangleMeshes";
                string realCacheDirectory = VirtualFileSystem.GetRealPathByVirtual( cacheDirectory );

                if( Directory.Exists( realCacheDirectory ) )
                {
                    byte[] sourceBuffer;
                    string baseName;
                    GetCookTriangleMeshSourceBuffer( vertices, indices, materialIndices, out sourceBuffer, out baseName );
                    string realFileName = Path.Combine( realCacheDirectory, baseName + ".cache" );

                    if( File.Exists( realFileName ) )
                    {
                        int major, minor, bugfix;
                        PhysXNativeWorld.GetSDKVersion( out major, out minor, out bugfix );
                        int additional = 0;
                        int version = ( ( ( ( ( major << 8 ) + minor ) << 8 ) + bugfix ) << 8 ) + additional;

                        //File format:
                        //1. PhysX version (4 bytes)
                        //2. source buffer length (4 bytes)
                        //3. source buffer
                        //4. cooked data length (4 bytes)
                        //5. cooked data

                        //no archive
                        byte[] fileData = File.ReadAllBytes( realFileName );

                        //archive
                        //byte[] fileData;
                        ////Mono runtime specific
                        //if( RuntimeFramework.Runtime == RuntimeFramework.RuntimeType.Mono )
                        //   ZipConstants.DefaultCodePage = 0;
                        //using( ZipFile zipFile = new ZipFile( realFileName ) )
                        //{
                        //   ZipEntry entry = zipFile.GetEntry( "data" );
                        //   Stream zipStream = zipFile.GetInputStream( entry );
                        //   fileData = new byte[ entry.Size ];
                        //   if( zipStream.Read( fileData, 0, (int)entry.Size ) != fileData.Length )
                        //      return null;
                        //}

                        ReceiveDataReader reader = new ReceiveDataReader();
                        reader.Init( fileData, 0, fileData.Length * 8 );

                        //check for old version
                        int fileVersion = reader.ReadInt32();
                        if( version != fileVersion )
                            return null;

                        int fileBufferSize = reader.ReadInt32();
                        if( sourceBuffer.Length != fileBufferSize )
                            return null;

                        byte[] fileSourceBuffer = new byte[ fileBufferSize ];
                        reader.ReadBuffer( fileSourceBuffer );
                        unsafe
                        {
                            fixed( byte* pSource = sourceBuffer, pFileBuffer = fileSourceBuffer )
                            {
                                if( NativeUtils.CompareMemory( (IntPtr)pSource, (IntPtr)pFileBuffer,
                                    sourceBuffer.Length ) != 0 )
                                {
                                    return null;
                                }
                            }
                        }

                        int cookedSize = reader.ReadInt32();
                        byte[] cookedData = new byte[ cookedSize ];
                        reader.ReadBuffer( cookedData );

                        return cookedData;
                    }
                }
            }
            catch { }

            return null;
        }
开发者ID:whztt07,项目名称:SDK,代码行数:83,代码来源:PhysXBody.cs


注:本文中的ReceiveDataReader.ReadBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。