Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.66k stars 250 forks source link

Import minecraft terrain and player made structures #9

Open Headclot88 opened 7 years ago

Headclot88 commented 7 years ago

Being able to import terrain and player made structures from Minecraft into Godot would be useful as we would be able to use Minecraft as a level editor.

Zylann commented 7 years ago

I have no clue how to import the Minecraft format yet, but that could be really cool indeed. It would need to create a VoxelLibrary recreating Minecraft blocks, load a Minecraft world, and then convert it so that voxel IDs correspond to those in the VoxelLibrary. Doing that is very low priority for me, though.

I also thought about MagickaVoxel for import.

Headclot88 commented 7 years ago

This blog post might give some insight on porting MineCraft levels to a game engine. It is from the dev behind voxel farm. :)

http://procworld.blogspot.com/2017/03/destroy-block.html

https://www.youtube.com/watch?v=Z0upnXTM_kk

HeadClot commented 6 years ago

Hey Zylann Just thought I would chime in on this again.

I found something that may be of use for this issue. https://github.com/dougbinks/enkiMI

superewald commented 2 years ago

I would like to do something similar but instead of converting minecraft's region format, I thought of implementing a custom VoxelStream in order to load data from mca (minecraft region files). My personal aim is to create an API compatible minecraft clone in godot and this plugin seems to be best fit. I want to try implementing it on my own but before I wanna make sure I'm doing it right.

Creating the texture atlas should be easy (the InventivetalentDev/minecraft-assets repository contains necessary data).

According to Zylann's answer

It would need to create a VoxelLibrary recreating Minecraft blocks, load a Minecraft world, and then convert it so that voxel IDs correspond to those in the VoxelLibrary.

we should create a VoxelLibrary which maps the minecraft blocks. Though, I can't find any documentation on what exactly is the purpose of VoxelLibrary's. I assume it pulls the actual chunk data from a VoxelStream and instantiate the actual Voxel's but where does it get the materials (texture atlas) from ?

Thanks in advance!

Zylann commented 2 years ago

I assume it pulls the actual chunk data from a VoxelStream and instantiate the actual Voxel's

Very roughly, kind of? But that process happens in several stages involving more classes. In reality, a VoxelLibrary (now called VoxelBlockyLibrary in master) is just a list of 3D models. Each model contains geometry as a mesh. Models also have an ID, and that ID corresponds to the value of voxels. Your VoxelStream will be queried by an I/O thread, the data will be stored inside VoxelTerrain, which in turn will trigger mesh updates. VoxelMesherBlocky will then use a VoxelBlockyLibrary to convert a chunk of voxel data into a mesh that can be rendered.

About textures: each model also has a material index. This index corresponds to one material listed in VoxelTerrain properties. There is a maximum of 8 at the moment, mostly for historical reasons. But that doesn't mean you are limited to 8 textures: you are encouraged to use atlases, so in reality, you are limited in the number of shaders to use, and to render Minecraft blocks you don't need many (opaque, alpha clip, transparent?).

VoxelBlockyLibrary is also used for a few other things such as collisions with VoxelBoxMover and a some edition algorithms.

See https://voxel-tools.readthedocs.io/en/latest/blocky_terrain/