How to use the restructure.uint16le function in restructure

To help you get started, we’ve selected a few restructure examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wowserhq / blizzardry / src / lib / m2 / animation-block.js View on Github external
export default function (type) {
  return new r.Struct({
    interpolationType: r.uint16le,
    globalSequenceID: r.int16le,
    timestamps: new Nofs(new Nofs(r.uint32le)),
    values: new Nofs(new Nofs(type)),

    trackCount: function () {
      return this.values.length;
    },

    tracks: function () {
      const tracks = [];

      for (let trackIndex = 0; trackIndex < this.trackCount; trackIndex++) {
        const track = {};

        // Corresponds to offset in animations array of MD2.
        track.animationIndex = trackIndex;
github wowserhq / blizzardry / src / lib / m2 / skin.js View on Github external
import r from 'restructure';

import { Vec3Float } from '../types';

import Nofs from './nofs';

const Submesh = new r.Struct({
  partID: r.uint16le,
  level: r.uint16le,
  startVertex: r.uint16le,
  vertexCount: r.uint16le,
  startTriangle: r.uint16le,
  triangleCount: r.uint16le,
  boneCount: r.uint16le,
  startBone: r.uint16le,
  boneInfluences: r.uint16le,
  rootBone: r.uint16le,
  centerMass: Vec3Float,
  centerBoundingBox: Vec3Float,
  radius: r.floatle,
});

const Batch = new r.Struct({
  flags: r.uint16le,
  shaderID: r.uint16le,
  submeshIndex: r.uint16le,
  submeshIndex2: r.uint16le,
  vertexColorAnimationIndex: r.int16le,
  materialIndex: r.uint16le,
  layer: r.uint16le,
github wowserhq / blizzardry / src / lib / chunked / modf.js View on Github external
import r from 'restructure';

import { Vec3Float } from '../types';

import Chunk from './chunk';

export default Chunk({
  entries: new r.Array(new r.Struct({
    index: r.uint32le,
    id: r.uint32le,
    position: Vec3Float,
    rotation: Vec3Float,
    minBoundingBox: Vec3Float,
    maxBoundingBox: Vec3Float,
    flags: r.uint16le,
    doodadSet: r.uint16le,
    nameSet: r.uint16le,
    padding: new r.Reserved(r.uint16le),

    filename: function () {
      return this.parent.parent.MWMO.filenames[this.index];
    },
  }), 'size', 'bytes'),
});
github wowserhq / blizzardry / src / lib / wmo / index.js View on Github external
largerRadius: r.floatle,
    fogEnd: r.floatle,
    fogStartMultiplier: r.floatle,
    color: r.uint32le,
    unknowns: new r.Reserved(r.floatle, 2),
    color2: r.uint32le,
  }), 'size', 'bytes'),
});

const MOPV = Chunk({
  vertices: new r.Array(float32array3, 'size', 'bytes'),
});

const MOPT = Chunk({
  portals: new r.Array(new r.Struct({
    vertexOffset: r.uint16le,
    vertexCount: r.uint16le,
    plane: new r.Struct({
      normal: float32array3,
      constant: r.floatle,
    }),
  }), 'size', 'bytes'),
});

const MOPR = Chunk({
  references: new r.Array(new r.Struct({
    portalIndex: r.uint16le,
    groupIndex: r.uint16le,
    side: r.int16le,
    unknown1: r.uint16le,
  }), 'size', 'bytes'),
});
github wowserhq / blizzardry / src / lib / m2 / skin.js View on Github external
import r from 'restructure';

import { Vec3Float } from '../types';

import Nofs from './nofs';

const Submesh = new r.Struct({
  partID: r.uint16le,
  level: r.uint16le,
  startVertex: r.uint16le,
  vertexCount: r.uint16le,
  startTriangle: r.uint16le,
  triangleCount: r.uint16le,
  boneCount: r.uint16le,
  startBone: r.uint16le,
  boneInfluences: r.uint16le,
  rootBone: r.uint16le,
  centerMass: Vec3Float,
  centerBoundingBox: Vec3Float,
  radius: r.floatle,
});

const Batch = new r.Struct({
  flags: r.uint16le,
  shaderID: r.uint16le,
github wowserhq / blizzardry / src / lib / m2 / index.js View on Github external
import r from 'restructure';

import {
  Vec3Float,
  color16,
  compfixed16array4,
  float32array2,
  float32array3,
} from '../types';

import AnimationBlock from './animation-block';
import Nofs from './nofs';

const Animation = new r.Struct({
  id: r.uint16le,
  subID: r.uint16le,
  length: r.uint32le,
  movementSpeed: r.floatle,
  flags: r.uint32le,
  probability: r.int16le,

  unknowns: new r.Reserved(r.uint16le, 5),

  blendTime: r.uint32le,
  minBoundingBox: Vec3Float,
  maxBoundingBox: Vec3Float,
  boundingRadius: r.floatle,
  nextAnimationID: r.int16le,
  alias: r.uint16le,
});

const Bone = new r.Struct({
github wowserhq / blizzardry / src / lib / m2 / skin.js View on Github external
import r from 'restructure';

import { Vec3Float } from '../types';

import Nofs from './nofs';

const Submesh = new r.Struct({
  partID: r.uint16le,
  level: r.uint16le,
  startVertex: r.uint16le,
  vertexCount: r.uint16le,
  startTriangle: r.uint16le,
  triangleCount: r.uint16le,
  boneCount: r.uint16le,
  startBone: r.uint16le,
  boneInfluences: r.uint16le,
  rootBone: r.uint16le,
  centerMass: Vec3Float,
  centerBoundingBox: Vec3Float,
  radius: r.floatle,
});

const Batch = new r.Struct({
  flags: r.uint16le,
  shaderID: r.uint16le,
  submeshIndex: r.uint16le,
  submeshIndex2: r.uint16le,
  vertexColorAnimationIndex: r.int16le,
  materialIndex: r.uint16le,
github wowserhq / blizzardry / src / lib / wmo / group.js View on Github external
const MOCV = Chunk({
  colors: new r.Array(new r.Struct({
    b: r.uint8,
    g: r.uint8,
    r: r.uint8,
    a: r.uint8,
  }), 'size', 'bytes'),
});

const MOBA = Chunk({
  batches: new r.Array(new r.Struct({
    skips: new r.Reserved(r.int16le, 2 * 3),
    firstIndex: r.uint32le,
    indexCount: r.uint16le,
    firstVertex: r.uint16le,
    lastVertex: r.uint16le,
    skip: new r.Reserved(r.uint8),
    materialID: r.uint8,
  }), 'size', 'bytes'),
});

const MODR = Chunk({
  doodadIndices: new r.Array(r.int16le, 'size', 'bytes'),
});

export default Chunked({
  MOGP: MOGP,
  MOPY: MOPY,
  MOVI: MOVI,
  MOVT: MOVT,
  MONR: MONR,
  MOTV: MOTV,
github wowserhq / blizzardry / src / lib / adt / index.js View on Github external
indexX: r.uint32le,
  indexY: r.uint32le,
  layerCount: r.uint32le,
  doodadCount: r.uint32le,
  offsetMCVT: r.uint32le,
  offsetMCNR: r.uint32le,
  offsetMCLY: r.uint32le,
  offsetMCRF: r.uint32le,
  offsetMCAL: r.uint32le,
  sizeMCAL: r.uint32le,
  offsetMCSH: r.uint32le,
  sizeMCSH: r.uint32le,
  areaID: r.uint32le,
  wmoCount: r.uint32le,
  holes: r.uint16le,
  unknown: r.uint16le,

  textureMaps: new r.Reserved(r.uint16le, 8),

  predTex: r.uint32le,
  noEffectDoodad: r.uint32le,
  offsetMCSE: r.uint32le,
  soundEmitterCount: r.uint32le,
  offsetMCLQ: r.uint32le,
  sizeMCLQ: r.uint32le,
  position: Vec3Float,
  offsetMCCV: r.uint32le,

  skip: new r.Reserved(r.uint32le, 2),

  MCVT: MCVT,
  MCCV: new r.Optional(SkipChunk, function () {
github wowserhq / blizzardry / src / lib / types / quat16.js View on Github external
import r from 'restructure';

export default new r.Struct({
  x: r.uint16le,
  y: r.uint16le,
  z: r.uint16le,
  w: r.uint16le,
});