More updates

This commit is contained in:
Bill 2022-12-21 17:23:41 -05:00
parent b116ebd029
commit e2cad3b9fe
45 changed files with 923 additions and 234 deletions

View File

@ -0,0 +1,8 @@
import { IAssetPlaneVisualization } from './IAssetPlaneVisualization';
export interface IAssetPlane
{
id?: string;
visualizations?: IAssetPlaneVisualization[];
animatedVisualization?: IAssetPlaneVisualization[];
}

View File

@ -0,0 +1,7 @@
import { IAssetPlaneMaskVisualization } from './IAssetPlaneMaskVisualization';
export interface IAssetPlaneMask
{
id?: string;
visualizations?: IAssetPlaneMaskVisualization[];
}

View File

@ -0,0 +1,6 @@
import { IAssetPlaneMask } from './IAssetPlaneMask';
export interface IAssetPlaneMaskData
{
masks?: IAssetPlaneMask[];
}

View File

@ -0,0 +1,7 @@
import { IAssetPlaneTextureBitmap } from './IAssetPlaneTextureBitmap';
export interface IAssetPlaneMaskVisualization
{
size?: number;
bitmaps?: IAssetPlaneTextureBitmap[];
}

View File

@ -0,0 +1,7 @@
import { IAssetPlaneMaterialCellMatrix } from './IAssetPlaneMaterialCellMatrix';
export interface IAssetPlaneMaterial
{
id?: string;
matrices?: IAssetPlaneMaterialCellMatrix[];
}

View File

@ -0,0 +1,7 @@
import { IAssetPlaneMaterialCellExtraItemData } from './IAssetPlaneMaterialCellExtraItemData';
export interface IAssetPlaneMaterialCell
{
textureId?: string;
extraData?: IAssetPlaneMaterialCellExtraItemData;
}

View File

@ -0,0 +1,8 @@
import { IAssetPlaneMaterialCell } from './IAssetPlaneMaterialCell';
export interface IAssetPlaneMaterialCellColumn
{
repeatMode?: string;
width?: number;
cells?: IAssetPlaneMaterialCell[];
}

View File

@ -0,0 +1,6 @@
export interface IAssetPlaneMaterialCellExtraItemData
{
limitMax?: number;
extraItemTypes?: string[];
offsets?: [number, number][];
}

View File

@ -0,0 +1,12 @@
import { IAssetPlaneMaterialCellColumn } from './IAssetPlaneMaterialCellColumn';
export interface IAssetPlaneMaterialCellMatrix
{
repeatMode?: string;
align?: string;
normalMinX?: number;
normalMaxX?: number;
normalMinY?: number;
normalMaxY?: number;
columns?: IAssetPlaneMaterialCellColumn[];
}

View File

@ -0,0 +1,7 @@
import { IAssetPlaneTextureBitmap } from './IAssetPlaneTextureBitmap';
export interface IAssetPlaneTexture
{
id?: string;
bitmaps?: IAssetPlaneTextureBitmap[];
}

View File

@ -0,0 +1,8 @@
export interface IAssetPlaneTextureBitmap
{
assetName?: string;
normalMinX?: number;
normalMaxX?: number;
normalMinY?: number;
normalMaxY?: number;
}

View File

@ -0,0 +1,11 @@
import { IAssetPlaneVisualizationAnimatedLayer } from './IAssetPlaneVisualizationAnimatedLayer';
import { IAssetPlaneVisualizationLayer } from './IAssetPlaneVisualizationLayer';
export interface IAssetPlaneVisualization
{
size?: number;
horizontalAngle?: number;
verticalAngle?: number;
layers?: IAssetPlaneVisualizationLayer[];
animatedLayers?: IAssetPlaneVisualizationAnimatedLayer[];
}

View File

@ -0,0 +1,6 @@
import { IAssetPlaneVisualizationAnimatedLayerItem } from './IAssetPlaneVisualizationAnimatedLayerItem';
export interface IAssetPlaneVisualizationAnimatedLayer
{
items?: IAssetPlaneVisualizationAnimatedLayerItem[];
}

View File

@ -0,0 +1,11 @@
export interface IAssetPlaneVisualizationAnimatedLayerItem
{
id?: number;
assetId?: string;
x?: string;
y?: string;
randomX?: string;
randomY?: string;
speedX?: number;
speedY?: number;
}

View File

@ -0,0 +1,10 @@
import { IAssetPlane } from './IAssetPlane';
import { IAssetPlaneMaterial } from './IAssetPlaneMaterial';
import { IAssetPlaneTexture } from './IAssetPlaneTexture';
export interface IAssetPlaneVisualizationData
{
planes?: IAssetPlane[];
materials?: IAssetPlaneMaterial[];
textures?: IAssetPlaneTexture[];
}

View File

@ -0,0 +1,7 @@
export interface IAssetPlaneVisualizationLayer
{
materialId?: string;
color?: number;
offset?: number;
align?: string;
}

View File

@ -1,4 +1,10 @@
import { IAssetPlaneMaskData } from './IAssetPlaneMaskData';
import { IAssetPlaneVisualizationData } from './IAssetPlaneVisualizationData';
export interface IAssetRoomVisualizationData export interface IAssetRoomVisualizationData
{ {
floorData?: IAssetPlaneVisualizationData;
wallData?: IAssetPlaneVisualizationData;
landscapeData?: IAssetPlaneVisualizationData;
maskData?: IAssetPlaneMaskData;
} }

View File

