Code Monkey home page Code Monkey logo

iqm-exm's Introduction

Inter-Quake Model + Excessive Model (.iqm/.exm) Loader

Loader depends on LÖVE 11.x. Requires CPML for animation support, but not static meshes.

IQM/EXM specifications

The IQM specification file here (iqm.txt) is derived from upstream, but with clarifications corresponding with existing implementations of the format (upstream exporter and converter), and as implemented by this exporter.

The EXM specification is TBD, but currently the only notable change is the usage of the comment field for JSON scene metadata (objects, properties, curves...). The formats are otherwise completely compatible, and will stay as such unless there's a very good reason in the future (perhaps for a v3 format with blend shapes). It's fairly likely that a future version of the exporter will also provide more guarantees for the vertex format in EXM files.

Blender Exporter

The Blender exporter supports exporting .iqm and .exm formats. The .exm format is backwards compatible with .iqm, but has an additional metadata block with unspecified json in it (subject to change in future revisions).

It is derived from the IQM SDK a few years ago before the license changed from public domain to MIT. This version has some quality of life improvements and new features as needed for Excessive's games.

Usage:

local iqm = require "iqm"

-- load:
local model = iqm.load("foo.exm")

-- Make sure to enable mipmaps
model.textures = {
	Material1 = love.graphics.newImage("foo.png", { mipmaps = true })
}

-- Set filtering to 16x anisotropic.
for _, texture in pairs(model.textures) do
	texture:setFilter("linear", "linear", 16)
end

-- draw:
-- You can draw the whole model as one mesh (just don't set draw range), but
-- if you draw this way you can assign a different shader/textures per-mesh.
-- (naturally, at the expense of more draw calls - do what's best for you)
for _, buffer in ipairs(model.meshes) do
	local texture = model.textures[buffer.material]
	model.mesh:setTexture(texture)
	model.mesh:setDrawRange(buffer.first, buffer.last - buffer.first)
	love.graphics.draw(model.mesh)
end

iqm-exm's People

Contributors

bjornbytes avatar karai17 avatar scurest avatar shakesoda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

iqm-exm's Issues

EXM sample models

sample models other than cthulhu from the love3d-demos repo would be helpful for people implementing support for the format who need something to test against.

IQMv3 (and/or EXMv3) wishlist/planning

figured I'd leave an issue up about this: future features wishlist. implementation details not required.

feedback/ideas are very much welcome, and everything is valuable. I intend for this format to remain opinionated (i.e. unlike glTF - things work exactly one way, with minimal indirection and an explicit focus on games and simplicity) and try to stay lean, but that doesn't mean we can't think up all kinds of things!

these don't all have to be good and fully thought out ideas, just some potential nice-to-haves to be thought of in depth at a later time. bonus points if they don't increase minimum required complexity to load a valid file.

ideally, new features will degrade nicely for existing readers and incomplete implementations, i.e. an older or minimal reader which doesn't support a given feature can still render a mesh correctly.

I have utterly no idea if upstream will ever update the format, but it seems unlikely. will change the format magic if compat is meaningfully broken ever.

exporter options

  • option to ignore root bone motion (convenient when animating)
  • export collections, white or blacklist?

metadata

  • frame markers (useful for animations having corresponding sfx, for example)
  • mesh tagging (vis, groups, collision, lods...)
  • look into a simple alternate metadata representation that doesn't need an entire json parser. parsing json is sluggish and a ton of code.
  • an actual material model? something like the disney or enterprise pbr model would be really handy, but this might be just way too specific to include.
  • cameras and lights might be useful to represent here (in addition to existing support for empties)
    • 2019-09-10: added light data export

format additions/changes/cleanup

  • the only animation flag is loop, are any others useful?
  • additional color and UV layers would be very useful. common to use second UVs for lightmaps, or more color layers for masking.
    • perhaps allow exporting additional color and weight layers as IQM_CUSTOM+n and use the vertex array flag for the base type?
    • 2019-4-4: added EXM_TEXCOORD2 vertex array 0x20. not in the spec. see comments.
  • some of the sections in the header aren't actually used as far as I can tell - what uses flags? has anyone actually used the extensions or should that be repurposed for metadata? etc...
  • more strict data types for components - lots of weird combinations are possible now, but few are actually used.
  • blend shapes (see how glTF does them?)
  • ushort vertex data (positions) scaled to (undeformed) bounding box, ushort normalized uvs, some kind of two-component normal encoding?
  • guaranteed object bounds, mesh uvs + normals + tangents
  • explicit non-deforming bones (useful for leaf bones for lengths, helper bones/targets...)
  • object animation and inverse transforms, implemented such that positions are still applied but if supported you can reverse the transformation and work in their original local space (so you don't have to understand an object hierarchy to render a model properly)

IQM/EXM debugger/inspector

IQE was kind of a bad idea (never quite matched the binary format, tons of extra export code, another format to support entirely...), but being able to inspect files in a human readable way is very useful. tools for inspecting model data would be worthwhile.

NLA is finicky if you don't have a current writable action

the entire export params nonsense needs to be gutted and switched with NLA, as it is actually designed for animating. unsure how to handle looping flag (magic names?)

also, when working on anything but the current (editing) NLA strip, export errors out from messing with read only params.

add exm specs, update iqm spec with clarifications

iqm's spec leaves some ambiguity which needs to be cleared up, especially by leaving the coordinate system unspecified (i.e. "use blender's").

exm should actually specify that it uses blender's z-up. iqm spec text should be clarified for what it actually does right now.

will need to begin to formalize the metadata block

latest blender revision is broken

commits after blender revision de491abf996281785391b18b3547d1bff305355f break this exporter, and frankly I have no idea why others aren't affected.

animations become completely hosed, like so:

blender_2018-12-08_09-41-43

https://developer.blender.org/rBde491abf996281785391b18b3547d1bff305355f#208632

I've got no clue what's going wrong yet to reduce this into a repro and was essentially told to fuck off without it, so I'm leaving this here for now.

if you are affected right now and need animations to work, build blender revision 38ef3d6b91e128c93557991cb8cb9911c9b21f90

Unhandled error on empty file(?)

So for some reason or another, blender decided to export what I'm assuming from the filesize is an empty mesh, and iqm.lua doesn't know what to make of it.
the iqm file:
https://alloyed.me/shared/probably_empty.iqm
traceback:

Error: rocks/share/lua/5.1/iqm/init.lua:173: declaration specifier expected near ';' at line 2
stack traceback:
    [C]: in function 'cdef'
    rocks/share/lua/5.1/iqm/init.lua:173: in function 'load'
    render.lua:94: in function 'f'
    main.lua:56: in function 'load_assets'
    main.lua:68: in function 'newA'
    rocks/share/lua/5.1/gabe/love.lua:20: in function 'load'
    [string "boot.lua"]:437: in function <[string "boot.lua"]:433>
    [C]: in function 'xpcall'

I haven't read the spec, so it might be that blender spit out an entirely invalid file. The details for that, just in case

  • blender 2.76b hash f337fea
  • iqm exporter 2015.8.3

replace (unspecified) exm json with binary chunk

parsing json is very slow, a hassle to do when using a language that doesn't provide it (i.e. C, C++), and inflates file sizes.

need to think about an efficient and simple structure for the scene metadata, and switch it from using a json comment to iqm extensions. no header changes will be required, so this will only impact compatibility if you use the existing json data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.