Japaneses Trees[V 1.0]

OdnetninI
Member
 
Posts: 38
Joined: Sun Oct 21, 2012 08:20

Japaneses Trees[V 1.0]

by OdnetninI » Thu Nov 01, 2012 17:03

If you want this type of trees continue reading:
Image

I added to the engine, Japanese Trees.

How to Compile: https://github.com/celeron55/minetest/blob/stable-0.4/README.txt

First Open src/subgame.cpp

For this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
std::string getGameName(const std::string &game_path)
{
    std::string conf_path = game_path + DIR_DELIM + "game.conf";
    Settings conf;
    bool succeeded = conf.readConfigFile(conf_path.c_str());
    if(!succeeded)
        return "";
    if(!conf.exists("name"))
        return "";
    return conf.get("name");
}


Change for this:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
bool japanese = false;

std::string getGameName(const std::string &game_path)
{
    std::string conf_path = game_path + DIR_DELIM + "game.conf";
    Settings conf;
    bool succeeded = conf.readConfigFile(conf_path.c_str());
    if(!succeeded)
        return "";
    if(!conf.exists("name"))
        return "";

/*
        Japanese
    */
    if(!conf.exists("JapaneseTree"))
        japanese = false;
    else {
        if (stoi(conf.get("JapaneseTree")) == 1)
            japanese = true;

        else
            japanese = false;
    }

    return conf.get("name");
}


Now open src/mapgen.cpp


Add This:


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
extern bool japanese;


Before:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
namespace mapgen


Now Change this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
        bool is_apple_tree, INodeDefManager *ndef)
{
    MapNode treenode(ndef->getId("mapgen_tree"));
    MapNode leavesnode(ndef->getId("mapgen_leaves"));
    MapNode applenode(ndef->getId("mapgen_apple"));

    s16 trunk_h = myrand_range(4, 5);
    v3s16 p1 = p0;
    for(s16 ii=0; ii<trunk_h; ii++)
    {
        if(vmanip.m_area.contains(p1))
            vmanip.m_data[vmanip.m_area.index(p1)] = treenode;
        p1.Y++;
    }

    // p1 is now the last piece of the trunk
    p1.Y -= 1;

VoxelArea leaves_a(v3s16(-2,-1,-2), v3s16(2,2,2));
    //SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]);
    Buffer<u8> leaves_d(leaves_a.getVolume());
    for(s32 i=0; i<leaves_a.getVolume(); i++)
        leaves_d[i] = 0;

    // Force leaves at near the end of the trunk
    {
        s16 d = 1;
        for(s16 z=-d; z<=d; z++)
        for(s16 y=-d; y<=d; y++)
        for(s16 x=-d; x<=d; x++)
        {
            leaves_d[leaves_a.index(v3s16(x,y,z))] = 1;
        }
    }

    // Add leaves randomly
    for(u32 iii=0; iii<7; iii++)
    {
        s16 d = 1;

        v3s16 p(
            myrand_range(leaves_a.MinEdge.X, leaves_a.MaxEdge.X-d),
            myrand_range(leaves_a.MinEdge.Y, leaves_a.MaxEdge.Y-d),
            myrand_range(leaves_a.MinEdge.Z, leaves_a.MaxEdge.Z-d)
        );

        for(s16 z=0; z<=d; z++)
        for(s16 y=0; y<=d; y++)
        for(s16 x=0; x<=d; x++)
        {
            leaves_d[leaves_a.index(p+v3s16(x,y,z))] = 1;
        }
    }

    // Blit leaves to vmanip
    for(s16 z=leaves_a.MinEdge.Z; z<=leaves_a.MaxEdge.Z; z++)
    for(s16 y=leaves_a.MinEdge.Y; y<=leaves_a.MaxEdge.Y; y++)
    for(s16 x=leaves_a.MinEdge.X; x<=leaves_a.MaxEdge.X; x++)
    {
        v3s16 p(x,y,z);
        p += p1;
        if(vmanip.m_area.contains(p) == false)
            continue;
        u32 vi = vmanip.m_area.index(p);
        if(vmanip.m_data[vi].getContent() != CONTENT_AIR
                && vmanip.m_data[vi].getContent() != CONTENT_IGNORE)
            continue;
        u32 i = leaves_a.index(x,y,z);
        if(leaves_d[i] == 1) {
            bool is_apple = myrand_range(0,99) < 10;
            if(is_apple_tree && is_apple) {
                vmanip.m_data[vi] = applenode;
            } else {
                    vmanip.m_data[vi] = leavesnode;
                }
            }
        }
    }
}


