Skip to content

5z3f/ChaosLib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChaosLib λ

// ------------------------------------------------------------
// ChaosLib - Last Chaos Library (Alpha, under construction)
// Written in .NET 5 | C# 9.0
// ------------------------------------------------------------
// ChaosLib.D3D        3D Utilites
// ChaosLib.MAP        Game Data Mapper
// ------------------------------------------------------------

Currently Available

  • Binary Importer
    • BM Last Chaos Mesh (Version 16 & 17)
    • BM Serious Engine 1.10 Mesh (Version 11 & 12)
    • BS Last Chaos Skeleton
    • BA Last Chaos Animation
    • BAE Last Chaos Animation Effect
    • TEX Last Chaos Texture
  • Binary Exporter
    • BM Last Chaos Mesh (Version 17)
    • BM Serious Engine 1.10 Mesh (Version 12)
    • BS Last Chaos Skeleton
    • BA Last Chaos Animation
    • BAE Last Chaos Animation Effect
    • TEX Last Chaos Texture (Uncompressed)
  • ASCII Exporter
    • AM Mesh 0.1
    • AS Skeleton 0.1
    • AA Animation 0.1
    • AAL Animset List
  • OBJ Exporter
    • OBJ Mesh (with UV) (this format does not support weight maps which are needed for animations)
  • GLTF Exporter
    • GLTF/GLB Mesh (without weight maps) (if .png textures exists in saving directory they will be packed into .glb file)

Currently Available

  • Binary Importer
    • LOD MobAll (NPC)
    • LOD Action
    • LOD Title
    • LOD MonsterCombo
    • BIN LevelGuide
    • LOD ItemExchange
    • DTA Help (help1)
    • DTA Map
    • BIN ArmorPreview
    • WTR WorldTerrain (Version 19 & 20)
    • SAT ServerAttributeMap
    • SHT ServerHeightMap
  • Binary Exporter
    • LOD MobAll (NPC)
    • LOD Action
    • LOD Title
    • LOD MonsterCombo
    • BIN LevelGuide
    • LOD ItemExchange
    • DTA Help (help1)
    • DTA Map
    • BIN ArmorPreview
  • Mapped with database
    • LOD NPC
    • LOD Action
    • LOD Title
    • LOD MonsterCombo
    • LOD ItemExchange
    • DTA Help (help1)

Known issues

  • Rotation in animation is unstable, quaternion correction needed
  • Skeleton should be child->parent sorted before exporting

Showcase

.BA >> .AA >> Milkshape 3D >> .FBX >> Cinema 4D

ChaosAsset chaosAsset = new ChaosAsset();
var dataObject = chaosAsset.Import(AssetType.Animation, "besurel.ba", AssetDataType.Binary);
chaosAsset.Export(AssetType.Animation, dataObject.Animations[0], "attack01.aa", AssetDataType.ASCII);

besurel_attack01.aa

.BS >> .AS >> Milkshape 3D >> .FBX >> Cinema 4D

ChaosAsset chaosAsset = new ChaosAsset();
var dataObject = chaosAsset.Import(AssetType.Skeleton, "besurel.bs", AssetDataType.Binary);
chaosAsset.Export(AssetType.Skeleton, dataObject, "besurel.as", AssetDataType.ASCII);

besurel.as

.BM >> .OBJ >> Cinema 4D

ChaosAsset chaosAsset = new ChaosAsset();
var dataObject = chaosAsset.Import(AssetType.Mesh, "besurel.bm", AssetDataType.Binary);
chaosAsset.Export(AssetType.Mesh, dataObject, "besurel.obj", AssetDataType.OBJ);

besurel.obj

.TEX >> .PNG

ChaosAsset chaosAsset = new ChaosAsset();
var texture = chaosAsset.Import(AssetType.Texture, "besurel.tex", AssetDataType.Binary);
Bitmap bmp = texture.BitmapFrames[0]; // non animated textures are exported as Frame 0
bmp.Save("besurel.png", ImageFormat.Png);
Besurel Texture

besurel.png

Animated Texture

example-animated-texture

MAP ATTRIBUTES

attribute-all.png

.WTR >> .PNG

ChaosMap chaosMap = new ChaosMap();
bool colorizeAttributes = true;
var dataObject = chaosMap.Import(ContentType.WorldTerrain, ContentDataType.Binary, "Dratan.wtr", colorizeAttributes);

// save attributes as merged bitmap
Bitmap bmpMerged = dataObject.AttributeBitmap.Layers.Merged;
bmpMerged.Save("attribute-combined.png", ImageFormat.Png);

COMBINED

ChaosMap chaosMap = new ChaosMap();
bool colorizeAttributes = true;
var dataObject = chaosMap.Import(ContentType.WorldTerrain, ContentDataType.Binary, "Dratan.wtr", colorizeAttributes);

// save single attribute
Bitmap bmpUnwalkable = dataObject.AttributeBitmap.Layers.MATT_UNWALKABLE;
bmpUnwalkable.Save("attribute-unwalkable.png", ImageFormat.Png);

MATT_UNWALKABLE

.SAT >> .PNG

// sat contains only raw attribute bytes, there is no header defining version or map size so we need to do it manually
dynamic settings = new ExpandoObject();
settings.Width = 3072;
settings.Height = 3072;
settings.IsNew = true;                       // sat version
settings.SeparateLayers = true;              // whether create only merged bitmap or also separated layers

var dataObject = chaosMap.Import(ContentType.ServerAttributeMap, ContentDataType.Binary, "Dratan_3072_3072_0_1F.sat", settings);

// save single attribute
Bitmap bmpUnwalkable = dataObject.Layers.MATT_UNWALKABLE;
bmpUnwalkable.Save("attribute-unwalkable.png", ImageFormat.Png);

// save all merged attributes
Bitmap bmpMerged = dataObject.Layers.Merged;
bmpMerged.Save("attribute-combined.png", ImageFormat.Png);

ATTRIBUTE COLORS

#FFFFFFFF MATT_WALKABLE
#FF000000 MATT_UNWALKABLE
#FF32CD32 MATT_PEACE
#FFFFA07A MATT_FREEPKZONE
#FFCD5C5C MATT_WAR
#FFEE82EE MATT_STAIR_UP
#FFEE82EE MATT_STAIR_DOWN
#FFFFE4E1 MATT_PRODUCT_PUBLIC
#FF800000 MATT_PRODUCT_PRIVATE

Contributors

  • Karmel0x - his knowledge and helping hand