NetCraft icon indicating copy to clipboard operation
NetCraft copied to clipboard

Entities

Open satoshinm opened this issue 7 years ago • 5 comments

Objects of arbitrary 3d models not locked to the world grid, unlike blocks.

  • [x] Spawn entities
  • [ ] Object model loading
  • [ ] Save/load to disk
  • [ ] Physics
  • [ ] Behavior ("AI")
  • [ ] Mobs

satoshinm avatar Apr 02 '17 20:04 satoshinm

Craft actually already supports a form of entities: players. This includes position/rotation updates with interpolation (P command), naming the entities by id (N), deleting entities when they leave the game (D). Players can roam freely from the world grid, as disembodied cubic heads.

The same existing functionality could be extended and reused for other kinds of "entities", question is, what next? Item drop entities? Mob entities? Projectile entities?

satoshinm avatar Apr 13 '17 04:04 satoshinm

Use http://assimp.org Open Asset Import Library (assimp) for asset loading object models files? Supports many types of formats including .stl (stereolithography) common on http://www.thingiverse.com and formats of various 3d modeling software packages. There is a tutorial to use assimp at https://learnopengl.com/#!Model-Loading/Assimp. And then drag-and-drop an object file to load it into the world as an entity.

satoshinm avatar May 11 '17 05:05 satoshinm

Assimp is not suitable for various reasons, see: https://github.com/satoshinm/NetCraft/pull/139#issuecomment-302745455

Some alternative code to consider, or write anew:

  • https://github.com/charles-l/sanegl/blob/master/sgl_mesh_loader.c .3ds Autodesk 3ds Max model loader
  • https://github.com/rlk/obj - Wavefront .obj - found here
  • Binary STL or text STL. three.js STL loader test: https://threejs.org/examples/webgl_loader_stl.html

satoshinm avatar May 20 '17 06:05 satoshinm

https://github.com/nothings/single_file_libs#geometry-file shows some promising model loading libraries in C: https://github.com/joeld42/tk_objfile https://github.com/syoyo/tinyobjloader-c and https://github.com/xelatihy/yocto-gl are for .obj, and https://github.com/ddiakopoulos/tinyply for .ply (C++)

satoshinm avatar May 27 '17 21:05 satoshinm

OBJ is one of the easier formats to parse. It would require hard-coding animations, but that may, or may not be an issue.

twetzel59 avatar Jun 10 '17 01:06 twetzel59