For This:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
void make_tree(ManualMapVoxelManipulator &vmanip, v3s16 p0,
        bool is_apple_tree, INodeDefManager *ndef)
{
    MapNode treenode(ndef->getId("mapgen_tree"));
    MapNode leavesnode(ndef->getId("mapgen_leaves"));
    MapNode Jleavesnode(ndef->getId("mapgen_leaves_japanese"));
    MapNode applenode(ndef->getId("mapgen_apple"));

    s16 trunk_h = myrand_range(4, 5);
    v3s16 p1 = p0;
    for(s16 ii=0; ii<trunk_h; ii++)
    {
        if(vmanip.m_area.contains(p1))
            vmanip.m_data[vmanip.m_area.index(p1)] = treenode;
        p1.Y++;
    }

    // p1 is now the last piece of the trunk
    p1.Y -= 1;

    VoxelArea leaves_a(v3s16(-2,-1,-2), v3s16(2,2,2));
    //SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]);
    Buffer<u8> leaves_d(leaves_a.getVolume());
    for(s32 i=0; i<leaves_a.getVolume(); i++)
        leaves_d[i] = 0;

    // Force leaves at near the end of the trunk
    {
        s16 d = 1;
        for(s16 z=-d; z<=d; z++)
        for(s16 y=-d; y<=d; y++)
        for(s16 x=-d; x<=d; x++)
        {
            leaves_d[leaves_a.index(v3s16(x,y,z))] = 1;
        }
    }

    // Add leaves randomly
    for(u32 iii=0; iii<7; iii++)
    {
        s16 d = 1;

        v3s16 p(
            myrand_range(leaves_a.MinEdge.X, leaves_a.MaxEdge.X-d),
            myrand_range(leaves_a.MinEdge.Y, leaves_a.MaxEdge.Y-d),
            myrand_range(leaves_a.MinEdge.Z, leaves_a.MaxEdge.Z-d)
        );

        for(s16 z=0; z<=d; z++)
        for(s16 y=0; y<=d; y++)
        for(s16 x=0; x<=d; x++)
        {
            leaves_d[leaves_a.index(p+v3s16(x,y,z))] = 1;
        }
    }

    bool is_japanese = myrand_range(0,99) < 20;

    // Blit leaves to vmanip
    for(s16 z=leaves_a.MinEdge.Z; z<=leaves_a.MaxEdge.Z; z++)
    for(s16 y=leaves_a.MinEdge.Y; y<=leaves_a.MaxEdge.Y; y++)
    for(s16 x=leaves_a.MinEdge.X; x<=leaves_a.MaxEdge.X; x++)
    {
        v3s16 p(x,y,z);
        p += p1;
        if(vmanip.m_area.contains(p) == false)
            continue;
        u32 vi = vmanip.m_area.index(p);
        if(vmanip.m_data[vi].getContent() != CONTENT_AIR
                && vmanip.m_data[vi].getContent() != CONTENT_IGNORE)
            continue;
        u32 i = leaves_a.index(x,y,z);
        if(leaves_d[i] == 1) {
            bool is_apple = myrand_range(0,99) < 10;
            if(is_apple_tree && is_apple) {
                vmanip.m_data[vi] = applenode;
            } else {
                //JAPANESE
                if (japanese == true && is_japanese) {
                    vmanip.m_data[vi] = Jleavesnode;
                } else {
                    // Normal
                    vmanip.m_data[vi] = leavesnode;
                }
            }
        }
    }
}


your_game could be:
  • minetest
  • minimal
  • etc...

Now Open: games/your_game/mods/default/init.lua

Add this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_node("default:Jleaves", {
    description = "Japanese Leaves",
    drawtype = "allfaces_optional",
    visual_scale = 1.3,
    tiles = {"default_Jleaves.png"},
    paramtype = "light",
    groups = {snappy=3, leafdecay=3, flammable=2},
    drop = {
        max_items = 1,
        items = {
            {
                -- player will get sapling with 1/20 chance
                items = {'default:sapling'},
                rarity = 20,
            },
            {
                -- player will get leaves only if he get no saplings,
                -- this is because max_items is 1
                items = {'default:Jleaves'},
            }
        }
    },
    sounds = default.node_sound_leaves_defaults(),
})


