Mythruna
March 28, 2024, 04:50:59 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new forums. See "Announcements" for a note for new users.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: State of things...  (Read 9819 times)
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« on: February 03, 2013, 01:55:29 AM »

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:
Code:
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.
Code:
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:
Code:
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. Smiley
Logged
BigredRm
Donators
Sr. Member
***
Posts: 379


<-o Word up goes to that modern man o->


View Profile
« Reply #1 on: February 03, 2013, 08:01:30 AM »



Team PSpeed!
Logged

Visit Iron Island @ 1708,702
belgariad87
Donators
Hero Member
***
Posts: 507


RPG player for life


View Profile
« Reply #2 on: February 03, 2013, 08:24:37 AM »

woo team PSpeed!

i feel stupid cuz i know i'm missing something as i try to read your code  Undecided  whats the difference between "diffuseMap" and "normalMap"?
Logged

Specs for future reference:
Windows 7 64bit ; Intel Quad Core ; 8GB RAM ; AMD Radeon HD 6800 ; TB HD
Michael
Donators
Hero Member
***
Posts: 2166



View Profile
« Reply #3 on: February 03, 2013, 10:11:24 AM »

Team PSpeed: ADMIN: pspeed; members: BigredRm, belgariad87, Shzylo

Hehe, That was an amazing thing you got there Paul!
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #4 on: February 03, 2013, 12:11:31 PM »

woo team PSpeed!

i feel stupid cuz i know i'm missing something as i try to read your code  Undecided  whats the difference between "diffuseMap" and "normalMap"?

Diffuse map is the colors of the texture.  The normal map defines how light hits the surface... it makes it look bumpy by adding highlights and shadows.  A parallax map actually displaces the pixels a little (within the bounds of the polygon) so that it looks more 3D.  For example, in the current version of Mythruna, the wood planks texture has both normal maps and parallax maps.  Not only does the highlighting change as light passes over but if you move you can see different edges of the individual boards.
Logged
belgariad87
Donators
Hero Member
***
Posts: 507


RPG player for life


View Profile
« Reply #5 on: February 03, 2013, 01:15:48 PM »

woo team PSpeed!

i feel stupid cuz i know i'm missing something as i try to read your code  Undecided  whats the difference between "diffuseMap" and "normalMap"?

Diffuse map is the colors of the texture.  The normal map defines how light hits the surface... it makes it look bumpy by adding highlights and shadows.  A parallax map actually displaces the pixels a little (within the bounds of the polygon) so that it looks more 3D.  For example, in the current version of Mythruna, the wood planks texture has both normal maps and parallax maps.  Not only does the highlighting change as light passes over but if you move you can see different edges of the individual boards.
thats incredible! so does that mean 'texture' is a method that you created elsewhere? or is it a method at all
Logged

Specs for future reference:
Windows 7 64bit ; Intel Quad Core ; 8GB RAM ; AMD Radeon HD 6800 ; TB HD
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #6 on: February 03, 2013, 02:40:11 PM »

woo team PSpeed!

i feel stupid cuz i know i'm missing something as i try to read your code  Undecided  whats the difference between "diffuseMap" and "normalMap"?

Diffuse map is the colors of the texture.  The normal map defines how light hits the surface... it makes it look bumpy by adding highlights and shadows.  A parallax map actually displaces the pixels a little (within the bounds of the polygon) so that it looks more 3D.  For example, in the current version of Mythruna, the wood planks texture has both normal maps and parallax maps.  Not only does the highlighting change as light passes over but if you move you can see different edges of the individual boards.
thats incredible! so does that mean 'texture' is a method that you created elsewhere? or is it a method at all

Yeah, texture() is a function in the API for materials.  It does what it needs to do to load that texture.  I basically just exposed what I already do in the released version of Mythruna... but now to the groovy API for materials.
Logged
Michael
Donators
Hero Member
***
Posts: 2166



View Profile
« Reply #7 on: February 03, 2013, 02:44:21 PM »

I will love the convenience of this that texture if I ever want to add more blocks and it doesn't work Smiley
Logged
belgariad87
Donators
Hero Member
***
Posts: 507


RPG player for life


View Profile
« Reply #8 on: February 03, 2013, 07:41:40 PM »

Yeah, texture() is a function in the API for materials.  It does what it needs to do to load that texture.  I basically just exposed what I already do in the released version of Mythruna... but now to the groovy API for materials.
ah i see. maybe i am learning after all then  Wink
Logged

Specs for future reference:
Windows 7 64bit ; Intel Quad Core ; 8GB RAM ; AMD Radeon HD 6800 ; TB HD
Moonkey
Hero Member
*****
Posts: 1587

This is probably a picture.


View Profile
« Reply #9 on: February 04, 2013, 01:32:33 AM »

So Paul is a team of the Matrix... And he never told me...
Logged

Mythruna: Don't you dare read any posts I made before 2014.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!