arx-convert
Version:
Converts various Arx Fatalis formats to JSON or YAML and back
106 lines (105 loc) • 3.34 kB
TypeScript
import { BinaryIO } from '../common/BinaryIO.js';
import type { ArxQuaternion, ArxVector3 } from '../common/types.js';
import type { ArxTheaSample } from './types.js';
/**
* @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/animation/Animation.h#L131
* @see https://github.com/arx/ArxLibertatis/blob/ArxFatalis-1.21/Sources/Include/EERIETypes.h#L667
*/
export declare enum ArxAnimationPlayingFlags {
None = 0,
/**
* Must be looped at end (indefinitely...)
*/
Loop = 1,
/**
* Is played in reverse (from end to start)
*/
Reverse = 2,
/**
* Is paused
*/
Paused = 4,
/**
* Has just finished
*/
AnimEnd = 8,
/**
* Is a static Anim (no movement offset returned)
*/
StaticAnim = 16,
/**
* Must be stopped at end
*/
StopEnd = 32,
/**
* User controlled... MUST be played...
*/
ForcePlay = 64,
/**
* ctime externally set, no update
*/
ExControl = 128
}
/**
* @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/animation/AnimationFormat.h#L116
*/
export type ArxTheoAnimationGroup = {
isKey: boolean;
/**
* if value is missing than it means it's a quaternion with 0/0/0/1 values
*/
quaternion?: ArxQuaternion;
/**
* if value is missing than it means it's a vector with 0/0/0 values
*/
translate?: ArxVector3;
/**
* if value is missing than it means it's a vector with 0/0/0 values
*/
zoom?: ArxVector3;
};
/**
* @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/animation/AnimationFormat.h#L91 - old keyframe format
* @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/animation/AnimationFormat.h#L102 - new keyframe format
*
* The new keyframe format contains an "info_frame" field, but the runtime code doesn't use it, it holds no data or garbage
*
* The original data is extended with optional fields that get computed when parsing keyframe data
*/
export type ArxKeyFrame = {
/**
* Position of this keyframe on the timeline set between `0` (inclusive) and `ArxTeaHeader.totalNumberOfFrames` (exclusive)
*/
frame: number;
/**
* always set to -1 or 9 in tea files, so Arx Libertatis in debug mode expects only those 2 values
* @see https://github.com/arx/ArxLibertatis/blob/1.2.1/src/animation/Animation.cpp#L304
*
* if ommitted the default value is -1
*/
flags?: ArxAnimationPlayingFlags;
/**
* not used by Arx
*/
isMasterKeyFrame: boolean;
/**
* not used by Arx
*/
isKeyFrame: boolean;
timeFrame: number;
groups: ArxTheoAnimationGroup[];
/**
* if value is missing than it means it's a vector with 0/0/0 values
*/
translate?: ArxVector3;
/**
* if value is missing than it means it's a quaternion with 0/0/0/1 values
*/
quaternion?: ArxQuaternion;
sample?: ArxTheaSample;
};
export declare class KeyFrame {
static readFrom(binary: BinaryIO<ArrayBufferLike>, version: number, numberOfGroups: number): ArxKeyFrame;
static accumulateFrom(keyframe: ArxKeyFrame): ArrayBuffer;
static sizeOf(version: number, hasTranslateData: boolean, hasQuaternionData: boolean, hasMorphData: boolean, numberOfGroups: number, hasSample: boolean, sampleSize?: number): number;
}