• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Web mdx/mdl converter/viewer

Status
Not open for further replies.
Level 3
Joined
May 2, 2017
Messages
5
GitHub - 4eb0da/war3-model: TypeScript-based mdl/mdx (Warcraft 3 model formats) converter/renderer
TypeScript-based parser/generator/viewer. May be used in browsers / node.js applications.

Demos:
Usage:
JavaScript:
import {parse as parseMDL} from '../../parsers/mdl';
import {generate as generateMDL} from '../../generators/mdl';

let model = parseMDL('...');
let mdl = generateMDL(model);
console.log(mdl);


MDX/MDL features and limitations:
  • All standart features like Sequences, Bones, Cameras, etc
  • Multiple texture chunks (mdx only)
  • Multiple sequences/nodes with the same name (not quite sure is it feature or not, but War3 actually contains such models)
  • SoundTrack not supported
Viewer features and limitations:
  • Standart geometry/animation
  • Custom team color setting
  • ReplaceableId 1/2
  • Global sequences
  • Alpha blending and multiple layers
  • TextureAnimation
  • Billboarded/BillboardedLockXYZ, w/o DontInherit/CameraAnchored
  • RibbonEmitter (w/o Gravity and TextureSlot/Color animation)
  • ParticleEmitter2 (with Tail/Head/Both/Squirt(?))
  • Limited mobile devices support
  • No light support (normals, light, Unshaded, etc)
  • No render priority support (PriorityPlane and others)
BLP support
  • BLP1 only (not BLP0 and BLP2 support)
  • Decoder only, no encoder
  • Direct & jpeg data
  • Variable alpha (8/4/1/0 bit, but tested only 8/0)
  • API for getting all mipmap level's data

blademaster.gif
waterelemental.gif
 
Last edited:
Level 3
Joined
May 2, 2017
Messages
5
Yep, you are right, textures in preview works in some unobvious way.
After dragging model into the page additional drop zones will be added for textures from the model.
In GIF's from topic post I manually converted BLP into PNG.
As you mentioned, right now there is no BLP support. Moreover, I have no plans for it. Currently renderer have api for external texture setting, so BLP parser can be used "outside" of renderer.

Can't find your github page (I've googled it and seen your profile with no result).
By the way, thank you for your "MDX Specifications" thread, I've used it in some tricky parts, which other specifications have missed (not yet posted "thanks paragraph" in repo =/ )
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
GitHub - flowtsohg/mdx-m3-viewer: A WebGL viewer for MDX and M3 files used by the games Warcraft 3 and Starcraft 2 respectively.

It's a bit of a mess, since the last official version is so old, but you'll get the idea.
Branch v4 is much newer so the code is a lot more organized, but it also uses instanced rendering, so the rendering code will probably be too different for your code.

Probably only interesting stuff for you in src/handlers/.

If you look at the BLP handler, you'll see it's very simple to load BLPs. The hard part is getting JPG parsing, so I used a 3rd party library for that (can't use a native browser Image object, since it premultiplies the alpha channel, Blizzard use nonstandard 4 channel RGBA data in JPG format).
If you do want the BLP code, I suggest you to check the v4 version. It has fixes and is neater.
DSG also wrote updated specs BLP Specifications (WC3)

Converting BLPs to PNGs on the fly when requesting textures, ahh, reminds me of the 3D viewer a couple of years ago, nostalgic.
Once you have support for BLP, ask Ralle if you can get access to the database, and then your code can automatically load in-game resources.
 
Last edited:
Level 3
Joined
May 2, 2017
Messages
5
Pretty interesting. I've look BLP code at this weekend. Thanks.

Found 3d viewer there, on Hive. Didn't know it ever exist (but SC2 viewer not working right now, FYI)
 
Last edited:
Level 3
Joined
May 2, 2017
Messages
5
Added BLP1 decoding support (used your code A LOT), added demo and readme update
Also published to npm
Thanks for the links
 
Status
Not open for further replies.
Top