Mythruna
April 25, 2024, 04:50:28 PM *
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: Why does it look so easy?  (Read 6763 times)
Michael
Donators
Hero Member
***
Posts: 2166



View Profile
« on: September 03, 2012, 09:53:34 PM »

i am once again looking at the files in mythruna, seeing if i understand. please tell me if i am correct.

I am using Stone for example:
Code:
addToolGroup( "Stone" ) {    
        addType( 4, "stone", "Stone", MaterialType.STONE, 0, new CubeFactory(4) );
        }
Of course the '''Add Tool Group''' is for a section on which you hold CTRL to scroll through that list.
the '''addType( 4, "stone", "Stone", MaterialType.STONE, 0, new CubeFactory(4) );'''

addType is to add the block.
the number (4) is like the grid number or whatever.
"stone" is the name.
"Stone" is the category name.
"MaterialType.STONE" im not sure exactly,
"new CubeFactory(4)" is i believe is put to form that material type into a square.
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #1 on: September 03, 2012, 10:06:16 PM »

I think it's:
4 = block type... ie: the number that goes in the grid cell (as you said)
"stone" = the unique name for the block type
"Stone" = the display name for the type... the one that appears in the tool view
MaterialType.STONE = the actual properties of the "material type", ie: mass, hardness, etc.  It also controls what sound effect is used when walking on it and stuff.
0 = the group number.  It controls how how faces are merged.
new CubeFactory(4) = the factory that actually creates the geometry using texture/material type "4" (ie: the bumpy stone texture) and it uses it for all of the sides.  It's only coincidence that this number is the same as the block type.

As to "Why does it look so easy?" because I wrote addToolGroup(), addType(), MaterialType, and CubeFactory for you.  They are doing all of the work and this line is only associating things together.  And it's about the simplest case there is.

Things do get more complicated, after all:
Code:
        addType( 28, "stone-pillar-se", "Stone Pillar", MaterialType.STONE ) {
            fromTemplate( "pillar-se" ) { remapMaterials( 0:4 ) }
        }

Which is referring to the pillar-se template:
Code:
    addTemplate( "pillar-se" ) {
        fromTemplate( "pillar-nw" ) {
            rotate(180);
        }
        up() {
            quad(0) { retexture(Direction.UP) }
        }
        down() {
            quad(0) { retexture(Direction.DOWN) }
        }
    }

Which itself is a 180 degree rotation of the pillar-nw template:
Code:
    addTemplate( "pillar-nw" ) {
 
        Vector3f oMin = new Vector3f( 0, 0, 0 );
        Vector3f oMax = new Vector3f( 0.5f, 0.5f, 1 );         
   
        collider( new CubeCollider( oMin, oMax ) );

        Vector3f min = oMin.subtract( 0.5f, 0.5f, 0.5f );
        Vector3f max = oMax.subtract( 0.5f, 0.5f, 0.5f );
       
        north( ShapeIndex.getRect(oMin.x, oMin.z, oMax.x, oMax.z) ) {
 
            quad {
                material(0);
               
                vertex( max.x, min.y, min.z ) {
                    texture( 0, 0 );
                }
                vertex( min.x, min.y, min.z ) {
                    texture( 1, 0 );
                }
                vertex( min.x, min.y, max.z ) {
                    texture( 1, 1 );
                }
                vertex( max.x, min.y, max.z ) {
                    texture( 0, 1 );
                }
            }
        }

        internal( Direction.SOUTH ) { //south( ShapeIndex.getRect(min.x, min.z, max.x, max.z) ) {
 
            quad {
                material(0);
               
                vertex( min.x, max.y, min.z ) {
                    texture( 0, 0 );
                }
                vertex( max.x, max.y, min.z ) {
                    texture( 1, 0 );
                }
                vertex( max.x, max.y, max.z ) {
                    texture( 1, 1 );
                }
                vertex( min.x, max.y, max.z ) {
                    texture( 0, 1 );
                }
            }
        }

        west( ShapeIndex.getRect(oMin.y, oMin.z, oMax.y, oMax.z) ) {
 
            quad {
                material(0);
               
                vertex( min.x, min.y, min.z ) {
                    texture( 0, 0 );
                }
                vertex( min.x, max.y, min.z ) {
                    texture( 1, 0 );
                }
                vertex( min.x, max.y, max.z ) {
                    texture( 1, 1 );
                }
                vertex( min.x, min.y, max.z ) {
                    texture( 0, 1 );
                }
            }
        }

        internal( Direction.EAST ) {
 
            quad {
                material(0);
               
                vertex( max.x, max.y, min.z ) {
                    texture( 0, 0 );
                }
                vertex( max.x, min.y, min.z ) {
                    texture( 1, 0 );
                }
                vertex( max.x, min.y, max.z ) {
                    texture( 1, 1 );
                }
                vertex( max.x, max.y, max.z ) {
                    texture( 0, 1 );
                }
            }
        }

        up( ShapeIndex.getRect(oMin.x, oMin.y, oMax.x, oMax.y) ) {
            quad {
                material(0);
               
                vertex( min.x, max.y, max.z ) {
                    texture( 0, 0 );
                }
                vertex( max.x, max.y, max.z ) {
                    texture( 1, 0 );
                }
                vertex( max.x, min.y, max.z ) {
                    texture( 1, 1 );
                }
                vertex( min.x, min.y, max.z ) {
                    texture( 0, 1 );
                }
            }
        }
       
        down( ShapeIndex.getRect(oMin.x, oMin.y, oMax.x, oMax.y) ) {
            quad {
                material(0);
               
                vertex( max.x, max.y, min.z ) {
                    texture( 1, 1 );
                }
                vertex( min.x, max.y, min.z ) {
                    texture( 0, 1 );
                }
                vertex( min.x, min.y, min.z ) {
                    texture( 0, 0 );
                }
                vertex( max.x, min.y, min.z ) {
                    texture( 1, 0 );
                }
            }
        }

    }

These are more complicated to explain.
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #2 on: September 03, 2012, 10:07:08 PM »

Suffice it to say... when custom block packs are formally supported: if you want to just reskin existing block shapes then your job will be very easy.
Logged
Moonkey
Hero Member
*****
Posts: 1587

This is probably a picture.


View Profile
« Reply #3 on: September 05, 2012, 12:22:33 AM »

Suffice it to say... when custom block packs are formally supported: if you want to just reskin existing block shapes then your job will be very easy.


I feel like making a retro texture pack. Smiley
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!