// TODO: Methods to access ShaderParam variable values. // ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { loader.CheckSignature(_signature); Name = loader.LoadString(); Flags = loader.ReadEnum <MaterialFlags>(true); ushort idx = loader.ReadUInt16(); ushort numRenderInfo = loader.ReadUInt16(); byte numSampler = loader.ReadByte(); byte numTextureRef = loader.ReadByte(); ushort numShaderParam = loader.ReadUInt16(); ushort numShaderParamVolatile = loader.ReadUInt16(); ushort sizParamSource = loader.ReadUInt16(); ushort sizParamRaw = loader.ReadUInt16(); ushort numUserData = loader.ReadUInt16(); RenderInfos = loader.LoadDict <RenderInfo>(); RenderState = loader.Load <RenderState>(); ShaderAssign = loader.Load <ShaderAssign>(); TextureRefs = loader.LoadList <TextureRef>(numTextureRef); uint ofsSamplerList = loader.ReadOffset(); // Only use dict. Samplers = loader.LoadDict <Sampler>(); uint ofsShaderParamList = loader.ReadOffset(); // Only use dict. ShaderParams = loader.LoadDict <ShaderParam>(); ShaderParamData = loader.LoadCustom(() => loader.ReadBytes(sizParamSource)); UserData = loader.LoadDict <UserData>(); VolatileFlags = loader.LoadCustom(() => loader.ReadBytes((int)Math.Ceiling(numShaderParam / 8f))); uint userPointer = loader.ReadUInt32(); }
void IResData.Load(ResFileLoader loader) { uint ofsData = loader.ReadOffset(); uint sizData = loader.ReadSize(); Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData), ofsData); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { Name = loader.LoadString(); ushort count = loader.ReadUInt16(); Type = loader.ReadEnum <UserDataType>(true); loader.Seek(1); switch (Type) { case UserDataType.Int32: _value = loader.ReadInt32s(count); break; case UserDataType.Single: _value = loader.ReadSingles(count); break; case UserDataType.String: _value = loader.LoadStrings(count, Encoding.ASCII); break; case UserDataType.WString: _value = loader.LoadStrings(count, Encoding.Unicode); break; case UserDataType.Byte: _value = loader.ReadBytes(count); break; } }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader, UserDataType Type, int count) { switch (Type) { case UserDataType.Int32: _value = loader.ReadInt32s(count); break; case UserDataType.Single: _value = loader.ReadSingles(count); break; case UserDataType.String: _value = loader.LoadStrings(count, Encoding.ASCII); break; case UserDataType.WString: _value = loader.LoadStrings(count, Encoding.Unicode); break; case UserDataType.Byte: _value = loader.ReadBytes(count); break; } }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { unk = loader.ReadUInt32(); uint Size = loader.ReadUInt32(); BufferOffset = loader.ReadInt64(); byte[] padding = loader.ReadBytes(16); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { if (loader.ResFile.Version >= 0x02040000) { uint ofsData = loader.ReadOffset(); uint sizData = loader.ReadUInt32(); Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData), ofsData); } }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { loader.CheckSignature(_signature); Dim = loader.ReadEnum <GX2SurfaceDim>(true); Width = loader.ReadUInt32(); Height = loader.ReadUInt32(); Depth = loader.ReadUInt32(); MipCount = loader.ReadUInt32(); Format = loader.ReadEnum <GX2SurfaceFormat>(true); AAMode = loader.ReadEnum <GX2AAMode>(true); Use = loader.ReadEnum <GX2SurfaceUse>(true); uint sizData = loader.ReadUInt32(); uint imagePointer = loader.ReadUInt32(); uint sizMipData = loader.ReadUInt32(); uint mipPointer = loader.ReadUInt32(); TileMode = loader.ReadEnum <GX2TileMode>(true); Swizzle = loader.ReadUInt32(); Alignment = loader.ReadUInt32(); Pitch = loader.ReadUInt32(); MipOffsets = loader.ReadUInt32s(13); ViewMipFirst = loader.ReadUInt32(); ViewMipCount = loader.ReadUInt32(); ViewSliceFirst = loader.ReadUInt32(); ViewSliceCount = loader.ReadUInt32(); CompSelR = loader.ReadEnum <GX2CompSel>(true); CompSelG = loader.ReadEnum <GX2CompSel>(true); CompSelB = loader.ReadEnum <GX2CompSel>(true); CompSelA = loader.ReadEnum <GX2CompSel>(true); Regs = loader.ReadUInt32s(5); uint handle = loader.ReadUInt32(); ArrayLength = loader.ReadUInt32(); // Possibly just a byte. Name = loader.LoadString(); Path = loader.LoadString(); Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData)); MipData = loader.LoadCustom(() => loader.ReadBytes((int)sizMipData)); UserData = loader.LoadDict <UserData>(); ushort numUserData = loader.ReadUInt16(); loader.Seek(2); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { uint dataPointer = loader.ReadUInt32(); uint size = loader.ReadUInt32(); uint handle = loader.ReadUInt32(); Stride = loader.ReadUInt16(); ushort numBuffering = loader.ReadUInt16(); uint contextPointer = loader.ReadUInt32(); Data = loader.LoadCustom(() => { byte[][] data = new byte[numBuffering][]; for (int i = 0; i < numBuffering; i++) { data[i] = loader.ReadBytes((int)size); } return(data); }); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { if (loader.IsSwitch) { uint SubMeshArrayOffset = loader.ReadOffset(); MemoryPool = loader.Load <MemoryPool>(); long Buffer = loader.ReadOffset(); var bufferSize = loader.Load <BufferSize>(); uint FaceBufferOffset = loader.ReadUInt32(); PrimitiveType = PrimitiveTypeList[loader.ReadEnum <SwitchPrimitiveType>(true)]; IndexFormat = IndexList[loader.ReadEnum <SwitchIndexFormat>(true)]; uint indexCount = loader.ReadUInt32(); FirstVertex = loader.ReadUInt32(); ushort numSubMesh = loader.ReadUInt16(); ushort padding = loader.ReadUInt16(); SubMeshes = loader.LoadList <SubMesh>(numSubMesh, SubMeshArrayOffset).ToList(); uint DataOffset = (uint)BufferInfo.BufferOffset + FaceBufferOffset; //Load buffer data from mem block IndexBuffer = new Buffer(); IndexBuffer.Flags = bufferSize.Flag; IndexBuffer.Data = new byte[1][]; IndexBuffer.Data[0] = loader.LoadCustom(() => loader.ReadBytes((int)bufferSize.Size), DataOffset); } else { PrimitiveType = loader.ReadEnum <GX2PrimitiveType>(true); IndexFormat = loader.ReadEnum <GX2IndexFormat>(true); uint indexCount = loader.ReadUInt32(); ushort numSubMesh = loader.ReadUInt16(); loader.Seek(2); SubMeshes = loader.LoadList <SubMesh>(numSubMesh).ToList(); IndexBuffer = loader.Load <Buffer>(); FirstVertex = loader.ReadUInt32(); } }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { TargetAttribIndices = loader.ReadBytes(20); TargetAttribIndexOffsets = loader.ReadBytes(4); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { loader.CheckSignature(_signature); Dim = loader.ReadEnum <GX2SurfaceDim>(true); Width = loader.ReadUInt32(); Height = loader.ReadUInt32(); Depth = loader.ReadUInt32(); MipCount = loader.ReadUInt32(); Format = loader.ReadEnum <GX2SurfaceFormat>(true); AAMode = loader.ReadEnum <GX2AAMode>(true); Use = loader.ReadEnum <GX2SurfaceUse>(true); uint sizData = loader.ReadUInt32(); uint imagePointer = loader.ReadUInt32(); uint sizMipData = loader.ReadUInt32(); uint mipPointer = loader.ReadUInt32(); TileMode = loader.ReadEnum <GX2TileMode>(true); Swizzle = loader.ReadUInt32(); Alignment = loader.ReadUInt32(); Pitch = loader.ReadUInt32(); MipOffsets = loader.ReadUInt32s(13); ViewMipFirst = loader.ReadUInt32(); ViewMipCount = loader.ReadUInt32(); ViewSliceFirst = loader.ReadUInt32(); ViewSliceCount = loader.ReadUInt32(); CompSelR = loader.ReadEnum <GX2CompSel>(true); CompSelG = loader.ReadEnum <GX2CompSel>(true); CompSelB = loader.ReadEnum <GX2CompSel>(true); CompSelA = loader.ReadEnum <GX2CompSel>(true); Regs = loader.ReadUInt32s(5); uint handle = loader.ReadUInt32(); ArrayLength = loader.ReadByte(); // Possibly just a byte. loader.Seek(3, System.IO.SeekOrigin.Current); Name = loader.LoadString(); Path = loader.LoadString(); // Load texture data. bool?isMainTextureFile = loader.ResFile.Name.Contains(".Tex1") ? new bool?(true) : loader.ResFile.Name.Contains(".Tex2") ? new bool?(false) : null; switch (isMainTextureFile) { case true: Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData)); loader.ReadOffset(); // MipData not used. break; case false: MipData = loader.LoadCustom(() => loader.ReadBytes((int)sizMipData)); loader.ReadOffset(); // Data not used. break; default: Data = loader.LoadCustom(() => loader.ReadBytes((int)sizData)); MipData = loader.LoadCustom(() => loader.ReadBytes((int)sizMipData)); break; } UserData = loader.LoadDict <UserData>(); ushort numUserData = loader.ReadUInt16(); loader.Seek(2); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { if (loader.IsSwitch) { Name = loader.LoadString(); uint DataOffset = loader.ReadOffset(); uint count = 0; if (loader.ResFile.VersionMajor2 <= 2 && loader.ResFile.VersionMajor == 0) { char[] Reserved = loader.ReadChars(8); count = loader.ReadUInt32(); Type = (UserDataType)loader.ReadUInt32(); } else { count = loader.ReadUInt32(); Type = loader.ReadEnum <UserDataType>(true); char[] Reserved = loader.ReadChars(43); } switch (Type) { case UserDataType.Byte: _value = loader.LoadCustom(() => loader.ReadSBytes((int)count), DataOffset); break; case UserDataType.Int32: _value = loader.LoadCustom(() => loader.ReadInt32s((int)count), DataOffset); break; case UserDataType.Single: _value = loader.LoadCustom(() => loader.ReadSingles((int)count), DataOffset); break; case UserDataType.String: _value = loader.LoadCustom(() => loader.LoadStrings((int)count, Encoding.UTF8), DataOffset); break; case UserDataType.WString: _value = loader.LoadCustom(() => loader.LoadStrings((int)count, Encoding.Unicode), DataOffset); break; } } else { Name = loader.LoadString(); ushort count = loader.ReadUInt16(); Type = loader.ReadEnum <UserDataType>(true); loader.Seek(1); switch (Type) { case UserDataType.Int32: _value = loader.ReadInt32s(count); break; case UserDataType.Single: _value = loader.ReadSingles(count); break; case UserDataType.String: _value = loader.LoadStrings(count, Encoding.UTF8); break; case UserDataType.WString: _value = loader.LoadStrings(count, Encoding.Unicode); break; case UserDataType.Byte: _value = loader.ReadBytes(count); break; } } }