@ -1 +1,17 @@
export * from './IAssetPlane';
export * from './IAssetPlaneMask';
export * from './IAssetPlaneMaskData';
export * from './IAssetPlaneMaskVisualization';
export * from './IAssetPlaneMaterial';
export * from './IAssetPlaneMaterialCell';
export * from './IAssetPlaneMaterialCellColumn';
export * from './IAssetPlaneMaterialCellExtraItemData';
export * from './IAssetPlaneMaterialCellMatrix';
export * from './IAssetPlaneTexture';
export * from './IAssetPlaneTextureBitmap';
export * from './IAssetPlaneVisualization';
export * from './IAssetPlaneVisualizationAnimatedLayer';
export * from './IAssetPlaneVisualizationAnimatedLayerItem';
export * from './IAssetPlaneVisualizationData';
export * from './IAssetPlaneVisualizationLayer';
export * from './IAssetRoomVisualizationData'; export * from './IAssetRoomVisualizationData';

View File

@ -63,8 +63,8 @@ export class AssetMapper extends Mapper
if (IMAGE_SOURCES.has(assetXML.name)) asset.source = IMAGE_SOURCES.get(assetXML.name) as string; if (IMAGE_SOURCES.has(assetXML.name)) asset.source = IMAGE_SOURCES.get(assetXML.name) as string;
} }
if(assetXML.x !== undefined) asset.x = assetXML.x; asset.x = assetXML.x ?? 0;
if(assetXML.y !== undefined) asset.y = assetXML.y; asset.y = assetXML.y ?? 0;
if (assetXML.flipH !== undefined) asset.flipH = assetXML.flipH; if (assetXML.flipH !== undefined) asset.flipH = assetXML.flipH;
if (assetXML.flipV !== undefined) asset.flipV = assetXML.flipV; if (assetXML.flipV !== undefined) asset.flipV = assetXML.flipV;
if (assetXML.usesPalette !== undefined) asset.usesPalette = assetXML.usesPalette; if (assetXML.usesPalette !== undefined) asset.usesPalette = assetXML.usesPalette;

View File

