vengi-voxel / vengi

free and open source voxel art tools - editor, thumbnailer and format converter
http://vengi-voxel.github.io/vengi/
Other
1.05k stars 87 forks source link

VOXELFORMAT: VENGI: support loading and saving named points #470

Closed mgerhardy closed 2 weeks ago

mgerhardy commented 3 weeks ago

Formats like 3zh have named point support and in general it would be nice to also export them to e.g. formats like gltf where game engines could make use of them for e.g. character hands and to place the items.

One idea would be a new scene graph node type called point and just give it a name, a coordinate and of course the transforms.

UFO:Alien Invasion was using tag files for this - as we also have md2 import support - maybe we could also import the tag files and the animation. But for getting this done, the first step would be to get support for this into the format itself, import the points from formats like 3zh and export them as point meshes to gltf

Tasks

BenMcLean commented 3 weeks ago

One issue to watch out for is, in file formats which can contain multiple voxel models such as for animation frames, it should somehow be made clear that a named point is associated with one model/frame only. It shouldn't be possible to get confused which point belongs to which model/frame.

Named points should be unique, in that a combination of a model/frame and a string should map to either one 3D point or return null, but we should not allow two 3D points in the same model with the same name. (my C# code uses a Dictionary<string, Point3D> for this)

Also, the origin or "reference point" as VoxEdit's documentation calls this, should simply be one of the named points, with the name Origin. It should only be special by convention, but not special in the algorithm for parsing the file format.

I hope I'm making sense here.

BenMcLean commented 3 weeks ago

Another idea: It is valid for named points to be outside the bounds of the model. For example, a model of a character posed to throw an object might have a point outside the bounds of the model for where the object would land after being thrown so the game engine can draw a target there. It would be understandable if that's too hard for the editor to edit, but it should be valid for whatever file format I adopt.

My code's voxel models use three ushorts (unsigned 16-bit integers) for 3D coordinates and a byte for colors/materials, where 0 is empty and 1-255 are valid colors/materials. But my Point3D struct uses 32-bit signed integers because while it isn't valid to have voxels in negative coordinates, it is valid to have points there.

mgerhardy commented 3 weeks ago

Another idea: It is valid for named points to be outside the bounds of the model. For example, a model of a character posed to throw an object might have a point outside the bounds of the model for where the object would land after being thrown so the game engine can draw a target there. It would be understandable if that's too hard for the editor to edit, but it should be valid for whatever file format I adopt.

My code's voxel models use three ushorts (unsigned 16-bit integers) for 3D coordinates and a byte for colors/materials, where 0 is empty and 1-255 are valid colors/materials. But my Point3D struct uses 32-bit signed integers because while it isn't valid to have voxels in negative coordinates, it is valid to have points there.

This is already possible - the point can get moved free in the world already