V-Gears 0
Free Final Fantasy VII engine.
DaFile.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <vector>
19#include "common/File.h"
20#include "common/TypeDefine.h"
21
28class DaFile{
29
30 public:
31
40 DaFile(File file);
41
58 std::vector<std::string> GenerateAFiles(std::string model_id, std::string path);
59
60 private:
61
65 static const float OFFSET_SCALE;
66
73 struct TriValue{
74
78 char16_t s_x;
79
83 char16_t s_y;
84
88 char16_t s_z;
89
93 int i_x;
94
98 int i_y;
99
103 int i_z;
104
108 float f_x;
109
113 float f_y;
114
118 float f_z;
119 };
120
124 struct Frame{
125
130
134 std::vector<TriValue> bones;
135 };
136
137 struct Animation{
138
143
148
153
158
162 std::vector<Frame> frames;
163 };
164
172 static int ExtendSignInteger(int val, int len);
173
181 static int GetSignExtendedShort(int val, int len);
182
186 void Read();
187
200
211 Frame ReadFirstFrame(u32 bones, u8 key);
212
224 Frame ReadFrame(u32 bones, u8 key, Frame prev);
225
237
246 int GetBitsU(int bits);
247
256 int GetBitsS(int bits);
257
266 int GetCompressedDeltaFromStream(int lowered_precision_bits);
267
272
277
281 std::vector<Animation> animations_;
282
287
288};
Ogre::uint32 u32
Definition: TypeDefine.h:23
Ogre::uint8 u8
Definition: TypeDefine.h:21
Represents a compiled animations file.
Definition: DaFile.h:28
static int GetSignExtendedShort(int val, int len)
Extends the sign for a short value for a specified bit length.
Definition: DaFile.cpp:99
int GetBitsU(int bits)
Read an arbitrary number of bits from the da contents as unsigned.
Definition: DaFile.cpp:227
Animation ReadAnimation()
Reads an animation from the *da file.
Definition: DaFile.cpp:124
static int ExtendSignInteger(int val, int len)
Extends the sign for an integer value for a specified bit length.
Definition: DaFile.cpp:87
Frame ReadFrame(u32 bones, u8 key, Frame prev)
Reads a compressed frame.
Definition: DaFile.cpp:184
int GetBitsS(int bits)
Read an arbitrary number of bits from the da contents as signed.
Definition: DaFile.cpp:276
Frame ReadFirstFrame(u32 bones, u8 key)
Reads the first, uncompressed frame.
Definition: DaFile.cpp:152
int GetCompressedDeltaFromStream(int lowered_precision_bits)
Decodes a delta rotation read from the stream.
Definition: DaFile.cpp:281
u8 * da_bytes_
Contents of the da file as a byte array.
Definition: DaFile.h:276
DaFile(File file)
Constructor.
Definition: DaFile.cpp:23
std::vector< Animation > animations_
List of animations.
Definition: DaFile.h:281
u32 bit_offset_
Number of bits already read from the da file.
Definition: DaFile.h:286
int GetDynamicOffsetFromStream()
Retrieves a positional offset value of dynamic size from the file.
Definition: DaFile.cpp:218
File da_file_
The da file.
Definition: DaFile.h:271
std::vector< std::string > GenerateAFiles(std::string model_id, std::string path)
Generates .a files from the da file.
Definition: DaFile.cpp:34
static const float OFFSET_SCALE
Scale for bone offsets.
Definition: DaFile.h:65
void Read()
Reads the Da file and extracts all the data.
Definition: DaFile.cpp:108
Represents a file.
Definition: File.h:24
Definition: DaFile.h:137
u32 bone_count
Number of bones in the animation.
Definition: DaFile.h:142
u32 frame_count
Number of frames in the animation.
Definition: DaFile.h:147
std::vector< Frame > frames
List of frames in the animation.
Definition: DaFile.h:162
u8 key
Key for decoding values in an animation.
Definition: DaFile.h:157
u32 size
Size of the animation data.
Definition: DaFile.h:152
Information for a frame.
Definition: DaFile.h:124
std::vector< TriValue > bones
Each of the bone rotations.
Definition: DaFile.h:134
TriValue offset
Root offset.
Definition: DaFile.h:129
A three-coordinate value.
Definition: DaFile.h:73
float f_x
X value, float_format.
Definition: DaFile.h:108
char16_t s_x
X value, short format.
Definition: DaFile.h:78
int i_y
Y value, integer format.
Definition: DaFile.h:98
float f_y
Y value, float format.
Definition: DaFile.h:113
char16_t s_y
Y value, short format.
Definition: DaFile.h:83
int i_z
Z value, integer format.
Definition: DaFile.h:103
char16_t s_z
Z value, short format.
Definition: DaFile.h:88
float f_z
Z value, float format.
Definition: DaFile.h:118
int i_x
X value, integer format.
Definition: DaFile.h:93