@ -1,5 +1,17 @@
import { IAssetData } from '../../json'; import { IAssetData, IAssetPlane, IAssetPlaneMaskVisualization, IAssetPlaneVisualizationData } from '../../json';
import { RoomVisualizationXML } from '../../xml'; import { IAssetPlaneMask } from '../../json/asset/room-visualization/IAssetPlaneMask';
import { IAssetPlaneMaskData } from '../../json/asset/room-visualization/IAssetPlaneMaskData';
import { IAssetPlaneMaterial } from '../../json/asset/room-visualization/IAssetPlaneMaterial';
import { IAssetPlaneMaterialCell } from '../../json/asset/room-visualization/IAssetPlaneMaterialCell';
import { IAssetPlaneMaterialCellColumn } from '../../json/asset/room-visualization/IAssetPlaneMaterialCellColumn';
import { IAssetPlaneMaterialCellMatrix } from '../../json/asset/room-visualization/IAssetPlaneMaterialCellMatrix';
import { IAssetPlaneTexture } from '../../json/asset/room-visualization/IAssetPlaneTexture';
import { IAssetPlaneTextureBitmap } from '../../json/asset/room-visualization/IAssetPlaneTextureBitmap';
import { IAssetPlaneVisualization } from '../../json/asset/room-visualization/IAssetPlaneVisualization';
import { IAssetPlaneVisualizationAnimatedLayer } from '../../json/asset/room-visualization/IAssetPlaneVisualizationAnimatedLayer';
import { IAssetPlaneVisualizationAnimatedLayerItem } from '../../json/asset/room-visualization/IAssetPlaneVisualizationAnimatedLayerItem';
import { IAssetPlaneVisualizationLayer } from '../../json/asset/room-visualization/IAssetPlaneVisualizationLayer';
import { PlaneMaskVisualizationDataXML, PlaneMaterialCellColumnXML, PlaneMaterialCellMatrixXML, PlaneMaterialCellXML, PlaneMaterialXML, PlaneTextureBitmapXML, PlaneTextureXML, PlaneVisualizationAnimatedLayerItemXML, PlaneVisualizationAnimatedLayerXML, PlaneVisualizationDataXML, PlaneVisualizationLayerXML, PlaneVisualizationXML, PlaneXML, RoomVisualizationXML } from '../../xml';
import { Mapper } from './Mapper'; import { Mapper } from './Mapper';
export class RoomVisualizationMapper extends Mapper export class RoomVisualizationMapper extends Mapper
@ -8,13 +20,412 @@ export class RoomVisualizationMapper extends Mapper
{ {
if (!visualization || !output) return; if (!visualization || !output) return;
RoomVisualizationMapper.mapVisualizationXML(new RoomVisualizationXML(visualization.visualizationData), output); RoomVisualizationMapper.mapVisualizationXML(new RoomVisualizationXML(visualization.visualizationData), output)
} }
private static mapVisualizationXML(xml: RoomVisualizationXML, output: IAssetData): void private static mapVisualizationXML(xml: RoomVisualizationXML, output: IAssetData): void
{ {
if (!xml || !output) return; if (!xml || !output) return;
console.log(xml); output.roomVisualization = {};
if (xml.floorData !== undefined)
{
if (xml.floorData)
{
output.roomVisualization.floorData = {};
RoomVisualizationMapper.mapPlaneVisualizationDataXML(xml.floorData, output.roomVisualization.floorData);
}
}
if (xml.wallData !== undefined)
{
if (xml.wallData)
{
output.roomVisualization.wallData = {};
RoomVisualizationMapper.mapPlaneVisualizationDataXML(xml.wallData, output.roomVisualization.wallData);
}
}
if (xml.landscapeData !== undefined)
{
if (xml.landscapeData)
{
output.roomVisualization.landscapeData = {};
RoomVisualizationMapper.mapPlaneVisualizationDataXML(xml.landscapeData, output.roomVisualization.landscapeData);
}
}
if (xml.landscapeData !== undefined)
{
if (xml.landscapeData)
{
output.roomVisualization.landscapeData = {};
RoomVisualizationMapper.mapPlaneVisualizationDataXML(xml.landscapeData, output.roomVisualization.landscapeData);
}
}
if (xml.maskData !== undefined)
{
if (xml.maskData)
{
output.roomVisualization.maskData = {};
RoomVisualizationMapper.mapPlaneMaskData(xml.maskData, output.roomVisualization.maskData);
}
}
}
private static mapPlaneVisualizationDataXML(xml: PlaneVisualizationDataXML, output: IAssetPlaneVisualizationData): void
{
if (!xml || !output) return;
if (xml.planes !== undefined)
{
if (xml.planes.length)
{
output.planes = [];
RoomVisualizationMapper.mapPlanes(xml.planes, output.planes);
}
}
if (xml.materials !== undefined)
{
if (xml.materials.length)
{
output.materials = [];
RoomVisualizationMapper.mapMaterials(xml.materials, output.materials);
}
}
if (xml.textures !== undefined)
{
if (xml.textures.length)
{
output.textures = [];
RoomVisualizationMapper.mapTextures(xml.textures, output.textures);
}
}
}
private static mapPlanes(xml: PlaneXML[], output: IAssetPlane[]): void
{
if (!xml || !output) return;
for (const planeXML of xml)
{
const plane: IAssetPlane = {};
if (planeXML.id !== undefined) plane.id = planeXML.id;
if (planeXML.visualizations !== undefined)
{
if (planeXML.visualizations.length)
{
plane.visualizations = [];
RoomVisualizationMapper.mapPlaneVisualizationsXML(planeXML.visualizations, plane.visualizations);
}
}
if (planeXML.animatedVisualization !== undefined)
{
if (planeXML.animatedVisualization.length)
{
plane.animatedVisualization = [];
RoomVisualizationMapper.mapPlaneVisualizationsXML(planeXML.animatedVisualization, plane.animatedVisualization);
}
}
output.push(plane);
}
}
private static mapPlaneVisualizationsXML(xml: PlaneVisualizationXML[], output: IAssetPlaneVisualization[]): void
{
if (!xml || !output) return;
for (const planeVisualizationXML of xml)
{
const visualization: IAssetPlaneVisualization = {};
if (planeVisualizationXML.size !== undefined) visualization.size = planeVisualizationXML.size;
if (planeVisualizationXML.horizontalAngle !== undefined) visualization.horizontalAngle = planeVisualizationXML.horizontalAngle;
if (planeVisualizationXML.verticalAngle !== undefined) visualization.verticalAngle = planeVisualizationXML.verticalAngle;
if (planeVisualizationXML.layers !== undefined)
{
if (planeVisualizationXML.layers.length)
{
visualization.layers = [];
RoomVisualizationMapper.mapPlaneVisualizationLayers(planeVisualizationXML.layers, visualization.layers);
}
}
if (planeVisualizationXML.animatedLayers !== undefined)
{
if (planeVisualizationXML.animatedLayers.length)
{
visualization.animatedLayers = [];
RoomVisualizationMapper.mapPlaneVisualizationAnimatedLayers(planeVisualizationXML.animatedLayers, visualization.animatedLayers);
}
}
output.push(visualization);
}
}
private static mapPlaneVisualizationLayers(xml: PlaneVisualizationLayerXML[], output: IAssetPlaneVisualizationLayer[]): void
{
if (!xml || !output) return;
for (const planeVisualizationLayerXML of xml)
{
const layer: IAssetPlaneVisualizationLayer = {};
if (planeVisualizationLayerXML.materialId !== undefined) layer.materialId = planeVisualizationLayerXML.materialId;
if (planeVisualizationLayerXML.color !== undefined) layer.color = planeVisualizationLayerXML.color;
if (planeVisualizationLayerXML.offset !== undefined) layer.offset = planeVisualizationLayerXML.offset;
if (planeVisualizationLayerXML.align !== undefined) layer.align = planeVisualizationLayerXML.align;
output.push(layer);
}
}
private static mapPlaneVisualizationAnimatedLayers(xml: PlaneVisualizationAnimatedLayerXML[], output: IAssetPlaneVisualizationAnimatedLayer[]): void
{
if (!xml || !output) return;
for (const planeVisualizationAnimatedLayerXML of xml)
{
const animatedLayer: IAssetPlaneVisualizationAnimatedLayer = {};
if (planeVisualizationAnimatedLayerXML.items !== undefined)
{
if (planeVisualizationAnimatedLayerXML.items.length)
{
animatedLayer.items = [];
RoomVisualizationMapper.mapPlaneVisualizationAnimatedLayerItems(planeVisualizationAnimatedLayerXML.items, animatedLayer.items);
}
}
output.push(animatedLayer);
}
}
private static mapPlaneVisualizationAnimatedLayerItems(xml: PlaneVisualizationAnimatedLayerItemXML[], output: IAssetPlaneVisualizationAnimatedLayerItem[]): void
{
if (!xml || !output) return;
for (const planeVisualizationAnimatedLayerItemXML of xml)
{
const layerItem: IAssetPlaneVisualizationAnimatedLayerItem = {};
if (planeVisualizationAnimatedLayerItemXML.id !== undefined) layerItem.id = planeVisualizationAnimatedLayerItemXML.id;
if (planeVisualizationAnimatedLayerItemXML.assetId !== undefined) layerItem.assetId = planeVisualizationAnimatedLayerItemXML.assetId;
if (planeVisualizationAnimatedLayerItemXML.x !== undefined) layerItem.x = planeVisualizationAnimatedLayerItemXML.x;
if (planeVisualizationAnimatedLayerItemXML.y !== undefined) layerItem.y = planeVisualizationAnimatedLayerItemXML.y;
if (planeVisualizationAnimatedLayerItemXML.randomX !== undefined) layerItem.randomX = planeVisualizationAnimatedLayerItemXML.randomX;
if (planeVisualizationAnimatedLayerItemXML.randomY !== undefined) layerItem.randomY = planeVisualizationAnimatedLayerItemXML.randomY;
if (planeVisualizationAnimatedLayerItemXML.speedX !== undefined) layerItem.speedX = planeVisualizationAnimatedLayerItemXML.speedX;
if (planeVisualizationAnimatedLayerItemXML.speedY !== undefined) layerItem.speedY = planeVisualizationAnimatedLayerItemXML.speedY;
output.push(layerItem);
}
}
private static mapMaterials(xml: PlaneMaterialXML[], output: IAssetPlaneMaterial[]): void
{
if (!xml || !output) return;
for (const planeMaterialXML of xml)
{
const planeMaterial: IAssetPlaneMaterial = {};
if (planeMaterialXML.id !== undefined) planeMaterial.id = planeMaterialXML.id;
if (planeMaterialXML.matrices !== undefined)
{
if (planeMaterialXML.matrices.length)
{
planeMaterial.matrices = [];
RoomVisualizationMapper.mapMaterialCellMatrices(planeMaterialXML.matrices, planeMaterial.matrices);
}
}
output.push(planeMaterial);
}
}
private static mapMaterialCellMatrices(xml: PlaneMaterialCellMatrixXML[], output: IAssetPlaneMaterialCellMatrix[]): void
{
if (!xml || !output) return;
for (const planeMaterialCellMatrixXML of xml)
{
const planeMaterialCellMatrix: IAssetPlaneMaterialCellMatrix = {};
if (planeMaterialCellMatrixXML.repeatMode !== undefined) planeMaterialCellMatrix.repeatMode = planeMaterialCellMatrixXML.repeatMode;
if (planeMaterialCellMatrixXML.align !== undefined) planeMaterialCellMatrix.align = planeMaterialCellMatrixXML.align;
if (planeMaterialCellMatrixXML.normalMinX !== undefined) planeMaterialCellMatrix.normalMinX = planeMaterialCellMatrixXML.normalMinX;
if (planeMaterialCellMatrixXML.normalMaxX !== undefined) planeMaterialCellMatrix.normalMaxX = planeMaterialCellMatrixXML.normalMaxX;
if (planeMaterialCellMatrixXML.normalMinY !== undefined) planeMaterialCellMatrix.normalMinY = planeMaterialCellMatrixXML.normalMinY;
if (planeMaterialCellMatrixXML.normalMaxY !== undefined) planeMaterialCellMatrix.normalMaxY = planeMaterialCellMatrixXML.normalMaxY;
if (planeMaterialCellMatrixXML.columns !== undefined)
{
if (planeMaterialCellMatrixXML.columns.length)
{
planeMaterialCellMatrix.columns = [];
RoomVisualizationMapper.mapMaterialCellColumns(planeMaterialCellMatrixXML.columns, planeMaterialCellMatrix.columns);
}
}
output.push(planeMaterialCellMatrix);
}
}
private static mapMaterialCellColumns(xml: PlaneMaterialCellColumnXML[], output: IAssetPlaneMaterialCellColumn[]): void
{
if (!xml || !output) return;
for (const planeMaterialCellColumnXML of xml)
{
const planeMaterialCellColumn: IAssetPlaneMaterialCellColumn = {};
if (planeMaterialCellColumnXML.repeatMode !== undefined) planeMaterialCellColumn.repeatMode = planeMaterialCellColumnXML.repeatMode;
if (planeMaterialCellColumnXML.width !== undefined) planeMaterialCellColumn.width = planeMaterialCellColumnXML.width;
if (planeMaterialCellColumnXML.cells !== undefined)
{
if (planeMaterialCellColumnXML.cells.length)
{
planeMaterialCellColumn.cells = [];
RoomVisualizationMapper.mapMaterialCells(planeMaterialCellColumnXML.cells, planeMaterialCellColumn.cells);
}
}
output.push(planeMaterialCellColumn);
}
}
private static mapMaterialCells(xml: PlaneMaterialCellXML[], output: IAssetPlaneMaterialCell[]): void
{
if (!xml || !output) return;
for (const planeMaterialCellXML of xml)
{
const planeMaterialCell: IAssetPlaneMaterialCell = {};
if (planeMaterialCellXML.textureId !== undefined) planeMaterialCell.textureId = planeMaterialCellXML.textureId;
if (planeMaterialCellXML.extraData !== undefined)
{
planeMaterialCell.extraData = {};
if (planeMaterialCellXML.extraData.limitMax !== undefined) planeMaterialCell.extraData.limitMax = planeMaterialCellXML.extraData.limitMax;
if (planeMaterialCellXML.extraData.extraItemTypes !== undefined) planeMaterialCell.extraData.extraItemTypes = planeMaterialCellXML.extraData.extraItemTypes;
if (planeMaterialCellXML.extraData.offsets !== undefined) planeMaterialCell.extraData.offsets = planeMaterialCellXML.extraData.offsets;
}
output.push(planeMaterialCell);
}
}
private static mapTextures(xml: PlaneTextureXML[], output: IAssetPlaneTexture[]): void
{
if (!xml || !output) return;
for (const planeTextureXML of xml)
{
const planeTexture: IAssetPlaneTexture = {};
if (planeTextureXML.id !== undefined) planeTexture.id = planeTextureXML.id;
if (planeTextureXML.bitmaps !== undefined)
{
if (planeTextureXML.bitmaps.length)
{
planeTexture.bitmaps = [];
RoomVisualizationMapper.mapTextureBitmaps(planeTextureXML.bitmaps, planeTexture.bitmaps);
}
}
output.push(planeTexture);
}
}
private static mapTextureBitmaps(xml: PlaneTextureBitmapXML[], output: IAssetPlaneTextureBitmap[]): void
{
if (!xml || !output) return;
for (const planeTextureBitmapXML of xml)
{
const planeTextureBitmap: IAssetPlaneTextureBitmap = {};
if (planeTextureBitmapXML.assetName !== undefined) planeTextureBitmap.assetName = planeTextureBitmapXML.assetName;
if (planeTextureBitmapXML.normalMinX !== undefined) planeTextureBitmap.normalMinX = planeTextureBitmapXML.normalMinX;
if (planeTextureBitmapXML.normalMaxX !== undefined) planeTextureBitmap.normalMaxX = planeTextureBitmapXML.normalMaxX;
if (planeTextureBitmapXML.normalMinY !== undefined) planeTextureBitmap.normalMinY = planeTextureBitmapXML.normalMinY;
if (planeTextureBitmapXML.normalMaxY !== undefined) planeTextureBitmap.normalMaxY = planeTextureBitmapXML.normalMaxY;
output.push(planeTextureBitmap);
}
}
private static mapPlaneMaskData(xml: PlaneMaskVisualizationDataXML, output: IAssetPlaneMaskData): void
{
if (!xml || !output) return;
if ((xml.masks !== undefined) && Array.isArray(xml.masks))
{
output.masks = [];
for (const planeMaskXML of xml.masks)
{
const planeMask: IAssetPlaneMask = {};
if (planeMaskXML.id !== undefined) planeMask.id = planeMaskXML.id;
if ((planeMaskXML.visualizations !== undefined) && planeMaskXML.visualizations.length)
{
planeMask.visualizations = [];
for (const planeMaskVisualizationXML of planeMaskXML.visualizations)
{
const planeMaskVisualization: IAssetPlaneMaskVisualization = {};
if (planeMaskVisualizationXML.size !== undefined) planeMaskVisualization.size = planeMaskVisualizationXML.size;
if ((planeMaskVisualizationXML.bitmaps !== undefined) && planeMaskVisualizationXML.bitmaps.length)
{
planeMaskVisualization.bitmaps = [];
RoomVisualizationMapper.mapTextureBitmaps(planeMaskVisualizationXML.bitmaps, planeMaskVisualization.bitmaps);
}
planeMask.visualizations.push(planeMaskVisualization);
}
}
output.masks.push(planeMask);
}
}
} }
} }

