V-Gears 0
Free Final Fantasy VII engine.
DaFile Class Reference

Represents a compiled animations file. More...

#include <DaFile.h>

Collaboration diagram for DaFile:

Classes

struct  Animation
 
struct  Frame
 Information for a frame. More...
 
struct  TriValue
 A three-coordinate value. More...
 

Public Member Functions

 DaFile (File file)
 Constructor. More...
 
std::vector< std::string > GenerateAFiles (std::string model_id, std::string path)
 Generates .a files from the da file. More...
 

Private Member Functions

void Read ()
 Reads the Da file and extracts all the data. More...
 
Animation ReadAnimation ()
 Reads an animation from the *da file. More...
 
Frame ReadFirstFrame (u32 bones, u8 key)
 Reads the first, uncompressed frame. More...
 
Frame ReadFrame (u32 bones, u8 key, Frame prev)
 Reads a compressed frame. More...
 
int GetDynamicOffsetFromStream ()
 Retrieves a positional offset value of dynamic size from the file. More...
 
int GetBitsU (int bits)
 Read an arbitrary number of bits from the da contents as unsigned. More...
 
int GetBitsS (int bits)
 Read an arbitrary number of bits from the da contents as signed. More...
 
int GetCompressedDeltaFromStream (int lowered_precision_bits)
 Decodes a delta rotation read from the stream. More...
 

Static Private Member Functions

static int ExtendSignInteger (int val, int len)
 Extends the sign for an integer value for a specified bit length. More...
 
static int GetSignExtendedShort (int val, int len)
 Extends the sign for a short value for a specified bit length. More...
 

Private Attributes

File da_file_
 The da file. More...
 
u8da_bytes_
 Contents of the da file as a byte array. More...
 
std::vector< Animationanimations_
 List of animations. More...
 
u32 bit_offset_
 Number of bits already read from the da file. More...
 

Static Private Attributes

static const float OFFSET_SCALE = 0.0070312473867f
 Scale for bone offsets. More...
 

Detailed Description

Represents a compiled animations file.

Da files are bundled into battle.lgp. They contain information about a skeleton animation. They are heavily compressed, and involve a lot of bit reading to decompile.

Constructor & Destructor Documentation

◆ DaFile()

DaFile::DaFile ( File  file)

Constructor.

Reads the file.

Parameters
[in,out]fileThe file to read from. The file contents will not be altered, but it's offset will be changed while reading it.

Member Function Documentation

◆ ExtendSignInteger()

int DaFile::ExtendSignInteger ( int  val,
int  len 
)
staticprivate

Extends the sign for an integer value for a specified bit length.

Parameters
[in]valThe value to extend.
[in]lenNumber of bytes to extend the value to.
Returns
The signed integer.

◆ GenerateAFiles()

std::vector< std::string > DaFile::GenerateAFiles ( std::string  model_id,
std::string  path 
)

Generates .a files from the da file.

A file will be generated for each animation in the da file. See {

See also
VGearsAFile.h} for more info about .a files. Files will be created in the specified path, and will be named like the model id, followed by an underscore, followed a two-digit animation index (starting from 0) followed by the ".a extension". For example, if path is "/home/user/.v-gears", the model id is "ac", and the da file contains three animations, the following files will be generated: "/home/user/.v-gears/ac_00.a", "/home/user/.v-gears/ac_01.a" and "/home/user/.v-gears/ac_02.a".
Parameters
[in]model_idID of the model the animation belongs to, usually a two letter code. Used to generate the file name.
[in]pathPath to the directory where the files will be saved.
Returns
A list of the generated files. They include the path and the extension.

◆ GetBitsS()

int DaFile::GetBitsS ( int  bits)
private

Read an arbitrary number of bits from the da contents as signed.

Bits will be read from {

See also
bit_offset_}.
Parameters
[in]bitsNumber of bits.
Returns
Signed value.

◆ GetBitsU()

int DaFile::GetBitsU ( int  bits)
private

Read an arbitrary number of bits from the da contents as unsigned.

Bits will be read from {

See also
bit_offset_}.
Parameters
[in]bitsNumber of bits.
Returns
Unsigned value.

◆ GetCompressedDeltaFromStream()

int DaFile::GetCompressedDeltaFromStream ( int  lowered_precision_bits)
private

Decodes a delta rotation read from the stream.

Requires {

See also
bit_offset_} to indicate the bit at which the delta begins
Parameters
lowered_precision_bitsHow many bits to sift the read value. The animation key.
Returns
The decoded value.

◆ GetDynamicOffsetFromStream()

int DaFile::GetDynamicOffsetFromStream ( )
private

Retrieves a positional offset value of dynamic size from the file.

Requires {

See also
bit_offset_} to indicate the bit at which the frame begins. The first read bit will determine the length of the read data. If it's 1, 7 more bits of data will be read and returned. It it isn't, 16 more bits of data will be read and returned. In total, either 17 or 8 bits of data will be read.
Returns
The read value.

◆ GetSignExtendedShort()

int DaFile::GetSignExtendedShort ( int  val,
int  len 
)
staticprivate

Extends the sign for a short value for a specified bit length.

Parameters
[in]valThe value to extend.
[in]lenNumber of bytes to extend the value to.
Returns
The signed integer.

◆ Read()

void DaFile::Read ( )
private

Reads the Da file and extracts all the data.

◆ ReadAnimation()

DaFile::Animation DaFile::ReadAnimation ( )
private

Reads an animation from the *da file.

Requires {

See also
bit_offset_} to indicate the bit at which the animation begins.

If the read animation is invalid (i.e. with a size less than 11 bytes), the {

See also
Animation.frame_count} will be 0 and the rest of the data in the animation is not to be trusted, and the animation should not be used.
Returns
The animation read.

◆ ReadFirstFrame()

DaFile::Frame DaFile::ReadFirstFrame ( u32  bones,
u8  key 
)
private

Reads the first, uncompressed frame.

Requires {

See also
bit_offset_} to indicate the bit at which the frame begins.
Parameters
[in]bonesThe number of bones involved in the animation.
[in]keyKey for decoding the animation (fifth byte in the animation second header).
Returns
The first frame.

◆ ReadFrame()

DaFile::Frame DaFile::ReadFrame ( u32  bones,
u8  key,
Frame  prev 
)
private

Reads a compressed frame.

Requires {

See also
bit_offset_} to indicate the bit at which the frame begins.
Parameters
[in]bonesThe number of bones involved in the animation.
[in]keyKey for decoding the animation (fifth byte in the animation second header).
[in]prevPrevious frame.
Returns
The first frame.

Member Data Documentation

◆ animations_

std::vector<Animation> DaFile::animations_
private

List of animations.

◆ bit_offset_

u32 DaFile::bit_offset_
private

Number of bits already read from the da file.

◆ da_bytes_

u8* DaFile::da_bytes_
private

Contents of the da file as a byte array.

◆ da_file_

File DaFile::da_file_
private

The da file.

◆ OFFSET_SCALE

const float DaFile::OFFSET_SCALE = 0.0070312473867f
staticprivate

Scale for bone offsets.


The documentation for this class was generated from the following files: