// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ internal CameraAnimData(ResFileLoader loader) { ClipNear = loader.ReadSingle(); ClipFar = loader.ReadSingle(); AspectRatio = loader.ReadSingle(); FieldOfView = loader.ReadSingle(); Position = loader.ReadVector3F(); Rotation = loader.ReadVector3F(); Twist = loader.ReadSingle(); }
void IResData.Load(ResFileLoader loader) { WrapModeU = (TexClamp)loader.ReadByte(); WrapModeV = (TexClamp)loader.ReadByte(); WrapModeW = (TexClamp)loader.ReadByte(); CompareFunc = (CompareFunction)loader.ReadByte(); BorderColorType = (TexBorderType)loader.ReadByte(); Anisotropic = (MaxAnisotropic)loader.ReadByte(); _filterFlags = loader.ReadUInt16(); MinLOD = loader.ReadSingle(); MaxLOD = loader.ReadSingle(); LODBias = loader.ReadSingle(); loader.Seek(12); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { _flags = loader.ReadUInt32(); PolygonControl = new PolygonControl() { Value = loader.ReadUInt32() }; DepthControl = new DepthControl() { Value = loader.ReadUInt32() }; AlphaControl = new AlphaControl() { Value = loader.ReadUInt32() }; AlphaRefValue = loader.ReadSingle(); ColorControl = new ColorControl() { Value = loader.ReadUInt32() }; BlendTarget = loader.ReadUInt32(); BlendControl = new BlendControl() { Value = loader.ReadUInt32() }; BlendColor = loader.ReadVector4F(); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { loader.CheckSignature(_signature); Name = loader.LoadString(); Flags = loader.ReadEnum <ShapeFlags>(true); ushort idx = loader.ReadUInt16(); MaterialIndex = loader.ReadUInt16(); BoneIndex = loader.ReadUInt16(); VertexBufferIndex = loader.ReadUInt16(); ushort numSkinBoneIndex = loader.ReadUInt16(); VertexSkinCount = loader.ReadByte(); byte numMesh = loader.ReadByte(); byte numKeyShape = loader.ReadByte(); TargetAttribCount = loader.ReadByte(); ushort numSubMeshBoundingNodes = loader.ReadUInt16(); // Padding in engine. Radius = loader.ReadSingle(); VertexBuffer = loader.Load <VertexBuffer>(); Meshes = loader.LoadList <Mesh>(numMesh); SkinBoneIndices = loader.LoadCustom(() => loader.ReadUInt16s(numSkinBoneIndex)); KeyShapes = loader.LoadDict <KeyShape>(); // TODO: At least BotW has more data following the Boundings, or that are no boundings at all. if (numSubMeshBoundingNodes == 0) { // Compute the count differently if the node count was padding. SubMeshBoundings = loader.LoadCustom(() => loader.ReadBoundings(Meshes[0].SubMeshes.Count + 1)); } else { SubMeshBoundingNodes = loader.LoadList <BoundingNode>(numSubMeshBoundingNodes); SubMeshBoundings = loader.LoadCustom(() => loader.ReadBoundings(numSubMeshBoundingNodes)); SubMeshBoundingIndices = loader.LoadCustom(() => loader.ReadUInt16s(numSubMeshBoundingNodes)); } uint userPointer = loader.ReadUInt32(); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { _flags = loader.ReadUInt16(); ushort numKey = loader.ReadUInt16(); AnimDataOffset = loader.ReadUInt32(); StartFrame = loader.ReadSingle(); EndFrame = loader.ReadSingle(); Scale = loader.ReadSingle(); Offset = loader.ReadSingle(); if (loader.ResFile.Version >= 0x03040000) { Delta = loader.ReadSingle(); } Frames = loader.LoadCustom(() => { switch (FrameType) { case AnimCurveFrameType.Single: return(loader.ReadSingles(numKey)); case AnimCurveFrameType.Decimal10x5: float[] dec10x5Frames = new float[numKey]; for (int i = 0; i < numKey; i++) { dec10x5Frames[i] = (float)loader.ReadDecimal10x5(); } return(dec10x5Frames); case AnimCurveFrameType.Byte: float[] byteFrames = new float[numKey]; for (int i = 0; i < numKey; i++) { byteFrames[i] = loader.ReadByte(); } return(byteFrames); default: throw new ResException($"Invalid {nameof(FrameType)}."); } }); Keys = loader.LoadCustom(() => { int elementsPerKey = ElementsPerKey; float[,] keys = new float[numKey, elementsPerKey]; switch (KeyType) { case AnimCurveKeyType.Single: for (int i = 0; i < numKey; i++) { keys[i, 0] = loader.ReadSingle(); } break; case AnimCurveKeyType.Int16: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { keys[i, j] = loader.ReadUInt16(); } } break; case AnimCurveKeyType.SByte: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { keys[i, j] = loader.ReadSByte(); } } break; default: throw new ResException($"Invalid {nameof(KeyType)}."); } return(keys); }); }
// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { _flags = loader.ReadUInt16(); ushort numKey = loader.ReadUInt16(); AnimDataOffset = loader.ReadUInt32(); StartFrame = loader.ReadSingle(); EndFrame = loader.ReadSingle(); Scale = loader.ReadSingle(); Offset = loader.ReadSingle(); if (loader.ResFile.Version >= 0x03040000) { Delta = loader.ReadSingle(); } Frames = loader.LoadCustom(() => { switch (FrameType) { case AnimCurveFrameType.Single: if (CurveType == AnimCurveType.StepInt) { float[] dec10x5Frame = new float[numKey]; for (int i = 0; i < numKey; i++) { dec10x5Frame[i] = loader.ReadUInt32(); } return(dec10x5Frame); } else { return(loader.ReadSingles(numKey)); } case AnimCurveFrameType.Decimal10x5: float[] dec10x5Frames = new float[numKey]; for (int i = 0; i < numKey; i++) { dec10x5Frames[i] = (float)loader.ReadDecimal10x5(); } return(dec10x5Frames); case AnimCurveFrameType.Byte: float[] byteFrames = new float[numKey]; for (int i = 0; i < numKey; i++) { byteFrames[i] = loader.ReadByte(); } return(byteFrames); default: throw new ResException($"Invalid {nameof(FrameType)}."); } }); //Bools use bits to store values. if (CurveType == AnimCurveType.StepBool) { int KeyBool = 0; if (KeyType == AnimCurveKeyType.Single) //Read them as a int instead of a float { KeyBool = loader.LoadCustom(() => loader.ReadInt32()); } else if (KeyType == AnimCurveKeyType.Int16) { KeyBool = loader.LoadCustom(() => loader.ReadInt16()); } else if (KeyType == AnimCurveKeyType.SByte) { KeyBool = loader.LoadCustom(() => loader.ReadSByte()); } KeyStepBoolData = new bool[numKey]; for (int i = 0; i < numKey; i++) { bool set = (KeyBool & 0x1) != 0; KeyBool >>= 1; KeyStepBoolData[i] = set; } } else { Keys = loader.LoadCustom(() => { int elementsPerKey = ElementsPerKey; float[,] keys = new float[numKey, elementsPerKey]; switch (KeyType) { case AnimCurveKeyType.Single: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { if (CurveType == AnimCurveType.StepInt) { keys[i, j] = loader.ReadUInt32(); } else { keys[i, j] = loader.ReadSingle(); } } } break; case AnimCurveKeyType.Int16: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { keys[i, j] = loader.ReadInt16(); } } break; case AnimCurveKeyType.SByte: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { keys[i, j] = loader.ReadSByte(); } } break; default: throw new ResException($"Invalid {nameof(KeyType)}."); } return(keys); }); } }
void IResData.Load(ResFileLoader loader) { long FrameArrayOffset = 0; long KeyArrayOffset = 0; ushort numKey = 0; if (loader.IsSwitch) { FrameArrayOffset = loader.ReadOffset(); KeyArrayOffset = loader.ReadOffset(); _flags = loader.ReadUInt16(); numKey = loader.ReadUInt16(); AnimDataOffset = loader.ReadUInt32(); StartFrame = loader.ReadSingle(); EndFrame = loader.ReadSingle(); Scale = loader.ReadSingle(); Offset = loader.ReadSingle(); Delta = loader.ReadSingle(); int padding = loader.ReadInt32(); } else { _flags = loader.ReadUInt16(); numKey = loader.ReadUInt16(); AnimDataOffset = loader.ReadUInt32(); StartFrame = loader.ReadSingle(); EndFrame = loader.ReadSingle(); Scale = loader.ReadSingle(); Offset = loader.ReadSingle(); if (loader.ResFile.Version >= 0x03040000) { Delta = loader.ReadSingle(); } FrameArrayOffset = loader.ReadOffset(); KeyArrayOffset = loader.ReadOffset(); } Frames = loader.LoadCustom(() => { switch (FrameType) { case AnimCurveFrameType.Single: return(loader.ReadSingles(numKey)); case AnimCurveFrameType.Decimal10x5: float[] dec10x5Frames = new float[numKey]; for (int i = 0; i < numKey; i++) { dec10x5Frames[i] = (float)loader.ReadDecimal10x5(); } return(dec10x5Frames); case AnimCurveFrameType.Byte: float[] byteFrames = new float[numKey]; for (int i = 0; i < numKey; i++) { byteFrames[i] = loader.ReadByte(); } return(byteFrames); default: throw new ResException($"Invalid {nameof(FrameType)}."); } }, (uint)FrameArrayOffset); Keys = loader.LoadCustom(() => { int elementsPerKey = ElementsPerKey; float[,] keys = new float[numKey, elementsPerKey]; switch (KeyType) { case AnimCurveKeyType.Single: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { if (CurveType == AnimCurveType.StepInt || CurveType == AnimCurveType.StepBool) { keys[i, j] = loader.ReadUInt32(); } else { keys[i, j] = loader.ReadSingle(); } } } break; case AnimCurveKeyType.Int16: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { keys[i, j] = loader.ReadInt16(); } } break; case AnimCurveKeyType.SByte: for (int i = 0; i < numKey; i++) { for (int j = 0; j < elementsPerKey; j++) { keys[i, j] = loader.ReadSByte(); } } break; default: throw new ResException($"Invalid {nameof(KeyType)}."); } return(keys); }, (uint)KeyArrayOffset); //Bools use bits to store values. if (CurveType == AnimCurveType.StepBool) { int keyIndex = 0; KeyStepBoolData = new bool[numKey]; for (int i = 0; i < Keys.Length; i++) { if (numKey <= keyIndex) { break; } int value = (int)Keys[i, 0]; //Bit shift each key value for (int j = 0; j < 32; j++) { if (numKey <= keyIndex) { break; } bool set = (value & 0x1) != 0; value >>= 1; KeyStepBoolData[keyIndex] = set; keyIndex++; } } } }