View File

@ -1,23 +0,0 @@
import { PlaneAnimationLayerItemXML } from './PlaneAnimationLayerItemXML';
export class PlaneAnimationLayerXML
{
private readonly _items: PlaneAnimationLayerItemXML[];
constructor(xml: any)
{
const attributes = xml.$;
if ((xml.animationItem !== undefined) && Array.isArray(xml.animationItem))
{
this._items = [];
for (const item of xml.animationItem) this._items.push(new PlaneAnimationLayerItemXML(item));
}
}
public get items(): PlaneAnimationLayerItemXML[]
{
return this._items;
}
}

View File

@ -0,0 +1,23 @@
import { RoomPlaneMaskXML } from './RoomPlaneMaskXML';
export class PlaneMaskVisualizationDataXML
{
private readonly _masks: RoomPlaneMaskXML[];
constructor(xml: any)
{
const attributes = xml.$;
if ((xml.mask !== undefined) && Array.isArray(xml.mask))
{
this._masks = [];
for (const mask of xml.mask) this._masks.push(new RoomPlaneMaskXML(mask));
}
}
public get masks(): RoomPlaneMaskXML[]
{
return this._masks;
}
}

View File

@ -0,0 +1,34 @@
import { PlaneTextureBitmapXML } from './texture';
export class PlaneMaskVisualizationXML
{
private readonly _size: number;
private readonly _bitmaps: PlaneTextureBitmapXML[];
constructor(xml: any)
{
const attributes = xml.$;
if (attributes !== undefined)
{
if (attributes.size !== undefined) this._size = parseInt(attributes.size);
}
if ((xml.bitmap !== undefined) && Array.isArray(xml.bitmap))
{
this._bitmaps = [];
for (const bitmap of xml.bitmap) this._bitmaps.push(new PlaneTextureBitmapXML(bitmap));
}
}
public get size(): number
{
return this._size;
}
public get bitmaps(): PlaneTextureBitmapXML[]
{
return this._bitmaps;
}
}

