本文整理汇总了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;
}