I continue to make progress in small leaps as I dig away at the reworking of the core engine.
Tonight I finally got actual world data loading in. This is kind of one of those "leaps". The block types and stuff still aren't fully ported over but it's still progress... and looks kind of funny.
As part of the plugin related restructuring, the engine tries to be more robust in the face of missing things. So when a plugin doesn't define a particular block then you get that "BAD" block. The water, leaf, flora, etc. materials haven't been ported over yet so those blocks are still "bad". (The green lines are showing me the "leaf" boundaries for debugging purposes.)
I've done a lot of work on the plug-in side of things, especially related to block types and materials. I'd already converted the old version's block types over to groovy scripts some time back but I've been cleaning them up a little more. The new design separates things a bit better and I don't end up with UI/Build-mode specific crud down in these files.
Here is an example of some of the material definitions:
materialLibrary( "core" ) {
material( "dirt" ) {
diffuseMap = texture("Textures/brown-dirt2.jpg", TextureRepeat.XY )
normalMap = texture("Textures/brown-dirt-norm.jpg", TextureRepeat.XY )
indexedNormals = true // automatically means there are two versions of this material
}
material( "grass-side" ) {
diffuseMap = texture( "Textures/brown-dirt-side2.jpg", TextureRepeat.X )
normalMap = texture( "Textures/brown-dirt-side-norms.jpg", TextureRepeat.X )
parallaxMap = texture( "Textures/brown-dirt-side-bump.jpg", TextureRepeat.X )
indexedNormals = true
}
material( "grass" ) {
diffuseMap = texture( "Textures/grass.jpg", TextureRepeat.XY )
normalMap = texture( "Textures/grass-norm.jpg", TextureRepeat.XY )
indexedNormals = true
}
material( "sand" ) {
diffuseMap = texture( "Textures/sand.jpg", TextureRepeat.XY )
normalMap = texture( "Textures/grass-norm.jpg", TextureRepeat.XY )
indexedNormals = true
}
....
And now the block types and templates reference them by name... and a material name is fully-qualified with the library name.
Here's an example of a library with some templates in it. Templates can be reused by multiple block types.
blockLibrary( name:"core-templates" ) {
template( "cube" ) {
volume( 1 )
north( BoundaryShapes.UNIT_SQUARE ) {
indexedNormals(true);
quad {
material( "core:dirt" );
vertex( 1, 0, 0 ) {
texture( 0, 0 );
}
vertex( 0, 0, 0 ) {
texture( 1, 0 );
}
vertex( 0, 0, 1 ) {
texture( 1, 1 );
}
vertex( 1, 0, 1 ) {
texture( 0, 1 );
}
}
}
south( BoundaryShapes.UNIT_SQUARE ) {
indexedNormals(true);
quad {
material( "core:dirt" );
vertex( 0, 1, 0 ) {
texture( 0, 0 );
}
vertex( 1, 1, 0 ) {
texture( 1, 0 );
}
vertex( 1, 1, 1 ) {
texture( 1, 1 );
}
vertex( 0, 1, 1 ) {
texture( 0, 1 );
}
}
}
...too much more to include here as just a small example...
And then some actual block types in a library:
blockLibrary( name:"core-blocks" ) {
block( "BAD-BLOCK" ) {
fromTemplate( "cube" );
replaceMaterial( "core:dirt", "bad" );
indexedNormals(false);
}
block( "dirt" ) {
fromTemplate( "cube" );
}
rotationGroup( "dirt-wedge" ) {
rotations( "dirt-wedge-n", "dirt-wedge-e", "dirt-wedge-s", "dirt-wedge-w" ) {
fromTemplate( "wedge-n" )
}
}
block( "grass" ) {
fromTemplate( "cube" );
replaceMaterial( "core:dirt", "core:grass-side" );
up {
replaceMaterial( "core:grass-side", "core:grass" );
}
down {
replaceMaterial( "core:grass-side", "core:dirt" );
}
}
So, assuming I get plug-in packaging working fully for this version, adding custom materials and block types should be pretty easy for anyone with a little coding knowledge.
The worlds are already setup to remember what plugins they were created with and they build a proper name index so that adding new block types later won't break an existing world, etc.. I will add some object export/import options for admins who want to transfer blueprints from one world to another since they will need to translate from one block type index to another.
Anyway, I'm pretty happy to have terrain loading in again as it's the prerequisite for 100 other things that I have to do next... and it's more fun to finish materials, lighting, etc. with a real world to look at.
Terrain is still not generated but I'm fortunate enough to have lots of big worlds to run around in that have stuff already generated. The generation has a few more tweaks to make before I can port it over since each "layer" of the generation cycle will now be a plugin and I need to potentially extract layer-specific information out for other reasons. (Like, I may want to know where buildings are... or where trees are, etc. without them having been actually generated.)
This post is probably a bit confusing... my head has been deep into code for several weeks now and my grasp on reality might be fraying a bit.