View File

@ -1,4 +1,4 @@
export class PlaneAnimationLayerItemXML export class PlaneVisualizationAnimatedLayerItemXML
{ {
private readonly _id: number; private readonly _id: number;
private readonly _assetId: string; private readonly _assetId: string;

View File

@ -0,0 +1,23 @@
import { PlaneVisualizationAnimatedLayerItemXML } from './PlaneVisualizationAnimatedLayerItemXML';
export class PlaneVisualizationAnimatedLayerXML
{
private readonly _items: PlaneVisualizationAnimatedLayerItemXML[];
constructor(xml: any)
{
const attributes = xml.$;
if ((xml.animationItem !== undefined) && Array.isArray(xml.animationItem))
{
this._items = [];
for (const item of xml.animationItem) this._items.push(new PlaneVisualizationAnimatedLayerItemXML(item));
}
}
public get items(): PlaneVisualizationAnimatedLayerItemXML[]
{
return this._items;
}
}

View File

@ -1,10 +1,10 @@
import { PlaneMaterialXML } from './PlaneMaterialXML'; import { PlaneMaterialXML } from './material';
import { PlaneTextureXML } from './PlaneTextureXML'; import { PlaneXML } from './PlaneXML';
import { PlaneVisualizationXML } from './PlaneVisualizationXML'; import { PlaneTextureXML } from './texture';
export class PlaneVisualizationDataXML export class PlaneVisualizationDataXML
{ {
private readonly _planes: PlaneVisualizationXML[]; private readonly _planes: PlaneXML[];
private readonly _materials: PlaneMaterialXML[]; private readonly _materials: PlaneMaterialXML[];
private readonly _textures: PlaneTextureXML[]; private readonly _textures: PlaneTextureXML[];
@ -18,7 +18,7 @@ export class PlaneVisualizationDataXML
for (const wallParent of xml.walls) for (const wallParent of xml.walls)
{ {
if (Array.isArray(wallParent.wall)) for (const wall of wallParent.wall) this._planes.push(new PlaneVisualizationXML(wall)); if (Array.isArray(wallParent.wall)) for (const wall of wallParent.wall) this._planes.push(new PlaneXML(wall));
} }
} }
@ -28,7 +28,7 @@ export class PlaneVisualizationDataXML
for (const floorParent of xml.floors) for (const floorParent of xml.floors)
{ {
if (Array.isArray(floorParent.floor)) for (const floor of floorParent.floor) this._planes.push(new PlaneVisualizationXML(floor)); if (Array.isArray(floorParent.floor)) for (const floor of floorParent.floor) this._planes.push(new PlaneXML(floor));
} }
} }
@ -38,7 +38,7 @@ export class PlaneVisualizationDataXML
for (const landscapeParent of xml.landscapes) for (const landscapeParent of xml.landscapes)
{ {
if (Array.isArray(landscapeParent.landscape)) for (const landscape of landscapeParent.landscape) this._planes.push(new PlaneVisualizationXML(landscape)); if (Array.isArray(landscapeParent.landscape)) for (const landscape of landscapeParent.landscape) this._planes.push(new PlaneXML(landscape));
} }
} }
@ -63,7 +63,7 @@ export class PlaneVisualizationDataXML
} }
} }
public get planes(): PlaneVisualizationXML[] public get planes(): PlaneXML[]
{ {
return this._planes; return this._planes;
} }