Now open games/your_game/game.conf

Add:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
JapaneseTree = 1


1 for activate, 0 disable.


Warring: it made that all new generated trees at any map chages. I recomed use a diferent minetest_game for every type of trees.

Now open games/your_game/mods/default/mapgen.lua

Add this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_alias("mapgen_leaves_japanese", "default:Jleaves")


For finish, add: Image, to games/your_game/mods/default/textures and rename it to: default_Jleaves.png

Download img: http://img803.imageshack.us/img803/7209/defaultjleaves.png

Bye
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Thu Nov 01, 2012 17:07

It would be better to create a mod that uses on_generate and sets some trees to japanese trees. That is easier to use.
 

OdnetninI
Member
 
Posts: 38
Joined: Sun Oct 21, 2012 08:20

by OdnetninI » Thu Nov 01, 2012 17:09

yeah, but i want to learn how internal game works, and i get this with engine.
Last edited by OdnetninI on Thu Nov 01, 2012 17:09, edited 1 time in total.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Thu Nov 01, 2012 18:36

great! this is beatiful!
 

User avatar
GloopMaster
Member
 
Posts: 213
Joined: Wed Aug 01, 2012 18:03

by GloopMaster » Thu Nov 01, 2012 23:58

they're called sakura trees. Just a heads-up ;)
Meow.

That is all.
 

User avatar
CaKeSs
Member
 
Posts: 48
Joined: Sat Oct 13, 2012 02:48

by CaKeSs » Sun Nov 11, 2012 04:13

First, I thought it was Bonsai.
lalalalala, Hit, dig, break, collect! -JusticeV before he fell in lava.
|Youtube||Unrealsoftware Account|Granite Mod|
 

OdnetninI
Member
 
Posts: 38
Joined: Sun Oct 21, 2012 08:20

by OdnetninI » Sun Nov 11, 2012 08:21

SOrry CaKeSs, they are sakura trees
 

Michael Eh?
Member
 
Posts: 282
Joined: Sun Jan 01, 2012 17:21

by Michael Eh? » Fri Jan 18, 2013 04:59

Actually they are Cherry trees which bloom in spring. Sakura means Cherry.

However, if this could be opened up to allow hooks to allow for more Biomes like snow or return of Jungle trees. I think that would make the game more open to development.

Maybe allowing them in certain areas of the map like extreme East or West of the map or certain North-South (latitudes) or elevations.

Like Palm/coconut trees only beside water and normal sand.
 

User avatar
Menche
Member
 
Posts: 994
Joined: Sat Jul 02, 2011 00:43

by Menche » Fri Jan 18, 2013 05:03

Probably the recommended way to implement tree is with L-Systems in lua.
An innocent kitten dies every time you top-post.
I am on the Voxelands Forums more often than here.
Try Voxelands (forked from Minetest 0.3) by darkrose
 

Spots
Member
 
Posts: 124
Joined: Tue Jul 24, 2012 12:12

by Spots » Fri Jan 18, 2013 05:18

this would make a great mod or addition to the new trees , cherry blossoms in pink and red and hydrangea trees in pinks and blues
 

Michael Eh?
Member
 
Posts: 282
Joined: Sun Jan 01, 2012 17:21

by Michael Eh? » Tue Feb 05, 2013 16:36

You are going to have to decide if you are going to include cherries and seedlings. maybe even cherry wood which would add some depth in colour. Alot of worlds buildings loose their organic look. Maybe along with bambo we can have an asian feel to the game which would bring in anime fans as well as Asian players.
 

User avatar
Gambit
Member
 
Posts: 452
Joined: Sat Oct 29, 2011 19:31

by Gambit » Tue Feb 12, 2013 03:49

Rename it "sakura", it's more easier to go by since that's what they're called.
Current Projects: MineToon | PixelBOX
Gambit's Checkmate Server - 43.65.296.232 - port: 30001
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Tue Feb 12, 2013 07:45

Gambit wrote:Rename it "sakura", it's more easier to go by since that's what they're called.
And less time to type too!

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Tue Feb 12, 2013 16:00

If someone can come up with a nice L-Systems model and biome information for me, I'll add this to moretrees.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Tue Feb 12, 2013 17:31

Image

that?
Last edited by Mito551 on Tue Feb 12, 2013 17:31, edited 1 time in total.
 


Return to Minetest Engine

Who is online

Users browsing this forum: No registered users and 6 guests

cron