View File

@ -1,4 +1,4 @@
export class PlaneLayerXML export class PlaneVisualizationLayerXML
{ {
private readonly _materialId: string; private readonly _materialId: string;
private readonly _color: number; private readonly _color: number;

View File

@ -1,10 +1,13 @@
import { PlaneXML } from './PlaneXML'; import { PlaneVisualizationAnimatedLayerXML } from './PlaneVisualizationAnimatedLayerXML';
import { PlaneVisualizationLayerXML } from './PlaneVisualizationLayerXML';
export class PlaneVisualizationXML export class PlaneVisualizationXML
{ {
private readonly _id: string; private readonly _size: number;
private readonly _visualizations: PlaneXML[]; private readonly _horizontalAngle: number;
private readonly _animatedVisualization: PlaneXML[]; private readonly _verticalAngle: number;
private readonly _layers: PlaneVisualizationLayerXML[];
private readonly _animatedLayers: PlaneVisualizationAnimatedLayerXML[];
constructor(xml: any) constructor(xml: any)
{ {
@ -12,36 +15,48 @@ export class PlaneVisualizationXML
if (attributes !== undefined) if (attributes !== undefined)
{ {
if (attributes.id !== undefined) this._id = attributes.id; if (attributes.size !== undefined) this._size = parseInt(attributes.size);
if (attributes.horizontalAngle !== undefined) this._horizontalAngle = parseFloat(attributes.horizontalAngle);
if (attributes.verticalAngle !== undefined) this._verticalAngle = parseFloat(attributes.verticalAngle);
} }
if ((xml.visualization !== undefined) && Array.isArray(xml.visualization)) if ((xml.visualizationLayer !== undefined) && Array.isArray(xml.visualizationLayer))
{ {
this._visualizations = []; this._layers = [];
for (const visualization of xml.visualization) this._visualizations.push(new PlaneXML(visualization)); for (const layer of xml.visualizationLayer) this._layers.push(new PlaneVisualizationLayerXML(layer));
} }
if ((xml.animatedVisualization !== undefined) && Array.isArray(xml.animatedVisualization)) if ((xml.animationLayer !== undefined) && Array.isArray(xml.animationLayer))
{ {
this._animatedVisualization = []; this._animatedLayers = [];
for (const visualization of xml.animatedVisualization) this._animatedVisualization.push(new PlaneXML(visualization)); for (const layer of xml.animationLayer) this._animatedLayers.push(new PlaneVisualizationAnimatedLayerXML(layer));
} }
} }
public get id(): string public get size(): number
{ {
return this._id; return this._size;
} }
public get visualizations(): PlaneXML[] public get horizontalAngle(): number
{ {
return this._visualizations; return this._horizontalAngle;
} }
public get animatedVisualization(): PlaneXML[] public get verticalAngle(): number
{ {
return this._animatedVisualization; return this._verticalAngle;
}
public get layers(): PlaneVisualizationLayerXML[]
{
return this._layers;
}
public get animatedLayers(): PlaneVisualizationAnimatedLayerXML[]
{
return this._animatedLayers;
} }
} }

View File

@ -1,13 +1,10 @@
import { PlaneAnimationLayerXML } from './PlaneAnimationLayerXML'; import { PlaneVisualizationXML } from './PlaneVisualizationXML';
import { PlaneLayerXML } from './PlaneLayerXML';
export class PlaneXML export class PlaneXML
{ {
private readonly _size: number; private readonly _id: string;
private readonly _horizontalAngle: number; private readonly _visualizations: PlaneVisualizationXML[];
private readonly _verticalAngle: number; private readonly _animatedVisualization: PlaneVisualizationXML[];
private readonly _layers: PlaneLayerXML[];
private readonly _animatedLayers: PlaneAnimationLayerXML[];
constructor(xml: any) constructor(xml: any)
{ {
@ -15,48 +12,36 @@ export class PlaneXML
if (attributes !== undefined) if (attributes !== undefined)
{ {
if (attributes.size !== undefined) this._size = parseInt(attributes.size); if (attributes.id !== undefined) this._id = attributes.id;
if (attributes.horizontalAngle !== undefined) this._horizontalAngle = parseFloat(attributes.horizontalAngle);
if (attributes.verticalAngle !== undefined) this._verticalAngle = parseFloat(attributes.verticalAngle);
} }
if ((xml.visualizationLayer !== undefined) && Array.isArray(xml.visualizationLayer)) if ((xml.visualization !== undefined) && Array.isArray(xml.visualization))
{ {
this._layers = []; this._visualizations = [];
for (const layer of xml.visualizationLayer) this._layers.push(new PlaneLayerXML(layer)); for (const visualization of xml.visualization) this._visualizations.push(new PlaneVisualizationXML(visualization));
} }
if ((xml.animationLayer !== undefined) && Array.isArray(xml.animationLayer)) if ((xml.animatedVisualization !== undefined) && Array.isArray(xml.animatedVisualization))
{ {
this._animatedLayers = []; this._animatedVisualization = [];
for (const layer of xml.animationLayer) this._animatedLayers.push(new PlaneAnimationLayerXML(layer)); for (const visualization of xml.animatedVisualization) this._animatedVisualization.push(new PlaneVisualizationXML(visualization));
} }
} }
public get size(): number public get id(): string
{ {
return this._size; return this._id;
} }
public get horizontalAngle(): number public get visualizations(): PlaneVisualizationXML[]
{ {
return this._horizontalAngle; return this._visualizations;
} }
public get verticalAngle(): number public get animatedVisualization(): PlaneVisualizationXML[]
{ {
return this._verticalAngle; return this._animatedVisualization;
}
public get layers(): PlaneLayerXML[]
{
return this._layers;
}
public get animatedLayers(): PlaneAnimationLayerXML[]
{
return this._animatedLayers;
} }
} }

View File

@ -0,0 +1,34 @@
import { PlaneMaskVisualizationXML } from './PlaneMaskVisualizationXML';
export class RoomPlaneMaskXML
{
private readonly _id: string;
private readonly _visualizations: PlaneMaskVisualizationXML[];
constructor(xml: any)
{
const attributes = xml.$;
if (attributes !== undefined)
{
if (attributes.id !== undefined) this._id = attributes.id;
}
if ((xml.maskVisualization !== undefined) && Array.isArray(xml.maskVisualization))
{
this._visualizations = [];
for (const visualization of xml.maskVisualization) this._visualizations.push(new PlaneMaskVisualizationXML(visualization));
}
}
public get id(): string
{
return this._id;
}
public get visualizations(): PlaneMaskVisualizationXML[]
{
return this._visualizations;
}
}

View File

@ -1,3 +1,4 @@
import { PlaneMaskVisualizationDataXML } from './PlaneMaskVisualizationDataXML';
import { PlaneVisualizationDataXML } from './PlaneVisualizationDataXML'; import { PlaneVisualizationDataXML } from './PlaneVisualizationDataXML';
export class RoomVisualizationXML export class RoomVisualizationXML
@ -5,6 +6,7 @@ export class RoomVisualizationXML
private readonly _wallData: PlaneVisualizationDataXML; private readonly _wallData: PlaneVisualizationDataXML;
private readonly _floorData: PlaneVisualizationDataXML; private readonly _floorData: PlaneVisualizationDataXML;
private readonly _landscapeData: PlaneVisualizationDataXML; private readonly _landscapeData: PlaneVisualizationDataXML;
private readonly _maskData: PlaneMaskVisualizationDataXML;
constructor(xml: any) constructor(xml: any)
{ {
@ -24,6 +26,11 @@ export class RoomVisualizationXML
{ {
this._landscapeData = new PlaneVisualizationDataXML(xml.landscapeData[0]); this._landscapeData = new PlaneVisualizationDataXML(xml.landscapeData[0]);
} }
if ((xml.maskData !== undefined) && Array.isArray(xml.maskData))
{
this._maskData = new PlaneMaskVisualizationDataXML(xml.maskData[0]);
}
} }
public get wallData(): PlaneVisualizationDataXML public get wallData(): PlaneVisualizationDataXML
@ -40,4 +47,9 @@ export class RoomVisualizationXML
{ {
return this._landscapeData; return this._landscapeData;
} }
public get maskData(): PlaneMaskVisualizationDataXML
{
return this._maskData;
}
} }

View File

@ -1 +1,10 @@
export * from './material';
export * from './PlaneMaskVisualizationDataXML';
export * from './PlaneVisualizationAnimatedLayerItemXML';
export * from './PlaneVisualizationAnimatedLayerXML';
export * from './PlaneVisualizationDataXML';
export * from './PlaneVisualizationLayerXML';
export * from './PlaneVisualizationXML';
export * from './PlaneXML';
export * from './RoomVisualizationXML'; export * from './RoomVisualizationXML';
export * from './texture';

View File

@ -0,0 +1,5 @@
export * from './PlaneMaterialCellColumnXML';
export * from './PlaneMaterialCellExtraItemDataXML';
export * from './PlaneMaterialCellMatrixXML';
export * from './PlaneMaterialCellXML';
export * from './PlaneMaterialXML';

View File

@ -0,0 +1,2 @@
export * from './PlaneTextureBitmapXML';
export * from './PlaneTextureXML';

View File

@ -9,7 +9,11 @@ export const GenerateNitroBundleFromSwf = async (habboAssetSWF: HabboAssetSWF, a
const spriteBundle = await GenerateSpriteSheet(habboAssetSWF); const spriteBundle = await GenerateSpriteSheet(habboAssetSWF);
const assetData = await SWFUtilities.mapXML2JSON(habboAssetSWF, assetType); const assetData = await SWFUtilities.mapXML2JSON(habboAssetSWF, assetType);
if(assetData) assetData.name = habboAssetSWF.getDocumentClass(); let assetName = habboAssetSWF.getDocumentClass();
return SWFUtilities.createNitroBundle(assetData.name, assetData, spriteBundle); if (assetName === 'HabboRoomContent') assetName = 'room';
assetData.name = assetName;
return SWFUtilities.createNitroBundle(assetName, assetData, spriteBundle);
}; };

View File

@ -12,6 +12,8 @@ export const GenerateSpriteSheet = async (habboAssetSWF: HabboAssetSWF, convertC
let documentClass = habboAssetSWF.getDocumentClass(); let documentClass = habboAssetSWF.getDocumentClass();
if (documentClass === 'HabboRoomContent') documentClass = 'room';
if (convertCase) documentClass = (documentClass.replace(/(?:^|\.?)([A-Z])/g, (x, y) => ('_' + y.toLowerCase().replace(/^_/, '')))); if (convertCase) documentClass = (documentClass.replace(/(?:^|\.?)([A-Z])/g, (x, y) => ('_' + y.toLowerCase().replace(/^_/, ''))));
for (const tag of tagList) for (const tag of tagList)
@ -50,6 +52,8 @@ export const GenerateSpriteSheet = async (habboAssetSWF: HabboAssetSWF, convertC
if (convertCase) className = ((className.replace(/(?:^|\.?)([A-Z])/g, (x, y) => ('_' + y.toLowerCase().replace(/^_/, '')))).substring(1)); if (convertCase) className = ((className.replace(/(?:^|\.?)([A-Z])/g, (x, y) => ('_' + y.toLowerCase().replace(/^_/, '')))).substring(1));
if (className.startsWith('HabboRoomContent')) className = className.replace('HabboRoomContent', 'room');
imageBundle.addImage(className, imageTag.imgData); imageBundle.addImage(className, imageTag.imgData);
} }

View File

@ -1,4 +1,5 @@
import { wrap } from 'bytebuffer'; import { wrap } from 'bytebuffer';
import { writeFile } from 'fs/promises';
import { parseStringPromise } from 'xml2js'; import { parseStringPromise } from 'xml2js';
import { AnimationMapper, AssetMapper, IAssetData, IndexMapper, LogicMapper, ManifestMapper, NitroBundle, RoomVisualizationMapper, SpriteBundle, VisualizationMapper } from '../common'; import { AnimationMapper, AssetMapper, IAssetData, IndexMapper, LogicMapper, ManifestMapper, NitroBundle, RoomVisualizationMapper, SpriteBundle, VisualizationMapper } from '../common';
import { HabboAssetSWF } from './HabboAssetSWF'; import { HabboAssetSWF } from './HabboAssetSWF';
@ -15,6 +16,8 @@ export class SWFUtilities
{ {
if (spriteBundle && (spriteBundle.spritesheet !== undefined)) assetData.spritesheet = spriteBundle.spritesheet; if (spriteBundle && (spriteBundle.spritesheet !== undefined)) assetData.spritesheet = spriteBundle.spritesheet;
writeFile('room.json', JSON.stringify(assetData), 'utf8');
const nitroBundle = new NitroBundle(); const nitroBundle = new NitroBundle();
nitroBundle.addFile((className + '.json'), Buffer.from(JSON.stringify(assetData))); nitroBundle.addFile((className + '.json'), Buffer.from(JSON.stringify(assetData)));
@ -87,8 +90,6 @@ export class SWFUtilities
{ {
const binaryData = SWFUtilities.getBinaryData(habboAssetSWF, 'visualization', true, snakeCase); const binaryData = SWFUtilities.getBinaryData(habboAssetSWF, 'visualization', true, snakeCase);
console.log(binaryData);
if (!binaryData) return null; if (!binaryData) return null;
return await parseStringPromise(this.removeComments(binaryData.binaryData)); return await parseStringPromise(this.removeComments(binaryData.binaryData));
@ -164,7 +165,9 @@ export class SWFUtilities
if (manifestXML) ManifestMapper.mapXML(manifestXML, output); if (manifestXML) ManifestMapper.mapXML(manifestXML, output);
const assetXML = await this.getAssetsXML(habboAssetSWF, snakeCase); let assetXML = await this.getAssetsXML(habboAssetSWF, snakeCase);
if (!assetXML) assetXML = await this.getRoomAssetsXML(habboAssetSWF, snakeCase);
if (assetXML) if (assetXML)
{ {
@ -194,10 +197,6 @@ export class SWFUtilities
} }
} }
const roomAssetXML = await this.getRoomAssetsXML(habboAssetSWF, snakeCase);
if (assetXML) AssetMapper.mapXML(roomAssetXML, output);
const animationXML = await this.getAnimationXML(habboAssetSWF, snakeCase); const animationXML = await this.getAnimationXML(habboAssetSWF, snakeCase);
if (animationXML) AnimationMapper.mapXML(animationXML, output); if (animationXML) AnimationMapper.mapXML(animationXML, output);
@ -209,10 +208,12 @@ export class SWFUtilities
const visualizationXML = await this.getVisualizationXML(habboAssetSWF, snakeCase); const visualizationXML = await this.getVisualizationXML(habboAssetSWF, snakeCase);
if (visualizationXML) VisualizationMapper.mapXML(visualizationXML, output); if (visualizationXML) VisualizationMapper.mapXML(visualizationXML, output);
else
{
const visualizationXML = await this.getRoomVisualizationXML(habboAssetSWF, snakeCase);
const roomVisualizationXML = await this.getRoomVisualizationXML(habboAssetSWF, snakeCase); if (visualizationXML) RoomVisualizationMapper.mapXML(visualizationXML, output);
}
if (roomVisualizationXML) RoomVisualizationMapper.mapXML(roomVisualizationXML, output);
return output; return output;
} }